summaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-04 23:00:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-04 23:00:49 -0700
commit0cb57f957f6ea07a8e33173d39716716db455d30 (patch)
treeaf84c6baed373c3ebc6ecd245d09088ac4503682 /regex.c
parent274cb70971d6a2cebcd887350b4b8602b32743d7 (diff)
downloadtxr-0cb57f957f6ea07a8e33173d39716716db455d30.tar.gz
txr-0cb57f957f6ea07a8e33173d39716716db455d30.tar.bz2
txr-0cb57f957f6ea07a8e33173d39716716db455d30.zip
regex: read/print bug: escaped double quote.
Because the regex printer wrongly uses out_str_char (for the sake of borrowing its semicolon-notation processing) when a regex prints, all characters that require escaping in a string literal get escaped, which includes the " character. Unfortunately the \" sequence which results is rejected by the regex parser. * lib.c (out_str_char): Kludge: add extra argument to distinguish regex use versus string use, and treat the double quote accordingly. (out_str_readable): Give 0 arg to new param of out_str_char. * lib.h (out_str_char): Declaration updated. * regex.c (print_class_char, print_rec): Pass 1 to new param of out_str_char.
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 47693e97..3fb6b42c 100644
--- a/regex.c
+++ b/regex.c
@@ -2272,7 +2272,7 @@ static void print_class_char(val ch, val first_p, val stream, int *semi_flag)
put_char(ch, stream);
return;
}
- out_str_char(c_chr(ch), stream, semi_flag);
+ out_str_char(c_chr(ch), stream, semi_flag, 1);
}
static void print_rec(val exp, val stream, int *semi_flag);
@@ -2311,7 +2311,7 @@ static void print_rec(val exp, val stream, int *semi_flag)
put_char(exp, stream);
break;
default:
- out_str_char(ch, stream, semi_flag);
+ out_str_char(ch, stream, semi_flag, 1);
}
} else if (stringp(exp)) {
cnum i;