summaryrefslogtreecommitdiff
path: root/regparse.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-29 16:29:06 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-29 16:29:06 (GMT)
commit291fa223cfb2349c5e7fc5bb0e7729a2cfcc52cf (patch)
tree575b9cf8fa53adeedd5cc53b801da706c1598069 /regparse.c
parent31eb29fe975bdf1d1e7ed5f3eb991430b381bc06 (diff)
* regparse.c (is_onechar_cclass): optimize character class
Merge Onigmo 27278c12e6674043cc8affca6507e20e119a86ee. * regparse.c (is_onechar_cclass): [bug] unexpected match occurs when a char class contains no char * enc/unicode.c (init_case_fold_table): define the sizes of case folding tables in casefold.h git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regparse.c')
-rw-r--r--regparse.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/regparse.c b/regparse.c
index 08ffa80..f1e8e4f 100644
--- a/regparse.c
+++ b/regparse.c
@@ -1786,8 +1786,8 @@ add_code_range_to_buf0(BBuf** pbuf, ScanEnv* env, OnigCodePoint from, OnigCodePo
if (inc_n != 1) {
if (checkdup && from <= data[low*2+1]
- && (data[low*2] <= from || data[low*2+1] <= to))
- CC_DUP_WARN(env);
+ && (data[low*2] <= from || data[low*2+1] <= to))
+ CC_DUP_WARN(env);
if (from > data[low*2])
from = data[low*2];
if (to < data[(high - 1)*2 + 1])
@@ -1799,7 +1799,7 @@ add_code_range_to_buf0(BBuf** pbuf, ScanEnv* env, OnigCodePoint from, OnigCodePo
int to_pos = SIZE_CODE_POINT * (1 + (low + 1) * 2);
if (inc_n > 0) {
- if ((OnigCodePoint )high < n) {
+ if (high < n) {
int size = (n - high) * 2 * SIZE_CODE_POINT;
BBUF_MOVE_RIGHT(bbuf, from_pos, to_pos, size);
}
@@ -5722,9 +5722,13 @@ is_onechar_cclass(CClassNode* cc, OnigCodePoint* code)
}
}
}
+ if (found == 0) {
+ /* the character class contains no char. */
+ return 0;
+ }
if (j >= 0) {
/* only one char found in the bitset, calculate the code point. */
- c = BITS_IN_ROOM * j + (countbits(b2 - 1) & 0x1f);
+ c = BITS_IN_ROOM * j + countbits(b2 - 1);
}
*code = c;
return 1;
@@ -5746,7 +5750,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
switch (tok->type) {
case TK_ALT:
case TK_EOT:
- end_of_token:
+ end_of_token:
*np = node_new_empty();
return tok->type;
break;