]> granicus.if.org Git - onig/commitdiff
define ONIGENC_IS_CODE_DIGIT_ASCII()
authorK.Kosako <kosako@sofnec.co.jp>
Thu, 10 Aug 2017 01:56:48 +0000 (10:56 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Thu, 10 Aug 2017 01:56:48 +0000 (10:56 +0900)
src/regint.h
src/regparse.c

index 10a70b3f69597685601a424e9ac62f92b37db09a..00cb8ca991a8b397577a9f53ea130af1902a1d97 100644 (file)
@@ -282,10 +282,13 @@ typedef unsigned int  MemStatusType;
 
 #define INT_MAX_LIMIT           ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
 
+#define ONIGENC_IS_CODE_DIGIT_ASCII(enc, code) \
+  ((code) < 128 && ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_DIGIT))
+
 #define DIGITVAL(code)    ((code) - '0')
 #define ODIGITVAL(code)   DIGITVAL(code)
 #define XDIGITVAL(enc,code) \
-  (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
+  (ONIGENC_IS_CODE_DIGIT_ASCII(enc,code) ? DIGITVAL(code) \
    : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
 
 #define IS_SINGLELINE(option)     ((option) & ONIG_OPTION_SINGLELINE)
index b46df28514b9c313aad6f6c6d537d7e1d44920a5..cf6cdac38aaae3b3d9ef2cdf04133189efeffcf3 100644 (file)
@@ -2107,7 +2107,7 @@ onig_scan_unsigned_number(UChar** src, const UChar* end, OnigEncoding enc)
   num = 0;
   while (! PEND) {
     PFETCH(c);
-    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+    if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)) {
       val = (unsigned int )DIGITVAL(c);
       if ((INT_MAX_LIMIT - val) / 10UL < num)
         return -1;  /* overflow */
@@ -2163,7 +2163,7 @@ scan_unsigned_octal_number(UChar** src, UChar* end, int maxlen,
   num = 0;
   while (! PEND && maxlen-- != 0) {
     PFETCH(c);
-    if (ONIGENC_IS_CODE_DIGIT(enc, c) && c < '8') {
+    if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c) && c < '8') {
       val = ODIGITVAL(c);
       if ((INT_MAX_LIMIT - val) / 8UL < num)
         return -1;  /* overflow */
@@ -3115,7 +3115,7 @@ fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end,
     if (c == end_code)
       return ONIGERR_EMPTY_GROUP_NAME;
 
-    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+    if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)) {
       *num_type = IS_ABS_NUM;
       digit_count++;
     }
@@ -3144,7 +3144,7 @@ fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end,
     }
 
     if (*num_type != IS_NOT_NUM) {
-      if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+      if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)) {
         digit_count++;
       }
       else {
@@ -3167,7 +3167,7 @@ fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end,
         goto end;
       }
       PFETCH(c);
-      if (! ONIGENC_IS_CODE_DIGIT(enc, c)) goto err;
+      if (! ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)) goto err;
       PUNFETCH;
       level = onig_scan_unsigned_number(&p, end, enc);
       if (level < 0) return ONIGERR_TOO_BIG_NUMBER;
@@ -3247,7 +3247,7 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
     if (c == end_code)
       return ONIGERR_EMPTY_GROUP_NAME;
 
-    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+    if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)) {
       if (ref == 1)
         *num_type = IS_ABS_NUM;
       else {
@@ -3291,7 +3291,7 @@ fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
       }
 
       if (*num_type != IS_NOT_NUM) {
-        if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+        if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)) {
           digit_count++;
         }
         else {
@@ -3557,7 +3557,7 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
         if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
         if (!PEND) {
           c2 = PPEEK;
-          if (ONIGENC_IS_CODE_DIGIT(enc, c2))
+          if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c2))
             return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;
         }
 
@@ -3944,7 +3944,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
         num = scan_unsigned_octal_number(&p, end, 11, enc);
         if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
         if (!PEND) {
-          if (ONIGENC_IS_CODE_DIGIT(enc, PPEEK))
+          if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, PPEEK))
             return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;
         }
 
@@ -5316,7 +5316,7 @@ parse_enclosure(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
         PFETCH(c);
         if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
 
-        if (ONIGENC_IS_CODE_DIGIT(enc, c)
+        if (ONIGENC_IS_CODE_DIGIT_ASCII(enc, c)
             || c == '-' || c == '+' || c == '<' || c == '\'') {
           UChar* name_end;
           int back_num;