From 3ca670b7b7c71ca67d70cac9dffb2ba6120b2e36 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Dec 2022 11:24:18 +0200 Subject: Improve escape sequence support Specifically: 1. In the double-quoted strings we now only do effective escaping of the special `$("\` characters plus `)` for symmetry. 2. There is now support for "escape sequence expansion" in the form $\X where \X can be any of the C/C++ simple escape sequences (\n, \t, etc) plus \0 (which in C/C++ is an octal escape sequence). For example: info "foo$\n$\tbar$\n$\tbaz" Will print: buildfile:1:1: info: foo bar baz --- tests/expansion/escape.testscript | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/expansion/escape.testscript (limited to 'tests') diff --git a/tests/expansion/escape.testscript b/tests/expansion/escape.testscript new file mode 100644 index 0000000..1140032 --- /dev/null +++ b/tests/expansion/escape.testscript @@ -0,0 +1,17 @@ +# file : tests/expansion/type.testscript +# license : MIT; see accompanying LICENSE file + +# Test escape sequence expansion. + +.include ../common.testscript + +: simple +: +$* <>EOO +print "foo$\nbar" +print $size([string] "foo$\0bar") +EOI +foo +bar +7 +EOO -- cgit v1.1