]> granicus.if.org Git - onig/commitdiff
fix invalid state after char-class in char-class
authorK.Kosako <kosako@sofnec.co.jp>
Fri, 4 Oct 2019 07:19:28 +0000 (16:19 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Fri, 4 Oct 2019 07:19:28 +0000 (16:19 +0900)
src/regparse.c

index 4172dd948bd4144579f58b4ea611dc53af7478e2..b6238a84bdfa76e0ff5048ca7c8c82f60bbda83b 100644 (file)
@@ -6405,14 +6405,14 @@ parse_cc(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env)
         in_raw = 0;
         goto val_entry;
       }
-      goto next_class;
+      goto next_cprop;
       break;
 
     case TK_CHAR_TYPE:
       r = add_ctype_to_cc(cc, tok->u.prop.ctype, tok->u.prop.not, env);
       if (r != 0) goto err;
 
-    next_class:
+    next_cprop:
       r = cc_cprop_next(cc, &curr_code, &curr_type, &state, env);
       if (r != 0) goto err;
       break;
@@ -6426,7 +6426,7 @@ parse_cc(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env)
         }
         r = add_ctype_to_cc(cc, ctype, tok->u.prop.not, env);
         if (r != 0) goto err;
-        goto next_class;
+        goto next_cprop;
       }
       break;
 
@@ -6471,7 +6471,7 @@ parse_cc(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env)
       }
       else if (state == CS_RANGE) {
         CC_ESC_WARN(env, (UChar* )"-");
-        goto any_char_in;  /* [!--x] is allowed */
+        goto any_char_in;  /* [!--] is allowed */
       }
       else { /* CS_COMPLETE */
         r = fetch_token_in_cc(tok, &p, end, env);
@@ -6499,6 +6499,13 @@ parse_cc(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env)
         Node *anode;
         CClassNode* acc;
 
+        if (state == CS_VALUE) {
+          r = cc_char_next(cc, &curr_code, 0, &curr_raw, 0, curr_type, &curr_type,
+                           &state, env);
+          if (r != 0) goto err;
+        }
+        state = CS_COMPLETE;
+
         r = parse_cc(&anode, tok, &p, end, env);
         if (r != 0) {
           onig_node_free(anode);