diff options
author | David Mitchell <davem@iabyn.com> | 2015-09-09 13:02:40 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-10-02 11:18:17 +0100 |
commit | 73e8ff0004522621dfb42f01966853b51d5522a6 (patch) | |
tree | 1e2b70f790f84ab21c55ecfc85291511408af7ed /regexec.c | |
parent | 0fa1f7e4e66a455cab6ccf1f9c49f2373c1ced80 (diff) | |
download | perl-73e8ff0004522621dfb42f01966853b51d5522a6.tar.gz |
fix some 32/64-bit compiler warnings
Some bits of code don't do well on a 32-bit system with 64-bit ints
(-Duse64bitint)
In particular:
_MEM_WRAP_NEEDS_RUNTIME_CHECK:
if sizeof(MEM_SIZE) > sizeof(n), then the shift count could be
negative
S_regmatch:
ln and n were two different sizes and signesses, so comparing them
warned. Since they were being mis-used as two convenient temporary
booleans anyway, just use temporary booleans instead.
Perl_sv_vcatpvfn_flags:
the test/assertion (IV)elen < 0 was (I think) being used to test for
signed/unsigned conversion wrap-around. elen is of type STRLEN which
is a pointer-based type, so can be 32-bit while IV is 64-bit. Instead
compare it to half the maximum value of a STRLEN var to see if it may
have wrapped.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 48 |
1 files changed, 30 insertions, 18 deletions
@@ -1205,10 +1205,10 @@ Perl_re_intuit_start(pTHX_ * didn't contradict, so just retry the anchored "other" * substr */ DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, - " Found /%s^%s/m, rescanning for anchored from offset %ld (rx_origin now %"IVdf")...\n", + " Found /%s^%s/m, rescanning for anchored from offset %"IVdf" (rx_origin now %"IVdf")...\n", PL_colors[0], PL_colors[1], - (long)(rx_origin - strbeg + prog->anchored_offset), - (long)(rx_origin - strbeg) + (IV)(rx_origin - strbeg + prog->anchored_offset), + (IV)(rx_origin - strbeg) )); goto do_other_substr; } @@ -5526,6 +5526,8 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) /* FALLTHROUGH */ case BOUNDL: /* /\b/l */ + { + bool b1, b2; _CHECK_AND_WARN_PROBLEMATIC_LOCALE; if (FLAGS(scan) != TRADITIONAL_BOUND) { @@ -5538,27 +5540,28 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) if (utf8_target) { if (locinput == reginfo->strbeg) - ln = isWORDCHAR_LC('\n'); + b1 = isWORDCHAR_LC('\n'); else { - ln = isWORDCHAR_LC_utf8(reghop3((U8*)locinput, -1, + b1 = isWORDCHAR_LC_utf8(reghop3((U8*)locinput, -1, (U8*)(reginfo->strbeg))); } - n = (NEXTCHR_IS_EOS) + b2 = (NEXTCHR_IS_EOS) ? isWORDCHAR_LC('\n') : isWORDCHAR_LC_utf8((U8*)locinput); } else { /* Here the string isn't utf8 */ - ln = (locinput == reginfo->strbeg) + b1 = (locinput == reginfo->strbeg) ? isWORDCHAR_LC('\n') : isWORDCHAR_LC(UCHARAT(locinput - 1)); - n = (NEXTCHR_IS_EOS) + b2 = (NEXTCHR_IS_EOS) ? isWORDCHAR_LC('\n') : isWORDCHAR_LC(nextchr); } - if (to_complement ^ (ln == n)) { + if (to_complement ^ (b1 == b2)) { sayNO; } break; + } case NBOUND: /* /\B/ */ to_complement = 1; @@ -5575,6 +5578,8 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) /* FALLTHROUGH */ case BOUNDA: /* /\b/a */ + { + bool b1, b2; bound_ascii_match_only: /* Here the string isn't utf8, or is utf8 and only ascii characters @@ -5586,16 +5591,17 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) * 2) it is a multi-byte character, in which case the final byte is * never mistakable for ASCII, and so the test will say it is * not a word character, which is the correct answer. */ - ln = (locinput == reginfo->strbeg) + b1 = (locinput == reginfo->strbeg) ? isWORDCHAR_A('\n') : isWORDCHAR_A(UCHARAT(locinput - 1)); - n = (NEXTCHR_IS_EOS) + b2 = (NEXTCHR_IS_EOS) ? isWORDCHAR_A('\n') : isWORDCHAR_A(nextchr); - if (to_complement ^ (ln == n)) { + if (to_complement ^ (b1 == b2)) { sayNO; } break; + } case NBOUNDU: /* /\B/u */ to_complement = 1; @@ -5609,15 +5615,18 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) bound_utf8: switch((bound_type) FLAGS(scan)) { case TRADITIONAL_BOUND: - ln = (locinput == reginfo->strbeg) + { + bool b1, b2; + b1 = (locinput == reginfo->strbeg) ? 0 /* isWORDCHAR_L1('\n') */ : isWORDCHAR_utf8(reghop3((U8*)locinput, -1, (U8*)(reginfo->strbeg))); - n = (NEXTCHR_IS_EOS) + b2 = (NEXTCHR_IS_EOS) ? 0 /* isWORDCHAR_L1('\n') */ : isWORDCHAR_utf8((U8*)locinput); - match = cBOOL(ln != n); + match = cBOOL(b1 != b2); break; + } case GCB_BOUND: if (locinput == reginfo->strbeg || NEXTCHR_IS_EOS) { match = TRUE; /* GCB always matches at begin and @@ -5679,14 +5688,17 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) else { /* Not utf8 target */ switch((bound_type) FLAGS(scan)) { case TRADITIONAL_BOUND: - ln = (locinput == reginfo->strbeg) + { + bool b1, b2; + b1 = (locinput == reginfo->strbeg) ? 0 /* isWORDCHAR_L1('\n') */ : isWORDCHAR_L1(UCHARAT(locinput - 1)); - n = (NEXTCHR_IS_EOS) + b2 = (NEXTCHR_IS_EOS) ? 0 /* isWORDCHAR_L1('\n') */ : isWORDCHAR_L1(nextchr); - match = cBOOL(ln != n); + match = cBOOL(b1 != b2); break; + } case GCB_BOUND: if (locinput == reginfo->strbeg || NEXTCHR_IS_EOS) { |