CMUCL commit: intl-branch src/tools (piglatin.lisp)
Raymond Toy
rtoy at common-lisp.net
Mon Mar 8 17:06:51 CET 2010
Date: Monday, March 8, 2010 @ 11:06:51
Author: rtoy
Path: /project/cmucl/cvsroot/src/tools
Tag: intl-branch
Modified: piglatin.lisp
Don't modify *readtable* before we open the files; modify it AFTER
we've opened the files. When we open the files using :utf8, the
compiler gets called to compile the utf8 format. But *readtable* has
been modified with a different string reader that doesn't understand
Lisp strings. This causes the compilation of utf8 to fail.
---------------+
piglatin.lisp | 112 ++++++++++++++++++++++++++++----------------------------
1 file changed, 56 insertions(+), 56 deletions(-)
Index: src/tools/piglatin.lisp
diff -u src/tools/piglatin.lisp:1.1.2.4 src/tools/piglatin.lisp:1.1.2.5
--- src/tools/piglatin.lisp:1.1.2.4 Mon Mar 1 19:41:02 2010
+++ src/tools/piglatin.lisp Mon Mar 8 11:06:51 2010
@@ -88,69 +88,69 @@
((char= ch #\\) (setq backslash t)))))))
(defun latinize-pot (in out)
- (let ((*readtable* (copy-readtable nil))
- (state 0)
+ (let ((state 0)
(string nil)
(plural nil)
(count 0))
- (set-macro-character #\# (lambda (stream char)
- (declare (ignore char))
- (list (read-line stream t nil t))))
- (set-macro-character #\" #'read-pot-string)
(with-open-file (pot in :direction :input :external-format :utf-8)
(with-open-file (po out :direction :output :external-format :utf-8
:if-does-not-exist :create
:if-exists :supersede)
- (loop for item = (read pot nil pot) until (eq item pot) do
- (cond ((consp item)
- (write-char #\# po) (write-string (car item) po) (terpri po))
- ((eq item 'msgid)
- (write-string "msgid " po)
- (incf count)
- (setq state 1))
- ((eq item 'msgid_plural)
- (write-string "msgid_plural " po)
- (setq state 2))
- ((eq item 'msgstr)
- (write-string "msgstr " po)
- (when (equal string '(""))
- (write-string +piglatin-header+ po)
- (setq string nil))
- (dolist (x string)
- (write-char #\" po)
- (write-string x po)
- (write-char #\" po)
- (terpri po))
- (terpri po)
- (setq state 0 string nil))
- ((eq item 'msgstr[0])
- (write-string "msgstr[0] " po)
- (dolist (x string)
- (write-char #\" po)
- (write-string x po)
- (write-char #\" po)
- (terpri po))
- (write-string "msgstr[1] " po)
- (dolist (x plural)
- (write-char #\" po)
- (write-string x po)
- (write-char #\" po)
- (terpri po))
- (terpri po)
- (setq state 0 string nil plural nil))
- ((not (stringp item)) (error "Something's wrong"))
- ((= state 1)
- (write-char #\" po)
- (write-string item po)
- (write-char #\" po)
- (terpri po)
- (setq string (nconc string (list (latinize item)))))
- ((= state 2)
- (write-char #\" po)
- (write-string item po)
- (write-char #\" po)
- (terpri po)
- (setq plural (nconc plural (list (latinize item)))))))))
+ (let ((*readtable* (copy-readtable nil)))
+ (set-macro-character #\# (lambda (stream char)
+ (declare (ignore char))
+ (list (read-line stream t nil t))))
+ (set-macro-character #\" #'read-pot-string)
+ (loop for item = (read pot nil pot) until (eq item pot) do
+ (cond ((consp item)
+ (write-char #\# po) (write-string (car item) po) (terpri po))
+ ((eq item 'msgid)
+ (write-string "msgid " po)
+ (incf count)
+ (setq state 1))
+ ((eq item 'msgid_plural)
+ (write-string "msgid_plural " po)
+ (setq state 2))
+ ((eq item 'msgstr)
+ (write-string "msgstr " po)
+ (when (equal string '(""))
+ (write-string +piglatin-header+ po)
+ (setq string nil))
+ (dolist (x string)
+ (write-char #\" po)
+ (write-string x po)
+ (write-char #\" po)
+ (terpri po))
+ (terpri po)
+ (setq state 0 string nil))
+ ((eq item 'msgstr[0])
+ (write-string "msgstr[0] " po)
+ (dolist (x string)
+ (write-char #\" po)
+ (write-string x po)
+ (write-char #\" po)
+ (terpri po))
+ (write-string "msgstr[1] " po)
+ (dolist (x plural)
+ (write-char #\" po)
+ (write-string x po)
+ (write-char #\" po)
+ (terpri po))
+ (terpri po)
+ (setq state 0 string nil plural nil))
+ ((not (stringp item)) (error "Something's wrong"))
+ ((= state 1)
+ (write-char #\" po)
+ (write-string item po)
+ (write-char #\" po)
+ (terpri po)
+ (setq string (nconc string (list (latinize item)))))
+ ((= state 2)
+ (write-char #\" po)
+ (write-string item po)
+ (write-char #\" po)
+ (terpri po)
+ (setq plural (nconc plural (list (latinize item))))))))))
(format t "~&Translated ~D messages~%" count)))
;; Translate all of the pot files in DIR
More information about the cmucl-commit
mailing list