From: K.Kosako Date: Thu, 22 Feb 2018 03:58:16 +0000 (+0900) Subject: add sign_on argument into parse_int() X-Git-Tag: v6.8.0~227 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09c62d2b975026b6d0fa049cab6c125c9902bd1f;p=onig add sign_on argument into parse_int() --- diff --git a/src/regparse.c b/src/regparse.c index 822b56d..795cd0f 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -6448,19 +6448,17 @@ parse_callout_of_code(Node** np, int cterm, UChar** src, UChar* end, ScanEnv* en } static int -parse_int(OnigEncoding enc, UChar* s, UChar* end, int* ri) +parse_int(OnigEncoding enc, UChar* s, UChar* end, int sign_on, int* ri) { int v; int d; int flag; - int first; UChar* p; OnigCodePoint c; if (s >= end) return ONIGERR_INVALID_CALLOUT_ARG; - first = 1; - flag = 1; + flag = 1; v = 0; p = s; while (p < end) { @@ -6473,13 +6471,13 @@ parse_int(OnigEncoding enc, UChar* s, UChar* end, int* ri) v = v * 10 + d; } - else if (first != 0 && (c == '-' || c == '+')) { + else if (sign_on != 0 && (c == '-' || c == '+')) { if (c == '-') flag = -1; } else return ONIGERR_INVALID_CALLOUT_ARG; - first = 0; + sign_on = 0; } *ri = flag * v; @@ -6551,7 +6549,7 @@ parse_callout_args(int cterm, UChar** src, UChar* end, int max_arg_num, switch (types[n]) { case ONIG_TYPE_INT: if (cn == 0) return ONIGERR_INVALID_CALLOUT_ARG; - r = parse_int(enc, buf, bufend, &(vals[n].i)); + r = parse_int(enc, buf, bufend, 1, &(vals[n].i)); if (r != ONIG_NORMAL) return r; break;