| 1 |
;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*- |
| 2 |
;;; |
| 3 |
;;; Copyright (c) 2009, Juan Jose Garcia-Ripoll |
| 4 |
;;; |
| 5 |
;;; This program is free software; you can redistribute it and/or |
| 6 |
;;; modify it under the terms of the GNU Library General Public |
| 7 |
;;; License as published by the Free Software Foundation; either |
| 8 |
;;; version 2 of the License, or (at your option) any later version. |
| 9 |
;;; |
| 10 |
;;; See file '../Copyright' for full details. |
| 11 |
|
| 12 |
(load (merge-pathnames "tools" *load-pathname*)) |
| 13 |
|
| 14 |
(defconstant +encodings-root+ (translate-logical-pathname #p"ext:encodings;")) |
| 15 |
|
| 16 |
(loop for entry in +all-mappings+ |
| 17 |
for name = (first entry) |
| 18 |
for orig = (make-pathname :name name :type "BIN" |
| 19 |
:defaults +encodings-root+) |
| 20 |
for copy = (ensure-directories-exist |
| 21 |
(make-pathname :name name :type "BIN" |
| 22 |
:defaults "build:encodings;")) |
| 23 |
do (progn |
| 24 |
(unless (probe-file orig) |
| 25 |
(error "Missing mapping") |
| 26 |
(let ((mapping (if (equalp name "JISX0208") |
| 27 |
(mapcar #'rest (read-mapping name 3)) |
| 28 |
(read-mapping name)))) |
| 29 |
(dump-mapping-array mapping orig))) |
| 30 |
(copy-encoding-file orig copy))) |
| 31 |
|
| 32 |
(defconstant +aliases+ |
| 33 |
'((:us-ascii ext::ascii) |
| 34 |
(:utf-8 ext::utf8) |
| 35 |
(:ucs-2 ext::ucs2 ext::utf-16 ext::utf16 ext::unicode) |
| 36 |
(:ucs-2le ext::ucs2le ext::utf-16le) |
| 37 |
(:ucs-2be ext::ucs2be ext::utf-16be) |
| 38 |
(:ucs-4 ext::ucs4 ext::utf-32 ext::utf32) |
| 39 |
(:ucs-4be ext::ucs4be ext::utf-32be) |
| 40 |
(:ucs-4le ext::ucs4le ext::utf-32le) |
| 41 |
|
| 42 |
(ext::koi8-r ext::koi8r) |
| 43 |
|
| 44 |
(ext::iso-8859-1 ext::iso8859-1 ext::latin-1 ext::cp819 ext::ibm819) |
| 45 |
(ext::iso-8859-2 ext::iso8859-2 ext::latin-2 ext::latin2) |
| 46 |
(ext::iso-8859-3 ext::iso8859-3 ext::latin-3 ext::latin3) |
| 47 |
(ext::iso-8859-4 ext::iso8859-4 ext::latin-4 ext::latin4) |
| 48 |
(ext::iso-8859-5 ext::iso8859-5 ext::cyrillic) |
| 49 |
(ext::iso-8859-6 ext::iso8859-6 ext::arabic ext::asmo-708 ext::ecma-114) |
| 50 |
(ext::iso-8859-7 ext::iso8859-7 ext::greek8 ext::greek ext::ecma-118) |
| 51 |
(ext::iso-8859-8 ext::iso8859-8 ext::hebrew) |
| 52 |
(ext::iso-8859-9 ext::iso8859-9 ext::latin-5 ext::latin5) |
| 53 |
(ext::iso-8859-10 ext::iso8859-10 ext::latin-6 ext::latin6) |
| 54 |
;(:iso-8859-11 :iso8859-11 :thai) |
| 55 |
(ext::iso-8859-13 ext::iso8859-13 ext::latin-7 ext::latin7) |
| 56 |
(ext::iso-8859-14 ext::iso8859-14 ext::latin-8 ext::latin8) |
| 57 |
(ext::iso-8859-15 ext::iso8859-15 ext::latin-9 ext::latin9) |
| 58 |
|
| 59 |
(ext::dos-cp437 ext::ibm437) |
| 60 |
(ext::dos-cp850 ext::ibm850 ext::cp850) |
| 61 |
(ext::dos-cp852 ext::ibm852) |
| 62 |
(ext::dos-cp855 ext::ibm855) |
| 63 |
(ext::dos-cp857 ext::ibm857) |
| 64 |
(ext::dos-cp860 ext::ibm860) |
| 65 |
(ext::dos-cp861 ext::ibm861) |
| 66 |
(ext::dos-cp862 ext::ibm862 ext::cp862) |
| 67 |
(ext::dos-cp863 ext::ibm863) |
| 68 |
(ext::dos-cp864 ext::ibm864) |
| 69 |
(ext::dos-cp865 ext::ibm865) |
| 70 |
(ext::dos-cp866 ext::ibm866 ext::cp866) |
| 71 |
(ext::dos-cp869 ext::ibm869) |
| 72 |
|
| 73 |
(ext::windows-cp932 ext::windows-932 ext::cp932) |
| 74 |
(ext::windows-cp936 ext::windows-936 ext::cp936) |
| 75 |
(ext::windows-cp949 ext::windows-949 ext::cp949) |
| 76 |
(ext::windows-cp950 ext::windows-950 ext::cp950) |
| 77 |
|
| 78 |
(ext::windows-cp1250 ext::windows-1250 ext::ms-ee) |
| 79 |
(ext::windows-cp1251 ext::windows-1251 ext::ms-cyrl) |
| 80 |
(ext::windows-cp1252 ext::windows-1252 ext::ms-ansi) |
| 81 |
(ext::windows-cp1253 ext::windows-1253 ext::ms-greek) |
| 82 |
(ext::windows-cp1254 ext::windows-1254 ext::ms-turk) |
| 83 |
(ext::windows-cp1255 ext::windows-1255 ext::ms-hebr) |
| 84 |
(ext::windows-cp1256 ext::windows-1256 ext::ms-arab) |
| 85 |
(ext::windows-cp1257 ext::windows-1257 ext::winbaltrim) |
| 86 |
(ext::windows-cp1258 ext::windows-1258) |
| 87 |
)) |
| 88 |
|
| 89 |
(loop for (name . aliases) in +aliases+ |
| 90 |
do (loop with *package* = (find-package "CL") |
| 91 |
for alias in aliases |
| 92 |
for filename0 = (make-pathname :name (symbol-name alias) |
| 93 |
:defaults "build:encodings;") |
| 94 |
for filename = (ensure-directories-exist filename0) |
| 95 |
do (with-open-file (out filename :direction :output :if-exists :supersede |
| 96 |
:if-does-not-exist :create :element-type 'base-char) |
| 97 |
(format t "~%;;; Creating alias ~A -> ~A, ~A" alias name filename) |
| 98 |
(if (keywordp name) |
| 99 |
(format out "(defparameter ~S '~S)" alias name) |
| 100 |
(format out "(defparameter ~S (ext::make-encoding '~S))" alias name)) |
| 101 |
))) |
| 102 |
|
| 103 |
(copy-encoding-file "ext:encodings;tools.lisp" "build:encodings;tools.lisp") |
| 104 |
(copy-encoding-file (merge-pathnames "ISO-2022-JP" +encodings-root+) |
| 105 |
"build:encodings;ISO-2022-JP") |
| 106 |
(copy-encoding-file (merge-pathnames "ISO-2022-JP-1" +encodings-root+) |
| 107 |
"build:encodings;ISO-2022-JP-1") |