Raymond Toy pushed to branch issue-363-add-version-number at cmucl / cmucl
Commits:
-
9ea51cb2
by Raymond Toy at 2025-01-28T14:14:09+00:00
-
98961a8b
by Raymond Toy at 2025-01-28T14:14:10+00:00
-
5f94e404
by Raymond Toy at 2025-01-28T15:50:59+00:00
-
4bc3e3f4
by Raymond Toy at 2025-01-28T15:50:59+00:00
-
bf461224
by Raymond Toy at 2025-01-29T13:59:15-08:00
-
fd391099
by Raymond Toy at 2025-01-31T14:39:40+00:00
-
12e15d8b
by Raymond Toy at 2025-01-31T14:39:40+00:00
-
739de261
by Raymond Toy at 2025-01-31T06:57:45-08:00
-
46f8aca7
by Raymond Toy at 2025-02-03T13:47:04-08:00
-
c88d93f3
by Raymond Toy at 2025-02-03T13:49:25-08:00
-
bcea3e15
by Raymond Toy at 2025-02-03T13:54:57-08:00
-
c95ff4ba
by Raymond Toy at 2025-02-03T14:22:20-08:00
-
dc084d13
by Raymond Toy at 2025-02-04T07:40:42-08:00
27 changed files:
- .gitlab-ci.yml
- bin/build.sh
- bin/cmucl-version.sh
- bin/make-dist.sh
- bin/run-unit-tests.sh
- + src/bootfiles/21e/boot-2024-08.lisp
- src/code/exports.lisp
- src/code/extfmts.lisp
- src/code/unix.lisp
- src/general-info/release-21f.md
- src/i18n/locale/cmucl-unix.pot
- src/i18n/locale/cmucl.pot
- src/lisp/GNUmakefile
- src/lisp/lisp.c
- src/pcl/simple-streams/external-formats/ascii.lisp
- src/pcl/simple-streams/external-formats/euc-kr.lisp
- src/pcl/simple-streams/external-formats/iso8859-1.lisp
- src/pcl/simple-streams/external-formats/iso8859-2.lisp
- src/pcl/simple-streams/external-formats/mac-roman.lisp
- src/pcl/simple-streams/external-formats/utf-16-be.lisp
- src/pcl/simple-streams/external-formats/utf-16-le.lisp
- src/pcl/simple-streams/external-formats/utf-16.lisp
- src/pcl/simple-streams/external-formats/utf-32-be.lisp
- src/pcl/simple-streams/external-formats/utf-32-le.lisp
- src/pcl/simple-streams/external-formats/utf-32.lisp
- src/pcl/simple-streams/external-formats/utf-8.lisp
- + tests/external-formats.lisp
Changes:
1 | 1 | variables:
|
2 | 2 | download_url: "https://common-lisp.net/project/cmucl/downloads/snapshots/2024/08"
|
3 | 3 | version: "2024-08-x86"
|
4 | - bootstrap: ""
|
|
4 | + bootstrap: "-B boot-2024-08"
|
|
5 | 5 | |
6 | 6 | |
7 | 7 | stages:
|
... | ... | @@ -51,8 +51,8 @@ linux:build: |
51 | 51 | # instead of clang.
|
52 | 52 | - bin/build.sh $bootstrap -R -C "x86_linux" -o snapshot/bin/lisp
|
53 | 53 | # - bin/build.sh $bootstrap -R -C "x86_linux" -o snapshot/bin/lisp
|
54 | - # If needed use -V to specify the version in case some tag makes git
|
|
55 | - # describe return something that make-dist.sh doesn't like.
|
|
54 | + # When the result of `git describe` cannot be used as a version
|
|
55 | + # string, an alternative can be provided with the -V flag
|
|
56 | 56 | - bin/make-dist.sh -I dist linux-4
|
57 | 57 | |
58 | 58 | linux:cross-build:
|
... | ... | @@ -51,6 +51,7 @@ export GIT_FILE_COMMENT |
51 | 51 | SKIPUTILS=no
|
52 | 52 | DEFAULT_VERSION="`bin/cmucl-version.sh`"
|
53 | 53 | export DEFAULT_VERISON
|
54 | +echo DEFAULT_VERSION = $DEFAULT_VERSION
|
|
54 | 55 | |
55 | 56 | # If gmake exists, assume it is GNU make and use it.
|
56 | 57 | if [ -z "$MAKE" ]; then
|
1 | 1 | #!/bin/sh
|
2 | 2 | |
3 | +# If no, just print out the version. If yes, print out the version as
|
|
4 | +# a C file #define.
|
|
5 | + |
|
6 | +FILE=""
|
|
7 | + |
|
8 | +while getopts "f" arg
|
|
9 | +do
|
|
10 | + case $arg in
|
|
11 | + f) FILE=yes
|
|
12 | + ;;
|
|
13 | + esac
|
|
14 | +done
|
|
15 | + |
|
3 | 16 | # Script to determine the cmucl version based on git describe
|
4 | 17 | GIT_HASH="`(git describe --dirty 2>/dev/null || git describe 2>/dev/null)`"
|
5 | 18 | # echo GIT_HASH = ${GIT_HASH}
|
6 | 19 | |
7 | -if expr "X${GIT_HASH}" : 'Xsnapshot-[0-9][0-9][0-9][0-9]-[01][0-9]' > /dev/null; then
|
|
20 | +if [ `expr "X${GIT_HASH}" : 'Xsnapshot-[0-9][0-9][0-9][0-9]-[01][0-9]'` != 0 ]; then
|
|
8 | 21 | # The git hash looks like snapshot-yyyy-mm-<stuff>. Remove the
|
9 | 22 | # "snapshot-" part.
|
10 | 23 | DEFAULT_VERSION=`expr "${GIT_HASH}" : "snapshot-\(.*\)"`
|
11 | 24 | fi
|
12 | 25 | |
13 | -if expr "X${GIT_HASH}" : 'X[0-9][0-9][a-f]' > /dev/null; then
|
|
26 | +if [ `expr "X${GIT_HASH}" : 'X[0-9][0-9][a-f]'` != 0 ]; then
|
|
14 | 27 | # The git hash looks like a release which is 3 hex digits. Use it as is.
|
15 | 28 | DEFAULT_VERSION="${GIT_HASH}"
|
16 | 29 | fi
|
17 | 30 | |
18 | -echo $DEFAULT_VERSION |
|
31 | +if [ -z "$FILE" ]; then
|
|
32 | + echo $DEFAULT_VERSION
|
|
33 | +else
|
|
34 | + cat <<EOF
|
|
35 | +/*
|
|
36 | + * Cmucl version
|
|
37 | + *
|
|
38 | + * DO NOT EDIT! This file is auto-generated via bin/cmucl-version.sh.
|
|
39 | + */
|
|
40 | + |
|
41 | +#define CMUCL_VERSION "$DEFAULT_VERSION"
|
|
42 | +EOF
|
|
43 | +fi
|
|
44 | + |
... | ... | @@ -182,9 +182,6 @@ fi |
182 | 182 | TARGET="`echo $1 | sed 's:/*$::'`"
|
183 | 183 | |
184 | 184 | echo INSTALL_DIR = $INSTALL_DIR
|
185 | -#if [ -n "$INSTALL_DIR" ]; then
|
|
186 | -# VERSION="today"
|
|
187 | -#fi
|
|
188 | 185 | |
189 | 186 | echo cmucl-$VERSION-$ARCH-$OS
|
190 | 187 | ROOT=`dirname $0`
|
... | ... | @@ -51,7 +51,7 @@ trap cleanup EXIT |
51 | 51 | |
52 | 52 | #set -x
|
53 | 53 | if [ -n "${TESTDIR}" ]; then
|
54 | - TESTDIRARG=" :test-directory \"${TESTDIR}/\""
|
|
54 | + TESTDIRARG=" :test-directory \"$TESTDIR/\""
|
|
55 | 55 | else
|
56 | 56 | TESTDIR="tests/"
|
57 | 57 | TESTDIRARG=""
|
... | ... | @@ -59,12 +59,12 @@ fi |
59 | 59 | # Compile up the C file that is used for testing alien funcalls to
|
60 | 60 | # functions that return integer types of different lengths. We use
|
61 | 61 | # gcc since clang isn't always available.
|
62 | -(cd $TESTDIR; gcc -m32 -O3 -c test-return.c)
|
|
62 | +(cd "$TESTDIR"; gcc -m32 -O3 -c test-return.c)
|
|
63 | 63 | |
64 | 64 | if [ $# -eq 0 ]; then
|
65 | 65 | # Test directory arg for run-all-tests if a non-default
|
66 | 66 | # No args so run all the tests
|
67 | - $LISP -nositeinit -noinit -load $TESTDIR/run-tests.lisp -eval "(cmucl-test-runner:run-all-tests ${TESTDIRARG})"
|
|
67 | + $LISP -nositeinit -noinit -load "$TESTDIR"/run-tests.lisp -eval "(cmucl-test-runner:run-all-tests ${TESTDIRARG})"
|
|
68 | 68 | else
|
69 | 69 | # Run selected files. Convert each file name to uppercase and append "-TESTS"
|
70 | 70 | result=""
|
... | ... | @@ -73,6 +73,6 @@ else |
73 | 73 | new=`echo $f | tr '[a-z]' '[A-Z]'`
|
74 | 74 | result="$result "\"$new-TESTS\"
|
75 | 75 | done
|
76 | - $LISP -nositeinit -noinit -load $TESTDIR/run-tests.lisp -eval "(progn (cmucl-test-runner:load-test-files) (cmucl-test-runner:run-test $result))"
|
|
76 | + $LISP -nositeinit -noinit -load "$TESTDIR"/run-tests.lisp -eval "(progn (cmucl-test-runner:load-test-files) (cmucl-test-runner:run-test $result))"
|
|
77 | 77 | fi
|
78 | 78 |
1 | +;; Bootstrap file for the ef-octet-count changes. Just need to change
|
|
2 | +;; the value of +ef-max+
|
|
3 | + |
|
4 | +(in-package "STREAM")
|
|
5 | + |
|
6 | +(handler-bind
|
|
7 | + ((error (lambda (c)
|
|
8 | + (declare (ignore c))
|
|
9 | + (invoke-restart 'continue))))
|
|
10 | + (defconstant +ef-max+ 14)) |
... | ... | @@ -1456,7 +1456,8 @@ |
1456 | 1456 | (name
|
1457 | 1457 | '("STRING-TO-OCTETS" "OCTETS-TO-STRING" "*DEFAULT-EXTERNAL-FORMAT*"
|
1458 | 1458 | "STRING-ENCODE" "STRING-DECODE" "SET-SYSTEM-EXTERNAL-FORMAT"
|
1459 | - "LIST-ALL-EXTERNAL-FORMATS" "DESCRIBE-EXTERNAL-FORMAT"))
|
|
1459 | + "LIST-ALL-EXTERNAL-FORMATS" "DESCRIBE-EXTERNAL-FORMAT"
|
|
1460 | + "STRING-OCTET-COUNT"))
|
|
1460 | 1461 | (intern name "STREAM"))
|
1461 | 1462 | |
1462 | 1463 | (defpackage "EXTENSIONS"
|
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 | string-encode string-decode set-system-external-format
|
20 | 20 | +replacement-character-code+
|
21 | 21 | list-all-external-formats
|
22 | - describe-external-format))
|
|
22 | + describe-external-format
|
|
23 | + string-octet-count))
|
|
23 | 24 | |
24 | 25 | (defvar *default-external-format*
|
25 | 26 | :utf-8
|
... | ... | @@ -52,6 +53,7 @@ |
52 | 53 | flush ; flush state
|
53 | 54 | copy-state ; copy state
|
54 | 55 | osc ; octets to string, counted
|
56 | + oc ; number of octets to encode string
|
|
55 | 57 | max)
|
56 | 58 | |
57 | 59 | ;; Unicode replacement character U+FFFD
|
... | ... | @@ -96,6 +98,11 @@ |
96 | 98 | (copy-state nil :type (or null function) :read-only t)
|
97 | 99 | (cache nil :type (or null simple-vector))
|
98 | 100 | ;;
|
101 | + ;; Function to count the number of octets needed to encode a
|
|
102 | + ;; codepoint. Basically like code-to-octets, except we return the
|
|
103 | + ;; number of octets needed instead of the octets themselves.
|
|
104 | + (octet-count #'%efni :type (or null function) :read-only t)
|
|
105 | + ;;
|
|
99 | 106 | ;; Minimum number of octets needed to form a codepoint
|
100 | 107 | (min 1 :type kernel:index :read-only t)
|
101 | 108 | ;;
|
... | ... | @@ -126,7 +133,8 @@ |
126 | 133 | (setf (gethash (ef-name ef) *external-formats*) ef))
|
127 | 134 | |
128 | 135 | (declaim (inline ef-octets-to-code ef-code-to-octets ef-flush-state ef-copy-state
|
129 | - ef-cache ef-min-octets ef-max-octets))
|
|
136 | + ef-cache ef-min-octets ef-max-octets
|
|
137 | + ef-octet-count))
|
|
130 | 138 | |
131 | 139 | (defun ef-octets-to-code (ef)
|
132 | 140 | (efx-octets-to-code (ef-efx ef)))
|
... | ... | @@ -143,6 +151,9 @@ |
143 | 151 | (defun ef-cache (ef)
|
144 | 152 | (efx-cache (ef-efx ef)))
|
145 | 153 | |
154 | +(defun ef-octet-count (ef)
|
|
155 | + (efx-octet-count (ef-efx ef)))
|
|
156 | + |
|
146 | 157 | (defun ef-min-octets (ef)
|
147 | 158 | (efx-min (ef-efx ef)))
|
148 | 159 | |
... | ... | @@ -166,7 +177,7 @@ |
166 | 177 | ;;; DEFINE-EXTERNAL-FORMAT -- Public
|
167 | 178 | ;;;
|
168 | 179 | ;;; name (&key base min max size documentation) (&rest slots) octets-to-code
|
169 | -;;; code-to-octets flush-state copy-state
|
|
180 | +;;; code-to-octets flush-state copy-state octet-count
|
|
170 | 181 | ;;;
|
171 | 182 | ;;; Define a new external format. If base is specified, then an
|
172 | 183 | ;;; external format is defined that is based on a previously defined
|
... | ... | @@ -228,6 +239,15 @@ |
228 | 239 | ;;; This should probably be a deep copy so that if the original
|
229 | 240 | ;;; state is modified, the copy is not.
|
230 | 241 | ;;;
|
242 | +;;; octet-count (code state error &rest vars)
|
|
243 | +;;; Defines a form to determine the number of octets needed to
|
|
244 | +;;; encode the given CODE using the external format. This is
|
|
245 | +;;; essentially the same as CODE-TO-OCTETS, except the encoding is
|
|
246 | +;;; not saved anywhere. ERROR is the same as in CODE-TO-OCTETS.
|
|
247 | +;;;
|
|
248 | +;;; This should return one value: the number of octets needed to
|
|
249 | +;;; encode the given code.
|
|
250 | +;;;
|
|
231 | 251 | ;;; Note: external-formats work on code-points, not
|
232 | 252 | ;;; characters, so that the entire 31 bit ISO-10646 range can be
|
233 | 253 | ;;; used internally regardless of the size of a character recognized
|
... | ... | @@ -238,7 +258,7 @@ |
238 | 258 | (defmacro define-external-format (name (&key base min max size (documentation ""))
|
239 | 259 | (&rest slots)
|
240 | 260 | &optional octets-to-code code-to-octets
|
241 | - flush-state copy-state)
|
|
261 | + flush-state copy-state octet-count)
|
|
242 | 262 | (let* ((tmp (gensym))
|
243 | 263 | (min (or min size 1))
|
244 | 264 | (max (or max size 6))
|
... | ... | @@ -282,7 +302,17 @@ |
282 | 302 | (declare (ignorable ,state))
|
283 | 303 | (let (,@',slotb
|
284 | 304 | ,@(loop for var in vars collect `(,var (gensym))))
|
285 | - ,body))))
|
|
305 | + ,body)))
|
|
306 | + (octet-count ((code state error &rest vars) body)
|
|
307 | + `(lambda (,',tmp ,state ,error)
|
|
308 | + (declare (ignorable ,state ,error)
|
|
309 | + (optimize (ext:inhibit-warnings 3)))
|
|
310 | + (let (,@',slotb
|
|
311 | + (,code ',code)
|
|
312 | + ,@(loop for var in vars collect `(,var (gensym))))
|
|
313 | + `(let ((,',code (the lisp:codepoint ,,',tmp)))
|
|
314 | + (declare (ignorable ,',code))
|
|
315 | + ,,body)))))
|
|
286 | 316 | (%intern-ef (make-external-format ,name
|
287 | 317 | ,(if base
|
288 | 318 | `(ef-efx (find-external-format ,(ef-name base)))
|
... | ... | @@ -291,7 +321,8 @@ |
291 | 321 | :flush-state ,flush-state
|
292 | 322 | :copy-state ,copy-state
|
293 | 323 | :cache (make-array +ef-max+
|
294 | - :initial-element nil)
|
|
324 | + :initial-element nil)
|
|
325 | + :octet-count ,octet-count
|
|
295 | 326 | :min ,(min min max)
|
296 | 327 | :max ,(max min max)))
|
297 | 328 | nil
|
... | ... | @@ -688,7 +719,20 @@ character and illegal outputs are replaced by a question mark.") |
688 | 719 | (intl:gettext "Cannot output codepoint #x~X to ISO8859-1 stream")
|
689 | 720 | ,code 1))
|
690 | 721 | #x3F)
|
691 | - ,code))))
|
|
722 | + ,code)))
|
|
723 | + ()
|
|
724 | + ()
|
|
725 | + (octet-count (code state error)
|
|
726 | + `(if (> ,code 255)
|
|
727 | + (if ,error
|
|
728 | + (locally
|
|
729 | + ;; No warnings about fdefinition
|
|
730 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
731 | + (funcall ,error
|
|
732 | + (intl:gettext "Cannot output codepoint #x~X to ISO8859-1 stream")
|
|
733 | + ,code 1))
|
|
734 | + 1)
|
|
735 | + 1)))
|
|
692 | 736 | |
693 | 737 | ;;; OCTETS-TO-CODEPOINT, CODEPOINT-TO-OCTETS -- Semi-Public
|
694 | 738 | ;;;
|
... | ... | @@ -709,6 +753,10 @@ character and illegal outputs are replaced by a question mark.") |
709 | 753 | (let ((ef (find-external-format external-format)))
|
710 | 754 | (funcall (ef-code-to-octets ef) code state output error)))
|
711 | 755 | |
756 | +(defmacro count-codepoint-octets (external-format code state &optional error)
|
|
757 | + (let ((ef (find-external-format external-format)))
|
|
758 | + (funcall (ef-octet-count ef) code state error)))
|
|
759 | + |
|
712 | 760 | |
713 | 761 | |
714 | 762 | (defvar *ef-base* +ef-max+)
|
... | ... | @@ -878,6 +926,42 @@ character and illegal outputs are replaced by a question mark.") |
878 | 926 | (when f
|
879 | 927 | (funcall f state))))
|
880 | 928 | |
929 | +(defmacro octet-count (external-format char state &optional error)
|
|
930 | + (let ((nchar (gensym))
|
|
931 | + (nstate (gensym))
|
|
932 | + (count-it (gensym))
|
|
933 | + (ch (gensym)))
|
|
934 | + `(let ((,nchar ,char)
|
|
935 | + (,nstate ,state))
|
|
936 | + (when (null ,nstate) (setq ,nstate (setf ,state (cons nil nil))))
|
|
937 | + (if (lisp::surrogatep (char-code ,nchar) :high)
|
|
938 | + (setf (car ,nstate) ,nchar)
|
|
939 | + (flet ((,count-it (,ch)
|
|
940 | + (count-codepoint-octets ,external-format ,ch (cdr ,nstate) ,error)))
|
|
941 | + (if (car ,nstate)
|
|
942 | + (prog1
|
|
943 | + (,count-it (if (lisp::surrogatep (char-code ,nchar) :low)
|
|
944 | + (surrogates-to-codepoint (car ,nstate) ,nchar)
|
|
945 | + (if ,error
|
|
946 | + (locally
|
|
947 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
948 | + (funcall ,error
|
|
949 | + (intl:gettext "Cannot convert invalide surrogate #~x~X to character")
|
|
950 | + ,nchar))
|
|
951 | + +replacement-character-code+)))
|
|
952 | + (setf (car ,nstate) nil))
|
|
953 | + ;; A lone trailing (low surrogate gets replaced with
|
|
954 | + ;; the replacement character.
|
|
955 | + (,count-it (if (lisp::surrogatep (char-code ,nchar) :low)
|
|
956 | + (if ,error
|
|
957 | + (locally
|
|
958 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
959 | + (funcall ,error
|
|
960 | + (intl:gettext "Cannot convert lone trailing surrogate #x~X to character")
|
|
961 | + ,nchar))
|
|
962 | + +replacement-character-code+)
|
|
963 | + (char-code ,nchar)))))))))
|
|
964 | + |
|
881 | 965 | (def-ef-macro ef-string-to-octets (extfmt lisp::lisp +ef-max+ +ef-so+)
|
882 | 966 | `(lambda (string start end buffer buffer-start buffer-end error bufferp
|
883 | 967 | &aux (ptr buffer-start) (state nil) (last-octet buffer-start))
|
... | ... | @@ -1071,6 +1155,31 @@ character and illegal outputs are replaced by a question mark.") |
1071 | 1155 | (values (if stringp string (lisp::shrink-vector string pos)) (- pos s-start) last-octet new-state))))
|
1072 | 1156 | |
1073 | 1157 | |
1158 | +(def-ef-macro ef-string-octet-count (extfmt lisp::lisp +ef-max+ +ef-oc+)
|
|
1159 | + `(lambda (string start end error &aux (total 0) (state nil))
|
|
1160 | + (dotimes (i (- end start) total)
|
|
1161 | + (incf total
|
|
1162 | + (octet-count ,extfmt (schar string (+ start i)) state error)))))
|
|
1163 | + |
|
1164 | +(defun string-octet-count (string &key (start 0) end (external-format :default) error)
|
|
1165 | + "Compute the number of octets needed to convert String using the
|
|
1166 | + specified External-format. The string is bound by Start (defaulting
|
|
1167 | + to 0) and End (defaulting to the end of the string)."
|
|
1168 | + (let ((composing-format-p
|
|
1169 | + ;; Determine is the external format is a composing format
|
|
1170 | + ;; which we determine by seeing that the name of the format
|
|
1171 | + ;; is a cons. Probably not the best way.
|
|
1172 | + (consp (ef-name (find-external-format external-format)))))
|
|
1173 | + ;; We currently don't know how to get just the number of octets
|
|
1174 | + ;; when a composing external format is used. As a workaround, use
|
|
1175 | + ;; STRING-TO-OCTETS to find the number of octets.
|
|
1176 | + (if composing-format-p
|
|
1177 | + (nth-value 1
|
|
1178 | + (string-to-octets string :start start :end end
|
|
1179 | + :external-format external-format))
|
|
1180 | + (lisp::with-array-data ((string string) (start start) (end end))
|
|
1181 | + (funcall (ef-string-octet-count external-format)
|
|
1182 | + string start end error)))))
|
|
1074 | 1183 | |
1075 | 1184 | (def-ef-macro ef-encode (extfmt lisp::lisp +ef-max+ +ef-en+)
|
1076 | 1185 | `(lambda (string start end result error &aux (ptr 0) (state nil))
|
... | ... | @@ -1186,10 +1295,11 @@ character and illegal outputs are replaced by a question mark.") |
1186 | 1295 | (#.+ef-so+ (%ef-string-to-octets ef))
|
1187 | 1296 | (#.+ef-en+ (%ef-encode ef))
|
1188 | 1297 | (#.+ef-de+ (%ef-decode ef))
|
1189 | - (#.+ef-osc+ (%ef-octets-to-string-counted ef))))
|
|
1298 | + (#.+ef-osc+ (%ef-octets-to-string-counted ef))
|
|
1299 | + (#.+ef-oc+ (%ef-octet-count ef))))
|
|
1190 | 1300 | `(setf (aref (ef-cache (find-external-format ,(ef-name ef))) ,slot)
|
1191 | 1301 | ,(subst (ef-name ef) ef
|
1192 | - (function-lambda-expression (aref (ef-cache ef) slot))))))
|
|
1302 | + (function-lambda-expression (aref (ef-cache ef) slot)))))))
|
|
1193 | 1303 | |
1194 | 1304 | ;;; Builtin external formats.
|
1195 | 1305 | |
... | ... | @@ -1307,7 +1417,17 @@ replacement character.") |
1307 | 1417 | ((< ,code #x800) (utf8 ,code 1))
|
1308 | 1418 | ((< ,code #x10000) (utf8 ,code 2))
|
1309 | 1419 | ((< ,code #x110000) (utf8 ,code 3))
|
1310 | - (t (error "How did this happen? Codepoint U+~X is illegal" ,code))))))
|
|
1420 | + (t (error "How did this happen? Codepoint U+~X is illegal" ,code)))))
|
|
1421 | + ()
|
|
1422 | + ()
|
|
1423 | + (octet-count (code state error)
|
|
1424 | + `(locally
|
|
1425 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
1426 | + (cond ((< ,code #x80) 1)
|
|
1427 | + ((< ,code #x800) 2)
|
|
1428 | + ((< ,code #x10000) 3)
|
|
1429 | + ((< ,code #x110000) 4)
|
|
1430 | + (t (error "How did this happen? Codepoint U+~X is illegal" ,code))))))
|
|
1311 | 1431 | |
1312 | 1432 | (define-external-format :ascii (:size 1 :documentation
|
1313 | 1433 | "US ASCII 7-bit encoding. Illegal input sequences are replaced with
|
... | ... | @@ -1333,4 +1453,14 @@ replaced with a question mark.") |
1333 | 1453 | (declare (optimize (ext:inhibit-warnings 3)))
|
1334 | 1454 | (funcall ,error "Cannot output codepoint #x~X to ASCII stream" ,code))
|
1335 | 1455 | #x3F)
|
1336 | - ,code)))) |
|
1456 | + ,code)))
|
|
1457 | + ()
|
|
1458 | + ()
|
|
1459 | + (octet-count (code state error)
|
|
1460 | + `(if (> ,code #x7f)
|
|
1461 | + (if ,error
|
|
1462 | + (locally
|
|
1463 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
1464 | + (funcall ,error "Cannot output codepoint #x~X to ASCII stream" ,code))
|
|
1465 | + 1)
|
|
1466 | + 1))) |
... | ... | @@ -2873,7 +2873,10 @@ |
2873 | 2873 | (int-syscall ("fork")))
|
2874 | 2874 | |
2875 | 2875 | (defun unix-setlocale ()
|
2876 | - _N"Call setlocale(3c) with fixed args. Returns 0 on success."
|
|
2876 | + _N"Set all the categories of the locale according to the values of
|
|
2877 | + the environment variables by calling setlocale(LC_ALL, \"\").
|
|
2878 | + |
|
2879 | + Returns 0 on success and -1 if setlocale failed."
|
|
2877 | 2880 | (alien:alien-funcall
|
2878 | 2881 | (alien:extern-alien "os_setlocale"
|
2879 | 2882 | (function c-call:int))))
|
... | ... | @@ -2900,3 +2903,32 @@ |
2900 | 2903 | (extern-alien "os_get_locale_codeset"
|
2901 | 2904 | (function (* char))))
|
2902 | 2905 | c-string))
|
2906 | + |
|
2907 | +(defun unix-mkstemp (template)
|
|
2908 | + _N"Generates a unique temporary file name from TEMPLATE, and creates
|
|
2909 | + and opens the file. On success, the corresponding file descriptor
|
|
2910 | + and name of the file is returned.
|
|
2911 | + |
|
2912 | + The last six characters of the template must be \"XXXXXX\"."
|
|
2913 | + ;; Hope this buffer is large enough!
|
|
2914 | + (let ((octets (%name->file template)))
|
|
2915 | + (syscall ("mkstemp" c-call:c-string)
|
|
2916 | + (values result
|
|
2917 | + ;; Convert the file name back to a Lisp string.
|
|
2918 | + (%file->name octets))
|
|
2919 | + octets)))
|
|
2920 | + |
|
2921 | +(defun unix-mkdtemp (template)
|
|
2922 | + _N"Generate a uniquely named temporary directory from Template,
|
|
2923 | + which must have \"XXXXXX\" as the last six characters. The
|
|
2924 | + directory is created with permissions 0700. The name of the
|
|
2925 | + directory is returned."
|
|
2926 | + (let* ((octets (%name->file template))
|
|
2927 | + (result (alien-funcall
|
|
2928 | + (extern-alien "mkdtemp"
|
|
2929 | + (function (* char)
|
|
2930 | + c-call:c-string))
|
|
2931 | + octets)))
|
|
2932 | + (if (null-alien result)
|
|
2933 | + (values nil (unix-errno))
|
|
2934 | + (%file->name octets)))) |
... | ... | @@ -30,6 +30,7 @@ public domain. |
30 | 30 | * ANSI compliance fixes:
|
31 | 31 | * Bug fixes:
|
32 | 32 | * Gitlab tickets:
|
33 | + * ~~#135~~ `(unix-namestring ".")` returns "" instead of "."
|
|
33 | 34 | * ~~#154~~ piglatin translation does not work anymore
|
34 | 35 | * ~~#171~~ Readably print `(make-pathname :name :unspecfic)`
|
35 | 36 | * ~~#180~~ Move `get-page-size` to C
|
... | ... | @@ -52,6 +53,7 @@ public domain. |
52 | 53 | available for Hemlock
|
53 | 54 | * ~~#261~~ Remove `get-system-info` from "bsd-os.lisp"
|
54 | 55 | * ~~#268~~ Can't clone ansi-test repo on Mac OS CI box
|
56 | + * ~~#262~~ [arch_skip_inst invalid code -55]
|
|
55 | 57 | * ~~#265~~ CI for mac os is broken
|
56 | 58 | * ~~#266~~ Support "~user" in namestrings
|
57 | 59 | * ~~#269~~ Add function to get user's home directory
|
... | ... | @@ -77,17 +79,42 @@ public domain. |
77 | 79 | * ~~#299~~ Enable xoroshiro assembly routine
|
78 | 80 | * ~~#303~~ Variable `*assert-not-standard-readtable*` defined but
|
79 | 81 | not used.
|
82 | + * ~~#309~~ obj_run_linker does unnecessary allocations
|
|
80 | 83 | * ~~#312~~ Compiler error building motif server on Fedora 40
|
81 | 84 | * ~~#314~~ tanh incorrect for large args
|
82 | 85 | * ~~#316~~ Support roundtrip character casing
|
83 | 86 | * ~~#320~~ Motif variant not defaulted for `x86_linux_clang` config
|
84 | 87 | * ~~#321~~ Rename Motif Config.x86 to Config.linux
|
85 | 88 | * ~~#323~~ Make string casing functions compliant
|
89 | + * ~~#327~~ Fix up weird CLRLF and LF line terminators in the same file
|
|
86 | 90 | * ~~#329~~ Fix compiler warnings in os.lisp
|
87 | 91 | * ~~#330~~ Fix typos in unicode.lisp
|
88 | 92 | * ~~#333~~ `load` doesn't accept generalized boolean for
|
89 | 93 | `:if-does-not-exist` arg
|
94 | + * ~~#338~~ Solaris/x86 build
|
|
95 | + * ~~#336~~ Clean up some compiler notes
|
|
96 | + * ~~#337~~ Cross-compile from x86 (linux) to x86 fails
|
|
97 | + * ~~#339~~ Solaris/x86 `nl_langinfo` returns "646"
|
|
98 | + * ~~#340~~ Use `+ascii-limit+` instead of `#x7f` in srctran.lisp
|
|
99 | + for consistency
|
|
100 | + * ~~#341~~ Update version feature in cross-compile script
|
|
101 | + * ~~#342~~ Add CI job to run gcc static analyer
|
|
102 | + * ~~#348~~ Solaris/x86: u_int64_t vs uint64_t
|
|
103 | + * ~~#347~~ Solaris/x86: Update cross-compile script
|
|
104 | + * ~~#350~~ Export warnings on Solaris
|
|
105 | + * ~~#351~~ Solaris does not recognize `-E` option for grep
|
|
106 | + * ~~#352~~ Always use bzip2 compression for tarballs
|
|
107 | + * ~~#353~~ Automatically use gtar on Solaris when making a distribution
|
|
108 | + * ~~#354~~ Check that executables can be created in CI
|
|
109 | + * ~~#356~~ Return value from `vm::x87-floating-point-modes` should
|
|
110 | + have status word in low part of result
|
|
111 | + * ~~#357~~ Solaris needs limits.h to get `PATH_MAX` in elf.c
|
|
112 | + * ~~#360~~ Adding site-init file
|
|
90 | 113 | * ~~#361~~ Add herald item to mention where to report issues
|
114 | + * ~~#362~~ Simplify "library:" search-list
|
|
115 | + * ~~#364~~ Add interface to `mkdtemp` and `mkstemp`
|
|
116 | + * ~~#367~~ Add stream:string-count-octets to count octets in a string
|
|
117 | + * ~~#369~~ Improve docstring for `unix::unix-setlocale`
|
|
91 | 118 | * Other changes:
|
92 | 119 | * Improvements to the PCL implementation of CLOS:
|
93 | 120 | * Changes to building procedure:
|
... | ... | @@ -1418,7 +1418,11 @@ msgid "" |
1418 | 1418 | msgstr ""
|
1419 | 1419 | |
1420 | 1420 | #: src/code/unix.lisp
|
1421 | -msgid "Call setlocale(3c) with fixed args. Returns 0 on success."
|
|
1421 | +msgid ""
|
|
1422 | +"Set all the categories of the locale according to the values of\n"
|
|
1423 | +" the environment variables by calling setlocale(LC_ALL, \"\").\n"
|
|
1424 | +"\n"
|
|
1425 | +" Returns 0 on success and -1 if setlocale failed."
|
|
1422 | 1426 | msgstr ""
|
1423 | 1427 | |
1424 | 1428 | #: src/code/unix.lisp
|
... | ... | @@ -1432,3 +1436,20 @@ msgstr "" |
1432 | 1436 | msgid "Get the codeset from the locale"
|
1433 | 1437 | msgstr ""
|
1434 | 1438 | |
1439 | +#: src/code/unix.lisp
|
|
1440 | +msgid ""
|
|
1441 | +"Generates a unique temporary file name from TEMPLATE, and creates\n"
|
|
1442 | +" and opens the file. On success, the corresponding file descriptor\n"
|
|
1443 | +" and name of the file is returned.\n"
|
|
1444 | +"\n"
|
|
1445 | +" The last six characters of the template must be \"XXXXXX\"."
|
|
1446 | +msgstr ""
|
|
1447 | + |
|
1448 | +#: src/code/unix.lisp
|
|
1449 | +msgid ""
|
|
1450 | +"Generate a uniquely named temporary directory from Template,\n"
|
|
1451 | +" which must have \"XXXXXX\" as the last six characters. The\n"
|
|
1452 | +" directory is created with permissions 0700. The name of the\n"
|
|
1453 | +" directory is returned."
|
|
1454 | +msgstr ""
|
|
1455 | + |
... | ... | @@ -9300,6 +9300,13 @@ msgid "" |
9300 | 9300 | " external format."
|
9301 | 9301 | msgstr ""
|
9302 | 9302 | |
9303 | +#: src/code/extfmts.lisp
|
|
9304 | +msgid ""
|
|
9305 | +"Compute the number of octets needed to convert String using the\n"
|
|
9306 | +" specified External-format. The string is bound by Start (defaulting\n"
|
|
9307 | +" to 0) and End (defaulting to the end of the string)."
|
|
9308 | +msgstr ""
|
|
9309 | + |
|
9303 | 9310 | #: src/code/extfmts.lisp
|
9304 | 9311 | msgid ""
|
9305 | 9312 | "Encode the given String using External-Format and return a new\n"
|
... | ... | @@ -41,7 +41,7 @@ OBJS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(patsubst %.s,%.o,$(SRCS)))) |
41 | 41 | ### Don't look in RCS for the files, because we might not want the latest.
|
42 | 42 | %: RCS/%,v
|
43 | 43 | |
44 | -DEFAULT_VERSION = $(shell ../../bin/cmucl-version.sh)
|
|
44 | +#DEFAULT_VERSION = $(shell ../../bin/cmucl-version.sh)
|
|
45 | 45 | |
46 | 46 | lisp.nm: lisp lisp.a
|
47 | 47 | echo 'Map file for lisp version ' `cat version` > ,lisp.nm
|
... | ... | @@ -53,8 +53,11 @@ version.o : version.c version |
53 | 53 | mv ,version version
|
54 | 54 | $(CC) ${CFLAGS} $(CPPFLAGS) -DVERSION=`cat version` -c $<
|
55 | 55 | |
56 | -lisp.o : lisp.c
|
|
57 | - $(CC) ${CFLAGS} $(CPPFLAGS) -DCMUCL_VERSION="\"${DEFAULT_VERSION}\"" -c $<
|
|
56 | +lisp.o : lisp.c cmucl-version.h
|
|
57 | + $(CC) ${CFLAGS} $(CPPFLAGS) -c $<
|
|
58 | + |
|
59 | +cmucl-version.h:
|
|
60 | + ../../bin/cmucl-version.sh -f > cmucl-version.h
|
|
58 | 61 | |
59 | 62 | lisp: ${OBJS} version.o
|
60 | 63 | $(CC) -g ${OS_LINK_FLAGS} -o ,lisp $^ ${OS_LIBS} -lm
|
... | ... | @@ -126,7 +129,7 @@ translations: |
126 | 129 | done; done
|
127 | 130 | |
128 | 131 | # Always build lisp.o so that the embedded version is updated.
|
129 | -.PHONY : translations lisp.o
|
|
132 | +.PHONY : translations cmucl-version.h lisp.o
|
|
130 | 133 | |
131 | 134 | # Like translations, but we don't compute the diff. We just overwrite
|
132 | 135 | # the po files in the repository so that we can tell if the
|
... | ... | @@ -42,8 +42,10 @@ |
42 | 42 | #include <time.h>
|
43 | 43 | #endif
|
44 | 44 | |
45 | +#include "cmucl-version.h"
|
|
46 | + |
|
45 | 47 | #ifndef CMUCL_VERSION
|
46 | -#define CMUCL_VERSION "alpha"
|
|
48 | +#error CMUCL_VERSION not defined!
|
|
47 | 49 | #endif
|
48 | 50 | |
49 | 51 |
|
... | ... | @@ -33,5 +33,15 @@ replaced with a question mark.") |
33 | 33 | (declare (optimize (ext:inhibit-warnings 3)))
|
34 | 34 | (funcall ,error "Cannot output codepoint #x~X to ASCII stream" ,code))
|
35 | 35 | #x3F)
|
36 | - ,code))))
|
|
36 | + ,code)))
|
|
37 | + ()
|
|
38 | + ()
|
|
39 | + (octet-count (code state error)
|
|
40 | + `(if (> ,code #x7f)
|
|
41 | + (if ,error
|
|
42 | + (locally
|
|
43 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
44 | + (funcall ,error "Cannot output codepoint #x~X to ASCII stream" ,code))
|
|
45 | + 1)
|
|
46 | + 1)))
|
|
37 | 47 |
... | ... | @@ -1007,4 +1007,16 @@ character and illegal outputs are replaced by a question mark.") |
1007 | 1007 | (t
|
1008 | 1008 | (if ,error
|
1009 | 1009 | (funcall ,error "Cannot output codepoint #x~X to EUC-KR format." ,code)
|
1010 | - (,output #X3f)))))))) |
|
1010 | + (,output #X3f)))))))
|
|
1011 | + ()
|
|
1012 | + ()
|
|
1013 | + (octet-count (code state error present)
|
|
1014 | + `(if (<= ,code #x7f)
|
|
1015 | + 1
|
|
1016 | + (let ((,present (get-inverse ,itable ,code)))
|
|
1017 | + (cond (,present
|
|
1018 | + 2)
|
|
1019 | + (t
|
|
1020 | + (if ,error
|
|
1021 | + (funcall ,error "Cannot output codepoint #x~X to EUC-KR format." ,code)
|
|
1022 | + 1))))))) |
... | ... | @@ -31,4 +31,17 @@ character and illegal outputs are replaced by a question mark.") |
31 | 31 | (funcall ,error "Cannot output codepoint #x~X to ISO8859-1 stream"
|
32 | 32 | ,code 1))
|
33 | 33 | #x3F)
|
34 | - ,code)))) |
|
34 | + ,code)))
|
|
35 | + ()
|
|
36 | + ()
|
|
37 | + (octet-count (code state error)
|
|
38 | + `(if (> ,code 255)
|
|
39 | + (if ,error
|
|
40 | + (locally
|
|
41 | + ;; No warnings about fdefinition
|
|
42 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
43 | + (funcall ,error
|
|
44 | + (intl:gettext "Cannot output codepoint #x~X to ISO8859-1 stream")
|
|
45 | + ,code 1))
|
|
46 | + 1)
|
|
47 | + 1))) |
... | ... | @@ -47,4 +47,19 @@ character and illegal outputs are replaced by a question mark.") |
47 | 47 | (declare (optimize (ext:inhibit-warnings 3)))
|
48 | 48 | (funcall ,error "Cannot output codepoint #x~X to ISO8859-2 stream"
|
49 | 49 | ,code))
|
50 | - #x3F))))))) |
|
50 | + #x3F))))))
|
|
51 | + ()
|
|
52 | + ()
|
|
53 | + (octet-count (code state error present)
|
|
54 | + `(if (< ,code 160)
|
|
55 | + 1
|
|
56 | + (let ((,present (get-inverse ,itable ,code)))
|
|
57 | + (if ,present
|
|
58 | + 1
|
|
59 | + (if ,error
|
|
60 | + (locally
|
|
61 | + ;; No warnings about fdefinition
|
|
62 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
63 | + (funcall ,error "Cannot output codepoint #x~X to ISO8859-2 stream"
|
|
64 | + ,code))
|
|
65 | + 1)))))) |
... | ... | @@ -49,4 +49,19 @@ character and illegal outputs are replaced by a question mark.") |
49 | 49 | (declare (optimize (ext:inhibit-warnings 3)))
|
50 | 50 | (funcall ,error "Cannot output codepoint #x~X to MAC-ROMAN stream"
|
51 | 51 | ,code))
|
52 | - #x3F))))))) |
|
52 | + #x3F))))))
|
|
53 | + ()
|
|
54 | + ()
|
|
55 | + (octet-count (code state error present)
|
|
56 | + `(if (< ,code 128)
|
|
57 | + 1
|
|
58 | + (let ((,present (get-inverse ,itable ,code)))
|
|
59 | + (if ,present
|
|
60 | + 1
|
|
61 | + (if ,error
|
|
62 | + (locally
|
|
63 | + ;; No warnings about fdefinition
|
|
64 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
65 | + (funcall ,error "Cannot output codepoint #x~X to MAC-ROMAN stream"
|
|
66 | + ,code))
|
|
67 | + 1)))))) |
... | ... | @@ -110,4 +110,12 @@ Unicode replacement character.") |
110 | 110 | (copy-state (state)
|
111 | 111 | ;; The state is either NIL or a codepoint, so nothing really
|
112 | 112 | ;; special is needed to copy it.
|
113 | - `(progn ,state))) |
|
113 | + `(progn ,state))
|
|
114 | + (octet-count (code state error)
|
|
115 | + `(cond ((< ,code #x10000)
|
|
116 | + 2)
|
|
117 | + ((< ,code #x110000)
|
|
118 | + 4)
|
|
119 | + (t
|
|
120 | + ;; Replacement character is 2 octets
|
|
121 | + 2)))) |
... | ... | @@ -111,4 +111,12 @@ Unicode replacement character.") |
111 | 111 | (copy-state (state)
|
112 | 112 | ;; The state is either NIL or a codepoint, so nothing really
|
113 | 113 | ;; special is needed.
|
114 | - `(progn ,state))) |
|
114 | + `(progn ,state))
|
|
115 | + (octet-count (code state error)
|
|
116 | + `(cond ((< ,code #x10000)
|
|
117 | + 2)
|
|
118 | + ((< ,code #x110000)
|
|
119 | + 4)
|
|
120 | + (t
|
|
121 | + ;; Replacement character is 2 octets
|
|
122 | + 2)))) |
... | ... | @@ -156,4 +156,18 @@ Unicode replacement character.") |
156 | 156 | ,c))))))
|
157 | 157 | (copy-state (state)
|
158 | 158 | ;; The state is list. Copy it
|
159 | - `(copy-list ,state))) |
|
159 | + `(copy-list ,state))
|
|
160 | + (octet-count (code state error)
|
|
161 | + `(let ((bom-count 0))
|
|
162 | + (unless ,state
|
|
163 | + ;; Output BOM
|
|
164 | + (setf bom-count 2)
|
|
165 | + (setf ,state t))
|
|
166 | + (+ bom-count
|
|
167 | + (cond ((< ,code #x10000)
|
|
168 | + 2)
|
|
169 | + ((< ,code #x110000)
|
|
170 | + 4)
|
|
171 | + (t
|
|
172 | + ;; Replacement character is 2 octets
|
|
173 | + 2)))))) |
... | ... | @@ -61,4 +61,18 @@ Unicode replacement character.") |
61 | 61 | ,code))
|
62 | 62 | +replacement-character-code+)))
|
63 | 63 | (t
|
64 | - (out ,code)))))) |
|
64 | + (out ,code)))))
|
|
65 | + ()
|
|
66 | + ()
|
|
67 | + (octet-count (code state error)
|
|
68 | + `(cond ((lisp::surrogatep ,code)
|
|
69 | + (if ,error
|
|
70 | + (locally
|
|
71 | + ;; No warnings about fdefinition
|
|
72 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
73 | + (funcall ,error "Surrogate code #x~4,'0X is illegal for UTF32 output"
|
|
74 | + ,code))
|
|
75 | + ;; Replacement character is 2 octets
|
|
76 | + 2))
|
|
77 | + (t
|
|
78 | + 4)))) |
... | ... | @@ -62,4 +62,18 @@ Unicode replacement character.") |
62 | 62 | ,code))
|
63 | 63 | +replacement-character-code+)))
|
64 | 64 | (t
|
65 | - (out ,code)))))) |
|
65 | + (out ,code)))))
|
|
66 | + ()
|
|
67 | + ()
|
|
68 | + (octet-count (code state error)
|
|
69 | + `(cond ((lisp::surrogatep ,code)
|
|
70 | + (if ,error
|
|
71 | + (locally
|
|
72 | + ;; No warnings about fdefinition
|
|
73 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
74 | + (funcall ,error "Surrogate code #x~4,'0X is illegal for UTF32 output"
|
|
75 | + ,code))
|
|
76 | + ;; Replacement character is 2 octets
|
|
77 | + 2))
|
|
78 | + (t
|
|
79 | + 4)))) |
... | ... | @@ -114,4 +114,20 @@ Unicode replacement character.") |
114 | 114 | nil
|
115 | 115 | (copy-state (state)
|
116 | 116 | ;; The state is either NIL or T, so we can just return that.
|
117 | - `(progn ,state))) |
|
117 | + `(progn ,state))
|
|
118 | + (octet-count (code state error)
|
|
119 | + `(let ((bom-count 0))
|
|
120 | + (unless ,state
|
|
121 | + (setf bom-count 4)
|
|
122 | + (setf ,state t))
|
|
123 | + (cond ((lisp::surrogatep ,code)
|
|
124 | + (if ,error
|
|
125 | + (locally
|
|
126 | + ;; No warnings about fdefinition
|
|
127 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
128 | + (funcall ,error "Surrogate code #x~4,'0X is illegal for UTF32 output"
|
|
129 | + ,code))
|
|
130 | + ;; Replacement character is 2 octets
|
|
131 | + (+ 2 bom-count)))
|
|
132 | + (t
|
|
133 | + (+ 4 bom-count)))))) |
... | ... | @@ -127,4 +127,14 @@ replacement character.") |
127 | 127 | ((< ,code #x800) (utf8 ,code 1))
|
128 | 128 | ((< ,code #x10000) (utf8 ,code 2))
|
129 | 129 | ((< ,code #x110000) (utf8 ,code 3))
|
130 | - (t (error "How did this happen? Codepoint U+~X is illegal" ,code)))))) |
|
130 | + (t (error "How did this happen? Codepoint U+~X is illegal" ,code)))))
|
|
131 | + ()
|
|
132 | + ()
|
|
133 | + (octet-count (code state error)
|
|
134 | + `(locally
|
|
135 | + (declare (optimize (ext:inhibit-warnings 3)))
|
|
136 | + (cond ((< ,code #x80) 1)
|
|
137 | + ((< ,code #x800) 2)
|
|
138 | + ((< ,code #x10000) 3)
|
|
139 | + ((< ,code #x110000) 4)
|
|
140 | + (t (error "How did this happen? Codepoint U+~X is illegal" ,code)))))) |
1 | +;;; Tests for external formats
|
|
2 | + |
|
3 | +(defpackage :external-formats-tests
|
|
4 | + (:use :cl :lisp-unit))
|
|
5 | + |
|
6 | +(in-package "EXTERNAL-FORMATS-TESTS")
|
|
7 | + |
|
8 | +(defparameter *test-iso8859-1*
|
|
9 | + (let ((rs (kernel::make-random-object :state (kernel::init-random-state 27182828))))
|
|
10 | + (lisp::codepoints-string
|
|
11 | + (loop for k from 0 below 1000
|
|
12 | + collect (random 256 rs))))
|
|
13 | + "Random test string with ISO8859-1 characters")
|
|
14 | + |
|
15 | +(defparameter *test-unicode*
|
|
16 | + (let ((rs (kernel::make-random-object :state (kernel::init-random-state 27182828))))
|
|
17 | + (lisp::codepoints-string
|
|
18 | + (loop for k from 0 below 1000
|
|
19 | + collect (random 20000 rs))))
|
|
20 | + "Random test string with codepoints below 20000")
|
|
21 | + |
|
22 | + |
|
23 | + |
|
24 | +(defmacro test-octet-count (string format)
|
|
25 | + "Test that STRING-OCTET-COUNT returns the correct number of octets"
|
|
26 | + ;; We expect STRING-OCTET-COUNT returns the same number of octets
|
|
27 | + ;; that are produced by STRING-TO-OCTETS.
|
|
28 | + `(multiple-value-bind (octets count converted)
|
|
29 | + (stream:string-to-octets ,string :external-format ,format)
|
|
30 | + ;; While we're at it, make sure that the length of the octet
|
|
31 | + ;; buffer matches returned count. And make sure we converted all
|
|
32 | + ;; the characters in the string.
|
|
33 | + (assert-equal (length octets) count)
|
|
34 | + (assert-equal (length ,string) converted)
|
|
35 | + ;; Finally, make sure that STRING-OCTET-COUNT returns the same
|
|
36 | + ;; number of octets from STRING-TO-OCTETS.
|
|
37 | + (assert-equal (length octets)
|
|
38 | + (stream::string-octet-count ,string :external-format ,format))))
|
|
39 | + |
|
40 | +(define-test octet-count.iso8859-1
|
|
41 | + (:tag :octet-count)
|
|
42 | + (test-octet-count *test-iso8859-1* :iso8859-1))
|
|
43 | + |
|
44 | +(define-test octet-count.ascii
|
|
45 | + (:tag :octet-count)
|
|
46 | + (test-octet-count *test-iso8859-1* :ascii))
|
|
47 | + |
|
48 | +(define-test octet-count.ascii.error
|
|
49 | + (:tag :octet-count)
|
|
50 | + (assert-error 'simple-error
|
|
51 | + (stream::string-octet-count *test-iso8859-1*
|
|
52 | + :external-format :ascii
|
|
53 | + :error 'error)))
|
|
54 | + |
|
55 | +(define-test octet-count.utf-8
|
|
56 | + (:tag :octet-count)
|
|
57 | + (test-octet-count *test-unicode* :utf-8))
|
|
58 | + |
|
59 | +(define-test octet-count.utf-16
|
|
60 | + (:tag :octet-count)
|
|
61 | + (test-octet-count *test-unicode* :utf-16))
|
|
62 | + |
|
63 | +(define-test octet-count.utf-16-be
|
|
64 | + (:tag :octet-count)
|
|
65 | + (test-octet-count *test-unicode* :utf-16-be))
|
|
66 | + |
|
67 | +(define-test octet-count.utf-16-le
|
|
68 | + (:tag :octet-count)
|
|
69 | + (test-octet-count *test-unicode* :utf-16-le))
|
|
70 | + |
|
71 | +(define-test octet-count.utf-32
|
|
72 | + (:tag :octet-count)
|
|
73 | + (test-octet-count *test-unicode* :utf-32))
|
|
74 | + |
|
75 | +(define-test octet-count.utf-32-le
|
|
76 | + (:tag :octet-count)
|
|
77 | + (test-octet-count *test-unicode* :utf-32-le))
|
|
78 | + |
|
79 | +(define-test octet-count.utf-32-le
|
|
80 | + (:tag :octet-count)
|
|
81 | + (test-octet-count *test-unicode* :utf-32-le))
|
|
82 | + |
|
83 | +(define-test octet-count.euc-kr
|
|
84 | + (:tag :octet-count)
|
|
85 | + (test-octet-count *test-unicode* :euc-kr))
|
|
86 | + |
|
87 | +(define-test octet-count.iso8859-2
|
|
88 | + (:tag :octet-count)
|
|
89 | + (test-octet-count *test-iso8859-1* :iso8859-2))
|
|
90 | + |
|
91 | +(define-test octet-count.iso8859-3
|
|
92 | + (:tag :octet-count)
|
|
93 | + (test-octet-count *test-iso8859-1* :iso8859-3))
|
|
94 | + |
|
95 | +(define-test octet-count.iso8859-4
|
|
96 | + (:tag :octet-count)
|
|
97 | + (test-octet-count *test-iso8859-1* :iso8859-4))
|
|
98 | + |
|
99 | +(define-test octet-count.iso8859-5
|
|
100 | + (:tag :octet-count)
|
|
101 | + (test-octet-count *test-iso8859-1* :iso8859-5))
|
|
102 | + |
|
103 | +(define-test octet-count.iso8859-6
|
|
104 | + (:tag :octet-count)
|
|
105 | + (test-octet-count *test-iso8859-1* :iso8859-6))
|
|
106 | + |
|
107 | +(define-test octet-count.iso8859-7
|
|
108 | + (:tag :octet-count)
|
|
109 | + (test-octet-count *test-iso8859-1* :iso8859-7))
|
|
110 | + |
|
111 | +(define-test octet-count.iso8859-8
|
|
112 | + (:tag :octet-count)
|
|
113 | + (test-octet-count *test-iso8859-1* :iso8859-8))
|
|
114 | + |
|
115 | +(define-test octet-count.iso8859-10
|
|
116 | + (:tag :octet-count)
|
|
117 | + (test-octet-count *test-iso8859-1* :iso8859-10))
|
|
118 | + |
|
119 | +(define-test octet-count.iso8859-13
|
|
120 | + (:tag :octet-count)
|
|
121 | + (test-octet-count *test-iso8859-1* :iso8859-13))
|
|
122 | + |
|
123 | +(define-test octet-count.iso8859-14
|
|
124 | + (:tag :octet-count)
|
|
125 | + (test-octet-count *test-iso8859-1* :iso8859-14))
|
|
126 | + |
|
127 | +(define-test octet-count.iso8859-15
|
|
128 | + (:tag :octet-count)
|
|
129 | + (test-octet-count *test-iso8859-1* :iso8859-15))
|
|
130 | + |
|
131 | +(define-test octet-count.mac-roman
|
|
132 | + (:tag :octet-count)
|
|
133 | + (test-octet-count *test-iso8859-1* :mac-roman))
|
|
134 | +
|
|
135 | + |