Skip to content

Commit bcaec47

Browse files
committed
Fix remimu attempt 2
1 parent 7c46c87 commit bcaec47

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/engine/external/remimu.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ USAGE
111111
assert(!e);
112112
113113
int64_t match_len = regex_match(tokens, "23.53) ", 0, 0, 0, 0);
114-
printf("########### return: " PRId64 "\n", match_len);
114+
printf("########### return: %" PRId64 "\n", match_len);
115115
116116
// with captures:
117117
@@ -126,9 +126,9 @@ USAGE
126126
memset(cap_span, 0xFF, sizeof(cap_span));
127127
128128
int64_t matchlen = regex_match(tokens, "aaaaaabbbabaqa", 0, 5, cap_pos, cap_span);
129-
printf("Match length: " PRId64 "\n", matchlen);
129+
printf("Match length: %" PRId64 "\n", matchlen);
130130
for (int i = 0; i < 5; i++)
131-
printf("Capture %d: " PRIu64 " plus " PRIu64 "\n", i, cap_pos[i], cap_span[i]);
131+
printf("Capture %d: %" PRIu64 " plus " PRIu64 "\n", i, cap_pos[i], cap_span[i]);
132132
133133
// for debugging
134134
print_regex_tokens(tokens);
@@ -961,7 +961,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
961961
} \
962962
rewind_stack[stack_n++] = s; \
963963
_P_TEXT_HIGHLIGHTED(); \
964-
IF_VERBOSE(printf("-- saving rewind state k %u i " PRIu64 " rmin " PRIu64 " rmax " PRIu64 " (line %d) (depth %d prev %d)\n", s.k, i, range_min, range_max, __LINE__, stack_n, s.prev);) \
964+
IF_VERBOSE(printf("-- saving rewind state k %u i %" PRIu64 " rmin %" PRIu64 " rmax %" PRIu64 " (line %d) (depth %d prev %d)\n", s.k, i, range_min, range_max, __LINE__, stack_n, s.prev);) \
965965
} while (0)
966966
#define _REWIND_DO_SAVE_DUMMY(K) _REWIND_DO_SAVE_RAW(K, 1)
967967
#define _REWIND_DO_SAVE(K) _REWIND_DO_SAVE_RAW(K, 0)
@@ -983,7 +983,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
983983
q_group_stack[tokens[k].mask[0]] = rewind_stack[stack_n].prev; \
984984
} \
985985
_P_TEXT_HIGHLIGHTED(); \
986-
IF_VERBOSE(printf("-- rewound to k %u i " PRIu64 " rmin " PRIu64 " rmax " PRIu64 " (kind %d prev %d)\n", k, i, range_min, range_max, tokens[k].kind, rewind_stack[stack_n].prev);) \
986+
IF_VERBOSE(printf("-- rewound to k %u i %" PRIu64 " rmin %" PRIu64 " rmax %" PRIu64 " (kind %d prev %d)\n", k, i, range_min, range_max, tokens[k].kind, rewind_stack[stack_n].prev);) \
987987
k -= 1; \
988988
} while (0)
989989
// the -= 1 is because of the k++ in the for loop
@@ -1009,7 +1009,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
10091009
return -2;
10101010
}
10111011
}
1012-
IF_VERBOSE(printf("k: " PRIu32 "\ti: " PRIu64 "\tl: %d\tstack_n: %d\n", k, i, limit, (int)stack_n);)
1012+
IF_VERBOSE(printf("k: %" PRIu32 "\ti: %" PRIu64 "\tl: %d\tstack_n: %" PRIu64 "\n", k, i, limit, (int)stack_n);)
10131013
_P_TEXT_HIGHLIGHTED();
10141014
if (tokens[k].kind == REMIMU_KIND_CARET)
10151015
{
@@ -1057,7 +1057,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
10571057
{
10581058
if (!just_rewinded)
10591059
{
1060-
IF_VERBOSE(printf("hit OPEN. i is " PRIu64 ", depth is %d\n", i, stack_n);)
1060+
IF_VERBOSE(printf("hit OPEN. i is %" PRIu64 ", depth is %d\n", i, stack_n);)
10611061
// need this to be able to detect and reject zero-size matches
10621062
//q_group_state[tokens[k].mask[0]] = i;
10631063

@@ -1079,12 +1079,12 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
10791079
}
10801080
else
10811081
{
1082-
IF_VERBOSE(printf("rewinded into OPEN. i is " PRIu64 ", depth is %d\n", i, stack_n);)
1082+
IF_VERBOSE(printf("rewinded into OPEN. i is %" PRIu64 ", depth is %d\n", i, stack_n);)
10831083
just_rewinded = 0;
10841084

10851085
uint64_t orig_k = k;
10861086

1087-
IF_VERBOSE(printf("--- trying to try another alternation, start k is " PRIu32 ", rmin is " PRIu64 "\n", k, range_min);)
1087+
IF_VERBOSE(printf("--- trying to try another alternation, start k is %" PRIu32 ", rmin is %" PRIu64 "\n", k, range_min);)
10881088

10891089
if (range_min != 0)
10901090
{
@@ -1097,12 +1097,12 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
10971097
else if (tokens[k-1].kind == REMIMU_KIND_OPEN || tokens[k-1].kind == REMIMU_KIND_NCOPEN)
10981098
k += tokens[k-1].mask[15] - 1;
10991099

1100-
IF_VERBOSE(printf("kamakama " PRIu32 " %d\n", k, (int)tokens[k].kind);)
1100+
IF_VERBOSE(printf("kamakama %" PRIu32 " %d\n", k, (int)tokens[k].kind);)
11011101

11021102
if (tokens[k].kind == REMIMU_KIND_END) // unbalanced parens
11031103
return -3;
11041104

1105-
IF_VERBOSE(printf("---?!?! " PRIu64 ", " PRIu32 "\n", k, q_group_state[tokens[k].mask[0]]);)
1105+
IF_VERBOSE(printf("---?!?! %" PRIu64 ", %" PRIu32 "\n", k, q_group_state[tokens[k].mask[0]]);)
11061106
if (tokens[k].kind == REMIMU_KIND_CLOSE)
11071107
{
11081108
IF_VERBOSE(puts("!!~!~!~~~~!!~~!~ hit CLOSE. rewinding");)
@@ -1129,13 +1129,13 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
11291129
REMIMU_ASSERT(tokens[k].kind == REMIMU_KIND_OR);
11301130
}
11311131

1132-
IF_VERBOSE(printf("--- FOUND ALTERNATION for paren at k " PRIu64 " at k " PRIu32 "\n", orig_k, k);)
1132+
IF_VERBOSE(printf("--- FOUND ALTERNATION for paren at k %" PRIu64 " at k %" PRIu32 "\n", orig_k, k);)
11331133

11341134
ptrdiff_t k_diff = k - orig_k;
11351135
range_min = k_diff + 1;
11361136

11371137
IF_VERBOSE(puts("(saving in paren after rewinding and looking for next regex token to check)");)
1138-
IF_VERBOSE(printf(PRIu64 "\n", range_min);)
1138+
IF_VERBOSE(printf("%" PRIu64 "\n", range_min);)
11391139
_REWIND_DO_SAVE(k - k_diff);
11401140
}
11411141
}
@@ -1157,14 +1157,14 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
11571157
{
11581158
uint32_t prev = q_group_stack[tokens[k].mask[0]];
11591159

1160-
IF_VERBOSE(printf("qrqrqrqrqrqrqrq------- k " PRIu32 ", gs %d, gaz %d, i " PRIu64 ", tklo %d, rmin " PRIu64 ", tkhi %d, rmax " PRIu64 ", prev " PRIu32 ", sn %d\n", k, q_group_state[tokens[k].mask[0]], (int)q_group_accepts_zero[tokens[k].mask[0]], i, (int)tokens[k].count_lo, range_min, (int)tokens[k].count_hi, range_max, prev, (int)stack_n);)
1160+
IF_VERBOSE(printf("qrqrqrqrqrqrqrq------- k %" PRIu32 ", gs %d, gaz %d, i %" PRIu64 ", tklo %d, rmin %" PRIu64 ", tkhi %d, rmax %" PRIu64 ", prev %" PRIu32 ", sn %d\n", k, q_group_state[tokens[k].mask[0]], (int)q_group_accepts_zero[tokens[k].mask[0]], i, (int)tokens[k].count_lo, range_min, (int)tokens[k].count_hi, range_max, prev, (int)stack_n);)
11611161

11621162
range_max = tokens[k].count_hi;
11631163
range_max -= 1;
11641164
range_min = q_group_accepts_zero[tokens[k].mask[0]] ? 0 : tokens[k].count_lo;
11651165
//REMIMU_ASSERT(q_group_state[tokens[k + tokens[k].pair_offset].mask[0]] <= i);
11661166
//if (prev) REMIMU_ASSERT(rewind_stack[prev].i <= i);
1167-
IF_VERBOSE(printf("qzqzqzqzqzqzqzq------- rmin " PRIu64 ", rmax " PRIu64 "\n", range_min, range_max);)
1167+
IF_VERBOSE(printf("qzqzqzqzqzqzqzq------- rmin %" PRIu64 ", rmax %" PRIu64 "\n", range_min, range_max);)
11681168

11691169
// minimum requirement not yet met
11701170
if (q_group_state[tokens[k].mask[0]] + 1 < range_min)
@@ -1180,7 +1180,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
11801180
// maximum allowance exceeded
11811181
else if (tokens[k].count_hi != 0 && q_group_state[tokens[k].mask[0]] + 1 > range_max)
11821182
{
1183-
IF_VERBOSE(printf("hit maximum allowed instances of a quantified group " PRIu32 " " PRIu64 "\n", q_group_state[tokens[k].mask[0]], range_max);)
1183+
IF_VERBOSE(printf("hit maximum allowed instances of a quantified group %" PRIu32 " %" PRIu64 "\n", q_group_state[tokens[k].mask[0]], range_max);)
11841184
range_max -= 1;
11851185
_REWIND_OR_ABORT();
11861186
continue;
@@ -1203,8 +1203,8 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
12031203
// reject zero-length matches
12041204
if ((force_zero || (prev != 0 && rewind_stack[prev].i == i))) // && q_group_state[tokens[k].mask[0]] > 0
12051205
{
1206-
IF_VERBOSE(printf("rejecting zero-length match..... %d " PRIu64 " " PRIu64 "\n", (int)force_zero, rewind_stack[prev].i, i);)
1207-
IF_VERBOSE(printf(PRIu32 " (k: " PRIu64 ")\n", q_group_state[tokens[k].mask[0]], k);)
1206+
IF_VERBOSE(printf("rejecting zero-length match..... %d %" PRIu64 " %" PRIu64 "\n", (int)force_zero, rewind_stack[prev].i, i);)
1207+
IF_VERBOSE(printf("%" PRIu32 " (k: %" PRIu64 ")\n", q_group_state[tokens[k].mask[0]], k);)
12081208

12091209
q_group_accepts_zero[tokens[k].mask[0]] = 1;
12101210
_REWIND_OR_ABORT();
@@ -1213,9 +1213,9 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
12131213
}
12141214
else if (tokens[k].mode & REMIMU_MODE_LAZY) // lazy
12151215
{
1216-
IF_VERBOSE(printf("nidnfasidfnidfndifn------- " PRIu32 ", %d, " PRIu64 "\n", q_group_state[tokens[k].mask[0]], (int)tokens[k].count_lo, range_min);)
1216+
IF_VERBOSE(printf("nidnfasidfnidfndifn------- %" PRIu32 ", %d, %" PRIu64 "\n", q_group_state[tokens[k].mask[0]], (int)tokens[k].count_lo, range_min);)
12171217
if (prev)
1218-
IF_VERBOSE(printf("lazy doesn't think it's zero-length. prev i " PRIu64 " vs i " PRIu64 " (depth %d)\n", rewind_stack[prev].i, i, (int)stack_n);)
1218+
IF_VERBOSE(printf("lazy doesn't think it's zero-length. prev i %" PRIu64 " vs i %" PRIu64 " (depth %d)\n", rewind_stack[prev].i, i, (int)stack_n);)
12191219
// continue on to past the group; group retry is in rewind state
12201220
q_group_state[tokens[k].mask[0]] += 1;
12211221
_REWIND_DO_SAVE(k);
@@ -1272,11 +1272,11 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
12721272
else
12731273
{
12741274
// greedy. if we're going to go outside the acceptable range, rewind
1275-
IF_VERBOSE(printf("kufukufu %d " PRIu64 "\n", (int)tokens[k].count_lo, range_min);)
1275+
IF_VERBOSE(printf("kufukufu %d %" PRIu64 "\n", (int)tokens[k].count_lo, range_min);)
12761276
//uint64_t old_i = i;
12771277
if (q_group_state[tokens[k].mask[0]] < range_min && !q_group_accepts_zero[tokens[k].mask[0]])
12781278
{
1279-
IF_VERBOSE(printf("rewinding from greedy group because we're going to go out of range (" PRIu32 " vs " PRIu64 ")\n", q_group_state[tokens[k].mask[0]], range_min);)
1279+
IF_VERBOSE(printf("rewinding from greedy group because we're going to go out of range (%" PRIu32 " vs %" PRIu64 ")\n", q_group_state[tokens[k].mask[0]], range_min);)
12801280
//i = old_i;
12811281
_REWIND_OR_ABORT();
12821282
}
@@ -1340,7 +1340,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
13401340
n += 1;
13411341
}
13421342
range_max = n;
1343-
IF_VERBOSE(printf("set rmin to " PRIu64 " and rmax to " PRIu64 " on entry into normal greedy token with k " PRIu32 "\n", range_min, range_max, k);)
1343+
IF_VERBOSE(printf("set rmin to %" PRIu64 " and rmax to %" PRIu64 " on entry into normal greedy token with k %" PRIu32 "\n", range_min, range_max, k);)
13441344
if (!(tokens[k].mode & REMIMU_MODE_POSSESSIVE))
13451345
_REWIND_DO_SAVE(k);
13461346
}
@@ -1370,7 +1370,7 @@ REMIMU_FUNC_VISIBILITY int64_t regex_match(const RegexToken * tokens, const char
13701370
}
13711371
else
13721372
{
1373-
//IF_VERBOSE(printf("comparing rmin " PRIu64 " and rmax " PRIu64 " token with k " PRIu32 "\n", range_min, range_max, k);)
1373+
//IF_VERBOSE(printf("comparing rmin %" PRIu64 " and rmax %" PRIu64 " token with k %" PRIu32 "\n", range_min, range_max, k);)
13741374
if (range_max > range_min)
13751375
{
13761376
IF_VERBOSE(printf("greedy normal going back (k: %d)\n", k);)

0 commit comments

Comments
 (0)