aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--re.c15
2 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5ca01f24..d3ae5ebb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/re.c b/re.c
index 691955f4..b317b096 100644
--- a/re.c
+++ b/re.c
@@ -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;