1 ;;; update-cdb.el --- Update and/or setup character attribute database
3 ;; Copyright (C) 2002,2003,2004 MORIOKA Tomohiko.
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: Character, Database, CHISE, Unicode, UCS-4, MULE.
8 ;; This file is part of XEmacs CHISE.
10 ;; XEmacs CHISE is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; XEmacs CHISE is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs CHISE; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (defun delete-file-with-children (filename)
28 (if (file-directory-p filename)
30 (directory-files filename 'full "^[^.]" 'so-sort)))
33 (delete-file-with-children file)))
34 (remove-directory filename))
35 (delete-file filename)))
39 (defvar system-char-database-directory
40 (expand-file-name "chise-db"
44 (defun file-name-char-attribute-name (filename)
47 (len (length filename))
50 (if (eq (setq chr (aref filename i)) ?%)
51 (setq dest (concat dest
52 (substring filename base i)
56 (substring filename (1+ i) (+ i 3)) 16))))
60 (concat dest (substring filename base len))))
63 ((or load-ignore-elc-files
64 (not (file-exists-p system-char-database-directory)))
65 (if (file-exists-p system-char-database-directory)
66 (delete-file-with-children system-char-database-directory))
68 (load "dumped-chars.el")
69 (dolist (file system-char-db-source-file-list)
72 (dolist (attribute (char-attribute-list))
73 (save-char-attribute-table attribute))
75 (dolist (ccs (charset-list))
76 (and (fboundp 'save-charset-properties)
77 (save-charset-properties ccs))
78 (save-charset-mapping-table ccs))
83 "(setq next-defined-char-id #x%X)\n"
84 next-defined-char-id))
85 (write-region (point-min)(point-max)
86 "../lisp/utf-2000/cid-conf.el"))
89 (if (>= (function-max-args 'char-attribute-list) 1)
90 (char-attribute-list 'rehash)
91 (mapcar (lambda (file)
92 (mount-char-attribute-table
93 (intern (file-name-char-attribute-name file))))
95 (expand-file-name "system-char-id" ; "character/feature"
96 system-char-database-directory)
98 (dolist (ccs (charset-list))
99 (reset-charset-mapping-table ccs))
100 (load "../lisp/utf-2000/cid-conf.el")
103 (load "dumped-chars.el")
104 (dolist (file system-char-db-source-file-list)
108 (defun char-ref= (cr1 cr2 &optional tester)
109 (cond ((char-ref-p cr1)
111 (char-spec= (plist-get cr1 :char)
112 (plist-get cr2 :char) tester)
113 (char-spec= (plist-get cr1 :char) cr2 tester)))
117 (plist-get cr2 :char)
121 (defun char-spec= (cs1 cs2 &optional tester)
126 (funcall tester cs1 cs2)
127 (funcall tester cs1 (find-char cs2)))
129 (funcall tester (find-char cs1) cs2)
130 (funcall tester (find-char cs1) (find-char cs2)))))
138 (if (setq ret (find-char dc))
140 (when (characterp dc)
141 (setq ret (get-char-attribute dc '->uppercase))
143 (member* c ret :test #'char-ref=)
145 (put-case-table-pair c dc (standard-case-table))))
151 ;;; update-cdb.el ends here