Skip to content

Commit

Permalink
generate more-correct C strings
Browse files Browse the repository at this point in the history
Make C string generation more correct.
Still not perfect.  See #25.
  • Loading branch information
tromey committed Sep 16, 2017
1 parent 5f9d0c4 commit 08c48d0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion elcomp/eltoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 08c48d0

Please sign in to comment.