diff options
| author | Kenichi Handa | 1997-05-16 00:58:57 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-05-16 00:58:57 +0000 |
| commit | 13d5617d046fca406276dc7a923db3ea7750a1a7 (patch) | |
| tree | cc84e728ed79805dcc583a1b6b61565877e939d0 | |
| parent | 632a44143ffee4fa3a86dcdcc30091e707e5771a (diff) | |
| download | emacs-13d5617d046fca406276dc7a923db3ea7750a1a7.tar.gz emacs-13d5617d046fca406276dc7a923db3ea7750a1a7.zip | |
(make-unification-table): Fix handling of a generic
character.
Coding system names changed as follows:
internal -> emacs-mule, automatic-conversion -> undecided.
Coding category name changes as follows:
coding-category-internal -> coding-category-emacs-mule.
(charset-list): Bug fixed.
| -rw-r--r-- | lisp/international/mule.el | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 5f08051f356..9dd3f033432 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -202,7 +202,14 @@ A generic character can be used to index a char table (e.g. syntax-table)." | |||
| 202 | 202 | ||
| 203 | (defmacro charset-list () | 203 | (defmacro charset-list () |
| 204 | "Return list of charsets ever defined." | 204 | "Return list of charsets ever defined." |
| 205 | charset-list) | 205 | 'charset-list) |
| 206 | |||
| 207 | (defsubst generic-char-p (char) | ||
| 208 | "Return t if and only if CHAR is a generic character. | ||
| 209 | See also the documentation of make-char." | ||
| 210 | (let ((l (split-char char))) | ||
| 211 | (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0)) | ||
| 212 | (not (eq (car l) 'composition))))) | ||
| 206 | 213 | ||
| 207 | ;; Coding-system staffs | 214 | ;; Coding-system staffs |
| 208 | 215 | ||
| @@ -512,7 +519,7 @@ is set to the returned value. | |||
| 512 | ;; But eol-type is not yet set. | 519 | ;; But eol-type is not yet set. |
| 513 | (setq local-eol nil)) | 520 | (setq local-eol nil)) |
| 514 | (if (null (eq (coding-system-type buffer-file-coding-system) t)) | 521 | (if (null (eq (coding-system-type buffer-file-coding-system) t)) |
| 515 | ;; This is not automatic-conversion. | 522 | ;; This is not `undecided'. |
| 516 | (progn | 523 | (progn |
| 517 | (setq local-coding buffer-file-coding-system) | 524 | (setq local-coding buffer-file-coding-system) |
| 518 | (while (symbolp (get local-coding 'coding-system)) | 525 | (while (symbolp (get local-coding 'coding-system)) |
| @@ -529,8 +536,8 @@ is set to the returned value. | |||
| 529 | ;; But eol-type is not found. | 536 | ;; But eol-type is not found. |
| 530 | (setq found-eol nil)) | 537 | (setq found-eol nil)) |
| 531 | (if (eq (coding-system-type coding) t) | 538 | (if (eq (coding-system-type coding) t) |
| 532 | ;; This is automatic-conversion, which means nothing found | 539 | ;; This is `undecided', which means nothing found except |
| 533 | ;; except for eol-type. | 540 | ;; for eol-type. |
| 534 | (setq coding nil)) | 541 | (setq coding nil)) |
| 535 | 542 | ||
| 536 | ;; The local setting takes precedence over the found one. | 543 | ;; The local setting takes precedence over the found one. |
| @@ -544,27 +551,43 @@ is set to the returned value. | |||
| 544 | 551 | ||
| 545 | (defun make-unification-table (&rest args) | 552 | (defun make-unification-table (&rest args) |
| 546 | "Make a unification table (char table) from arguments. | 553 | "Make a unification table (char table) from arguments. |
| 547 | Each argument is a list of cons cells of characters. | 554 | Each argument is a list of the form (FROM . TO), |
| 548 | While unifying characters in the unification table, a character of | 555 | where FROM is a character to be unified to TO. |
| 549 | the car part is unified to a character of the corresponding cdr part. | 556 | |
| 550 | 557 | FROM can be a generic character (see make-char). In this case, TO is | |
| 551 | A characters can be a generic characters (see make-char). In this case, | 558 | a generic character containing the same number of charcters or a |
| 552 | all characters belonging to a generic character of the car part | 559 | oridinal character. If FROM and TO are both generic characters, all |
| 553 | are unified to characters beloging to a generic characters of the | 560 | characters belonging to FROM are unified to characters belonging to TO |
| 554 | corresponding cdr part without changing their position code(s)." | 561 | without changing their position code(s)." |
| 555 | (let ((table (make-char-table 'character-unification-table)) | 562 | (let ((table (make-char-table 'character-unification-table)) |
| 556 | revlist) | 563 | revlist) |
| 557 | (while args | 564 | (while args |
| 558 | (let ((elts (car args))) | 565 | (let ((elts (car args))) |
| 559 | (while elts | 566 | (while elts |
| 560 | (let ((from (car (car elts))) | 567 | (let* ((from (car (car elts))) |
| 561 | (to (cdr (car elts)))) | 568 | (from-i 0) ; degree of freedom of FROM |
| 562 | (if (or (not (integerp from)) (not (integerp to))) | 569 | (from-rev (nreverse (split-char from))) |
| 563 | (error "Invalid character pair (%s . %s)" from to)) | 570 | (to (cdr (car elts))) |
| 564 | ;; If we have already unified TO to some char, FROM should | 571 | (to-i 0) ; degree of freedom of TO |
| 565 | ;; also be unified to the same char. | 572 | (to-rev (nreverse (split-char to)))) |
| 566 | (setq to (or (aref table to) to)) | 573 | ;; Check numbers of heading 0s in FROM-REV and TO-REV. |
| 567 | (aset table from to) | 574 | (while (eq (car from-rev) 0) |
| 575 | (setq from-i (1+ from-i) from-rev (cdr from-rev))) | ||
| 576 | (while (eq (car to-rev) 0) | ||
| 577 | (setq to-i (1+ to-i) to-rev (cdr to-rev))) | ||
| 578 | (if (and (/= from-i to-i) (/= to-i 0)) | ||
| 579 | (error "Invalid character pair (%d . %d)" from to)) | ||
| 580 | ;; If we have already unified TO to TO-ALT, FROM should | ||
| 581 | ;; also be unified to TO-ALT. But, this is only if TO is | ||
| 582 | ;; a generic character or TO-ALT is not a generic | ||
| 583 | ;; character. | ||
| 584 | (let ((to-alt (aref table to))) | ||
| 585 | (if (and to-alt | ||
| 586 | (or (> to-i 0) (not (generic-char-p to-alt)))) | ||
| 587 | (setq to to-alt))) | ||
| 588 | (if (> from-i 0) | ||
| 589 | (set-char-table-default table from to) | ||
| 590 | (aset table from to)) | ||
| 568 | ;; If we have already unified some chars to FROM, they | 591 | ;; If we have already unified some chars to FROM, they |
| 569 | ;; should also be unified to TO. | 592 | ;; should also be unified to TO. |
| 570 | (let ((l (assq from revlist))) | 593 | (let ((l (assq from revlist))) |