diff options
| author | Kenichi Handa | 2004-04-07 07:22:10 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-04-07 07:22:10 +0000 |
| commit | 350cd166ce580a8e2bd8ec1f8e0b8d27d6ece32e (patch) | |
| tree | a19c7a3d611c98e13b068ccb99b48186c62cc72f | |
| parent | 0ea6242fabb904c61f3ff8e16b4436707549c536 (diff) | |
| download | emacs-350cd166ce580a8e2bd8ec1f8e0b8d27d6ece32e.tar.gz emacs-350cd166ce580a8e2bd8ec1f8e0b8d27d6ece32e.zip | |
(make-translation-table): Set second extra
slot of the char table to 1.
(make-translation-table-from-vector): Likewise.
(make-translation-table-from-alist): Fix handling of multiple
entries.
| -rw-r--r-- | lisp/international/mule.el | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 1b193bc5fb9..d2cc9c0f195 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -1839,6 +1839,7 @@ character, say TO-ALT, FROM is also translated to TO-ALT." | |||
| 1839 | (if rev-from | 1839 | (if rev-from |
| 1840 | (setcdr rev-to (append rev-from (cdr rev-to))))))) | 1840 | (setcdr rev-to (append rev-from (cdr rev-to))))))) |
| 1841 | ;; Return TABLE just created. | 1841 | ;; Return TABLE just created. |
| 1842 | (set-char-table-extra-slot table 1 1) | ||
| 1842 | table)) | 1843 | table)) |
| 1843 | 1844 | ||
| 1844 | (defun make-translation-table-from-vector (vec) | 1845 | (defun make-translation-table-from-vector (vec) |
| @@ -1856,6 +1857,8 @@ See also the variable `nonascii-translation-table'." | |||
| 1856 | (if (>= ch 256) | 1857 | (if (>= ch 256) |
| 1857 | (aset rev-table ch i)))) | 1858 | (aset rev-table ch i)))) |
| 1858 | (set-char-table-extra-slot table 0 rev-table) | 1859 | (set-char-table-extra-slot table 0 rev-table) |
| 1860 | (set-char-table-extra-slot table 1 1) | ||
| 1861 | (set-char-table-extra-slot rev-table 1 1) | ||
| 1859 | table)) | 1862 | table)) |
| 1860 | 1863 | ||
| 1861 | (defun make-translation-table-from-alist (alist) | 1864 | (defun make-translation-table-from-alist (alist) |
| @@ -1864,32 +1867,36 @@ ALIST is an alist, each element has the form (FROM . TO). | |||
| 1864 | FROM and TO are a character or a vector of characters. | 1867 | FROM and TO are a character or a vector of characters. |
| 1865 | If FROM is a character, that character is translated to TO. | 1868 | If FROM is a character, that character is translated to TO. |
| 1866 | If FROM is a vector of characters, that sequence is translated to TO. | 1869 | If FROM is a vector of characters, that sequence is translated to TO. |
| 1867 | The second extra-slot of the value is a translation table for reverse mapping." | 1870 | The first extra-slot of the value is a translation table for reverse mapping." |
| 1868 | (let ((table (make-char-table 'translation-table)) | 1871 | (let ((tables (vector (make-char-table 'translation-table) |
| 1869 | (rev-table (make-char-table 'translation-table)) | 1872 | (make-char-table 'translation-table))) |
| 1870 | max-lookup from to) | 1873 | table max-lookup from to idx val) |
| 1871 | (setq max-lookup 1) | 1874 | (dotimes (i 2) |
| 1872 | (dolist (elt alist) | 1875 | (setq table (aref tables i)) |
| 1873 | (setq from (car elt) to (cdr elt)) | 1876 | (setq max-lookup 1) |
| 1874 | (if (characterp from) | 1877 | (dolist (elt alist) |
| 1875 | (aset table from to) | 1878 | (if (= i 0) |
| 1876 | (let* ((ch (aref from 0)) | 1879 | (setq from (car elt) to (cdr elt)) |
| 1877 | (val (aref table ch))) | 1880 | (setq from (cdr elt) to (car elt))) |
| 1878 | (aset table ch (cons (cons from to) val))) | 1881 | (if (characterp from) |
| 1879 | (setq max-lookup (max max-lookup (length from))))) | 1882 | (setq idx from) |
| 1880 | (set-char-table-extra-slot table 1 max-lookup) | 1883 | (setq idx (aref from 0) |
| 1881 | (setq max-lookup 1) | 1884 | max-lookup (max max-lookup (length from)))) |
| 1882 | (dolist (elt alist) | 1885 | (setq val (aref table idx)) |
| 1883 | (setq from (cdr elt) to (car elt)) | 1886 | (if val |
| 1884 | (if (characterp from) | 1887 | (progn |
| 1885 | (aset rev-table from to) | 1888 | (or (consp val) |
| 1886 | (let* ((ch (aref from 0)) | 1889 | (setq val (list (cons (vector idx) val)))) |
| 1887 | (val (aref rev-table ch))) | 1890 | (if (characterp from) |
| 1888 | (aset rev-table ch (cons (cons from to) val))) | 1891 | (setq from (vector from))) |
| 1889 | (setq max-lookup (max max-lookup (length from))))) | 1892 | (setq val (nconc val (list (cons from to))))) |
| 1890 | (set-char-table-extra-slot rev-table 1 max-lookup) | 1893 | (if (characterp from) |
| 1891 | (set-char-table-extra-slot table 0 rev-table) | 1894 | (setq val to) |
| 1892 | table)) | 1895 | (setq val (list (cons from to))))) |
| 1896 | (aset table idx val)) | ||
| 1897 | (set-char-table-extra-slot table 1 max-lookup)) | ||
| 1898 | (set-char-table-extra-slot (aref tables 0) 0 (aref tables 1)) | ||
| 1899 | (aref tables 0))) | ||
| 1893 | 1900 | ||
| 1894 | (defun define-translation-table (symbol &rest args) | 1901 | (defun define-translation-table (symbol &rest args) |
| 1895 | "Define SYMBOL as the name of translation table made by ARGS. | 1902 | "Define SYMBOL as the name of translation table made by ARGS. |