diff options
| author | Kenichi Handa | 2006-03-02 01:47:27 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-03-02 01:47:27 +0000 |
| commit | 3dd525cd0ec9f3900ff1df269a50399451516063 (patch) | |
| tree | 5e07ae4bad2282d2a3748483f86cc615a6f38533 | |
| parent | cf2f4bcfa76c26fb2a675a69c77762f623e66102 (diff) | |
| download | emacs-3dd525cd0ec9f3900ff1df269a50399451516063.tar.gz emacs-3dd525cd0ec9f3900ff1df269a50399451516063.zip | |
(ccl-embed-string): Check string length.
Set special flag for multibyte character sequence.
(ccl-compile-write-string): Don't make str unibyte.
(ccl-compile-write-repeat): Likewise.
(ccl-compile-write): If the character code doesn't fit in 22-bit
(ccl-dump-write-const-string): Check special flag for multibyte
character sequence.
| -rw-r--r-- | lisp/international/ccl.el | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el index 9078d29d942..0ee5999efbc 100644 --- a/lisp/international/ccl.el +++ b/lisp/international/ccl.el | |||
| @@ -209,16 +209,21 @@ | |||
| 209 | ;; Embed string STR of length LEN in `ccl-program-vector' at | 209 | ;; Embed string STR of length LEN in `ccl-program-vector' at |
| 210 | ;; `ccl-current-ic'. | 210 | ;; `ccl-current-ic'. |
| 211 | (defun ccl-embed-string (len str) | 211 | (defun ccl-embed-string (len str) |
| 212 | (let ((i 0)) | 212 | (if (> len #xFFFFF) |
| 213 | (while (< i len) | 213 | (error "CCL: String too long: %d" len)) |
| 214 | (ccl-embed-data (logior (ash (aref str i) 16) | 214 | (if (> (string-bytes str) len) |
| 215 | (if (< (1+ i) len) | 215 | (dotimes (i len) |
| 216 | (ash (aref str (1+ i)) 8) | 216 | (ccl-embed-data (logior #x1000000 (aref str i)))) |
| 217 | 0) | 217 | (let ((i 0)) |
| 218 | (if (< (+ i 2) len) | 218 | (while (< i len) |
| 219 | (aref str (+ i 2)) | 219 | (ccl-embed-data (logior (ash (aref str i) 16) |
| 220 | 0))) | 220 | (if (< (1+ i) len) |
| 221 | (setq i (+ i 3))))) | 221 | (ash (aref str (1+ i)) 8) |
| 222 | 0) | ||
| 223 | (if (< (+ i 2) len) | ||
| 224 | (aref str (+ i 2)) | ||
| 225 | 0))) | ||
| 226 | (setq i (+ i 3)))))) | ||
| 222 | 227 | ||
| 223 | ;; Embed a relative jump address to `ccl-current-ic' in | 228 | ;; Embed a relative jump address to `ccl-current-ic' in |
| 224 | ;; `ccl-program-vector' at IC without altering the other bit field. | 229 | ;; `ccl-program-vector' at IC without altering the other bit field. |
| @@ -461,7 +466,6 @@ | |||
| 461 | 466 | ||
| 462 | ;; Compile WRITE statement with string argument. | 467 | ;; Compile WRITE statement with string argument. |
| 463 | (defun ccl-compile-write-string (str) | 468 | (defun ccl-compile-write-string (str) |
| 464 | (setq str (string-as-unibyte str)) | ||
| 465 | (let ((len (length str))) | 469 | (let ((len (length str))) |
| 466 | (ccl-embed-code 'write-const-string 1 len) | 470 | (ccl-embed-code 'write-const-string 1 len) |
| 467 | (ccl-embed-string len str)) | 471 | (ccl-embed-string len str)) |
| @@ -673,7 +677,6 @@ | |||
| 673 | (ccl-embed-code 'write-const-jump 0 ccl-loop-head) | 677 | (ccl-embed-code 'write-const-jump 0 ccl-loop-head) |
| 674 | (ccl-embed-data arg)) | 678 | (ccl-embed-data arg)) |
| 675 | ((stringp arg) | 679 | ((stringp arg) |
| 676 | (setq arg (string-as-unibyte arg)) | ||
| 677 | (let ((len (length arg)) | 680 | (let ((len (length arg)) |
| 678 | (i 0)) | 681 | (i 0)) |
| 679 | (ccl-embed-code 'write-string-jump 0 ccl-loop-head) | 682 | (ccl-embed-code 'write-string-jump 0 ccl-loop-head) |
| @@ -731,7 +734,9 @@ | |||
| 731 | (error "CCL: Invalid number of arguments: %s" cmd)) | 734 | (error "CCL: Invalid number of arguments: %s" cmd)) |
| 732 | (let ((rrr (nth 1 cmd))) | 735 | (let ((rrr (nth 1 cmd))) |
| 733 | (cond ((integerp rrr) | 736 | (cond ((integerp rrr) |
| 734 | (ccl-embed-code 'write-const-string 0 rrr)) | 737 | (if (> rrr #xFFFFF) |
| 738 | (ccl-compile-write-string (string rrr)) | ||
| 739 | (ccl-embed-code 'write-const-string 0 rrr))) | ||
| 735 | ((stringp rrr) | 740 | ((stringp rrr) |
| 736 | (ccl-compile-write-string rrr)) | 741 | (ccl-compile-write-string rrr)) |
| 737 | ((and (symbolp rrr) (vectorp (nth 2 cmd))) | 742 | ((and (symbolp rrr) (vectorp (nth 2 cmd))) |
| @@ -1135,12 +1140,16 @@ | |||
| 1135 | (insert "write \"") | 1140 | (insert "write \"") |
| 1136 | (while (< i len) | 1141 | (while (< i len) |
| 1137 | (let ((code (ccl-get-next-code))) | 1142 | (let ((code (ccl-get-next-code))) |
| 1138 | (insert (format "%c" (lsh code -16))) | 1143 | (if (logand code #x1000000) |
| 1139 | (if (< (1+ i) len) | 1144 | (progn |
| 1140 | (insert (format "%c" (logand (lsh code -8) 255)))) | 1145 | (insert (logand code #xFFFFFF)) |
| 1141 | (if (< (+ i 2) len) | 1146 | (setq i (1+ i))) |
| 1142 | (insert (format "%c" (logand code 255)))) | 1147 | (insert (format "%c" (lsh code -16))) |
| 1143 | (setq i (+ i 3)))) | 1148 | (if (< (1+ i) len) |
| 1149 | (insert (format "%c" (logand (lsh code -8) 255)))) | ||
| 1150 | (if (< (+ i 2) len) | ||
| 1151 | (insert (format "%c" (logand code 255)))) | ||
| 1152 | (setq i (+ i 3))))) | ||
| 1144 | (insert "\"\n")))) | 1153 | (insert "\"\n")))) |
| 1145 | 1154 | ||
| 1146 | (defun ccl-dump-write-array (rrr cc) | 1155 | (defun ccl-dump-write-array (rrr cc) |