Skip to content

Commit

Permalink
escape warnings for VisualStudio 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
kkos committed Mar 21, 2021
1 parent 40ccaab commit c5a2cdd
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
(MEM_STATUS_AT((reg)->push_mem_end, (idx)) != 0 ? \
STACK_AT(mem_end_stk[idx].i)->u.mem.pstr : mem_end_stk[idx].s)

#define DIST_CAST(d) (int )(d)


static int forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start, UChar* range, UChar** low, UChar** high);

static int
Expand Down Expand Up @@ -4495,7 +4498,7 @@ regset_search_body_position_lead(OnigRegSet* set,
sr[i].state = SRS_DEAD;
if (reg->optimize != OPTIMIZE_NONE) {
if (reg->dist_max != INFINITE_LEN) {
if (end - range > reg->dist_max)
if (end - range > DIST_CAST(reg->dist_max))
sch_range = (UChar* )range + reg->dist_max;
else
sch_range = (UChar* )end;
Expand Down Expand Up @@ -5158,7 +5161,7 @@ forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start,

p = start;
if (reg->dist_min != 0) {
if (end - p <= reg->dist_min)
if (end - p <= DIST_CAST(reg->dist_min))
return 0; /* fail */

if (ONIGENC_IS_SINGLEBYTE(reg->enc)) {
Expand Down Expand Up @@ -5191,7 +5194,7 @@ forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start,
}

if (p && p < range) {
if (p - start < reg->dist_min) {
if (p - start < DIST_CAST(reg->dist_min)) {
retry_gate:
pprev = p;
p += enclen(reg->enc, p);
Expand Down Expand Up @@ -5236,7 +5239,7 @@ forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start,
}
else {
if (reg->dist_max != INFINITE_LEN) {
if (p - str < reg->dist_max) {
if (p - str < DIST_CAST(reg->dist_max)) {
*low = (UChar* )str;
}
else {
Expand All @@ -5247,7 +5250,7 @@ forward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* start,
}
}
/* no needs to adjust *high, *high is used as range check only */
if (p - str < reg->dist_min)
if (p - str < DIST_CAST(reg->dist_min))
*high = (UChar* )str;
else
*high = p - reg->dist_min;
Expand Down Expand Up @@ -5332,13 +5335,13 @@ backward_search(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
}

if (reg->dist_max != INFINITE_LEN) {
if (p - str < reg->dist_max)
if (p - str < DIST_CAST(reg->dist_max))
*low = (UChar* )str;
else
*low = p - reg->dist_max;

if (reg->dist_min != 0) {
if (p - str < reg->dist_min)
if (p - str < DIST_CAST(reg->dist_min))
*high = (UChar* )str;
else
*high = p - reg->dist_min;
Expand Down Expand Up @@ -5482,13 +5485,13 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end,

if (range > start) {
if (reg->anc_dist_max != INFINITE_LEN &&
min_semi_end - start > reg->anc_dist_max) {
min_semi_end - start > DIST_CAST(reg->anc_dist_max)) {
start = min_semi_end - reg->anc_dist_max;
if (start < end)
start = onigenc_get_right_adjust_char_head(reg->enc, str, start);
}
if (max_semi_end - (range - 1) < reg->anc_dist_min) {
if (max_semi_end - str + 1 < reg->anc_dist_min)
if (max_semi_end - (range - 1) < DIST_CAST(reg->anc_dist_min)) {
if (max_semi_end - str + 1 < DIST_CAST(reg->anc_dist_min))
goto mismatch_no_msa;
else
range = max_semi_end - reg->anc_dist_min + 1;
Expand All @@ -5500,11 +5503,11 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end,
}
else {
if (reg->anc_dist_max != INFINITE_LEN &&
min_semi_end - range > reg->anc_dist_max) {
min_semi_end - range > DIST_CAST(reg->anc_dist_max)) {
range = min_semi_end - reg->anc_dist_max;
}
if (max_semi_end - start < reg->anc_dist_min) {
if (max_semi_end - str < reg->anc_dist_min)
if (max_semi_end - start < DIST_CAST(reg->anc_dist_min)) {
if (max_semi_end - str < DIST_CAST(reg->anc_dist_min))
goto mismatch_no_msa;
else {
start = max_semi_end - reg->anc_dist_min;
Expand Down Expand Up @@ -5575,7 +5578,7 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end,
if (reg->dist_max == INFINITE_LEN)
sch_range = (UChar* )end;
else {
if ((end - range) < reg->dist_max)
if (end - range < DIST_CAST(reg->dist_max))
sch_range = (UChar* )end;
else {
sch_range = (UChar* )range + reg->dist_max;
Expand Down Expand Up @@ -5651,14 +5654,14 @@ search_in_range(regex_t* reg, const UChar* str, const UChar* end,
else
adjrange = (UChar* )end;

if (end - range > reg->dist_min)
if (end - range > DIST_CAST(reg->dist_min))
min_range = range + reg->dist_min;
else
min_range = end;

if (reg->dist_max != INFINITE_LEN) {
do {
if (end - s > reg->dist_max)
if (end - s > DIST_CAST(reg->dist_max))
sch_start = s + reg->dist_max;
else {
sch_start = onigenc_get_prev_char_head(reg->enc, str, end);
Expand Down

0 comments on commit c5a2cdd

Please sign in to comment.