[cmucl-commit] [git] CMU Common Lisp branch master updated. snapshot-2013-05-7-gd879838

Raymond Toy rtoy at common-lisp.net
Tue May 21 02:08:56 UTC 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".

The branch, master has been updated
       via  d879838d33c578bcecf282b8b95628b6d9bbc476 (commit)
      from  59c50055f4538c8ba49f6f8cae403563ea76cfbb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d879838d33c578bcecf282b8b95628b6d9bbc476
Author: Raymond Toy <toy.raymond at gmail.com>
Date:   Mon May 20 19:08:31 2013 -0700

    Don't reverse surrogate pairs in strings; it's not allowed by the
    CLHS.

diff --git a/src/code/string.lisp b/src/code/string.lisp
index f23db5b..5176edf 100644
--- a/src/code/string.lisp
+++ b/src/code/string.lisp
@@ -1177,18 +1177,7 @@
 	   (src-index start (1+ src-index)))
 	  ((minusp dst-index))
 	(declare (fixnum src-index dst-index))
-	(let ((current-char (schar sequence src-index)))
-	  (cond ((and (lisp::surrogatep current-char :leading)
-		      (plusp dst-index))
-		 ;; Reverse surrogate pairs correctly, which means the
-		 ;; pair isn't reversed at all.
-		 (incf src-index)
-		 (setf (schar r dst-index) (schar sequence src-index))
-		 (decf dst-index)
-		 (setf (schar r dst-index) current-char))
-		(t
-		 ;; Easy case
-		 (setf (schar r dst-index) current-char)))))
+	(setf (schar r dst-index) (schar sequence src-index)))
       r)))
 
 #+unicode
@@ -1196,16 +1185,15 @@
   (declare (optimize (speed 3) (space 0) (safety 0))
 	   (type string sequence))
   (with-string sequence
-    (flet ((rev (start end)
-	     (do ((i start (1+ i))
-		  (j (1- end) (1- j)))
-		 ((>= i j))
-	       (declare (type kernel:index i j))
-	       (rotatef (schar sequence i) (schar sequence j)))))
-      (let ((len end))
-	(loop for i = start then n as n = (%glyph-f sequence i) do
-	  (rev i n) while (< n len))
-	(rev start end))))
+    (let ((length (- end start)))
+      (declare (fixnum length))
+      (do ((left-index 0 (1+ left-index))
+	   (right-index (1- length) (1- right-index))
+	   (half-length (truncate length 2)))
+	  ((= left-index half-length) sequence)
+	(declare (fixnum left-index right-index half-length))
+	(rotatef (aref sequence left-index)
+		 (aref sequence right-index)))))
   sequence)
 
 
diff --git a/src/general-info/release-20e.txt b/src/general-info/release-20e.txt
index d9aeb5e..858f585 100644
--- a/src/general-info/release-20e.txt
+++ b/src/general-info/release-20e.txt
@@ -60,6 +60,8 @@ New in this release:
       #79.
     * Fix error in (format t "~ve" 21 5d-324).  (See ticket #80).
     * String reverse is much faster (upto 20 times)
+    * REVERSE and NREVERSE on strings will reverse surrogate pairs.
+      (Previously, surrogate pairs weren't reversed.)
 
 
   * Trac Tickets:

-----------------------------------------------------------------------

Summary of changes:
 src/code/string.lisp             |   32 ++++++++++----------------------
 src/general-info/release-20e.txt |    2 ++
 2 files changed, 12 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
CMU Common Lisp


More information about the cmucl-commit mailing list