]> granicus.if.org Git - re2c/commitdiff
Added a few casts to 'printf' args to silence warnings caused by different type width...
authorUlya Trofimovich <skvadrik@gmail.com>
Sat, 13 Jul 2019 22:41:30 +0000 (23:41 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Sat, 13 Jul 2019 22:46:11 +0000 (23:46 +0100)
lib/bench.cc
lib/regexec_nfa_posix_backward.cc
lib/test.cc
src/debug/dump_dfa.cc
src/test/s_to_n32_unsafe/test.cc

index ef51b094b1dbf8bf04fa3f92cfff6f21faeb35fb..dccdf27b86a9ac178f5174ff62262e2fefd90ffc 100644 (file)
@@ -166,14 +166,14 @@ static uint32_t groupcnt(const char *r)
     return cnt;
 }
 
-static void bench(const char *r, std::vector<std::string> &ss, size_t n
+static void bench(const char *r, std::vector<std::string> &ss, uint32_t n
     , int mask, int need)
 {
     assert(!ss.empty());
     const char *s0 = ss[0].c_str();
 
-    fprintf(stderr, "\nr: %.*s..., s: %.*s..., n: %lu, %lu chars, %u groups\n"
-        , 30, r, 30, s0, n, strlen(r), groupcnt(r));
+    fprintf(stderr, "\nr: %.*s..., s: %.*s..., n: %u, %lu chars, %u groups\n"
+        , 30, r, 30, s0, n, (unsigned long)strlen(r), groupcnt(r));
 
     std::vector<Result> rs;
 
index 407e89194acaa852786af441dc7a7e5d9b83d948..93829b15a69b8297963dca83b89f77ed44bd269b 100644 (file)
@@ -88,15 +88,15 @@ static bool scan(psimctx_t &ctx, nfa_state_t *q, bool all);
 static bool relax_gor1(psimctx_t &ctx, const psimctx_t::conf_t &c);
 static void closure_posix_gor1(psimctx_t &ctx);
 static inline void closure_posix(psimctx_t &ctx);
-static inline size_t index(const nfa_state_t *s, const nfa_t &nfa);
+static inline uint32_t index(const nfa_state_t *s, const nfa_t &nfa);
 static void copy_offs(psimctx_t &ctx, const nfa_state_t *y, const nfa_state_t *x, tag_info_t info);
 static inline void accept_offsets(psimctx_t &ctx, const nfa_state_t *s);
 
 // debug
 static int D = 0;
-static void prtoff(psimctx_t &ctx, size_t x, bool newer);
-static inline void prtoff4(psimctx_t &ctx, size_t x);
-static inline void prtoff5(psimctx_t &ctx, size_t x);
+static void prtoff(psimctx_t &ctx, uint32_t x, bool newer);
+static inline void prtoff4(psimctx_t &ctx, uint32_t x);
+static inline void prtoff5(psimctx_t &ctx, uint32_t x);
 
 static regoff_t *offsets4 = NULL;
 static regoff_t *offsets5 = NULL;
@@ -181,9 +181,9 @@ int regexec_nfa_posix_backward(const regex_t *preg, const char *string
     return 0;
 }
 
-static size_t index(const nfa_state_t *s, const nfa_t &nfa)
+static uint32_t index(const nfa_state_t *s, const nfa_t &nfa)
 {
-    return static_cast<size_t>(s - nfa.states);
+    return static_cast<uint32_t>(s - nfa.states);
 }
 
 void closure_simple(psimctx_t &ctx)
@@ -261,7 +261,7 @@ static int32_t precedence(psimctx_t &ctx, const conf_t &x
     , const conf_t &y RE2C_ATTR((unused)))
 {
     DASSERT(x.state == y.state);
-    const size_t idx = index(x.state, ctx.nfa);
+    const uint32_t idx = index(x.state, ctx.nfa);
 
     const size_t ntags = ctx.nfa.tags.size();
     const regoff_t *ox = offsets5 + ntags * idx * 2;
@@ -269,7 +269,7 @@ static int32_t precedence(psimctx_t &ctx, const conf_t &x
 
     prtoff5(ctx, idx);
     prtoff4(ctx, idx);
-    if (D) fprintf(stderr, "prec %lu: ", idx);
+    if (D) fprintf(stderr, "prec %u: ", idx);
 
     for (size_t t = 0; t < ctx.nfa.tags.size(); t += 2) {
         const regoff_t offx = ox[2 * (t + 1)];
@@ -312,7 +312,7 @@ void closure_posix_gor1(psimctx_t &ctx)
         const regoff_t *oy = offsets6 + ntags * c->origin * 2;
         memcpy(ox, oy, ntags * sizeof(regoff_t) * 2);
 
-        if (D) fprintf(stderr, "restoring offsets %u to %ld\n"
+        if (D) fprintf(stderr, "restoring offsets %u to %u\n"
             , c->origin, index(c->state, ctx.nfa));
 
         relax_gor1(ctx, *c);
@@ -440,7 +440,7 @@ void closure_posix_gtop(psimctx_t &ctx)
         const regoff_t *oy = offsets6 + ntags * c->origin * 2;
         memcpy(ox, oy, ntags * sizeof(regoff_t) * 2);
 
-        if (D) fprintf(stderr, "restoring offsets %u to %lu\n"
+        if (D) fprintf(stderr, "restoring offsets %u to %u\n"
             , c->origin, index(c->state, ctx.nfa));
 
         relax_gtop(ctx, *c);
@@ -452,7 +452,7 @@ void closure_posix_gtop(psimctx_t &ctx)
         heap.pop();
         q->active = 0;
 
-        if (D) fprintf(stderr, "> %lu ", index(q, ctx.nfa));
+        if (D) fprintf(stderr, "> %u ", index(q, ctx.nfa));
         prtoff4(ctx, index(q, ctx.nfa));
 
         typedef psimctx_t::conf_t conf_t;
@@ -522,8 +522,7 @@ void make_one_step(psimctx_t &ctx, uint32_t sym)
         if (s->type == nfa_state_t::RAN) {
             for (const Range *r = s->ran.ran; r; r = r->next()) {
                 if (r->lower() <= sym && sym < r->upper()) {
-                    const conf_t c(s->ran.out
-                        , static_cast<uint32_t>(index(s, ctx.nfa)), HROOT);
+                    const conf_t c(s->ran.out, index(s, ctx.nfa), HROOT);
                     reach.push_back(c);
                     break;
                 }
@@ -579,12 +578,12 @@ static void copy_offs(psimctx_t &ctx, const nfa_state_t *y, const nfa_state_t *x
     , tag_info_t info)
 {
     const std::vector<Tag> &tags = ctx.nfa.tags;
-    const size_t
-        ntags = tags.size(),
+    const size_t ntags = tags.size();
+    const uint32_t
         xidx = index(x, ctx.nfa),
         yidx = index(y, ctx.nfa);
 
-    if (D) fprintf(stderr, "copying offsets %lu to %lu ", yidx, xidx);
+    if (D) fprintf(stderr, "copying offsets %u to %u ", yidx, xidx);
     prtoff4(ctx, yidx);
 
     regoff_t       *ox = offsets5 + ntags * xidx * 2;
@@ -611,25 +610,25 @@ static void copy_offs(psimctx_t &ctx, const nfa_state_t *y, const nfa_state_t *x
             }
         }
 
-        if (D) fprintf(stderr, "setting offset %lu[%u] to %lu\n"
-            , xidx, t, ox[2 * t]);
+        if (D) fprintf(stderr, "setting offset %u[%u] to %ld\n"
+            , xidx, t, (long)ox[2 * t]);
     }
 }
 
 void accept_offsets(psimctx_t &ctx, const nfa_state_t *s)
 {
-    const size_t idx = index(s, ctx.nfa);
+    const uint32_t idx = index(s, ctx.nfa);
     const size_t ntags = ctx.nfa.tags.size();
 
     const regoff_t *ox = offsets5 + ntags * idx * 2;
     regoff_t       *oy = offsets4 + ntags * idx * 2;
     memcpy(oy, ox, ntags * sizeof(regoff_t) * 2);
 
-    if (D) fprintf(stderr, "setting offsets %lu to ", idx);
+    if (D) fprintf(stderr, "setting offsets %u to ", idx);
     prtoff4(ctx, idx);
 }
 
-static void prtoff(psimctx_t &ctx, size_t x, bool newer)
+static void prtoff(psimctx_t &ctx, uint32_t x, bool newer)
 {
     if (!D) return;
 
@@ -637,19 +636,19 @@ static void prtoff(psimctx_t &ctx, size_t x, bool newer)
     const regoff_t *ox = (newer ? offsets5 : offsets4) + ntags * x * 2;
     for (size_t t = 0; t < ntags; t += 2) {
         fprintf(stderr, "(%ld,%ld)(%ld,%ld)"
-            , ox[2 * t],     ox[2 * (t + 1)]
-            , ox[2 * t + 1], ox[2 * (t + 1) + 1]);
+            , (long)ox[2 * t],     (long)ox[2 * (t + 1)]
+            , (long)ox[2 * t + 1], (long)ox[2 * (t + 1) + 1]);
     }
     fprintf(stderr, "\n");
 }
 
-static void prtoff4(psimctx_t &ctx, size_t x)
+static void prtoff4(psimctx_t &ctx, uint32_t x)
 {
     if (D) fprintf(stderr, "off4: ");
     prtoff(ctx, x, false);
 }
 
-static void prtoff5(psimctx_t &ctx, size_t x)
+static void prtoff5(psimctx_t &ctx, uint32_t x)
 {
     if (D) fprintf(stderr, "off5: ");
     prtoff(ctx, x, true);
index 4ff953c7802c93b1b700a3d35318a8a85b709499..b2b340c0b910890b4e536ac399c3ccfe2f9dd0c1 100644 (file)
@@ -60,8 +60,8 @@ static int test(const char *pattern, const char *string
                 "\tpmatch[%u].rm_so = %ld (expected %ld)\n"
                 "\tpmatch[%u].rm_eo = %ld (expected %ld)\n"
                 , prefix, pattern, string
-                , i, have.rm_so, so
-                , i, have.rm_eo, eo);
+                , i, (long)have.rm_so, (long)so
+                , i, (long)have.rm_eo, (long)eo);
             goto end;
         }
     }
index ecef2ae70c612b86573148fec9bc752992fdefa3..be45255cab4e07b1d140f84284f14a87f18a7374 100644 (file)
@@ -321,7 +321,7 @@ void dump_clstats(const ctx_t &ctx)
     const closure_stats_t &cs = ctx.dc_clstats;
     if (ctx.dc_opts->dump_closure_stats) {
         fprintf(stderr, "scans: %-10u prec: %-10u length: %-10lu\n"
-            , cs.nscans, cs.nprec, static_cast<uint64_t>(cs.length));
+            , cs.nscans, cs.nprec, (unsigned long)cs.length);
     }
 }
 
index a1f877708d2cb77aeca414b58c4bd1bf2a15f147..9f30657ed86c316c90618f13ddd72970aa4b7ca4 100644 (file)
@@ -33,7 +33,7 @@ static int32_t test_u (uint64_t i)
     uint32_t u = i == 0; // not equal to i
     if (re2c::s_to_u32_unsafe (s_start, s_end, u) && u != i)
     {
-        fprintf (stderr, "unsigned: expected: %lu, got: %u\n", i, u);
+        fprintf (stderr, "unsigned: expected: %lu, got: %u\n", (unsigned long)i, u);
         return 1;
     }
     return 0;
@@ -54,7 +54,7 @@ static int32_t test_i (int64_t i)
     int32_t j = i == 0; // not equal to i
     if (re2c::s_to_i32_unsafe (s_start, s_end, j) && j != i)
     {
-        fprintf (stderr, "signed: expected: %ld, got: %d\n", i, j);
+        fprintf (stderr, "signed: expected: %ld, got: %d\n", (long)i, j);
         return 1;
     }
     return 0;