Skip to content

Commit

Permalink
Use raw string if a cclass contains only one character
Browse files Browse the repository at this point in the history
(Issue #46)
  • Loading branch information
k-takata committed Dec 1, 2016
1 parent 67fa14b commit d3a6585
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions regparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6084,11 +6084,10 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env)
/* Emoji variation sequence
* http://unicode.org/Public/emoji/4.0/emoji-zwj-sequences.txt
*/
np1 = node_new_cclass();
num1 = ONIGENC_CODE_TO_MBC(env->enc, 0xfe0f, buf);
if (num1 < 0) return num1;
np1 = node_new_str_raw(buf, buf + num1);
if (IS_NULL(np1)) goto err;
cc = NCCLASS(np1);
r = add_code_range(&(cc->mbuf), env, 0xfe0f, 0xfe0f);
if (r != 0) goto err;

tmp = node_new_quantifier(0, 1, 0);
if (IS_NULL(tmp)) goto err;
Expand Down Expand Up @@ -6131,11 +6130,10 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env)
alt2 = NULL;

/* ZWJ */
np1 = node_new_cclass();
num1 = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
if (num1 < 0) return num1;
np1 = node_new_str_raw(buf, buf + num1);
if (IS_NULL(np1)) goto err;
cc = NCCLASS(np1);
r = add_code_range(&(cc->mbuf), env, 0x200D, 0x200D);
if (r != 0) goto err;

tmp = node_new_list(np1, list2);
if (IS_NULL(tmp)) goto err;
Expand Down Expand Up @@ -6255,11 +6253,10 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env)
list2 = tmp;
np1 = NULL;

np1 = node_new_cclass();
num1 = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
if (num1 < 0) return num1;
np1 = node_new_str_raw(buf, buf + num1);
if (IS_NULL(np1)) goto err;
cc = NCCLASS(np1);
r = add_code_range(&(cc->mbuf), env, 0x200D, 0x200D);
if (r != 0) goto err;

tmp = node_new_list(np1, list2);
if (IS_NULL(tmp)) goto err;
Expand Down Expand Up @@ -6332,11 +6329,10 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env)
np1 = NULL;

/* Prepend+ */
np1 = node_new_cclass();
num1 = ONIGENC_CODE_TO_MBC(env->enc, 0x200D, buf);
if (num1 < 0) return num1;
np1 = node_new_str_raw(buf, buf + num1);
if (IS_NULL(np1)) goto err;
cc = NCCLASS(np1);
r = add_code_range(&(cc->mbuf), env, 0x200D, 0x200D);
if (r != 0) goto err;

tmp = node_new_quantifier(0, 1, 0);
if (IS_NULL(tmp)) goto err;
Expand Down

0 comments on commit d3a6585

Please sign in to comment.