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 (eval-when-compile (require 'cl))
29 (defun delete-file-with-children (filename)
30 (if (file-directory-p filename)
32 (directory-files filename 'full "^[^.]" 'so-sort)))
35 (delete-file-with-children file)))
36 (remove-directory filename))
37 (delete-file filename)))
41 (defvar system-char-database-directory
42 (expand-file-name "chise-db"
46 (defun file-name-char-attribute-name (filename)
49 (len (length filename))
52 (if (eq (setq chr (aref filename i)) ?%)
53 (setq dest (concat dest
54 (substring filename base i)
58 (substring filename (1+ i) (+ i 3)) 16))))
62 (concat dest (substring filename base len))))
65 ((or load-ignore-elc-files
66 (not (file-exists-p system-char-database-directory)))
67 (if (file-exists-p system-char-database-directory)
68 (delete-file-with-children system-char-database-directory))
70 (load "dumped-chars.el")
71 (dolist (file system-char-db-source-file-list)
74 (dolist (attribute (char-attribute-list))
75 (save-char-attribute-table attribute))
77 (dolist (ccs (charset-list))
78 (and (fboundp 'save-charset-properties)
79 (save-charset-properties ccs))
80 (save-charset-mapping-table ccs))
85 "(setq next-defined-char-id #x%X)\n"
86 next-defined-char-id))
87 (write-region (point-min)(point-max)
88 "../lisp/utf-2000/cid-conf.el"))
91 (if (>= (function-max-args 'char-attribute-list) 1)
92 (char-attribute-list 'rehash)
93 (mapcar (lambda (file)
94 (mount-char-attribute-table
95 (intern (file-name-char-attribute-name file))))
97 (expand-file-name "system-char-id" ; "character/feature"
98 system-char-database-directory)
100 (dolist (ccs (charset-list))
101 (reset-charset-mapping-table ccs))
102 (load "../lisp/utf-2000/cid-conf.el")
105 (load "dumped-chars.el")
106 (dolist (file system-char-db-source-file-list)
108 (dolist (feature '(ideographic-structure))
112 c feature (char-refs-simplify-char-specs v))
117 (defun char-ref= (cr1 cr2 &optional tester)
118 (cond ((char-ref-p cr1)
120 (char-spec= (plist-get cr1 :char)
121 (plist-get cr2 :char) tester)
122 (char-spec= (plist-get cr1 :char) cr2 tester)))
126 (plist-get cr2 :char)
130 (defun char-spec= (cs1 cs2 &optional tester)
135 (funcall tester cs1 cs2)
136 (funcall tester cs1 (find-char cs2)))
138 (funcall tester (find-char cs1) cs2)
139 (funcall tester (find-char cs1) (find-char cs2)))))
147 (if (setq ret (find-char dc))
149 (when (characterp dc)
150 (setq ret (get-char-attribute dc '->uppercase))
152 (member* c ret :test #'char-ref=)
154 (put-case-table-pair c dc (standard-case-table))))
160 ;;; update-cdb.el ends here