diff options
author | Hugo van der Sanden <hv@crypt.org> | 2015-02-23 16:48:15 +0000 |
---|---|---|
committer | Hugo van der Sanden <hv@crypt.org> | 2015-03-09 22:15:46 +0000 |
commit | 22ff313068aa37b1a24855e760e71ee9a20a1a90 (patch) | |
tree | 09da195258e4a85e42a39dd24d7c60c849409ef1 /regcomp.c | |
parent | 35cd12d12a5a5777098caf722f8748b39c3be45f (diff) | |
download | perl-22ff313068aa37b1a24855e760e71ee9a20a1a90.tar.gz |
[perl #123814] replace grok_atou with grok_atoUV
Some questions and loose ends:
XXX gv.c:S_gv_magicalize - why are we using SSize_t for paren?
XXX mg.c:Perl_magic_set - need appopriate error handling for $)
XXX regcomp.c:S_reg - need to check if we do the right thing if parno
was not grokked
Perl_get_debug_opts should probably return something unsigned; not sure
if that's something we can change.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 45 |
1 files changed, 28 insertions, 17 deletions
@@ -10121,10 +10121,13 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) RExC_parse++; is_neg = TRUE; } - unum = grok_atou(RExC_parse, &endptr); - num = (unum > I32_MAX) ? I32_MAX : (I32)unum; - if (endptr) - RExC_parse = (char*)endptr; + if (grok_atoUV(RExC_parse, &unum, &endptr) + && unum <= I32_MAX + ) { + num = (I32)unum; + RExC_parse = (char*)endptr; + } else + num = I32_MAX; if (is_neg) { /* Some limit for num? */ num = -num; @@ -10308,9 +10311,14 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) RExC_parse++; parno = 0; if (RExC_parse[0] >= '1' && RExC_parse[0] <= '9' ) { - parno = grok_atou(RExC_parse, &endptr); - if (endptr) + UV uv; + if (grok_atoUV(RExC_parse, &uv, &endptr) + && uv <= I32_MAX + ) { + parno = (I32)uv; RExC_parse = (char*)endptr; + } + /* XXX else what? */ } else if (RExC_parse[0] == '&') { SV *sv_dat; RExC_parse++; @@ -10327,9 +10335,14 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) /* (?(1)...) */ char c; char *tmp; - parno = grok_atou(RExC_parse, &endptr); - if (endptr) - RExC_parse = (char*)endptr; + UV uv; + if (grok_atoUV(RExC_parse, &uv, &endptr) + && uv <= I32_MAX + ) { + parno = (I32)uv; + RExC_parse = (char*)endptr; + } + /* XXX else what? */ ret = reganode(pRExC_state, GROUPP, parno); insert_if_check_paren: @@ -10815,8 +10828,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth) maxpos = next; RExC_parse++; if (isDIGIT(*RExC_parse)) { - uv = grok_atou(RExC_parse, &endptr); - if (!endptr) + if (!grok_atoUV(RExC_parse, &uv, &endptr)) vFAIL("Invalid quantifier in {,}"); if (uv >= REG_INFTY) vFAIL2("Quantifier in {,} bigger than %d", REG_INFTY - 1); @@ -10829,8 +10841,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth) else maxpos = RExC_parse; if (isDIGIT(*maxpos)) { - uv = grok_atou(maxpos, &endptr); - if (!endptr) + if (!grok_atoUV(maxpos, &uv, &endptr)) vFAIL("Invalid quantifier in {,}"); if (uv >= REG_INFTY) vFAIL2("Quantifier in {,} bigger than %d", REG_INFTY - 1); @@ -11531,10 +11542,10 @@ static I32 S_backref_value(char *p) { const char* endptr; - UV val = grok_atou(p, &endptr); - if (endptr == p || endptr == NULL || val > I32_MAX) - return I32_MAX; - return (I32)val; + UV val; + if (grok_atoUV(p, &val, &endptr) && val <= I32_MAX) + return (I32)val; + return I32_MAX; } |