aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-13 11:36:12 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-13 11:36:12 +0200
commit154417897bc79301667634c6760d95b4382631fa (patch)
treec90478baaa0b3d235272ef25566658f3194d2234
parentAdd support for "other" in preprocessing-tokens. (diff)
downloadcalp-154417897bc79301667634c6760d95b4382631fa.tar.gz
calp-154417897bc79301667634c6760d95b4382631fa.tar.xz
Stringification operator now escapes quotes and backslashes.
-rw-r--r--module/c/unlex.scm7
1 files changed, 6 insertions, 1 deletions
diff --git a/module/c/unlex.scm b/module/c/unlex.scm
index e714816d..1f8ba0a1 100644
--- a/module/c/unlex.scm
+++ b/module/c/unlex.scm
@@ -4,6 +4,7 @@
:use-module (c lex2)
:use-module (c cpp-types)
:use-module (c cpp-util)
+ :use-module ((texinfo string-utils) :select (escape-special-chars))
:export (unlex
unlex-aggressive
stringify-token
@@ -47,7 +48,11 @@
(for-each (match-lambda
(`(escape-sequence ,x)
(display (stringify-escape-sequence x)))
- (s (display s)))
+ ;; Backslash in source strings is usually encoded by an
+ ;; 'escape-sequence, but literal backslashes can be in
+ ;; "regular" string fragments as result of the stringification
+ ;; operator (#).
+ (s (display (escape-special-chars s "\"\\" #\\))))
fragments)
(display #\"))))