aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorGlenn Morris2017-04-23 16:31:02 -0700
committerGlenn Morris2017-04-24 23:06:27 -0700
commitd22ddf5944b97ca7f853d034f9e2e812d9bf5552 (patch)
tree83c2efb7c0e79a9d379f8928f99e3243d2f4d385 /admin
parent46dafe4103d1d24a9ec9b3a7a561829bcd5807aa (diff)
downloademacs-d22ddf5944b97ca7f853d034f9e2e812d9bf5552.tar.gz
emacs-d22ddf5944b97ca7f853d034f9e2e812d9bf5552.zip
Write each generated character property lisp file only once
* admin/unidata/unidata-gen.el (unidata-file-alist): Rename from unidata-prop-alist. All users changed. Use file name rather than property name as the key. (unidata-prop-prop): New function. (unidata-prop-index, unidata-prop-generator, unidata-prop-docstring) (unidata-prop-describer, unidata-prop-default, unidata-prop-val-list): Change to parse the argument rather than unidata-prop-alist. (unidata-gen-table-character, unidata-gen-table) (unidata-gen-table-symbol, unidata-gen-table-integer) (unidata-gen-table-numeric, unidata-gen-table-word-list) (unidata-gen-table-name, unidata-gen-table-decomposition) (unidata-gen-table-special-casing): Pass index as an argument. (unidata-check): Adapt to unidata-file-alist. Pass index to generator functions. (unidata-gen-files): Adapt to unidata-file-alist. Write each output file once only. Overwrite rather than delete.
Diffstat (limited to 'admin')
-rw-r--r--admin/unidata/unidata-gen.el466
1 files changed, 235 insertions, 231 deletions
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el
index 9ebcbe0705a..42489b13b61 100644
--- a/admin/unidata/unidata-gen.el
+++ b/admin/unidata/unidata-gen.el
@@ -149,14 +149,14 @@
149 (setq unidata-list (cdr table)))) 149 (setq unidata-list (cdr table))))
150 150
151;; Alist of this form: 151;; Alist of this form:
152;; (PROP INDEX GENERATOR FILENAME DOCSTRING DESCRIBER DEFAULT VAL-LIST) 152;; (FILENAME (PROP INDEX GENERATOR DOCSTRING DESCRIBER DEFAULT VAL-LIST) ...)
153;; FILENAME: filename to store the char-table(s)
153;; PROP: character property 154;; PROP: character property
154;; INDEX: index to each element of unidata-list for PROP. 155;; INDEX: index to each element of unidata-list for PROP.
155;; It may be a function that generates an alist of character codes 156;; It may be a function that generates an alist of character codes
156;; vs. the corresponding property values. Currently, only character 157;; vs. the corresponding property values. Currently, only character
157;; codepoints or symbol values are supported in this case. 158;; codepoints or symbol values are supported in this case.
158;; GENERATOR: function to generate a char-table 159;; GENERATOR: function to generate a char-table
159;; FILENAME: filename to store the char-table
160;; DOCSTRING: docstring for the property 160;; DOCSTRING: docstring for the property
161;; DESCRIBER: function to call to get a description string of property value 161;; DESCRIBER: function to call to get a description string of property value
162;; DEFAULT: the default value of the property. It may have the form 162;; DEFAULT: the default value of the property. It may have the form
@@ -166,111 +166,132 @@
166;; between FROMn and TOn is VALn. 166;; between FROMn and TOn is VALn.
167;; VAL-LIST: list of specially ordered property values 167;; VAL-LIST: list of specially ordered property values
168 168
169(defconst unidata-prop-alist 169(defconst unidata-file-alist
170 '((name 170 '(("uni-name.el"
171 1 unidata-gen-table-name "uni-name.el" 171 (name
172 "Unicode character name. 172 1 unidata-gen-table-name
173 "Unicode character name.
173Property value is a string or nil. 174Property value is a string or nil.
174The value nil stands for the default value \"null string\")." 175The value nil stands for the default value \"null string\")."
175 nil 176 nil
176 nil) 177 nil))
177 (general-category 178 ("uni-category.el"
178 2 unidata-gen-table-symbol "uni-category.el" 179 (general-category
179 "Unicode general category. 180 2 unidata-gen-table-symbol
181 "Unicode general category.
180Property value is one of the following symbols: 182Property value is one of the following symbols:
181 Lu, Ll, Lt, Lm, Lo, Mn, Mc, Me, Nd, Nl, No, Pc, Pd, Ps, Pe, Pi, Pf, Po, 183 Lu, Ll, Lt, Lm, Lo, Mn, Mc, Me, Nd, Nl, No, Pc, Pd, Ps, Pe, Pi, Pf, Po,
182 Sm, Sc, Sk, So, Zs, Zl, Zp, Cc, Cf, Cs, Co, Cn" 184 Sm, Sc, Sk, So, Zs, Zl, Zp, Cc, Cf, Cs, Co, Cn"
183 unidata-describe-general-category 185 unidata-describe-general-category
184 Cn 186 Cn
185 ;; The order of elements must be in sync with unicode_category_t 187 ;; The order of elements must be in sync with
186 ;; in src/character.h. 188 ;; unicode_category_t in src/character.h.
187 (Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po 189 (Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po
188 Sm Sc Sk So Zs Zl Zp Cc Cf Cs Co Cn)) 190 Sm Sc Sk So Zs Zl Zp Cc Cf Cs Co Cn)))
189 (canonical-combining-class 191 ("uni-combining.el"
190 3 unidata-gen-table-integer "uni-combining.el" 192 (canonical-combining-class
191 "Unicode canonical combining class. 193 3 unidata-gen-table-integer
194 "Unicode canonical combining class.
192Property value is an integer." 195Property value is an integer."
193 unidata-describe-canonical-combining-class 196 unidata-describe-canonical-combining-class
194 0) 197 0))
195 (bidi-class 198 ("uni-bidi.el"
196 4 unidata-gen-table-symbol "uni-bidi.el" 199 (bidi-class
197 "Unicode bidi class. 200 4 unidata-gen-table-symbol
201 "Unicode bidi class.
198Property value is one of the following symbols: 202Property value is one of the following symbols:
199 L, LRE, LRO, LRI, R, AL, RLE, RLO, RLI, FSI, PDF, PDI, 203 L, LRE, LRO, LRI, R, AL, RLE, RLO, RLI, FSI, PDF, PDI,
200 EN, ES, ET, AN, CS, NSM, BN, B, S, WS, ON" 204 EN, ES, ET, AN, CS, NSM, BN, B, S, WS, ON"
201 unidata-describe-bidi-class 205 unidata-describe-bidi-class
202 ;; The assignment of default values to blocks of code points 206 ;; The assignment of default values to blocks of code points
203 ;; follows the file DerivedBidiClass.txt from the Unicode 207 ;; follows the file DerivedBidiClass.txt from the Unicode
204 ;; Character Database (UCD). 208 ;; Character Database (UCD).
205 (L (#x0600 #x06FF AL) (#xFB50 #xFDFF AL) (#xFE70 #xFEFF AL) 209 (L (#x0600 #x06FF AL) (#xFB50 #xFDFF AL) (#xFE70 #xFEFF AL)
206 (#x0590 #x05FF R) (#x07C0 #x08FF R) 210 (#x0590 #x05FF R) (#x07C0 #x08FF R)
207 (#xFB1D #xFB4F R) (#x10800 #x10FFF R) (#x1E800 #x1EFFF R)) 211 (#xFB1D #xFB4F R) (#x10800 #x10FFF R) (#x1E800 #x1EFFF R))
208 ;; The order of elements must be in sync with bidi_type_t in 212 ;; The order of elements must be in sync with bidi_type_t in
209 ;; src/dispextern.h. 213 ;; src/dispextern.h.
210 (L R EN AN BN B AL LRE LRO RLE RLO PDF LRI RLI FSI PDI 214 (L R EN AN BN B AL LRE LRO RLE RLO PDF LRI RLI FSI PDI
211 ES ET CS NSM S WS ON)) 215 ES ET CS NSM S WS ON)))
212 (decomposition 216 ("uni-decomposition.el"
213 5 unidata-gen-table-decomposition "uni-decomposition.el" 217 (decomposition
214 "Unicode decomposition mapping. 218 5 unidata-gen-table-decomposition
219 "Unicode decomposition mapping.
215Property value is a list of characters. The first element may be 220Property value is a list of characters. The first element may be
216one of these symbols representing compatibility formatting tag: 221one of these symbols representing compatibility formatting tag:
217 font, noBreak, initial, medial, final, isolated, circle, super, 222 font, noBreak, initial, medial, final, isolated, circle, super,
218 sub, vertical, wide, narrow, small, square, fraction, compat" 223 sub, vertical, wide, narrow, small, square, fraction, compat"
219 unidata-describe-decomposition) 224 unidata-describe-decomposition))
220 (decimal-digit-value 225 ("uni-decimal.el"
221 6 unidata-gen-table-integer "uni-decimal.el" 226 (decimal-digit-value
222 "Unicode numeric value (decimal digit). 227 6 unidata-gen-table-integer
228 "Unicode numeric value (decimal digit).
223Property value is an integer 0..9, or nil. 229Property value is an integer 0..9, or nil.
224The value nil stands for NaN \"Numeric_Value\".") 230The value nil stands for NaN \"Numeric_Value\"."))
225 (digit-value 231 ("uni-digit.el"
226 7 unidata-gen-table-integer "uni-digit.el" 232 (digit-value
227 "Unicode numeric value (digit). 233 7 unidata-gen-table-integer
234 "Unicode numeric value (digit).
228Property value is an integer 0..9, or nil. 235Property value is an integer 0..9, or nil.
229The value nil stands for NaN \"Numeric_Value\".") 236The value nil stands for NaN \"Numeric_Value\"."))
230 (numeric-value 237 ("uni-numeric.el"
231 8 unidata-gen-table-numeric "uni-numeric.el" 238 (numeric-value
232 "Unicode numeric value (numeric). 239 8 unidata-gen-table-numeric
240 "Unicode numeric value (numeric).
233Property value is an integer, a floating point, or nil. 241Property value is an integer, a floating point, or nil.
234The value nil stands for NaN \"Numeric_Value\".") 242The value nil stands for NaN \"Numeric_Value\"."))
235 (mirrored 243 ("uni-mirrored.el"
236 9 unidata-gen-table-symbol "uni-mirrored.el" 244 (mirrored
237 "Unicode bidi mirrored flag. 245 9 unidata-gen-table-symbol
246 "Unicode bidi mirrored flag.
238Property value is a symbol `Y' or `N'. See also the property `mirroring'." 247Property value is a symbol `Y' or `N'. See also the property `mirroring'."
239 nil 248 nil
240 N) 249 N)
241 (old-name 250 (mirroring
242 10 unidata-gen-table-name "uni-old-name.el" 251 unidata-gen-mirroring-list unidata-gen-table-character
243 "Unicode old names as published in Unicode 1.0. 252 "Unicode bidi-mirroring characters.
253Property value is a character that has the corresponding mirroring image or nil.
254The value nil means that the actual property value of a character
255is the character itself."))
256 ("uni-old-name.el"
257 (old-name
258 10 unidata-gen-table-name
259 "Unicode old names as published in Unicode 1.0.
244Property value is a string or nil. 260Property value is a string or nil.
245The value nil stands for the default value \"null string\").") 261The value nil stands for the default value \"null string\")."))
246 (iso-10646-comment 262 ("uni-comment.el"
247 11 unidata-gen-table-name "uni-comment.el" 263 (iso-10646-comment
248 "Unicode ISO 10646 comment. 264 11 unidata-gen-table-name
249Property value is a string.") 265 "Unicode ISO 10646 comment.
250 (uppercase 266Property value is a string."))
251 12 unidata-gen-table-character "uni-uppercase.el" 267 ("uni-uppercase.el"
252 "Unicode simple uppercase mapping. 268 (uppercase
269 12 unidata-gen-table-character
270 "Unicode simple uppercase mapping.
253Property value is a character or nil. 271Property value is a character or nil.
254The value nil means that the actual property value of a character 272The value nil means that the actual property value of a character
255is the character itself." 273is the character itself."
256 string) 274 string))
257 (lowercase 275 ("uni-lowercase.el"
258 13 unidata-gen-table-character "uni-lowercase.el" 276 (lowercase
259 "Unicode simple lowercase mapping. 277 13 unidata-gen-table-character
278 "Unicode simple lowercase mapping.
260Property value is a character or nil. 279Property value is a character or nil.
261The value nil means that the actual property value of a character 280The value nil means that the actual property value of a character
262is the character itself." 281is the character itself."
263 string) 282 string))
264 (titlecase 283 ("uni-titlecase.el"
265 14 unidata-gen-table-character "uni-titlecase.el" 284 (titlecase
266 "Unicode simple titlecase mapping. 285 14 unidata-gen-table-character
286 "Unicode simple titlecase mapping.
267Property value is a character or nil. 287Property value is a character or nil.
268The value nil means that the actual property value of a character 288The value nil means that the actual property value of a character
269is the character itself." 289is the character itself."
270 string) 290 string))
271 (special-uppercase 291 ("uni-special-uppercase.el"
272 2 unidata-gen-table-special-casing "uni-special-uppercase.el" 292 (special-uppercase
273 "Unicode unconditional special casing mapping. 293 2 unidata-gen-table-special-casing
294 "Unicode unconditional special casing mapping.
274 295
275Property value is (possibly empty) string or nil. The value nil denotes that 296Property value is (possibly empty) string or nil. The value nil denotes that
276`uppercase' property should be consulted instead. A string denotes what 297`uppercase' property should be consulted instead. A string denotes what
@@ -279,10 +300,11 @@ sequence of characters given character maps into.
279This mapping includes language- and context-independent special casing rules 300This mapping includes language- and context-independent special casing rules
280defined by Unicode only. It also does not include association which would 301defined by Unicode only. It also does not include association which would
281duplicate information from `uppercase' property." 302duplicate information from `uppercase' property."
282 nil) 303 nil))
283 (special-lowercase 304 ("uni-special-lowercase.el"
284 0 unidata-gen-table-special-casing "uni-special-lowercase.el" 305 (special-lowercase
285 "Unicode unconditional special casing mapping. 306 0 unidata-gen-table-special-casing
307 "Unicode unconditional special casing mapping.
286 308
287Property value is (possibly empty) string or nil. The value nil denotes that 309Property value is (possibly empty) string or nil. The value nil denotes that
288`lowercase' property should be consulted instead. A string denotes what 310`lowercase' property should be consulted instead. A string denotes what
@@ -291,10 +313,11 @@ sequence of characters given character maps into.
291This mapping includes language- and context-independent special casing rules 313This mapping includes language- and context-independent special casing rules
292defined by Unicode only. It also does not include association which would 314defined by Unicode only. It also does not include association which would
293duplicate information from `lowercase' property." 315duplicate information from `lowercase' property."
294 nil) 316 nil))
295 (special-titlecase 317 ("uni-special-titlecase.el"
296 1 unidata-gen-table-special-casing "uni-special-titlecase.el" 318 (special-titlecase
297 "Unicode unconditional special casing mapping. 319 1 unidata-gen-table-special-casing
320 "Unicode unconditional special casing mapping.
298 321
299Property value is (possibly empty) string or nil. The value nil denotes that 322Property value is (possibly empty) string or nil. The value nil denotes that
300`titlecase' property should be consulted instead. A string denotes what 323`titlecase' property should be consulted instead. A string denotes what
@@ -303,38 +326,33 @@ sequence of characters given character maps into.
303This mapping includes language- and context-independent special casing rules 326This mapping includes language- and context-independent special casing rules
304defined by Unicode only. It also does not include association which would 327defined by Unicode only. It also does not include association which would
305duplicate information from `titlecase' property." 328duplicate information from `titlecase' property."
306 nil) 329 nil))
307 (mirroring 330 ("uni-brackets.el"
308 unidata-gen-mirroring-list unidata-gen-table-character "uni-mirrored.el" 331 (paired-bracket
309 "Unicode bidi-mirroring characters. 332 unidata-gen-brackets-list unidata-gen-table-character
310Property value is a character that has the corresponding mirroring image or nil. 333 "Unicode bidi paired-bracket characters.
311The value nil means that the actual property value of a character
312is the character itself.")
313 (paired-bracket
314 unidata-gen-brackets-list unidata-gen-table-character "uni-brackets.el"
315 "Unicode bidi paired-bracket characters.
316Property value is the paired bracket character, or nil. 334Property value is the paired bracket character, or nil.
317The value nil means that the character is neither an opening nor 335The value nil means that the character is neither an opening nor
318a closing paired bracket." 336a closing paired bracket."
319 string) 337 string)
320 (bracket-type 338 (bracket-type
321 unidata-gen-bracket-type-list unidata-gen-table-symbol "uni-brackets.el" 339 unidata-gen-bracket-type-list unidata-gen-table-symbol
322 "Unicode bidi paired-bracket type. 340 "Unicode bidi paired-bracket type.
323Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." 341Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
324 unidata-describe-bidi-bracket-type 342 unidata-describe-bidi-bracket-type
325 n 343 n
326 ;; The order of elements must be in sync with bidi_bracket_type_t 344 ;; The order of elements must be in sync with bidi_bracket_type_t
327 ;; in src/dispextern.h. 345 ;; in src/dispextern.h.
328 (n o c)))) 346 (n o c)))))
329 347
330;; Functions to access the above data. 348;; Functions to access the above data.
331(defsubst unidata-prop-index (prop) (nth 1 (assq prop unidata-prop-alist))) 349(defsubst unidata-prop-prop (proplist) (nth 0 proplist))
332(defsubst unidata-prop-generator (prop) (nth 2 (assq prop unidata-prop-alist))) 350(defsubst unidata-prop-index (proplist) (nth 1 proplist))
333(defsubst unidata-prop-file (prop) (nth 3 (assq prop unidata-prop-alist))) 351(defsubst unidata-prop-generator (proplist) (nth 2 proplist))
334(defsubst unidata-prop-docstring (prop) (nth 4 (assq prop unidata-prop-alist))) 352(defsubst unidata-prop-docstring (proplist) (nth 3 proplist))
335(defsubst unidata-prop-describer (prop) (nth 5 (assq prop unidata-prop-alist))) 353(defsubst unidata-prop-describer (proplist) (nth 4 proplist))
336(defsubst unidata-prop-default (prop) (nth 6 (assq prop unidata-prop-alist))) 354(defsubst unidata-prop-default (proplist) (nth 5 proplist))
337(defsubst unidata-prop-val-list (prop) (nth 7 (assq prop unidata-prop-alist))) 355(defsubst unidata-prop-val-list (proplist) (nth 6 proplist))
338 356
339 357
340;; SIMPLE TABLE 358;; SIMPLE TABLE
@@ -362,9 +380,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
362;; 3rd: 0 (corresponding to uniprop_encode_character in chartab.c) 380;; 3rd: 0 (corresponding to uniprop_encode_character in chartab.c)
363;; 4th to 5th: nil 381;; 4th to 5th: nil
364 382
365(defun unidata-gen-table-character (prop &rest ignore) 383(defun unidata-gen-table-character (prop prop-idx &rest ignore)
366 (let ((table (make-char-table 'char-code-property-table)) 384 (let ((table (make-char-table 'char-code-property-table))
367 (prop-idx (unidata-prop-index prop))
368 (vec (make-vector 128 0)) 385 (vec (make-vector 128 0))
369 (tail unidata-list) 386 (tail unidata-list)
370 elt range val idx slot) 387 elt range val idx slot)
@@ -469,13 +486,12 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
469 486
470;; Generate a char-table for the character property PROP. 487;; Generate a char-table for the character property PROP.
471 488
472(defun unidata-gen-table (prop val-func default-value val-list) 489(defun unidata-gen-table (prop prop-idx val-func default-value val-list)
473 (let ((table (make-char-table 'char-code-property-table)) 490 (let ((table (make-char-table 'char-code-property-table))
474 (prop-idx (unidata-prop-index prop))
475 (vec (make-vector 128 0)) 491 (vec (make-vector 128 0))
476 ;; When this warning is printed, there's a need to make the 492 ;; When this warning is printed, there's a need to make the
477 ;; following changes: 493 ;; following changes:
478 ;; (1) update unidata-prop-alist with the new bidi-class values; 494 ;; (1) update unidata-file-alist with the new bidi-class values;
479 ;; (2) extend bidi_type_t enumeration on src/dispextern.h to 495 ;; (2) extend bidi_type_t enumeration on src/dispextern.h to
480 ;; include the new classes; 496 ;; include the new classes;
481 ;; (3) possibly update the assertion in bidi.c:bidi_check_type; and 497 ;; (3) possibly update the assertion in bidi.c:bidi_check_type; and
@@ -596,8 +612,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
596 (set-char-table-extra-slot table 4 (vconcat (mapcar 'car val-list))) 612 (set-char-table-extra-slot table 4 (vconcat (mapcar 'car val-list)))
597 table)) 613 table))
598 614
599(defun unidata-gen-table-symbol (prop default-value val-list) 615(defun unidata-gen-table-symbol (prop index default-value val-list)
600 (let ((table (unidata-gen-table prop 616 (let ((table (unidata-gen-table prop index
601 #'(lambda (x) (and (> (length x) 0) 617 #'(lambda (x) (and (> (length x) 0)
602 (intern x))) 618 (intern x)))
603 default-value val-list))) 619 default-value val-list)))
@@ -605,8 +621,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
605 (set-char-table-extra-slot table 2 1) 621 (set-char-table-extra-slot table 2 1)
606 table)) 622 table))
607 623
608(defun unidata-gen-table-integer (prop default-value val-list) 624(defun unidata-gen-table-integer (prop index default-value val-list)
609 (let ((table (unidata-gen-table prop 625 (let ((table (unidata-gen-table prop index
610 #'(lambda (x) (and (> (length x) 0) 626 #'(lambda (x) (and (> (length x) 0)
611 (string-to-number x))) 627 (string-to-number x)))
612 default-value val-list))) 628 default-value val-list)))
@@ -614,8 +630,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
614 (set-char-table-extra-slot table 2 1) 630 (set-char-table-extra-slot table 2 1)
615 table)) 631 table))
616 632
617(defun unidata-gen-table-numeric (prop default-value val-list) 633(defun unidata-gen-table-numeric (prop index default-value val-list)
618 (let ((table (unidata-gen-table prop 634 (let ((table (unidata-gen-table prop index
619 #'(lambda (x) 635 #'(lambda (x)
620 (if (string-match "/" x) 636 (if (string-match "/" x)
621 (/ (float (string-to-number x)) 637 (/ (float (string-to-number x))
@@ -921,9 +937,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
921 937
922;; Generate a char-table for character names. 938;; Generate a char-table for character names.
923 939
924(defun unidata-gen-table-word-list (prop val-func) 940(defun unidata-gen-table-word-list (prop prop-idx val-func)
925 (let ((table (make-char-table 'char-code-property-table)) 941 (let ((table (make-char-table 'char-code-property-table))
926 (prop-idx (unidata-prop-index prop))
927 (word-list (list nil)) 942 (word-list (list nil))
928 word-table 943 word-table
929 block-list block-word-table block-end 944 block-list block-word-table block-end
@@ -1068,8 +1083,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1068 (or (byte-code-function-p (symbol-function fun)) 1083 (or (byte-code-function-p (symbol-function fun))
1069 (byte-compile fun)))) 1084 (byte-compile fun))))
1070 1085
1071(defun unidata-gen-table-name (prop &rest ignore) 1086(defun unidata-gen-table-name (prop index &rest ignore)
1072 (let* ((table (unidata-gen-table-word-list prop 'unidata-split-name)) 1087 (let* ((table (unidata-gen-table-word-list prop index 'unidata-split-name))
1073 (word-tables (char-table-extra-slot table 4))) 1088 (word-tables (char-table-extra-slot table 4)))
1074 (unidata--ensure-compiled 'unidata-get-name 'unidata-put-name) 1089 (unidata--ensure-compiled 'unidata-get-name 'unidata-put-name)
1075 (set-char-table-extra-slot table 1 (symbol-function 'unidata-get-name)) 1090 (set-char-table-extra-slot table 1 (symbol-function 'unidata-get-name))
@@ -1106,8 +1121,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1106 (nreverse l))))) 1121 (nreverse l)))))
1107 1122
1108 1123
1109(defun unidata-gen-table-decomposition (prop &rest ignore) 1124(defun unidata-gen-table-decomposition (prop index &rest ignore)
1110 (let* ((table (unidata-gen-table-word-list prop 'unidata-split-decomposition)) 1125 (let* ((table (unidata-gen-table-word-list prop index 'unidata-split-decomposition))
1111 (word-tables (char-table-extra-slot table 4))) 1126 (word-tables (char-table-extra-slot table 4)))
1112 (unidata--ensure-compiled 'unidata-get-decomposition 1127 (unidata--ensure-compiled 'unidata-get-decomposition
1113 'unidata-put-decomposition) 1128 'unidata-put-decomposition)
@@ -1149,9 +1164,8 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1149 (forward-line))) 1164 (forward-line)))
1150 result)) 1165 result))
1151 1166
1152(defun unidata-gen-table-special-casing (prop &rest ignore) 1167(defun unidata-gen-table-special-casing (prop prop-idx &rest ignore)
1153 (let ((table (make-char-table 'char-code-property-table)) 1168 (let ((table (make-char-table 'char-code-property-table)))
1154 (prop-idx (unidata-prop-index prop)))
1155 (set-char-table-extra-slot table 0 prop) 1169 (set-char-table-extra-slot table 0 prop)
1156 (mapc (lambda (entry) 1170 (mapc (lambda (entry)
1157 (let ((ch (car entry)) (v (nth prop-idx (cdr entry)))) 1171 (let ((ch (car entry)) (v (nth prop-idx (cdr entry))))
@@ -1322,56 +1336,57 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1322;; (unidata-check)) 1336;; (unidata-check))
1323 1337
1324(defun unidata-check () 1338(defun unidata-check ()
1325 (dolist (elt unidata-prop-alist) 1339 (dolist (elt unidata-file-alist)
1326 (let* ((prop (car elt)) 1340 (dolist (proplist (cdr elt))
1327 (index (unidata-prop-index prop)) 1341 (let* ((prop (unidata-prop-prop proplist))
1328 (generator (unidata-prop-generator prop)) 1342 (index (unidata-prop-index proplist))
1329 (default-value (unidata-prop-default prop)) 1343 (generator (unidata-prop-generator proplist))
1330 (val-list (unidata-prop-val-list prop)) 1344 (default-value (unidata-prop-default proplist))
1331 (table (progn 1345 (val-list (unidata-prop-val-list proplist))
1332 (message "Generating %S table..." prop) 1346 (table (progn
1333 (funcall generator prop default-value val-list))) 1347 (message "Generating %S table..." prop)
1334 (decoder (char-table-extra-slot table 1)) 1348 (funcall generator prop index default-value val-list)))
1335 (alist (and (functionp index) 1349 (decoder (char-table-extra-slot table 1))
1336 (funcall index))) 1350 (alist (and (functionp index)
1337 (check #x400)) 1351 (funcall index)))
1338 (dolist (e unidata-list) 1352 (check #x400))
1339 (let* ((char (car e)) 1353 (dolist (e unidata-list)
1340 (val1 1354 (let* ((char (car e))
1341 (if alist (nth 1 (assoc char alist)) 1355 (val1
1342 (nth index e))) 1356 (if alist (nth 1 (assoc char alist))
1343 val2) 1357 (nth index e)))
1344 (if (and (stringp val1) (= (length val1) 0)) 1358 val2)
1345 (setq val1 nil)) 1359 (if (and (stringp val1) (= (length val1) 0))
1346 (unless (or (consp char) 1360 (setq val1 nil))
1347 (integerp decoder)) 1361 (unless (or (consp char)
1348 (setq val2 1362 (integerp decoder))
1349 (cond ((functionp decoder) 1363 (setq val2
1350 (funcall decoder char (aref table char) table)) 1364 (cond ((functionp decoder)
1351 (t ; must be nil 1365 (funcall decoder char (aref table char) table))
1352 (aref table char)))) 1366 (t ; must be nil
1353 (if val1 1367 (aref table char))))
1354 (cond ((eq generator 'unidata-gen-table-symbol) 1368 (if val1
1355 (setq val1 (intern val1))) 1369 (cond ((eq generator 'unidata-gen-table-symbol)
1356 ((eq generator 'unidata-gen-table-integer) 1370 (setq val1 (intern val1)))
1357 (setq val1 (string-to-number val1))) 1371 ((eq generator 'unidata-gen-table-integer)
1358 ((eq generator 'unidata-gen-table-character) 1372 (setq val1 (string-to-number val1)))
1359 (setq val1 (string-to-number val1 16))) 1373 ((eq generator 'unidata-gen-table-character)
1360 ((eq generator 'unidata-gen-table-decomposition) 1374 (setq val1 (string-to-number val1 16)))
1361 (setq val1 (unidata-split-decomposition val1)))) 1375 ((eq generator 'unidata-gen-table-decomposition)
1362 (cond ((eq prop 'decomposition) 1376 (setq val1 (unidata-split-decomposition val1))))
1363 (setq val1 (list char))) 1377 (cond ((eq prop 'decomposition)
1364 ((eq prop 'bracket-type) 1378 (setq val1 (list char)))
1365 (setq val1 'n)))) 1379 ((eq prop 'bracket-type)
1366 (when (>= char check) 1380 (setq val1 'n))))
1367 (message "%S %04X" prop check) 1381 (when (>= char check)
1368 (setq check (+ check #x400))) 1382 (message "%S %04X" prop check)
1369 (or (equal val1 val2) 1383 (setq check (+ check #x400)))
1370 ;; <control> characters get a 'name' property of nil 1384 (or (equal val1 val2)
1371 (and (eq prop 'name) (string= val1 "<control>") (null val2)) 1385 ;; <control> characters get a 'name' property of nil
1372 (insert (format "> %04X %S\n< %04X %S\n" 1386 (and (eq prop 'name) (string= val1 "<control>") (null val2))
1373 char val1 char val2))) 1387 (insert (format "> %04X %S\n< %04X %S\n"
1374 (sit-for 0))))))) 1388 char val1 char val2)))
1389 (sit-for 0))))))))
1375 1390
1376;; The entry function. It generates files described in the header 1391;; The entry function. It generates files described in the header
1377;; comment of this file. 1392;; comment of this file.
@@ -1389,61 +1404,50 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1389 (coding-system-for-read 'utf-8) 1404 (coding-system-for-read 'utf-8)
1390 (charprop-file (expand-file-name "charprop.el" dest-dir)) 1405 (charprop-file (expand-file-name "charprop.el" dest-dir))
1391 (unidata-dir data-dir)) 1406 (unidata-dir data-dir))
1392 (dolist (elt unidata-prop-alist)
1393 (let* ((prop (car elt))
1394 (file (expand-file-name (unidata-prop-file prop) dest-dir)))
1395 (if (file-exists-p file)
1396 (delete-file file))))
1397 (unidata-setup-list unidata-text-file) 1407 (unidata-setup-list unidata-text-file)
1398 (with-temp-file charprop-file 1408 (with-temp-file charprop-file
1399 (insert ";; Automatically generated by unidata-gen.el.\n") 1409 (insert ";; Automatically generated by unidata-gen.el.\n")
1400 (dolist (elt unidata-prop-alist) 1410 (dolist (elt unidata-file-alist)
1401 (let* ((prop (car elt)) 1411 (let* ((file (expand-file-name (car elt) dest-dir))
1402 (generator (unidata-prop-generator prop))
1403 (file (expand-file-name (unidata-prop-file prop) dest-dir))
1404 (basename (file-name-nondirectory file)) 1412 (basename (file-name-nondirectory file))
1405 (docstring (unidata-prop-docstring prop)) 1413 (cbuff (current-buffer)))
1406 (describer (unidata-prop-describer prop)) 1414 (or noninteractive (message "Generating %s..." file))
1407 (default-value (unidata-prop-default prop)) 1415 ;; Filename in this comment line is extracted by sed in Makefile.
1408 (val-list (unidata-prop-val-list prop))
1409 ;; Avoid creating backup files for those uni-*.el files
1410 ;; that hold more than one table.
1411 (backup-inhibited t)
1412 table)
1413 ;; Filename in this comment line is extracted by sed in
1414 ;; Makefile.
1415 (insert (format ";; FILE: %s\n" basename)) 1416 (insert (format ";; FILE: %s\n" basename))
1416 (insert (format "(define-char-code-property '%S %S\n %S)\n"
1417 prop basename docstring))
1418 (with-temp-buffer 1417 (with-temp-buffer
1419 (or noninteractive (message "Generating %s..." file)) 1418 (insert ";; Copyright (C) 1991-2014 Unicode, Inc.
1420 (when (file-exists-p file)
1421 (insert-file-contents file)
1422 (goto-char (point-max))
1423 (search-backward ";; Local Variables:"))
1424 (setq table (funcall generator prop default-value val-list))
1425 (when describer
1426 (unless (subrp (symbol-function describer))
1427 (unidata--ensure-compiled describer)
1428 (setq describer (symbol-function describer)))
1429 (set-char-table-extra-slot table 3 describer))
1430 (if (bobp)
1431 (insert ";; Copyright (C) 1991-2014 Unicode, Inc.
1432;; This file was generated from the Unicode data files at 1419;; This file was generated from the Unicode data files at
1433;; http://www.unicode.org/Public/UNIDATA/. 1420;; http://www.unicode.org/Public/UNIDATA/.
1434;; See lisp/international/README for the copyright and permission notice.\n")) 1421;; See lisp/international/README for the copyright and permission notice.\n")
1435 (insert (format "(define-char-code-property '%S\n %S\n %S)\n" 1422 (dolist (proplist (cdr elt))
1436 prop table docstring)) 1423 (let ((prop (unidata-prop-prop proplist))
1437 (if (eobp) 1424 (index (unidata-prop-index proplist))
1438 (insert ";; Local Variables:\n" 1425 (generator (unidata-prop-generator proplist))
1439 ";; coding: utf-8\n" 1426 (docstring (unidata-prop-docstring proplist))
1440 ";; version-control: never\n" 1427 (describer (unidata-prop-describer proplist))
1441 ";; no-byte-compile: t\n" 1428 (default-value (unidata-prop-default proplist))
1442 ";; no-update-autoloads: t\n" 1429 (val-list (unidata-prop-val-list proplist))
1443 ";; End:\n\n" 1430 table)
1444 (format ";; %s ends here\n" basename))) 1431 (with-current-buffer cbuff
1445 (write-file file) 1432 (insert (format "(define-char-code-property '%S %S\n %S)\n"
1446 (or noninteractive (message "Generating %s...done" file))))) 1433 prop basename docstring)))
1434 (setq table (funcall generator prop index default-value val-list))
1435 (when describer
1436 (unless (subrp (symbol-function describer))
1437 (unidata--ensure-compiled describer)
1438 (setq describer (symbol-function describer)))
1439 (set-char-table-extra-slot table 3 describer))
1440 (insert (format "(define-char-code-property '%S\n %S\n %S)\n"
1441 prop table docstring))))
1442 (insert ";; Local Variables:\n"
1443 ";; coding: utf-8\n"
1444 ";; version-control: never\n"
1445 ";; no-byte-compile: t\n"
1446 ";; no-update-autoloads: t\n"
1447 ";; End:\n\n"
1448 (format ";; %s ends here\n" basename))
1449 (write-file file nil))
1450 (or noninteractive (message "Generating %s...done" file))))
1447 (message "Writing %s..." charprop-file) 1451 (message "Writing %s..." charprop-file)
1448 (insert ";; Local Variables:\n" 1452 (insert ";; Local Variables:\n"
1449 ";; coding: utf-8\n" 1453 ";; coding: utf-8\n"