update.
[chise/ids.git] / ids-read.el
index ff05c18..1693763 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ids-read.el --- Reader for IDS-* files
 
-;; Copyright (C) 2002,2003,2004 MORIOKA Tomohiko
+;; Copyright (C) 2002, 2003, 2004, 2020, 2021 MORIOKA Tomohiko
 
 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
 ;; Keywords: IDS, IDC, Ideographs, UCS, Unicode
@@ -32,7 +32,7 @@
   (save-excursion
     (set-buffer buffer)
     (goto-char (point-min))
-    (let (line chs ids code char u-char structure)
+    (let (line chs ids apparent-ids code char u-char structure)
       (while (not (eobp))
        (unless (looking-at ";")
          (setq line
                 "\t"))
          (setq chs (car line)
                ids (nth 2 line)
+               apparent-ids (nth 3 line)
                u-char nil)
+         (setq apparent-ids
+               (if (and apparent-ids
+                        (string-match "^@apparent=" apparent-ids))
+                   (substring apparent-ids (match-end 0))))
          (setq char
                (cond
                 ((string-match "U[-+]\\([0-9A-F]+\\)" chs)
                 ((string-match "CB\\([0-9]+\\)" chs)
                  (decode-char 'ideograph-cbeta
                               (string-to-int (match-string 1 chs))))
+                ((string-match "SW-JIGUGE-\\([0-9]+\\)" chs)
+                 (decode-char '=shuowen-jiguge
+                              (string-to-int (match-string 1 chs))))
                 ))
-         (when (and char
-                    (>= (length ids) 3)
-                    (not (string-match "\\?" ids))
-                    (consp (setq structure (ids-parse-string ids simplify))))
-           (when (or (not soft)
-                     (null
-                      (get-char-attribute char 'ideographic-structure)))
-             (put-char-attribute char
-                                 'ideographic-structure
-                                 (cdr (car structure))))
-           (when (and u-char
-                      (not (eq char u-char))
-                      (or (not soft)
-                          (null
-                           (get-char-attribute
-                            u-char 'ideographic-structure))))
-             (put-char-attribute
-              u-char 'ideographic-structure
-              (ideographic-structure-convert-to-domain
-               (cdr (car structure)) 'unicode)))
+         (when char
+           (when (and (>= (length ids) 3)
+                      (not (string-match "\\?" ids))
+                      (consp (setq structure (ids-parse-string ids simplify))))
+             (when (or (not soft)
+                       (null
+                        (get-char-attribute char 'ideographic-structure)))
+               (put-char-attribute char
+                                   'ideographic-structure
+                                   (cdr (car structure))))
+             (when (and u-char
+                        (not (eq char u-char))
+                        (or (not soft)
+                            (null
+                             (get-char-attribute
+                              u-char 'ideographic-structure))))
+               (put-char-attribute
+                u-char 'ideographic-structure
+                (ideographic-structure-convert-to-domain
+                 (cdr (car structure)) 'unicode))))
+           (when (and (>= (length apparent-ids) 3)
+                      (consp (setq structure
+                                   (ids-parse-string apparent-ids simplify))))
+             (when (or (not soft)
+                       (null
+                        (get-char-attribute char 'ideographic-structure@apparent)))
+               (put-char-attribute char
+                                   'ideographic-structure@apparent
+                                   (cdr (car structure)))))
            )
          )
        (forward-line)