From: David Vázquez Date: Fri, 24 May 2013 01:58:25 +0000 (+0100) Subject: string-upcase and string-downcase non primitives X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=9d3e2d64fff21ebc844ab9254fa6ff798d10d634;p=jscl.git string-upcase and string-downcase non primitives --- diff --git a/src/compiler.lisp b/src/compiler.lisp index 961315c..e29f57b 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1443,9 +1443,6 @@ "var x = " x ";" *newline* "return typeof(x) == 'object' && 'length' in x && x.stringp == 1;"))) -(define-builtin string-upcase (x) - (code "make_lisp_string(xstring(" x ").toUpperCase())")) - (define-raw-builtin funcall (func &rest args) (js!selfcall "var f = " (ls-compile func) ";" *newline* diff --git a/src/string.lisp b/src/string.lisp index e4cd22c..7026cb3 100644 --- a/src/string.lisp +++ b/src/string.lisp @@ -77,3 +77,14 @@ (defun concat (&rest strs) (!reduce #'concat-two strs "")) + + +(defun string-upcase (string) + (let ((new (make-string (length string)))) + (dotimes (i (length string) new) + (aset new i (char-upcase (char string i)))))) + +(defun string-downcase (string) + (let ((new (make-string (length string)))) + (dotimes (i (length string) new) + (aset new i (char-downcase (char string i))))))