From 08c48d0fb2917fd0ec9ff15fe900b1f009c0a4db Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 16 Sep 2017 17:22:10 -0600 Subject: [PATCH] generate more-correct C strings Make C string generation more correct. Still not perfect. See #25. --- elcomp/eltoc.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/elcomp/eltoc.el b/elcomp/eltoc.el index 4d7f9d0..02de974 100644 --- a/elcomp/eltoc.el +++ b/elcomp/eltoc.el @@ -41,7 +41,16 @@ (defun elcomp--c-quote-string (str) "Quote a Lisp string according to C rules." (concat "\"" - (replace-regexp-in-string "[\\\\\"\n]" "\\\\\\&" str) + (mapconcat (lambda (c) + ;; Not really complete yet. + (cl-case c + ((?\\ ?\") + (string ?\\ c)) + (?\n "\\n") + (?\r "\\r") + (?\t "\\t") + (t (string c)))) + str "") "\"")) (defun elcomp--c-name (symbol)