From 154417897bc79301667634c6760d95b4382631fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 13 Jul 2022 11:36:12 +0200 Subject: Stringification operator now escapes quotes and backslashes. --- module/c/unlex.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 #\")))) -- cgit v1.2.3