mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-11 03:33:11 -08:00
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:
parent
762cd7ebb3
commit
e76b75a08a
1 changed files with 10 additions and 0 deletions
|
|
@ -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)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue