]> code.delx.au - gnu-emacs/blobdiff - lisp/international/titdic-cnv.el
Fix previous change.
[gnu-emacs] / lisp / international / titdic-cnv.el
index 162c84da3014a8328edc42c96470c82d9105e6b1..ed5df5b95922a8eb39cee7d801a4d384e9be77c3 100644 (file)
@@ -1,7 +1,11 @@
 ;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package -*- coding:iso-2022-7bit; -*-
 
-;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
+;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: Quail, TIT, cxterm
 
@@ -19,8 +23,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -206,7 +210,7 @@ SPC, 6, 3, 4, or 7 specifing a tone (SPC:\e$(0?v(N\e(B, 6:\e$(0Dm(N\e(B, 3:\e$(0&9Vy\e
 
 ;; Return a value of the key in the current line.
 (defsubst tit-read-key-value ()
-  (if (looking-at "[^ \t\n]+")
+  (if (looking-at "[^ \t\r\n]+")
       (car (read-from-string (concat "\"" (match-string 0) "\"")))))
 
 ;; Return an appropriate quail-package filename from FILENAME (TIT
@@ -267,7 +271,9 @@ SPC, 6, 3, 4, or 7 specifing a tone (SPC:\e$(0?v(N\e(B, 6:\e$(0Dm(N\e(B, 3:\e$(0&9Vy\e
        (tit-keyprompt nil))
 
     (princ ";; Quail package `")
-    (princ package) (princ "' -*- coding:iso-2022-7bit; -*-\n")
+    (princ package)
+    (princ "' -*- coding:iso-2022-7bit; ")
+    (princ "byte-compile-disable-print-circle:t; -*-\n")
     (princ ";;   Generated by the command `titdic-convert'\n;;\tDate: ")
     (princ (current-time-string))
     (princ "\n;;\tOriginal TIT dictionary file: ")
@@ -465,13 +471,16 @@ SPC, 6, 3, 4, or 7 specifing a tone (SPC:\e$(0?v(N\e(B, 6:\e$(0Dm(N\e(B, 3:\e$(0&9Vy\e
 Optional argument DIRNAME if specified is the directory name under which
 the generated Quail package is saved."
   (interactive "FTIT dictionary file: ")
-  (let ((coding-system-for-write 'iso-2022-7bit))
+  (let ((coding-system-for-write 'iso-2022-7bit-unix))
     (with-temp-file  (tit-make-quail-package-file-name filename dirname)
-      (set-buffer-file-coding-system 'iso-2022-7bit)
+      ;; Explicitly speficy eol format to `unix'.
+      (set-buffer-file-coding-system 'iso-2022-7bit-unix)
       (let ((standard-output (current-buffer)))
        (with-temp-buffer
          (set-buffer-multibyte nil)
-         (let ((coding-system-for-read 'no-conversion))
+         ;; Here we must use `raw-text' instead of `no-conversion' to
+         ;; enable auto-decoding of eol format (CRLF->LF).
+         (let ((coding-system-for-read 'raw-text))
            (insert-file-contents (expand-file-name filename)))
 
          ;; Decode the buffer contents from the encoding specified by a
@@ -639,7 +648,7 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"."
 ;;
 ;; You should have received a copy of the GNU General Public License along with
 ;; CCE; see the file COPYING.  If not, write to the Free Software Foundation,
-;; 675 Mass Ave, Cambridge, MA 02139, USA.")
+;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
 
     ("chinese-ziranma" "\e$AWTH;\e(B"
      "ziranma.cin" cn-gb-2312 "ZIRANMA.el"
@@ -668,7 +677,7 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"."
 ;;
 ;; You should have received a copy of the GNU General Public License along with
 ;; CCE; see the file COPYING.  If not, write to the Free Software Foundation,
-;; 675 Mass Ave, Cambridge, MA 02139, USA.")
+;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
 
     ("chinese-ctlau" "\e$AAuTA\e(B"
      "CTLau.html" cn-gb-2312 "CTLau.el"
@@ -694,7 +703,7 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"."
 ;; #
 ;; # You should have received a copy of the GNU General Public License
 ;; # along with this program; if not, write to the Free Software Foundation,
-;; # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
+;; # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
 
     ("chinese-ctlaub" "\e$(0N,Gn\e(B"
      "CTLau-b5.html" big5 "CTLau-b5.el"
@@ -720,7 +729,7 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"."
 ;; #
 ;; # You should have received a copy of the GNU General Public License
 ;; # along with this program; if not, write to the Free Software Foundation,
-;; # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
+;; # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
     ))
 
 ;; Generate a code of a Quail package in the current buffer from Tsang
@@ -768,6 +777,11 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\"."
     (insert "(quail-define-rules\n")
     (save-excursion
       (set-buffer dicbuf)
+      ;; Handle double CR line ends, which result when checking out of
+      ;; CVS on MS-Windows.
+      (goto-char (point-min))
+      (while (re-search-forward "\r\r$" nil t)
+       (replace-match ""))
       (goto-char (point-min))
       (search-forward "A440")
       (beginning-of-line)
@@ -899,6 +913,9 @@ method `chinese-tonepy' with which you must specify tones by digits
   (let ((pos (point)))
     (insert-buffer-substring dicbuf)
     (goto-char pos)
+    (re-search-forward "^[a-z]")
+    (beginning-of-line)
+    (delete-region pos (point))
     (while (not (eobp))
       (insert "(\"")
       (skip-chars-forward "a-z")
@@ -1108,27 +1125,33 @@ the generated Quail package is saved."
        name title dicfile coding quailfile converter copyright
        dicbuf)
     (while tail
-      (when (or (string-match (nth 2 (car tail)) filename)
-               ;; MS-DOS filesystem truncates file names to 8+3
-               ;; limits, so "cangjie-table.cns" becomes
-               ;; "cangjie-.cns", and the above string-match fails.
-               ;; Give DOS users a chance...
-               (and (fboundp 'msdos-long-file-names)
-                    (not (msdos-long-file-names))
-                    (string-match (dos-8+3-filename (nth 2 (car tail)))
-                                  filename)))
-       (setq slot (car tail)
-             name (car slot)
+      (setq slot (car tail)
+           dicfile (nth 2 slot)
+           quailfile (nth 4 slot))
+      (when (and (or (string-match dicfile filename)
+                    ;; MS-DOS filesystem truncates file names to 8+3
+                    ;; limits, so "cangjie-table.cns" becomes
+                    ;; "cangjie-.cns", and the above string-match
+                    ;; fails.  Give DOS users a chance...
+                    (and (fboundp 'msdos-long-file-names)
+                         (not (msdos-long-file-names))
+                         (string-match (dos-8+3-filename dicfile) filename)))
+                (if (file-newer-than-file-p
+                     filename (expand-file-name quailfile dirname))
+                    t
+                  (message "%s is up to date" quailfile)
+                  nil))
+       (setq name (car slot)
              title (nth 1 slot)
-             dicfile (nth 2 slot)
              coding (nth 3 slot)
-             quailfile (nth 4 slot)
              converter (nth 5 slot)
              copyright (nth 6 slot))
        (message "Converting %s to %s..." dicfile quailfile)
        (with-temp-file (expand-file-name quailfile dirname)
-         (set-buffer-file-coding-system 'iso-2022-7bit)
-         (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; -*-\n")
+         ;; Explicitly speficy eol format to `unix'.
+         (set-buffer-file-coding-system 'iso-2022-7bit-unix)
+         (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; ")
+         (insert "byte-compile-disable-print-circle:t; -*-\n");
          (insert ";;   Generated by the command `miscdic-convert'\n")
          (insert ";;   Date: " (current-time-string) "\n")
          (insert ";;   Source dictionary file: " dicfile "\n")