From: K.Kosako Date: Wed, 12 Sep 2018 01:54:24 +0000 (+0900) Subject: rename positive_int_multiply() to onig_positive_int_multiply() X-Git-Tag: v6.9.1~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9745359f1510b3435244ac9915e2847f18bc0d88;p=onig rename positive_int_multiply() to onig_positive_int_multiply() --- diff --git a/src/regcomp.c b/src/regcomp.c index ee534ed..7f382c8 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -138,6 +138,17 @@ int_multiply_cmp(int x, int y, int v) return 1; } +extern int +onig_positive_int_multiply(int x, int y) +{ + if (x == 0 || y == 0) return 0; + + if (x < INT_MAX / y) + return x * y; + else + return -1; +} + #ifndef PLATFORM_UNALIGNED_WORD_ACCESS static unsigned char PadBuf[WORD_ALIGNMENT_SIZE]; diff --git a/src/regint.h b/src/regint.h index cb7cd11..09a4676 100644 --- a/src/regint.h +++ b/src/regint.h @@ -841,6 +841,7 @@ extern void onig_transfer P_((regex_t* to, regex_t* from)); extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, void* /* CClassNode* */ cc)); extern RegexExt* onig_get_regex_ext(regex_t* reg); extern int onig_ext_set_pattern(regex_t* reg, const UChar* pattern, const UChar* pattern_end); +extern int onig_positive_int_multiply(int x, int y); #ifdef USE_CALLOUT diff --git a/src/regparse.c b/src/regparse.c index 433da20..edca44e 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -198,17 +198,6 @@ onig_set_parse_depth_limit(unsigned int depth) return 0; } -static int -positive_int_multiply(int x, int y) -{ - if (x == 0 || y == 0) return 0; - - if (x < INT_MAX / y) - return x * y; - else - return -1; -} - static void bbuf_free(BBuf* bbuf) { @@ -3877,7 +3866,7 @@ onig_reduce_nested_quantifier(Node* pnode, Node* cnode) if (pnum < 0 || cnum < 0) { if ((p->lower == p->upper) && ! IS_REPEAT_INFINITE(p->upper)) { if ((c->lower == c->upper) && ! IS_REPEAT_INFINITE(c->upper)) { - int n = positive_int_multiply(p->lower, c->lower); + int n = onig_positive_int_multiply(p->lower, c->lower); if (n >= 0) { p->lower = p->upper = n; NODE_BODY(pnode) = NODE_BODY(cnode);