diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | re.c | 15 |
2 files changed, 21 insertions, 2 deletions
@@ -1,3 +1,11 @@ +Sun May 29 22:48:41 2011 Arnold D. Robbins <arnold@skeeve.com> + + * re.c (expand_range): Handle cases where expanded range + includes '\\' (and ']'). Thanks to Juergen Daubert <jue@jue.li>. + Fatal error if end point is below start point ([z-a]), + thanks to John Haque. Don't repeat the last character in + the expansion. Thanks to Arnold Robbins. + Fri May 27 10:01:17 2011 Arnold D. Robbins <arnold@skeeve.com> * Release 3.1.84: Third beta test tar ball for 4.0. @@ -643,6 +643,7 @@ add_char(char **bufp, size_t *lenp, char ch, char **ptr) erealloc(*bufp, char *, newlen + 2, "add_char"); *ptr = *bufp + offset; **ptr = ch; + *lenp = newlen + 2; (*ptr)++; } @@ -714,7 +715,7 @@ again: /* inside [...] but not inside [[:...:]] */ if (*sp == '-') { int start, end; - char i; + int i; if (sp[1] == ']') { /* also literal */ copy(); @@ -728,8 +729,18 @@ again: len--; } end = sp[1]; - for (i = start + 1; i <= end; i++) + if (end < start) + fatal(_("Invalid range end: /%.*s/"), + *lenp, s); + for (i = start + 1; i < end; i++) { + /* + * Will the special cases never end? + */ + if (i == '\\' || i == ']') { + copych('\\'); + } copych(i); + } sp++; len--; continue; |