From c554153d3fe9a21e57854d3174e2804adfb22f00 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 15 Feb 2015 18:27:58 -0800 Subject: * regex.c (print_rec): A compound must use parentheses for elements which have a higher precedence than catenation. --- ChangeLog | 5 +++++ regex.c | 10 ++++++++-- 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 + + * regex.c (print_rec): A compound must use parentheses for + elements which have a higher precedence than catenation. + 2015-02-12 Kaz Kylheku * 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) -- cgit v1.2.3