diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-01-08 11:53:52 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-01-08 11:53:52 +0100 |
commit | fa838e76139763f902c7d27cb9e1d393ed6a15e4 (patch) | |
tree | 7d0ae09775ea950056193eaa2ca93844299d46f1 /lib/uniname/gen-uninames.lisp | |
parent | c78359d9542c86b972aac373efcf7bc7a8a560e5 (diff) | |
parent | 2959e59fab3bab834368adefd90bd4b1b094366b (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'lib/uniname/gen-uninames.lisp')
-rwxr-xr-x | lib/uniname/gen-uninames.lisp | 95 |
1 files changed, 69 insertions, 26 deletions
diff --git a/lib/uniname/gen-uninames.lisp b/lib/uniname/gen-uninames.lisp index 937b50ef..5ebb921c 100755 --- a/lib/uniname/gen-uninames.lisp +++ b/lib/uniname/gen-uninames.lisp @@ -1,7 +1,30 @@ #!/usr/local/bin/clisp -C ;;; Creation of gnulib's uninames.h from the UnicodeData.txt table. -;;; Bruno Haible 2000-12-28 + +;;; Copyright (C) 2000-2022 Free Software Foundation, Inc. +;;; Written by Bruno Haible <bruno@clisp.org>, 2000-12-28. +;;; +;;; This program is free software. +;;; It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". +;;; You can redistribute it and/or modify it under either +;;; - the terms of the GNU Lesser General Public License as published +;;; by the Free Software Foundation; either version 3, or (at your +;;; option) any later version, or +;;; - the terms of the GNU General Public License as published by the +;;; Free Software Foundation; either version 2, or (at your option) +;;; any later version, or +;;; - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+". +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; Lesser General Public License and the GNU General Public License +;;; for more details. +;;; +;;; You should have received a copy of the GNU Lesser General Public +;;; License and of the GNU General Public License along with this +;;; program. If not, see <https://www.gnu.org/licenses/>. (defparameter add-comments nil) @@ -58,11 +81,12 @@ (unless (or (<= #xFE00 code #xFE0F) (<= #xE0100 code #xE01EF)) (push (make-unicode-char :index name-index :name name-string) - all-chars) + all-chars + ) (setf (gethash code all-chars-hashed) (car all-chars)) ;; Update the contiguous range, or start a new range. (if (and range (= (1+ (range-end-code range)) code)) - (setf (range-end-code range) code) + (setf (range-end-code range) code) (progn (when range (push range all-ranges)) @@ -70,32 +94,33 @@ :start-code code :end-code code)))) (incf name-index) - (setq last-code code) - ) ) ) ) + ) ) ) ) ) ) ) ) (setq all-chars (nreverse all-chars)) (if range - (push range all-ranges)) + (push range all-ranges)) (setq all-ranges (nreverse all-ranges)) (when aliasfile ;; Read all characters and names from the alias file. (with-open-file (istream aliasfile :direction :input) (loop - (let ((line (read-line istream nil nil))) - (unless line (return)) - (let* ((i1 (position #\; line)) - (i2 (position #\; line :start (1+ i1))) - (code-string (subseq line 0 i1)) - (code (parse-integer code-string :radix 16)) - (name-string (subseq line (1+ i1) i2)) - (uc (gethash code all-chars-hashed))) - (when uc - (push (make-unicode-char :index (unicode-char-index uc) - :name name-string) - all-aliases) - ) ) ) ) ) ) + (let ((line (read-line istream nil nil))) + (unless line (return)) + (unless (or (equal line "") (equal (subseq line 0 1) "#")) + (let* ((i1 (position #\; line)) + (i2 (position #\; line :start (1+ i1))) + (code-string (subseq line 0 i1)) + (code (parse-integer code-string :radix 16)) + (name-string (subseq line (1+ i1) i2)) + (uc (gethash code all-chars-hashed))) + (when uc + (push (make-unicode-char :index (unicode-char-index uc) + :name name-string) + all-aliases + ) ) ) ) ) ) ) ) (setq all-aliases (nreverse all-aliases) - all-chars-and-aliases (append all-chars all-aliases)) + all-chars-and-aliases (append all-chars all-aliases) + ) ;; Split into words. (let ((words-by-length (make-array 0 :adjustable t))) (dolist (name (list* "HANGUL SYLLABLE" "CJK COMPATIBILITY" "VARIATION" @@ -151,6 +176,28 @@ (format ostream " * Unicode character name table.~%") (format ostream " * Generated automatically by the gen-uninames utility.~%") (format ostream " */~%") + (format ostream "/* Copyright (C) 2000-2022 Free Software Foundation, Inc.~%") + (format ostream "~%") + (format ostream " This file is free software.~%") + (format ostream " It is dual-licensed under \"the GNU LGPLv3+ or the GNU GPLv2+\".~%") + (format ostream " You can redistribute it and/or modify it under either~%") + (format ostream " - the terms of the GNU Lesser General Public License as published~%") + (format ostream " by the Free Software Foundation; either version 3, or (at your~%") + (format ostream " option) any later version, or~%") + (format ostream " - the terms of the GNU General Public License as published by the~%") + (format ostream " Free Software Foundation; either version 2, or (at your option)~%") + (format ostream " any later version, or~%") + (format ostream " - the same dual license \"the GNU LGPLv3+ or the GNU GPLv2+\".~%") + (format ostream "~%") + (format ostream " This file is distributed in the hope that it will be useful,~%") + (format ostream " but WITHOUT ANY WARRANTY; without even the implied warranty of~%") + (format ostream " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU~%") + (format ostream " Lesser General Public License and the GNU General Public License~%") + (format ostream " for more details.~%") + (format ostream "~%") + (format ostream " You should have received a copy of the GNU Lesser General Public~%") + (format ostream " License and of the GNU General Public License along with this~%") + (format ostream " program. If not, see <https://www.gnu.org/licenses/>. */~%") (format ostream "~%") (format ostream "static const char unicode_name_words[~D] = {~%" (let ((sum 0)) @@ -279,9 +326,7 @@ (incf i (length (unicode-char-word-indices uc))) ) ) (format ostream "};~%") - (format ostream "static const struct { uint16_t index; uint32_t name:24; }~%") - (format ostream "#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)~%__attribute__((__packed__))~%#endif~%") - (format ostream "unicode_name_to_index[~D] = {~%" + (format ostream "static const struct { uint16_t index; uint32_t name:24; } ATTRIBUTE_PACKED unicode_name_to_index[~D] = {~%" (length all-chars-and-aliases) ) (dolist (uc all-chars-and-aliases) @@ -295,9 +340,7 @@ (format ostream "~%") ) (format ostream "};~%") - (format ostream "static const struct { uint16_t index; uint32_t name:24; }~%") - (format ostream "#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)~%__attribute__((__packed__))~%#endif~%") - (format ostream "unicode_index_to_name[~D] = {~%" + (format ostream "static const struct { uint16_t index; uint32_t name:24; } ATTRIBUTE_PACKED unicode_index_to_name[~D] = {~%" (length all-chars) ) (dolist (uc (sort (copy-list all-chars) #'< :key #'unicode-char-index)) |