summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--regex.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index c436a7c3..ad117473 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-15 Kaz Kylheku <kaz@kylheku.com>
+
+ * regex.c (print_rec): A compound must use parentheses for
+ elements which have a higher precedence than catenation.
+
2015-02-12 Kaz Kylheku <kaz@kylheku.com>
* lib.c (list_collect, list_collect_append): In error
diff --git a/regex.c b/regex.c
index 222b0923..f3b4ffc6 100644
--- a/regex.c
+++ b/regex.c
@@ -1773,8 +1773,14 @@ static void print_rec(val exp, val stream)
}
put_char(chr(']'), stream);
} else if (sym == compound_s) {
- while (args)
- print_rec(pop(&args), stream);
+ for (; args; args = cdr(args)) {
+ val arg = car(args);
+ if (consp(arg) && car(arg) != zeroplus_s && car(arg) != oneplus_s &&
+ car(arg) != optional_s && car (arg) != compound_s)
+ paren_print_rec(arg, stream);
+ else
+ print_rec(arg, stream);
+ }
} else if (sym == zeroplus_s || sym == oneplus_s || sym == optional_s) {
val arg = pop(&args);
if (consp(arg) && car(arg) != set_s && car(arg) != cset_s)