summaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-07-16 17:54:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-07-16 17:54:18 -0700
commit2411f779f47c441659720ad0ddcabf91df1d2529 (patch)
tree51f6ea0e466f5691fb27a32020bdef763d6e68ed /regex.c
parent0359aa22e83881d7686144145fe42920fe943fa0 (diff)
downloadtxr-2411f779f47c441659720ad0ddcabf91df1d2529.tar.gz
txr-2411f779f47c441659720ad0ddcabf91df1d2529.tar.bz2
txr-2411f779f47c441659720ad0ddcabf91df1d2529.zip
regex: don't print superfluous parens around classes.
* regex.c (print_rec): Switching from negative tests to positive: print parens around elements of a compound which have a lower precedence. The previously incorrectly omitted set and cset remain unmentioned, so under this inversion of logic, they print without parentheses.
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/regex.c b/regex.c
index 705ac26d..e61d29d3 100644
--- a/regex.c
+++ b/regex.c
@@ -2251,8 +2251,8 @@ static void print_rec(val exp, val stream, int *semi_flag)
} else if (sym == compound_s) {
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)
+ if (consp(arg) && (car(arg) == compl_s || car(arg) == and_s ||
+ car(arg) == nongreedy_s))
paren_print_rec(arg, stream, semi_flag);
else
print_rec(arg, stream, semi_flag);