changeset 58784:5f1c0193e984

(GET_UNSIGNED_NUMBER): Signal an error when reaching the end. Remove redundant correctness checks. (regex_compile): Fix up error codes for \{..\} expressions.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 06 Dec 2004 00:41:40 +0000
parents a7b93ce9e1ab
children 5251b89bd389
files src/ChangeLog src/regex.c
diffstat 2 files changed, 29 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Dec 05 23:58:24 2004 +0000
+++ b/src/ChangeLog	Mon Dec 06 00:41:40 2004 +0000
@@ -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.
--- a/src/regex.c	Sun Dec 05 23:58:24 2004 +0000
+++ b/src/regex.c	Mon Dec 06 00:41:40 2004 +0000
@@ -1950,28 +1950,27 @@
 
 /* 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 @@
 
 		beg_interval = p;
 
-		if (p == pend)
-		  FREE_STACK_RETURN (REG_EBRACE);
-
 		GET_UNSIGNED_NUMBER (lower_bound);
 
 		if (c == ',')
@@ -3253,7 +3249,8 @@
 		  {
 		    if (c != '\\')
 		      FREE_STACK_RETURN (REG_BADBR);
-
+		    if (p == pend)
+		      FREE_STACK_RETURN (REG_EESCAPE);
 		    PATFETCH (c);
 		  }