[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dfa: small fixes to single-byte range computation
From: |
Paolo Bonzini |
Subject: |
[PATCH] dfa: small fixes to single-byte range computation |
Date: |
Mon, 30 Apr 2012 09:01:24 +0200 |
* src/dfa.c (parse_bracket_exp): Do not call regexec with an invalid
subject. Move declarations before all statements.
---
src/dfa.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/dfa.c b/src/dfa.c
index eefc817..a78e760 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1104,6 +1104,11 @@ parse_bracket_exp (void)
}
else
{
+ /* Defer to the system regex library about the meaning
+ of range expressions. */
+ regex_t re;
+ char pattern[6] = { '[', 0, '-', 0, ']', 0 };
+ char subject[2] = { 0, 0 };
c1 = c;
if (case_fold)
{
@@ -1111,17 +1116,16 @@ parse_bracket_exp (void)
c2 = tolower (c2);
}
- /* Defer to the system regex library about the meaning
- of range expressions. */
- regex_t re;
- char pattern[6] = { '[', c1, '-', c2, ']', 0 };
- char subject[2] = { 0, 0 };
+ pattern[1] = c1;
+ pattern[3] = c2;
regcomp (&re, pattern, REG_NOSUB);
for (c = 0; c < NOTCHAR; ++c)
{
+ if ((case_fold && isupper (c)) ||
+ (MB_CUR_MAX > 1 && btowc (c) == WEOF))
+ continue;
subject[0] = c;
- if (!(case_fold && isupper (c))
- && regexec (&re, subject, 0, NULL, 0) != REG_NOMATCH)
+ if (regexec (&re, subject, 0, NULL, 0) != REG_NOMATCH)
setbit_case_fold_c (c, ccl);
}
regfree (&re);
--
1.7.9.3
- [PATCH] dfa: small fixes to single-byte range computation,
Paolo Bonzini <=