summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2004-12-06 00:41:40 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2004-12-06 00:41:40 +0000
commitc72b0edd085ee95677140e78c42eb104f74a3354 (patch)
treecbc7592716372cfe8178d8aca942bb2e4501cbeb
parent952cb0846a0f0e4faf4075180062f0e0e91b9170 (diff)
downloademacs-c72b0edd085ee95677140e78c42eb104f74a3354.tar.gz
(GET_UNSIGNED_NUMBER): Signal an error when reaching the end.
Remove redundant correctness checks. (regex_compile): Fix up error codes for \{..\} expressions.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/regex.c49
2 files changed, 29 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d21df41fe56..17dc673c681 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-05 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * regex.c (GET_UNSIGNED_NUMBER): Signal an error when reaching the end.
+ Remove redundant correctness checks.
+ (regex_compile): Fix up error codes for \{..\} expressions.
+
2004-12-05 Richard M. Stallman <rms@gnu.org>
* regex.c (regex_compile): Fix end-of-pattern case for space.
diff --git a/src/regex.c b/src/regex.c
index 130765134f5..1009c837dcf 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1950,28 +1950,27 @@ struct range_table_work_area
/* Get the next unsigned number in the uncompiled pattern. */
#define GET_UNSIGNED_NUMBER(num) \
- do { if (p != pend) \
- { \
- PATFETCH (c); \
- if (c == ' ') \
- FREE_STACK_RETURN (REG_BADBR); \
- while ('0' <= c && c <= '9') \
- { \
- int prev; \
- if (num < 0) \
- num = 0; \
- prev = num; \
- num = num * 10 + c - '0'; \
- if (num / 10 != prev) \
- FREE_STACK_RETURN (REG_BADBR); \
- if (p == pend) \
- break; \
- PATFETCH (c); \
- } \
- if (c == ' ') \
- FREE_STACK_RETURN (REG_BADBR); \
- } \
- } while (0)
+ do { \
+ if (p == pend) \
+ FREE_STACK_RETURN (REG_EBRACE); \
+ else \
+ { \
+ PATFETCH (c); \
+ while ('0' <= c && c <= '9') \
+ { \
+ int prev; \
+ if (num < 0) \
+ num = 0; \
+ prev = num; \
+ num = num * 10 + c - '0'; \
+ if (num / 10 != prev) \
+ FREE_STACK_RETURN (REG_BADBR); \
+ if (p == pend) \
+ FREE_STACK_RETURN (REG_EBRACE); \
+ PATFETCH (c); \
+ } \
+ } \
+ } while (0)
#if ! WIDE_CHAR_SUPPORT
@@ -3234,9 +3233,6 @@ regex_compile (pattern, size, syntax, bufp)
beg_interval = p;
- if (p == pend)
- FREE_STACK_RETURN (REG_EBRACE);
-
GET_UNSIGNED_NUMBER (lower_bound);
if (c == ',')
@@ -3253,7 +3249,8 @@ regex_compile (pattern, size, syntax, bufp)
{
if (c != '\\')
FREE_STACK_RETURN (REG_BADBR);
-
+ if (p == pend)
+ FREE_STACK_RETURN (REG_EESCAPE);
PATFETCH (c);
}