New function lisp-to-c-name: return prin1 representation of object

with all characters that are invalid in C identifiers replaced by
underscore.
This commit is contained in:
japhie 2005-05-29 15:19:16 +00:00
parent 762cd7ebb3
commit e76b75a08a

View file

@ -206,3 +206,13 @@
(rem-sysprop symbol ':inline-safe)
(rem-sysprop symbol 'lfun))
(defun lisp-to-c-name (obj)
"Translate Lisp object prin1 representation to valid C identifier name"
(and obj
(map 'string
#'(lambda (c)
(let ((cc (char-code c)))
(if (or (<= #.(char-code #\a) cc #.(char-code #\z))
(<= #.(char-code #\0) cc #.(char-code #\9)))
c #\_)))
(string-downcase (prin1-to-string obj)))))