annotate src/charset.c @ 88399:c93a7728939b

Don't load "international/utf-8". Don't call update-coding-systems-internal. Bind coding-system-for-write to `utf-8' while writing fns-XXX.el. Call clear-charset-maps before dumping.
author Kenichi Handa <handa@m17n.org>
date Fri, 01 Mar 2002 02:00:32 +0000
parents f6557aebe110
children 9a1e7befb0b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1 /* Basic character set support.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
2 Copyright (C) 1995, 97, 98, 2000, 2001 Electrotechnical Laboratory, JAPAN.
18341
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 18003
diff changeset
3 Licensed to the Free Software Foundation.
38394
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
4 Copyright (C) 2001 Free Software Foundation, Inc.
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
5 Copyright (C) 2001, 2002
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
6 National Institute of Advanced Industrial Science and Technology (AIST)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
7 Registration Number H13PRO009
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
9 This file is part of GNU Emacs.
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
10
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
11 GNU Emacs is free software; you can redistribute it and/or modify
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
12 it under the terms of the GNU General Public License as published by
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
13 the Free Software Foundation; either version 2, or (at your option)
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
14 any later version.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
16 GNU Emacs is distributed in the hope that it will be useful,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
19 GNU General Public License for more details.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 You should have received a copy of the GNU General Public License
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 along with GNU Emacs; see the file COPYING. If not, write to
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
24 Boston, MA 02111-1307, USA. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25611
diff changeset
26 #ifdef emacs
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25611
diff changeset
27 #include <config.h>
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25611
diff changeset
28 #endif
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25611
diff changeset
29
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 #include <stdio.h>
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
31 #include <unistd.h>
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
32 #include <ctype.h>
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 #ifdef emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 #include <sys/types.h>
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 #include "lisp.h"
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
38 #include "character.h"
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 #include "charset.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 #include "coding.h"
17843
f03ff9d069c6 Include disptab.h.
Kenichi Handa <handa@m17n.org>
parents: 17834
diff changeset
41 #include "disptab.h"
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
42 #include "buffer.h"
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 #else /* not emacs */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 #include "mulelib.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 #endif /* emacs */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
50
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
51 /*** GENERAL NOTE on CODED CHARACTER SET (CHARSET) ***
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
53 A coded character set ("charset" hereafter) is a meaningful
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
54 collection (i.e. language, culture, functionality, etc) of
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
55 characters. Emacs handles multiple charsets at once. In Emacs Lisp
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
56 code, a charset is represented by symbol. In C code, a charset is
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
57 represented by its ID number or by a pointer the struct charset.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
59 The actual information about each charset is stored in two places.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
60 Lispy information is stored in the hash table Vcharset_hash_table as
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
61 a vector (charset attributes). The other information is stored in
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
62 charset_table as struct charset.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
64 */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
66 /* List of all charsets. This variable is used only from Emacs
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
67 Lisp. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 Lisp_Object Vcharset_list;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
70 /* Hash table that contains attributes of each charset. Keys are
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
71 charset symbols, and values are vectors of charset attributes. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
72 Lisp_Object Vcharset_hash_table;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
73
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
74 /* Table of struct charset. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
75 struct charset *charset_table;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
76
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
77 static int charset_table_size;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
78 int charset_table_used;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
79
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
80 Lisp_Object Qcharsetp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
81
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
82 /* Special charset symbols. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
83 Lisp_Object Qascii;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
84 Lisp_Object Qeight_bit_control;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
85 Lisp_Object Qeight_bit_graphic;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
86 Lisp_Object Qiso_8859_1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
87 Lisp_Object Qunicode;
20720
f084bb8d535f (min_composite_char): New variable.
Kenichi Handa <handa@m17n.org>
parents: 20705
diff changeset
88
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
89 /* The corresponding charsets. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
90 int charset_ascii;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
91 int charset_8_bit_control;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
92 int charset_8_bit_graphic;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
93 int charset_iso_8859_1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
94 int charset_unicode;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
95
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
96 /* Value of charset attribute `charset-iso-plane'. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
97 Lisp_Object Qgl, Qgr;
23489
09201cebfa21 (Vauto_fill_chars, Qauto_fill_chars): New variables.
Kenichi Handa <handa@m17n.org>
parents: 23427
diff changeset
98
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
99 /* The primary charset. It is a charset of unibyte characters. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
100 int charset_primary;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
101
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
102 /* List of charsets ordered by the priority. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
103 Lisp_Object Vcharset_ordered_list;
23489
09201cebfa21 (Vauto_fill_chars, Qauto_fill_chars): New variables.
Kenichi Handa <handa@m17n.org>
parents: 23427
diff changeset
104
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
105 /* List of iso-2022 charsets. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
106 Lisp_Object Viso_2022_charset_list;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
107
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
108 /* List of emacs-mule charsets. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
109 Lisp_Object Vemacs_mule_charset_list;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
110
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
111 struct charset *emacs_mule_charset[256];
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 /* Mapping table from ISO2022's charset (specified by DIMENSION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 CHARS, and FINAL-CHAR) to Emacs' charset. */
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
115 int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
117 Lisp_Object Vcharset_map_directory;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
118
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
119 Lisp_Object Vchar_unified_charset_table;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
121 #define CODE_POINT_TO_INDEX(charset, code) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
122 ((charset)->code_linear_p \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
123 ? (code) - (charset)->min_code \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
124 : ((((code) >> 24) <= (charset)->code_space[13]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
125 && ((((code) >> 16) & 0xFF) <= (charset)->code_space[9]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
126 && ((((code) >> 8) & 0xFF) <= (charset)->code_space[5]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
127 && (((code) & 0xFF) <= (charset)->code_space[1])) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
128 ? (((((code) >> 24) - (charset)->code_space[12]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
129 * (charset)->code_space[11]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
130 + (((((code) >> 16) & 0xFF) - (charset)->code_space[8]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
131 * (charset)->code_space[7]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
132 + (((((code) >> 8) & 0xFF) - (charset)->code_space[4]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
133 * (charset)->code_space[3]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
134 + (((code) & 0xFF) - (charset)->code_space[0])) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
135 : -1)
20705
a949dc65fbea (nonascii_insert_offset): Variable moved from cmds.c.
Richard M. Stallman <rms@gnu.org>
parents: 20636
diff changeset
136
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
137
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
138 /* Convert the character index IDX to code-point CODE for CHARSET.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
139 It is assumed that IDX is in a valid range. */
20890
c7cfd531cf2b (Vnonascii_translate_table): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20833
diff changeset
140
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
141 #define INDEX_TO_CODE_POINT(charset, idx) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
142 ((charset)->code_linear_p \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
143 ? (idx) + (charset)->min_code \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
144 : (((charset)->code_space[0] + (idx) % (charset)->code_space[2]) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
145 | (((charset)->code_space[4] \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
146 + ((idx) / (charset)->code_space[3] % (charset)->code_space[6])) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
147 << 8) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
148 | (((charset)->code_space[8] \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
149 + ((idx) / (charset)->code_space[7] % (charset)->code_space[10])) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
150 << 16) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
151 | (((charset)->code_space[12] + ((idx) / (charset)->code_space[11])) \
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
152 << 24)))
22703
15e0119749cf (Vgeneric_character_list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22524
diff changeset
153
19384
6ce37633c7f9 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19025
diff changeset
154
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
155
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
156 /* Set to 1 when a charset map is loaded to warn that a buffer text
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
157 and a string data may be relocated. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
158 int charset_map_loaded;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
159
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
160 /* Parse the mapping vector MAP which has this form:
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
161 [CODE0 CHAR0 CODE1 CHAR1 ... ]
20933
5ceea9d50194 (invalid_character): New function.
Kenichi Handa <handa@m17n.org>
parents: 20890
diff changeset
162
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
163 If CONTROL_FLAG is 0, setup CHARSET->min_char and CHARSET->max_char.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
164
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
165 If CONTROL_FLAG is 1, setup CHARSET->min_char, CHARSET->max_char,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
166 CHARSET->decoder, and CHARSET->encoder.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
167
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
168 If CONTROL_FLAG is 2, setup CHARSET->deunifier and
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
169 Vchar_unify_table. If Vchar_unified_charset_table is non-nil,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
170 setup it too. */
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
171
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
172 static void
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
173 parse_charset_map (charset, map, control_flag)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
174 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
175 Lisp_Object map;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
176 int control_flag;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
177 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
178 Lisp_Object vec, table;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
179 unsigned min_code = CHARSET_MIN_CODE (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
180 unsigned max_code = CHARSET_MAX_CODE (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
181 int ascii_compatible_p = charset->ascii_compatible_p;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
182 int min_char, max_char, nonascii_min_char;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
183 int size;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
184 int i;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
185 int first;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
186 unsigned char *fast_map = charset->fast_map;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
187
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
188 if (control_flag)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
189 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
190 int n = CODE_POINT_TO_INDEX (charset, max_code) + 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
191 unsigned invalid_code = CHARSET_INVALID_CODE (charset);
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
192
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
193 table = Fmake_char_table (Qnil, make_number (invalid_code));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
194 if (control_flag == 1)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
195 vec = Fmake_vector (make_number (n), make_number (-1));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
196 else if (! CHAR_TABLE_P (Vchar_unify_table))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
197 Vchar_unify_table = Fmake_char_table (Qnil, make_number (-1));
20933
5ceea9d50194 (invalid_character): New function.
Kenichi Handa <handa@m17n.org>
parents: 20890
diff changeset
198
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
199 charset_map_loaded = 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
200 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
202 size = ASIZE (map);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
203 nonascii_min_char = MAX_CHAR;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
204 CHARSET_COMPACT_CODES_P (charset) = 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
205 for (first = 1, i = 0; i < size; i += 2)
23767
1dfb6d38354f (non_ascii_char_to_string): If C has modifier bits,
Kenichi Handa <handa@m17n.org>
parents: 23720
diff changeset
206 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
207 Lisp_Object val;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
208 unsigned code, temp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
209 int c, char_index;
25250
2228d0a678ef (non_ascii_char_to_string): Handle modifier bits as
Kenichi Handa <handa@m17n.org>
parents: 23978
diff changeset
210
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
211 val = AREF (map, i);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
212 CHECK_NATNUM (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
213 code = XFASTINT (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
214 val = AREF (map, i + 1);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
215 CHECK_NATNUM (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
216 c = XFASTINT (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
217
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
218 if (code < min_code || code > max_code)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
219 continue;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
220 char_index = CODE_POINT_TO_INDEX (charset, code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
221 if (char_index < 0
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
222 || c > MAX_CHAR)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
223 continue;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
224
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
225 if (control_flag < 2)
25250
2228d0a678ef (non_ascii_char_to_string): Handle modifier bits as
Kenichi Handa <handa@m17n.org>
parents: 23978
diff changeset
226 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
227 if (first)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
228 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
229 min_char = max_char = c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
230 first = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
231 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
232 else if (c > max_char)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
233 max_char = c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
234 else if (c < min_char)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
235 min_char = c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
236 if (ascii_compatible_p && ! ASCII_BYTE_P (c)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
237 && c < nonascii_min_char)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
238 nonascii_min_char = c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
239
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
240 CHARSET_FAST_MAP_SET (c, fast_map);
25250
2228d0a678ef (non_ascii_char_to_string): Handle modifier bits as
Kenichi Handa <handa@m17n.org>
parents: 23978
diff changeset
241 }
2228d0a678ef (non_ascii_char_to_string): Handle modifier bits as
Kenichi Handa <handa@m17n.org>
parents: 23978
diff changeset
242
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
243 if (control_flag)
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
244 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
245 if (control_flag == 1)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
246 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
247 if (char_index >= ASIZE (vec))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
248 abort ();
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
249 ASET (vec, char_index, make_number (c));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
250 if (code > 0x7FFFFFF)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
251 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
252 CHAR_TABLE_SET (table, c,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
253 Fcons (make_number (code >> 16),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
254 make_number (code & 0xFFFF)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
255 CHARSET_COMPACT_CODES_P (charset) = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
256 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
257 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
258 CHAR_TABLE_SET (table, c, make_number (code));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
259 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
260 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
261 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
262 int c1 = DECODE_CHAR (charset, code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
263 if (c1 >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
264 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
265 CHAR_TABLE_SET (table, c, make_number (c1));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
266 CHAR_TABLE_SET (Vchar_unify_table, c1, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
267 if (CHAR_TABLE_P (Vchar_unified_charset_table))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
268 CHAR_TABLE_SET (Vchar_unified_charset_table, c1,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
269 CHARSET_NAME (charset));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
270 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
271 }
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
272 }
23767
1dfb6d38354f (non_ascii_char_to_string): If C has modifier bits,
Kenichi Handa <handa@m17n.org>
parents: 23720
diff changeset
273 }
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
274
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
275 if (control_flag < 2)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
277 CHARSET_MIN_CHAR (charset) = (ascii_compatible_p
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
278 ? nonascii_min_char : min_char);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
279 CHARSET_MAX_CHAR (charset) = max_char;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
280 if (control_flag)
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
281 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
282 CHARSET_DECODER (charset) = vec;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
283 CHARSET_ENCODER (charset) = table;
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
284 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 }
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
286 else
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
287 CHARSET_DEUNIFIER (charset) = table;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
288 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
289
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
290
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
291 /* Read a hexadecimal number (preceded by "0x") from the file FP while
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
292 paying attention to comment charcter '#'. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
293
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
294 static INLINE unsigned
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
295 read_hex (fp, eof)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
296 FILE *fp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
297 int *eof;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
298 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
299 int c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
300 unsigned n;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
302 while ((c = getc (fp)) != EOF)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
303 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
304 if (c == '#' || c == ' ')
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
305 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
306 while ((c = getc (fp)) != EOF && c != '\n');
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
307 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
308 else if (c == '0')
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
309 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
310 if ((c = getc (fp)) == EOF || c == 'x')
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
311 break;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
312 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
313 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
314 if (c == EOF)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
315 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
316 *eof = 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
317 return 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
318 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
319 *eof = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
320 n = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
321 if (c == 'x')
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
322 while ((c = getc (fp)) != EOF && isxdigit (c))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
323 n = ((n << 4)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
324 | (c <= '9' ? c - '0' : c <= 'F' ? c - 'A' + 10 : c - 'a' + 10));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
325 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
326 while ((c = getc (fp)) != EOF && isdigit (c))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
327 n = (n * 10) + c - '0';
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
328 return n;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330
38394
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
331
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
332 /* Return a mapping vector for CHARSET loaded from MAPFILE.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
333 Each line of MAPFILE has this form:
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
334 0xAAAA 0xBBBB
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
335 where 0xAAAA is a code-point and 0xBBBB is the corresponding
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
336 character code.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
337 The returned vector has this form:
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
338 [ CODE1 CHAR1 CODE2 CHAR2 .... ]
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
339 */
38394
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
340
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
341 static Lisp_Object
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
342 load_charset_map (charset, mapfile)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
343 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
344 Lisp_Object mapfile;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
345 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
346 int fd;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
347 FILE *fp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
348 int num;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
349 unsigned *numbers_table[256];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
350 int numbers_table_used;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
351 unsigned *numbers;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
352 int eof;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
353 Lisp_Object suffixes;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
354 Lisp_Object vec;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
355 int i;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
356
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
357 suffixes = Fcons (build_string (".map"),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
358 Fcons (build_string (".TXT"), Qnil));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
359
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
360 fd = openp (Fcons (Vcharset_map_directory, Qnil), mapfile, suffixes,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
361 NULL, 0);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
362 if (fd < 0
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
363 || ! (fp = fdopen (fd, "r")))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
364 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
365 add_to_log ("Failure in loading charset map: %S", mapfile, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
366 return Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
367 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
368
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
369 numbers_table_used = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
370 num = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
371 eof = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
372 while (1)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
373 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
374 unsigned n = read_hex (fp, &eof);
38394
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
375
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
376 if (eof)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
377 break;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
378 if ((num % 0x10000) == 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
379 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
380 if (numbers_table_used == 256)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
381 break;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
382 numbers = (unsigned *) alloca (sizeof (unsigned) * 0x10000);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
383 numbers_table[numbers_table_used++] = numbers;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
384 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
385 *numbers++ = n;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
386 num++;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
387 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
388 fclose (fp);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
389 close (fd);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
390
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
391 vec = Fmake_vector (make_number (num), Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
392 for (i = 0; i < num; i++, numbers++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
393 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
394 if ((i % 0x10000) == 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
395 numbers = numbers_table[i / 0x10000];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
396 ASET (vec, i, make_number (*numbers));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
397 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
398
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
399 charset_map_loaded = 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
400
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
401 return vec;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
402 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
403
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
404 static void
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
405 load_charset (charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
406 struct charset *charset;
38394
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
407 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
408 if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP_DEFERRED)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
409 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
410 Lisp_Object map;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
411
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
412 map = CHARSET_MAP (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
413 if (STRINGP (map))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
414 map = load_charset_map (charset, map);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
415 parse_charset_map (charset, map, 1);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
416 CHARSET_METHOD (charset) = CHARSET_METHOD_MAP;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
417 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
418 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
419
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
420
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
421 DEFUN ("charsetp", Fcharsetp, Scharsetp, 1, 1, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
422 doc: /* Return non-nil if and only if OBJECT is a charset.*/)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
423 (object)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
424 Lisp_Object object;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
425 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
426 return (CHARSETP (object) ? Qt : Qnil);
38394
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
427 }
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
428
245ae371bd4d (char_to_string_1): Extracted from char_to_string.
Gerd Moellmann <gerd@gnu.org>
parents: 36521
diff changeset
429
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
430 void
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
431 map_charset_chars (c_function, function, charset_symbol, arg)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
432 void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
433 Lisp_Object function, charset_symbol, arg;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
434 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
435 int id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
436 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
437 Lisp_Object range;
22185
80a2aa51a6e1 Change term "character translation table" to
Kenichi Handa <handa@m17n.org>
parents: 22168
diff changeset
438
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
439 CHECK_CHARSET_GET_ID (charset_symbol, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
440 charset = CHARSET_FROM_ID (id);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
442 if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP_DEFERRED)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
443 load_charset (charset);
21445
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
444
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
445 if (CHARSET_METHOD (charset) == CHARSET_METHOD_OFFSET)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
446 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
447 range = Fcons (make_number (CHARSET_MIN_CHAR (charset)),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
448 make_number (CHARSET_MAX_CHAR (charset)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
449 if (NILP (function))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
450 (*c_function) (arg, range, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
451 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
452 call2 (function, range, arg);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
453 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
454 else if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
455 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
456 if (! CHAR_TABLE_P (CHARSET_ENCODER (charset)))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
457 return;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
458 if (CHARSET_ASCII_COMPATIBLE_P (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
459 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
460 range = Fcons (make_number (0), make_number (127));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
461 if (NILP (function))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
462 (*c_function) (arg, range, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
463 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
464 call2 (function, range, arg);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
465 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
466 map_char_table (c_function, function, CHARSET_ENCODER (charset), arg,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
467 0, NULL);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
468 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
469 else /* i.e. CHARSET_METHOD_PARENT */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
470 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
471 int from, to, c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
472 unsigned code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
473 int i, j, k, l;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
474 int *code_space = CHARSET_CODE_SPACE (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
475 Lisp_Object val;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
477 range = Fcons (Qnil, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
478 from = to = -2;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
479 for (i = code_space[12]; i <= code_space[13]; i++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
480 for (j = code_space[8]; j <= code_space[9]; j++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
481 for (k = code_space[4]; k <= code_space[5]; k++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
482 for (l = code_space[0]; l <= code_space[1]; l++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
483 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
484 code = (i << 24) | (j << 16) | (k << 8) | l;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
485 c = DECODE_CHAR (charset, code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
486 if (c == to + 1)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
487 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
488 to++;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
489 continue;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
490 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
491 if (from >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
492 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
493 if (from < to)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
494 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
495 XSETCAR (range, make_number (from));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
496 XSETCDR (range, make_number (to));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
497 val = range;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
498 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
499 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
500 val = make_number (from);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
501 if (NILP (function))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
502 (*c_function) (arg, val, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
503 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
504 call2 (function, val, arg);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
505 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
506 from = to = (c < 0 ? -2 : c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
507 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
508 if (from >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
509 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
510 if (from < to)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
511 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
512 XSETCAR (range, make_number (from));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
513 XSETCDR (range, make_number (to));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
514 val = range;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
515 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
516 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
517 val = make_number (from);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
518 if (NILP (function))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
519 (*c_function) (arg, val, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
520 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
521 call2 (function, val, arg);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
522 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
523 }
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
524 }
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
525
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
526 DEFUN ("map-charset-chars", Fmap_charset_chars, Smap_charset_chars, 2, 3, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
527 doc: /* Call FUNCTION for each characters in CHARSET.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
528 FUNCTION is called with three arguments; FROM, TO, and the 3rd optional
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
529 argument ARG.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
530 FROM and TO indicates a range of character sequence that are contained
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
531 in CHARSET. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
532 (function, charset, arg)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
533 Lisp_Object function, charset, arg;
17727
9d39361ce928 (unify_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 17366
diff changeset
534 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
535 map_charset_chars (NULL, function, charset, arg);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
536 return Qnil;
20705
a949dc65fbea (nonascii_insert_offset): Variable moved from cmds.c.
Richard M. Stallman <rms@gnu.org>
parents: 20636
diff changeset
537 }
22927
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
538
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
539
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
540 /* Define a charset according to the arguments. The Nth argument is
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
541 the Nth attribute of the charset (the last attribute `charset-id'
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
542 is not included). See the docstring of `define-charset' for the
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
543 detail. */
22927
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
544
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
545 DEFUN ("define-charset-internal", Fdefine_charset_internal,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
546 Sdefine_charset_internal, charset_arg_max, MANY, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
547 doc: /* For internal use only. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
548 (nargs, args)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
549 int nargs;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
550 Lisp_Object *args;
22927
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
551 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
552 /* Charset attr vector. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
553 Lisp_Object attrs;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
554 Lisp_Object val;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
555 unsigned hash_code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
556 struct Lisp_Hash_Table *hash_table = XHASH_TABLE (Vcharset_hash_table);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
557 int i;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
558 struct charset charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
559 int id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
560 int dimension;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
561 int new_definition_p;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
562 int nchars;
22927
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
563
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
564 if (nargs != charset_arg_max)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
565 return Fsignal (Qwrong_number_of_arguments,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
566 Fcons (intern ("define-charset-internal"),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
567 make_number (nargs)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
568
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
569 attrs = Fmake_vector (make_number (charset_attr_max), Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
570
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
571 CHECK_SYMBOL (args[charset_arg_name]);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
572 ASET (attrs, charset_name, args[charset_arg_name]);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
573
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
574 val = args[charset_arg_code_space];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
575 for (i = 0, dimension = 0, nchars = 1; i < 4; i++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
576 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
577 int min_byte, max_byte;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
578
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
579 min_byte = XINT (Faref (val, make_number (i * 2)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
580 max_byte = XINT (Faref (val, make_number (i * 2 + 1)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
581 if (min_byte < 0 || min_byte > max_byte || max_byte >= 256)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
582 error ("Invalid :code-space value");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
583 charset.code_space[i * 4] = min_byte;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
584 charset.code_space[i * 4 + 1] = max_byte;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
585 charset.code_space[i * 4 + 2] = max_byte - min_byte + 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
586 nchars *= charset.code_space[i * 4 + 2];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
587 charset.code_space[i * 4 + 3] = nchars;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
588 if (max_byte > 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
589 dimension = i + 1;
22927
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
590 }
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
591
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
592 val = args[charset_arg_dimension];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
593 if (NILP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
594 charset.dimension = dimension;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
595 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
596 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
597 CHECK_NATNUM (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
598 charset.dimension = XINT (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
599 if (charset.dimension < 1 || charset.dimension > 4)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
600 args_out_of_range_3 (val, make_number (1), make_number (4));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
601 }
22927
209acf11198c (multibyte_char_to_unibyte): New function.
Kenichi Handa <handa@m17n.org>
parents: 22774
diff changeset
602
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
603 charset.code_linear_p
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
604 = (charset.dimension == 1
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
605 || (charset.code_space[2] == 256
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
606 && (charset.dimension == 2
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
607 || (charset.code_space[6] == 256
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
608 && (charset.dimension == 3
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
609 || charset.code_space[10] == 256)))));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
610
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
611 charset.iso_chars_96 = charset.code_space[2] == 96;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
613 charset.min_code = (charset.code_space[0]
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
614 | (charset.code_space[4] << 8)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
615 | (charset.code_space[8] << 16)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
616 | (charset.code_space[12] << 24));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
617 charset.max_code = (charset.code_space[1]
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
618 | (charset.code_space[5] << 8)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
619 | (charset.code_space[9] << 16)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
620 | (charset.code_space[13] << 24));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
622 val = args[charset_arg_invalid_code];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
623 if (NILP (val))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
625 if (charset.min_code > 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
626 charset.invalid_code = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
627 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
628 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
629 XSETINT (val, charset.max_code + 1);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
630 if (XINT (val) == charset.max_code + 1)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
631 charset.invalid_code = charset.max_code + 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
632 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
633 error ("Attribute :invalid-code must be specified");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
634 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
638 CHECK_NATNUM (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
639 charset.invalid_code = XFASTINT (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
640 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
641
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
642 val = args[charset_arg_iso_final];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
643 if (NILP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
644 charset.iso_final = -1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
645 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
646 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
647 CHECK_NUMBER (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
648 if (XINT (val) < '0' || XINT (val) > 127)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
649 error ("Invalid iso-final-char: %d", XINT (val));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
650 charset.iso_final = XINT (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
651 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
652
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
653 val = args[charset_arg_iso_revision];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
654 if (NILP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
655 charset.iso_revision = -1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
656 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
657 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
658 CHECK_NUMBER (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
659 if (XINT (val) > 63)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
660 args_out_of_range (make_number (63), val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
661 charset.iso_revision = XINT (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
662 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
663
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
664 val = args[charset_arg_emacs_mule_id];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
665 if (NILP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
666 charset.emacs_mule_id = -1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
667 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
668 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
669 CHECK_NATNUM (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
670 if ((XINT (val) > 0 && XINT (val) <= 128) || XINT (val) >= 256)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
671 error ("Invalid emacs-mule-id: %d", XINT (val));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
672 charset.emacs_mule_id = XINT (val);
29538
c0c34d18e8a0 (update_charset_table): Update the table
Kenichi Handa <handa@m17n.org>
parents: 29269
diff changeset
673 }
23628
4a0a107fac9e (string_to_non_ascii_char): Change the check for the
Kenichi Handa <handa@m17n.org>
parents: 23576
diff changeset
674
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
675 charset.ascii_compatible_p = ! NILP (args[charset_arg_ascii_compatible_p]);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
676
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
677 charset.supplementary_p = ! NILP (args[charset_arg_supplementary_p]);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
678
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
679 charset.unified_p = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
680
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
681 bzero (charset.fast_map, sizeof (charset.fast_map));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
682
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
683 if (! NILP (args[charset_arg_code_offset]))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
684 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
685 val = args[charset_arg_code_offset];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
686 CHECK_NUMBER (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
687
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
688 charset.method = CHARSET_METHOD_OFFSET;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
689 charset.code_offset = XINT (val);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
691 i = CODE_POINT_TO_INDEX (&charset, charset.min_code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
692 charset.min_char = i + charset.code_offset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
693 i = CODE_POINT_TO_INDEX (&charset, charset.max_code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
694 charset.max_char = i + charset.code_offset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
695 if (charset.max_char > MAX_CHAR)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
696 error ("Unsupported max char: %d", charset.max_char);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
698 for (i = charset.min_char; i < 0x10000 && i <= charset.max_char;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
699 i += 128)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
700 CHARSET_FAST_MAP_SET (i, charset.fast_map);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
701 for (; i <= charset.max_char; i += 0x1000)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
702 CHARSET_FAST_MAP_SET (i, charset.fast_map);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
703 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
704 else if (! NILP (args[charset_arg_map]))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
705 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
706 val = args[charset_arg_map];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
707 ASET (attrs, charset_map, val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
708 if (STRINGP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
709 val = load_charset_map (&charset, val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
710 CHECK_VECTOR (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
711 parse_charset_map (&charset, val, 0);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
712 charset.method = CHARSET_METHOD_MAP_DEFERRED;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
713 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
714 else if (! NILP (args[charset_arg_parents]))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
716 val = args[charset_arg_parents];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
717 CHECK_LIST (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
718 charset.method = CHARSET_METHOD_INHERIT;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
719 val = Fcopy_sequence (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
720 ASET (attrs, charset_parents, val);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
722 charset.min_char = MAX_CHAR;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
723 charset.max_char = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
724 for (; ! NILP (val); val = Fcdr (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
725 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
726 Lisp_Object elt, car_part, cdr_part;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
727 int this_id, offset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
728 struct charset *this_charset;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
729
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
730 elt = Fcar (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
731 if (CONSP (elt))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
732 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
733 car_part = XCAR (elt);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
734 cdr_part = XCDR (elt);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
735 CHECK_CHARSET_GET_ID (car_part, this_id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
736 CHECK_NUMBER (cdr_part);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
737 offset = XINT (cdr_part);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
738 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
739 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
740 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
741 CHECK_CHARSET_GET_ID (elt, this_id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
742 offset = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
743 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
744 XSETCAR (val, Fcons (make_number (this_id), make_number (offset)));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
746 this_charset = CHARSET_FROM_ID (this_id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
747 if (charset.min_char > this_charset->min_char)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
748 charset.min_char = this_charset->min_char;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
749 if (charset.max_char < this_charset->max_char)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
750 charset.max_char = this_charset->max_char;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
751 for (i = 0; i < 190; i++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
752 charset.fast_map[i] |= this_charset->fast_map[i];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
753 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
754 }
43144
69a3fef3cb46 (get_charset_id): Use if-else instead of ?:.
Eli Zaretskii <eliz@gnu.org>
parents: 42162
diff changeset
755 else
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
756 error ("None of :code-offset, :map, :parents are specified");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
757
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
758 val = args[charset_arg_unify_map];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
759 if (! NILP (val) && !STRINGP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
760 CHECK_VECTOR (val);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
761 ASET (attrs, charset_unify_map, val);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
763 CHECK_LIST (args[charset_arg_plist]);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
764 ASET (attrs, charset_plist, args[charset_arg_plist]);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
766 charset.hash_index = hash_lookup (hash_table, args[charset_arg_name],
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
767 &hash_code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
768 if (charset.hash_index >= 0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
769 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
770 new_definition_p = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
771 HASH_VALUE (hash_table, charset.hash_index) = attrs;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
773 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
775 charset.hash_index = hash_put (hash_table, args[charset_arg_name], attrs,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
776 hash_code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
777 if (charset_table_used == charset_table_size)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
778 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
779 charset_table_size += 256;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
780 charset_table
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
781 = ((struct charset *)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
782 xrealloc (charset_table,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
783 sizeof (struct charset) * charset_table_size));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
784 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
785 id = charset_table_used++;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
786 ASET (attrs, charset_id, make_number (id));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
787 new_definition_p = 1;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
790
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
791 charset.id = id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
792 charset_table[id] = charset;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
794 if (charset.iso_final >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
795 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
796 ISO_CHARSET_TABLE (charset.dimension, charset.iso_chars_96,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
797 charset.iso_final) = id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
798 if (new_definition_p)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
799 Viso_2022_charset_list = nconc2 (Viso_2022_charset_list,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
800 Fcons (make_number (id), Qnil));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
801 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
802
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
803 if (charset.emacs_mule_id >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
804 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
805 emacs_mule_charset[charset.emacs_mule_id] = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
806 if (new_definition_p)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
807 Vemacs_mule_charset_list = nconc2 (Vemacs_mule_charset_list,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
808 Fcons (make_number (id), Qnil));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
809 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
810
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
811 if (new_definition_p)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
812 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
813 Vcharset_list = Fcons (args[charset_arg_name], Vcharset_list);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
814 Vcharset_ordered_list = nconc2 (Vcharset_ordered_list,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
815 Fcons (make_number (id), Qnil));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
816 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
817
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
818 return Qnil;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
822 DEFUN ("define-charset-alias", Fdefine_charset_alias,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
823 Sdefine_charset_alias, 2, 2, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
824 doc: /* Define ALIAS as an alias for charset CHARSET. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
825 (alias, charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
826 Lisp_Object alias, charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
827 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
828 Lisp_Object attr;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
830 CHECK_CHARSET_GET_ATTR (charset, attr);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
831 Fputhash (alias, attr, Vcharset_hash_table);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
835
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
836 DEFUN ("primary-charset", Fprimary_charset, Sprimary_charset, 0, 0, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
837 doc: /* Return the primary charset. */)
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
838 ()
22703
15e0119749cf (Vgeneric_character_list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22524
diff changeset
839 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
840 return CHARSET_NAME (CHARSET_FROM_ID (charset_primary));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
841 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
842
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
843
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
844 DEFUN ("set-primary-charset", Fset_primary_charset, Sset_primary_charset,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
845 1, 1, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
846 doc: /* Set the primary charset to CHARSET. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
847 (charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
848 Lisp_Object charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
849 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
850 int id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
851
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
852 CHECK_CHARSET_GET_ID (charset, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
853 charset_primary = id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
854 return Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
855 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
856
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
857
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
858 DEFUN ("charset-plist", Fcharset_plist, Scharset_plist, 1, 1, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
859 doc: /* Return a property list of CHARSET. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
860 (charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
861 Lisp_Object charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
862 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
863 Lisp_Object attrs;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
864
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
865 CHECK_CHARSET_GET_ATTR (charset, attrs);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
866 return CHARSET_ATTR_PLIST (attrs);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
867 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
868
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
869
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
870 DEFUN ("set-charset-plist", Fset_charset_plist, Sset_charset_plist, 2, 2, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
871 doc: /* Set CHARSET's property list to PLIST. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
872 (charset, plist)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
873 Lisp_Object charset, plist;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
874 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
875 Lisp_Object attrs;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
876
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
877 CHECK_CHARSET_GET_ATTR (charset, attrs);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
878 CHARSET_ATTR_PLIST (attrs) = plist;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
879 return plist;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
880 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
881
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
882
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
883 DEFUN ("unify-charset", Funify_charset, Sunify_charset, 1, 2, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
884 doc: /* Unify characters of CHARSET with Unicode. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
885 (charset, unify_map)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
886 Lisp_Object charset, unify_map;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
887 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
888 int id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
889 struct charset *cs;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
890
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
891 CHECK_CHARSET_GET_ID (charset, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
892 cs = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
893 if (CHARSET_METHOD (cs) == CHARSET_METHOD_MAP_DEFERRED)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
894 load_charset (cs);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
895 if (CHARSET_UNIFIED_P (cs)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
896 && CHAR_TABLE_P (CHARSET_DEUNIFIER (cs)))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
897 return Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
898 CHARSET_UNIFIED_P (cs) = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
899 if (NILP (unify_map))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
900 unify_map = CHARSET_UNIFY_MAP (cs);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
901 if (STRINGP (unify_map))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
902 unify_map = load_charset_map (cs, unify_map);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
903 parse_charset_map (cs, unify_map, 2);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
904 CHARSET_UNIFIED_P (cs) = 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
905 return Qnil;
22703
15e0119749cf (Vgeneric_character_list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22524
diff changeset
906 }
15e0119749cf (Vgeneric_character_list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22524
diff changeset
907
20435
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
908 DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char,
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
909 Sget_unused_iso_final_char, 2, 2, 0,
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
910 doc: /*
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
911 Return an unsed ISO's final char for a charset of DIMENISION and CHARS.
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
912 DIMENSION is the number of bytes to represent a character: 1 or 2.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
913 CHARS is the number of characters in a dimension: 94 or 96.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
914
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
915 This final char is for private use, thus the range is `0' (48) .. `?' (63).
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
916 If there's no unused final char for the attrified kind of charset,
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
917 return nil. */)
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
918 (dimension, chars)
20435
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
919 Lisp_Object dimension, chars;
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
920 {
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
921 int final_char;
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
922
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40115
diff changeset
923 CHECK_NUMBER (dimension);
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40115
diff changeset
924 CHECK_NUMBER (chars);
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
925 if (XINT (dimension) != 1 && XINT (dimension) != 2 && XINT (dimension) != 3)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
926 args_out_of_range_3 (dimension, make_number (1), make_number (3));
20435
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
927 if (XINT (chars) != 94 && XINT (chars) != 96)
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
928 args_out_of_range_3 (chars, make_number (94), make_number (96));
20435
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
929 for (final_char = '0'; final_char <= '?'; final_char++)
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
930 if (ISO_CHARSET_TABLE (XINT (dimension), XINT (chars), final_char) < 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
931 break;
20435
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
932 return (final_char <= '?' ? make_number (final_char) : Qnil);
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
933 }
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
934
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
935 static void
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
936 check_iso_charset_parameter (dimension, chars, final_char)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
937 Lisp_Object dimension, chars, final_char;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
938 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
939 CHECK_NATNUM (dimension);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
940 CHECK_NATNUM (chars);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
941 CHECK_NATNUM (final_char);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
942
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
943 if (XINT (dimension) > 3)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
944 error ("Invalid DIMENSION %d, it should be 1, 2, or 3", XINT (dimension));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
945 if (XINT (chars) != 94 && XINT (chars) != 96)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
946 error ("Invalid CHARS %d, it should be 94 or 96", XINT (chars));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
947 if (XINT (final_char) < '0' || XINT (final_char) > '~')
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
948 error ("Invalid FINAL-CHAR %c, it should be `0'..`~'", XINT (chars));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
949 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
950
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
951
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952 DEFUN ("declare-equiv-charset", Fdeclare_equiv_charset, Sdeclare_equiv_charset,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
953 4, 4, 0,
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
954 doc: /*
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
955 Declare a charset of DIMENSION, CHARS, FINAL-CHAR is the same as CHARSET.
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
956 CHARSET should be defined by `defined-charset' in advance. */)
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
957 (dimension, chars, final_char, charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
958 Lisp_Object dimension, chars, final_char, charset;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
960 int id;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
962 CHECK_CHARSET_GET_ID (charset, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
963 check_iso_charset_parameter (dimension, chars, final_char);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
964
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
965 ISO_CHARSET_TABLE (dimension, chars, final_char) = id;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
968
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
969
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
970 /* Return information about charsets in the text at PTR of NBYTES
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
971 bytes, which are NCHARS characters. The value is:
29094
8b1a19b318e9 Fix comment for find_charset_in_text.
Kenichi Handa <handa@m17n.org>
parents: 29003
diff changeset
972
29095
39e94c12f469 Fix previous change (typo).
Kenichi Handa <handa@m17n.org>
parents: 29094
diff changeset
973 0: Each character is represented by one byte. This is always
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
974 true for a unibyte string. For a multibyte string, true if
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
975 it contains only ASCII characters.
22168
2156ac6d054f (find_charset_in_str): New arg CMPCHARP.
Kenichi Handa <handa@m17n.org>
parents: 22121
diff changeset
976
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
977 1: No charsets other than ascii, eight-bit-control, and
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
978 latin-1 are found.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
979
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
980 2: Otherwise.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
981 */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
982
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
983 int
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
984 string_xstring_p (string)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
985 Lisp_Object string;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
986 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
987 unsigned char *p = XSTRING (string)->data;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
988 unsigned char *endp = p + STRING_BYTES (XSTRING (string));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
989 struct charset *charset;
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
990
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
991 if (XSTRING (string)->size == STRING_BYTES (XSTRING (string)))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
992 return 0;
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
993
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
994 charset = CHARSET_FROM_ID (charset_iso_8859_1);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
995 while (p < endp)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
996 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
997 int c = STRING_CHAR_ADVANCE (p);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
998
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
999 if (ENCODE_CHAR (charset, c) < 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1000 return 2;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1001 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1002 return 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1003 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1004
20228
acb7aa0aa71f (find_charset_in_str): Handle the case that STR
Kenichi Handa <handa@m17n.org>
parents: 20188
diff changeset
1005
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1006 /* Find charsets in the string at PTR of NCHARS and NBYTES.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1007
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1008 CHARSETS is a vector. Each element is a cons of CHARSET and
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1009 FOUND-FLAG. CHARSET is a charset id, and FOUND-FLAG is nil or t.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1010 FOUND-FLAG t (or nil) means that the corresponding charset is
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1011 already found (or not yet found).
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1012
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1013 It may lookup a translation table TABLE if supplied. */
20228
acb7aa0aa71f (find_charset_in_str): Handle the case that STR
Kenichi Handa <handa@m17n.org>
parents: 20188
diff changeset
1014
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1015 static void
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1016 find_charsets_in_text (ptr, nchars, nbytes, charsets, table)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1017 unsigned char *ptr;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1018 int nchars, nbytes;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1019 Lisp_Object charsets, table;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1020 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1021 unsigned char *pend = ptr + nbytes;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1022 int ncharsets = ASIZE (charsets);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1023
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1024 if (nchars == nbytes)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1025 return;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1026
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1027 while (ptr < pend)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1028 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1029 int c = STRING_CHAR_ADVANCE (ptr);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1030 int i;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1031 int all_found = 1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1032 Lisp_Object elt;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1033
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1034 if (!NILP (table))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1035 c = translate_char (table, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1036 for (i = 0; i < ncharsets; i++)
17727
9d39361ce928 (unify_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 17366
diff changeset
1037 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1038 elt = AREF (charsets, i);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1039 if (NILP (XCDR (elt)))
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1040 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1041 struct charset *charset = CHARSET_FROM_ID (XINT (XCAR (elt)));
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1042
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1043 if (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1044 XCDR (elt) = Qt;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1045 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1046 all_found = 0;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1047 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048 }
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1049 if (all_found)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1050 break;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1051 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1052 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1053
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1054
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1055 DEFUN ("find-charset-region", Ffind_charset_region, Sfind_charset_region,
17727
9d39361ce928 (unify_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 17366
diff changeset
1056 2, 3, 0,
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1057 doc: /* Return a list of charsets in the region between BEG and END.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1058 BEG and END are buffer positions.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1059 Optional arg TABLE if non-nil is a translation table to look up.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1060
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1061 If the region contains invalid multibyte characters,
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1062 `unknown' is included in the returned list.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1063
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1064 If the current buffer is unibyte, the returned list may contain
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1065 only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1066 (beg, end, table)
17727
9d39361ce928 (unify_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 17366
diff changeset
1067 Lisp_Object beg, end, table;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1068 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1069 Lisp_Object charsets;
20534
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1070 int from, from_byte, to, stop, stop_byte, i;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 Lisp_Object val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1072
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073 validate_region (&beg, &end);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 from = XFASTINT (beg);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075 stop = to = XFASTINT (end);
20534
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1076
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 if (from < GPT && GPT < to)
20534
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1078 {
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1079 stop = GPT;
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1080 stop_byte = GPT_BYTE;
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1081 }
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1082 else
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1083 stop_byte = CHAR_TO_BYTE (stop);
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1084
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1085 from_byte = CHAR_TO_BYTE (from);
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1086
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1087 charsets = Fmake_vector (make_number (charset_table_used), Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1088 for (i = 0; i < charset_table_used; i++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1089 ASET (charsets, i, Fcons (make_number (i), Qnil));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1090
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1091 while (1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1092 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1093 find_charsets_in_text (BYTE_POS_ADDR (from_byte), stop - from,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1094 stop_byte - from_byte, charsets, table);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1095 if (stop < to)
20534
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1096 {
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1097 from = stop, from_byte = stop_byte;
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1098 stop = to, stop_byte = CHAR_TO_BYTE (stop);
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1099 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1100 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1101 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1102 }
20534
066251bcf9f7 (Fchars_in_string): Update call to CHAR_HEAD_P.
Richard M. Stallman <rms@gnu.org>
parents: 20435
diff changeset
1103
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1104 val = Qnil;
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1105 for (i = charset_table_used - 1; i >= 0; i--)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1106 if (!NILP (XCDR (AREF (charsets, i))))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1107 val = Fcons (CHARSET_NAME (charset_table + i), val);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1108 return val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1109 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1110
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1111 DEFUN ("find-charset-string", Ffind_charset_string, Sfind_charset_string,
17727
9d39361ce928 (unify_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 17366
diff changeset
1112 1, 2, 0,
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1113 doc: /* Return a list of charsets in STR.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1114 Optional arg TABLE if non-nil is a translation table to look up.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1115
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1116 If the string contains invalid multibyte characters,
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1117 `unknown' is included in the returned list.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1118
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1119 If STR is unibyte, the returned list may contain
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1120 only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1121 (str, table)
17727
9d39361ce928 (unify_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 17366
diff changeset
1122 Lisp_Object str, table;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1123 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1124 Lisp_Object charsets;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1125 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1126 Lisp_Object val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1127
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40115
diff changeset
1128 CHECK_STRING (str);
20614
a4800f9842e4 (multibyte_chars_in_text): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20575
diff changeset
1129
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1130 charsets = Fmake_vector (make_number (charset_table_used), Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1131 find_charsets_in_text (XSTRING (str)->data, XSTRING (str)->size,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1132 STRING_BYTES (XSTRING (str)), charsets, table);
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1133
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1134 val = Qnil;
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1135 for (i = charset_table_used - 1; i >= 0; i--)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1136 if (!NILP (XCDR (AREF (charsets, i))))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1137 val = Fcons (CHARSET_NAME (charset_table + i), val);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1138 return val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1139 }
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1140
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1141
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1142
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1143 /* Return a character correponding to the code-point CODE of
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1144 CHARSET. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1145
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1146 int
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1147 decode_char (charset, code)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1148 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1149 unsigned code;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1150 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1151 int c, char_index;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1152 enum charset_method method = CHARSET_METHOD (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1153
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1154 if (code < CHARSET_MIN_CODE (charset) || code > CHARSET_MAX_CODE (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1155 return -1;
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
1156
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1157 if (method == CHARSET_METHOD_MAP_DEFERRED)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1158 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1159 load_charset (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1160 method = CHARSET_METHOD (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1161 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1162
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1163 if (method == CHARSET_METHOD_INHERIT)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1164 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1165 Lisp_Object parents;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1166
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1167 parents = CHARSET_PARENTS (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1168 c = -1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1169 for (; CONSP (parents); parents = XCDR (parents))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1170 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1171 int id = XINT (XCAR (XCAR (parents)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1172 int code_offset = XINT (XCDR (XCAR (parents)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1173 unsigned this_code = code + code_offset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1174
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1175 charset = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1176 if ((c = DECODE_CHAR (charset, this_code)) >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1177 break;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1178 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1179 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1180 else
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
1181 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1182 char_index = CODE_POINT_TO_INDEX (charset, code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1183
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1184 if (method == CHARSET_METHOD_MAP)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1185 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1186 Lisp_Object decoder;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1187
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1188 decoder = CHARSET_DECODER (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1189 if (! VECTORP (decoder))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1190 return -1;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1191 c = XINT (AREF (decoder, char_index));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1192 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1193 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1194 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1195 c = char_index + CHARSET_CODE_OFFSET (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1196 }
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
1197 }
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1198
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1199 if (CHARSET_UNIFIED_P (charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1200 && c >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1201 MAYBE_UNIFY_CHAR (c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1202
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1203 return c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1204 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1205
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1206
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1207 /* Return a code-point of CHAR in CHARSET. If CHAR doesn't belong to
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1208 CHARSET, return CHARSET_INVALID_CODE (CHARSET). */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1209
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1210 unsigned
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1211 encode_char (charset, c)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1212 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1213 int c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1214 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1215 unsigned code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1216 enum charset_method method = CHARSET_METHOD (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1217
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1218 if (CHARSET_UNIFIED_P (charset))
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
1219 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1220 Lisp_Object deunifier;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1221 int deunified;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1222
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1223 deunifier = CHARSET_DEUNIFIER (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1224 if (! CHAR_TABLE_P (deunifier))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1225 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1226 Funify_charset (CHARSET_NAME (charset), Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1227 deunifier = CHARSET_DEUNIFIER (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1228 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1229 deunified = XINT (CHAR_TABLE_REF (deunifier, c));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1230 if (deunified > 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1231 c = deunified;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1232 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1233
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1234 if (! CHARSET_FAST_MAP_REF ((c), charset->fast_map)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1235 || c < CHARSET_MIN_CHAR (charset) || c > CHARSET_MAX_CHAR (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1236 return CHARSET_INVALID_CODE (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1237
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1238 if (method == CHARSET_METHOD_INHERIT)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1239 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1240 Lisp_Object parents;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1241
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1242 parents = CHARSET_PARENTS (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1243 for (; CONSP (parents); parents = XCDR (parents))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1244 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1245 int id = XINT (XCAR (XCAR (parents)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1246 int code_offset = XINT (XCDR (XCAR (parents)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1247 struct charset *this_charset = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1248
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1249 code = ENCODE_CHAR (this_charset, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1250 if (code != CHARSET_INVALID_CODE (this_charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1251 && (code_offset < 0 || code >= code_offset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1252 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1253 code -= code_offset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1254 if (CODE_POINT_TO_INDEX (charset, code) >= 0)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1255 return code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1256 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1257 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1258 return CHARSET_INVALID_CODE (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1259 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1260
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1261 if (method == CHARSET_METHOD_MAP_DEFERRED)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1262 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1263 load_charset (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1264 method = CHARSET_METHOD (charset);
25506
ba0ad349e792 (SPLIT_COMPOSITE_SEQ): New macro.
Kenichi Handa <handa@m17n.org>
parents: 25250
diff changeset
1265 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1266
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1267 if (method == CHARSET_METHOD_MAP)
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1268 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1269 Lisp_Object encoder;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1270 Lisp_Object val;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1271
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1272 encoder = CHARSET_ENCODER (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1273 if (! CHAR_TABLE_P (CHARSET_ENCODER (charset)))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1274 return CHARSET_INVALID_CODE (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1275 val = CHAR_TABLE_REF (encoder, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1276 if (CONSP (val))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1277 code = (XINT (XCAR (val)) << 16) | XINT (XCDR (val));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1278 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1279 code = XINT (val);
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1280 }
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1281 else
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1282 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1283 code = c - CHARSET_CODE_OFFSET (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1284 code = INDEX_TO_CODE_POINT (charset, code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1285 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1286
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1287 return code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1288 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1289
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1290
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1291 DEFUN ("decode-char", Fdecode_char, Sdecode_char, 2, 3, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1292 doc: /* Decode the pair of CHARSET and CODE-POINT into a character.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1293 Return nil if CODE-POINT is not valid in CHARSET.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1294
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1295 CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE).
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1296
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1297 Optional argument RESTRICTION specifies a way to map the pair of CCS
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1298 and CODE-POINT to a chracter. Currently not supported and just ignored. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1299 (charset, code_point, restriction)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1300 Lisp_Object charset, code_point, restriction;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1301 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1302 int c, id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1303 unsigned code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1304 struct charset *charsetp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1305
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1306 CHECK_CHARSET_GET_ID (charset, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1307 if (CONSP (code_point))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1308 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1309 CHECK_NATNUM (XCAR (code_point));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1310 CHECK_NATNUM (XCDR (code_point));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1311 code = (XINT (XCAR (code_point)) << 16) | (XINT (XCAR (code_point)));
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1312 }
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1313 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1314 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1315 CHECK_NATNUM (code_point);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1316 code = XINT (code_point);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1317 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1318 charsetp = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1319 c = DECODE_CHAR (charsetp, code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1320 return (c >= 0 ? make_number (c) : Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1321 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1322
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1323
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1324 DEFUN ("encode-char", Fencode_char, Sencode_char, 2, 3, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1325 doc: /* Encode the character CH into a code-point of CHARSET.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1326 Return nil if CHARSET doesn't include CH.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1327
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1328 Optional argument RESTRICTION specifies a way to map CHAR to a
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1329 code-point in CCS. Currently not supported and just ignored. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1330 (ch, charset, restriction)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1331 Lisp_Object ch, charset, restriction;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1332 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1333 int c, id;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1334 unsigned code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1335 struct charset *charsetp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1336
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1337 CHECK_CHARSET_GET_ID (charset, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1338 CHECK_NATNUM (ch);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1339 c = XINT (ch);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1340 charsetp = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1341 code = ENCODE_CHAR (charsetp, ch);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1342 if (code == CHARSET_INVALID_CODE (charsetp))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1343 return Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1344 if (code > 0x7FFFFFF)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1345 return Fcons (make_number (code >> 16), make_number (code & 0xFFFF));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1346 return make_number (code);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1347 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1348
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1349
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1350 DEFUN ("make-char", Fmake_char, Smake_char, 1, 4, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1351 doc: /* Return a character of CHARSET whose position code is CODE.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1352
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1353 If dimension of CHARSET is two, and the third optional arg CODE2 is
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1354 non-nil, CODE actually specifies the first byte of the position code,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1355 and CODE2 specifies the second byte.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1356
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1357 If dimension of CHARSET is three, and the third optional arg CODE2 and
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1358 the fourth optional arg CODE3 are both non-nil, CODE actually
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1359 specifies the first byte of the position code, CODE2 the second byte,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1360 and CODE3 the third byte. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1361 (charset, code, code2, code3)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1362 Lisp_Object charset, code, code2, code3;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1363 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1364 int id, dimension;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1365 struct charset *charsetp;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1366 unsigned c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1367
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1368 CHECK_CHARSET_GET_ID (charset, id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1369 charsetp = CHARSET_FROM_ID (id);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1370
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1371 if (NILP (code))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1372 code = make_number (CHARSET_MIN_CODE (charsetp));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1373 else
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1374 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1375 CHECK_NATNUM (code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1376 dimension = CHARSET_DIMENSION (charsetp);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1377
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1378 if (!NILP (code2))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1379 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1380 CHECK_NATNUM (code2);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1381 if (dimension == 3)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1382 CHECK_NATNUM (code3);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1383 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1384 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1385
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1386 if (dimension == 1 || NILP (code2))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1387 c = XFASTINT (code);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1388 else if (dimension == 2)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1389 c = (XFASTINT (code) << 8) | XFASTINT (code2);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1390 else if (dimension == 3)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1391 c = (XFASTINT (code) << 16) | (XFASTINT (code2) << 8) | XFASTINT (code3);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1392
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1393 c = DECODE_CHAR (charsetp, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1394 return make_number (c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1395 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1396
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1397
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1398 /* Return the first charset in CHARSET_LIST that contains C.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1399 CHARSET_LIST is a list of charset IDs. If it is nil, use
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1400 Vcharset_ordered_list. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1401
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1402 struct charset *
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1403 char_charset (c, charset_list, code_return)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1404 int c;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1405 Lisp_Object charset_list;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1406 unsigned *code_return;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1407 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1408 if (NILP (charset_list))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1409 charset_list = Vcharset_ordered_list;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1410
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1411 while (CONSP (charset_list))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1412 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1413 struct charset *charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1414 unsigned code = ENCODE_CHAR (charset, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1415
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1416 if (code != CHARSET_INVALID_CODE (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1417 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1418 if (code_return)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1419 *code_return = code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1420 return charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1421 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1422 charset_list = XCDR (charset_list);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1423 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1424 return NULL;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1425 }
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1426
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1427
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1428 DEFUN ("split-char", Fsplit_char, Ssplit_char, 1, 1, 0,
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1429 doc: /*Return list of charset and one or two position-codes of CHAR.
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1430 If CHAR is invalid as a character code,
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1431 return a list of symbol `unknown' and CHAR. */)
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1432 (ch)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1433 Lisp_Object ch;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1434 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1435 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1436 int c, dimension;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1437 unsigned code;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1438 Lisp_Object val;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1439
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1440 CHECK_CHARACTER (ch);
23883
0ca2fa58ca7b (Qunknown): New variable.
Kenichi Handa <handa@m17n.org>
parents: 23767
diff changeset
1441 c = XFASTINT (ch);
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1442 charset = CHAR_CHARSET (c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1443 if (! charset)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1444 return Fcons (intern ("unknown"), Fcons (ch, Qnil));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1445
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1446 code = ENCODE_CHAR (charset, c);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1447 if (code == CHARSET_INVALID_CODE (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1448 abort ();
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1449 dimension = CHARSET_DIMENSION (charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1450 val = (dimension == 1 ? Fcons (make_number (code), Qnil)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1451 : dimension == 2 ? Fcons (make_number (code >> 8),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1452 Fcons (make_number (code & 0xFF), Qnil))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1453 : Fcons (make_number (code >> 16),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1454 Fcons (make_number ((code >> 8) & 0xFF),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1455 Fcons (make_number (code & 0xFF), Qnil))));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1456 return Fcons (CHARSET_NAME (charset), val);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1457 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1458
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1459
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1460 DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 1, 0,
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1461 doc: /* Return the charset of highest priority that contains CHAR. */)
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1462 (ch)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1463 Lisp_Object ch;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1464 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1465 struct charset *charset;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1466
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1467 CHECK_CHARACTER (ch);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1468 charset = CHAR_CHARSET (XINT (ch));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1469 return (CHARSET_NAME (charset));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1470 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1471
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1472
21445
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1473 DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0,
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1474 doc: /*
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1475 Return charset of a character in the current buffer at position POS.
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1476 If POS is nil, it defauls to the current point.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1477 If POS is out of range, the value is nil. */)
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1478 (pos)
21445
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1479 Lisp_Object pos;
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1480 {
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1481 Lisp_Object ch;
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1482 struct charset *charset;
21445
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1483
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1484 ch = Fchar_after (pos);
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1485 if (! INTEGERP (ch))
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1486 return ch;
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1487 charset = CHAR_CHARSET (XINT (ch));
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1488 return (CHARSET_NAME (charset));
21445
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1489 }
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1490
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1491
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1492 DEFUN ("iso-charset", Fiso_charset, Siso_charset, 3, 3, 0,
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1493 doc: /*
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1494 Return charset of ISO's specification DIMENSION, CHARS, and FINAL-CHAR.
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1495
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1496 ISO 2022's designation sequence (escape sequence) distinguishes charsets
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1497 by their DIMENSION, CHARS, and FINAL-CHAR,
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1498 where as Emacs distinguishes them by charset symbol.
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1499 See the documentation of the function `charset-info' for the meanings of
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1500 DIMENSION, CHARS, and FINAL-CHAR. */)
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1501 (dimension, chars, final_char)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1502 Lisp_Object dimension, chars, final_char;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1503 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1504 int id;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1505
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1506 check_iso_charset_parameter (dimension, chars, final_char);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1507 id = ISO_CHARSET_TABLE (XFASTINT (dimension), XFASTINT (chars),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1508 XFASTINT (final_char));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1509 return (id >= 0 ? CHARSET_NAME (CHARSET_FROM_ID (id)) : Qnil);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1510 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1511
35407
916718dc2950 (strwidth): Use c_string_width.
Kenichi Handa <handa@m17n.org>
parents: 34985
diff changeset
1512
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1513 DEFUN ("clear-charset-maps", Fclear_charset_maps, Sclear_charset_maps,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1514 0, 0, 0,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1515 doc: /*
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1516 Clear encoder and decoder of charsets that are loaded from mapfiles. */)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1517 ()
31420
126c87fe1aad Include composite.h
Kenichi Handa <handa@m17n.org>
parents: 31176
diff changeset
1518 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1519 int i;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1520 struct charset *charset;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1521 Lisp_Object attrs;
31420
126c87fe1aad Include composite.h
Kenichi Handa <handa@m17n.org>
parents: 31176
diff changeset
1522
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1523 for (i = 0; i < charset_table_used; i++)
31420
126c87fe1aad Include composite.h
Kenichi Handa <handa@m17n.org>
parents: 31176
diff changeset
1524 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1525 charset = CHARSET_FROM_ID (i);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1526 attrs = CHARSET_ATTRIBUTES (charset);
35407
916718dc2950 (strwidth): Use c_string_width.
Kenichi Handa <handa@m17n.org>
parents: 34985
diff changeset
1527
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1528 if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP)
35407
916718dc2950 (strwidth): Use c_string_width.
Kenichi Handa <handa@m17n.org>
parents: 34985
diff changeset
1529 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1530 CHARSET_ATTR_DECODER (attrs) = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1531 CHARSET_ATTR_ENCODER (attrs) = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1532 CHARSET_METHOD (charset) = CHARSET_METHOD_MAP_DEFERRED;
35407
916718dc2950 (strwidth): Use c_string_width.
Kenichi Handa <handa@m17n.org>
parents: 34985
diff changeset
1533 }
916718dc2950 (strwidth): Use c_string_width.
Kenichi Handa <handa@m17n.org>
parents: 34985
diff changeset
1534
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1535 if (CHARSET_UNIFIED_P (charset))
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1536 CHARSET_ATTR_DEUNIFIER (attrs) = Qnil;
31420
126c87fe1aad Include composite.h
Kenichi Handa <handa@m17n.org>
parents: 31176
diff changeset
1537 }
35407
916718dc2950 (strwidth): Use c_string_width.
Kenichi Handa <handa@m17n.org>
parents: 34985
diff changeset
1538
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1539 if (CHAR_TABLE_P (Vchar_unified_charset_table))
20614
a4800f9842e4 (multibyte_chars_in_text): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20575
diff changeset
1540 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1541 Foptimize_char_table (Vchar_unified_charset_table);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1542 Vchar_unify_table = Vchar_unified_charset_table;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1543 Vchar_unified_charset_table = Qnil;
20614
a4800f9842e4 (multibyte_chars_in_text): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20575
diff changeset
1544 }
a4800f9842e4 (multibyte_chars_in_text): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20575
diff changeset
1545
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1546 return Qnil;
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1547 }
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1548
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1549
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1550 void
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1551 init_charset ()
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1554 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1555
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1556
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21445
diff changeset
1557 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1558 init_charset_once ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1559 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1560 int i, j, k;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1561
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1562 for (i = 0; i < ISO_MAX_DIMENSION; i++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1563 for (j = 0; j < ISO_MAX_CHARS; j++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1564 for (k = 0; k < ISO_MAX_FINAL; k++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1565 iso_charset_table[i][j][k] = -1;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1566
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1567 for (i = 0; i < 255; i++)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1568 emacs_mule_charset[i] = NULL;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1569
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1570 #if 0
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1571 Vchar_charset_set = Fmake_char_table (Qnil, Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1572 CHAR_TABLE_SET (Vchar_charset_set, make_number (97), Qnil);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1573
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1574 DEFSYM (Qcharset_encode_table, "charset-encode-table");
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1575
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1576 /* Intern this now in case it isn't already done.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1577 Setting this variable twice is harmless.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1578 But don't staticpro it here--that is done in alloc.c. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1579 Qchar_table_extra_slots = intern ("char-table-extra-slots");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1580
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1581 /* Now we are ready to set up this property, so we can create syntax
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1582 tables. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1583 Fput (Qcharset_encode_table, Qchar_table_extra_slots, make_number (0));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1584 #endif
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1585 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1586
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1587 #ifdef emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1588
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21445
diff changeset
1589 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1590 syms_of_charset ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1591 {
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1592 char *p;
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1593
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1594 DEFSYM (Qcharsetp, "charsetp");
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1595
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1596 DEFSYM (Qascii, "ascii");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1597 DEFSYM (Qunicode, "unicode");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1598 DEFSYM (Qeight_bit_control, "eight-bit-control");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1599 DEFSYM (Qeight_bit_graphic, "eight-bit-graphic");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1600 DEFSYM (Qiso_8859_1, "iso-8859-1");
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1601
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1602 DEFSYM (Qgl, "gl");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1603 DEFSYM (Qgr, "gr");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1604
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1605 p = (char *) xmalloc (30000);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1606
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1607 staticpro (&Vcharset_ordered_list);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1608 Vcharset_ordered_list = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1609
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1610 staticpro (&Viso_2022_charset_list);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1611 Viso_2022_charset_list = Qnil;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1613 staticpro (&Vemacs_mule_charset_list);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1614 Vemacs_mule_charset_list = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1615
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1616 staticpro (&Vcharset_hash_table);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1617 Vcharset_hash_table = Fmakehash (Qeq);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1618
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1619 charset_table_size = 128;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1620 charset_table = ((struct charset *)
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1621 xmalloc (sizeof (struct charset) * charset_table_size));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1622 charset_table_used = 0;
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1623
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1624 staticpro (&Vchar_unified_charset_table);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1625 Vchar_unified_charset_table = Fmake_char_table (Qnil, make_number (-1));
29003
72eafb39ec65 (Qeight_bit_control, Qeight_bit_graphic): New
Kenichi Handa <handa@m17n.org>
parents: 28818
diff changeset
1626
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1627 defsubr (&Scharsetp);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1628 defsubr (&Smap_charset_chars);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1629 defsubr (&Sdefine_charset_internal);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1630 defsubr (&Sdefine_charset_alias);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1631 defsubr (&Sprimary_charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1632 defsubr (&Sset_primary_charset);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1633 defsubr (&Scharset_plist);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1634 defsubr (&Sset_charset_plist);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1635 defsubr (&Sunify_charset);
20435
099812ea310f (Fget_unused_iso_final_char): New function.
Kenichi Handa <handa@m17n.org>
parents: 20362
diff changeset
1636 defsubr (&Sget_unused_iso_final_char);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1637 defsubr (&Sdeclare_equiv_charset);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1638 defsubr (&Sfind_charset_region);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1639 defsubr (&Sfind_charset_string);
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1640 defsubr (&Sdecode_char);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1641 defsubr (&Sencode_char);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1642 defsubr (&Ssplit_char);
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1643 defsubr (&Smake_char);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644 defsubr (&Schar_charset);
21445
4c0b4a1025cd (string_to_non_ascii_char): Include garbage bytes (if
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
1645 defsubr (&Scharset_after);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1646 defsubr (&Siso_charset);
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1647 defsubr (&Sclear_charset_maps);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1648
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1649 DEFVAR_LISP ("charset-map-directory", &Vcharset_map_directory,
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1650 doc: /* Directory of charset map files that come with GNU Emacs.
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1651 The default value is \"\\[data-directory]/charsets\". */);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1652 Vcharset_map_directory = Fexpand_file_name (build_string ("charsets"),
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1653 Vdata_directory);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1654
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1655 DEFVAR_LISP ("charset-list", &Vcharset_list,
40103
6b389fb978bc Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 39682
diff changeset
1656 doc: /* List of charsets ever defined. */);
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1657 Vcharset_list = Qnil;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1658
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1659 /* Make the prerequisite charset `ascii' and `unicode'. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1660 {
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1661 Lisp_Object args[charset_arg_max];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1662 Lisp_Object plist[14];
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1663 Lisp_Object val;
20705
a949dc65fbea (nonascii_insert_offset): Variable moved from cmds.c.
Richard M. Stallman <rms@gnu.org>
parents: 20636
diff changeset
1664
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1665 plist[0] = intern (":name");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1666 plist[1] = args[charset_arg_name] = Qascii;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1667 plist[2] = intern (":dimension");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1668 plist[3] = args[charset_arg_dimension] = make_number (1);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1669 val = Fmake_vector (make_number (8), make_number (0));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1670 ASET (val, 1, make_number (127));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1671 plist[4] = intern (":code-space");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1672 plist[5] = args[charset_arg_code_space] = val;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1673 plist[6] = intern (":iso-final-char");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1674 plist[7] = args[charset_arg_iso_final] = make_number ('B');
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1675 args[charset_arg_iso_revision] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1676 plist[8] = intern (":emacs-mule-id");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1677 plist[9] = args[charset_arg_emacs_mule_id] = make_number (0);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1678 plist[10] = intern (":ascii-compatible-p");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1679 plist[11] = args[charset_arg_ascii_compatible_p] = Qt;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1680 args[charset_arg_supplementary_p] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1681 args[charset_arg_invalid_code] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1682 plist[12] = intern (":code-offset");
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1683 plist[13] = args[charset_arg_code_offset] = make_number (0);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1684 args[charset_arg_map] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1685 args[charset_arg_parents] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1686 args[charset_arg_unify_map] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1687 /* The actual plist is set by mule-conf.el. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1688 args[charset_arg_plist] = Flist (14, plist);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1689 Fdefine_charset_internal (charset_arg_max, args);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1690 charset_ascii = CHARSET_SYMBOL_ID (Qascii);
20720
f084bb8d535f (min_composite_char): New variable.
Kenichi Handa <handa@m17n.org>
parents: 20705
diff changeset
1691
88364
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1692 plist[1] = args[charset_arg_name] = Qunicode;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1693 plist[3] = args[charset_arg_dimension] = make_number (3);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1694 val = Fmake_vector (make_number (8), make_number (0));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1695 ASET (val, 1, make_number (255));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1696 ASET (val, 3, make_number (255));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1697 ASET (val, 5, make_number (16));
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1698 plist[5] = args[charset_arg_code_space] = val;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1699 plist[7] = args[charset_arg_iso_final] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1700 args[charset_arg_iso_revision] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1701 plist[9] = args[charset_arg_emacs_mule_id] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1702 plist[11] = args[charset_arg_ascii_compatible_p] = Qt;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1703 args[charset_arg_supplementary_p] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1704 args[charset_arg_invalid_code] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1705 plist[13] = args[charset_arg_code_offset] = make_number (0);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1706 args[charset_arg_map] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1707 args[charset_arg_parents] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1708 args[charset_arg_unify_map] = Qnil;
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1709 /* The actual plist is set by mule-conf.el. */
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1710 args[charset_arg_plist] = Flist (14, plist);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1711 Fdefine_charset_internal (charset_arg_max, args);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1712 charset_unicode = CHARSET_SYMBOL_ID (Qunicode);
f6557aebe110 Completely re-written. Character and multibyte
Kenichi Handa <handa@m17n.org>
parents: 43144
diff changeset
1713 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1714 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1715
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1716 #endif /* emacs */