Author: hhubner Date: 2007-11-14 00:26:34 -0500 (Wed, 14 Nov 2007) New Revision: 2275
Added: branches/trunk-reorg/thirdparty/cl+ssl/ branches/trunk-reorg/thirdparty/cl+ssl/LICENSE branches/trunk-reorg/thirdparty/cl+ssl/Makefile branches/trunk-reorg/thirdparty/cl+ssl/bio.lisp branches/trunk-reorg/thirdparty/cl+ssl/cl+ssl.asd branches/trunk-reorg/thirdparty/cl+ssl/conditions.lisp branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-all.lisp branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-clisp.lisp branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer.lisp branches/trunk-reorg/thirdparty/cl+ssl/ffi.lisp branches/trunk-reorg/thirdparty/cl+ssl/index.css branches/trunk-reorg/thirdparty/cl+ssl/index.html branches/trunk-reorg/thirdparty/cl+ssl/package.lisp branches/trunk-reorg/thirdparty/cl+ssl/reload.lisp branches/trunk-reorg/thirdparty/cl+ssl/streams.lisp branches/trunk-reorg/thirdparty/cl+ssl/test.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/CHANGELOG branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/ascii.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/code-pages.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/foo.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/index.html branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/external-format.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/flexi-streams.asd branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/in-memory.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/input.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/iso-8859.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/koi8-r.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/lw-binary-stream.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/output.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/packages.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/specials.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/stream.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/strings.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/README branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/packages.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/test.lisp branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_cr_be.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_cr_le.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_crlf_be.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_crlf_le.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_lf_be.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_lf_le.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_cr_be.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_cr_le.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_crlf_be.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_crlf_le.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_lf_be.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_lf_le.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_cr.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_crlf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_lf.txt branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/util.lisp branches/trunk-reorg/thirdparty/trivial-gray-streams/ branches/trunk-reorg/thirdparty/trivial-gray-streams/COPYING branches/trunk-reorg/thirdparty/trivial-gray-streams/Makefile branches/trunk-reorg/thirdparty/trivial-gray-streams/README branches/trunk-reorg/thirdparty/trivial-gray-streams/mixin.lisp branches/trunk-reorg/thirdparty/trivial-gray-streams/package.lisp branches/trunk-reorg/thirdparty/trivial-gray-streams/trivial-gray-streams.asd branches/trunk-reorg/thirdparty/trivial-https/ branches/trunk-reorg/thirdparty/trivial-https/LICENSE branches/trunk-reorg/thirdparty/trivial-https/README branches/trunk-reorg/thirdparty/trivial-https/trivial-https.asd branches/trunk-reorg/thirdparty/trivial-https/trivial-https.lisp Log: updating
Added: branches/trunk-reorg/thirdparty/cl+ssl/LICENSE =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/LICENSE 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/LICENSE 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,31 @@ +Copyright (C) 2001, 2003 Eric Marsden +Copyright (C) ???? Jochen Schmidt +Copyright (C) 2005 David Lichteblau +Copyright (C) 2007 Pixel // pinterface + +* License first changed by Eric Marsden, Jochen Schmidt, and David Lichteblau + from plain LGPL to Lisp-LGPL in December 2005. + +* License then changed by Eric Marsden, Jochen Schmidt, and David Lichteblau + from Lisp-LGPL to MIT-style in January 2007. + + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE.
Added: branches/trunk-reorg/thirdparty/cl+ssl/Makefile =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/Makefile 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/Makefile 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,3 @@ +.PHONY: clean +clean: + rm -f *.fasl *.x86f *.fas *.ufsl *.lib *.pfsl
Added: branches/trunk-reorg/thirdparty/cl+ssl/bio.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/bio.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/bio.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,136 @@ +;;; Copyright (C) 2005 David Lichteblau +;;; +;;; See LICENSE for details. + +(in-package cl+ssl) + +(defconstant +bio-type-socket+ (logior 5 #x0400 #x0100)) +(defconstant +BIO_FLAGS_READ+ 1) +(defconstant +BIO_FLAGS_WRITE+ 2) +(defconstant +BIO_FLAGS_SHOULD_RETRY+ 8) +(defconstant +BIO_CTRL_FLUSH+ 11) + +(cffi:defcstruct bio-method + (type :int) + (name :pointer) + (bwrite :pointer) + (bread :pointer) + (bputs :pointer) + (bgets :pointer) + (ctrl :pointer) + (create :pointer) + (destroy :pointer) + (callback-ctrl :pointer)) + +(cffi:defcstruct bio + (method :pointer) + (callback :pointer) + (cb-arg :pointer) + (init :int) + (shutdown :int) + (flags :int) + (retry-reason :int) + (num :int) + (ptr :pointer) + (next-bio :pointer) + (prev-bio :pointer) + (references :int) + (num-read :unsigned-long) + (num-write :unsigned-long) + (crypto-ex-data-stack :pointer) + (crypto-ex-data-dummy :int)) + +(defun make-bio-lisp-method () + (let ((m (cffi:foreign-alloc 'bio-method))) + (setf (cffi:foreign-slot-value m 'bio-method 'type) + ;; fixme: this is wrong, but presumably still better than some + ;; random value here. + +bio-type-socket+) + (macrolet ((slot (name) + `(cffi:foreign-slot-value m 'bio-method ,name))) + (setf (slot 'name) (cffi:foreign-string-alloc "lisp")) + (setf (slot 'bwrite) (cffi:callback lisp-write)) + (setf (slot 'bread) (cffi:callback lisp-read)) + (setf (slot 'bputs) (cffi:callback lisp-puts)) + (setf (slot 'bgets) (cffi:null-pointer)) + (setf (slot 'ctrl) (cffi:callback lisp-ctrl)) + (setf (slot 'create) (cffi:callback lisp-create)) + (setf (slot 'destroy) (cffi:callback lisp-destroy)) + (setf (slot 'callback-ctrl) (cffi:null-pointer))) + m)) + +(defun bio-new-lisp () + (bio-new *bio-lisp-method*)) + + +;;; "cargo cult" + +(cffi:defcallback lisp-write :int ((bio :pointer) (buf :pointer) (n :int)) + bio + (dotimes (i n) + (write-byte (cffi:mem-ref buf :unsigned-char i) *socket*)) + (finish-output *socket*) + n) + +(defun clear-retry-flags (bio) + (setf (cffi:foreign-slot-value bio 'bio 'flags) + (logandc2 (cffi:foreign-slot-value bio 'bio 'flags) + (logior +BIO_FLAGS_READ+ + +BIO_FLAGS_WRITE+ + +BIO_FLAGS_SHOULD_RETRY+)))) + +(defun set-retry-read (bio) + (setf (cffi:foreign-slot-value bio 'bio 'flags) + (logior (cffi:foreign-slot-value bio 'bio 'flags) + +BIO_FLAGS_READ+ + +BIO_FLAGS_SHOULD_RETRY+))) + +(cffi:defcallback lisp-read :int ((bio :pointer) (buf :pointer) (n :int)) + bio buf n + (let ((i 0)) + (handler-case + (unless (or (cffi:null-pointer-p buf) (null n)) + (clear-retry-flags bio) + (when (or *blockp* (listen *socket*)) + (setf (cffi:mem-ref buf :unsigned-char i) (read-byte *socket*)) + (incf i)) + (loop + while (and (< i n) + (or (null *partial-read-p*) (listen *socket*))) + do + (setf (cffi:mem-ref buf :unsigned-char i) (read-byte *socket*)) + (incf i)) + #+(or) + (when (zerop i) (set-retry-read bio))) + (end-of-file ())) + i)) + +(cffi:defcallback lisp-puts :int ((bio :pointer) (buf :string)) + bio buf + (error "lisp-puts not implemented")) + +(cffi:defcallback lisp-ctrl :int + ((bio :pointer) (cmd :int) (larg :long) (parg :pointer)) + bio larg parg + (cond + ((eql cmd +BIO_CTRL_FLUSH+) 1) + (t + ;; (warn "lisp-ctrl(~A,~A,~A)" cmd larg parg) + 0))) + +(cffi:defcallback lisp-create :int ((bio :pointer)) + (setf (cffi:foreign-slot-value bio 'bio 'init) 1) + (setf (cffi:foreign-slot-value bio 'bio 'num) 0) + (setf (cffi:foreign-slot-value bio 'bio 'ptr) (cffi:null-pointer)) + (setf (cffi:foreign-slot-value bio 'bio 'flags) 0) + 1) + +(cffi:defcallback lisp-destroy :int ((bio :pointer)) + (cond + ((cffi:null-pointer-p bio) 0) + (t + (setf (cffi:foreign-slot-value bio 'bio 'init) 0) + (setf (cffi:foreign-slot-value bio 'bio 'flags) 0) + 1))) + +(setf *bio-lisp-method* nil) ;force reinit if anything changed here
Added: branches/trunk-reorg/thirdparty/cl+ssl/cl+ssl.asd =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/cl+ssl.asd 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/cl+ssl.asd 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,27 @@ +;;; -*- mode: lisp -*- +;;; +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; Copyright (C) 2007 Pixel // pinterface +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +(defpackage :cl+ssl-system + (:use :cl :asdf)) + +(in-package :cl+ssl-system) + +(defsystem :cl+ssl + :depends-on (:cffi :trivial-gray-streams :flexi-streams) + :serial t + :components + ((:file "package") + (:file "reload") + (:file "conditions") + (:file "ffi") + (:file "ffi-buffer-all") + #-clisp (:file "ffi-buffer") + #+clisp (:file "ffi-buffer-clisp") + (:file "streams") + (:file "bio")))
Added: branches/trunk-reorg/thirdparty/cl+ssl/conditions.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/conditions.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/conditions.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,211 @@ +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +(in-package :cl+ssl) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defconstant +ssl-error-none+ 0) + (defconstant +ssl-error-ssl+ 1) + (defconstant +ssl-error-want-read+ 2) + (defconstant +ssl-error-want-write+ 3) + (defconstant +ssl-error-want-x509-lookup+ 4) + (defconstant +ssl-error-syscall+ 5) + (defconstant +ssl-error-zero-return+ 6) + (defconstant +ssl-error-want-connect+ 7)) + + +;;; Condition hierarchy +;;; +(define-condition ssl-error (error) + ((queue :initform nil :initarg :queue :reader ssl-error-queue))) + +(define-condition ssl-error/handle (ssl-error) + ((ret :initarg :ret + :reader ssl-error-ret) + (handle :initarg :handle + :reader ssl-error-handle)) + (:report (lambda (condition stream) + (format stream "Unspecified error ~A on handle ~A" + (ssl-error-ret condition) + (ssl-error-handle condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +(define-condition ssl-error-initialize (ssl-error) + ((reason :initarg :reason + :reader ssl-error-reason)) + (:report (lambda (condition stream) + (format stream "SSL initialization error: ~A" + (ssl-error-reason condition)) + (write-sequence (ssl-error-queue condition) stream)))) + + +(define-condition ssl-error-want-something (ssl-error/handle) + ()) + +;;;SSL_ERROR_NONE +(define-condition ssl-error-none (ssl-error/handle) + () + (:documentation + "The TLS/SSL I/O operation completed. This result code is returned if and + only if ret > 0.") + (:report (lambda (condition stream) + (format stream "The TLS/SSL operation on handle ~A completed. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_ZERO_RETURN +(define-condition ssl-error-zero-return (ssl-error/handle) + () + (:documentation + "The TLS/SSL connection has been closed. If the protocol version is SSL 3.0 + or TLS 1.0, this result code is returned only if a closure alert has + occurred in the protocol, i.e. if the connection has been closed cleanly. + Note that in this case SSL_ERROR_ZERO_RETURN + does not necessarily indicate that the underlying transport has been + closed.") + (:report (lambda (condition stream) + (format stream "The TLS/SSL connection on handle ~A has been closed. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_WANT_READ +(define-condition ssl-error-want-read (ssl-error-want-something) + () + (:documentation + "The operation did not complete; the same TLS/SSL I/O function should be + called again later. If, by then, the underlying BIO has data available for + reading (if the result code is SSL_ERROR_WANT_READ) or allows writing data + (SSL_ERROR_WANT_WRITE), then some TLS/SSL protocol progress will take place, + i.e. at least part of an TLS/SSL record will be read or written. Note that + the retry may again lead to a SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE + condition. There is no fixed upper limit for the number of iterations that + may be necessary until progress becomes visible at application protocol + level.") + (:report (lambda (condition stream) + (format stream "The TLS/SSL operation on handle ~A did not complete: It wants a READ. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_WANT_WRITE +(define-condition ssl-error-want-write (ssl-error-want-something) + () + (:documentation + "The operation did not complete; the same TLS/SSL I/O function should be + called again later. If, by then, the underlying BIO has data available for + reading (if the result code is SSL_ERROR_WANT_READ) or allows writing data + (SSL_ERROR_WANT_WRITE), then some TLS/SSL protocol progress will take place, + i.e. at least part of an TLS/SSL record will be read or written. Note that + the retry may again lead to a SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE + condition. There is no fixed upper limit for the number of iterations that + may be necessary until progress becomes visible at application protocol + level.") + (:report (lambda (condition stream) + (format stream "The TLS/SSL operation on handle ~A did not complete: It wants a WRITE. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_WANT_CONNECT +(define-condition ssl-error-want-connect (ssl-error-want-something) + () + (:documentation + "The operation did not complete; the same TLS/SSL I/O function should be + called again later. The underlying BIO was not connected yet to the peer + and the call would block in connect()/accept(). The SSL + function should be called again when the connection is established. These + messages can only appear with a BIO_s_connect() or + BIO_s_accept() BIO, respectively. In order to find out, when + the connection has been successfully established, on many platforms + select() or poll() for writing on the socket file + descriptor can be used.") + (:report (lambda (condition stream) + (format stream "The TLS/SSL operation on handle ~A did not complete: It wants a connect first. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_WANT_X509_LOOKUP +(define-condition ssl-error-want-x509-lookup (ssl-error-want-something) + () + (:documentation + "The operation did not complete because an application callback set by + SSL_CTX_set_client_cert_cb() has asked to be called again. The + TLS/SSL I/O function should be called again later. Details depend on the + application.") + (:report (lambda (condition stream) + (format stream "The TLS/SSL operation on handle ~A did not complete: An application callback wants to be called again. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_SYSCALL +(define-condition ssl-error-syscall (ssl-error/handle) + ((syscall :initarg :syscall)) + (:documentation + "Some I/O error occurred. The OpenSSL error queue may contain more + information on the error. If the error queue is empty (i.e. ERR_get_error() returns 0), + ret can be used to find out more about the error: If ret == 0, an EOF was observed that + violates the protocol. If ret == -1, the underlying BIO reported an I/O error (for socket + I/O on Unix systems, consult errno for details).") + (:report (lambda (condition stream) + (if (zerop (err-get-error)) + (case (ssl-error-ret condition) + (0 (format stream "An I/O error occurred: An unexpected EOF was observed on handle ~A. (return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition))) + (-1 (format stream "An I/O error occurred in the underlying BIO. (return code: ~A)" + (ssl-error-ret condition))) + (otherwise (format stream "An I/O error occurred: undocumented reason. (return code: ~A)" + (ssl-error-ret condition)))) + (format stream "An UNKNOWN I/O error occurred in the underlying BIO. (return code: ~A)" + (ssl-error-ret condition))) + (write-sequence (ssl-error-queue condition) stream)))) + +;; SSL_ERROR_SSL +(define-condition ssl-error-ssl (ssl-error/handle) + () + (:documentation + "A failure in the SSL library occurred, usually a protocol error. The + OpenSSL error queue contains more information on the error.") + (:report (lambda (condition stream) + (format stream + "A failure in the SSL library occurred on handle ~A. (Return code: ~A)" + (ssl-error-handle condition) + (ssl-error-ret condition)) + (write-sequence (ssl-error-queue condition) stream)))) + +(defun write-ssl-error-queue (stream) + (format stream "SSL error queue: ~%") + (loop + for error-code = (err-get-error) + until (zerop error-code) + do (format stream "~a~%" (err-error-string error-code (cffi:null-pointer))))) + +(defun ssl-signal-error (handle syscall error-code original-error) + (let ((queue (with-output-to-string (s) (write-ssl-error-queue s)))) + (if (and (eql error-code #.+ssl-error-syscall+) + (not (zerop original-error))) + (error 'ssl-error-syscall + :handle handle + :ret error-code + :queue queue + :syscall syscall) + (error (case error-code + (#.+ssl-error-none+ 'ssl-error-none) + (#.+ssl-error-ssl+ 'ssl-error-ssl) + (#.+ssl-error-want-read+ 'ssl-error-want-read) + (#.+ssl-error-want-write+ 'ssl-error-want-write) + (#.+ssl-error-want-x509-lookup+ 'ssl-error-want-x509-lookup) + (#.+ssl-error-zero-return+ 'ssl-error-zero-return) + (#.+ssl-error-want-connect+ 'ssl-error-want-connect) + (#.+ssl-error-syscall+ 'ssl-error-zero-return) + (t 'ssl-error/handle)) + :handle handle + :ret error-code + :queue queue))))
Added: branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-all.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-all.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-all.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,12 @@ +(in-package :cl+ssl) + +(defconstant +initial-buffer-size+ 2048) + +(declaim + (inline + make-buffer + buffer-length + buffer-elt + set-buffer-elt + v/b-replace + b/v-replace))
Added: branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-clisp.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-clisp.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer-clisp.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,29 @@ +(in-package :cl+ssl) + +(defun make-buffer (size) + (cffi-sys:%foreign-alloc size)) + +(defun buffer-length (buf) + (declare (ignore buf)) + +initial-buffer-size+) + +(defun buffer-elt (buf index) + (ffi:memory-as buf 'ffi:uint8 index)) +(defun set-buffer-elt (buf index val) + (setf (ffi:memory-as buf 'ffi:uint8 index) val)) +(defsetf buffer-elt set-buffer-elt) + +(defun v/b-replace (vec buf &key (start1 0) end1 (start2 0) (end2 +initial-buffer-size+)) + (replace + vec + (ffi:memory-as buf (ffi:parse-c-type `(ffi:c-array ffi:uint8 ,(- end2 start2))) start2) + :start1 start1 + :end1 end1)) +(defun b/v-replace (buf vec &key (start1 0) (end1 +initial-buffer-size+) (start2 0) end2) + (setf + (ffi:memory-as buf (ffi:parse-c-type `(ffi:c-array ffi:uint8 ,(- end1 start1))) start1) + (subseq vec start2 end2))) + +(defmacro with-pointer-to-vector-data ((ptr buf) &body body) + `(let ((,ptr ,buf)) + ,@body))
Added: branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/ffi-buffer.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,22 @@ +(in-package :cl+ssl) + +(defun make-buffer (size) + (cffi-sys::make-shareable-byte-vector size)) + +(defun buffer-length (buf) + (length buf)) + +(defun buffer-elt (buf index) + (elt buf index)) +(defun set-buffer-elt (buf index val) + (setf (elt buf index) val)) +(defsetf buffer-elt set-buffer-elt) + +(defun v/b-replace (vec buf &key (start1 0) end1 (start2 0) end2) + (replace vec buf :start1 start1 :end1 end1 :start2 start2 :end2 end2)) +(defun b/v-replace (buf vec &key (start1 0) end1 (start2 0) end2) + (replace buf vec :start1 start1 :end1 end1 :start2 start2 :end2 end2)) + +(defmacro with-pointer-to-vector-data ((ptr buf) &body body) + `(cffi-sys::with-pointer-to-vector-data (,ptr ,buf) + ,@body))
Added: branches/trunk-reorg/thirdparty/cl+ssl/ffi.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/ffi.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/ffi.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,248 @@ +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +(declaim + (optimize (speed 3) (space 1) (safety 1) (debug 0) (compilation-speed 0))) + +(in-package :cl+ssl) + +;;; Global state +;;; +(defvar *ssl-global-context* nil) +(defvar *ssl-global-method* nil) +(defvar *bio-lisp-method* nil) + +(defparameter *blockp* t) +(defparameter *partial-read-p* nil) + +(defun ssl-initialized-p () + (and *ssl-global-context* *ssl-global-method*)) + + +;;; Constants +;;; +(defconstant +random-entropy+ 256) + +(defconstant +ssl-filetype-pem+ 1) +(defconstant +ssl-filetype-asn1+ 2) +(defconstant +ssl-filetype-default+ 3) + +(defconstant +SSL_CTRL_SET_SESS_CACHE_MODE+ 44) + + +;;; Misc +;;; +(defmacro while (cond &body body) + `(do () ((not ,cond)) ,@body)) + + +;;; Function definitions +;;; +(declaim (inline ssl-write ssl-read ssl-connect ssl-accept)) + +(cffi:defctype ssl-method :pointer) +(cffi:defctype ssl-ctx :pointer) +(cffi:defctype ssl-pointer :pointer) + +(cffi:defcfun ("SSL_get_version" ssl-get-version) + :string + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_load_error_strings" ssl-load-error-strings) + :void) +(cffi:defcfun ("SSL_library_init" ssl-library-init) + :int) +(cffi:defcfun ("SSLv2_client_method" ssl-v2-client-method) + ssl-method) +(cffi:defcfun ("SSLv23_client_method" ssl-v23-client-method) + ssl-method) +(cffi:defcfun ("SSLv23_server_method" ssl-v23-server-method) + ssl-method) +(cffi:defcfun ("SSLv23_method" ssl-v23-method) + ssl-method) +(cffi:defcfun ("SSLv3_client_method" ssl-v3-client-method) + ssl-method) +(cffi:defcfun ("SSLv3_server_method" ssl-v3-server-method) + ssl-method) +(cffi:defcfun ("SSLv3_method" ssl-v3-method) + ssl-method) +(cffi:defcfun ("TLSv1_client_method" ssl-TLSv1-client-method) + ssl-method) +(cffi:defcfun ("TLSv1_server_method" ssl-TLSv1-server-method) + ssl-method) +(cffi:defcfun ("TLSv1_method" ssl-TLSv1-method) + ssl-method) + +(cffi:defcfun ("SSL_CTX_new" ssl-ctx-new) + ssl-ctx + (method ssl-method)) +(cffi:defcfun ("SSL_new" ssl-new) + ssl-pointer + (ctx ssl-ctx)) +(cffi:defcfun ("SSL_set_fd" ssl-set-fd) + :int + (ssl ssl-pointer) + (fd :int)) +(cffi:defcfun ("SSL_set_bio" ssl-set-bio) + :void + (ssl ssl-pointer) + (rbio :pointer) + (wbio :pointer)) +(cffi:defcfun ("SSL_get_error" ssl-get-error) + :int + (ssl ssl-pointer) + (ret :int)) +(cffi:defcfun ("SSL_set_connect_state" ssl-set-connect-state) + :void + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_set_accept_state" ssl-set-accept-state) + :void + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_connect" ssl-connect) + :int + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_accept" ssl-accept) + :int + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_write" ssl-write) + :int + (ssl ssl-pointer) + (buf :pointer) + (num :int)) +(cffi:defcfun ("SSL_read" ssl-read) + :int + (ssl ssl-pointer) + (buf :pointer) + (num :int)) +(cffi:defcfun ("SSL_shutdown" ssh-shutdown) + :void + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_free" ssl-free) + :void + (ssl ssl-pointer)) +(cffi:defcfun ("SSL_CTX_free" ssl-ctx-free) + :void + (ctx ssl-ctx)) +(cffi:defcfun ("RAND_seed" rand-seed) + :void + (buf :pointer) + (num :int)) +(cffi:defcfun ("BIO_ctrl" bio-set-fd) + :long + (bio :pointer) + (cmd :int) + (larg :long) + (parg :pointer)) +(cffi:defcfun ("BIO_new_socket" bio-new-socket) + :pointer + (fd :int) + (close-flag :int)) +(cffi:defcfun ("BIO_new" bio-new) + :pointer + (method :pointer)) + +(cffi:defcfun ("ERR_get_error" err-get-error) + :unsigned-long) +(cffi:defcfun ("ERR_error_string" err-error-string) + :string + (e :unsigned-long) + (buf :pointer)) + +(cffi:defcfun ("SSL_set_cipher_list" ssl-set-cipher-list) + :int + (ssl ssl-pointer) + (str :string)) +(cffi:defcfun ("SSL_use_RSAPrivateKey_file" ssl-use-rsa-privatekey-file) + :int + (ssl ssl-pointer) + (str :string) + ;; either +ssl-filetype-pem+ or +ssl-filetype-asn1+ + (type :int)) +(cffi:defcfun + ("SSL_CTX_use_RSAPrivateKey_file" ssl-ctx-use-rsa-privatekey-file) + :int + (ctx ssl-ctx) + (type :int)) +(cffi:defcfun ("SSL_use_certificate_file" ssl-use-certificate-file) + :int + (ssl ssl-pointer) + (str :string) + (type :int)) +(cffi:defcfun ("SSL_CTX_load_verify_locations" ssl-ctx-load-verify-locations) + :int + (ctx ssl-ctx) + (CAfile :string) + (CApath :string)) +(cffi:defcfun ("SSL_CTX_set_client_CA_list" ssl-ctx-set-client-ca-list) + :void + (ctx ssl-ctx) + (list ssl-pointer)) +(cffi:defcfun ("SSL_load_client_CA_file" ssl-load-client-ca-file) + ssl-pointer + (file :string)) + +(cffi:defcfun ("SSL_CTX_ctrl" ssl-ctx-ctrl) + :long + (ctx ssl-ctx) + (cmd :int) + (larg :long) + (parg :long)) + + +;;; Funcall wrapper +;;; +(defvar *socket*) + +(declaim (inline ensure-ssl-funcall)) +(defun ensure-ssl-funcall (*socket* handle func sleep-time &rest args) + (loop + (handler-case + (let ((rc (apply func args))) + (when (plusp rc) + (return rc)) + (ssl-signal-error handle func (ssl-get-error handle rc) rc)) + (ssl-error-want-something (condition) + (declare (ignore condition)) + ;; FIXME: what is this SLEEP business for? + ;; Do we still need this? + (warn "sleeping in ensure-ssl-funcall") + (sleep sleep-time))))) + + +;;; Initialization +;;; +(defun init-prng () + ;; this initialization of random entropy is not necessary on + ;; Linux, since the OpenSSL library automatically reads from + ;; /dev/urandom if it exists. On Solaris it is necessary. + (let ((buf (cffi-sys::make-shareable-byte-vector +random-entropy+))) + (dotimes (i +random-entropy+) + (setf (elt buf i) (random 256))) + (cffi-sys::with-pointer-to-vector-data (ptr buf) + (rand-seed ptr +random-entropy+)))) + +(defun ssl-ctx-set-session-cache-mode (ctx mode) + (ssl-ctx-ctrl ctx +SSL_CTRL_SET_SESS_CACHE_MODE+ mode 0)) + +(defun initialize (&optional (method 'ssl-v23-method)) + (setf *bio-lisp-method* (make-bio-lisp-method)) + (ssl-load-error-strings) + (ssl-library-init) + (init-prng) + (setf *ssl-global-method* (funcall method)) + (setf *ssl-global-context* (ssl-ctx-new *ssl-global-method*)) + (ssl-ctx-set-session-cache-mode *ssl-global-context* 3)) + +(defun ensure-initialized (&optional (method 'ssl-v23-method)) + (unless (ssl-initialized-p) + (initialize method)) + (unless *bio-lisp-method* + (setf *bio-lisp-method* (make-bio-lisp-method)))) + +(defun reload () + (cffi:load-foreign-library 'libssl) + (cffi:load-foreign-library 'libeay32) + (setf *ssl-global-context* nil) + (setf *ssl-global-method* nil))
Added: branches/trunk-reorg/thirdparty/cl+ssl/index.css =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/index.css 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/index.css 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,66 @@ +div.sidebar { + float: right; + background-color: #eeeeee; + border: 2pt solid black; + margin: 0em 2pt 1em 2em; + min-width: 15%; + padding: 0pt 5pt 5pt 5pt; +} + +div.sidebar ul { + padding: 0pt 0pt 0pt 1em; + margin: 0 0 1em; +} + +body { + color: #000000; + background-color: #ffffff; + margin-right: 0pt; + margin-bottom: 10%; + padding-left: 30px; +} + +h1,h2 { + background-color: darkred; + color: white; + margin-left: -30px; +} + +th { + background-color: darkred; + color: white; + text-align: left; +} + +pre { + background-color: #eeeeee; + border: solid 1px #d0d0d0; + padding: 1em; + margin-right: 10%; +} + +.def { + background-color: #ddddff; + font-weight: bold; +} + +.nomargin { + margin-bottom: 0; + margin-top: 0; +} + +.working { + background-color: #60c060; +} + +.broken { + background-color: #ff6060; +} + +.incomplete { + background-color: #ffff60; +} + +.unknown { + background-color: #cccccc; +}
Added: branches/trunk-reorg/thirdparty/cl+ssl/index.html =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/index.html 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/index.html 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,271 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head> + <title>CL+SSL</title> + <link rel="stylesheet" type="text/css" href="index.css"/> + </head> + <body> + <h1>CL<em style="font-weight: normal">plus</em>SSL</h1> + + <h3>Subprojects</h3> + <ul> + <li><a href="#cl+ssl">CL+SSL</a></li> + <li><a href="#trivial-https">trivial-https</a></li> + <li><a href="#trivial-gray-streams">trivial-gray-streams</a></li> + </ul> + + <h3>News</h3> + <p> + 2007-xx-yy + </p> + <ul> + <li> + Fixed windows support, thanks to Matthew Kennedy and Vodonosov Anton. + </li> + </ul> + <p> + 2007-07-07 + </p> + <ul> + <li> + Improved clisp support, thanks + to <a + href="http://web.kepibu.org/code/lisp/cl+ssl/%22%3EPixel + // pinterface</a>, as well as client certificate support. + </li> + <li> + Re-introduced support for direct access to file descriptors as + an optimization. New function <tt>stream-fd</tt>. New keyword + argument <tt>close-callback</tt>. + </li> + </ul> + <p> + 2007-01-16: CL+SSL is now available under an MIT-style license. + </p> + + <h3>Download</h3> + <p> + Anonymous CVS (<a href="http://common-lisp.net/cgi-bin/viewcvs.cgi/?cvsroot=cl-plus-ssl">browse</a>): + </p> + <pre>$ export CVSROOT=:pserver:anonymous@common-lisp.net:/project/cl-plus-ssl/cvsroot +$ cvs login +password: anonymous +$ cvs co cl+ssl +$ cvs co trivial-gray-streams +$ cvs co trivial-https</pre> + <p> + <a + href="http://common-lisp.net/project/cl-plus-ssl/download/%22%3ETarballs</a> + are also available (but not always up-to-date). + </p> + <p> + Note that you need the <tt>libssl-dev</tt> package on Debian to + load this package without manual configuration. + </p> + + <p> + Send bug reports to <a + href="mailto:cl-plus-ssl-devel@common-lisp.net">cl-plus-ssl-devel@common-lisp.net</a> + (<a + href="http://common-lisp.net/cgi-bin/mailman/listinfo/cl-plus-ssl-devel%22%3Elist + information</a>). + </p> + + <a name="cl+ssl"> + <h2>CL+SSL</h2> + + <p>A simple Common Lisp interface to OpenSSL.</p> + + <h3>About</h3> + + <p> + This library is a fork of <a + href="http://www.cliki.net/SSL-CMUCL">SSL-CMUCL</a>. The original + SSL-CMUCL source code was written by Eric Marsden and includes + contributions by Jochen Schmidt. License: MIT-style. + </p> + + <ul> + <li> + CL+SSL is portable code based on CFFI and gray streams. + </li> + <li> + It defines its own libssl BIO method, so that SSL I/O is + actually written over portable Lisp streams instead of bypassing + the streams and sending data over Unix file descriptors directly. + </li> + </ul> + + <p> + Comparison chart: + </p> + <table border="1" cellpadding="2" cellspacing="0"> + <thead> + <tr> + <th></th> + <th><b>FFI</b></th> + <th><b>Streams</b></th> + <th><b>Lisp-BIO</b></th> + </tr> + </thead> + <tr> + <td>CL+SSL</td> + <td>CFFI</td> + <td>gray<sup>1</sup>, buffering output</td> + <td>yes</td> + </tr> + <tr> + <td>CL-SSL</td> + <td>UFFI</td> + <td>gray, buffering I/O [<em>part of ACL-COMPAT</em>]</td> + <td>no</td> + </tr> + <tr> + <td>SSL-CMUCL</td> + <td>CMUCL/ALIEN</td> + <td>CMUCL, non-buffering</td> + <td>no</td> + </tr> + </table> + <p> + <sup>1</sup> Character I/O and external formats in CL+SSL + are provided + using <a href="http://weitz.de/flexi-streams/">flexi-streams</a>. + </p> + + <h3>API functions</h3> + <p> + <div class="def">Function CL+SSL:STREAM-FD (stream)</div> + Return <tt>stream</tt>'s file descriptor as an integer, if + known. Otherwise return <tt>stream</tt> itself. + </p> + <p> + Pass the + return value of this function to <tt>make-ssl-client-stream</tt> + or <tt>make-ssl-servre-stream</tt>, which are faster when + accessing file descriptors directly. + </p> + <p> + <div class="def">Function CL+SSL:MAKE-SSL-CLIENT-STREAM (fd-or-stream &key external-format certificate key close-callback)</div> + Return an SSL stream for the client socket <tt>fd-or-stream</tt>. + All reads and writes to this SSL stream will be pushed through the + SSL connection. + </p> + <p> + If <tt>fd-or-stream</tt> is a lisp stream, it can + the SSL stream will close it automatically. File descriptors are + not closed automatically. However, if <tt>close-callback</tt> is + non-nil, it will be called with zero arguments when the SSL stream + is closed. + + <tt>certificate</tt> is the path to a file containing the PEM-encoded + certificate for your client. <tt>key</tt> is the path to the PEM-encoded + key for the client, which must not be associated with a passphrase. + </p> + <p> + If <tt>external-format</tt> is <tt>nil</tt> (the default), a plain + <tt>(unsigned-byte 8)</tt> SSL stream is returned. With a + non-null <tt>external-format</tt>, a flexi-stream capable of + character I/O will be returned instead, with the specified value + as its initial external format. + </p> + <p> + <div class="def">Function CL+SSL:MAKE-SSL-SERVER-STREAM (fd-or-stream &key external-format certificate key close-callback)</div> + Return an SSL stream for the server socket <tt>fd-or-stream</tt>. All + reads and writes to this server stream will be pushed through the + OpenSSL library. + </p> + <p> + If <tt>fd-or-stream</tt> is a lisp stream, it can + the SSL stream will close it automatically. File descriptors are + not closed automatically. However, if <tt>close-callback</tt> is + non-nil, it will be called with zero arguments when the SSL stream + is closed. + + <tt>certificate</tt> is the path to a file containing the PEM-encoded + certificate for your server. <tt>key</tt> is the path to the PEM-encoded + key for the server, which must not be associated with a + passphrase. See above for <tt>external-format</tt> handling. + </p> + <p> + <div class="def">Function CL+SSL:RELOAD ()</div> + Reload <tt>libssl</tt>. Call this function after restarting a Lisp + core with CL+SSL dumped into it on Lisp implementations that do + not reload shared libraries automatically. + </p> + + <h3>Portability</h3> + <p> + CL+SSL requires CFFI with callback support. + </p> + <p> + Test results for Linux/x86, except OpenMCL which was tested on + Linux/PPC: + </p> + <table border="1" cellpadding="2" cellspacing="0"> + <thead> + <tr> + <th><b>Lisp Implementation</b></th> + <th><b>Status</b></th> + <th><b>Comments</b></th> + </tr> + </thead> + <tr><td>OpenMCL</td><td class="working">Working</td></tr> + <tr><td>SBCL</td><td class="working">Working</td></tr> + <tr><td>CMU CL</td><td class="working">Working</td></tr> + <tr><td>CLISP</td><td class="working">Working</td></tr> + <tr><td>LispWorks</td><td class="working">Working</td></tr> + <tr> + <td>Allegro</td> + <td class="broken">Broken</td> + <td>segfault</td> + </tr> + <tr><td>Corman CL</td><td class="unknown">Unknown</td></tr> + <tr><td>Digitool MCL</td><td class="unknown">Unknown</td></tr> + <tr><td>Scieneer CL</td><td class="unknown">Unknown</td></tr> + <tr><td>ECL</td><td class="unknown">Unknown</td></tr> + <tr><td>GCL</td><td class="unknown">Unknown</td></tr> + </table> + + <h3>TODO</h3> + <ul> + <li>CNAME checking!</li> + </ul> + + <a name="trivial-https"> + <h2>trivial-https</h2> + + <p> + trivial-https is a fork of Brian + Mastenbrook's <a + href="http://www.cliki.net/trivial-http">trivial-http</a> adding + support for HTTPS using CL+SSL. License: MIT-style. + </p> + + <p> + <b> + Note: The <a href="http://weitz.de/drakma/">Drakma</a> HTTP + client library by Weitz supports HTTPS using CL+SSL. + trivial-https will not be developed further; please use Drakma + instead. + </b> + </p> + + <p> + <a href="http://common-lisp.net/cgi-bin/viewcvs.cgi/*checkout*/trivial-https/README?rev=HEAD&cvsroot=cl-plus-ssl&content-type=text/plain">README</a> + </p> + + <a name="trivial-gray-streams"> + <h2>trivial-gray-streams</h2> + + <p> + trivial-gray-streams provides an extremely thin compatibility + layer for gray streams. License: MIT-style. + </p> + + <p> + <a href="http://common-lisp.net/cgi-bin/viewcvs.cgi/*checkout*/trivial-gray-streams/README?rev=HEAD&cvsroot=cl-plus-ssl&content-type=text/plain">README</a> + </p> + </body> +</html>
Added: branches/trunk-reorg/thirdparty/cl+ssl/package.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/package.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/package.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,15 @@ +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +(in-package :cl-user) + +(defpackage :cl+ssl + (:use :common-lisp :trivial-gray-streams) + (:export #:ensure-initialized + #:reload + #:stream-fd + #:make-ssl-client-stream + #:make-ssl-server-stream))
Added: branches/trunk-reorg/thirdparty/cl+ssl/reload.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/reload.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/reload.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,28 @@ +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +;;; We do this in an extra file so that it happens +;;; - after the asd file has been loaded, so that users can +;;; customize *libssl-pathname* between loading the asd and LOAD-OPing +;;; the actual sources +;;; - before ssl.lisp is loaded, which needs the library at compilation +;;; time on some implemenations +;;; - but not every time ffi.lisp is re-loaded as would happen if we +;;; put this directly into ffi.lisp + +(in-package :cl+ssl) + +(cffi:define-foreign-library libssl + (:windows "libssl32.dll") + (:unix (:or "libssl.so.0.9.8" "libssl.so")) + (t (:default "libssl3"))) + +(cffi:use-foreign-library libssl) + +(cffi:define-foreign-library libeay32 + (:windows "libeay32.dll")) + +(cffi:use-foreign-library libeay32)
Added: branches/trunk-reorg/thirdparty/cl+ssl/streams.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/streams.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/streams.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,252 @@ +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; Copyright (C) 2007 Pixel // pinterface +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +(declaim + (optimize (speed 3) (space 1) (safety 1) (debug 0) (compilation-speed 0))) + +(in-package :cl+ssl) + +(defclass ssl-stream + (fundamental-binary-input-stream + fundamental-binary-output-stream + trivial-gray-stream-mixin) + ((ssl-stream-socket + :initarg :socket + :accessor ssl-stream-socket) + (close-callback + :initarg :close-callback + :accessor ssl-close-callback) + (handle + :initform nil + :accessor ssl-stream-handle) + (output-buffer + :initform (make-buffer +initial-buffer-size+) + :accessor ssl-stream-output-buffer) + (output-pointer + :initform 0 + :accessor ssl-stream-output-pointer) + (input-buffer + :initform (make-buffer +initial-buffer-size+) + :accessor ssl-stream-input-buffer) + (peeked-byte + :initform nil + :accessor ssl-stream-peeked-byte))) + +(defmethod print-object ((object ssl-stream) stream) + (print-unreadable-object (object stream :type t) + (format stream "for ~A" (ssl-stream-socket object)))) + +(defclass ssl-server-stream (ssl-stream) + ((certificate + :initarg :certificate + :accessor ssl-stream-certificate) + (key + :initarg :key + :accessor ssl-stream-key))) + +(defmethod stream-element-type ((stream ssl-stream)) + '(unsigned-byte 8)) + +(defmethod close ((stream ssl-stream) &key abort) + (declare (ignore abort)) + (force-output stream) + (ssl-free (ssl-stream-handle stream)) + (setf (ssl-stream-handle stream) nil) + (when (streamp (ssl-stream-socket stream)) + (close (ssl-stream-socket stream))) + (when (functionp (ssl-close-callback stream)) + (funcall (ssl-close-callback stream)))) + +(defmethod open-stream-p ((stream ssl-stream)) + (and (ssl-stream-handle stream) t)) + +(defmethod stream-listen ((stream ssl-stream)) + (or (ssl-stream-peeked-byte stream) + (setf (ssl-stream-peeked-byte stream) + (let* ((*blockp* nil) + (b (stream-read-byte stream))) + (if (eql b :eof) nil b))))) + +(defmethod stream-read-byte ((stream ssl-stream)) + (or (ssl-stream-peeked-byte stream) + (let ((buf (ssl-stream-input-buffer stream))) + (handler-case + (with-pointer-to-vector-data (ptr buf) + (ensure-ssl-funcall (ssl-stream-socket stream) + (ssl-stream-handle stream) + #'ssl-read + 5.5 + (ssl-stream-handle stream) + ptr + 1) + (buffer-elt buf 0)) + (ssl-error-zero-return () ;SSL_read returns 0 on end-of-file + :eof))))) + +(defmethod stream-read-sequence ((stream ssl-stream) thing start end &key) + (check-type thing (simple-array (unsigned-byte 8) (*))) + (when (and (< start end) (ssl-stream-peeked-byte stream)) + (setf (elt thing start) (ssl-stream-peeked-byte stream)) + (setf (ssl-stream-peeked-byte stream) nil) + (incf start)) + (let ((buf (ssl-stream-input-buffer stream))) + (loop + for length = (min (- end start) (buffer-length buf)) + while (plusp length) + do + (handler-case + (with-pointer-to-vector-data (ptr buf) + (ensure-ssl-funcall (ssl-stream-socket stream) + (ssl-stream-handle stream) + #'ssl-read + 5.5 + (ssl-stream-handle stream) + ptr + length) + (v/b-replace thing buf :start1 start :end1 (+ start length)) + (incf start length)) + (ssl-error-zero-return () ;SSL_read returns 0 on end-of-file + (return)))) + start)) + +(defmethod stream-write-byte ((stream ssl-stream) b) + (let ((buf (ssl-stream-output-buffer stream))) + (when (eql (buffer-length buf) (ssl-stream-output-pointer stream)) + (force-output stream)) + (setf (buffer-elt buf (ssl-stream-output-pointer stream)) b) + (incf (ssl-stream-output-pointer stream))) + b) + +(defmethod stream-write-sequence ((stream ssl-stream) thing start end &key) + (check-type thing (simple-array (unsigned-byte 8) (*))) + (let ((buf (ssl-stream-output-buffer stream))) + (when (> (+ (- end start) (ssl-stream-output-pointer stream)) (buffer-length buf)) + ;; not enough space left? flush buffer. + (force-output stream) + ;; still doesn't fit? + (while (> (- end start) (buffer-length buf)) + (b/v-replace buf thing :start2 start) + (incf start (buffer-length buf)) + (setf (ssl-stream-output-pointer stream) (buffer-length buf)) + (force-output stream))) + (b/v-replace buf thing + :start1 (ssl-stream-output-pointer stream) + :start2 start + :end2 end) + (incf (ssl-stream-output-pointer stream) (- end start))) + thing) + +(defmethod stream-finish-output ((stream ssl-stream)) + (stream-force-output stream)) + +(defmethod stream-force-output ((stream ssl-stream)) + (let ((buf (ssl-stream-output-buffer stream)) + (fill-ptr (ssl-stream-output-pointer stream)) + (handle (ssl-stream-handle stream)) + (socket (ssl-stream-socket stream))) + (when (plusp fill-ptr) + (with-pointer-to-vector-data (ptr buf) + (ensure-ssl-funcall socket handle #'ssl-write 0.5 handle ptr fill-ptr)) + (setf (ssl-stream-output-pointer stream) 0)))) + + +;;; interface functions +;;; +(defun make-ssl-client-stream + (socket &key certificate key (method 'ssl-v23-method) external-format + close-callback) + "Returns an SSL stream for the client socket descriptor SOCKET. +CERTIFICATE is the path to a file containing the PEM-encoded certificate for + your client. KEY is the path to the PEM-encoded key for the client, which +must not be associated with a passphrase." + (ensure-initialized method) + (let ((stream (make-instance 'ssl-stream + :socket socket + :close-callback close-callback)) + (handle (ssl-new *ssl-global-context*))) + (setf (ssl-stream-handle stream) handle) + (etypecase socket + (integer (ssl-set-fd handle socket)) + (stream (ssl-set-bio handle (bio-new-lisp) (bio-new-lisp)))) + (ssl-set-connect-state handle) + (when key + (unless (eql 1 (ssl-use-rsa-privatekey-file handle + key + +ssl-filetype-pem+)) + (error 'ssl-error-initialize :reason "Can't load RSA private key ~A"))) + (when certificate + (unless (eql 1 (ssl-use-certificate-file handle + certificate + +ssl-filetype-pem+)) + (error 'ssl-error-initialize + :reason "Can't load certificate ~A" certificate))) + (ensure-ssl-funcall socket handle #'ssl-connect 0.25 handle) + (if external-format + (flexi-streams:make-flexi-stream stream + :external-format external-format) + stream))) + +(defun make-ssl-server-stream + (socket &key certificate key (method 'ssl-v23-method) external-format + close-callback) + "Returns an SSL stream for the server socket descriptor SOCKET. +CERTIFICATE is the path to a file containing the PEM-encoded certificate for + your server. KEY is the path to the PEM-encoded key for the server, which +must not be associated with a passphrase." + (ensure-initialized method) + (let ((stream (make-instance 'ssl-server-stream + :socket socket + :close-callback close-callback + :certificate certificate + :key key)) + (handle (ssl-new *ssl-global-context*))) + (setf (ssl-stream-handle stream) handle) + (etypecase socket + (integer + (ssl-set-fd handle socket)) + (stream + (let ((bio (bio-new-lisp))) + (ssl-set-bio handle bio bio)))) + (ssl-set-accept-state handle) + (when (zerop (ssl-set-cipher-list handle "ALL")) + (error 'ssl-error-initialize :reason "Can't set SSL cipher list")) + (when key + (unless (eql 1 (ssl-use-rsa-privatekey-file handle + key + +ssl-filetype-pem+)) + (error 'ssl-error-initialize :reason "Can't load RSA private key ~A"))) + (when certificate + (unless (eql 1 (ssl-use-certificate-file handle + certificate + +ssl-filetype-pem+)) + (error 'ssl-error-initialize + :reason "Can't load certificate ~A" certificate))) + (ensure-ssl-funcall socket handle #'ssl-accept 0.25 handle) + (if external-format + (flexi-streams:make-flexi-stream stream + :external-format external-format) + stream))) + +(defgeneric stream-fd (stream)) +(defmethod stream-fd (stream) stream) + +#+sbcl +(defmethod stream-fd ((stream sb-sys:fd-stream)) + (sb-sys:fd-stream-fd stream)) + +#+cmu +(defmethod stream-fd ((stream system:fd-stream)) + (system:fd-stream-fd stream)) + +#+openmcl +(defmethod stream-fd ((stream ccl::basic-stream)) + (ccl::ioblock-device (ccl::stream-ioblock stream t))) + +#+clisp +(defmethod stream-fd ((stream stream)) + ;; sockets appear to be direct instances of STREAM + (ignore-errors (socket:stream-handles stream)))
Added: branches/trunk-reorg/thirdparty/cl+ssl/test.lisp =================================================================== --- branches/trunk-reorg/thirdparty/cl+ssl/test.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/cl+ssl/test.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,103 @@ +;;; Copyright (C) 2001, 2003 Eric Marsden +;;; Copyright (C) 2005 David Lichteblau +;;; "the conditions and ENSURE-SSL-FUNCALL are by Jochen Schmidt." +;;; +;;; See LICENSE for details. + +#| +(load "test.lisp") +(ssl-test::test-https-client "www.google.com") +(ssl-test::test-https-server) +|# + +(defpackage :ssl-test + (:use :cl)) +(in-package :ssl-test) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (asdf:operate 'asdf:load-op :trivial-sockets)) + +(defun read-line-crlf (stream &optional eof-error-p) + (let ((s (make-string-output-stream))) + (loop + for empty = t then nil + for c = (read-char stream eof-error-p nil) + while (and c (not (eql c #\return))) + do + (unless (eql c #\newline) + (write-char c s)) + finally + (return + (if empty nil (get-output-stream-string s)))))) + +(defun test-nntps-client (&optional (host "snews.gmane.org") (port 563)) + (let* ((fd (trivial-sockets:open-stream host port + :element-type '(unsigned-byte 8))) + (nntps (cl+ssl:make-ssl-client-stream fd :external-format :iso-8859-1))) + (format t "NNTPS> ~A~%" (read-line-crlf nntps)) + (write-line "HELP" nntps) + (force-output nntps) + (loop :for line = (read-line-crlf nntps nil) + :until (string-equal "." line) + :do (format t "NNTPS> ~A~%" line)))) + + +;; open an HTTPS connection to a secure web server and make a +;; HEAD request +(defun test-https-client (host &optional (port 443)) + (let* ((socket (trivial-sockets:open-stream + host + port + :element-type '(unsigned-byte 8))) + (https (cl+ssl:make-ssl-client-stream + (cl+ssl:stream-fd socket) + :external-format :iso-8859-1))) + (unwind-protect + (progn + (format https "HEAD / HTTP/1.0~%Host: ~a~%~%" host) + (force-output https) + (loop :for line = (read-line-crlf https nil) + :while line :do + (format t "HTTPS> ~a~%" line))) + (close socket) + (close https)))) + +;; start a simple HTTPS server. See the mod_ssl documentation at +;; URL:http://www.modssl.org/ for information on generating the +;; server certificate and key +;; +;; You can stress-test the server with +;; +;; siege -c 10 -u https://host:8080/foobar +;; +(defun test-https-server + (&key (port 8080) + (cert "/home/david/newcert.pem") + (key "/home/david/newkey.pem")) + (format t "~&SSL server listening on port ~d~%" port) + (trivial-sockets:with-server (server (:port port)) + (loop + (let* ((socket (trivial-sockets:accept-connection + server + :element-type '(unsigned-byte 8))) + (client (cl+ssl:make-ssl-server-stream + (cl+ssl:stream-fd socket) + :external-format :iso-8859-1 + :certificate cert + :key key))) + (unwind-protect + (progn + (loop :for line = (read-line-crlf client nil) + :while (> (length line) 1) :do + (format t "HTTPS> ~a~%" line)) + (format client "HTTP/1.0 200 OK~%") + (format client "Server: SSL-CMUCL/1.1~%") + (format client "Content-Type: text/plain~%") + (terpri client) + (format client "G'day at ~A!~%" + (multiple-value-list (get-decoded-time))) + (format client "CL+SSL running in ~A ~A~%" + (lisp-implementation-type) + (lisp-implementation-version))) + (close socket) + (close client))))))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/CHANGELOG =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/CHANGELOG 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/CHANGELOG 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,190 @@ +Version 0.13.1 +2007-10-11 +Small fix for AllegroCL's "modern" mode + +Version 0.13.0 +2007-09-13 +Better optimizations for STREAM-WRITE-SEQUENCE (thanks to Anton Vodonosov) +Bugfix for STREAM-WRITE-BYTE + +Version 0.12.0 +2007-09-07 +Added "bound" for flexi input streams + +Version 0.11.2 +2007-04-06 +Fixed bug in STREAM-WRITE-STRING implementation (reported by quasi) + +Version 0.11.1 +2007-03-22 +More ugliness for a bit of output performance in special cases + +Version 0.11.0 +2007-03-09 +Re-factoring of how encoding errors are handled (patch by Anton Vodonosov) + +Version 0.10.3 +2007-02-19 +Fixed bug in UTF-16 output (patch by Stelian Ionescu) +Fixed *SUBSTITUTION-CHAR* example in docs + +Version 0.10.2 +2007-01-12 +Another fix - sigh... + +Version 0.10.1 +2007-01-11 +Fixed the last change (thanks to Red Daly) + +Version 0.10.0 +2007-01-10 +Added transformers to in-memory streams (thanks to Chris Dean) +Documentation fixes + +Version 0.9.1 +2006-12-27 +More performance improvements (thanks to Robert J. Macomber for SBCL hints) + +Version 0.9.0 +2006-12-27 +Complete re-factoring to improve performance and reduce consing (at least for LispWorks) +Added some tests +Added *PROVIDE-USE-VALUE-RESTART* +Added FLEXI-STREAM-POSITION-SPEC-ERROR condition + +Version 0.8.0 +2006-11-14 +Added USE-VALUE restart for STREAM-READ-CHAR (thanks to Anton Vodonosov) +Added *SUBSTITUTION-CHAR* + +Version 0.7.2 +2006-11-06 +Removed unnecessary CHECK-EOF-NO-HANG also for in-memory streams (see 0.5.8) + +Version 0.7.1 +2006-10-31 +Argh, missed the most important part... + +Version 0.7.0 +2006-10-31 +Added KOI8-R (thanks to Igor Plekhov) + +Version 0.6.6 +2006-10-06 +Made sure not to apply Gray stream generic function to underlying stream + +Version 0.6.5 +2006-10-06 +Optimized STREAM-WRITE-SEQUENCE and STREAM-READ-SEQUENCE for arrays of octets + +Version 0.6.4 +2006-10-05 +Made READ-BYTE/WRITE-BYTE the default behaviour, i.e. we only use the sequence functions for LW if necessary + +Version 0.6.3 +2006-10-02 +Fixed problems with CMUCL Gray streams implementation (reported by Ivan Toshkov) + +Version 0.6.2 +2006-09-23 +Added method for MAKE-LOAD-FORM which is needed for OpenMCL (reported by Robert Synnott, see Drakma mailing list) + +Version 0.6.1 +2006-09-15 +Switched FILE-POSITION implementation to TRIVIAL-GRAY-STREAMS (thanks to David Lichteblau) + +Version 0.6.0 +2006-09-13 +Implemented file positions for LispWorks + +Version 0.5.10 +2006-09-04 +Flexi streams can have binary element types now + +Version 0.5.9 +2006-09-01 +Added string functions + +Version 0.5.8 +2006-09-01 +CHECK-EOF-NO-HANG is not necessary +Updated LW links in documentation +Changed package handling in system definition (thanks to Christophe Rhodes) + +Version 0.5.7 +2006-06-29 +Removed incompatibility with AllegroCL, see mailing list archive for details + +Version 0.5.6 +2006-06-13 +Fixed Emacs mode lines (reported by Robert Goldman) + +Version 0.5.5 +2006-05-24 +Some small fixes for LW + +Version 0.5.4 +2006-05-18 +Workaround for CMUCL (thanks to Satyaki Das) + +Version 0.5.3 +2006-03-06 +Fixed more typos in stream.lisp +Added missing exports in packages.lisp + +Version 0.5.2 +2006-01-26 +Fixed typos in stream.lisp (thanks to James Bielman) + +Version 0.5.1 +2005-12-14 +Some bugfixes in output.lisp (thanks to Jan Idzikowski) + +Version 0.5.0 +2005-12-11 +Added in-memory streams +Exported types +Added specific conditions + +Version 0.4.1 +2005-12-05 +Updated docs + +Version 0.4.0 +2005-12-05 +Added US-ASCII encoding +Added *USE-REPLACEMENT-CHAR* + +Version 0.3.0 +2005-11-26 +Added UNREAD-BYTE and PEEK-BYTE + +Version 0.2.4 +2005-11-26 +WIN32:CODE-PAGE only for LispWorks + +Version 0.2.3 +2005-11-26 +Added STREAM-TERPRI to appease AllegroCL +Fixed typo in docs + +Version 0.2.2 +2005-11-26 +Patch to make class precendence list work in AllegroCL (David Lichteblau) + +Version 0.2.1 +2005-11-25 +Adapted to new TRIVIAL-GRAY-STREAMS API (David Lichteblau) +More changes for portability, specifically for SBCL (David Lichteblau) + +Version 0.2.0 +2005-11-25 +Portable version thanks to TRIVIAL-GRAY-STREAMS (David Lichteblau) + +Version 0.1.1 +2005-11-25 +Documentation enhancements + +Version 0.1.0 +2005-11-25 +Initial public release
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/ascii.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/ascii.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/ascii.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,35 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/ascii.lisp,v 1.7 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defvar +ascii-table+ + #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533) + "An array enumerating the character codes for the US-ASCII +encoding.")
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/code-pages.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/code-pages.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/code-pages.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,62 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/code-pages.lisp,v 1.5 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +;;; the following code was auto-generated with LWW + +(defvar +code-page-tables+ + '((437 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 228 224 229 231 234 235 232 239 238 236 196 197 201 230 198 244 246 242 251 249 255 214 220 162 163 165 8359 402 225 237 243 250 241 209 170 186 191 8976 172 189 188 161 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 160)) + (720 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 233 226 132 224 134 231 234 235 232 239 238 141 142 143 144 1617 1618 244 164 1600 251 249 1569 1570 1571 1572 163 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 1590 1591 1592 1593 1594 1601 181 1602 1603 1604 1605 1606 1607 1608 1609 1610 8801 1611 1612 1613 1614 1615 1616 8776 176 8729 183 8730 8319 178 9632 160)) + (737 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 931 932 933 934 935 936 937 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 963 962 964 965 966 967 968 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 969 940 941 942 970 943 972 973 971 974 902 904 905 906 908 910 911 177 8805 8804 938 939 247 8776 176 8729 183 8730 8319 178 9632 160)) + (775 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 262 252 233 257 228 291 229 263 322 275 342 343 299 377 196 197 201 230 198 333 246 290 162 346 347 214 220 248 163 216 215 164 256 298 243 379 380 378 8221 166 169 174 172 189 188 321 171 187 9617 9618 9619 9474 9508 260 268 280 278 9571 9553 9559 9565 302 352 9488 9492 9524 9516 9500 9472 9532 370 362 9562 9556 9577 9574 9568 9552 9580 381 261 269 281 279 303 353 371 363 382 9496 9484 9608 9604 9612 9616 9600 211 223 332 323 245 213 181 324 310 311 315 316 326 274 325 8217 173 177 8220 190 182 167 247 8222 176 8729 183 185 179 178 9632 160)) + (850 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 228 224 229 231 234 235 232 239 238 236 196 197 201 230 198 244 246 242 251 249 255 214 220 248 163 216 215 402 225 237 243 250 241 209 170 186 191 174 172 189 188 161 171 187 9617 9618 9619 9474 9508 193 194 192 169 9571 9553 9559 9565 162 165 9488 9492 9524 9516 9500 9472 9532 227 195 9562 9556 9577 9574 9568 9552 9580 164 240 208 202 203 200 305 205 206 207 9496 9484 9608 9604 166 204 9600 211 223 212 210 245 213 181 254 222 218 219 217 253 221 175 180 173 177 8215 190 182 167 247 184 176 168 183 185 179 178 9632 160)) + (852 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 228 367 263 231 322 235 336 337 238 377 196 262 201 313 314 244 246 317 318 346 347 214 220 356 357 321 215 269 225 237 243 250 260 261 381 382 280 281 172 378 268 351 171 187 9617 9618 9619 9474 9508 193 194 282 350 9571 9553 9559 9565 379 380 9488 9492 9524 9516 9500 9472 9532 258 259 9562 9556 9577 9574 9568 9552 9580 164 273 272 270 203 271 327 205 206 283 9496 9484 9608 9604 354 366 9600 211 223 212 323 324 328 352 353 340 218 341 368 253 221 355 180 173 733 731 711 728 167 247 184 176 168 729 369 344 345 9632 160)) + (855 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1106 1026 1107 1027 1105 1025 1108 1028 1109 1029 1110 1030 1111 1031 1112 1032 1113 1033 1114 1034 1115 1035 1116 1036 1118 1038 1119 1039 1102 1070 1098 1066 1072 1040 1073 1041 1094 1062 1076 1044 1077 1045 1092 1060 1075 1043 171 187 9617 9618 9619 9474 9508 1093 1061 1080 1048 9571 9553 9559 9565 1081 1049 9488 9492 9524 9516 9500 9472 9532 1082 1050 9562 9556 9577 9574 9568 9552 9580 164 1083 1051 1084 1052 1085 1053 1086 1054 1087 9496 9484 9608 9604 1055 1103 9600 1071 1088 1056 1089 1057 1090 1058 1091 1059 1078 1046 1074 1042 1100 1068 8470 173 1099 1067 1079 1047 1096 1064 1101 1069 1097 1065 1095 1063 167 9632 160)) + (857 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 228 224 229 231 234 235 232 239 238 305 196 197 201 230 198 244 246 242 251 249 304 214 220 248 163 216 350 351 225 237 243 250 241 209 286 287 191 174 172 189 188 161 171 187 9617 9618 9619 9474 9508 193 194 192 169 9571 9553 9559 9565 162 165 9488 9492 9524 9516 9500 9472 9532 227 195 9562 9556 9577 9574 9568 9552 9580 164 186 170 202 203 200 65533 205 206 207 9496 9484 9608 9604 166 204 9600 211 223 212 210 245 213 181 65533 215 218 219 217 236 255 175 180 173 177 65533 190 182 167 247 184 176 168 183 185 179 178 9632 160)) + (860 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 227 224 193 231 234 202 232 205 212 236 195 194 201 192 200 244 245 242 218 249 204 213 220 162 163 217 8359 211 225 237 243 250 241 209 170 186 191 210 172 189 188 161 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 160)) + (861 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 228 224 229 231 234 235 232 208 240 222 196 197 201 230 198 244 246 254 251 221 253 214 220 248 163 216 8359 402 225 237 243 250 193 205 211 218 191 8976 172 189 188 161 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 160)) + (862 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 162 163 165 8359 402 225 237 243 250 241 209 170 186 191 8976 172 189 188 161 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 160)) + (863 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 194 224 182 231 234 235 232 239 238 8215 192 167 201 200 202 244 203 207 251 249 164 212 220 162 163 217 219 402 166 180 243 250 168 184 179 175 206 8976 172 189 188 190 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 160)) + (864 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 176 183 8729 8730 9618 9472 9474 9532 9508 9516 9500 9524 9488 9484 9492 9496 946 8734 966 177 189 188 8776 171 187 65271 65272 155 156 65275 65276 159 160 173 65154 163 164 65156 65533 65533 65166 65167 65173 65177 1548 65181 65185 65189 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 65233 1563 65201 65205 65209 1567 162 65152 65153 65155 65157 65226 65163 65165 65169 65171 65175 65179 65183 65187 65191 65193 65195 65197 65199 65203 65207 65211 65215 65217 65221 65227 65231 166 172 247 215 65225 1600 65235 65239 65243 65247 65251 65255 65259 65261 65263 65267 65213 65228 65230 65229 65249 65149 1617 65253 65257 65260 65264 65266 65232 65237 65269 65270 65245 65241 65265 9632 65533)) + (865 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 199 252 233 226 228 224 229 231 234 235 232 239 238 236 196 197 201 230 198 244 246 242 251 249 255 214 220 248 163 216 8359 402 225 237 243 250 241 209 170 186 191 8976 172 189 188 161 171 164 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 160)) + (866 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1025 1105 1028 1108 1031 1111 1038 1118 176 8729 183 8730 8470 164 9632 160)) + (869 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 902 135 183 172 166 8216 8217 904 8213 905 906 938 908 147 148 910 939 169 911 178 179 940 163 941 942 943 970 912 972 973 913 914 915 916 917 918 919 189 920 921 171 187 9617 9618 9619 9474 9508 922 923 924 925 9571 9553 9559 9565 926 927 9488 9492 9524 9516 9500 9472 9532 928 929 9562 9556 9577 9574 9568 9552 9580 931 932 933 934 935 936 937 945 946 947 9496 9484 9608 9604 948 949 9600 950 951 952 953 954 955 956 957 958 959 960 961 963 962 964 900 173 177 965 966 967 167 968 901 176 168 969 971 944 974 9632 160)) + (1250 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 131 8222 8230 8224 8225 136 8240 352 8249 346 356 381 377 144 8216 8217 8220 8221 8226 8211 8212 152 8482 353 8250 347 357 382 378 160 711 728 321 164 260 166 167 168 169 350 171 172 173 174 379 176 177 731 322 180 181 182 183 184 261 351 187 317 733 318 380 340 193 194 258 196 313 262 199 268 201 280 203 282 205 206 270 272 323 327 211 212 336 214 215 344 366 218 368 220 221 354 223 341 225 226 259 228 314 263 231 269 233 281 235 283 237 238 271 273 324 328 243 244 337 246 247 345 367 250 369 252 253 355 729)) + (1251 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1026 1027 8218 1107 8222 8230 8224 8225 8364 8240 1033 8249 1034 1036 1035 1039 1106 8216 8217 8220 8221 8226 8211 8212 152 8482 1113 8250 1114 1116 1115 1119 160 1038 1118 1032 164 1168 166 167 1025 169 1028 171 172 173 174 1031 176 177 1030 1110 1169 181 182 183 1105 8470 1108 187 1112 1029 1109 1111 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103)) + (1252 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 402 8222 8230 8224 8225 710 8240 352 8249 338 141 381 143 144 8216 8217 8220 8221 8226 8211 8212 732 8482 353 8250 339 157 382 376 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255)) + (1253 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 402 8222 8230 8224 8225 136 8240 138 8249 140 141 142 143 144 8216 8217 8220 8221 8226 8211 8212 152 8482 154 8250 156 157 158 159 160 901 902 163 164 165 166 167 168 169 65533 171 172 173 174 8213 176 177 178 179 900 181 182 183 904 905 906 187 908 189 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 65533 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 65533)) + (1254 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 402 8222 8230 8224 8225 710 8240 352 8249 338 141 142 143 144 8216 8217 8220 8221 8226 8211 8212 732 8482 353 8250 339 157 158 376 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 286 209 210 211 212 213 214 215 216 217 218 219 220 304 350 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 287 241 242 243 244 245 246 247 248 249 250 251 252 305 351 255)) + (1255 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 402 8222 8230 8224 8225 710 8240 138 8249 140 141 142 143 144 8216 8217 8220 8221 8226 8211 8212 732 8482 154 8250 156 157 158 159 160 161 162 163 8362 165 166 167 168 169 215 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 247 187 188 189 190 191 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1520 1521 1522 1523 1524 65533 65533 65533 65533 65533 65533 65533 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 65533 65533 8206 8207 65533)) + (1256 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 1662 8218 402 8222 8230 8224 8225 710 8240 1657 8249 338 1670 1688 1672 1711 8216 8217 8220 8221 8226 8211 8212 1705 8482 1681 8250 339 8204 8205 1722 160 1548 162 163 164 165 166 167 168 169 1726 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 1563 187 188 189 190 1567 1729 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 215 1591 1592 1593 1594 1600 1601 1602 1603 224 1604 226 1605 1606 1607 1608 231 232 233 234 235 1609 1610 238 239 1611 1612 1613 1614 244 1615 1616 247 1617 249 1618 251 252 8206 8207 1746)) + (1257 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 131 8222 8230 8224 8225 136 8240 138 8249 140 168 711 184 144 8216 8217 8220 8221 8226 8211 8212 152 8482 154 8250 156 175 731 159 160 65533 162 163 164 65533 166 167 216 169 342 171 172 173 174 198 176 177 178 179 180 181 182 183 248 185 343 187 188 189 190 230 260 302 256 262 196 197 280 274 268 201 377 278 290 310 298 315 352 323 325 211 332 213 214 215 370 321 346 362 220 379 381 223 261 303 257 263 228 229 281 275 269 233 378 279 291 311 299 316 353 324 326 243 333 245 246 247 371 322 347 363 252 380 382 729)) + (1258 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 8364 129 8218 402 8222 8230 8224 8225 710 8240 138 8249 338 141 142 143 144 8216 8217 8220 8221 8226 8211 8212 732 8482 154 8250 339 157 158 376 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 258 196 197 198 199 200 201 202 203 768 205 206 207 272 209 777 211 212 416 214 215 216 217 218 219 220 431 771 223 224 225 226 259 228 229 230 231 232 233 234 235 769 237 238 239 273 241 803 243 244 417 246 247 248 249 250 251 252 432 8363 255))) + "A list of 8-bit Windows code pages where each element is a +cons with the car being the ID of the code page and the cdr being +a vector enumerating the corresponding character codes.")
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/foo.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/foo.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/index.html =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/index.html 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/doc/index.html 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,1044 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <title>FLEXI-STREAMS - Flexible bivalent streams for Common Lisp</title> + <style type="text/css"> + pre { padding:5px; background-color:#e0e0e0 } + h3, h4 { text-decoration: underline; } + a { text-decoration: none; padding: 1px 2px 1px 2px; } + a:visited { text-decoration: none; padding: 1px 2px 1px 2px; } + a:hover { text-decoration: none; padding: 1px 1px 1px 1px; border: 1px solid #000000; } + a:focus { text-decoration: none; padding: 1px 2px 1px 2px; border: none; } + a.none { text-decoration: none; padding: 0; } + a.none:visited { text-decoration: none; padding: 0; } + a.none:hover { text-decoration: none; border: none; padding: 0; } + a.none:focus { text-decoration: none; border: none; padding: 0; } + a.noborder { text-decoration: none; padding: 0; } + a.noborder:visited { text-decoration: none; padding: 0; } + a.noborder:hover { text-decoration: none; border: none; padding: 0; } + a.noborder:focus { text-decoration: none; border: none; padding: 0; } + </style> +</head> + +<body bgcolor=white> + +<h2>FLEXI-STREAMS - Flexible bivalent streams for Common Lisp</h2> + +<blockquote> +<br> <br><h3><a name=abstract class=none>Abstract</a></h3> + +FLEXI-STREAMS implements "virtual" bivalent streams that can be +layered atop real binary or bivalent streams and that can be used to +read and write character data in various single- or multi-octet +encodings which can be changed on the fly. It also supplies +<em>in-memory</em> binary streams which are similar to string streams. +<p> +The library needs a Common Lisp implementation that +supports <a +href="http://www.nhplace.com/kent/CL/Issues/stream-definition-by-user.html%22%3E<em>Gray +streams</em></a> and relies on David +Lichteblau's <a +href="http://www.cliki.net/trivial-gray-streams%22%3Etrivial-gray-streams</a> +to offer portability between different Lisps. +<p> +The code comes with +a <a +href="http://www.opensource.org/licenses/bsd-license.php%22%3EBSD-style +license</a> so you can basically do with it whatever you want. + +<p> +<font color=red>Download shortcut:</font> <a href="http://weitz.de/files/flexi-streams.tar.gz">http://weitz.de/files/flexi-streams.tar.gz</a>. +</blockquote> + +<br> <br><h3><a class=none name="contents">Contents</a></h3> +<ol> + <li><a href="#example">Example usage</a> + <li><a href="#install">Download and installation</a> + <li><a href="#backward-compatibility">Backward compatibility with version 0.10.3 and before</a> + <li><a href="#mail">Support and mailing lists</a> + <li><a href="#dictionary">The FLEXI-STREAMS dictionary</a> + <ol> + <li><a href="#external-formats">External formats</a> + <ol> + <li><a href="#make-external-format"><code>make-external-format</code></a> + <li><a href="#external-format-name"><code>external-format-name</code></a> + <li><a href="#external-format-eol-style"><code>external-format-eol-style</code></a> + <li><a href="#external-format-little-endian"><code>external-format-little-endian</code></a> + <li><a href="#external-format-id"><code>external-format-id</code></a> + <li><a href="#external-format-equal"><code>external-format-equal</code></a> + <li><a href="#*default-eol-style*"><code>*default-eol-style*</code></a> + <li><a href="#*default-little-endian*"><code>*default-little-endian*</code></a> + </ol> + <li><a href="#flexi-streams">Flexi streams</a> + <ol> + <li><a href="#flexi-stream"><code>flexi-stream</code></a> + <li><a href="#flexi-input-stream"><code>flexi-input-stream</code></a> + <li><a href="#flexi-output-stream"><code>flexi-output-stream</code></a> + <li><a href="#flexi-io-stream"><code>flexi-io-stream</code></a> + <li><a href="#make-flexi-stream"><code>make-flexi-stream</code></a> + <li><a href="#flexi-stream-external-format"><code>flexi-stream-external-format</code></a> + <li><a href="#flexi-stream-element-type"><code>flexi-stream-element-type</code></a> + <li><a href="#flexi-stream-column"><code>flexi-stream-column</code></a> + <li><a href="#flexi-stream-position"><code>flexi-stream-position</code></a> + <li><a href="#flexi-stream-bound"><code>flexi-stream-bound</code></a> + <li><a href="#flexi-stream-stream"><code>flexi-stream-stream</code></a> + <li><a href="#unread-byte"><code>unread-byte</code></a> + <li><a href="#peek-byte"><code>peek-byte</code></a> + <li><a href="#*substitution-char*"><code>*substitution-char*</code></a> + <li><a href="#octet"><code>octet</code></a> + <li><a href="#flexi-stream-error"><code>flexi-stream-error</code></a> + <li><a href="#flexi-stream-encoding-error"><code>flexi-stream-encoding-error</code></a> + <li><a href="#flexi-stream-element-type-error"><code>flexi-stream-element-type-error</code></a> + <li><a href="#flexi-stream-element-type-error-element-type"><code>flexi-stream-element-type-error-element-type</code></a> + <li><a href="#flexi-stream-position-spec-error"><code>flexi-stream-position-spec-error</code></a> + <li><a href="#flexi-stream-position-spec-error-position-spec"><code>flexi-stream-position-spec-error-position-spec</code></a> + </ol> + <li><a href="#in-memory">In-memory streams</a> + <ol> + <li><a href="#in-memory-stream"><code>in-memory-stream</code></a> + <li><a href="#in-memory-input-stream"><code>in-memory-input-stream</code></a> + <li><a href="#in-memory-output-stream"><code>in-memory-output-stream</code></a> + <li><a href="#list-stream"><code>list-stream</code></a> + <li><a href="#vector-stream"><code>vector-stream</code></a> + <li><a href="#make-in-memory-input-stream"><code>make-in-memory-input-stream</code></a> + <li><a href="#make-in-memory-output-stream"><code>make-in-memory-output-stream</code></a> + <li><a href="#get-output-stream-sequence"><code>get-output-stream-sequence</code></a> + <li><a href="#output-stream-sequence-length"><code>output-stream-sequence-length</code></a> + <li><a href="#with-input-from-sequence"><code>with-input-from-sequence</code></a> + <li><a href="#with-output-to-sequence"><code>with-output-to-sequence</code></a> + <li><a href="#in-memory-stream-error"><code>in-memory-stream-error</code></a> + <li><a href="#in-memory-stream-closed-error"><code>in-memory-stream-closed-error</code></a> + </ol> + <li><a href="#strings">Strings</a> + <ol> + <li><a href="#string-to-octets"><code>string-to-octets</code></a> + <li><a href="#octets-to-string"><code>octets-to-string</code></a> + </ol> + </ol> + <li><a href="#position">File positions</a> + <li><a href="#ack">Acknowledgements</a> +</ol> + +<br> <br><h3><a name="example" class=none>Example usage</a></h3> + +The examples were created with <a href="http://www.lispworks.com/">LispWorks</a> 4.4.6 pro on Windows. The following two functions create <a href="foo.txt">the same file</a>: + +<pre> +(defun foo (pathspec) + "With standard LispWorks streams." + (with-open-file (out pathspec + :direction :output + :if-exists :supersede + :external-format '(:utf-8 :eol-style :crlf)) + (write-line "ÄÖÜ1" out)) + (with-open-file (out pathspec + :direction :output + :if-exists :append + :external-format '(:latin-1 :eol-style :lf)) + (write-line "ÄÖÜ2" out)) + (with-open-file (out pathspec + :direction :output + :if-exists :append + :element-type 'octet) + (write-byte #xeb out) + (write-sequence #(#xa3 #xa4 #xa5) out)) + (with-open-file (out pathspec + :direction :output + :if-exists :append + :external-format '(:unicode :little-endian nil :eol-style :crlf)) + (write-line "ÄÖÜ3" out))) + +(defun bar (pathspec) + "With a <a href="#flexi-streams" class=noborder>flexi stream</a>." + (with-open-file (out pathspec + :direction :output + :if-exists :supersede + :external-format '(:latin-1 :eol-style :lf)) + (setq out (<a href="#make-flexi-stream" class=noborder>make-flexi-stream</a> out <a href="#external-formats" class=noborder>:external-format</a> :utf-8)) + (write-line "ÄÖÜ1" out) + (setf (<a href="#flexi-stream-external-format" class=noborder>flexi-stream-external-format</a> out) '(:latin-1 :eol-style :lf)) + (write-line "ÄÖÜ2" out) + (write-byte #xeb out) + (write-sequence #(#xa3 #xa4 #xa5) out) + (setf (flexi-stream-external-format out) :ucs-2be) + (write-line "ÄÖÜ3" out))) +</pre> + +<p> +And applying this function +<pre> +(defun baz (pathspec) + (let (result) + (with-open-file (in pathspec :element-type '<a href="#octet" class=noborder>octet</a>) + (setq in (<a href="#make-flexi-stream" class=noborder>make-flexi-stream</a> in <a href="#external-formats" class=noborder>:external-format</a> :utf-8)) + (push (read-line in) result) + (push (read-byte in) result) + (setf (<a href="#flexi-stream-external-format" class=noborder>flexi-stream-external-format</a> in) '(:latin-1 :eol-style :lf)) + (push (read-line in) result) + (setf (flexi-stream-external-format in) :greek) + (push (read-char in) result) + (setf (flexi-stream-external-format in) :latin0) + (let ((string (make-string 3 :element-type 'character))) + (read-sequence string in) + (push string result)) + (let ((octets (make-array 2 :element-type 'octet))) + (read-sequence octets in) + (push octets result)) + (setf (flexi-stream-external-format in) :ucs-2be) + (push (read-line in) result)) + (nreverse result))) +</pre> +to the file created above will yield the list +<pre> +("ÄÖÜ1" 196 "ÖÜ2" #λ "£€¥" #(0 196) "ÖÜ3") +</pre> + +<p> +For more examples see the source code +of <a +href="http://weitz.de/drakma/%22%3EDrakma</a>, <a +href="http://weitz.de/chunga/%22%3EChunga</a>, +or <a href="http://weitz.de/cl-wbxml/">CL-WBXML</a>. + +<br> <br><h3><a name="install" class=none>Download and installation</a></h3> + +Before you try to install FLEXI-STREAMS, first check that in your Lisp +each <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/13_.htm%22%3Echaracter</a>'s +<a +href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_c.htm#character... +code</a> is equal to +its <a +href="http://en.wikipedia.org/wiki/Unicode%22%3EUnicode</a> <a +href="http://unicode.org/glossary/%22%3Ecode point</a> and +that <code>(CHAR-CODE #\Newline)</code> +and <code>(CHAR-CODE #\Linefeed)</code> have the same +value (10). (This is the case for all relevant CL +implementations which were in use when this library was written. It +is <em>not</em> mandated by the ANSI standard, though.) +<p> +FLEXI-STREAMS together with this documentation can be downloaded from <a +href="http://weitz.de/files/flexi-streams.tar.gz%22%3Ehttp://weitz.de/files/flexi-...</a>. The +current version is 0.13.1. +<p> +Before you install FLEXI-STREAMS you first need to +install the <a +href="http://www.cliki.net/trivial-gray-streams%22%3Etrivial-gray-streams</a> library +unless you already have it. +<p> +FLEXI-STREAMS comes with a system definition for <a +href="http://www.cliki.net/asdf%22%3EASDF</a> so you can install the library with +<pre> +(asdf:oos 'asdf:load-op :flexi-streams) +</pre> +if you've unpacked it in a place where ASDF can find it. Installation +via <a href="http://www.cliki.net/asdf-install">asdf-install</a> +should also be possible, and there's a port +to <a href="http://www.cliki.net/Gentoo">Gentoo Lisp</a> thanks to +Matthew Kennedy. +<p> +You can run a test suite which tests <em>some</em> (but +not <em>all</em>) aspects of the library with +<pre> +(asdf:oos 'asdf:test-op :flexi-streams) +</pre> +This might take a while... +<p> +Luís Oliveira maintains a <a href="http://darcs.net/">darcs</a> +repository of FLEXI-STREAMS +at <a href="http://common-lisp.net/%7Eloliveira/ediware/">http://common-lisp.net/~loliveira/ediware/</a>. +<p> +A <a href="http://www.selenic.com/mercurial/wiki/">Mercurial</a> +repository of older versions is available +at <a +href="http://arcanes.fr.eu.org/~pierre/2007/02/weitz/%22%3Ehttp://arcanes.fr.eu.or...</a> +thanks to Pierre Thierry. + +<!-- this chapter may be removed after several versions --> +<br> <br> +<h3><a name="backward-compatibility" class=none> +Backward compatibility with version 0.10.3 and before</a></h3> + +Two special variables used in flexi-streams 0.10.3 and before were removed - +<code>*PROVIDE-USE-VALUE-RESTART*</code> and <code>*USE-REPLACEMENT-CHAR*</code>. + +<p> +The code now behaves as if +<code>*PROVIDE-USE-VALUE-RESTART*</code> is always <code>T</code>. +Instead of <code>*USE-REPLACEMENT-CHAR*</code>, you can use +<a href="#*substitution-char*"><code>*SUBSTITUTION-CHAR*</code></a> or +invoke +a <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/r_use_va.htm%22%3E<code>USE-VALUE</code> +restart</a> +when a <a +href="#flexi-stream-encoding-error"><code>FLEXI-STREAM-ENCODING-ERROR</code></a> +is signaled. + +<br> <br><h3><a name="mail" class=none>Support and mailing lists</a></h3> + +For questions, bug reports, feature requests, improvements, or patches +please use the <a +href="http://common-lisp.net/mailman/listinfo/flexi-streams-devel%22%3Eflexi-strea... +mailing list</a>. If you want to be notified about future releases, +subscribe to the <a +href="http://common-lisp.net/mailman/listinfo/flexi-streams-announce%22%3Eflexi-st... +mailing list</a>. These mailing lists were made available thanks to +the services of <a href="http://common-lisp.net/">common-lisp.net</a>. +<p> +If you want to send patches, please <a href="http://weitz.de/patches.html">read this first</a>. + + +<br> <br><h3><a class=none name="dictionary">The FLEXI-STREAMS dictionary</a></h3> + +<h4><a name="external-formats" class=none>External formats</a></h4> + +<code>EXTERNAL-FORMAT</code> objects are used to denote the external +formats of <a href="#flexi-streams">flexi streams</a>. These objects are created using +the <a +href="#make-external-format"><code>MAKE-EXTERNAL-FORMAT</code></a> +function, and there are <a href="#external-format-name">various +readers</a> to query their attributes. Once such an object is +created it can't be changed. +<p> +An external format consists of a basic encoding +(like <a +href="http://en.wikipedia.org/wiki/Iso-8859-1%22%3EISO%C2%A08859-1</a> +or <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a>), a +definition how line endings are denoted - by a carriage return +character (ASCII 13), by a line feed character (ASCII 10), +or by both of these characters in a row -, and optionally (for +encodings that use units larger than 8 bits) information +about the <a href="http://en.wikipedia.org/wiki/Endian">endianess</a> +of the encoding. +<p> +The following encodings are currently supported by FLEXI-STREAMS: +<ul> +<li><a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> (denoted by the keyword <code>:UTF-8</code>), +<li><a href="http://en.wikipedia.org/wiki/UTF-16">UTF-16</a> (denoted by the keyword <code>:UTF-16</code>), +<li><a href="http://en.wikipedia.org/wiki/UTF-32">UTF-32</a> (denoted by the keyword <code>:UTF-32</code>), +<li>all <a href="http://czyborra.com/charsets/iso8859.html">ISO 8859</a> character sets (denoted by keywords like <code>:ISO-8859-15</code>), +<li><a href="http://en.wikipedia.org/wiki/KOI8-R">KOI8-R</a> (denoted by the keyword <code>:KOI8-R</code>), +<li>a couple +of <a href="http://czyborra.com/charsets/codepages.html">Windows code +pages</a> (denoted by the keyword <code>:CODE-PAGE</code> and an +obligatory <code>:ID</code> argument), and +<li><a href="http://en.wikipedia.org/wiki/ASCII">US-ASCII</a>. +</ul> +<p> +A couple of alternative names are allowed that are listed below: +<p> +<table border=1> +<tr><td><code>:UTF-8</code></td><td><code>:UTF8</code></td></tr> +<tr><td rowspan=4 valign=top><code>:UTF-16</code></td><td><code>:UTF16</code></td></tr> +<tr><td><code>:UCS-2</code></td></tr> +<tr><td><code>:UCS2</code></td></tr> +<tr><td><code>:UNICODE</code></td></tr> +<tr><td rowspan=3 valign=top><code>:UTF-32</code></td><td><code>:UTF32</code></td></tr> +<tr><td><code>:UCS-4</code></td></tr> +<tr><td><code>:UCS4</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-1</code></td><td><code>:LATIN-1</code></td></tr> +<tr><td><code>:LATIN1</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-2</code></td><td><code>:LATIN-2</code></td></tr> +<tr><td><code>:LATIN2</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-3</code></td><td><code>:LATIN-3</code></td></tr> +<tr><td><code>:LATIN3</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-4</code></td><td><code>:LATIN-4</code></td></tr> +<tr><td><code>:LATIN4</code></td></tr> +<tr><td><code>:ISO-8859-5</code></td><td><code>:CYRILLIC</code></td></tr> +<tr><td><code>:ISO-8859-6</code></td><td><code>:ARABIC</code></td></tr> +<tr><td><code>:ISO-8859-7</code></td><td><code>:GREEK</code></td></tr> +<tr><td><code>:ISO-8859-8</code></td><td><code>:HEBREW</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-9</code></td><td><code>:LATIN-5</code></td></tr> +<tr><td><code>:LATIN5</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-10</code></td><td><code>:LATIN-6</code></td></tr> +<tr><td><code>:LATIN6</code></td></tr> +<tr><td><code>:ISO-8859-11</code></td><td><code>:THAI</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-13</code></td><td><code>:LATIN-7</code></td></tr> +<tr><td><code>:LATIN7</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-14</code></td><td><code>:LATIN-8</code></td></tr> +<tr><td><code>:LATIN8</code></td></tr> +<tr><td rowspan=4 valign=top><code>:ISO-8859-15</code></td><td><code>:LATIN-9</code></td></tr> +<tr><td><code>:LATIN9</code></td></tr> +<tr><td><code>:LATIN-0</code></td></tr> +<tr><td><code>:LATIN0</code></td></tr> +<tr><td rowspan=2 valign=top><code>:ISO-8859-16</code></td><td><code>:LATIN-10</code></td></tr> +<tr><td><code>:LATIN10</code></td></tr> +<tr><td rowspan=2 valign=top><code>:CODE-PAGE</code></td><td><code>:CODEPAGE</code></td></tr> +<tr><td><code>WIN32:CODE-PAGE<br>(only on <a href="http://www.lispworks.com/products/lww.html">LWW</a>)</code></td></tr> +<tr><td><code>:KOI8-R</code></td><td><code>:KOI8R</code></td></tr> +<tr><td><code>:US-ASCII</code></td><td><code>:ASCII</code></td></tr> +</table> +<p> +(Note that we treat UCS-2 exactly like UTF-16 although there +are <a href="http://en.wikipedia.org/wiki/UTF-16">subtle +differences</a>. Also note that even though we support encodings like +UTF-32 some Lisps only supports characters contained within +the <a +href="http://en.wikipedia.org/wiki/Basic_Multilingual_Plane%22%3EBasic +Multilingual Plane</a> (like LispWorks) or even less (like CMUCL), so +if other characters are read from a +<a href="#flexi-streams">flexi +stream</a>, <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_cha.htm%22%3E<code>READ-CHAR</code></a> +will try to be helpful and return the corresponding Unicode code point - +an integer - instead. This might lead to an error if you're using +functions +like <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_lin.htm%22%3E<code>READ-LINE</code></a>, though.) + +<p> +Whenever a FLEXI-STREAMS function accepts an external format as one of +its arguments, you can provide either an <code>EXTERNAL-FORMAT</code> +object or a shortcut which can be a list or a symbol. The list +shortcuts have a syntax similar +to <a +href="http://www.lispworks.com/documentation/lw50/LWUG/html/lwuser-360.htm%22%3Eth... +one used by LispWorks</a> - the cars are the names of and encoding +and the cdrs of these lists correspond to the keyword arguments +to <a +href="#make-external-format"><code>MAKE-EXTERNAL-FORMAT</code></a>, so +for example +<pre>(:latin-1 :eol-style :crlf)</pre> +is equivalent to +<pre>(<a class=noborder href="#make-external-format">make-external-format</a> :latin-1 :eol-style :crlf)</pre> The +symbol shortcuts are equivalent to +calling <a +href="#make-external-format"><code>MAKE-EXTERNAL-FORMAT</code></a> +without keyword arguments, i.e. +<pre>:thai</pre> +behaves like +<pre>(<a class=noborder href="#make-external-format">make-external-format</a> :thai)</pre> +Finally, the following expansions are +available: +<p> +<table border=1> +<tr><td><code>:UCS-2LE</code></td><td><code>(:UCS-2 :LITTLE-ENDIAN T)</code></td></tr> +<tr><td><code>:UCS-2BE</code></td><td><code>(:UCS-2 :LITTLE-ENDIAN NIL)</code></td></tr> +<tr><td><code>:UCS-4LE</code></td><td><code>(:UCS-4 :LITTLE-ENDIAN T)</code></td></tr> +<tr><td><code>:UCS-4BE</code></td><td><code>(:UCS-4 :LITTLE-ENDIAN NIL)</code></td></tr> +<tr><td><code>:UTF-16LE</code></td><td><code>(:UTF-16 :LITTLE-ENDIAN T)</code></td></tr> +<tr><td><code>:UTF-16BE</code></td><td><code>(:UTF-16 :LITTLE-ENDIAN NIL)</code></td></tr> +<tr><td><code>:UTF-32LE</code></td><td><code>(:UTF-32 :LITTLE-ENDIAN T)</code></td></tr> +<tr><td><code>:UTF-32BE</code></td><td><code>(:UTF-32 :LITTLE-ENDIAN NIL)</code></td></tr> +<tr><td><code>:IBM437</code></td><td><code>(:CODE-PAGE :ID 437)</code></td></tr> +<tr><td><code>:IBM850</code></td><td><code>(:CODE-PAGE :ID 850)</code></td></tr> +<tr><td><code>:IBM852</code></td><td><code>(:CODE-PAGE :ID 852)</code></td></tr> +<tr><td><code>:IBM855</code></td><td><code>(:CODE-PAGE :ID 855)</code></td></tr> +<tr><td><code>:IBM857</code></td><td><code>(:CODE-PAGE :ID 857)</code></td></tr> +<tr><td><code>:IBM860</code></td><td><code>(:CODE-PAGE :ID 860)</code></td></tr> +<tr><td><code>:IBM861</code></td><td><code>(:CODE-PAGE :ID 861)</code></td></tr> +<tr><td><code>:IBM862</code></td><td><code>(:CODE-PAGE :ID 862)</code></td></tr> +<tr><td><code>:IBM863</code></td><td><code>(:CODE-PAGE :ID 863)</code></td></tr> +<tr><td><code>:IBM864</code></td><td><code>(:CODE-PAGE :ID 864)</code></td></tr> +<tr><td><code>:IBM865</code></td><td><code>(:CODE-PAGE :ID 865)</code></td></tr> +<tr><td><code>:IBM866</code></td><td><code>(:CODE-PAGE :ID 866)</code></td></tr> +<tr><td><code>:IBM869</code></td><td><code>(:CODE-PAGE :ID 869)</code></td></tr> +<tr><td><code>:WINDOWS-1250</code></td><td><code>(:CODE-PAGE :ID 1250)</code></td></tr> +<tr><td><code>:WINDOWS-1251</code></td><td><code>(:CODE-PAGE :ID 1251)</code></td></tr> +<tr><td><code>:WINDOWS-1252</code></td><td><code>(:CODE-PAGE :ID 1252)</code></td></tr> +<tr><td><code>:WINDOWS-1253</code></td><td><code>(:CODE-PAGE :ID 1253)</code></td></tr> +<tr><td><code>:WINDOWS-1254</code></td><td><code>(:CODE-PAGE :ID 1254)</code></td></tr> +<tr><td><code>:WINDOWS-1255</code></td><td><code>(:CODE-PAGE :ID 1255)</code></td></tr> +<tr><td><code>:WINDOWS-1256</code></td><td><code>(:CODE-PAGE :ID 1256)</code></td></tr> +<tr><td><code>:WINDOWS-1257</code></td><td><code>(:CODE-PAGE :ID 1257)</code></td></tr> +<tr><td><code>:WINDOWS-1258</code></td><td><code>(:CODE-PAGE :ID 1258)</code></td></tr> +</table> +<p> +Note that if you provide a shortcut, it +will be converted to an <code>EXTERNAL-FORMAT</code> object first. +So, if you're concerned about efficiency, create these objects once and +re-use them. + +<p><br>[Function] +<br><a class=none name="make-external-format"><b>make-external-format</b> <i>name <tt>&key</tt> eol-style little-endian id</i> => <i>external-format</i></a> + +<blockquote><br> Creates and returns +an <a href="#external-formats"><code>EXTERNAL-FORMAT</code> +object</a>. <code><i>name</i></code> is a +symbol, <code><i>eol-style</i></code> is one of the +keywords <code>:CR</code>, <code>:LF</code>, or <code>:CRLF</code>, +and <code><i>little-endian</i></code> is +a <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_g.htm#generaliz... +boolean</a>. The default value for <code><i>eol-style</i></code> is the value of <a href="#*default-eol-style*"><code>*DEFAULT-EOL-STYLE*</code></a> except for Windows code pages where it is <code>:CRLF</code>. The default value +for <code><i>little-endian</i></code> is the value of <a href="#*default-little-endian*"><code>*DEFAULT-LITTLE-ENDIAN*</code></a> - this value is ignored unless <code><i>name</i></code> denotes one of UTF-16 or UTF-32. +<code><i>id</i></code> must be an integer denoting a Windows code page +known by FLEXI-STREAMS if <code><i>name</i></code> +is <code>:CODE-PAGE</code> or <code>WIN32:CODE-PAGE</code>, otherwise +the value is ignored. See <a href="#external-formats">the section +about external formats</a> for more info. +<p> +Examples (run on Windows): + +<pre> +CL-USER 1 > (make-external-format :latin-1) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:ISO-8859-1 :EOL-STYLE :CRLF) 2067DA84> + +CL-USER 2 > (make-external-format :latin-1 :eol-style :lf) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:ISO-8859-1 :EOL-STYLE :LF) 2068B4D4> + +CL-USER 3 > (make-external-format :ibm437) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:CODE-PAGE :ID 437 :EOL-STYLE :CRLF) 2069B33C> + +CL-USER 4 > (make-external-format :ucs-2) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:UTF-16 :EOL-STYLE :CRLF :LITTLE-ENDIAN T) 206B4F4C> + +CL-USER 5 > (make-external-format :ucs-2be) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:UTF-16 :EOL-STYLE :CRLF :LITTLE-ENDIAN NIL) 2067DBE4> + +CL-USER 6 > (make-external-format :ucs-2be :eol-style :br) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:UTF-16 :EOL-STYLE :BR :LITTLE-ENDIAN NIL) 206B54AC> +</pre> +</blockquote> + +<p><br>[Readers] +<br><a class=none name="external-format-name"><b>external-format-name</b> <i>external-format</i> => <i>name</i></a> +<br><a class=none name="external-format-eol-style"><b>external-format-eol-style</b> <i>external-format</i> => <i>eol-style</i></a> +<br><a class=none name="external-format-little-endian"><b>external-format-little-endian</b> <i>external-format</i> => <i>little-endian</i></a> +<br><a class=none name="external-format-id"><b>external-format-id</b> <i>external-format</i> => <i>id</i></a> + +<blockquote><br> +These methods can be used to query an <a href="#external-formats"><code>EXTERNAL-FORMAT</code> object</a> for its attributes. +</blockquote> + +<p><br>[Functions] +<br><a class=none name="external-format-equal"><b>external-format-equal</b> <i>external-format-1 external-format-2</i> => <i>generalized-boolean</i></a> + +<blockquote><br> +Checks whether the two <a href="#external-formats">external formats</a> <code><i>external-format-1</i></code> and <code><i>external-format-2</i></code> are equivalent with respect to their effects on <a href="#flexi-streams">flexi streams</a>. +<p> +Examples (run on Windows): + +<pre> +CL-USER 1 > (<a href="#make-external-format" class=noborder>make-external-format</a> :ucs-4le) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:UTF-32 :EOL-STYLE :CRLF :LITTLE-ENDIAN T) 2067FB74> + +CL-USER 2 > (external-format-equal <a href="http://www.lispworks.com/documentation/HyperSpec/Body/v__stst_.htm" class=noborder>*</a> (make-external-format :utf32 :little-endian t)) +T + +CL-USER 3 > (make-external-format :code-page :id 437) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:CODE-PAGE :ID 437 :EOL-STYLE :CRLF) 2069428C> + +CL-USER 4 > (external-format-equal * (make-external-format :ibm437)) +T +</pre> + +</blockquote> + +<p><br>[Special variable] +<br><a class=none name="*default-eol-style*"><b>*default-eol-style*</b></a> + +<blockquote><br> +The default value for the <code><i>eol-style</i></code> keyword argument of <a href="#make-external-format"><code>MAKE-EXTERNAL-FORMAT</code></a>. Its initial value is <code>:CRLF</code> on Windows and <code>:LF</code> on other operating systems. +</blockquote> + +<p><br>[Special variable] +<br><a class=none name="*default-little-endian*"><b>*default-little-endian*</b></a> + +<blockquote><br> +The default value for the <code><i>little-endian</i></code> keyword argument of <a href="#make-external-format"><code>MAKE-EXTERNAL-FORMAT</code></a>. Its initial value corresponds to the endianess of the platform FLEXI-STREAMS is used on as revealed by the <code>:LITTLE-ENDIAN</code> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/24_ab.htm">feature</a>. +</blockquote> + +<h4><a name="flexi-streams" class=none>Flexi streams</a></h4> + +<em>Flexi streams</em> are the core of the FLEXI-STREAMS library. You +create them using the +function <a +href="#make-flexi-stream"><code>MAKE-FLEXI-STREAM</code></a> which +takes an open binary stream (called the <em>underlying</em> stream) as its only required argument. +A <em>binary</em> stream in this context means that if it's an <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_i.htm#input">input +stream</a>, you can read from it with +<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_by.htm"><code>READ-BYTE</code></a> +(or, as a workaround for LispWorks, you can at least apply +<a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_seq.htm%22%3E<code>READ-SEQUENCE</code></a> +to it where the sequence is an array of element +type <a href="#octet"><code>OCTET</code></a>), and similarly for +<a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_by.htm#write-byte...<code>WRITE-BYTE</code></a> +(<a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_seq.htm%22%3E<code>WRITE-SEQUENCE</code></a> +for LispWorks) +and <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_o.htm#output%22... +streams</a>. (Note that this specifically holds +for <a +href="http://www.lispworks.com/documentation/lw50/LWRM/html/lwref-91.htm%22%3E<em>bivalent</em> +streams</a> like socket streams.) +<p> +A flexi stream behaves like an ordinary Lisp stream. It is an input +stream if the underlying binary stream is an input stream, and it is +an output stream when the underlying binary stream is an output +stream. You can write characters as well +as <a href="#octet">octets</a> to an output flexi stream and similarly +you can read characters and octets from an input flexi stream. +<p> +A flexi stream always has an <a href="#external-formats">external +format</a> associated with it which is deployed whenever you read +characters from the stream or write characters to it. You +can <a href="#flexi-stream-external-format">change</a> the external +format while you use the stream. +<p> +Once you're using a flexi stream you should <em>not</em> read from or +write to the underlying stream directly anymore. +<p> +If +you <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_close.htm%22%3Eclose</a> +a flexi stream, the underlying stream will also be closed. However, it +also suffices to close the underlying stream directly should you not +want to use the flexi stream anymore. So, the following usage +(where <code>IN</code> is implicitly closed at the end) is OK: +<pre> +(with-open-file (in "/foo/bar/baz.txt") + (let ((flexi (<a href="#make-flexi-stream" class=noborder>make-flexi-stream</a> in <a href="#external-formats" class=noborder>:external-format</a> :hebrew))) + (read-line flexi))) +</pre> +<p> +Output flexi streams will try to keep track of +the <a +href="http://www.lispworks.com/documentation/lw50/LWRM/html/lwref-591.htm%22%3Ecol...</a> +they're in but you can also <a href="#flexi-stream-column">set</a> the +column directly. This value will be incremented by one for each +character written to the stream and it will be set to <code>0</code> +if you send a <code>#\Newline</code> character. The column will be +set to <code>NIL</code> if an <a href="#octet"><code>OCTET</code></a> +is sent to the stream. Once the column is <code>NIL</code> it'll stay +like that unless it is explicitly set to another value. +<p> +Input flexi streams keep track of +their <a href="#flexi-stream-position">position</a> within the stream. +This value is incremented by one for +each <a href="#octet"><code>OCTET</code></a> read from the stream, and +it is incremented by the number of octets actually read for each +character read from the stream. So, if the encoding is UTF-8, reading +the character <code>#ä</code> (a-umlaut) will advance the position by two. +If the encoding is UTF-32 and the end-of-line style +is <code>:CRLF</code>, reading a <code>#\Newline</code> will advance +the position by eight. +<p> +You can also set the <a href="#flexi-stream-bound">bound</a> of an +input flexi stream. Initially it is <code>NIL</code>, but when it's +an integer and the +stream's <a href="#flexi-stream-position">position</a> has gone beyond +this bound, the stream will behave as if no more input is available. +<p> +Caveat: You can +only <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_unrd_c.htm%22%3Eunre...</a> +a character from a flexi stream if you haven't changed the external format after you read it. +<p> +Caveat: The <em>underlying</em> stream should either be a <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_b.htm#binary">binary stream</a> (i.e. have an element type that is a subtype of integer) or it should explicitly use an <a href="http://www.lispworks.com/documentation/lw50/LWUG/html/lwuser-360.htm">external format</a> with <code>:LF</code> as its end-of-line style. Otherwise it might perform unwanted conversion of line endings on its own. (LispWorks <a href="http://article.gmane.org/gmane.lisp.lispworks.general/4859">does this</a> even if you write binary data to the stream using <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_seq.htm"><code>WRITE-SEQUENCE</code></a>.) + +<p><br>[Standard class] +<br><a class=none name="flexi-stream"><b>flexi-stream</b></a> + +<blockquote><br> +Every <a href="#flexi-streams"><em>flexi stream</em></a> returned by <a href="#make-flexi-stream"><code>MAKE-FLEXI-STREAM</code></a> is of this type which is a subtype of <a href="http://www.lispworks.com/documentation/HyperSpec/Body/t_stream.htm"><code>STREAM</code></a>. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="flexi-input-stream"><b>flexi-input-stream</b></a> + +<blockquote><br> +A <a href="#flexi-streams"><em>flexi stream</em></a> is of this type if its underlying stream is an <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_in_stm.htm">input stream</a>. This is a subtype of <a href="#flexi-stream"><code>FLEXI-STREAM</code></a>. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="flexi-output-stream"><b>flexi-output-stream</b></a> + +<blockquote><br> +A <a href="#flexi-streams"><em>flexi stream</em></a> is of this type if its underlying stream is an <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_in_stm.htm">output stream</a>. This is a subtype of <a href="#flexi-stream"><code>FLEXI-STREAM</code></a>. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="flexi-io-stream"><b>flexi-io-stream</b></a> + +<blockquote><br> +A <a href="#flexi-streams"><em>flexi stream</em></a> is of this type if it is both a <a href="#flexi-input-stream"><code>FLEXI-INPUT-STREAM</code></a> as well as a <a href="#flexi-output-stream"><code>FLEXI-OUTPUT-STREAM</code></a>. +</blockquote> + +<p><br>[Function] +<br><a class=none name="make-flexi-stream"><b>make-flexi-stream</b> <i>stream <tt>&key</tt> external-format element-type column position bound</i> => <i>flexi-stream</i></a> + +<blockquote><br> +Creates and returns a <a href="#flexi-streams"><em>flexi stream</em></a>, i.e. an object of type <a href="#flexi-stream"><code>FLEXI-STREAM</code></a>. <code><i>stream</i></code> is the underlying Lisp stream. <code><i>external-format</i></code> is the initial <a href="#external-formats">external format</a> to be used by the stream, the default is the value of evaluating <code>(<a href="#make-external-format">MAKE-EXTERNAL-FORMAT</a> :LATIN1)</code>. <code><i>element-type</i></code> is the initial <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_stm_el.htm">element type</a> of the flexi stream the default of which is <a href="http://www.lispworks.com/documentation/lw50/LWRM/html/lwref-346.htm"><code>LW:SIMPLE-CHAR</code></a> for LispWorks and <a href="http://www.lispworks.com/documentation/HyperSpec/Body/t_ch.htm"><code>CHARACTER</code></a> otherwise. <code><i>column</i></code> is the initial column of the stream and should only be provided for output streams, the default is <code>0</code>. <code><i>position</i></code> is the initial octet position of the stream and must only be provided for input streams, the default is <code>0</code>. <code><i>bound</i></code> should be <code>NIL</code> (the default) or an integer and must only be provided for input streams. If the octet position of the stream has gone beyond this bound, the stream will behave as if no more input is available. See <a href="#flexi-streams">the section about flexi streams</a> for more information. +</blockquote> + +<p><br>[Accessors] +<br><a class=none name="flexi-stream-external-format"><b>flexi-stream-external-format</b> <i>flexi-stream</i> => <i>external-format</i></a> +<br><tt>(setf (</tt><b>flexi-stream-external-format</b> <i>flexi-stream</i>) <i>external-format</i><tt>)</tt> +<br><a class=none name="flexi-stream-element-type"><b>flexi-stream-element-type</b> <i>flexi-stream</i> => <i>element-type</i></a> +<br><tt>(setf (</tt><b>flexi-stream-element-type</b> <i>flexi-stream</i>) <i>element-type</i><tt>)</tt> +<br><a class=none name="flexi-stream-column"><b>flexi-stream-column</b> <i>flexi-output-stream</i> => <i>column</i></a> +<br><tt>(setf (</tt><b>flexi-stream-column</b> <i>flexi-output-stream</i>) <i>column</i><tt>)</tt> +<br><a class=none name="flexi-stream-position"><b>flexi-stream-position</b> <i>flexi-input-stream</i> => <i>position</i></a> +<br><tt>(setf (</tt><b>flexi-stream-position</b> <i>flexi-input-stream</i>) <i>position</i><tt>)</tt> +<br><a class=none name="flexi-stream-bound"><b>flexi-stream-bound</b> <i>flexi-input-stream</i> => <i>bound</i></a> +<br><tt>(setf (</tt><b>flexi-stream-bound</b> <i>flexi-input-stream</i>) <i>bound</i><tt>)</tt> + +<blockquote><br> +These methods can be used to get and set the corresponding attributes of a <a href="#flexi-streams">flexi stream</a>. +<p> +<a href="#flexi-stream-external-format"><code>(SETF +FLEXI-STREAM-EXTERNAL-FORMAT)</code></a> accepts keyword symbols +(<a href="#external-formats">names of external formats</a>), lists +(which should be valid lists of parameters +to <a +href="#make-external-format"><code>MAKE-EXTERNAL-FORMAT</code></a>), or <code>EXTERNAL-FORMAT</code> objects: +<pre> +CL-USER 1 > (setf (flexi-stream-external-format *my-stream*) :ucs-4le) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:UTF-32 :EOL-STYLE :CRLF :LITTLE-ENDIAN T) 206920DC> + +CL-USER 2 > (setf (flexi-stream-external-format *my-stream*) '(:ucs-2be :eol-style :br)) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:UTF-16 :EOL-STYLE :BR :LITTLE-ENDIAN NIL) 20696934> + +CL-USER 3 > (setf (flexi-stream-external-format *my-stream*) (make-external-format :ibm437)) +#<FLEXI-STREAMS::EXTERNAL-FORMAT (:CODE-PAGE :ID 437 :EOL-STYLE :CRLF) 2068716C> +</pre> +</blockquote> + +<p><br>[Reader] +<br><a class=none name="flexi-stream-stream"><b>flexi-stream-stream</b> <i>flexi-stream</i> => <i>stream</i></a> + +<blockquote><br> +This method returns the underlying stream of a <a href="#flexi-streams">flexi stream</a>. +</blockquote> + +<p><br>[Generic function] +<br><a class=none name="unread-byte"><b>unread-byte</b> <i>byte stream</i> => <i>nil</i></a> + +<blockquote><br> +Similar to <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_unrd_c.htm"><code>UNREAD-CHAR</code></a> in that it "unreads" the last <a href="#octet">octet</a> from +<code><i>stream</i></code> which must be a <a href="#flexi-streams">flexi stream</a>. Note that you can only call <code>UNREAD-BYTE</code> after a corresponding +<a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_by.htm"><code>READ-BYTE</code></a>, <em>not</em> after <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_cha.htm"><code>READ-CHAR</code></a>. +</blockquote> + +<p><br>[Generic function] +<br><a class=none name="peek-byte"><b>peek-byte</b> <i>stream <tt>&optional</tt> peek-type eof-error-p eof-value</i> => <i>byte</i></a> + +<blockquote><br> +<code>PEEK-BYTE</code> is like <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_peek_c.htm"><code>PEEK-CHAR</code></a>, i.e. it returns an <a href="#octet">octet</a> from <code><i>stream</i></code> (which must be a <a href="#flexi-streams">flexi stream</a>) +without actually removing it. If <code><i>peek-type</i></code> is <code>NIL</code>, the next octet is +returned, if <code><i>peek-type</i></code> is <code>T</code>, the next octet which is not <code>0</code> is +returned, if <code><i>peek-type</i></code> is an octet, the next octet which equals +<code><i>peek-type</i></code> is returned. <code><i>eof-error-p</i></code> and <code><i>eof-value</i></code> are interpreted as usual. +<p> +Note that the parameters aren't in the same order as with <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_peek_c.htm"><code>PEEK-CHAR</code></a> because it doesn't make much sense to make <code><i>stream</i></code> an optional argument. +</blockquote> + +<p><br>[Special variable] +<br><a class=none name="*substitution-char*"><b>*substitution-char*</b></a> + +<blockquote><br> +If this value is not NIL, it should be a character which is used +(as if by a <a href="http://www.lispworks.com/documentation/HyperSpec/Body/r_use_va.htm"><code>USE-VALUE</code> restart</a>) whenever during reading an error of +type <a href="#flexi-stream-encoding-error"><code>FLEXI-STREAM-ENCODING-ERROR</code></a> would have been signaled otherwise. + +<pre> +CL-USER 1 > (defun foo () + <font color=orange>;; not a valid UTF-8 sequence</font> + (<a href="#with-input-from-sequence" class=noborder>with-input-from-sequence</a> (in '(#xe4 #xf6 #xfc)) + (setq in (<a href="#make-flexi-stream" class=noborder>make-flexi-stream</a> in :external-format :utf8)) + (read-line in))) +FOO + +CL-USER 2 > (foo) + +Error: Unexpected value #xF6 in UTF-8 sequence. + 1 (continue) Specify a character to be used instead. + 2 (abort) Return to level 0. + 3 Return to top loop level 0. + +Type :b for backtrace, :c <option number> to proceed, or :? for other options + +CL-USER 3 : 1 > :c +Type a character: x + +Error: End of file while in UTF-8 sequence. + 1 (continue) Specify a character to be used instead. + 2 (abort) Return to level 0. + 3 Return to top loop level 0. + +Type :b for backtrace, :c <option number> to proceed, or :? for other options + +CL-USER 4 : 1 > :c +Type a character: y +"xy" +T + +CL-USER 5 > (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_handle.htm" class=noborder>handler-bind</a> ((<a href="#flexi-stream-encoding-error" class=noborder>flexi-stream-encoding-error</a> (lambda (condition) + (<a href="http://www.lispworks.com/documentation/HyperSpec/Body/r_use_va.htm" class=noborder>use-value</a> #-)))) + (foo)) +"--" +T + +CL-USER 6 > (let ((<a href="#*SUBSTITUTION-CHAR*" class=noborder>*substitution-char*</a> #?)) + (foo)) +"??" +T +</pre> +</blockquote> + +<p><br>[Type] +<br><a class=none name="octet"><b>octet</b></a> + +<blockquote><br> +Just a shortcut for <code>(UNSIGNED-BYTE 8)</code>. +</blockquote> + +<p><br>[Condition] +<br><a class=none name="flexi-stream-error"><b>flexi-stream-error</b></a> + +<blockquote><br> +All errors related to <a href="#flexi-streams">flexi streams</a> are of this type. This is a subtype of <a href="http://www.lispworks.com/documentation/HyperSpec/Body/e_stm_er.htm"><code>STREAM-ERROR</code></a>. +</blockquote> + +<p><br>[Condition] +<br><a class=none name="flexi-stream-encoding-error"><b>flexi-stream-encoding-error</b></a> + +<blockquote><br> +All errors related to encoding problems with <a href="#flexi-streams">flexi streams</a> are of this type. (This includes situation where an end of file is encountered in the middle of a multi-octet character.) When this condition is signaled during reading, <a href="http://www.lispworks.com/documentation/HyperSpec/Body/r_use_va.htm"><code>USE-VALUE</code> +restart</a> is provided. See also <a href="#*substitution-char*"><code>*SUBSTITUTION-CHAR*</code></a> and example for it. <a href="#flexi-encodingstream-error"><code>FLEXI-STREAM-ENCODING-ERROR</code></a> is a subtype of <a href="#flexi-stream-error"><code>FLEXI-STREAM-ERROR</code></a>. +</blockquote> + +<p><br>[Condition] +<br><a class=none name="flexi-stream-element-type-error"><b>flexi-stream-element-type-error</b></a> + +<blockquote><br> +All errors related to problems with the element type of <a href="#flexi-streams">flexi streams</a> are of this type. This is a subtype of <a href="#flexi-stream-error"><code>FLEXI-STREAM-ERROR</code></a> and has an additional slot for the element type which can be accessed with <a href="#flexi-stream-element-type-error-element-type"><code>FLEXI-STREAM-ELEMENT-TYPE-ERROR-ELEMENT-TYPE</code></a>. +</blockquote> + +<p><br>[Reader] +<br><a class=none name="flexi-stream-element-type-error-element-type"><b>flexi-stream-element-type-error-element-type</b> <i>condition</i> => <i>element-type</i></a> + +<blockquote><br> +If <code><i>condition</i></code> is of type <a href="#flexi-stream-element-type-error"><code>FLEXI-STREAM-ELEMENT-TYPE-ERROR</code></a>, this function will return the offending element type. +</blockquote> + +<p><br>[Condition] +<br><a class=none name="flexi-stream-position-spec-error"><b>flexi-stream-position-spec-error</b></a> + +<blockquote><br> Errors of this type are signaled if an erroneous +position spec is used in conjunction +with <a href="#position"><code>FILE-POSITION</code></a>. This is a +subtype +of <a href="#flexi-stream-error"><code>FLEXI-STREAM-ERROR</code></a> +and has an additional slot for the position spec which can be accessed +with <a +href="#flexi-stream-position-spec-error-position-spec"><code>FLEXI-STREAM-POSITION-SPEC-ERROR-POSITION-SPEC</code></a>. +</blockquote> + +<p><br>[Reader] +<br><a class=none name="flexi-stream-position-spec-error-position-spec"><b>flexi-stream-position-spec-error-position-spec</b> <i>condition</i> => <i>position-spec</i></a> + +<blockquote><br> +If <code><i>condition</i></code> is of type <a href="#flexi-stream-position-spec-error"><code>FLEXI-STREAM-POSITION-SPEC-ERROR</code></a>, this function will return the offending position spec. +</blockquote> + +<h4><a name="in-memory" class=none>In-memory streams</a></h4> + +The library also provides <em>in-memory</em> binary streams which are modeled after <a href="http://www.lispworks.com/documentation/HyperSpec/Body/t_stg_st.htm">string streams</a> and behave very similar only that they deal with <a href="#octet">octets</a> instead of characters and the underlying data structure is not a string but either a list or a vector. These streams can obviously be used as the underlying streams for <a href="#flexi-streams">flexi streams</a>. + +<p><br>[Standard class] +<br><a class=none name="in-memory-stream"><b>in-memory-stream</b></a> + +<blockquote><br> +Every <a href="#in-memory"><em>in-memory stream</em></a> returned by <a href="#make-in-memory-input-stream"><code>MAKE-IN-MEMORY-INPUT-STREAM</code></a> or <a href="#make-in-memory-output-stream"><code>MAKE-IN-MEMORY-OUTPUT-STREAM</code></a> is of this type which is a subtype of <a href="http://www.lispworks.com/documentation/HyperSpec/Body/t_stream.htm"><code>STREAM</code></a>. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="in-memory-input-stream"><b>in-memory-input-stream</b></a> + +<blockquote><br> +Every <a href="#in-memory"><em>in-memory stream</em></a> returned by <a href="#make-in-memory-input-stream"><code>MAKE-IN-MEMORY-INPUT-STREAM</code></a> is of this type which is a subtype of <a href="#in-memory-stream"><code>IN-MEMORY-STREAM</code></a>. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="in-memory-output-stream"><b>in-memory-output-stream</b></a> + +<blockquote><br> +Every <a href="#in-memory"><em>in-memory stream</em></a> returned by <a href="#make-in-memory-output-stream"><code>MAKE-IN-MEMORY-OUTPUT-STREAM</code></a> is of this type which is a subtype of <a href="#in-memory-stream"><code>IN-MEMORY-STREAM</code></a>. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="list-stream"><b>list-stream</b></a> + +<blockquote><br> +Every <a href="#in-memory"><em>in-memory input stream</em></a> is of this type if it reads from a list. +</blockquote> + +<p><br>[Standard class] +<br><a class=none name="vector-stream"><b>vector-stream</b></a> + +<blockquote><br> +Every <a href="#in-memory"><em>in-memory stream</em></a> is of this type if it reads from or writes to a vector. +</blockquote> + +<p><br>[Generic function] +<br><a class=none name="make-in-memory-input-stream"><b>make-in-memory-input-stream</b> <i>sequence <tt>&key</tt> start end transformer</i> => <i>in-memory-input-stream</i></a> + +<blockquote><br> +Returns a <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_b.htm#binary">binary</a> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_i.htm#input">input</a> stream (of type <a href="#in-memory-input-stream"><code>IN-MEMORY-INPUT-STREAM</code></a>) which will supply, in order, the +octets in the subsequence of <code><i>sequence</i></code> bounded by <code><i>start</i></code> (the default is <code>0</code>) and <code><i>end</i></code> (the default is the length of <code><i>sequence</i></code>). <code><i>sequence</i></code> must either be a list or a vector of <a href="#octet">octets</a>. +Each octet returned will be transformed in turn by the optional +<code><i>transformer</i></code> function. +</blockquote> + +<p><br>[Function] +<br><a class=none name="make-in-memory-output-stream"><b>make-in-memory-output-stream</b> <i><tt>&key</tt> element-type transformer</i> => <i>in-memory-output-stream</i></a> + +<blockquote><br> +Returns a <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_b.htm#binary">binary</a> <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_o.htm#output">output</a> stream (of type <a href="#in-memory-output-stream"><code>IN-MEMORY-OUTPUT-STREAM</code></a>) which accepts objects of type <code><i>element-type</i></code> (a subtype of <a href="#octet"><code>OCTET</code></a>) and makes +available a sequence (see <a href="#get-output-stream-sequence"><code>GET-OUTPUT-STREAM-SEQUENCE</code></a>) that contains the octets that were actually +output. The octets stored will each be transformed by the optional <code><i>transformer</i></code> function. +</blockquote> + +<p><br>[Generic function] +<br><a class=none name="get-output-stream-sequence"><b>get-output-stream-sequence</b> <i>stream <tt>&key</tt> as-list</i> => <i>sequence</i></a> + +<blockquote><br> +Returns a vector containing, in order, all the octets that have +been output to the <a href="#in-memory">in-memory output stream</a> <code><i>stream</i></code>. This operation clears any +octets on <code><i>stream</i></code>, so the vector contains only those octets which have +been output since the last call to <a href="#get-output-stream-sequence"><code>GET-OUTPUT-STREAM-SEQUENCE</code></a> or since +the creation of the stream, whichever occurred most recently. If +<code><i>as-list</i></code> is true the return value is coerced to a list. +</blockquote> + +<p><br>[Generic function] +<br><a class=none name="output-stream-sequence-length"><b>output-stream-sequence-length</b> <i>stream</i> => <i>length</i></a> + +<blockquote><br> Returns the current length of the underlying vector +of the <a href="#in-memory">in-memory output +stream</a> <code><i>stream</i></code>, i.e. this is the length of the +sequence that <a href="#get-output-stream-sequence"><code>GET-OUTPUT-STREAM-SEQUENCE</code></a> would return if called at +this very moment. +</blockquote> + +<p><br>[Macro] +<br><a class=none name="with-input-from-sequence"><b>with-input-from-sequence</b> <i>(var sequence <tt>&key</tt> start end transformer) statement*</i> => <i>result*</i></a> + +<blockquote><br> Creates an <a href="#in-memory">in-memory input +stream</a> from the sequence <code><i>sequence</i></code> using the +parameters <code><i>start</i></code> and <code><i>end</i></code> +(see <a +href="#make-in-memory-input-stream"><code>MAKE-IN-MEMORY-INPUT-STREAM</code></a>), +binds <code><i>var</i></code> to this stream and then executes +the <code><i>statement*</i></code> forms. A +function <code><i>transformer</i></code> may optionally be specified +to transform the returned octets. The stream is automatically closed +on exit from +<a href="#with-output-to-sequence"><code>WITH-OUTPUT-TO-SEQUENCE</code></a>, no matter whether the exit is normal or +abnormal. The return value of this macro is the return value of +the last statement of <code><i>statement*</i></code>. +</blockquote> + +<p><br>[Macro] +<br><a class=none name="with-output-to-sequence"><b>with-output-to-sequence</b> <i>(var <tt>&key</tt> as-list element-type transformer) statement*</i> => <i>sequence</i></a> + +<blockquote><br> +Creates an <a href="#in-memory">in-memory output stream</a>, binds <code><i>var</i></code> to this stream and +then executes the <code><i>statement*</i></code> forms. The stream stores +data of type <code><i>element-type</i></code> (a subtype of <a href="#octet"><code>OCTET</code></a>) which is (optionally) transformed by the +function <code><i>transformer</i></code> prior to storage. The stream is automatically closed on +exit from <a href="#with-output-to-sequence"><code>WITH-OUTPUT-TO-SEQUENCE</code></a>, no matter whether the exit is +normal or abnormal. The return value of this macro is a vector (or a +list if <code><i>as-list</i></code> is true) containing the octets that were sent to the +stream within the body of the macro. +</blockquote> + +<p><br>[Condition] +<br><a class=none name="in-memory-stream-error"><b>in-memory-stream-error</b></a> + +<blockquote><br> +All errors related to <a href="#in-memory">in-memory streams</a> are of this type. This is a subtype of <a href="http://www.lispworks.com/documentation/HyperSpec/Body/e_stm_er.htm"><code>STREAM-ERROR</code></a>. +</blockquote> + +<p><br>[Condition] +<br><a class=none name="in-memory-stream-closed-error"><b>in-memory-stream-closed-error</b></a> + +<blockquote><br> +An error of this type is signaled if one tries to read from or write to an <a href="#in-memory">in-memory stream</a> which had already been closed. This is a subtype of <a href="#in-memory-stream-error"><code>IN-MEMORY-STREAM-ERROR</code></a>. +</blockquote> + +<h4><a name="strings" class=none>Strings</a></h4> + +This section collects a few convenience functions for strings conversions: + +<p><br>[Function] +<br><a class=none name="string-to-octets"><b>string-to-octets</b> <i>string <tt>&key</tt> external-format start end</i> => <i>vector</i></a> + +<blockquote><br> + +Converts the Lisp string <code><i>string</i></code> from <code><i>start</i></code> to <code><i>end</i></code> to an array of +<a href="#octet">octets</a> corresponding to the <a href="#external-formats">external format</a> <code><i>external-format</i></code>. The defaults for +<code><i>start</i></code> and <code><i>end</i></code> +are <code>0</code> and <code>NIL</code> (meaning the length of the +vector). The default for <code><i>external-format</i></code> is the +value of +evaluating <code>(<a +href="#make-external-format">MAKE-EXTERNAL-FORMAT</a> :LATIN1)</code> + +</blockquote> + +<p><br>[Function] +<br><a class=none name="octets-to-string"><b>octets-to-string</b> <i>vector <tt>&key</tt> external-format start end</i> => <i>string</i></a> + +<blockquote><br> Converts the Lisp vector <code><i>vector</i></code> +of <a href="#octet">octets</a> from <code><i>start</i></code> +to <code><i>end</i></code> to string using +the <a href="#external-formats">external +format</a> <code><i>external-format</i></code>. The defaults for +<code><i>start</i></code> and <code><i>end</i></code> +are <code>0</code> and the length of the vector. The default +for <code><i>external-format</i></code> is the value of +evaluating <code>(<a +href="#make-external-format">MAKE-EXTERNAL-FORMAT</a> :LATIN1)</code> +</blockquote> + +<br> <br><h3><a class=none name="position">File positions</a></h3> + +For <a href="#flexi-streams">flexi streams</a> as well +as for <a href="#input-memory">in-memory +streams</a>, <a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_file_p.htm%22%3EFILE...</a> +will usually return <code>NIL</code> and do nothing when a second +argument is supplied. This is correct +w.r.t. the <a +href="http://www.lispworks.com/documentation/HyperSpec/%22%3EANSI +standard</a>, but not very helpful. However, even +with <a +href="http://www.nhplace.com/kent/CL/Issues/stream-definition-by-user.html%22%3EGr... +streams</a> there is no <em>portable</em> way to implement a better +behaviour. +<p> +For <a href="http://www.lispworks.com/">LispWorks</a> +and <a href="http://clisp.sf.net/">CLISP</a>, +<a +href="http://www.lispworks.com/documentation/HyperSpec/Body/f_file_p.htm%22%3EFILE...</a> +for <a href="#flexi-streams">flexi streams</a> will work as if the +function had been applied to the underlying stream, and +for <a href="#input-memory">in-memory streams</a> it will try to do +something sensible if the underlying data structure is a vector +(i.e. <em>not</em> a list). Patches for other Common Lisp +implementations should be sent to +the <a +href="http://common-lisp.net/project/cl-plus-ssl/#trivial-gray-streams%22%3Etrivia...</a> +maintainers. + +<br> <br><h3><a class=none name="ack">Acknowledgements</a></h3> + +Thanks to David Lichteblau for numerous portability patches. Thanks +to Igor Plekhov for the KOI8-R code. Thanks to Anton Vodonosov for +numerous patches and additions. + +<p> +$Header: /usr/local/cvsrep/flexi-streams/doc/index.html,v 1.96 2007/10/11 06:56:51 edi Exp $ +<p><a href="http://weitz.de/index.html">BACK TO MY HOMEPAGE</a> + +</body> +</html>
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/external-format.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/external-format.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/external-format.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,147 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/external-format.lisp,v 1.11 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defclass external-format () + ((name :initarg :name + :reader external-format-name + :documentation "The name of the external format - a +keyword.") + (id :initarg :id + :initform nil + :reader external-format-id + :documentation "If the external format denotes a Windows +code page this ID specifies which one to use. Otherwise the +value is ignored (and usually NIL).") + (little-endian :initarg :little-endian + :initform *default-little-endian* + :reader external-format-little-endian + :documentation "Whether multi-octet values are +read and written with the least significant octet first. For +8-bit encodings like :ISO-8859-1 this value is ignored.") + (eol-style :initarg :eol-style + :reader external-format-eol-style + :documentation "The character(s) to or from which +a #\Newline will be translated - one of the keywords :CR, :LF, +or :CRLF.")) + (:documentation "EXTERNAL-FORMAT objects are used to denote +encodings for flexi streams.")) + +(defmethod make-load-form ((thing external-format) &optional environment) + "Defines a way to reconstruct external formats. Needed for OpenMCL." + (make-load-form-saving-slots thing :environment environment)) + +(defun make-external-format% (name &key (little-endian *default-little-endian*) + id eol-style) + "Used internally by MAKE-EXTERNAL-FORMAT." + (let* ((real-name (normalize-external-format-name name)) + (initargs + (cond ((or (iso-8859-name-p real-name) + (koi8-r-name-p real-name) + (ascii-name-p real-name)) + (list :eol-style (or eol-style *default-eol-style*))) + ((code-page-name-p real-name) + (list :id (or (known-code-page-id-p id) + (error "Unknown code page ID ~S" id)) + ;; default EOL style for Windows code pages is :CRLF + :eol-style (or eol-style :crlf))) + (t (list :eol-style (or eol-style *default-eol-style*) + :little-endian little-endian))))) + (apply #'make-instance 'external-format + :name real-name + initargs))) + +(defun make-external-format (name &rest args + &key (little-endian *default-little-endian*) + id eol-style) + "Creates and returns an external format object as specified. +NAME is a keyword like :LATIN1 or :UTF-8, LITTLE-ENDIAN specifies +the `endianess' of the external format and is ignored for 8-bit +encodings, EOL-STYLE is one of the keywords :CR, :LF, or :CRLF +which denote the end-of-line character (sequence), ID is the ID +of a Windows code page (and ignored for other encodings)." + (declare (ignore id little-endian)) + (let ((shortcut-args (cdr (assoc name +shortcut-map+)))) + (cond (shortcut-args + (apply #'make-external-format% + (append shortcut-args + `(:eol-style ,eol-style)))) + (t (apply #'make-external-format% name args))))) + +(defun external-format-equal (ef1 ef2) + "Checks whether two EXTERNAL-FORMAT objects denote the same +encoding." + (let* ((name1 (external-format-name ef1)) + (code-page-name-p (code-page-name-p name1))) + ;; they must habe the same canonical name + (and (eq name1 + (external-format-name ef2)) + ;; if both are code pages the IDs must be the same + (or (not code-page-name-p) + (eql (external-format-id ef1) + (external-format-id ef2))) + ;; for non-8-bit encodings the endianess must be the same + (or code-page-name-p + (ascii-name-p name1) + (koi8-r-name-p name1) + (iso-8859-name-p name1) + (eq name1 :utf-8) + (eq (not (external-format-little-endian ef1)) + (not (external-format-little-endian ef2)))) + ;; the EOL style must also be the same + (eq (external-format-eol-style ef1) + (external-format-eol-style ef2))))) + +(defun normalize-external-format (external-format) + "Returns a list which is a `normalized' representation of the +external format EXTERNAL-FORMAT. Used internally by +PRINT-OBJECT, for example. Basically, the result is argument +list that can be fed back to MAKE-EXTERNAL-FORMAT to create an +equivalent object." + (let ((name (external-format-name external-format)) + (eol-style (external-format-eol-style external-format))) + (cond ((or (ascii-name-p name) + (koi8-r-name-p name) + (iso-8859-name-p name) + (eq name :utf-8)) + (list name :eol-style eol-style)) + ((code-page-name-p name) + (list name + :id (external-format-id external-format) + :eol-style eol-style)) + (t (list name + :eol-style eol-style + :little-endian (external-format-little-endian external-format)))))) + +(defmethod print-object ((object external-format) stream) + "How an EXTERNAL-FORMAT object is rendered. Uses +NORMALIZE-EXTERNAL-FORMAT." + (print-unreadable-object (object stream :type t :identity t) + (prin1 (normalize-external-format object) stream))) \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/flexi-streams.asd =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/flexi-streams.asd 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/flexi-streams.asd 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,66 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/flexi-streams.asd,v 1.57 2007/10/11 06:56:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :cl-user) + +(defpackage :flexi-streams-system + (:use :asdf :cl)) + +(in-package :flexi-streams-system) + +(defsystem :flexi-streams + :version "0.13.1" + :serial t + :components ((:file "packages") + (:file "ascii") + (:file "koi8-r") + (:file "iso-8859") + (:file "code-pages") + (:file "specials") + (:file "util") + (:file "external-format") + (:file "in-memory") + (:file "stream") + #+:lispworks (:file "lw-binary-stream") + (:file "output") + (:file "input") + (:file "strings")) + :depends-on (:trivial-gray-streams)) + +(defsystem :flexi-streams-test + :components ((:module "test" + :serial t + :components ((:file "packages") + (:file "test")))) + :depends-on (:flexi-streams)) + +(defmethod perform ((o test-op) (c (eql (find-system 'flexi-streams)))) + (operate 'load-op 'flexi-streams-test) + (funcall (intern (symbol-name :run-tests) + (find-package :flexi-streams-test))))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/in-memory.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/in-memory.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/in-memory.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,395 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/in-memory.lisp,v 1.25 2007/01/12 00:08:15 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defclass in-memory-stream (trivial-gray-stream-mixin) + ((transformer :initarg :transformer + :accessor in-memory-stream-transformer + :documentation "A function used to transform the +written/read octet to the value stored/retrieved in/from the +underlying vector.") + #+:cmu + (open-p :initform t + :accessor in-memory-stream-open-p + :documentation "For CMUCL we have to keep track of this +manually.")) + (:documentation "An IN-MEMORY-STREAM is a binary stream that reads +octets from or writes octets to a sequence in RAM.")) + +(defclass in-memory-input-stream (in-memory-stream fundamental-binary-input-stream) + () + (:documentation "An IN-MEMORY-INPUT-STREAM is a binary stream that +reads octets from a sequence in RAM.")) + +#+:cmu +(defmethod output-stream-p ((stream in-memory-input-stream)) + "Explicitly states whether this is an output stream." + (declare (optimize speed)) + nil) + +(defclass in-memory-output-stream (in-memory-stream fundamental-binary-output-stream) + () + (:documentation "An IN-MEMORY-OUTPUT-STREAM is a binary stream that +writes octets to a sequence in RAM.")) + +#+:cmu +(defmethod input-stream-p ((stream in-memory-output-stream)) + "Explicitly states whether this is an input stream." + (declare (optimize speed)) + nil) + +(defclass list-stream () + ((list :initarg :list + :accessor list-stream-list + :documentation "The underlying list of the stream.")) + (:documentation "A LIST-STREAM is a mixin for IN-MEMORY streams +where the underlying sequence is a list.")) + +(defclass vector-stream () + ((vector :initarg :vector + :accessor vector-stream-vector + :documentation "The underlying vector of the stream which +(for output) must always be adjustable and have a fill pointer.")) + (:documentation "A VECTOR-STREAM is a mixin for IN-MEMORY streams +where the underlying sequence is a vector.")) + +(defclass list-input-stream (list-stream in-memory-input-stream) + () + (:documentation "A binary input stream that gets its data from an +associated list of octets.")) + +(defclass vector-input-stream (vector-stream in-memory-input-stream) + ((index :initarg :index + :accessor vector-stream-index + :type (integer 0 #.array-dimension-limit) + :documentation "An index into the underlying vector denoting +the current position.") + (end :initarg :end + :accessor vector-stream-end + :type (integer 0 #.array-dimension-limit) + :documentation "An index into the underlying vector denoting +the end of the available data.")) + (:documentation "A binary input stream that gets its data from an +associated vector of octets.")) + +(defclass vector-output-stream (vector-stream in-memory-output-stream) + () + (:documentation "A binary output stream that writes its data to an +associated vector.")) + +(define-condition in-memory-stream-error (stream-error) + () + (:documentation "Superclass for all errors related to +IN-MEMORY streams.")) + +(define-condition in-memory-stream-closed-error (in-memory-stream-error) + () + (:report (lambda (condition stream) + (format stream "~S is closed." + (stream-error-stream condition)))) + (:documentation "An error that is signaled when someone is trying +to read from or write to a closed IN-MEMORY stream.")) + +#+:cmu +(defmethod open-stream-p ((stream in-memory-stream)) + "Returns a true value if STREAM is open. See ANSI standard." + (declare (optimize speed)) + (in-memory-stream-open-p stream)) + +#+:cmu +(defmethod close ((stream in-memory-stream) &key abort) + "Closes the stream STREAM. See ANSI standard." + (declare (ignore abort) + (optimize speed)) + (prog1 + (in-memory-stream-open-p stream) + (setf (in-memory-stream-open-p stream) nil))) + +(defmethod check-if-open ((stream in-memory-stream)) + "Checks if STREAM is open and signals an error otherwise." + (declare (optimize speed)) + (unless (open-stream-p stream) + (error 'in-memory-stream-closed-error + :stream stream))) + +(defmethod stream-element-type ((stream in-memory-stream)) + "The element type is always OCTET by definition." + (declare (optimize speed)) + 'octet) + +(defmethod transform-octet ((stream in-memory-stream) octet) + "Applies the transformer of STREAM to octet and returns the result." + (funcall (or (in-memory-stream-transformer stream) + #'identity) octet)) + +(defmethod stream-read-byte ((stream list-input-stream)) + "Reads one byte by simply popping it off of the top of the list." + (declare (optimize speed)) + (check-if-open stream) + (transform-octet stream (or (pop (list-stream-list stream)) + (return-from stream-read-byte :eof)))) + +(defmethod stream-listen ((stream list-input-stream)) + "Checks whether list is not empty." + (declare (optimize speed)) + (check-if-open stream) + (list-stream-list stream)) + +(defmethod stream-read-sequence ((stream list-input-stream) sequence start end &key) + "Repeatedly pops elements from the list until it's empty." + (declare (optimize speed) (type (integer 0 *) start end)) + (loop for index from start below end + while (list-stream-list stream) + do (setf (elt sequence index) + (pop (list-stream-list stream))) + finally (return index))) + +(defmethod stream-read-byte ((stream vector-input-stream)) + "Reads one byte and increments INDEX pointer unless we're beyond +END pointer." + (declare (optimize speed)) + (check-if-open stream) + (let ((index (vector-stream-index stream))) + (cond ((< index (vector-stream-end stream)) + (incf (vector-stream-index stream)) + (transform-octet stream (aref (vector-stream-vector stream) index))) + (t :eof)))) + +(defmethod stream-listen ((stream vector-input-stream)) + "Checking whether INDEX is beyond END." + (declare (optimize speed)) + (check-if-open stream) + (< (vector-stream-index stream) (vector-stream-end stream))) + +(defmethod stream-read-sequence ((stream vector-input-stream) sequence start end &key) + "Traverses both sequences in parallel until the end of one of them +is reached." + (declare (optimize speed) (type (integer 0 *) start end)) + (loop with vector-end of-type (integer 0 #.array-dimension-limit) = (vector-stream-end stream) + with vector = (vector-stream-vector stream) + for index from start below end + for vector-index of-type (integer 0 #.array-dimension-limit) = (vector-stream-index stream) + while (< vector-index vector-end) + do (setf (elt sequence index) + (aref vector vector-index)) + (incf (vector-stream-index stream)) + finally (return index))) + +(defmethod stream-write-byte ((stream vector-output-stream) byte) + "Writes a byte (octet) by extending the underlying vector." + (declare (optimize speed)) + (check-if-open stream) + (vector-push-extend (transform-octet stream byte) + (vector-stream-vector stream))) + +(defmethod stream-write-sequence ((stream vector-output-stream) sequence start end &key) + "Just calls VECTOR-PUSH-EXTEND repeatedly." + (declare (optimize speed) (type (integer 0 *) start end)) + (loop with vector = (vector-stream-vector stream) + for index from start below end + do (vector-push-extend (elt sequence index) vector)) + sequence) + +(defmethod stream-file-position ((stream vector-input-stream)) + "Simply returns the index into the underlying vector." + (declare (optimize speed)) + (vector-stream-index stream)) + +(defmethod (setf stream-file-position) (position-spec (stream vector-input-stream)) + "Sets the index into the underlying vector if POSITION-SPEC is acceptable." + (declare (optimize speed)) + (setf (vector-stream-index stream) + (case position-spec + (:start 0) + (:end (vector-stream-end stream)) + (otherwise + (unless (integerp position-spec) + (error 'flexi-stream-position-spec-error + :format-control "Unknown file position designator: ~S." + :format-arguments (list position-spec) + :position-spec position-spec)) + (unless (<= 0 position-spec (vector-stream-end stream)) + (error 'flexi-stream-position-spec-error + :format-control "File position designator ~S is out of bounds." + :format-arguments (list position-spec) + :position-spec position-spec)) + position-spec))) + position-spec) + +(defmethod stream-file-position ((stream vector-output-stream)) + "Simply returns the fill pointer of the underlying vector." + (declare (optimize speed)) + (fill-pointer (vector-stream-vector stream))) + +(defmethod (setf stream-file-position) (position-spec (stream vector-output-stream)) + "Sets the fill pointer underlying vector if POSITION-SPEC is +acceptable. Adjusts the vector if necessary." + (declare (optimize speed)) + (let* ((vector (vector-stream-vector stream)) + (total-size (array-total-size vector)) + (new-fill-pointer + (case position-spec + (:start 0) + (:end + (warn "File position designator :END doesn't really make sense for an output stream.") + total-size) + (otherwise + (unless (integerp position-spec) + (error 'flexi-stream-position-spec-error + :format-control "Unknown file position designator: ~S." + :format-arguments (list position-spec) + :position-spec position-spec)) + (unless (<= 0 position-spec array-total-size-limit) + (error 'flexi-stream-position-spec-error + :format-control "File position designator ~S is out of bounds." + :format-arguments (list position-spec) + :position-spec position-spec)) + position-spec)))) + (when (> new-fill-pointer total-size) + (adjust-array vector new-fill-pointer)) + (setf (fill-pointer vector) new-fill-pointer) + position-spec)) + +(defmethod make-in-memory-input-stream ((vector vector) &key (start 0) + (end (length vector)) + transformer) + "Returns a binary input stream which will supply, in order, the +octets in the subsequence of VECTOR bounded by START and END. +Each octet returned will be transformed in turn by the optional +TRANSFORMER function." + (declare (optimize speed)) + (make-instance 'vector-input-stream + :vector vector + :index start + :end end + :transformer transformer)) + +(defmethod make-in-memory-input-stream ((list list) &key (start 0) + (end (length list)) + transformer) + "Returns a binary input stream which will supply, in order, the +octets in the subsequence of LIST bounded by START and END. Each +octet returned will be transformed in turn by the optional +TRANSFORMER function." + (declare (optimize speed)) + (make-instance 'list-input-stream + :list (subseq list start end) + :transformer transformer)) + +(defun make-output-vector (&key (element-type 'octet)) + "Creates and returns an array which can be used as the underlying +vector for a VECTOR-OUTPUT-STREAM." + (declare (optimize speed)) + (make-array 0 :adjustable t + :fill-pointer 0 + :element-type element-type)) + +(defun make-in-memory-output-stream (&key (element-type 'octet) transformer) + "Returns a binary output stream which accepts objects of type +ELEMENT-TYPE (a subtype of OCTET) and makes available a sequence +that contains the octes that were actually output. The octets +stored will each be transformed by the optional TRANSFORMER +function." + (declare (optimize speed)) + (make-instance 'vector-output-stream + :vector (make-output-vector :element-type element-type) + :transformer transformer)) + +(defmethod get-output-stream-sequence ((stream in-memory-output-stream) &key as-list) + "Returns a vector containing, in order, all the octets that have +been output to the IN-MEMORY stream STREAM. This operation clears any +octets on STREAM, so the vector contains only those octets which have +been output since the last call to GET-OUTPUT-STREAM-SEQUENCE or since +the creation of the stream, whichever occurred most recently. If +AS-LIST is true the return value is coerced to a list." + (declare (optimize speed)) + (prog1 + (if as-list + (coerce (vector-stream-vector stream) 'list) + (vector-stream-vector stream)) + (setf (vector-stream-vector stream) + (make-output-vector)))) + +(defmethod output-stream-sequence-length ((stream in-memory-output-stream)) + "Returns the current length of the underlying vector of the +IN-MEMORY output stream STREAM." + (declare (optimize speed)) + (length (the (simple-array * (*)) (vector-stream-vector stream)))) + +(defmacro with-input-from-sequence ((var sequence &key start end transformer) + &body body) + "Creates an IN-MEMORY input stream from SEQUENCE using the +parameters START and END, binds VAR to this stream and then +executes the code in BODY. A function TRANSFORMER may optionally +be specified to transform the returned octets. The stream is +automatically closed on exit from WITH-INPUT-FROM-SEQUENCE, no +matter whether the exit is normal or abnormal. The return value +of this macro is the return value of BODY." + (with-rebinding (sequence) + `(let (,var) + (unwind-protect + (progn + (setq ,var (make-in-memory-input-stream ,sequence + :start (or ,start 0) + :end (or ,end (length ,sequence)) + :transformer ,transformer)) + ,@body) + (when ,var (close ,var)))))) + +(defmacro with-output-to-sequence ((var &key as-list (element-type ''octet) transformer) + &body body) + "Creates an IN-MEMORY output stream, binds VAR to this stream +and then executes the code in BODY. The stream stores data of +type ELEMENT-TYPE (a subtype of OCTET) which is (optionally) +transformed by the function TRANSFORMER prior to storage. The +stream is automatically closed on exit from +WITH-OUTPUT-TO-SEQUENCE, no matter whether the exit is normal or +abnormal. The return value of this macro is a vector (or a list +if AS-LIST is true) containing the octets that were sent to the +stream within BODY." + `(let (,var) + (unwind-protect + (progn + (setq ,var (make-in-memory-output-stream :element-type ,element-type + :transformer ,transformer)) + ,@body + (get-output-stream-sequence ,var :as-list ,as-list)) + (when ,var (close ,var))))) + +(declaim (inline translate-char)) +(defun translate-char (char-code external-format) + "Returns a list of octets which correspond to the +representation of the character with character code CHAR-CODE +when sent to a flexi stream with external format EXTERNAL-FORMAT. +Used internally by UNREAD-CHAR%. See also STRING-TO-OCTETS." + (declare (optimize speed)) + (with-output-to-sequence (list :as-list t) + (let ((stream (make-flexi-stream list :external-format external-format))) + (write-char (code-char char-code) stream)))) \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/input.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/input.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/input.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,497 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/input.lisp,v 1.48 2007/09/06 23:19:24 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +#-:lispworks +(defmethod read-byte* ((flexi-input-stream flexi-input-stream)) + "Reads one byte (octet) from the underlying stream of +FLEXI-OUTPUT-STREAM (or from the internal stack if it's not +empty)." + (declare (optimize speed)) + ;; we're using S instead of STREAM here because of an + ;; issue with SBCL: + ;; http://article.gmane.org/gmane.lisp.steel-bank.general/1386 + (with-accessors ((position flexi-stream-position) + (bound flexi-stream-bound) + (octet-stack flexi-stream-octet-stack) + (s flexi-stream-stream)) + flexi-input-stream + (declare (integer position) + (type (or null integer) bound)) + (when (and bound + (>= position bound)) + (return-from read-byte* nil)) + (incf position) + (or (pop octet-stack) + (read-byte s nil nil) + (progn (decf position) nil)))) + +#+:lispworks +(defmethod read-byte* ((flexi-input-stream flexi-input-stream)) + "Reads one byte (octet) from the underlying stream of +FLEXI-OUTPUT-STREAM (or from the internal stack if it's not +empty)." + (declare (optimize speed)) + (with-accessors ((position flexi-stream-position) + (bound flexi-stream-bound) + (octet-stack flexi-stream-octet-stack) + (stream flexi-stream-stream)) + flexi-input-stream + (declare (integer position) + (type (or null integer) bound)) + (when (and bound + (>= position bound)) + (return-from read-byte* nil)) + (incf position) + (or (pop octet-stack) + ;; we use READ-SEQUENCE because READ-BYTE doesn't work with all + ;; bivalent streams in LispWorks + (let* ((buffer (make-array 1 :element-type 'octet)) + (new-position (read-sequence buffer stream))) + (cond ((zerop new-position) + (decf position) nil) + (t (aref buffer 0))))))) + +#+:lispworks +(defmethod read-byte* ((flexi-input-stream flexi-binary-input-stream)) + "Reads one byte (octet) from the underlying stream of +FLEXI-OUTPUT-STREAM (or from the internal stack if it's not empty). +Optimized version (only needed for LispWorks) in case the underlying +stream is binary." + (declare (optimize speed)) + (with-accessors ((position flexi-stream-position) + (bound flexi-stream-bound) + (octet-stack flexi-stream-octet-stack) + (stream flexi-stream-stream)) + flexi-input-stream + (declare (integer position) + (type (or null integer) bound)) + (when (and bound + (>= position bound)) + (return-from read-byte* nil)) + (incf position) + (or (pop octet-stack) + (read-byte stream nil nil) + (progn (decf position) nil)))) + +(defmethod stream-clear-input ((flexi-input-stream flexi-input-stream)) + "Calls the corresponding method for the underlying input stream +and also clears the value of the OCTET-STACK slot." + (declare (optimize speed)) + ;; note that we don't reset the POSITION slot + (with-accessors ((octet-stack flexi-stream-octet-stack) + (stream flexi-stream-stream)) + flexi-input-stream + (setq octet-stack nil) + (clear-input stream))) + +(defmethod stream-listen ((flexi-input-stream flexi-input-stream)) + "Calls the corresponding method for the underlying input stream +but first checks if (old) input is available in the OCTET-STACK +slot." + (declare (optimize speed)) + (with-accessors ((position flexi-stream-position) + (bound flexi-stream-bound) + (octet-stack flexi-stream-octet-stack) + (stream flexi-stream-stream)) + flexi-input-stream + (when (and bound + (>= position bound)) + (return-from stream-listen nil)) + (or octet-stack (listen stream)))) + +(defmethod stream-read-byte ((stream flexi-input-stream)) + "Reads one byte (octet) from the underlying stream." + (declare (optimize speed)) + ;; set LAST-CHAR-CODE slot to NIL because we can't UNREAD-CHAR after + ;; this operation + (with-accessors ((last-char-code flexi-stream-last-char-code) + (last-octet flexi-stream-last-octet)) + stream + (setq last-char-code nil) + (let ((octet (read-byte* stream))) + (setq last-octet octet) + (or octet :eof)))) + +(defmethod unread-char% (char-code (flexi-input-stream flexi-input-stream)) + "Used internally to put a character denoted by the character code +CHAR-CODE which was already read back on the stream. Uses the +OCTET-STACK slot and decrements the POSITION slot accordingly." + (declare (optimize speed) (inline translate-char)) + (with-accessors ((position flexi-stream-position) + (octet-stack flexi-stream-octet-stack) + (external-format flexi-stream-external-format)) + flexi-input-stream + (declare (integer position)) + (let ((octets-read (translate-char char-code external-format))) + (decf position (length octets-read)) + (setq octet-stack (append octets-read octet-stack))))) + +(defmacro define-char-reader ((stream-var stream-class) &body body) + "Helper macro to define methods for STREAM-READ-CHAR. Defines a +method for the class STREAM-CLASS using the variable STREAM-VAR and +the code body BODY wrapped with some standard code common to all +methods defined here. The return value of BODY is a character code. +In case of encoding problems, BODY must return the value returned by +(RECOVER-FROM-ENCODING-ERROR ...)." + (with-unique-names (char-code body-fn) + `(defmethod stream-read-char ((,stream-var ,stream-class)) + "This method was generated with the DEFINE-CHAR-READER macro." + (declare (optimize speed)) + ;; note that we do nothing for the :LF EOL style because we + ;; assume that #\Newline is the same as #\Linefeed in all + ;; Lisps which will use this library + (with-accessors ((last-octet flexi-stream-last-octet) + (last-char-code flexi-stream-last-char-code)) + ,stream-var + ;; set LAST-OCTET slot to NIL because we can't UNREAD-BYTE after + ;; this operation + (setq last-octet nil) + (let ((,char-code + (flet ((,body-fn () ,@body)) + (declare (inline ,body-fn) (dynamic-extent (function ,body-fn))) + (,body-fn)))) + ;; remember this character and the current external format + ;; for UNREAD-CHAR + (setq last-char-code ,char-code) + (or (code-char ,char-code) ,char-code)))))) + +(defun recover-from-encoding-error (flexi-stream format-control &rest format-args) + "Helper function used by the STREAM-READ-CHAR methods below to deal +with encoding errors. Checks if *SUBSTITUTION-CHAR* is not NIL and +returns its character code in this case. Otherwise signals a +FLEXI-STREAM-ENCODING-ERROR as determined by the arguments to this +function and provides a corresponding USE-VALUE restart." + (when *substitution-char* + (return-from recover-from-encoding-error (char-code *substitution-char*))) + (restart-case + (apply #'signal-encoding-error flexi-stream format-control format-args) + (use-value (char) + :report "Specify a character to be used instead." + :interactive (lambda () + (loop + (format *query-io* "Type a character: ") + (let ((line (read-line *query-io*))) + (when (= 1 (length line)) + (return (list (char line 0))))))) + (char-code char)))) + +(define-char-reader (stream flexi-latin-1-input-stream) + (or (read-byte* stream) + (return-from stream-read-char :eof))) + +(define-char-reader (stream flexi-ascii-input-stream) + (let ((octet (or (read-byte* stream) + (return-from stream-read-char :eof)))) + (declare (type octet octet)) + (if (> octet 127) + (recover-from-encoding-error stream "No character which corresponds to octet #x~X." octet) + octet))) + +(define-char-reader (stream flexi-8-bit-input-stream) + (with-accessors ((encoding-table flexi-stream-encoding-table)) + stream + (let* ((octet (or (read-byte* stream) + (return-from stream-read-char :eof))) + (char-code (aref (the (simple-array * *) encoding-table) octet))) + (declare (type octet octet)) + (if (or (null char-code) + (= char-code 65533)) + (recover-from-encoding-error stream "No character which corresponds to octet #x~X." octet) + char-code)))) + +(define-char-reader (stream flexi-utf-8-input-stream) + (block body + (let (first-octet-seen) + (flet ((read-next-byte () + (prog1 + (or (read-byte* stream) + (cond (first-octet-seen + (return-from body + (recover-from-encoding-error stream + "End of file while in UTF-8 sequence."))) + (t (return-from stream-read-char :eof)))) + (setq first-octet-seen t)))) + (declare (inline read-next-byte) (dynamic-extent (function read-next-byte))) + (let ((octet (read-next-byte))) + (declare (type octet octet)) + (multiple-value-bind (start count) + (cond ((zerop (logand octet #b10000000)) + (values octet 0)) + ((= #b11000000 (logand octet #b11100000)) + (values (logand octet #b00011111) 1)) + ((= #b11100000 (logand octet #b11110000)) + (values (logand octet #b00001111) 2)) + ((= #b11110000 (logand octet #b11111000)) + (values (logand octet #b00000111) 3)) + ((= #b11111000 (logand octet #b11111100)) + (values (logand octet #b00000011) 4)) + ((= #b11111100 (logand octet #b11111110)) + (values (logand octet #b00000001) 5)) + (t (return-from body + (recover-from-encoding-error stream + "Unexpected value #x~X at start of UTF-8 sequence." + octet)))) + ;; note that we currently don't check for "overlong" + ;; sequences or other illegal values + (loop for result of-type (unsigned-byte 32) + = start then (+ (ash result 6) + (logand octet #b111111)) + repeat count + for octet of-type octet = (read-next-byte) + unless (= #b10000000 (logand octet #b11000000)) + do (return-from body + (recover-from-encoding-error stream + "Unexpected value #x~X in UTF-8 sequence." octet)) + finally (return result)))))))) + +(define-char-reader (stream flexi-utf-16-le-input-stream) + (block body + (let (first-octet-seen) + (labels ((read-next-byte () + (prog1 + (or (read-byte* stream) + (cond (first-octet-seen + (return-from body + (recover-from-encoding-error stream + "End of file while in UTF-16 sequence."))) + (t (return-from stream-read-char :eof)))) + (setq first-octet-seen t))) + (read-next-word () + (+ (the octet (read-next-byte)) + (ash (the octet (read-next-byte)) 8)))) + (declare (inline read-next-byte read-next-word) + (dynamic-extent (function read-next-byte) (function read-next-word))) + (let ((word (read-next-word))) + (cond ((<= #xd800 word #xdfff) + (let ((next-word (read-next-word))) + (unless (<= #xdc00 next-word #xdfff) + (return-from body + (recover-from-encoding-error stream "Unexpected UTF-16 word #x~X following #x~X." + next-word word))) + (+ (ash (logand #b1111111111 word) 10) + (logand #b1111111111 next-word) + #x10000))) + (t word))))))) + +(define-char-reader (stream flexi-utf-16-be-input-stream) + (block body + (let (first-octet-seen) + (labels ((read-next-byte () + (prog1 + (or (read-byte* stream) + (cond (first-octet-seen + (return-from body + (recover-from-encoding-error stream + "End of file while in UTF-16 sequence."))) + (t (return-from stream-read-char :eof)))) + (setq first-octet-seen t))) + (read-next-word () + (+ (ash (the octet (read-next-byte)) 8) + (the octet (read-next-byte))))) + (let ((word (read-next-word))) + (cond ((<= #xd800 word #xdfff) + (let ((next-word (read-next-word))) + (unless (<= #xdc00 next-word #xdfff) + (return-from body + (recover-from-encoding-error stream "Unexpected UTF-16 word #x~X following #x~X." + next-word word))) + (+ (ash (logand #b1111111111 word) 10) + (logand #b1111111111 next-word) + #x10000))) + (t word))))))) + +(define-char-reader (stream flexi-utf-32-le-input-stream) + (block body + (let (first-octet-seen) + (flet ((read-next-byte () + (prog1 + (or (read-byte* stream) + (cond (first-octet-seen + (return-from body + (recover-from-encoding-error stream + "End of file while in UTF-32 sequence."))) + (t (return-from stream-read-char :eof)))) + (setq first-octet-seen t)))) + (declare (inline read-next-byte) (dynamic-extent (function read-next-byte))) + (loop for count from 0 to 24 by 8 + for octet of-type octet = (read-next-byte) + sum (ash octet count)))))) + +(define-char-reader (stream flexi-utf-32-be-input-stream) + (block body + (let (first-octet-seen) + (flet ((read-next-byte () + (prog1 + (or (read-byte* stream) + (cond (first-octet-seen + (return-from body + (recover-from-encoding-error stream + "End of file while in UTF-32 sequence."))) + (t (return-from stream-read-char :eof)))) + (setq first-octet-seen t)))) + (declare (inline read-next-byte) (dynamic-extent (function read-next-byte))) + (loop for count from 24 downto 0 by 8 + for octet of-type octet = (read-next-byte) + sum (ash octet count)))))) + +(defmethod stream-read-char ((stream flexi-cr-mixin)) + "The `base' method for all streams which need end-of-line +conversion. Uses CALL-NEXT-METHOD to do the actual work of +reading one or more characters from the stream." + (declare (optimize speed)) + (let ((char (call-next-method))) + (when (eq char :eof) + (return-from stream-read-char :eof)) + (with-accessors ((external-format flexi-stream-external-format) + (last-char-code flexi-stream-last-char-code)) + stream + (when (eql char #\Return) + (case (external-format-eol-style external-format) + (:cr (setq char #\Newline + last-char-code #.(char-code #\Newline))) + ;; in the case :CRLF we have to look ahead one character + (:crlf (let ((next-char (call-next-method))) + (case next-char + (#\Linefeed + (setq char #\Newline + last-char-code #.(char-code #\Newline))) + (:eof) + ;; if the character we peeked at wasn't a + ;; linefeed character we push its + ;; constituents back onto our internal + ;; octet stack + (otherwise (unread-char% (char-code next-char) stream))))))) + char))) + +(defmethod stream-read-char-no-hang ((stream flexi-input-stream)) + "Reads one character if the underlying stream has at least one +octet available." + (declare (optimize speed)) + ;; note that this may block for non-8-bit encodings - I think + ;; there's no easy way to handle this correctly + (and (stream-listen stream) + (stream-read-char stream))) + +(defmethod stream-read-sequence ((flexi-input-stream flexi-input-stream) sequence start end &key) + "Reads enough input from STREAM to fill SEQUENCE from START to END. +If SEQUENCE is an array which can store octets we use READ-SEQUENCE to +fill it in one fell swoop, otherwise we iterate using +STREAM-READ-CHAR." + (declare (optimize speed) + (type (integer 0 *) start end)) + (with-accessors ((last-char-code flexi-stream-last-char-code) + (last-octet flexi-stream-last-octet) + (stream flexi-stream-stream) + (position flexi-stream-position) + (octet-stack flexi-stream-octet-stack)) + flexi-input-stream + (declare (integer position)) + (cond ((and (arrayp sequence) + (subtypep 'octet (array-element-type sequence))) + (setf last-char-code nil) + (let ((cursor start)) + (loop with stack = octet-stack + for continuep = (< cursor end) + for octet = (and continuep (pop stack)) + while octet + do (setf (aref sequence cursor) (the octet octet)) + (incf cursor)) + (let ((index + (read-sequence sequence stream :start cursor :end end))) + (incf position (- index start)) + (when (> index start) + (setq last-octet (aref sequence (1- index)))) + index))) + (t + (loop for index from start below end + for element = (stream-read-char flexi-input-stream) + until (eq element :eof) + do (setf (elt sequence index) element) + finally (return index)))))) + +(defmethod stream-unread-char ((stream flexi-input-stream) char) + "Implements UNREAD-CHAR for streams of type FLEXI-INPUT-STREAM. +Makes sure CHAR will only be unread if it was the last character +read and if it was read with the same encoding that's currently +being used by the stream." + (declare (optimize speed)) + (with-accessors ((last-char-code flexi-stream-last-char-code)) + stream + (unless last-char-code + (error 'flexi-stream-simple-error + :format-control "No character to unread from this stream (or external format has changed or last reading operation was binary).")) + (unless (= (char-code char) last-char-code) + (error 'flexi-stream-simple-error + :format-control "Last character read was different from ~S." + :format-arguments (list char))) + (unread-char% last-char-code stream) + (setq last-char-code nil) + nil)) + +(defmethod unread-byte (byte (flexi-input-stream flexi-input-stream)) + "Similar to UNREAD-CHAR in that it `unreads' the last octet from +STREAM. Note that you can only call UNREAD-BYTE after a corresponding +READ-BYTE." + (declare (optimize speed)) + (with-accessors ((last-octet flexi-stream-last-octet) + (octet-stack flexi-stream-octet-stack) + (position flexi-stream-position)) + flexi-input-stream + (unless last-octet + (error 'flexi-stream-simple-error + :format-control "No byte to unread from this stream (or last reading operation read a character).")) + (unless (= byte last-octet) + (error 'flexi-stream-simple-error + :format-control "Last byte read was different from #x~X." + :format-arguments (list byte))) + (setq last-octet nil) + (decf (the integer position)) + (push byte octet-stack) + nil)) + +(defmethod peek-byte ((flexi-input-stream flexi-input-stream) + &optional peek-type (eof-error-p t) eof-value) + "PEEK-BYTE is like PEEK-CHAR, i.e. it returns an octet from +FLEXI-INPUT-STREAM without actually removing it. If PEEK-TYPE is NIL +the next octet is returned, if PEEK-TYPE is T, the next octet which is +not 0 is returned, if PEEK-TYPE is an octet, the next octet which +equals PEEK-TYPE is returned. EOF-ERROR-P and EOF-VALUE are +interpreted as usual." + (declare (optimize speed)) + (loop for octet = (read-byte flexi-input-stream eof-error-p eof-value) + until (cond ((null peek-type)) + ((eql octet eof-value)) + ((eq peek-type t) + (plusp octet)) + (t (= octet peek-type))) + finally (unless (eql octet eof-value) + (unread-byte octet flexi-input-stream)) + (return octet))) \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/iso-8859.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/iso-8859.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/iso-8859.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,53 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/iso-8859.lisp,v 1.5 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +;;; the following code was auto-generated from files which can be +;;; found at ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/ + +(defvar +iso-8859-tables+ + '((:iso-8859-1 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255)) + (:iso-8859-2 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 728 321 164 317 346 167 168 352 350 356 377 173 381 379 176 261 731 322 180 318 347 711 184 353 351 357 378 733 382 380 340 193 194 258 196 313 262 199 268 201 280 203 282 205 206 270 272 323 327 211 212 336 214 215 344 366 218 368 220 221 354 223 341 225 226 259 228 314 263 231 269 233 281 235 283 237 238 271 273 324 328 243 244 337 246 247 345 367 250 369 252 253 355 729)) + (:iso-8859-3 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 294 728 163 164 65533 292 167 168 304 350 286 308 173 65533 379 176 295 178 179 180 181 293 183 184 305 351 287 309 189 65533 380 192 193 194 65533 196 266 264 199 200 201 202 203 204 205 206 207 65533 209 210 211 212 288 214 215 284 217 218 219 220 364 348 223 224 225 226 65533 228 267 265 231 232 233 234 235 236 237 238 239 65533 241 242 243 244 289 246 247 285 249 250 251 252 365 349 729)) + (:iso-8859-4 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 312 342 164 296 315 167 168 352 274 290 358 173 381 175 176 261 731 343 180 297 316 711 184 353 275 291 359 330 382 331 256 193 194 195 196 197 198 302 268 201 280 203 278 205 206 298 272 325 332 310 212 213 214 215 216 370 218 219 220 360 362 223 257 225 226 227 228 229 230 303 269 233 281 235 279 237 238 299 273 326 333 311 244 245 246 247 248 371 250 251 252 361 363 729)) + (:iso-8859-5 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 173 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 8470 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 167 1118 1119)) + (:iso-8859-6 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 65533 65533 65533 164 65533 65533 65533 65533 65533 65533 65533 1548 173 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 1563 65533 65533 65533 1567 65533 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 65533 65533 65533 65533 65533 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533)) + (:iso-8859-7 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 8216 8217 163 8364 8367 166 167 168 169 890 171 172 173 65533 8213 176 177 178 179 900 901 902 183 904 905 906 187 908 189 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 65533 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 65533)) + (:iso-8859-8 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 65533 162 163 164 165 166 167 168 169 215 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 247 187 188 189 190 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 8215 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 65533 65533 8206 8207 65533)) + (:iso-8859-9 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 286 209 210 211 212 213 214 215 216 217 218 219 220 304 350 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 287 241 242 243 244 245 246 247 248 249 250 251 252 305 351 255)) + (:iso-8859-10 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 274 290 298 296 310 167 315 272 352 358 381 173 362 330 176 261 275 291 299 297 311 183 316 273 353 359 382 8213 363 331 256 193 194 195 196 197 198 302 268 201 280 203 278 205 206 207 208 325 332 211 212 213 214 360 216 370 218 219 220 221 222 223 257 225 226 227 228 229 230 303 269 233 281 235 279 237 238 239 240 326 333 243 244 245 246 361 248 371 250 251 252 253 254 312)) + (:iso-8859-11 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 65533 65533 65533 65533 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 65533 65533 65533 65533)) + (:iso-8859-13 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 8221 162 163 164 8222 166 167 216 169 342 171 172 173 174 198 176 177 178 179 8220 181 182 183 248 185 343 187 188 189 190 230 260 302 256 262 196 197 280 274 268 201 377 278 290 310 298 315 352 323 325 211 332 213 214 215 370 321 346 362 220 379 381 223 261 303 257 263 228 229 281 275 269 233 378 279 291 311 299 316 353 324 326 243 333 245 246 247 371 322 347 363 252 380 382 8217)) + (:iso-8859-14 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 7682 7683 163 266 267 7690 167 7808 169 7810 7691 7922 173 174 376 7710 7711 288 289 7744 7745 182 7766 7809 7767 7811 7776 7923 7812 7813 7777 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 372 209 210 211 212 213 214 7786 216 217 218 219 220 221 374 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 373 241 242 243 244 245 246 7787 248 249 250 251 252 253 375 255)) + (:iso-8859-15 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 8364 165 352 167 353 169 170 171 172 173 174 175 176 177 178 179 381 181 182 183 382 185 186 187 338 339 376 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255)) + (:iso-8859-16 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 261 321 8364 8222 352 167 353 169 536 171 377 173 378 379 176 177 268 322 381 8221 182 183 382 269 537 187 338 339 376 380 192 193 194 258 196 262 198 199 200 201 202 203 204 205 206 207 272 323 210 211 212 336 214 346 368 217 218 219 220 280 538 223 224 225 226 259 228 263 230 231 232 233 234 235 236 237 238 239 273 324 242 243 244 337 246 347 369 249 250 251 252 281 539 255))) + "A list of the ISO-8859 encodings where each element is a cons +with the car being a keyword denoting the encoding and the cdr +being a vector enumerating the corresponding character codes.")
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/koi8-r.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/koi8-r.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/koi8-r.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,6 @@ +(in-package :flexi-streams) + +;; http://unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT +(defvar +koi8-r-table+ + #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 9472 9474 9484 9488 9492 9496 9500 9508 9516 9524 9532 9600 9604 9608 9612 9616 9617 9618 9619 8992 9632 8729 8730 8776 8804 8805 160 8993 176 178 183 247 9552 9553 9554 1105 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 1025 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 169 1102 1072 1073 1094 1076 1077 1092 1075 1093 1080 1081 1082 1083 1084 1085 1086 1087 1103 1088 1089 1090 1091 1078 1074 1100 1099 1079 1096 1101 1097 1095 1098 1070 1040 1041 1062 1044 1045 1060 1043 1061 1048 1049 1050 1051 1052 1053 1054 1055 1071 1056 1057 1058 1059 1046 1042 1068 1067 1047 1064 1069 1065 1063 1066) + "An array enumerating the character codes for the KOI8-R encoding.")
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/lw-binary-stream.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/lw-binary-stream.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/lw-binary-stream.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,441 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/lw-binary-stream.lisp,v 1.10 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defclass flexi-binary-output-stream (flexi-output-stream) + () + (:documentation "This class is for output streams where the +underlying stream is binary. It exists solely for the purpose of +optimizing output on LispWorks. See WRITE-BYTE*.")) + +(defclass flexi-binary-input-stream (flexi-input-stream) + () + (:documentation "This class is for input streams where the +underlying stream is binary. It exists solely for the purpose of +optimizing input on LispWorks. See READ-BYTE*.")) + +(defclass flexi-binary-io-stream (flexi-binary-input-stream flexi-binary-output-stream flexi-io-stream) + () + (:documentation "This class is for bidirectional streams where the +underlying stream is binary. It exists solely for the purpose of +optimizing input and output on LispWorks. See READ-BYTE* and +WRITE-BYTE*.")) + +(defclass flexi-binary-8-bit-input-stream (flexi-8-bit-input-stream flexi-binary-input-stream) + () + (:documentation "Like FLEXI-8-BIT-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-8-bit-input-stream (flexi-cr-mixin flexi-binary-8-bit-input-stream) + () + (:documentation "Like FLEXI-CR-8-BIT-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-ascii-input-stream (flexi-ascii-input-stream flexi-binary-8-bit-input-stream) + () + (:documentation "Like FLEXI-ASCII-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-ascii-input-stream (flexi-cr-mixin flexi-binary-ascii-input-stream) + () + (:documentation "Like FLEXI-CR-ASCII-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-latin-1-input-stream (flexi-latin-1-input-stream flexi-binary-8-bit-input-stream) + () + (:documentation "Like FLEXI-LATIN-1-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-latin-1-input-stream (flexi-cr-mixin flexi-binary-latin-1-input-stream) + () + (:documentation "Like FLEXI-CR-LATIN-1-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-32-le-input-stream (flexi-utf-32-le-input-stream flexi-binary-input-stream) + () + (:documentation "Like FLEXI-UTF-32-LE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-32-le-input-stream (flexi-cr-mixin flexi-binary-utf-32-le-input-stream) + () + (:documentation "Like FLEXI-CR-UTF-32-LE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-32-be-input-stream (flexi-utf-32-be-input-stream flexi-binary-input-stream) + () + (:documentation "Like FLEXI-UTF-32-BE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-32-be-input-stream (flexi-cr-mixin flexi-binary-utf-32-be-input-stream) + () + (:documentation "Like FLEXI-CR-UTF-32-BE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-16-le-input-stream (flexi-utf-16-le-input-stream flexi-binary-input-stream) + () + (:documentation "Like FLEXI-UTF-16-LE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-16-le-input-stream (flexi-cr-mixin flexi-binary-utf-16-le-input-stream) + () + (:documentation "Like FLEXI-CR-UTF-16-LE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-16-be-input-stream (flexi-utf-16-be-input-stream flexi-binary-input-stream) + () + (:documentation "Like FLEXI-UTF-16-BE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-16-be-input-stream (flexi-cr-mixin flexi-binary-utf-16-be-input-stream) + () + (:documentation "Like FLEXI-CR-UTF-16-BE-INPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-8-input-stream (flexi-utf-8-input-stream flexi-binary-input-stream) + () + (:documentation "Like FLEXI-UTF-8-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-8-input-stream (flexi-cr-mixin flexi-binary-utf-8-input-stream) + () + (:documentation "Like FLEXI-CR-UTF-8-INPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-8-bit-output-stream (flexi-8-bit-output-stream flexi-binary-output-stream) + () + (:documentation "Like FLEXI-8-BIT-OUTPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-8-bit-output-stream (flexi-cr-mixin flexi-binary-8-bit-output-stream) + () + (:documentation "Like FLEXI-CR-8-BIT-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-ascii-output-stream (flexi-ascii-output-stream flexi-binary-8-bit-output-stream) + () + (:documentation "Like FLEXI-ASCII-OUTPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-ascii-output-stream (flexi-cr-mixin flexi-binary-ascii-output-stream) + () + (:documentation "Like FLEXI-CR-ASCII-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-latin-1-output-stream (flexi-latin-1-output-stream flexi-binary-8-bit-output-stream) + () + (:documentation "Like FLEXI-LATIN-1-OUTPUT-STREAM but optimized +for LispWorks binary streams.")) + +(defclass flexi-binary-cr-latin-1-output-stream (flexi-cr-mixin flexi-binary-latin-1-output-stream) + () + (:documentation "Like FLEXI-CR-LATIN-1-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-32-le-output-stream (flexi-utf-32-le-output-stream flexi-binary-output-stream) + () + (:documentation "Like FLEXI-UTF-32-LE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-32-le-output-stream (flexi-cr-mixin flexi-binary-utf-32-le-output-stream) + () + (:documentation "Like FLEXI-CR-UTF-32-LE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-32-be-output-stream (flexi-utf-32-be-output-stream flexi-binary-output-stream) + () + (:documentation "Like FLEXI-UTF-32-BE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-32-be-output-stream (flexi-cr-mixin flexi-binary-utf-32-be-output-stream) + () + (:documentation "Like FLEXI-CR-UTF-32-BE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-16-le-output-stream (flexi-utf-16-le-output-stream flexi-binary-output-stream) + () + (:documentation "Like FLEXI-UTF-16-LE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-16-le-output-stream (flexi-cr-mixin flexi-binary-utf-16-le-output-stream) + () + (:documentation "Like FLEXI-CR-UTF-16-LE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-16-be-output-stream (flexi-utf-16-be-output-stream flexi-binary-output-stream) + () + (:documentation "Like FLEXI-UTF-16-BE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-16-be-output-stream (flexi-cr-mixin flexi-binary-utf-16-be-output-stream) + () + (:documentation "Like FLEXI-CR-UTF-16-BE-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-8-output-stream (flexi-utf-8-output-stream flexi-binary-output-stream) + () + (:documentation "Like FLEXI-UTF-8-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-8-output-stream (flexi-cr-mixin flexi-binary-utf-8-output-stream) + () + (:documentation "Like FLEXI-CR-UTF-8-OUTPUT-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-8-bit-io-stream (flexi-binary-io-stream flexi-8-bit-io-stream) + () + (:documentation "Like FLEXI-8-BIT-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-8-bit-io-stream (flexi-cr-mixin flexi-binary-8-bit-io-stream) + () + (:documentation "Like FLEXI-CR-8-BIT-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-ascii-io-stream (flexi-ascii-io-stream flexi-binary-8-bit-io-stream) + () + (:documentation "Like FLEXI-ASCII-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-ascii-io-stream (flexi-cr-mixin flexi-binary-ascii-io-stream) + () + (:documentation "Like FLEXI-CR-ASCII-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-latin-1-io-stream (flexi-latin-1-io-stream flexi-binary-8-bit-io-stream) + () + (:documentation "Like FLEXI-LATIN-1-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-latin-1-io-stream (flexi-cr-mixin flexi-binary-latin-1-io-stream) + () + (:documentation "Like FLEXI-CR-LATIN-1-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-32-le-io-stream (flexi-utf-32-le-io-stream flexi-binary-io-stream) + () + (:documentation "Like FLEXI-UTF-32-LE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-32-le-io-stream (flexi-cr-mixin flexi-binary-utf-32-le-io-stream) + () + (:documentation "Like FLEXI-CR-UTF-32-LE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-32-be-io-stream (flexi-utf-32-be-io-stream flexi-binary-io-stream) + () + (:documentation "Like FLEXI-UTF-32-BE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-32-be-io-stream (flexi-cr-mixin flexi-binary-utf-32-be-io-stream) + () + (:documentation "Like FLEXI-CR-UTF-32-BE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-16-le-io-stream (flexi-utf-16-le-io-stream flexi-binary-io-stream) + () + (:documentation "Like FLEXI-UTF-16-LE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-16-le-io-stream (flexi-cr-mixin flexi-binary-utf-16-le-io-stream) + () + (:documentation "Like FLEXI-CR-UTF-16-LE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-16-be-io-stream (flexi-utf-16-be-io-stream flexi-binary-io-stream) + () + (:documentation "Like FLEXI-UTF-16-BE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-16-be-io-stream (flexi-cr-mixin flexi-binary-utf-16-be-io-stream) + () + (:documentation "Like FLEXI-CR-UTF-16-BE-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-utf-8-io-stream (flexi-utf-8-io-stream flexi-binary-io-stream) + () + (:documentation "Like FLEXI-UTF-8-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defclass flexi-binary-cr-utf-8-io-stream (flexi-cr-mixin flexi-binary-utf-8-io-stream) + () + (:documentation "Like FLEXI-CR-UTF-8-IO-STREAM but +optimized for LispWorks binary streams.")) + +(defmethod set-class ((stream flexi-binary-input-stream)) + "Changes the actual class of STREAM depending on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (let ((external-format-name (external-format-name external-format)) + (external-format-cr (not (eq (external-format-eol-style external-format) :lf)))) + (change-class stream + (cond ((ascii-name-p external-format-name) + (if external-format-cr + 'flexi-binary-cr-ascii-input-stream + 'flexi-binary-ascii-input-stream)) + ((eq external-format-name :iso-8859-1) + (if external-format-cr + 'flexi-binary-cr-latin-1-input-stream + 'flexi-binary-latin-1-input-stream)) + ((or (koi8-r-name-p external-format-name) + (iso-8859-name-p external-format-name) + (code-page-name-p external-format-name)) + (if external-format-cr + 'flexi-binary-cr-8-bit-input-stream + 'flexi-binary-8-bit-input-stream)) + (t (case external-format-name + (:utf-8 (if external-format-cr + 'flexi-binary-cr-utf-8-input-stream + 'flexi-binary-utf-8-input-stream)) + (:utf-16 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-binary-cr-utf-16-le-input-stream + 'flexi-binary-cr-utf-16-be-input-stream) + (if (external-format-little-endian external-format) + 'flexi-binary-utf-16-le-input-stream + 'flexi-binary-utf-16-be-input-stream))) + (:utf-32 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-binary-cr-utf-32-le-input-stream + 'flexi-binary-cr-utf-32-be-input-stream) + (if (external-format-little-endian external-format) + 'flexi-binary-utf-32-le-input-stream + 'flexi-binary-utf-32-be-input-stream)))))))))) + +(defmethod set-class ((stream flexi-binary-output-stream)) + "Changes the actual class of STREAM depending on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (let ((external-format-name (external-format-name external-format)) + (external-format-cr (not (eq (external-format-eol-style external-format) :lf)))) + (change-class stream + (cond ((ascii-name-p external-format-name) + (if external-format-cr + 'flexi-binary-cr-ascii-output-stream + 'flexi-binary-ascii-output-stream)) + ((eq external-format-name :iso-8859-1) + (if external-format-cr + 'flexi-binary-cr-latin-1-output-stream + 'flexi-binary-latin-1-output-stream)) + ((or (koi8-r-name-p external-format-name) + (iso-8859-name-p external-format-name) + (code-page-name-p external-format-name)) + (if external-format-cr + 'flexi-binary-cr-8-bit-output-stream + 'flexi-binary-8-bit-output-stream)) + (t (case external-format-name + (:utf-8 (if external-format-cr + 'flexi-binary-cr-utf-8-output-stream + 'flexi-binary-utf-8-output-stream)) + (:utf-16 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-binary-cr-utf-16-le-output-stream + 'flexi-binary-cr-utf-16-be-output-stream) + (if (external-format-little-endian external-format) + 'flexi-binary-utf-16-le-output-stream + 'flexi-binary-utf-16-be-output-stream))) + (:utf-32 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-binary-cr-utf-32-le-output-stream + 'flexi-binary-cr-utf-32-be-output-stream) + (if (external-format-little-endian external-format) + 'flexi-binary-utf-32-le-output-stream + 'flexi-binary-utf-32-be-output-stream)))))))))) + +(defmethod set-class ((stream flexi-binary-io-stream)) + "Changes the actual class of STREAM depending on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (let ((external-format-name (external-format-name external-format)) + (external-format-cr (not (eq (external-format-eol-style external-format) :lf)))) + (change-class stream + (cond ((ascii-name-p external-format-name) + (if external-format-cr + 'flexi-binary-cr-ascii-io-stream + 'flexi-binary-ascii-io-stream)) + ((eq external-format-name :iso-8859-1) + (if external-format-cr + 'flexi-binary-cr-latin-1-io-stream + 'flexi-binary-latin-1-io-stream)) + ((or (koi8-r-name-p external-format-name) + (iso-8859-name-p external-format-name) + (code-page-name-p external-format-name)) + (if external-format-cr + 'flexi-binary-cr-8-bit-io-stream + 'flexi-binary-8-bit-io-stream)) + (t (case external-format-name + (:utf-8 (if external-format-cr + 'flexi-binary-cr-utf-8-io-stream + 'flexi-binary-utf-8-io-stream)) + (:utf-16 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-binary-cr-utf-16-le-io-stream + 'flexi-binary-cr-utf-16-be-io-stream) + (if (external-format-little-endian external-format) + 'flexi-binary-utf-16-le-io-stream + 'flexi-binary-utf-16-be-io-stream))) + (:utf-32 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-binary-cr-utf-32-le-io-stream + 'flexi-binary-cr-utf-32-be-io-stream) + (if (external-format-little-endian external-format) + 'flexi-binary-utf-32-le-io-stream + 'flexi-binary-utf-32-be-io-stream)))))))))) + + +(defmethod initialize-instance :after ((flexi-stream flexi-output-stream) &rest initargs) + "Might change the class of FLEXI-STREAM for optimization purposes. +Only needed for LispWorks." + (declare (ignore initargs) + (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + flexi-stream + (when (subtypep (stream-element-type stream) 'octet) + (change-class flexi-stream + (typecase flexi-stream + (flexi-io-stream 'flexi-binary-io-stream) + (otherwise 'flexi-binary-output-stream))) + (set-class flexi-stream)))) + +(defmethod initialize-instance :after ((flexi-stream flexi-input-stream) &rest initargs) + "Might change the class of FLEXI-STREAM for optimization purposes. +Only needed for LispWorks." + (declare (ignore initargs) + (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + flexi-stream + (when (subtypep (stream-element-type stream) 'octet) + (change-class flexi-stream + (typecase flexi-stream + (flexi-io-stream 'flexi-binary-io-stream) + (otherwise 'flexi-binary-input-stream))) + (set-class flexi-stream))))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/output.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/output.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/output.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,310 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/output.lisp,v 1.42 2007/09/13 19:35:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defgeneric write-byte* (byte sink) + (:documentation "Writes one byte (octet) to the underlying stream +of SINK (if SINK is a flexi stream) or adds the byte to the end of +SINK (if SINK is an array with a fill pointer).")) + +#-:lispworks +(defmethod write-byte* (byte (sink flexi-output-stream)) + (declare (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + sink + (write-byte byte stream))) + +#+:lispworks +(defmethod write-byte* (byte (sink flexi-output-stream)) + (declare (optimize speed)) + ;; we use WRITE-SEQUENCE because WRITE-BYTE doesn't work with all + ;; bivalent streams in LispWorks (4.4.6) + (with-accessors ((stream flexi-stream-stream)) + sink + (write-sequence (make-array 1 :element-type 'octet + :initial-element byte) + stream) + byte)) + +#+:lispworks +(defmethod write-byte* (byte (sink flexi-binary-output-stream)) + "Optimized version (only needed for LispWorks) in case the +underlying stream is binary." + (declare (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + sink + (write-byte byte stream))) + +(defmethod write-byte* (byte (sink array)) + (declare (optimize speed)) + (vector-push byte sink)) + +(defgeneric char-to-octets (stream char sink) + (:documentation "Converts the character CHAR to sequence of octets +and sends this sequence to SINK. STREAM will always be a flexi stream +which is used to determine how the character should be converted. +This function does all the work for STREAM-WRITE-CHAR in which case +SINK is the same as STREAM. It is also used in the implementation of +STREAM-WRITE-SEQUENCE below.")) + +(defmethod stream-write-char ((stream flexi-output-stream) char) + (declare (optimize speed)) + (char-to-octets stream char stream)) + +(defmethod char-to-octets ((stream flexi-latin-1-output-stream) char sink) + (declare (optimize speed)) + (let ((octet (char-code char))) + (when (> octet 255) + (signal-encoding-error stream "~S is not a LATIN-1 character." char)) + (write-byte* octet sink)) + char) + +(defmethod char-to-octets ((stream flexi-ascii-output-stream) char sink) + (declare (optimize speed)) + (let ((octet (char-code char))) + (when (> octet 127) + (signal-encoding-error stream "~S is not an ASCII character." char)) + (write-byte* octet sink)) + char) + +(defmethod char-to-octets ((stream flexi-8-bit-output-stream) char sink) + (declare (optimize speed)) + (with-accessors ((encoding-hash flexi-stream-encoding-hash)) + stream + (let ((octet (gethash (char-code char) encoding-hash))) + (unless octet + (signal-encoding-error stream "~S is not in this encoding." char)) + (write-byte* octet sink)) + char)) + +(defmethod char-to-octets ((stream flexi-utf-8-output-stream) char sink) + (declare (optimize speed)) + (let ((char-code (char-code char))) + (tagbody + (cond ((< char-code #x80) + (write-byte* char-code sink) + (go zero)) + ((< char-code #x800) + (write-byte* (logior #b11000000 (ldb (byte 5 6) char-code)) sink) + (go one)) + ((< char-code #x10000) + (write-byte* (logior #b11100000 (ldb (byte 4 12) char-code)) sink) + (go two)) + ((< char-code #x200000) + (write-byte* (logior #b11110000 (ldb (byte 3 18) char-code)) sink) + (go three)) + ((< char-code #x4000000) + (write-byte* (logior #b11111000 (ldb (byte 2 24) char-code)) sink) + (go four)) + (t (write-byte* (logior #b11111100 (ldb (byte 1 30) char-code)) sink))) + (write-byte* (logior #b10000000 (ldb (byte 6 24) char-code)) sink) + four + (write-byte* (logior #b10000000 (ldb (byte 6 18) char-code)) sink) + three + (write-byte* (logior #b10000000 (ldb (byte 6 12) char-code)) sink) + two + (write-byte* (logior #b10000000 (ldb (byte 6 6) char-code)) sink) + one + (write-byte* (logior #b10000000 (ldb (byte 6 0) char-code)) sink) + zero)) + char) + +(defmethod char-to-octets ((stream flexi-utf-16-le-output-stream) char sink) + (declare (optimize speed)) + (flet ((write-word (word) + (write-byte* (ldb (byte 8 0) word) sink) + (write-byte* (ldb (byte 8 8) word) sink))) + (declare (inline write-word) (dynamic-extent (function write-word))) + (let ((char-code (char-code char))) + (cond ((< char-code #x10000) + (write-word char-code)) + (t (decf char-code #x10000) + (write-word (logior #xd800 (ldb (byte 10 10) char-code))) + (write-word (logior #xdc00 (ldb (byte 10 0) char-code))))))) + char) + +(defmethod char-to-octets ((stream flexi-utf-16-be-output-stream) char sink) + (declare (optimize speed)) + (flet ((write-word (word) + (write-byte* (ldb (byte 8 8) word) sink) + (write-byte* (ldb (byte 8 0) word) sink))) + (declare (inline write-word) (dynamic-extent (function write-word))) + (let ((char-code (char-code char))) + (cond ((< char-code #x10000) + (write-word char-code)) + (t (decf char-code #x10000) + (write-word (logior #xd800 (ldb (byte 10 10) char-code))) + (write-word (logior #xdc00 (ldb (byte 10 0) char-code))))))) + char) + +(defmethod char-to-octets ((stream flexi-utf-32-le-output-stream) char sink) + (declare (optimize speed)) + (loop with char-code = (char-code char) + for position in '(0 8 16 24) do + (write-byte* (ldb (byte 8 position) char-code) sink)) + char) + +(defmethod char-to-octets ((stream flexi-utf-32-be-output-stream) char sink) + (declare (optimize speed)) + (loop with char-code = (char-code char) + for position in '(24 16 8 0) do + (write-byte* (ldb (byte 8 position) char-code) sink)) + char) + +(defmethod char-to-octets ((stream flexi-cr-mixin) char sink) + "The `base' method for all streams which need end-of-line +conversion. Uses CALL-NEXT-METHOD to do the actual work of sending +one or more characters to SINK." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (case char + (#\Newline + (case (external-format-eol-style external-format) + (:cr (call-next-method stream #\Return sink)) + (:crlf (call-next-method stream #\Return sink) + (call-next-method stream #\Linefeed sink)))) + (otherwise (call-next-method))) + char)) + +(defmethod stream-write-char :after ((stream flexi-output-stream) char) + (declare (optimize speed)) + ;; update the column unless we're in the middle of the line and + ;; the current value is NIL + (with-accessors ((column flexi-stream-column)) + stream + (cond ((char= char #\Newline) (setq column 0)) + (column (incf (the integer column)))))) + +(defmethod stream-clear-output ((flexi-output-stream flexi-output-stream)) + "Simply calls the corresponding method for the underlying +output stream." + (declare (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + flexi-output-stream + (clear-output stream))) + +(defmethod stream-finish-output ((flexi-output-stream flexi-output-stream)) + "Simply calls the corresponding method for the underlying +output stream." + (declare (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + flexi-output-stream + (finish-output stream))) + +(defmethod stream-force-output ((flexi-output-stream flexi-output-stream)) + "Simply calls the corresponding method for the underlying +output stream." + (declare (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + flexi-output-stream + (force-output stream))) + +(defmethod stream-line-column ((flexi-output-stream flexi-output-stream)) + "Returns the column stored in the COLUMN slot of the +FLEXI-OUTPUT-STREAM object STREAM." + (declare (optimize speed)) + (with-accessors ((column flexi-stream-column)) + flexi-output-stream + column)) + +(defmethod stream-write-byte ((flexi-output-stream flexi-output-stream) byte) + "Writes a byte (octet) to the underlying stream." + (declare (optimize speed)) + (with-accessors ((column flexi-stream-column)) + flexi-output-stream + ;; set column to NIL because we don't know how to handle binary + ;; output mixed with character output + (setq column nil) + (write-byte* byte flexi-output-stream))) + +#+:allegro +(defmethod stream-terpri ((stream flexi-output-stream)) + "Writes a #\Newline character to the underlying stream." + (declare (optimize speed)) + ;; needed for AllegroCL - grrr... + (stream-write-char stream #\Newline)) + +(defmethod stream-write-sequence ((flexi-output-stream flexi-output-stream) sequence start end &key) + "Writes all elements of the sequence SEQUENCE from START to END +to the underlying stream. The elements can be either octets or +characters. Characters are output according to the current +encoding (external format) of the FLEXI-OUTPUT-STREAM object +STREAM." + (declare (optimize speed) + (type (integer 0 *) start end)) + (with-accessors ((stream flexi-stream-stream) + (column flexi-stream-column)) + flexi-output-stream + (cond ((and (arrayp sequence) + (subtypep (array-element-type sequence) 'octet)) + ;; set column to NIL because we don't know how to handle binary + ;; output mixed with character output + (setq column nil) + (write-sequence sequence stream :start start :end end)) + (t (loop for index from start below end + for element = (elt sequence index) + when (characterp element) do + (stream-write-char flexi-output-stream element) + else do + (stream-write-byte flexi-output-stream element)) + sequence)))) + +(defmethod stream-write-sequence ((stream flexi-output-stream) (sequence string) start end &key) + "Optimized method for the cases where SEQUENCE is a string. Fills +an internal buffer and uses repeated calls to WRITE-SEQUENCE to write +to the underlying stream." + (declare (optimize speed) + (type (integer 0 *) start end)) + (let* ((buffer (make-array (+ +buffer-size+ 20) + :element-type '(unsigned-byte 8) + :fill-pointer 0)) + (last-newline-pos (position #\Newline sequence + :test #'char= + :start start + :end end + :from-end t))) + (loop for index from start below end + do (char-to-octets stream (aref sequence index) buffer) + when (>= (fill-pointer buffer) +buffer-size+) do + (write-sequence buffer (flexi-stream-stream stream)) + (setf (fill-pointer buffer) 0) + finally (when (>= (fill-pointer buffer) 0) + (write-sequence buffer (flexi-stream-stream stream)))) + (setf (flexi-stream-column stream) + (cond (last-newline-pos (- end last-newline-pos 1)) + ((flexi-stream-column stream) + (+ (flexi-stream-column stream) (- end start)))))) + sequence) + +(defmethod stream-write-string ((stream flexi-output-stream) string + &optional (start 0) (end (length string))) + "Simply hands over to the optimized method for STREAM-WRITE-SEQUENCE." + (stream-write-sequence stream string start (or end (length string))))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/packages.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/packages.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/packages.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,86 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/packages.lisp,v 1.29 2007/10/11 06:56:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :cl-user) + +(unless (find-symbol (if (eq (readtable-case *readtable*) :upcase) + "STREAM-FILE-POSITION" + "stream-file-position") + :trivial-gray-streams) + (error "You need a newer version of TRIVIAL-GRAY-STREAMS.")) + +(defpackage :flexi-streams + (:use :cl :trivial-gray-streams) + (:nicknames :flex) + #+:lispworks + (:shadow :with-accessors) + (:export :*default-eol-style* + :*default-little-endian* + :*substitution-char* + :external-format-eol-style + :external-format-equal + :external-format-id + :external-format-little-endian + :external-format-name + :flexi-input-stream + :flexi-output-stream + :flexi-io-stream + :flexi-stream + :flexi-stream-bound + :flexi-stream-external-format + :flexi-stream-encoding-error + :flexi-stream-element-type + :flexi-stream-element-type-error + :flexi-stream-element-type-error-element-type + :flexi-stream-error + :flexi-stream-column + :flexi-stream-position + :flexi-stream-position-spec-error + :flexi-stream-position-spec-error-position-spec + :flexi-stream-stream + :get-output-stream-sequence + :in-memory-stream + :in-memory-stream-closed-error + :in-memory-stream-error + :in-memory-input-stream + :in-memory-output-stream + :list-stream + :make-external-format + :make-in-memory-input-stream + :make-in-memory-output-stream + :make-flexi-stream + :octet + :octets-to-string + :output-stream-sequence-length + :peek-byte + :string-to-octets + :unread-byte + :vector-stream + :with-input-from-sequence + :with-output-to-sequence))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/specials.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/specials.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/specials.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,184 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/specials.lisp,v 1.24 2007/09/05 11:30:23 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(deftype octet () + "A shortcut for (UNSIGNED-BYTE 8)." + '(unsigned-byte 8)) + +(defvar +name-map+ + '((:utf8 . :utf-8) + (:utf16 . :utf-16) + (:ucs2 . :utf-16) + (:ucs-2 . :utf-16) + (:unicode . :utf-16) + (:utf32 . :utf-32) + (:ucs4 . :utf-32) + (:ucs-4 . :utf-32) + (:ascii . :us-ascii) + (:koi8r . :koi8-r) + (:latin-1 . :iso-8859-1) + (:latin1 . :iso-8859-1) + (:latin-2 . :iso-8859-2) + (:latin2 . :iso-8859-2) + (:latin-3 . :iso-8859-3) + (:latin3 . :iso-8859-3) + (:latin-4 . :iso-8859-4) + (:latin4 . :iso-8859-4) + (:cyrillic . :iso-8859-5) + (:arabic . :iso-8859-6) + (:greek . :iso-8859-7) + (:hebrew . :iso-8859-8) + (:latin-5 . :iso-8859-9) + (:latin5 . :iso-8859-9) + (:latin-6 . :iso-8859-10) + (:latin6 . :iso-8859-10) + (:thai . :iso-8859-11) + (:latin-7 . :iso-8859-13) + (:latin7 . :iso-8859-13) + (:latin-8 . :iso-8859-14) + (:latin8 . :iso-8859-14) + (:latin-9 . :iso-8859-15) + (:latin9 . :iso-8859-15) + (:latin-0 . :iso-8859-15) + (:latin0 . :iso-8859-15) + (:latin-10 . :iso-8859-16) + (:latin10 . :iso-8859-16) + (:codepage . :code-page) + #+(and :lispworks :win32) + (win32:code-page . :code-page)) + "An alist which mapes alternative names for external formats to +their canonical counterparts.") + +(defvar +shortcut-map+ + '((:ucs-2le . (:ucs-2 :little-endian t)) + (:ucs-2be . (:ucs-2 :little-endian nil)) + (:ucs-4le . (:ucs-4 :little-endian t)) + (:ucs-4be . (:ucs-4 :little-endian nil)) + (:utf-16le . (:utf-16 :little-endian t)) + (:utf-16be . (:utf-16 :little-endian nil)) + (:utf-32le . (:utf-32 :little-endian t)) + (:utf-32be . (:utf-32 :little-endian nil)) + (:ibm437 . (:code-page :id 437)) + (:ibm850 . (:code-page :id 850)) + (:ibm852 . (:code-page :id 852)) + (:ibm855 . (:code-page :id 855)) + (:ibm857 . (:code-page :id 857)) + (:ibm860 . (:code-page :id 860)) + (:ibm861 . (:code-page :id 861)) + (:ibm862 . (:code-page :id 862)) + (:ibm863 . (:code-page :id 863)) + (:ibm864 . (:code-page :id 864)) + (:ibm865 . (:code-page :id 865)) + (:ibm866 . (:code-page :id 866)) + (:ibm869 . (:code-page :id 869)) + (:windows-1250 . (:code-page :id 1250)) + (:windows-1251 . (:code-page :id 1251)) + (:windows-1252 . (:code-page :id 1252)) + (:windows-1253 . (:code-page :id 1253)) + (:windows-1254 . (:code-page :id 1254)) + (:windows-1255 . (:code-page :id 1255)) + (:windows-1256 . (:code-page :id 1256)) + (:windows-1257 . (:code-page :id 1257)) + (:windows-1258 . (:code-page :id 1258))) + "An alist which maps shortcuts for external formats to their +long forms.") + +(defvar *default-eol-style* + #+:win32 :crlf + #-:win32 :lf + "The end-of-line style used by external formats if none is +explicitly given. Depends on the OS the code is compiled on.") + +(defvar *default-little-endian* + #+:little-endian t + #-:little-endian nil + "Whether external formats are little-endian by default +(i.e. unless explicitly specified). Depends on the platform +the code is compiled on.") + +(defvar *substitution-char* nil + "If this value is not NIL, it should be a character which is used +(as if by a USE-VALUE restart) whenever during reading an error of +type FLEXI-STREAM-ENCODING-ERROR would have been signaled otherwise.") + +(defun invert-table (table) + "`Inverts' an array which maps octets to character codes to a +hash tables which maps character codes to octets." + (let ((hash (make-hash-table))) + (loop for octet from 0 + for char-code across table + unless (= char-code 65533) + do (setf (gethash char-code hash) octet)) + hash)) + +(defvar +iso-8859-hashes+ + (loop for (name . table) in +iso-8859-tables+ + collect (cons name (invert-table table))) + "An alist which maps names for ISO-8859 encodings to hash +tables which map character codes to the corresponding octets.") + +(defvar +code-page-hashes+ + (loop for (id . table) in +code-page-tables+ + collect (cons id (invert-table table))) + "An alist which maps IDs of Windows code pages to hash tables +which map character codes to the corresponding octets.") + +(defvar +ascii-hash+ (invert-table +ascii-table+) + "A hash table which maps US-ASCII character codes to the +corresponding octets.") + +(defvar +koi8-r-hash+ (invert-table +koi8-r-table+) + "A hash table which maps KOI8-R character codes to the +corresponding octets.") + +(defconstant +buffer-size+ 8192 + "Size of buffers used for internal purposes.") + +(pushnew :flexi-streams *features*) + +;; stuff for Nikodemus Siivola's HYPERDOC +;; see http://common-lisp.net/project/hyperdoc/ +;; and http://www.cliki.net/hyperdoc +;; also used by LW-ADD-ONS + +(defvar *hyperdoc-base-uri* "http://weitz.de/flexi-streams/") + +(let ((exported-symbols-alist + (loop for symbol being the external-symbols of :flexi-streams + collect (cons symbol + (concatenate 'string + "#" + (string-downcase symbol)))))) + (defun hyperdoc-lookup (symbol type) + (declare (ignore type)) + (cdr (assoc symbol + exported-symbols-alist + :test #'eq))))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/stream.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/stream.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/stream.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,730 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/stream.lisp,v 1.50 2007/09/06 23:46:29 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defclass flexi-stream (trivial-gray-stream-mixin) + ((stream :initarg :stream + :reader flexi-stream-stream + :documentation "The actual stream that's used for +input and/or output. It must be capable of reading/writing +octets with READ-SEQUENCE and/or WRITE-SEQUENCE.") + (external-format :initform (make-external-format :iso-8859-1) + :initarg :flexi-stream-external-format + :accessor flexi-stream-external-format + :documentation "The encoding currently used +by this stream. Can be changed on the fly.") + (element-type :initform #+:lispworks 'lw:simple-char #-:lispworks 'character + :initarg :element-type + :accessor flexi-stream-element-type + :documentation "The element type of this stream.")) + (:documentation "A FLEXI-STREAM object is a stream that's +`layered' atop an existing binary/bivalent stream in order to +allow for multi-octet external formats. FLEXI-STREAM itself is a +mixin and should not be instantiated.")) + +(define-condition flexi-stream-error (stream-error) + () + (:documentation "Superclass for all errors related to +flexi streams.")) + +(define-condition flexi-stream-simple-error (flexi-stream-error simple-condition) + () + (:documentation "Like FLEXI-STREAM-ERROR but with formatting +capabilities.")) + +(define-condition flexi-stream-element-type-error (flexi-stream-error) + ((element-type :initarg :element-type + :reader flexi-stream-element-type-error-element-type)) + (:report (lambda (condition stream) + (format stream "Element type ~S not allowed." + (flexi-stream-element-type-error-element-type condition)))) + (:documentation "Errors of this type are signaled if the flexi +stream has a wrong element type.")) + +(define-condition flexi-stream-encoding-error (flexi-stream-simple-error) + () + (:documentation "Errors of this type are signaled if there is an +encoding problem.")) + +(define-condition flexi-stream-position-spec-error (flexi-stream-simple-error) + ((position-spec :initarg :position-spec + :reader flexi-stream-position-spec-error-position-spec)) + (:documentation "Errors of this type are signaled if an +erroneous position spec is used in conjunction with +FILE-POSITION.")) + +(defun signal-encoding-error (flexi-stream format-control &rest format-args) + "Convenience function similar to ERROR to signal conditions of type +FLEXI-STREAM-ENCODING-ERROR." + (error 'flexi-stream-encoding-error + :format-control format-control + :format-arguments format-args + :stream flexi-stream)) + +(defun maybe-convert-external-format (external-format) + "Given an external format designator (a keyword, a list, or an +EXTERNAL-FORMAT object) returns the corresponding EXTERNAL-FORMAT +object." + (typecase external-format + (symbol (make-external-format external-format)) + (list (apply #'make-external-format external-format)) + (otherwise external-format))) + +(defmethod initialize-instance :after ((flexi-stream flexi-stream) &rest initargs) + "Makes sure the EXTERNAL-FORMAT and ELEMENT-TYPE slots contain +reasonable values." + (declare (ignore initargs) + (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format) + (element-type flexi-stream-element-type)) + flexi-stream + (unless (or (subtypep element-type 'character) + (subtypep element-type 'octet)) + (error 'flexi-stream-element-type-error + :element-type element-type + :stream flexi-stream)) + (setq external-format (maybe-convert-external-format external-format))) + ;; set actual class and maybe contents of 8-bit encoding slots + (set-class flexi-stream)) + +(defmethod (setf flexi-stream-external-format) :around (new-value (flexi-stream flexi-stream)) + "Converts the new value to an EXTERNAL-FORMAT object if +necessary." + (call-next-method (maybe-convert-external-format new-value) flexi-stream)) + +(defmethod (setf flexi-stream-element-type) :before (new-value (flexi-stream flexi-stream)) + "Checks whether the new value makes sense before it is set." + (unless (or (subtypep new-value 'character) + (subtypep new-value 'octet)) + (error 'flexi-stream-element-type-error + :element-type new-value + :stream flexi-stream))) + +(defmethod stream-element-type ((stream flexi-stream)) + "Returns the element type that was provided by the creator of +the stream." + (declare (optimize speed)) + (flexi-stream-element-type stream)) + +(defmethod close ((stream flexi-stream) &key abort) + "Closes the flexi stream by closing the underlying `real' +stream." + (declare (optimize speed)) + (with-accessors ((stream flexi-stream-stream)) + stream + (cond ((open-stream-p stream) + (close stream :abort abort)) + (t nil)))) + +(defmethod open-stream-p ((stream flexi-stream)) + "A flexi stream is open if its underlying stream is open." + (declare (optimize speed)) + (open-stream-p (flexi-stream-stream stream))) + +(defmethod stream-file-position ((stream flexi-stream)) + "Dispatch to method for underlying stream." + (declare (optimize speed)) + (stream-file-position (flexi-stream-stream stream))) + +(defmethod (setf stream-file-position) (position-spec (stream flexi-stream)) + "Dispatch to method for underlying stream." + (declare (optimize speed)) + (setf (stream-file-position (flexi-stream-stream stream)) + position-spec)) + +(defclass flexi-output-stream (flexi-stream fundamental-binary-output-stream + fundamental-character-output-stream) + ((column :initform 0 + :accessor flexi-stream-column + :documentation "The current output column. A +non-negative integer or NIL.")) + (:documentation "A FLEXI-OUTPUT-STREAM is a FLEXI-STREAM that +can actually be instatiated and used for output. Don't use +MAKE-INSTANCE to create a new FLEXI-OUTPUT-STREAM but use +MAKE-FLEXI-STREAM instead.")) + +#+:cmu +(defmethod input-stream-p ((stream flexi-output-stream)) + "Explicitly states whether this is an input stream." + (declare (optimize speed)) + nil) + +(defclass flexi-input-stream (flexi-stream fundamental-binary-input-stream + fundamental-character-input-stream) + ((last-char-code :initform nil + :accessor flexi-stream-last-char-code + :documentation "This slot either holds NIL or the +last character (code) read successfully. This is mainly used for +UNREAD-CHAR sanity checks.") + (last-octet :initform nil + :accessor flexi-stream-last-octet + :documentation "This slot either holds NIL or the last +octet read successfully from the stream using a `binary' operation +such as READ-BYTE. This is mainly used for UNREAD-BYTE sanity +checks.") + (octet-stack :initform nil + :accessor flexi-stream-octet-stack + :documentation "A small buffer which holds octets +that were already read from the underlying stream but not yet +used to produce characters. This is mainly used if we have to +look ahead for a CR/LF line ending.") + (position :initform 0 + :initarg :position + :type integer + :accessor flexi-stream-position + :documentation "The position within the stream where each +octet read counts as one.") + (bound :initform nil + :initarg :bound + :type (or null integer) + :accessor flexi-stream-bound + :documentation "When this is not NIL, it must be an integer +and the stream will behave as if no more data is available as soon as +POSITION is greater or equal than this value.")) + (:documentation "A FLEXI-INPUT-STREAM is a FLEXI-STREAM that +can actually be instatiated and used for input. Don't use +MAKE-INSTANCE to create a new FLEXI-INPUT-STREAM but use +MAKE-FLEXI-STREAM instead.")) + +#+:cmu +(defmethod output-stream-p ((stream flexi-input-stream)) + "Explicitly states whether this is an output stream." + (declare (optimize speed)) + nil) + +(defclass flexi-io-stream (flexi-input-stream flexi-output-stream) + () + (:documentation "A FLEXI-IO-STREAM is a FLEXI-STREAM that can +actually be instatiated and used for input and output. Don't use +MAKE-INSTANCE to create a new FLEXI-IO-STREAM but use +MAKE-FLEXI-STREAM instead.")) + +(defclass flexi-cr-mixin () + () + (:documentation "A mixin for flexi streams which need +end-of-line conversion, i.e. for those where the end-of-line +designator is /not/ the single character #\Linefeed.")) + +(defclass flexi-8-bit-input-stream (flexi-input-stream) + ((encoding-table :accessor flexi-stream-encoding-table)) + (:documentation "The class for all flexi input streams which +use an 8-bit encoding and thus need an additional slot for the +encoding table.")) + +(defclass flexi-cr-8-bit-input-stream (flexi-cr-mixin flexi-8-bit-input-stream) + () + (:documentation "The class for all flexi input streams which +use an 8-bit encoding /and/ need end-of-line conversion.")) + +(defclass flexi-ascii-input-stream (flexi-8-bit-input-stream) + () + (:documentation "Special class for flexi input streams which +use the US-ASCCI encoding.")) + +(defclass flexi-cr-ascii-input-stream (flexi-cr-mixin flexi-ascii-input-stream) + () + (:documentation "Special class for flexi input streams which +use the US-ASCCI encoding /and/ need end-of-line conversion.")) + +(defclass flexi-latin-1-input-stream (flexi-8-bit-input-stream) + () + (:documentation "Special class for flexi input streams which +use the ISO-8859-1 encoding.")) + +(defclass flexi-cr-latin-1-input-stream (flexi-cr-mixin flexi-latin-1-input-stream) + () + (:documentation "Special class for flexi input streams which +use the ISO-8859-1 encoding /and/ need end-of-line conversion.")) + +(defclass flexi-utf-32-le-input-stream (flexi-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-32 encoding with little-endian byte ordering.")) + +(defclass flexi-cr-utf-32-le-input-stream (flexi-cr-mixin flexi-utf-32-le-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-32 encoding with little-endian byte ordering /and/ +need end-of-line conversion.")) + +(defclass flexi-utf-32-be-input-stream (flexi-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-32 encoding with big-endian byte ordering.")) + +(defclass flexi-cr-utf-32-be-input-stream (flexi-cr-mixin flexi-utf-32-be-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-32 encoding with big-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-16-le-input-stream (flexi-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-16 encoding with little-endian byte ordering.")) + +(defclass flexi-cr-utf-16-le-input-stream (flexi-cr-mixin flexi-utf-16-le-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-16 encoding with little-endian byte ordering /and/ +need end-of-line conversion.")) + +(defclass flexi-utf-16-be-input-stream (flexi-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-16 encoding with big-endian byte ordering.")) + +(defclass flexi-cr-utf-16-be-input-stream (flexi-cr-mixin flexi-utf-16-be-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-16 encoding with big-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-8-input-stream (flexi-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-8 encoding.")) + +(defclass flexi-cr-utf-8-input-stream (flexi-cr-mixin flexi-utf-8-input-stream) + () + (:documentation "Special class for flexi input streams which +use the UTF-8 encoding /and/ need end-of-line conversion.")) + +(defclass flexi-8-bit-output-stream (flexi-output-stream) + ((encoding-hash :accessor flexi-stream-encoding-hash)) + (:documentation "The class for all flexi output streams which +use an 8-bit encoding and thus need an additional slot for the +encoding table.")) + +(defclass flexi-cr-8-bit-output-stream (flexi-cr-mixin flexi-8-bit-output-stream) + () + (:documentation "The class for all flexi output streams which +use an 8-bit encoding /and/ need end-of-line conversion.")) + +(defclass flexi-ascii-output-stream (flexi-8-bit-output-stream) + () + (:documentation "Special class for flexi output streams which +use the US-ASCCI encoding.")) + +(defclass flexi-cr-ascii-output-stream (flexi-cr-mixin flexi-ascii-output-stream) + () + (:documentation "Special class for flexi output streams which +use the US-ASCCI encoding /and/ need end-of-line conversion.")) + +(defclass flexi-latin-1-output-stream (flexi-8-bit-output-stream) + () + (:documentation "Special class for flexi output streams which +use the ISO-8859-1 encoding.")) + +(defclass flexi-cr-latin-1-output-stream (flexi-cr-mixin flexi-latin-1-output-stream) + () + (:documentation "Special class for flexi output streams which +use the ISO-8859-1 encoding /and/ need end-of-line conversion.")) + +(defclass flexi-utf-32-le-output-stream (flexi-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-32 encoding with little-endian byte ordering.")) + +(defclass flexi-cr-utf-32-le-output-stream (flexi-cr-mixin flexi-utf-32-le-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-32 encoding with little-endian byte ordering /and/ +need end-of-line conversion.")) + +(defclass flexi-utf-32-be-output-stream (flexi-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-32 encoding with big-endian byte ordering.")) + +(defclass flexi-cr-utf-32-be-output-stream (flexi-cr-mixin flexi-utf-32-be-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-32 encoding with big-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-16-le-output-stream (flexi-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-16 encoding with little-endian byte ordering.")) + +(defclass flexi-cr-utf-16-le-output-stream (flexi-cr-mixin flexi-utf-16-le-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-16 encoding with little-endian byte ordering /and/ +need end-of-line conversion.")) + +(defclass flexi-utf-16-be-output-stream (flexi-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-16 encoding with big-endian byte ordering.")) + +(defclass flexi-cr-utf-16-be-output-stream (flexi-cr-mixin flexi-utf-16-be-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-16 encoding with big-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-8-output-stream (flexi-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-8 encoding.")) + +(defclass flexi-cr-utf-8-output-stream (flexi-cr-mixin flexi-utf-8-output-stream) + () + (:documentation "Special class for flexi output streams which +use the UTF-8 encoding /and/ need end-of-line conversion.")) + +(defclass flexi-8-bit-io-stream (flexi-8-bit-input-stream flexi-8-bit-output-stream flexi-io-stream) + () + (:documentation "The class for all flexi I/O streams which use +an 8-bit encoding and thus need an additional slot for the +encoding table.")) + +(defclass flexi-cr-8-bit-io-stream (flexi-cr-mixin flexi-8-bit-io-stream) + () + (:documentation "The class for all flexi I/O streams which use +an 8-bit encoding /and/ need end-of-line conversion.")) + +(defclass flexi-ascii-io-stream (flexi-ascii-input-stream flexi-ascii-output-stream flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the US-ASCCI encoding.")) + +(defclass flexi-cr-ascii-io-stream (flexi-cr-mixin flexi-ascii-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the US-ASCCI encoding /and/ need end-of-line conversion.")) + +(defclass flexi-latin-1-io-stream (flexi-latin-1-input-stream flexi-latin-1-output-stream flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the ISO-8859-1 encoding.")) + +(defclass flexi-cr-latin-1-io-stream (flexi-cr-mixin flexi-latin-1-io-stream) + () + (:documentation "Special class for flexi input streams which +use the ISO-8859-1 encoding /and/ need end-of-line conversion.")) + +(defclass flexi-utf-32-le-io-stream (flexi-utf-32-le-input-stream + flexi-utf-32-le-output-stream + flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-32 encoding with little-endian byte ordering.")) + +(defclass flexi-cr-utf-32-le-io-stream (flexi-cr-mixin flexi-utf-32-le-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-32 encoding with little-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-32-be-io-stream (flexi-utf-32-be-input-stream + flexi-utf-32-be-output-stream + flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-32 encoding with big-endian byte ordering.")) + +(defclass flexi-cr-utf-32-be-io-stream (flexi-cr-mixin flexi-utf-32-be-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-32 encoding with big-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-16-le-io-stream (flexi-utf-16-le-input-stream + flexi-utf-16-le-output-stream + flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-16 encoding with little-endian byte ordering.")) + +(defclass flexi-cr-utf-16-le-io-stream (flexi-cr-mixin flexi-utf-16-le-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-16 encoding with little-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-16-be-io-stream (flexi-utf-16-be-input-stream + flexi-utf-16-be-output-stream + flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-16 encoding with big-endian byte ordering.")) + +(defclass flexi-cr-utf-16-be-io-stream (flexi-cr-mixin flexi-utf-16-be-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-16 encoding with big-endian byte ordering /and/ need +end-of-line conversion.")) + +(defclass flexi-utf-8-io-stream (flexi-utf-8-input-stream flexi-utf-8-output-stream flexi-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-8 encoding.")) + +(defclass flexi-cr-utf-8-io-stream (flexi-cr-mixin flexi-utf-8-io-stream) + () + (:documentation "Special class for flexi I/O streams which use +the UTF-8 encoding /and/ need end-of-line conversion.")) + +(defmethod (setf flexi-stream-external-format) :after (new-value (stream flexi-stream)) + "After we've changed the external format of a flexi stream, we +might have to change its actual class and maybe also the contents +of its 8-bit encoding slots." + (declare (ignore new-value) + (optimize speed)) + ;; note that it's potentially dangerous to call SET-CLASS from + ;; within a method, see for example this thread: + ;; http://thread.gmane.org/gmane.lisp.lispworks.general/6269 + (set-class stream)) + +(defmethod set-class ((stream flexi-input-stream)) + "Changes the actual class of STREAM depending on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (let ((external-format-name (external-format-name external-format)) + (external-format-cr (not (eq (external-format-eol-style external-format) :lf)))) + (change-class stream + (cond ((ascii-name-p external-format-name) + (if external-format-cr + 'flexi-cr-ascii-input-stream + 'flexi-ascii-input-stream)) + ((eq external-format-name :iso-8859-1) + (if external-format-cr + 'flexi-cr-latin-1-input-stream + 'flexi-latin-1-input-stream)) + ((or (koi8-r-name-p external-format-name) + (iso-8859-name-p external-format-name) + (code-page-name-p external-format-name)) + (if external-format-cr + 'flexi-cr-8-bit-input-stream + 'flexi-8-bit-input-stream)) + (t (case external-format-name + (:utf-8 (if external-format-cr + 'flexi-cr-utf-8-input-stream + 'flexi-utf-8-input-stream)) + (:utf-16 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-cr-utf-16-le-input-stream + 'flexi-cr-utf-16-be-input-stream) + (if (external-format-little-endian external-format) + 'flexi-utf-16-le-input-stream + 'flexi-utf-16-be-input-stream))) + (:utf-32 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-cr-utf-32-le-input-stream + 'flexi-cr-utf-32-be-input-stream) + (if (external-format-little-endian external-format) + 'flexi-utf-32-le-input-stream + 'flexi-utf-32-be-input-stream)))))))))) + +(defmethod set-class ((stream flexi-output-stream)) + "Changes the actual class of STREAM depending on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (let ((external-format-name (external-format-name external-format)) + (external-format-cr (not (eq (external-format-eol-style external-format) :lf)))) + (change-class stream + (cond ((ascii-name-p external-format-name) + (if external-format-cr + 'flexi-cr-ascii-output-stream + 'flexi-ascii-output-stream)) + ((eq external-format-name :iso-8859-1) + (if external-format-cr + 'flexi-cr-latin-1-output-stream + 'flexi-latin-1-output-stream)) + ((or (koi8-r-name-p external-format-name) + (iso-8859-name-p external-format-name) + (code-page-name-p external-format-name)) + (if external-format-cr + 'flexi-cr-8-bit-output-stream + 'flexi-8-bit-output-stream)) + (t (case external-format-name + (:utf-8 (if external-format-cr + 'flexi-cr-utf-8-output-stream + 'flexi-utf-8-output-stream)) + (:utf-16 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-cr-utf-16-le-output-stream + 'flexi-cr-utf-16-be-output-stream) + (if (external-format-little-endian external-format) + 'flexi-utf-16-le-output-stream + 'flexi-utf-16-be-output-stream))) + (:utf-32 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-cr-utf-32-le-output-stream + 'flexi-cr-utf-32-be-output-stream) + (if (external-format-little-endian external-format) + 'flexi-utf-32-le-output-stream + 'flexi-utf-32-be-output-stream)))))))))) + +(defmethod set-class ((stream flexi-io-stream)) + "Changes the actual class of STREAM depending on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format)) + stream + (let ((external-format-name (external-format-name external-format)) + (external-format-cr (not (eq (external-format-eol-style external-format) :lf)))) + (change-class stream + (cond ((ascii-name-p external-format-name) + (if external-format-cr + 'flexi-cr-ascii-io-stream + 'flexi-ascii-io-stream)) + ((eq external-format-name :iso-8859-1) + (if external-format-cr + 'flexi-cr-latin-1-io-stream + 'flexi-latin-1-io-stream)) + ((or (koi8-r-name-p external-format-name) + (iso-8859-name-p external-format-name) + (code-page-name-p external-format-name)) + (if external-format-cr + 'flexi-cr-8-bit-io-stream + 'flexi-8-bit-io-stream)) + (t (case external-format-name + (:utf-8 (if external-format-cr + 'flexi-cr-utf-8-io-stream + 'flexi-utf-8-io-stream)) + (:utf-16 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-cr-utf-16-le-io-stream + 'flexi-cr-utf-16-be-io-stream) + (if (external-format-little-endian external-format) + 'flexi-utf-16-le-io-stream + 'flexi-utf-16-be-io-stream))) + (:utf-32 (if external-format-cr + (if (external-format-little-endian external-format) + 'flexi-cr-utf-32-le-io-stream + 'flexi-cr-utf-32-be-io-stream) + (if (external-format-little-endian external-format) + 'flexi-utf-32-le-io-stream + 'flexi-utf-32-be-io-stream)))))))))) + +(defmethod set-class :after ((stream flexi-stream)) + "After we've changed the actual class of a flexi stream we may +have to set the contents of the 8-bit enconding slots as well." + (declare (optimize speed)) + (set-encoding-table stream) + (set-encoding-hash stream)) + +(defgeneric set-encoding-table (stream) + (:method (stream)) + (:documentation "Sets the value of the ENCODING-TABLE slot of +STREAM if necessary. The default method does nothing.")) + +(defgeneric set-encoding-hash (stream) + (:method (stream)) + (:documentation "Sets the value of the ENCODING-HASH slot of +STREAM if necessary. The default method does nothing.")) + +(defmethod set-encoding-table ((stream flexi-8-bit-input-stream)) + "Sets the value of the ENCODING-TABLE slot of STREAM depending +on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format) + (encoding-table flexi-stream-encoding-table)) + stream + (let ((external-format-name (external-format-name external-format))) + (setq encoding-table + (cond ((ascii-name-p external-format-name) +ascii-table+) + ((koi8-r-name-p external-format-name) +koi8-r-table+) + ((iso-8859-name-p external-format-name) + (cdr (assoc external-format-name +iso-8859-tables+ :test #'eq))) + ((code-page-name-p external-format-name) + (cdr (assoc (external-format-id external-format) +code-page-tables+)))))))) + +(defmethod set-encoding-hash ((stream flexi-8-bit-output-stream)) + "Sets the value of the ENCODING-HASH slot of STREAM depending +on its external format." + (declare (optimize speed)) + (with-accessors ((external-format flexi-stream-external-format) + (encoding-hash flexi-stream-encoding-hash)) + stream + (let ((external-format-name (external-format-name external-format))) + (setq encoding-hash + (cond ((ascii-name-p external-format-name) +ascii-hash+) + ((koi8-r-name-p external-format-name) +koi8-r-hash+) + ((iso-8859-name-p external-format-name) + (cdr (assoc external-format-name +iso-8859-hashes+ :test #'eq))) + ((code-page-name-p external-format-name) + (cdr (assoc (external-format-id external-format) +code-page-hashes+)))))))) + + +#+:cmu +(defmethod input-stream-p ((stream flexi-io-stream)) + "Explicitly states whether this is an input stream." + (declare (optimize speed)) + t) + +#+:cmu +(defmethod output-stream-p ((stream flexi-io-stream)) + "Explicitly states whether this is an output stream." + (declare (optimize speed)) + t) + +(defun make-flexi-stream (stream &rest args + &key (external-format (make-external-format :iso-8859-1)) + element-type column position bound) + "Creates and returns a new flexi stream. STREAM must be an open +binary or `bivalent' stream, i.e. it must be capable of +reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE. The +resulting flexi stream is an input stream if and only if STREAM is an +input stream. Likewise, it's an output stream if and only if STREAM +is an output stream. The default for ELEMENT-TYPE is LW:SIMPLE-CHAR +on LispWorks and CHARACTER on other Lisps. EXTERNAL-FORMAT must be an +EXTERNAL-FORMAT object or a symbol or a list denoting such an object. +COLUMN is the initial column of the stream which is either a +non-negative integer or NIL. The COLUMN argument must only be used +for output streams. POSITION (only used for input streams) should be +an integer and it denotes the position the stream is in - it will be +increased by one for each octet read. BOUND (only used for input +streams) should be NIL or an integer. If BOUND is not NIL and +POSITION has gone beyond BOUND, then the stream will behave as if no +more input is available." + ;; these arguments are ignored - they are only there to provide a + ;; meaningful parameter list for IDEs + (declare (ignore element-type column position bound)) + (unless (and (streamp stream) + (open-stream-p stream)) + (error "~S should have been an open stream." stream)) + (apply #'make-instance + ;; actual type depends on STREAM + (cond ((and (input-stream-p stream) + (output-stream-p stream)) + 'flexi-io-stream) + ((input-stream-p stream) + 'flexi-input-stream) + ((output-stream-p stream) + 'flexi-output-stream)) + :stream stream + :flexi-stream-external-format external-format + (sans args :external-format)))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/strings.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/strings.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/strings.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,56 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/strings.lisp,v 1.4 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +(defun string-to-octets (string &key (external-format (make-external-format :latin1)) + (start 0) end) + "Converts the Lisp string STRING from START to END to an array of +octets corresponding to the external format EXTERNAL-FORMAT." + (declare (optimize speed)) + (with-output-to-sequence (out) + (let ((flexi (make-flexi-stream out :external-format external-format))) + (write-string string flexi :start start :end end)))) + +(defun octets-to-string (vector &key (external-format (make-external-format :latin1)) + (start 0) (end (length vector))) + "Converts the Lisp vector VECTOR of octets from START to END to +string using the external format EXTERNAL-FORMAT." + (declare (optimize speed)) + (with-input-from-sequence (in vector :start start :end end) + (let ((flexi (make-flexi-stream in :external-format external-format)) + (result (make-array (- end start) + :element-type #+:lispworks 'lw:simple-char + #-:lispworks 'character + :fill-pointer t))) + (setf (fill-pointer result) + (read-sequence result flexi)) + result))) + +
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/README =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/README 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/README 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,4 @@ +The reference files in this directory were created/converted using a +mixture of GNU recode and the native internationalization facilities +of LispWorks and AllegroCL, i.e. we're not testing FLEXI-STREAMS +against files created by itself (which would be kind of useless). \ No newline at end of file
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/README ___________________________________________________________________ Name: svn:executable + *
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +:���� ��� ����� �� ����� ��� ������ � 1 ���� ���-�� ���� ���� ��� ���� ����� � 2 :���� ���-�� ����� ����� ���� :���-���� ��� ��� ����� ����� � 3 ����� ����� ���-�� ����-�� ����� ���� � 4 :���� ���� ���� ��� ���� ��� ����� ��� ���� ����� ����� � 5 :��� ��� ���-���� ���-���� ���� ���� ���� ���� ��� ����� ����� � 6 :���� ��� ��� ����� ��� ���� ��� ����� �����-�� ����� ���� � 7 ����� ��� ��� ���� ���� ����� ���� :��-���� ���-���� ���-���� ���� ����� ����� ����� � 8 :��� ��� ����-�� ����� ���� ���� ���� ����� ����� � 9 :��-���� ����� ����� ��� ��� ���� ������ ��� ����� ����� ����� � 10 :���-�� ����� ���� ���� ��� ����� ��� ��� ���� ���� ����� ����� �� 11 ����-�� ��-���� ��� ����� ��� ��� ��� �� :��-���� ��� ������ ��� ����� ��� ��� ���� ����� �� 12 ����� ���� ������ ��-���� ��� ���-��� :���-�� :����� ��� ���-���� ���-���� �� 13 ������ ����� ����� ���� ��� ����� ����� �� 14 �������� ���� ���� ����� ���� ���� ��� :����� ������ ����-�� ����� ����� ����� ������ ���� �� 15 :��-���� �����-�� ������ ����� ���-�� ����� ���� �� 16 ������ ���� �����-��� ���� ������ ���� :������� ��� ����� ����� ����� ����� ����� ��� ���� �� 17 :����-�� ���� ���� ��� ������� ������ ���� ����� �� 18 :���-�� ����� ���� ���� :����� ��� ���-���� ���-���� �� 19 ���� ��� ��� ��� ���� ����� ����� ����� � 20 :����� ���� ���-�� ����-�� ����� ���-�� ��� ������ ������-�� ����� ����� �� 21 ��� ������ ���� ���� ��� ����� ���� :���-�� ����� ���� ������ ��� ���-�� ����� ���� ��� ���� ����� ��� ����� �� 22 :���� ��� ����� ����� ����-�� :����� ��� ���-���� ���-���� �� 23 ���� ����� ��� ��� ���� ���� ����� ����� �� 24 :��-���� ����� ���-����� ���� �����-��� ����� ���� ���-�� ����� ���� �� 25 ����� ���� ������ ����� ���-�� ��� ����� :���-�� ������� ������ ��� ���� ����� ����� �� 26 ������ ����� ����� ��� ���� ����� :����-�� ���� ����-���� ����-���� ��� ����� ���� ����� ����-�� ����� ����� �� 27 :��� ��� ����� ��� ��� ���� ��� ����� ��� ����� ����� ��� ����� �� 28 ����� ��� ���� ���� ����� ����-�� ����� :����-�� ����� ���-���� ����� ��� ���-��-�� ��� ���� ��� ����� ����� �� 29 ��-��� ���-��-��� ����-�� ���-�� ��� ��� :����� ���� ��� ��� ��� ��-��� ���� ���� ����� ���-���� ���� ���-���� � 30 ��� ���-��-�� ��� ��� ��-��� ����-�� :��-���� ����� ��� ���-���� ��� ���-��-�� ����� ���� �� 31 :���� ��� ���-���� �� \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,68 @@ +:���� ��� ����� �� ����� ��� ������ � 1 +���� ���-�� ���� ���� ��� ���� ����� � 2 +:���� ���-�� ����� ����� ���� +:���-���� ��� ��� ����� ����� � 3 +����� ����� ���-�� ����-�� ����� ���� � 4 +:���� ���� ���� ��� +���� ��� ����� ��� ���� ����� ����� � 5 +:��� ��� ���-���� ���-���� +���� ���� ���� ���� ��� ����� ����� � 6 +:���� ��� ��� ����� +��� ���� ��� ����� �����-�� ����� ���� � 7 +����� ��� ��� ���� ���� ����� ���� +:��-���� +���-���� ���-���� ���� ����� ����� ����� � 8 +:��� ��� +����-�� ����� ���� ���� ���� ����� ����� � 9 +:��-���� ����� ����� ��� +��� ���� ������ ��� ����� ����� ����� � 10 +:���-�� ����� ���� ���� +��� ����� ��� ��� ���� ���� ����� ����� �� 11 +����-�� ��-���� ��� ����� ��� ��� ��� �� +:��-���� +��� ������ ��� ����� ��� ��� ���� ����� �� 12 +����� ���� ������ ��-���� ��� ���-��� +:���-�� +:����� ��� ���-���� ���-���� �� 13 +������ ����� ����� ���� ��� ����� ����� �� 14 +�������� ���� ���� ����� ���� ���� ��� +:����� ������ +����-�� ����� ����� ����� ������ ���� �� 15 +:��-���� +�����-�� ������ ����� ���-�� ����� ���� �� 16 +������ ���� �����-��� ���� ������ ���� +:������� ��� ����� +����� ����� ����� ����� ��� ���� �� 17 +:����-�� +���� ���� ��� ������� ������ ���� ����� �� 18 +:���-�� ����� ���� ���� +:����� ��� ���-���� ���-���� �� 19 +���� ��� ��� ��� ���� ����� ����� ����� � 20 +:����� ���� ���-�� ����-�� ����� +���-�� ��� ������ ������-�� ����� ����� �� 21 +��� ������ ���� ���� ��� ����� ���� +:���-�� ����� ���� ������ ��� ���-�� +����� ���� ��� ���� ����� ��� ����� �� 22 +:���� ��� ����� ����� ����-�� +:����� ��� ���-���� ���-���� �� 23 +���� ����� ��� ��� ���� ���� ����� ����� �� 24 +:��-���� ����� ���-����� ���� +�����-��� ����� ���� ���-�� ����� ���� �� 25 +����� ���� ������ ����� ���-�� ��� ����� +:���-�� +������� ������ ��� ���� ����� ����� �� 26 +������ ����� ����� ��� ���� ����� +:����-�� ���� ����-���� ����-���� +��� ����� ���� ����� ����-�� ����� ����� �� 27 +:��� ��� ����� ��� ��� +���� ��� ����� ��� ����� ����� ��� ����� �� 28 +����� ��� ���� ���� ����� ����-�� ����� +:����-�� ����� ���-���� ����� +��� ���-��-�� ��� ���� ��� ����� ����� �� 29 +��-��� ���-��-��� ����-�� ���-�� ��� ��� +:����� ���� ��� ��� ��� ��-��� +���� ���� ����� ���-���� ���� ���-���� � 30 +��� ���-��-�� ��� ��� ��-��� ����-�� +:��-���� ����� +��� ���-���� ��� ���-��-�� ����� ���� �� 31 +:���� ��� ���-���� ��
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_latin8_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,68 @@ +:���� ��� ����� �� ����� ��� ������ � 1 +���� ���-�� ���� ���� ��� ���� ����� � 2 +:���� ���-�� ����� ����� ���� +:���-���� ��� ��� ����� ����� � 3 +����� ����� ���-�� ����-�� ����� ���� � 4 +:���� ���� ���� ��� +���� ��� ����� ��� ���� ����� ����� � 5 +:��� ��� ���-���� ���-���� +���� ���� ���� ���� ��� ����� ����� � 6 +:���� ��� ��� ����� +��� ���� ��� ����� �����-�� ����� ���� � 7 +����� ��� ��� ���� ���� ����� ���� +:��-���� +���-���� ���-���� ���� ����� ����� ����� � 8 +:��� ��� +����-�� ����� ���� ���� ���� ����� ����� � 9 +:��-���� ����� ����� ��� +��� ���� ������ ��� ����� ����� ����� � 10 +:���-�� ����� ���� ���� +��� ����� ��� ��� ���� ���� ����� ����� �� 11 +����-�� ��-���� ��� ����� ��� ��� ��� �� +:��-���� +��� ������ ��� ����� ��� ��� ���� ����� �� 12 +����� ���� ������ ��-���� ��� ���-��� +:���-�� +:����� ��� ���-���� ���-���� �� 13 +������ ����� ����� ���� ��� ����� ����� �� 14 +�������� ���� ���� ����� ���� ���� ��� +:����� ������ +����-�� ����� ����� ����� ������ ���� �� 15 +:��-���� +�����-�� ������ ����� ���-�� ����� ���� �� 16 +������ ���� �����-��� ���� ������ ���� +:������� ��� ����� +����� ����� ����� ����� ��� ���� �� 17 +:����-�� +���� ���� ��� ������� ������ ���� ����� �� 18 +:���-�� ����� ���� ���� +:����� ��� ���-���� ���-���� �� 19 +���� ��� ��� ��� ���� ����� ����� ����� � 20 +:����� ���� ���-�� ����-�� ����� +���-�� ��� ������ ������-�� ����� ����� �� 21 +��� ������ ���� ���� ��� ����� ���� +:���-�� ����� ���� ������ ��� ���-�� +����� ���� ��� ���� ����� ��� ����� �� 22 +:���� ��� ����� ����� ����-�� +:����� ��� ���-���� ���-���� �� 23 +���� ����� ��� ��� ���� ���� ����� ����� �� 24 +:��-���� ����� ���-����� ���� +�����-��� ����� ���� ���-�� ����� ���� �� 25 +����� ���� ������ ����� ���-�� ��� ����� +:���-�� +������� ������ ��� ���� ����� ����� �� 26 +������ ����� ����� ��� ���� ����� +:����-�� ���� ����-���� ����-���� +��� ����� ���� ����� ����-�� ����� ����� �� 27 +:��� ��� ����� ��� ��� +���� ��� ����� ��� ����� ����� ��� ����� �� 28 +����� ��� ���� ���� ����� ����-�� ����� +:����-�� ����� ���-���� ����� +��� ���-��-�� ��� ���� ��� ����� ����� �� 29 +��-��� ���-��-��� ����-�� ���-�� ��� ��� +:����� ���� ��� ��� ��� ��-��� +���� ���� ����� ���-���� ���� ���-���� � 30 +��� ���-��-�� ��� ��� ��-��� ����-�� +:��-���� ����� +��� ���-���� ��� ���-��-�� ����� ���� �� 31 +:���� ��� ���-���� ��
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +:ץראה תאו םימשה תא םיהלא ארב תישארב א 1 םוהת ינפ-לע ךשחו והבו והת התיה ץראהו ב 2 :םימה ינפ-לע תפחרמ םיהלא חורו :רוא-יהיו רוא יהי םיהלא רמאיו ג 3 םיהלא לדביו בוט-יכ רואה-תא םיהלא אריו ד 4 :ךשחה ןיבו רואה ןיב הליל ארק ךשחלו םוי רואל םיהלא ארקיו ה 5 :דחא םוי רקב-יהיו ברע-יהיו יהיו םימה ךותב עיקר יהי םיהלא רמאיו ו 6 :םימל םימ ןיב לידבמ רשא םימה ןיב לדביו עיקרה-תא םיהלא שעיו ז 7 עיקרל לעמ רשא םימה ןיבו עיקרל תחתמ :ןכ-יהיו רקב-יהיו ברע-יהיו םימש עיקרל םיהלא ארקיו ח 8 :ינש םוי םוקמ-לא םימשה תחתמ םימה ווקי םיהלא רמאיו ט 9 :ןכ-יהיו השביה הארתו דחא ארק םימה הוקמלו ץרא השביל םיהלא ארקיו י 10 :בוט-יכ םיהלא אריו םימי ערז עירזמ בשע אשד ץראה אשדת םיהלא רמאיו אי 11 ץראה-לע וב-וערז רשא ונימל ירפ השע ירפ ץע :ןכ-יהיו ץעו והנימל ערז עירזמ בשע אשד ץראה אצותו בי 12 םיהלא אריו והנימל וב-וערז רשא ירפ-השע :בוט-יכ :ישילש םוי רקב-יהיו ברע-יהיו גי 13 לידבהל םימשה עיקרב תראמ יהי םיהלא רמאיו די 14 םידעומלו תתאל ויהו הלילה ןיבו םויה ןיב :םינשו םימילו ץראה-לע ריאהל םימשה עיקרב תרואמל ויהו וט 15 :ןכ-יהיו רואמה-תא םילדגה תראמה ינש-תא םיהלא שעיו זט 16 תלשממל ןטקה רואמה-תאו םויה תלשממל לדגה :םיבכוכה תאו הלילה ריאהל םימשה עיקרב םיהלא םתא ןתיו זי 17 :ץראה-לע ןיבו רואה ןיב לידבהלו הלילבו םויב לשמלו חי 18 :בוט-יכ םיהלא אריו ךשחה :יעיבר םוי רקב-יהיו ברע-יהיו טי 19 ףועו היח שפנ ץרש םימה וצרשי םיהלא רמאיו כ 20 :םימשה עיקר ינפ-לע ץראה-לע ףפועי שפנ-לכ תאו םילדגה םנינתה-תא םיהלא ארביו אכ 21 תאו םהנימל םימה וצרש רשא תשמרה היחה :בוט-יכ םיהלא אריו והנימל ףנכ ףוע-לכ ואלמו וברו ורפ רמאל םיהלא םתא ךרביו בכ 22 :ץראב ברי ףועהו םימיב םימה-תא :ישימח םוי רקב-יהיו ברע-יהיו גכ 23 המהב הנימל היח שפנ ץראה אצות םיהלא רמאיו דכ 24 :ןכ-יהיו הנימל ץרא-ותיחו שמרו המהבה-תאו הנימל ץראה תיח-תא םיהלא שעיו הכ 25 םיהלא אריו והנימל המדאה שמר-לכ תאו הנימל :בוט-יכ ונתומדכ ונמלצב םדא השענ םיהלא רמאיו וכ 26 המהבבו םימשה ףועבו םיה תגדב ודריו :ץראה-לע שמרה שמרה-לכבו ץראה-לכבו ארב םיהלא םלצב ומלצב םדאה-תא םיהלא ארביו זכ 27 :םתא ארב הבקנו רכז ותא וברו ורפ םיהלא םהל רמאיו םיהלא םתא ךרביו חכ 28 ףועבו םיה תגדב ודרו השבכו ץראה-תא ואלמו :ץראה-לע תשמרה היח-לכבו םימשה ערז בשע-לכ-תא םכל יתתנ הנה םיהלא רמאיו טכ 29 וב-רשא ץעה-לכ-תאו ץראה-לכ ינפ-לע רשא ערז :הלכאל היהי םכל ערז ערז ץע-ירפ שמור לכלו םימשה ףוע-לכלו ץראה תיח-לכלו ל 30 בשע קרי-לכ-תא היח שפנ וב-רשא ץראה-לע :ןכ-יהיו הלכאל דאמ בוט-הנהו השע רשא-לכ-תא םיהלא אריו אל 31 :יששה םוי רקב-יהיו בר \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,68 @@ +:ץראה תאו םימשה תא םיהלא ארב תישארב א 1 +םוהת ינפ-לע ךשחו והבו והת התיה ץראהו ב 2 +:םימה ינפ-לע תפחרמ םיהלא חורו +:רוא-יהיו רוא יהי םיהלא רמאיו ג 3 +םיהלא לדביו בוט-יכ רואה-תא םיהלא אריו ד 4 +:ךשחה ןיבו רואה ןיב +הליל ארק ךשחלו םוי רואל םיהלא ארקיו ה 5 +:דחא םוי רקב-יהיו ברע-יהיו +יהיו םימה ךותב עיקר יהי םיהלא רמאיו ו 6 +:םימל םימ ןיב לידבמ +רשא םימה ןיב לדביו עיקרה-תא םיהלא שעיו ז 7 +עיקרל לעמ רשא םימה ןיבו עיקרל תחתמ +:ןכ-יהיו +רקב-יהיו ברע-יהיו םימש עיקרל םיהלא ארקיו ח 8 +:ינש םוי +םוקמ-לא םימשה תחתמ םימה ווקי םיהלא רמאיו ט 9 +:ןכ-יהיו השביה הארתו דחא +ארק םימה הוקמלו ץרא השביל םיהלא ארקיו י 10 +:בוט-יכ םיהלא אריו םימי +ערז עירזמ בשע אשד ץראה אשדת םיהלא רמאיו אי 11 +ץראה-לע וב-וערז רשא ונימל ירפ השע ירפ ץע +:ןכ-יהיו +ץעו והנימל ערז עירזמ בשע אשד ץראה אצותו בי 12 +םיהלא אריו והנימל וב-וערז רשא ירפ-השע +:בוט-יכ +:ישילש םוי רקב-יהיו ברע-יהיו גי 13 +לידבהל םימשה עיקרב תראמ יהי םיהלא רמאיו די 14 +םידעומלו תתאל ויהו הלילה ןיבו םויה ןיב +:םינשו םימילו +ץראה-לע ריאהל םימשה עיקרב תרואמל ויהו וט 15 +:ןכ-יהיו +רואמה-תא םילדגה תראמה ינש-תא םיהלא שעיו זט 16 +תלשממל ןטקה רואמה-תאו םויה תלשממל לדגה +:םיבכוכה תאו הלילה +ריאהל םימשה עיקרב םיהלא םתא ןתיו זי 17 +:ץראה-לע +ןיבו רואה ןיב לידבהלו הלילבו םויב לשמלו חי 18 +:בוט-יכ םיהלא אריו ךשחה +:יעיבר םוי רקב-יהיו ברע-יהיו טי 19 +ףועו היח שפנ ץרש םימה וצרשי םיהלא רמאיו כ 20 +:םימשה עיקר ינפ-לע ץראה-לע ףפועי +שפנ-לכ תאו םילדגה םנינתה-תא םיהלא ארביו אכ 21 +תאו םהנימל םימה וצרש רשא תשמרה היחה +:בוט-יכ םיהלא אריו והנימל ףנכ ףוע-לכ +ואלמו וברו ורפ רמאל םיהלא םתא ךרביו בכ 22 +:ץראב ברי ףועהו םימיב םימה-תא +:ישימח םוי רקב-יהיו ברע-יהיו גכ 23 +המהב הנימל היח שפנ ץראה אצות םיהלא רמאיו דכ 24 +:ןכ-יהיו הנימל ץרא-ותיחו שמרו +המהבה-תאו הנימל ץראה תיח-תא םיהלא שעיו הכ 25 +םיהלא אריו והנימל המדאה שמר-לכ תאו הנימל +:בוט-יכ +ונתומדכ ונמלצב םדא השענ םיהלא רמאיו וכ 26 +המהבבו םימשה ףועבו םיה תגדב ודריו +:ץראה-לע שמרה שמרה-לכבו ץראה-לכבו +ארב םיהלא םלצב ומלצב םדאה-תא םיהלא ארביו זכ 27 +:םתא ארב הבקנו רכז ותא +וברו ורפ םיהלא םהל רמאיו םיהלא םתא ךרביו חכ 28 +ףועבו םיה תגדב ודרו השבכו ץראה-תא ואלמו +:ץראה-לע תשמרה היח-לכבו םימשה +ערז בשע-לכ-תא םכל יתתנ הנה םיהלא רמאיו טכ 29 +וב-רשא ץעה-לכ-תאו ץראה-לכ ינפ-לע רשא ערז +:הלכאל היהי םכל ערז ערז ץע-ירפ +שמור לכלו םימשה ףוע-לכלו ץראה תיח-לכלו ל 30 +בשע קרי-לכ-תא היח שפנ וב-רשא ץראה-לע +:ןכ-יהיו הלכאל +דאמ בוט-הנהו השע רשא-לכ-תא םיהלא אריו אל 31 +:יששה םוי רקב-יהיו בר
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/hebrew_utf8_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,68 @@ +:ץראה תאו םימשה תא םיהלא ארב תישארב א 1 +םוהת ינפ-לע ךשחו והבו והת התיה ץראהו ב 2 +:םימה ינפ-לע תפחרמ םיהלא חורו +:רוא-יהיו רוא יהי םיהלא רמאיו ג 3 +םיהלא לדביו בוט-יכ רואה-תא םיהלא אריו ד 4 +:ךשחה ןיבו רואה ןיב +הליל ארק ךשחלו םוי רואל םיהלא ארקיו ה 5 +:דחא םוי רקב-יהיו ברע-יהיו +יהיו םימה ךותב עיקר יהי םיהלא רמאיו ו 6 +:םימל םימ ןיב לידבמ +רשא םימה ןיב לדביו עיקרה-תא םיהלא שעיו ז 7 +עיקרל לעמ רשא םימה ןיבו עיקרל תחתמ +:ןכ-יהיו +רקב-יהיו ברע-יהיו םימש עיקרל םיהלא ארקיו ח 8 +:ינש םוי +םוקמ-לא םימשה תחתמ םימה ווקי םיהלא רמאיו ט 9 +:ןכ-יהיו השביה הארתו דחא +ארק םימה הוקמלו ץרא השביל םיהלא ארקיו י 10 +:בוט-יכ םיהלא אריו םימי +ערז עירזמ בשע אשד ץראה אשדת םיהלא רמאיו אי 11 +ץראה-לע וב-וערז רשא ונימל ירפ השע ירפ ץע +:ןכ-יהיו +ץעו והנימל ערז עירזמ בשע אשד ץראה אצותו בי 12 +םיהלא אריו והנימל וב-וערז רשא ירפ-השע +:בוט-יכ +:ישילש םוי רקב-יהיו ברע-יהיו גי 13 +לידבהל םימשה עיקרב תראמ יהי םיהלא רמאיו די 14 +םידעומלו תתאל ויהו הלילה ןיבו םויה ןיב +:םינשו םימילו +ץראה-לע ריאהל םימשה עיקרב תרואמל ויהו וט 15 +:ןכ-יהיו +רואמה-תא םילדגה תראמה ינש-תא םיהלא שעיו זט 16 +תלשממל ןטקה רואמה-תאו םויה תלשממל לדגה +:םיבכוכה תאו הלילה +ריאהל םימשה עיקרב םיהלא םתא ןתיו זי 17 +:ץראה-לע +ןיבו רואה ןיב לידבהלו הלילבו םויב לשמלו חי 18 +:בוט-יכ םיהלא אריו ךשחה +:יעיבר םוי רקב-יהיו ברע-יהיו טי 19 +ףועו היח שפנ ץרש םימה וצרשי םיהלא רמאיו כ 20 +:םימשה עיקר ינפ-לע ץראה-לע ףפועי +שפנ-לכ תאו םילדגה םנינתה-תא םיהלא ארביו אכ 21 +תאו םהנימל םימה וצרש רשא תשמרה היחה +:בוט-יכ םיהלא אריו והנימל ףנכ ףוע-לכ +ואלמו וברו ורפ רמאל םיהלא םתא ךרביו בכ 22 +:ץראב ברי ףועהו םימיב םימה-תא +:ישימח םוי רקב-יהיו ברע-יהיו גכ 23 +המהב הנימל היח שפנ ץראה אצות םיהלא רמאיו דכ 24 +:ןכ-יהיו הנימל ץרא-ותיחו שמרו +המהבה-תאו הנימל ץראה תיח-תא םיהלא שעיו הכ 25 +םיהלא אריו והנימל המדאה שמר-לכ תאו הנימל +:בוט-יכ +ונתומדכ ונמלצב םדא השענ םיהלא רמאיו וכ 26 +המהבבו םימשה ףועבו םיה תגדב ודריו +:ץראה-לע שמרה שמרה-לכבו ץראה-לכבו +ארב םיהלא םלצב ומלצב םדאה-תא םיהלא ארביו זכ 27 +:םתא ארב הבקנו רכז ותא +וברו ורפ םיהלא םהל רמאיו םיהלא םתא ךרביו חכ 28 +ףועבו םיה תגדב ודרו השבכו ץראה-תא ואלמו +:ץראה-לע תשמרה היח-לכבו םימשה +ערז בשע-לכ-תא םכל יתתנ הנה םיהלא רמאיו טכ 29 +וב-רשא ץעה-לכ-תאו ץראה-לכ ינפ-לע רשא ערז +:הלכאל היהי םכל ערז ערז ץע-ירפ +שמור לכלו םימשה ףוע-לכלו ץראה תיח-לכלו ל 30 +בשע קרי-לכ-תא היח שפנ וב-רשא ץראה-לע +:ןכ-יהיו הלכאל +דאמ בוט-הנהו השע רשא-לכ-תא םיהלא אריו אל 31 +:יששה םוי רקב-יהיו בר
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +Als Gregor Samsa eines Morgens aus unruhigen Tr�umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten R�cken und sah, wenn er den Kopf ein wenig hob, seinen gew�lbten, braunen, von bogenf�rmigen Versteifungen geteilten Bauch, auf dessen H�he sich die Bettdecke, zum g�nzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kl�glich d�nnen Beine flimmerten ihm hilflos vor den Augen.
�Was ist mit mir geschehen?�, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten W�nden. �ber dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem h�bschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasa� und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob.
Gregors Blick richtete sich dann zum Fenster, und das tr�be Wetter - man h�rte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. �Wie w�re es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten verg��e�, dachte er, aber das war g�nzlich undurchf�hrbar, denn er war gew�hnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenw�rtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die R�ckenlage zur�ck. Er versuchte es wohl hundertmal, schlo� die Augen, um die zappelnden Beine nicht sehen zu m�ssen, und lie� erst ab, als er in der Seite einen noch nie gef�hlten, leichten, dumpfen Schmerz zu f�hlen begann.
�Ach Gott�, dachte er, �was f�r einen anstrengenden Beruf habe ich gew�hlt! Tag aus, Tag ein auf der Reise. Die gesch�ftlichen Aufregungen sind viel gr��er, als im eigentlichen Gesch�ft zu Hause, und au�erdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschl�sse, das unregelm��ige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!� Er f�hlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem R�cken langsam n�her zum Bettpfosten, um den Kopf besser heben zu k�nnen; fand die juckende Stelle, die mit lauter kleinen wei�en P�nktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zur�ck, denn bei der Ber�hrung umwehten ihn K�lteschauer.
Er glitt wieder in seine fr�here Lage zur�ck. �Dies fr�hzeitige Aufstehen�, dachte er, �macht einen ganz bl�dsinnig. Der Mensch mu� seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zur�ckgehe, um die erlangten Auftr�ge zu �berschreiben, sitzen diese Herren erst beim Fr�hst�ck. Das sollte ich bei meinem Chef versuchen; ich w�rde auf der Stelle hinausfliegen. Wer wei� �brigens, ob das nicht sehr gut f�r mich w�re. Wenn ich mich nicht wegen meiner Eltern zur�ckhielte, ich h�tte l�ngst gek�ndigt, ich w�re vor den Chef hin getreten und h�tte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult h�tte er fallen m�ssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der H�he herab mit dem Angestellten zu reden, der �berdies wegen der Schwerh�rigkeit des Chefs ganz nahe herantreten mu�. Nun, die Hoffnung ist noch nicht g�nzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es d�rfte noch f�nf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der gro�e Schnitt gemacht. Vorl�ufig allerdings mu� ich aufstehen, denn mein Zug f�hrt um f�nf.�
Und er sah zur Weckuhr hin�ber, die auf dem Kasten tickte. �Himmlischer Vater!�, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorw�rts, es war sogar halb vor�ber, es n�herte sich schon dreiviertel. Sollte der Wecker nicht gel�utet haben? Man sah vom Bett aus, da� er auf vier Uhr richtig eingestellt war; gewi� hatte er auch gel�utet. Ja, aber war es m�glich, dieses m�belersch�tternde L�uten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der n�chste Zug ging um sieben Uhr; um den einzuholen, h�tte er sich unsinnig beeilen m�ssen, und die Kollektion war noch nicht eingepackt, und er selbst f�hlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Gesch�ftsdiener hatte beim F�nfuhrzug gewartet und die Meldung von seiner Vers�umnis l�ngst erstattet. Es war eine Kreatur des Chefs, ohne R�ckgrat und Verstand. Wie nun, wenn er sich krank meldete? Das w�re aber �u�erst peinlich und verd�chtig, denn Gregor war w�hrend seines f�nfj�hrigen Dienstes noch nicht einmal krank gewesen. Gewi� w�rde der Chef mit dem Krankenkassenarzt kommen, w�rde den Eltern wegen des faulen Sohnes Vorw�rfe machen und alle Einw�nde durch den Hinweis auf den Krankenkassenarzt abschneiden, f�r den es ja �berhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und h�tte er �brigens in diesem Falle so ganz unrecht? Gregor f�hlte sich tats�chlich, abgesehen von einer nach dem langen Schlaf wirklich �berfl�ssigen Schl�frigkeit, ganz wohl und hatte sogar einen besonders kr�ftigen Hunger. \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,11 @@ +Als Gregor Samsa eines Morgens aus unruhigen Tr�umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten R�cken und sah, wenn er den Kopf ein wenig hob, seinen gew�lbten, braunen, von bogenf�rmigen Versteifungen geteilten Bauch, auf dessen H�he sich die Bettdecke, zum g�nzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kl�glich d�nnen Beine flimmerten ihm hilflos vor den Augen. + +�Was ist mit mir geschehen?�, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten W�nden. �ber dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem h�bschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasa� und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob. + +Gregors Blick richtete sich dann zum Fenster, und das tr�be Wetter - man h�rte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. �Wie w�re es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten verg��e�, dachte er, aber das war g�nzlich undurchf�hrbar, denn er war gew�hnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenw�rtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die R�ckenlage zur�ck. Er versuchte es wohl hundertmal, schlo� die Augen, um die zappelnden Beine nicht sehen zu m�ssen, und lie� erst ab, als er in der Seite einen noch nie gef�hlten, leichten, dumpfen Schmerz zu f�hlen begann. + +�Ach Gott�, dachte er, �was f�r einen anstrengenden Beruf habe ich gew�hlt! Tag aus, Tag ein auf der Reise. Die gesch�ftlichen Aufregungen sind viel gr��er, als im eigentlichen Gesch�ft zu Hause, und au�erdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschl�sse, das unregelm��ige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!� Er f�hlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem R�cken langsam n�her zum Bettpfosten, um den Kopf besser heben zu k�nnen; fand die juckende Stelle, die mit lauter kleinen wei�en P�nktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zur�ck, denn bei der Ber�hrung umwehten ihn K�lteschauer. + +Er glitt wieder in seine fr�here Lage zur�ck. �Dies fr�hzeitige Aufstehen�, dachte er, �macht einen ganz bl�dsinnig. Der Mensch mu� seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zur�ckgehe, um die erlangten Auftr�ge zu �berschreiben, sitzen diese Herren erst beim Fr�hst�ck. Das sollte ich bei meinem Chef versuchen; ich w�rde auf der Stelle hinausfliegen. Wer wei� �brigens, ob das nicht sehr gut f�r mich w�re. Wenn ich mich nicht wegen meiner Eltern zur�ckhielte, ich h�tte l�ngst gek�ndigt, ich w�re vor den Chef hin getreten und h�tte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult h�tte er fallen m�ssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der H�he herab mit dem Angestellten zu reden, der �berdies wegen der Schwerh�rigkeit des Chefs ganz nahe herantreten mu�. Nun, die Hoffnung ist noch nicht g�nzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es d�rfte noch f�nf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der gro�e Schnitt gemacht. Vorl�ufig allerdings mu� ich aufstehen, denn mein Zug f�hrt um f�nf.� + +Und er sah zur Weckuhr hin�ber, die auf dem Kasten tickte. �Himmlischer Vater!�, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorw�rts, es war sogar halb vor�ber, es n�herte sich schon dreiviertel. Sollte der Wecker nicht gel�utet haben? Man sah vom Bett aus, da� er auf vier Uhr richtig eingestellt war; gewi� hatte er auch gel�utet. Ja, aber war es m�glich, dieses m�belersch�tternde L�uten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der n�chste Zug ging um sieben Uhr; um den einzuholen, h�tte er sich unsinnig beeilen m�ssen, und die Kollektion war noch nicht eingepackt, und er selbst f�hlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Gesch�ftsdiener hatte beim F�nfuhrzug gewartet und die Meldung von seiner Vers�umnis l�ngst erstattet. Es war eine Kreatur des Chefs, ohne R�ckgrat und Verstand. Wie nun, wenn er sich krank meldete? Das w�re aber �u�erst peinlich und verd�chtig, denn Gregor war w�hrend seines f�nfj�hrigen Dienstes noch nicht einmal krank gewesen. Gewi� w�rde der Chef mit dem Krankenkassenarzt kommen, w�rde den Eltern wegen des faulen Sohnes Vorw�rfe machen und alle Einw�nde durch den Hinweis auf den Krankenkassenarzt abschneiden, f�r den es ja �berhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und h�tte er �brigens in diesem Falle so ganz unrecht? Gregor f�hlte sich tats�chlich, abgesehen von einer nach dem langen Schlaf wirklich �berfl�ssigen Schl�frigkeit, ganz wohl und hatte sogar einen besonders kr�ftigen Hunger.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_cp1252_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,11 @@ +Als Gregor Samsa eines Morgens aus unruhigen Tr�umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten R�cken und sah, wenn er den Kopf ein wenig hob, seinen gew�lbten, braunen, von bogenf�rmigen Versteifungen geteilten Bauch, auf dessen H�he sich die Bettdecke, zum g�nzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kl�glich d�nnen Beine flimmerten ihm hilflos vor den Augen. + +�Was ist mit mir geschehen?�, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten W�nden. �ber dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem h�bschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasa� und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob. + +Gregors Blick richtete sich dann zum Fenster, und das tr�be Wetter - man h�rte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. �Wie w�re es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten verg��e�, dachte er, aber das war g�nzlich undurchf�hrbar, denn er war gew�hnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenw�rtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die R�ckenlage zur�ck. Er versuchte es wohl hundertmal, schlo� die Augen, um die zappelnden Beine nicht sehen zu m�ssen, und lie� erst ab, als er in der Seite einen noch nie gef�hlten, leichten, dumpfen Schmerz zu f�hlen begann. + +�Ach Gott�, dachte er, �was f�r einen anstrengenden Beruf habe ich gew�hlt! Tag aus, Tag ein auf der Reise. Die gesch�ftlichen Aufregungen sind viel gr��er, als im eigentlichen Gesch�ft zu Hause, und au�erdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschl�sse, das unregelm��ige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!� Er f�hlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem R�cken langsam n�her zum Bettpfosten, um den Kopf besser heben zu k�nnen; fand die juckende Stelle, die mit lauter kleinen wei�en P�nktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zur�ck, denn bei der Ber�hrung umwehten ihn K�lteschauer. + +Er glitt wieder in seine fr�here Lage zur�ck. �Dies fr�hzeitige Aufstehen�, dachte er, �macht einen ganz bl�dsinnig. Der Mensch mu� seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zur�ckgehe, um die erlangten Auftr�ge zu �berschreiben, sitzen diese Herren erst beim Fr�hst�ck. Das sollte ich bei meinem Chef versuchen; ich w�rde auf der Stelle hinausfliegen. Wer wei� �brigens, ob das nicht sehr gut f�r mich w�re. Wenn ich mich nicht wegen meiner Eltern zur�ckhielte, ich h�tte l�ngst gek�ndigt, ich w�re vor den Chef hin getreten und h�tte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult h�tte er fallen m�ssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der H�he herab mit dem Angestellten zu reden, der �berdies wegen der Schwerh�rigkeit des Chefs ganz nahe herantreten mu�. Nun, die Hoffnung ist noch nicht g�nzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es d�rfte noch f�nf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der gro�e Schnitt gemacht. Vorl�ufig allerdings mu� ich aufstehen, denn mein Zug f�hrt um f�nf.� + +Und er sah zur Weckuhr hin�ber, die auf dem Kasten tickte. �Himmlischer Vater!�, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorw�rts, es war sogar halb vor�ber, es n�herte sich schon dreiviertel. Sollte der Wecker nicht gel�utet haben? Man sah vom Bett aus, da� er auf vier Uhr richtig eingestellt war; gewi� hatte er auch gel�utet. Ja, aber war es m�glich, dieses m�belersch�tternde L�uten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der n�chste Zug ging um sieben Uhr; um den einzuholen, h�tte er sich unsinnig beeilen m�ssen, und die Kollektion war noch nicht eingepackt, und er selbst f�hlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Gesch�ftsdiener hatte beim F�nfuhrzug gewartet und die Meldung von seiner Vers�umnis l�ngst erstattet. Es war eine Kreatur des Chefs, ohne R�ckgrat und Verstand. Wie nun, wenn er sich krank meldete? Das w�re aber �u�erst peinlich und verd�chtig, denn Gregor war w�hrend seines f�nfj�hrigen Dienstes noch nicht einmal krank gewesen. Gewi� w�rde der Chef mit dem Krankenkassenarzt kommen, w�rde den Eltern wegen des faulen Sohnes Vorw�rfe machen und alle Einw�nde durch den Hinweis auf den Krankenkassenarzt abschneiden, f�r den es ja �berhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und h�tte er �brigens in diesem Falle so ganz unrecht? Gregor f�hlte sich tats�chlich, abgesehen von einer nach dem langen Schlaf wirklich �berfl�ssigen Schl�frigkeit, ganz wohl und hatte sogar einen besonders kr�ftigen Hunger.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +Als Gregor Samsa eines Morgens aus unruhigen Tr�umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten R�cken und sah, wenn er den Kopf ein wenig hob, seinen gew�lbten, braunen, von bogenf�rmigen Versteifungen geteilten Bauch, auf dessen H�he sich die Bettdecke, zum g�nzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kl�glich d�nnen Beine flimmerten ihm hilflos vor den Augen.
�Was ist mit mir geschehen?�, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten W�nden. �ber dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem h�bschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasa� und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob.
Gregors Blick richtete sich dann zum Fenster, und das tr�be Wetter - man h�rte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. �Wie w�re es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten verg��e�, dachte er, aber das war g�nzlich undurchf�hrbar, denn er war gew�hnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenw�rtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die R�ckenlage zur�ck. Er versuchte es wohl hundertmal, schlo� die Augen, um die zappelnden Beine nicht sehen zu m�ssen, und lie� erst ab, als er in der Seite einen noch nie gef�hlten, leichten, dumpfen Schmerz zu f�hlen begann.
�Ach Gott�, dachte er, �was f�r einen anstrengenden Beruf habe ich gew�hlt! Tag aus, Tag ein auf der Reise. Die gesch�ftlichen Aufregungen sind viel gr��er, als im eigentlichen Gesch�ft zu Hause, und au�erdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschl�sse, das unregelm��ige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!� Er f�hlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem R�cken langsam n�her zum Bettpfosten, um den Kopf besser heben zu k�nnen; fand die juckende Stelle, die mit lauter kleinen wei�en P�nktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zur�ck, denn bei der Ber�hrung umwehten ihn K�lteschauer.
Er glitt wieder in seine fr�here Lage zur�ck. �Dies fr�hzeitige Aufstehen�, dachte er, �macht einen ganz bl�dsinnig. Der Mensch mu� seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zur�ckgehe, um die erlangten Auftr�ge zu �berschreiben, sitzen diese Herren erst beim Fr�hst�ck. Das sollte ich bei meinem Chef versuchen; ich w�rde auf der Stelle hinausfliegen. Wer wei� �brigens, ob das nicht sehr gut f�r mich w�re. Wenn ich mich nicht wegen meiner Eltern zur�ckhielte, ich h�tte l�ngst gek�ndigt, ich w�re vor den Chef hin getreten und h�tte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult h�tte er fallen m�ssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der H�he herab mit dem Angestellten zu reden, der �berdies wegen der Schwerh�rigkeit des Chefs ganz nahe herantreten mu�. Nun, die Hoffnung ist noch nicht g�nzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es d�rfte noch f�nf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der gro�e Schnitt gemacht. Vorl�ufig allerdings mu� ich aufstehen, denn mein Zug f�hrt um f�nf.�
Und er sah zur Weckuhr hin�ber, die auf dem Kasten tickte. �Himmlischer Vater!�, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorw�rts, es war sogar halb vor�ber, es n�herte sich schon dreiviertel. Sollte der Wecker nicht gel�utet haben? Man sah vom Bett aus, da� er auf vier Uhr richtig eingestellt war; gewi� hatte er auch gel�utet. Ja, aber war es m�glich, dieses m�belersch�tternde L�uten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der n�chste Zug ging um sieben Uhr; um den einzuholen, h�tte er sich unsinnig beeilen m�ssen, und die Kollektion war noch nicht eingepackt, und er selbst f�hlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Gesch�ftsdiener hatte beim F�nfuhrzug gewartet und die Meldung von seiner Vers�umnis l�ngst erstattet. Es war eine Kreatur des Chefs, ohne R�ckgrat und Verstand. Wie nun, wenn er sich krank meldete? Das w�re aber �u�erst peinlich und verd�chtig, denn Gregor war w�hrend seines f�nfj�hrigen Dienstes noch nicht einmal krank gewesen. Gewi� w�rde der Chef mit dem Krankenkassenarzt kommen, w�rde den Eltern wegen des faulen Sohnes Vorw�rfe machen und alle Einw�nde durch den Hinweis auf den Krankenkassenarzt abschneiden, f�r den es ja �berhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und h�tte er �brigens in diesem Falle so ganz unrecht? Gregor f�hlte sich tats�chlich, abgesehen von einer nach dem langen Schlaf wirklich �berfl�ssigen Schl�frigkeit, ganz wohl und hatte sogar einen besonders kr�ftigen Hunger. \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,11 @@ +Als Gregor Samsa eines Morgens aus unruhigen Tr�umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten R�cken und sah, wenn er den Kopf ein wenig hob, seinen gew�lbten, braunen, von bogenf�rmigen Versteifungen geteilten Bauch, auf dessen H�he sich die Bettdecke, zum g�nzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kl�glich d�nnen Beine flimmerten ihm hilflos vor den Augen. + +�Was ist mit mir geschehen?�, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten W�nden. �ber dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem h�bschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasa� und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob. + +Gregors Blick richtete sich dann zum Fenster, und das tr�be Wetter - man h�rte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. �Wie w�re es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten verg��e�, dachte er, aber das war g�nzlich undurchf�hrbar, denn er war gew�hnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenw�rtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die R�ckenlage zur�ck. Er versuchte es wohl hundertmal, schlo� die Augen, um die zappelnden Beine nicht sehen zu m�ssen, und lie� erst ab, als er in der Seite einen noch nie gef�hlten, leichten, dumpfen Schmerz zu f�hlen begann. + +�Ach Gott�, dachte er, �was f�r einen anstrengenden Beruf habe ich gew�hlt! Tag aus, Tag ein auf der Reise. Die gesch�ftlichen Aufregungen sind viel gr��er, als im eigentlichen Gesch�ft zu Hause, und au�erdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschl�sse, das unregelm��ige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!� Er f�hlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem R�cken langsam n�her zum Bettpfosten, um den Kopf besser heben zu k�nnen; fand die juckende Stelle, die mit lauter kleinen wei�en P�nktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zur�ck, denn bei der Ber�hrung umwehten ihn K�lteschauer. + +Er glitt wieder in seine fr�here Lage zur�ck. �Dies fr�hzeitige Aufstehen�, dachte er, �macht einen ganz bl�dsinnig. Der Mensch mu� seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zur�ckgehe, um die erlangten Auftr�ge zu �berschreiben, sitzen diese Herren erst beim Fr�hst�ck. Das sollte ich bei meinem Chef versuchen; ich w�rde auf der Stelle hinausfliegen. Wer wei� �brigens, ob das nicht sehr gut f�r mich w�re. Wenn ich mich nicht wegen meiner Eltern zur�ckhielte, ich h�tte l�ngst gek�ndigt, ich w�re vor den Chef hin getreten und h�tte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult h�tte er fallen m�ssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der H�he herab mit dem Angestellten zu reden, der �berdies wegen der Schwerh�rigkeit des Chefs ganz nahe herantreten mu�. Nun, die Hoffnung ist noch nicht g�nzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es d�rfte noch f�nf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der gro�e Schnitt gemacht. Vorl�ufig allerdings mu� ich aufstehen, denn mein Zug f�hrt um f�nf.� + +Und er sah zur Weckuhr hin�ber, die auf dem Kasten tickte. �Himmlischer Vater!�, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorw�rts, es war sogar halb vor�ber, es n�herte sich schon dreiviertel. Sollte der Wecker nicht gel�utet haben? Man sah vom Bett aus, da� er auf vier Uhr richtig eingestellt war; gewi� hatte er auch gel�utet. Ja, aber war es m�glich, dieses m�belersch�tternde L�uten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der n�chste Zug ging um sieben Uhr; um den einzuholen, h�tte er sich unsinnig beeilen m�ssen, und die Kollektion war noch nicht eingepackt, und er selbst f�hlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Gesch�ftsdiener hatte beim F�nfuhrzug gewartet und die Meldung von seiner Vers�umnis l�ngst erstattet. Es war eine Kreatur des Chefs, ohne R�ckgrat und Verstand. Wie nun, wenn er sich krank meldete? Das w�re aber �u�erst peinlich und verd�chtig, denn Gregor war w�hrend seines f�nfj�hrigen Dienstes noch nicht einmal krank gewesen. Gewi� w�rde der Chef mit dem Krankenkassenarzt kommen, w�rde den Eltern wegen des faulen Sohnes Vorw�rfe machen und alle Einw�nde durch den Hinweis auf den Krankenkassenarzt abschneiden, f�r den es ja �berhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und h�tte er �brigens in diesem Falle so ganz unrecht? Gregor f�hlte sich tats�chlich, abgesehen von einer nach dem langen Schlaf wirklich �berfl�ssigen Schl�frigkeit, ganz wohl und hatte sogar einen besonders kr�ftigen Hunger.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_latin1_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,11 @@ +Als Gregor Samsa eines Morgens aus unruhigen Tr�umen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten R�cken und sah, wenn er den Kopf ein wenig hob, seinen gew�lbten, braunen, von bogenf�rmigen Versteifungen geteilten Bauch, auf dessen H�he sich die Bettdecke, zum g�nzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kl�glich d�nnen Beine flimmerten ihm hilflos vor den Augen. + +�Was ist mit mir geschehen?�, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten W�nden. �ber dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem h�bschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasa� und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob. + +Gregors Blick richtete sich dann zum Fenster, und das tr�be Wetter - man h�rte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. �Wie w�re es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten verg��e�, dachte er, aber das war g�nzlich undurchf�hrbar, denn er war gew�hnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenw�rtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die R�ckenlage zur�ck. Er versuchte es wohl hundertmal, schlo� die Augen, um die zappelnden Beine nicht sehen zu m�ssen, und lie� erst ab, als er in der Seite einen noch nie gef�hlten, leichten, dumpfen Schmerz zu f�hlen begann. + +�Ach Gott�, dachte er, �was f�r einen anstrengenden Beruf habe ich gew�hlt! Tag aus, Tag ein auf der Reise. Die gesch�ftlichen Aufregungen sind viel gr��er, als im eigentlichen Gesch�ft zu Hause, und au�erdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschl�sse, das unregelm��ige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!� Er f�hlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem R�cken langsam n�her zum Bettpfosten, um den Kopf besser heben zu k�nnen; fand die juckende Stelle, die mit lauter kleinen wei�en P�nktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zur�ck, denn bei der Ber�hrung umwehten ihn K�lteschauer. + +Er glitt wieder in seine fr�here Lage zur�ck. �Dies fr�hzeitige Aufstehen�, dachte er, �macht einen ganz bl�dsinnig. Der Mensch mu� seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zur�ckgehe, um die erlangten Auftr�ge zu �berschreiben, sitzen diese Herren erst beim Fr�hst�ck. Das sollte ich bei meinem Chef versuchen; ich w�rde auf der Stelle hinausfliegen. Wer wei� �brigens, ob das nicht sehr gut f�r mich w�re. Wenn ich mich nicht wegen meiner Eltern zur�ckhielte, ich h�tte l�ngst gek�ndigt, ich w�re vor den Chef hin getreten und h�tte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult h�tte er fallen m�ssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der H�he herab mit dem Angestellten zu reden, der �berdies wegen der Schwerh�rigkeit des Chefs ganz nahe herantreten mu�. Nun, die Hoffnung ist noch nicht g�nzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es d�rfte noch f�nf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der gro�e Schnitt gemacht. Vorl�ufig allerdings mu� ich aufstehen, denn mein Zug f�hrt um f�nf.� + +Und er sah zur Weckuhr hin�ber, die auf dem Kasten tickte. �Himmlischer Vater!�, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorw�rts, es war sogar halb vor�ber, es n�herte sich schon dreiviertel. Sollte der Wecker nicht gel�utet haben? Man sah vom Bett aus, da� er auf vier Uhr richtig eingestellt war; gewi� hatte er auch gel�utet. Ja, aber war es m�glich, dieses m�belersch�tternde L�uten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der n�chste Zug ging um sieben Uhr; um den einzuholen, h�tte er sich unsinnig beeilen m�ssen, und die Kollektion war noch nicht eingepackt, und er selbst f�hlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Gesch�ftsdiener hatte beim F�nfuhrzug gewartet und die Meldung von seiner Vers�umnis l�ngst erstattet. Es war eine Kreatur des Chefs, ohne R�ckgrat und Verstand. Wie nun, wenn er sich krank meldete? Das w�re aber �u�erst peinlich und verd�chtig, denn Gregor war w�hrend seines f�nfj�hrigen Dienstes noch nicht einmal krank gewesen. Gewi� w�rde der Chef mit dem Krankenkassenarzt kommen, w�rde den Eltern wegen des faulen Sohnes Vorw�rfe machen und alle Einw�nde durch den Hinweis auf den Krankenkassenarzt abschneiden, f�r den es ja �berhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und h�tte er �brigens in diesem Falle so ganz unrecht? Gregor f�hlte sich tats�chlich, abgesehen von einer nach dem langen Schlaf wirklich �berfl�ssigen Schl�frigkeit, ganz wohl und hatte sogar einen besonders kr�ftigen Hunger.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den Kopf ein wenig hob, seinen gewölbten, braunen, von bogenförmigen Versteifungen geteilten Bauch, auf dessen Höhe sich die Bettdecke, zum gänzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kläglich dünnen Beine flimmerten ihm hilflos vor den Augen.
»Was ist mit mir geschehen?«, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten Wänden. Über dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem hübschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasaß und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob.
Gregors Blick richtete sich dann zum Fenster, und das trübe Wetter - man hörte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. »Wie wäre es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten vergäße«, dachte er, aber das war gänzlich undurchführbar, denn er war gewöhnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenwärtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die Rückenlage zurück. Er versuchte es wohl hundertmal, schloß die Augen, um die zappelnden Beine nicht sehen zu müssen, und ließ erst ab, als er in der Seite einen noch nie gefühlten, leichten, dumpfen Schmerz zu fühlen begann.
»Ach Gott«, dachte er, »was für einen anstrengenden Beruf habe ich gewählt! Tag aus, Tag ein auf der Reise. Die geschäftlichen Aufregungen sind viel größer, als im eigentlichen Geschäft zu Hause, und außerdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschlüsse, das unregelmäßige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!« Er fühlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem Rücken langsam näher zum Bettpfosten, um den Kopf besser heben zu können; fand die juckende Stelle, die mit lauter kleinen weißen Pünktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zurück, denn bei der Berührung umwehten ihn Kälteschauer.
Er glitt wieder in seine frühere Lage zurück. »Dies frühzeitige Aufstehen«, dachte er, »macht einen ganz blödsinnig. Der Mensch muß seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zurückgehe, um die erlangten Aufträge zu überschreiben, sitzen diese Herren erst beim Frühstück. Das sollte ich bei meinem Chef versuchen; ich würde auf der Stelle hinausfliegen. Wer weiß übrigens, ob das nicht sehr gut für mich wäre. Wenn ich mich nicht wegen meiner Eltern zurückhielte, ich hätte längst gekündigt, ich wäre vor den Chef hin getreten und hätte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult hätte er fallen müssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der Höhe herab mit dem Angestellten zu reden, der überdies wegen der Schwerhörigkeit des Chefs ganz nahe herantreten muß. Nun, die Hoffnung ist noch nicht gänzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es dürfte noch fünf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der große Schnitt gemacht. Vorläufig allerdings muß ich aufstehen, denn mein Zug fährt um fünf.«
Und er sah zur Weckuhr hinüber, die auf dem Kasten tickte. »Himmlischer Vater!«, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorwärts, es war sogar halb vorüber, es näherte sich schon dreiviertel. Sollte der Wecker nicht geläutet haben? Man sah vom Bett aus, daß er auf vier Uhr richtig eingestellt war; gewiß hatte er auch geläutet. Ja, aber war es möglich, dieses möbelerschütternde Läuten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der nächste Zug ging um sieben Uhr; um den einzuholen, hätte er sich unsinnig beeilen müssen, und die Kollektion war noch nicht eingepackt, und er selbst fühlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Geschäftsdiener hatte beim Fünfuhrzug gewartet und die Meldung von seiner Versäumnis längst erstattet. Es war eine Kreatur des Chefs, ohne Rückgrat und Verstand. Wie nun, wenn er sich krank meldete? Das wäre aber äußerst peinlich und verdächtig, denn Gregor war während seines fünfjährigen Dienstes noch nicht einmal krank gewesen. Gewiß würde der Chef mit dem Krankenkassenarzt kommen, würde den Eltern wegen des faulen Sohnes Vorwürfe machen und alle Einwände durch den Hinweis auf den Krankenkassenarzt abschneiden, für den es ja überhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und hätte er übrigens in diesem Falle so ganz unrecht? Gregor fühlte sich tatsächlich, abgesehen von einer nach dem langen Schlaf wirklich überflüssigen Schläfrigkeit, ganz wohl und hatte sogar einen besonders kräftigen Hunger. \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,11 @@ +Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den Kopf ein wenig hob, seinen gewölbten, braunen, von bogenförmigen Versteifungen geteilten Bauch, auf dessen Höhe sich die Bettdecke, zum gänzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kläglich dünnen Beine flimmerten ihm hilflos vor den Augen. + +»Was ist mit mir geschehen?«, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten Wänden. Über dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem hübschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasaß und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob. + +Gregors Blick richtete sich dann zum Fenster, und das trübe Wetter - man hörte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. »Wie wäre es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten vergäße«, dachte er, aber das war gänzlich undurchführbar, denn er war gewöhnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenwärtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die Rückenlage zurück. Er versuchte es wohl hundertmal, schloß die Augen, um die zappelnden Beine nicht sehen zu müssen, und ließ erst ab, als er in der Seite einen noch nie gefühlten, leichten, dumpfen Schmerz zu fühlen begann. + +»Ach Gott«, dachte er, »was für einen anstrengenden Beruf habe ich gewählt! Tag aus, Tag ein auf der Reise. Die geschäftlichen Aufregungen sind viel größer, als im eigentlichen Geschäft zu Hause, und außerdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschlüsse, das unregelmäßige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!« Er fühlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem Rücken langsam näher zum Bettpfosten, um den Kopf besser heben zu können; fand die juckende Stelle, die mit lauter kleinen weißen Pünktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zurück, denn bei der Berührung umwehten ihn Kälteschauer. + +Er glitt wieder in seine frühere Lage zurück. »Dies frühzeitige Aufstehen«, dachte er, »macht einen ganz blödsinnig. Der Mensch muß seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zurückgehe, um die erlangten Aufträge zu überschreiben, sitzen diese Herren erst beim Frühstück. Das sollte ich bei meinem Chef versuchen; ich würde auf der Stelle hinausfliegen. Wer weiß übrigens, ob das nicht sehr gut für mich wäre. Wenn ich mich nicht wegen meiner Eltern zurückhielte, ich hätte längst gekündigt, ich wäre vor den Chef hin getreten und hätte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult hätte er fallen müssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der Höhe herab mit dem Angestellten zu reden, der überdies wegen der Schwerhörigkeit des Chefs ganz nahe herantreten muß. Nun, die Hoffnung ist noch nicht gänzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es dürfte noch fünf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der große Schnitt gemacht. Vorläufig allerdings muß ich aufstehen, denn mein Zug fährt um fünf.« + +Und er sah zur Weckuhr hinüber, die auf dem Kasten tickte. »Himmlischer Vater!«, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorwärts, es war sogar halb vorüber, es näherte sich schon dreiviertel. Sollte der Wecker nicht geläutet haben? Man sah vom Bett aus, daß er auf vier Uhr richtig eingestellt war; gewiß hatte er auch geläutet. Ja, aber war es möglich, dieses möbelerschütternde Läuten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der nächste Zug ging um sieben Uhr; um den einzuholen, hätte er sich unsinnig beeilen müssen, und die Kollektion war noch nicht eingepackt, und er selbst fühlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Geschäftsdiener hatte beim Fünfuhrzug gewartet und die Meldung von seiner Versäumnis längst erstattet. Es war eine Kreatur des Chefs, ohne Rückgrat und Verstand. Wie nun, wenn er sich krank meldete? Das wäre aber äußerst peinlich und verdächtig, denn Gregor war während seines fünfjährigen Dienstes noch nicht einmal krank gewesen. Gewiß würde der Chef mit dem Krankenkassenarzt kommen, würde den Eltern wegen des faulen Sohnes Vorwürfe machen und alle Einwände durch den Hinweis auf den Krankenkassenarzt abschneiden, für den es ja überhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und hätte er übrigens in diesem Falle so ganz unrecht? Gregor fühlte sich tatsächlich, abgesehen von einer nach dem langen Schlaf wirklich überflüssigen Schläfrigkeit, ganz wohl und hatte sogar einen besonders kräftigen Hunger.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/kafka_utf8_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,11 @@ +Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den Kopf ein wenig hob, seinen gewölbten, braunen, von bogenförmigen Versteifungen geteilten Bauch, auf dessen Höhe sich die Bettdecke, zum gänzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kläglich dünnen Beine flimmerten ihm hilflos vor den Augen. + +»Was ist mit mir geschehen?«, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten Wänden. Über dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer illustrierten Zeitschrift ausgeschnitten und in einem hübschen, vergoldeten Rahmen untergebracht hatte. Es stellte eine Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasaß und einen schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer entgegenhob. + +Gregors Blick richtete sich dann zum Fenster, und das trübe Wetter - man hörte Regentropfen auf das Fensterblech aufschlagen - machte ihn ganz melancholisch. »Wie wäre es, wenn ich noch ein wenig weiterschliefe und alle Narrheiten vergäße«, dachte er, aber das war gänzlich undurchführbar, denn er war gewöhnt, auf der rechten Seite zu schlafen, konnte sich aber in seinem gegenwärtigen Zustand nicht in diese Lage bringen. Mit welcher Kraft er sich auch auf die rechte Seite warf, immer wieder schaukelte er in die Rückenlage zurück. Er versuchte es wohl hundertmal, schloß die Augen, um die zappelnden Beine nicht sehen zu müssen, und ließ erst ab, als er in der Seite einen noch nie gefühlten, leichten, dumpfen Schmerz zu fühlen begann. + +»Ach Gott«, dachte er, »was für einen anstrengenden Beruf habe ich gewählt! Tag aus, Tag ein auf der Reise. Die geschäftlichen Aufregungen sind viel größer, als im eigentlichen Geschäft zu Hause, und außerdem ist mir noch diese Plage des Reisens auferlegt, die Sorgen um die Zuganschlüsse, das unregelmäßige, schlechte Essen, ein immer wechselnder, nie andauernder, nie herzlich werdender menschlicher Verkehr. Der Teufel soll das alles holen!« Er fühlte ein leichtes Jucken oben auf dem Bauch; schob sich auf dem Rücken langsam näher zum Bettpfosten, um den Kopf besser heben zu können; fand die juckende Stelle, die mit lauter kleinen weißen Pünktchen besetzt war, die er nicht zu beurteilen verstand; und wollte mit einem Bein die Stelle betasten, zog es aber gleich zurück, denn bei der Berührung umwehten ihn Kälteschauer. + +Er glitt wieder in seine frühere Lage zurück. »Dies frühzeitige Aufstehen«, dachte er, »macht einen ganz blödsinnig. Der Mensch muß seinen Schlaf haben. Andere Reisende leben wie Haremsfrauen. Wenn ich zum Beispiel im Laufe des Vormittags ins Gasthaus zurückgehe, um die erlangten Aufträge zu überschreiben, sitzen diese Herren erst beim Frühstück. Das sollte ich bei meinem Chef versuchen; ich würde auf der Stelle hinausfliegen. Wer weiß übrigens, ob das nicht sehr gut für mich wäre. Wenn ich mich nicht wegen meiner Eltern zurückhielte, ich hätte längst gekündigt, ich wäre vor den Chef hin getreten und hätte ihm meine Meinung von Grund des Herzens aus gesagt. Vom Pult hätte er fallen müssen! Es ist auch eine sonderbare Art, sich auf das Pult zu setzen und von der Höhe herab mit dem Angestellten zu reden, der überdies wegen der Schwerhörigkeit des Chefs ganz nahe herantreten muß. Nun, die Hoffnung ist noch nicht gänzlich aufgegeben; habe ich einmal das Geld beisammen, um die Schuld der Eltern an ihn abzuzahlen - es dürfte noch fünf bis sechs Jahre dauern - , mache ich die Sache unbedingt. Dann wird der große Schnitt gemacht. Vorläufig allerdings muß ich aufstehen, denn mein Zug fährt um fünf.« + +Und er sah zur Weckuhr hinüber, die auf dem Kasten tickte. »Himmlischer Vater!«, dachte er. Es war halb sieben Uhr, und die Zeiger gingen ruhig vorwärts, es war sogar halb vorüber, es näherte sich schon dreiviertel. Sollte der Wecker nicht geläutet haben? Man sah vom Bett aus, daß er auf vier Uhr richtig eingestellt war; gewiß hatte er auch geläutet. Ja, aber war es möglich, dieses möbelerschütternde Läuten ruhig zu verschlafen? Nun, ruhig hatte er ja nicht geschlafen, aber wahrscheinlich desto fester. Was aber sollte er jetzt tun? Der nächste Zug ging um sieben Uhr; um den einzuholen, hätte er sich unsinnig beeilen müssen, und die Kollektion war noch nicht eingepackt, und er selbst fühlte sich durchaus nicht besonders frisch und beweglich. Und selbst wenn er den Zug einholte, ein Donnerwetter des Chefs war nicht zu vermeiden, denn der Geschäftsdiener hatte beim Fünfuhrzug gewartet und die Meldung von seiner Versäumnis längst erstattet. Es war eine Kreatur des Chefs, ohne Rückgrat und Verstand. Wie nun, wenn er sich krank meldete? Das wäre aber äußerst peinlich und verdächtig, denn Gregor war während seines fünfjährigen Dienstes noch nicht einmal krank gewesen. Gewiß würde der Chef mit dem Krankenkassenarzt kommen, würde den Eltern wegen des faulen Sohnes Vorwürfe machen und alle Einwände durch den Hinweis auf den Krankenkassenarzt abschneiden, für den es ja überhaupt nur ganz gesunde, aber arbeitsscheue Menschen gibt. Und hätte er übrigens in diesem Falle so ganz unrecht? Gregor fühlte sich tatsächlich, abgesehen von einer nach dem langen Schlaf wirklich überflüssigen Schläfrigkeit, ganz wohl und hatte sogar einen besonders kräftigen Hunger.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/packages.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/packages.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/packages.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,33 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/test/packages.lisp,v 1.4 2007/01/01 23:47:16 edi Exp $ + +;;; Copyright (c) 2006-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :cl-user) + +(defpackage :flexi-streams-test + (:use :cl :flexi-streams))
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +����������������� ������ �� ������� ������������� ����������� �� Unicode, ������� ��������� 10-12 ����� 1997 ���� � ������ � ��������. ����������� ������� ������� ���� ��������� �� �������� ����������� ��������� � Unicode, ����������� � �������������������, ���������� � ���������� Unicode � ��������� ������������ �������� � ����������� �����������, �������, ������� � ������������ ������������ ��������. \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,6 @@ +����������������� ������ �� ������� ������������� ����������� �� +Unicode, ������� ��������� 10-12 ����� 1997 ���� � ������ � ��������. +����������� ������� ������� ���� ��������� �� �������� ����������� +��������� � Unicode, ����������� � �������������������, ���������� � +���������� Unicode � ��������� ������������ �������� � ����������� +�����������, �������, ������� � ������������ ������������ ��������.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_koi8r_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,6 @@ +����������������� ������ �� ������� ������������� ����������� �� +Unicode, ������� ��������� 10-12 ����� 1997 ���� � ������ � ��������. +����������� ������� ������� ���� ��������� �� �������� ����������� +��������� � Unicode, ����������� � �������������������, ���������� � +���������� Unicode � ��������� ������������ �������� � ����������� +�����������, �������, ������� � ������������ ������������ ��������.
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_cr.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_cr.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_crlf.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_crlf.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_lf.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/russian_utf8_lf.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/test.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/test.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/test.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,313 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS-TEST; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/test/test.lisp,v 1.12 2007/03/09 01:14:30 edi Exp $ + +;;; Copyright (c) 2006-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams-test) + +(defvar *this-file* (load-time-value + (or #.*compile-file-pathname* *load-pathname*)) + "The pathname of the file (`test.lisp') where this variable was +defined.") + +(defvar *tmp-dir* + (load-time-value + (merge-pathnames "flexi-streams-test/" + #+:allegro (system:temporary-directory) + #+:lispworks (pathname (or (lw:environment-variable "TEMP") + (lw:environment-variable "TMP") + #+:win32 "C:/" + #-:win32 "/tmp/")) + #-(or :allegro :lispworks) #p"/tmp/")) + "The pathname of a temporary directory used for testing.") + +(defvar *test-files* + '(("kafka" (:utf8 :latin1 :cp1252)) + ("tilton" (:utf8 :ascii)) + ("hebrew" (:utf8 :latin8)) + ("russian" (:utf8 :koi8r)) + ("unicode_demo" (:utf8 :ucs2 :ucs4))) + "A list of test files where each entry consists of the name +prefix and a list of encodings.") + +(defvar *test-success-counter* 0 + "Counts the number of successful tests.") + +(defun create-file-variants (file-name symbol) + "For a name suffix FILE-NAME and a symbol SYMBOL denoting an +encoding returns a list of pairs where the car is a full file +name and the cdr is the corresponding external format. This list +contains all possible variants w.r.t. to line-end conversion and +endianness." + (let ((args (ecase symbol + (:ascii '(:ascii)) + (:latin1 '(:latin-1)) + (:latin8 '(:hebrew)) + (:cp1252 '(:code-page :id 1252)) + (:koi8r '(:koi8-r)) + (:utf8 '(:utf-8)) + (:ucs2 '(:utf-16)) + (:ucs4 '(:utf-32)))) + (endianp (member symbol '(:ucs2 :ucs4)))) + (loop for little-endian in (if endianp '(t nil) '(t)) + for endian-suffix in (if endianp '("_le" "_be") '("")) + nconc (loop for eol-style in '(:lf :cr :crlf) + collect (cons (format nil "~A_~(~A~)_~(~A~)~A.txt" + file-name symbol eol-style endian-suffix) + (apply #'make-external-format + (append args `(:eol-style ,eol-style + :little-endian ,little-endian)))))))) + +(defun create-test-combinations (file-name symbols) + "For a name suffix FILE-NAME and a list of symbols SYMBOLS +denoting different encodings of the corresponding file returns a +list of lists which can be used as arglists for COMPARE-FILES." + (let ((file-variants (loop for symbol in symbols + nconc (create-file-variants file-name symbol)))) + (loop for (name-in . external-format-in) in file-variants + nconc (loop for (name-out . external-format-out) in file-variants + collect (list name-in external-format-in name-out external-format-out))))) + +(defun file-equal (file1 file2) + "Returns a true value iff FILE1 and FILE2 have the same +contents (viewed as binary files)." + (with-open-file (stream1 file1 :element-type 'octet) + (with-open-file (stream2 file2 :element-type 'octet) + (and (= (file-length stream1) (file-length stream2)) + (loop for byte1 = (read-byte stream1 nil nil) + for byte2 = (read-byte stream2 nil nil) + while (and byte1 byte2) + always (= byte1 byte2)))))) + +(defun copy-stream (stream-in external-format-in stream-out external-format-out) + "Copies the contents of the binary stream STREAM-IN to the +binary stream STREAM-OUT using flexi streams - STREAM-IN is read +with the external format EXTERNAL-FORMAT-IN and STREAM-OUT is +written with EXTERNAL-FORMAT-OUT." + (let ((in (make-flexi-stream stream-in :external-format external-format-in)) + (out (make-flexi-stream stream-out :external-format external-format-out))) + (loop for line = (read-line in nil nil) + while line + do (write-line line out)))) + +(defun copy-file (path-in external-format-in path-out external-format-out direction-out direction-in) + "Copies the contents of the file denoted by the pathname +PATH-IN to the file denoted by the pathname PATH-OUT using flexi +streams - STREAM-IN is read with the external format +EXTERNAL-FORMAT-IN and STREAM-OUT is written with +EXTERNAL-FORMAT-OUT. The input file is opened with +the :DIRECTION keyword argument DIRECTION-IN, the output file is +opened with the :DIRECTION keyword argument DIRECTION-OUT." + (with-open-file (in path-in + :element-type 'octet + :direction direction-in + :if-does-not-exist :error + :if-exists :overwrite) + (with-open-file (out path-out + :element-type 'octet + :direction direction-out + :if-does-not-exist :create + :if-exists :supersede) + (copy-stream in external-format-in out external-format-out)))) + +#+:lispworks +(defun copy-file-lw (path-in external-format-in path-out external-format-out direction-out direction-in) + "Same as COPY-FILE, but uses character streams instead of +binary streams. Only used to test LispWorks-specific behaviour." + (with-open-file (in path-in + :external-format '(:latin-1 :eol-style :lf) + :direction direction-in + :if-does-not-exist :error + :if-exists :overwrite) + (with-open-file (out path-out + :external-format '(:latin-1 :eol-style :lf) + :direction direction-out + :direction :output + :if-does-not-exist :create + :if-exists :supersede) + (copy-stream in external-format-in out external-format-out)))) + +(defun compare-files (path-in external-format-in path-out external-format-out) + "Copies the contents of the file (in the `test') denoted by the +relative pathname PATH-IN to the file (in a temporary directory) +denoted by the relative pathname PATH-OUT using flexi streams - +STREAM-IN is read with the external format EXTERNAL-FORMAT-IN and +STREAM-OUT is written with EXTERNAL-FORMAT-OUT. The resulting +file is compared with an existing file in the `test' directory to +check if the outcome is as expected. Uses various variants of +the :DIRECTION keyword when opening the files." + (let ((full-path-in (merge-pathnames path-in *this-file*)) + (full-path-out (ensure-directories-exist + (merge-pathnames path-out *tmp-dir*))) + (full-path-orig (merge-pathnames path-out *this-file*))) + (dolist (direction-out '(:output :io)) + (dolist (direction-in '(:input :io)) + (format *error-output* "Test ~S ~S [~A]~% --> ~S [~A].~%" path-in + (flex::normalize-external-format external-format-in) direction-in + (flex::normalize-external-format external-format-out) direction-out) + (copy-file full-path-in external-format-in + full-path-out external-format-out + direction-out direction-in) + (cond ((file-equal full-path-out full-path-orig) + (incf *test-success-counter*)) + (t (format *error-output* " Test failed!!!~%"))) + (terpri *error-output*) + #+:lispworks + (format *error-output* "LW-Test ~S ~S [~A]~% --> ~S [~A].~%" path-in + (flex::normalize-external-format external-format-in) direction-in + (flex::normalize-external-format external-format-out) direction-out) + #+:lispworks + (copy-file full-path-in external-format-in + full-path-out external-format-out + direction-out direction-in) + #+:lispworks + (cond ((file-equal full-path-out full-path-orig) + (incf *test-success-counter*)) + (t (format *error-output* " Test failed!!!~%"))) + (terpri *error-output*))))) + +(defmacro with-test ((test-description) &body body) + "Defines a test. Two utilities are available inside of the body of +the maco: The function FAIL, and the macro CHECK. FAIL, the lowest +level utility, marks the test defined by WITH-TEST as faided. CHECK +checks whether its argument is true, otherwise it calls FAIL. If +during evaluation of the specified expression any condition is +signaled, this is also considered a failure. + +WITH-TEST prints reports while the tests run. It also increments +*TEST-SUCCESS-COUNT* if a test completes successfully." + (flex::with-unique-names (successp) + `(let ((,successp t)) + (flet ((fail (format-str &rest format-args) + (setf ,successp nil) + (apply #'format *error-output* format-str format-args))) + (macrolet ((check (expression) + `(handler-case + (unless ,expression + (fail "Expression ~S failed.~%" ',expression)) + (condition (c) + (fail "Expression ~S failed signaling condition of type ~A: ~A.~%" + ',expression (type-of c) c))))) + (format *error-output* "Test ~S~%" ,test-description) + ,@body + (if ,successp + (incf *test-success-counter*) + (format *error-output* " Test failed!!!~%")) + (terpri *error-output*) + (terpri *error-output*)) + ,successp)))) + +(defmacro using-values ((&rest values) &body body) + "Executes BODY and feeds an element from VALUES to the USE-VALUE +restart each time a FLEXI-STREAM-ENCODING-ERROR is signaled. Signals +an error when there are more or less FLEXI-STREAM-ENCODING-ERRORs than +there are elements in VALUES." + (flex::with-unique-names (value-stack condition-counter) + `(let ((,value-stack ',values) + (,condition-counter 0)) + (handler-bind ((flexi-stream-encoding-error + #'(lambda (c) + (declare (ignore c)) + (unless ,value-stack + (error "Too many FLEXI-STREAM-ENCODING-ERRORs signaled, expected only ~A." + ,(length values))) + (incf ,condition-counter) + (use-value (pop ,value-stack))))) + (prog1 (progn ,@body) + (when ,value-stack + (error "~A FLEXI-STREAM-ENCODING-ERRORs signaled, but ~A were expected." + ,condition-counter ,(length values)))))))) + +(defun read-flexi-line (sequence external-format) + "Creates and returns a string from the octet sequence SEQUENCE using +the external format EXTERNAL-FORMAT." + (with-input-from-sequence (in sequence) + (setq in (make-flexi-stream in :external-format external-format)) + (read-line in))) + +(defun encoding-error-handling-test() + (with-test ("Handling of encoding errors") + (let ((*substitution-char* #?)) + ;; :ASCII doesn't have characters with char codes > 127 + (check (string= "a??" (read-flexi-line `(,(char-code #\a) 128 200) :ascii))) + ;; :WINDOWS-1253 doesn't have a characters with codes 170 and 210 + (check (string= "a??" (read-flexi-line `(,(char-code #\a) 170 210) :windows-1253))) + ;; not a valid UTF-8 sequence + (check (string= "??" (read-flexi-line `(#xe4 #xf6 #xfc) :utf8))) + ;; UTF-8 can't start neither with #b11111110 nor with #b11111111 + (check (string= "??" (read-flexi-line `(#b11111110 #b11111111) :utf8)))) + (let ((*substitution-char* nil)) + ;; :ASCII doesn't have characters with char codes > 127 + (check (string= "abc" (using-values (#\b #\c) + (read-flexi-line `(,(char-code #\a) 128 200) :ascii)))) + ;; :WINDOWS-1253 encoding doesn't have a characters with codes 170 and 210 + (check (string= "axy" (using-values (#\x #\y) + (read-flexi-line `(,(char-code #\a) 170 210) :windows-1253)))) + ;; not a valid UTF-8 sequence + (check (string= "QW" (using-values (#\Q #\W) (read-flexi-line `(#xe4 #xf6 #xfc) :utf8)))) + ;; UTF-8 can't start neither with #b11111110 nor with #b11111111 + (check (string= "QW" (using-values (#\Q #\W) (read-flexi-line `(#b11111110 #b11111111) :utf8)))) + ;; only one byte + (check (string= "E" (using-values (#\E) (read-flexi-line `(#x01) :utf-16le)))) + ;; two bytes, but value of resulting word suggests that another word follows + (check (string= "R" (using-values (#\R) (read-flexi-line `(#x01 #xd8) :utf-16le)))) + ;; the second word must fit into the [#xdc00; #xdfff] interval, but it is #xdbff + (check (string= "T" (using-values (#\T) (read-flexi-line `(#x01 #xd8 #xff #xdb) :utf-16le)))) + ;; the same as for little endian above, but using inverse order of bytes in words + (check (string= "E" (using-values (#\E) (read-flexi-line `(#x01) :utf-16be)))) + (check (string= "R" (using-values (#\R) (read-flexi-line `(#xd8 #x01) :utf-16be)))) + (check (string= "T" (using-values (#\T) (read-flexi-line `(#xd8 #x01 #xdb #xff) :utf-16be)))) + ;; the only case when error is signaled for UTF-32 is at end of file + ;; in the middle of 4-byte sequence, both for big and little endian + (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01) :utf-32le)))) + (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01 #x01) :utf-32le)))) + (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01 #x01 #x01) :utf-32le)))) + (check (string= "aY" (using-values (#\Y) + (read-flexi-line `(,(char-code #\a) #x00 #x00 #x00 #x01) :utf-32le)))) + (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01) :utf-32be)))) + (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01 #x01) :utf-32be)))) + (check (string= "Y" (using-values (#\Y) (read-flexi-line `(#x01 #x01 #x01) :utf-32be)))) + (check (string= "aY" (using-values (#\Y) + (read-flexi-line `(#x00 #x00 #x00 ,(char-code #\a) #x01) :utf-32be))))))) + +(defun run-tests () + "Applies COMPARE-FILES to all test scenarios created with +CREATE-TEST-COMBINATIONS, runs test for handling of encoding errors, +and shows simple statistics at the end." + (let* ((*test-success-counter* 0) + (args-list (loop for (file-name symbols) in *test-files* + nconc (create-test-combinations file-name symbols))) + (no-tests (* 4 (length args-list)))) + #+:lispworks + (setq no-tests (* 2 no-tests)) + (dolist (args args-list) + (apply #'compare-files args)) + (incf no-tests) + (encoding-error-handling-test) + (format *error-output* "~%~%~:[~A of ~A tests failed..~;~*All ~A tests passed~].~%" + (= no-tests *test-success-counter*) (- no-tests *test-success-counter*) no-tests))) +
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +Programmers who lock onto a design decision and cling to it in the face of contradictory new information -- well, that's almost everyone in my experience, so I better not say what I think of them or people will start saying bad things about me on c.l.l. -- Ken Tilton % This reminds me of the NYC cabby who accepted a fare to Chicago. When they got there and could not find the friend who was supposed to pay the fare he just laughed and said he should have known. -- Ken Tilton %
Actually, I believe that Aikido, Jazz and Lisp are different appearances of the same thing.
Yes, the Tao. /Everything/ is a different appearance of the tao. -- Ken Tilton
"Ken, I went to the library and read up on Buddhism, and believe me, you are no Buddhist." -- Kenny's mom % That absolutely terrifies the herd-following, lockstep-marching, mainstream-saluting cowards that obediently dash out or online to scoop up books on The Latest Thing. They learn and use atrocities like Java, C++, XML, and even Python for the security it gives them and then sit there slaving away miserably, tediously, joylously paying off mortgages and supporting ungrateful teenagers who despise them, only to look out the double-sealed thermo-pane windows of their central-heated, sound-proofed, dead-bolted, suffocating little nests into the howling gale thinking "what do they know that I do not know?" when they see us under a lean-to hunched over our laptops to shield them from the rain laughing our asses off as we write great code between bong hits.... what was the question? -- Ken Tilton % Shut up! (That last phrase has four or more syllables if pronounced as intended.) -- Ken Tilton % Nonsense. You'll be using it for the GUI, not protein-folding. -- Ken Tilton (responding to a comment that LTK was slow because it was based on TK) % Continuations certainly are clever, but if we learned anything from the rejection of the cover art for "Smell the Glove", it is that "there is a fine line between stupid... and clever". -- Ken Tilton % Ah, there's no place like academia for dispassionate, intellectually honest discussion of new ideas on their merits. Thank god for tenure giving your bold antagonist the protection they needed to shout down your iconoclastic..... hang on... -- Ken Tilton % Whoever objected must be in my killfile, ... -- Ken Tilton % From memory (but I think I have it right):
"But Jesus said, Suffer captured variables, and forbid them not, to come unto thine macro bodies: for of such is are DSLs made." -- Ken Tilton
Can I get an Amen? % Awareness of defect is the first step to recovery. -- Ken Tilton % You made a bad analogy (there are no good ones, but you found a new low) ... -- Ken Tilton % Yes, it is true that Kent Pitman was raised by a closet full of Lisp Machines, but the exception only proves the rule. -- Ken Tilton (in a postscript after positing that computer languages are not learned in infancy) % I suggest you try bartender's school to support yourself, start programming for fun again. -- Ken Tilton (responding to a comment that 98% of anything to do with computers was not interesting code) % You could add four lanes to my carpal tunnel and I still could not write all the code I am dying to write. -- Ken Tilton % Neutrality? I want to bury other languages, not have a gateway to them. -- Ken Tilton % Ken: "Cute puppy. Did you get it for companionship or to pick up chicks?" Simon: "Hunh? My puppy /always/ gives me companionship." -- Ken Tilton (on how he was understood by a native english speaker) % \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,96 @@ +Programmers who lock onto a design decision and cling to it in the face of +contradictory new information -- well, that's almost everyone in my +experience, so I better not say what I think of them or people will start +saying bad things about me on c.l.l. + -- Ken Tilton +% +This reminds me of the NYC cabby who accepted a fare to Chicago. When +they got there and could not find the friend who was supposed to pay the +fare he just laughed and said he should have known. + -- Ken Tilton +% +>> Actually, I believe that Aikido, Jazz and Lisp are different appearances +>> of the same thing. +Yes, the Tao. /Everything/ is a different appearance of the tao. + -- Ken Tilton + +"Ken, I went to the library and read up on Buddhism, and believe me, you +are no Buddhist." + -- Kenny's mom +% +That absolutely terrifies the herd-following, lockstep-marching, +mainstream-saluting cowards that obediently dash out or online to +scoop up books on The Latest Thing. They learn and use atrocities like +Java, C++, XML, and even Python for the security it gives them and +then sit there slaving away miserably, tediously, joylously paying off +mortgages and supporting ungrateful teenagers who despise them, only +to look out the double-sealed thermo-pane windows of their +central-heated, sound-proofed, dead-bolted, suffocating little nests +into the howling gale thinking "what do they know that I do not know?" +when they see us under a lean-to hunched over our laptops to shield +them from the rain laughing our asses off as we write great code +between bong hits.... what was the question? + -- Ken Tilton +% +Shut up! (That last phrase has four or more syllables if pronounced as +intended.) + -- Ken Tilton +% +Nonsense. You'll be using it for the GUI, not protein-folding. + -- Ken Tilton + (responding to a comment that LTK was slow because it + was based on TK) +% +Continuations certainly are clever, but if we learned anything from the +rejection of the cover art for "Smell the Glove", it is that "there is a +fine line between stupid... and clever". + -- Ken Tilton +% +Ah, there's no place like academia for dispassionate, intellectually +honest discussion of new ideas on their merits. Thank god for tenure +giving your bold antagonist the protection they needed to shout down +your iconoclastic..... hang on... + -- Ken Tilton +% +Whoever objected must be in my killfile, ... + -- Ken Tilton +% +From memory (but I think I have it right): + +"But Jesus said, Suffer captured variables, and forbid them not, to come +unto thine macro bodies: for of such is are DSLs made." + -- Ken Tilton + +Can I get an Amen? +% +Awareness of defect is the first step to recovery. + -- Ken Tilton +% +You made a bad analogy (there are no good ones, but you found a new +low) ... + -- Ken Tilton +% +Yes, it is true that Kent Pitman was raised by a closet full of Lisp +Machines, but the exception only proves the rule. + -- Ken Tilton + (in a postscript after positing that computer + languages are not learned in infancy) +% +I suggest you try bartender's school to support yourself, start +programming for fun again. + -- Ken Tilton + (responding to a comment that 98% of anything to do + with computers was not interesting code) +% +You could add four lanes to my carpal tunnel and I still could not +write all the code I am dying to write. + -- Ken Tilton +% +Neutrality? I want to bury other languages, not have a gateway to them. + -- Ken Tilton +% +Ken: "Cute puppy. Did you get it for companionship or to pick up chicks?" +Simon: "Hunh? My puppy /always/ gives me companionship." + -- Ken Tilton + (on how he was understood by a native english speaker) +%
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_ascii_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,96 @@ +Programmers who lock onto a design decision and cling to it in the face of +contradictory new information -- well, that's almost everyone in my +experience, so I better not say what I think of them or people will start +saying bad things about me on c.l.l. + -- Ken Tilton +% +This reminds me of the NYC cabby who accepted a fare to Chicago. When +they got there and could not find the friend who was supposed to pay the +fare he just laughed and said he should have known. + -- Ken Tilton +% +>> Actually, I believe that Aikido, Jazz and Lisp are different appearances +>> of the same thing. +Yes, the Tao. /Everything/ is a different appearance of the tao. + -- Ken Tilton + +"Ken, I went to the library and read up on Buddhism, and believe me, you +are no Buddhist." + -- Kenny's mom +% +That absolutely terrifies the herd-following, lockstep-marching, +mainstream-saluting cowards that obediently dash out or online to +scoop up books on The Latest Thing. They learn and use atrocities like +Java, C++, XML, and even Python for the security it gives them and +then sit there slaving away miserably, tediously, joylously paying off +mortgages and supporting ungrateful teenagers who despise them, only +to look out the double-sealed thermo-pane windows of their +central-heated, sound-proofed, dead-bolted, suffocating little nests +into the howling gale thinking "what do they know that I do not know?" +when they see us under a lean-to hunched over our laptops to shield +them from the rain laughing our asses off as we write great code +between bong hits.... what was the question? + -- Ken Tilton +% +Shut up! (That last phrase has four or more syllables if pronounced as +intended.) + -- Ken Tilton +% +Nonsense. You'll be using it for the GUI, not protein-folding. + -- Ken Tilton + (responding to a comment that LTK was slow because it + was based on TK) +% +Continuations certainly are clever, but if we learned anything from the +rejection of the cover art for "Smell the Glove", it is that "there is a +fine line between stupid... and clever". + -- Ken Tilton +% +Ah, there's no place like academia for dispassionate, intellectually +honest discussion of new ideas on their merits. Thank god for tenure +giving your bold antagonist the protection they needed to shout down +your iconoclastic..... hang on... + -- Ken Tilton +% +Whoever objected must be in my killfile, ... + -- Ken Tilton +% +From memory (but I think I have it right): + +"But Jesus said, Suffer captured variables, and forbid them not, to come +unto thine macro bodies: for of such is are DSLs made." + -- Ken Tilton + +Can I get an Amen? +% +Awareness of defect is the first step to recovery. + -- Ken Tilton +% +You made a bad analogy (there are no good ones, but you found a new +low) ... + -- Ken Tilton +% +Yes, it is true that Kent Pitman was raised by a closet full of Lisp +Machines, but the exception only proves the rule. + -- Ken Tilton + (in a postscript after positing that computer + languages are not learned in infancy) +% +I suggest you try bartender's school to support yourself, start +programming for fun again. + -- Ken Tilton + (responding to a comment that 98% of anything to do + with computers was not interesting code) +% +You could add four lanes to my carpal tunnel and I still could not +write all the code I am dying to write. + -- Ken Tilton +% +Neutrality? I want to bury other languages, not have a gateway to them. + -- Ken Tilton +% +Ken: "Cute puppy. Did you get it for companionship or to pick up chicks?" +Simon: "Hunh? My puppy /always/ gives me companionship." + -- Ken Tilton + (on how he was understood by a native english speaker) +%
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ +Programmers who lock onto a design decision and cling to it in the face of contradictory new information -- well, that's almost everyone in my experience, so I better not say what I think of them or people will start saying bad things about me on c.l.l. -- Ken Tilton % This reminds me of the NYC cabby who accepted a fare to Chicago. When they got there and could not find the friend who was supposed to pay the fare he just laughed and said he should have known. -- Ken Tilton %
Actually, I believe that Aikido, Jazz and Lisp are different appearances of the same thing.
Yes, the Tao. /Everything/ is a different appearance of the tao. -- Ken Tilton
"Ken, I went to the library and read up on Buddhism, and believe me, you are no Buddhist." -- Kenny's mom % That absolutely terrifies the herd-following, lockstep-marching, mainstream-saluting cowards that obediently dash out or online to scoop up books on The Latest Thing. They learn and use atrocities like Java, C++, XML, and even Python for the security it gives them and then sit there slaving away miserably, tediously, joylously paying off mortgages and supporting ungrateful teenagers who despise them, only to look out the double-sealed thermo-pane windows of their central-heated, sound-proofed, dead-bolted, suffocating little nests into the howling gale thinking "what do they know that I do not know?" when they see us under a lean-to hunched over our laptops to shield them from the rain laughing our asses off as we write great code between bong hits.... what was the question? -- Ken Tilton % Shut up! (That last phrase has four or more syllables if pronounced as intended.) -- Ken Tilton % Nonsense. You'll be using it for the GUI, not protein-folding. -- Ken Tilton (responding to a comment that LTK was slow because it was based on TK) % Continuations certainly are clever, but if we learned anything from the rejection of the cover art for "Smell the Glove", it is that "there is a fine line between stupid... and clever". -- Ken Tilton % Ah, there's no place like academia for dispassionate, intellectually honest discussion of new ideas on their merits. Thank god for tenure giving your bold antagonist the protection they needed to shout down your iconoclastic..... hang on... -- Ken Tilton % Whoever objected must be in my killfile, ... -- Ken Tilton % From memory (but I think I have it right):
"But Jesus said, Suffer captured variables, and forbid them not, to come unto thine macro bodies: for of such is are DSLs made." -- Ken Tilton
Can I get an Amen? % Awareness of defect is the first step to recovery. -- Ken Tilton % You made a bad analogy (there are no good ones, but you found a new low) ... -- Ken Tilton % Yes, it is true that Kent Pitman was raised by a closet full of Lisp Machines, but the exception only proves the rule. -- Ken Tilton (in a postscript after positing that computer languages are not learned in infancy) % I suggest you try bartender's school to support yourself, start programming for fun again. -- Ken Tilton (responding to a comment that 98% of anything to do with computers was not interesting code) % You could add four lanes to my carpal tunnel and I still could not write all the code I am dying to write. -- Ken Tilton % Neutrality? I want to bury other languages, not have a gateway to them. -- Ken Tilton % Ken: "Cute puppy. Did you get it for companionship or to pick up chicks?" Simon: "Hunh? My puppy /always/ gives me companionship." -- Ken Tilton (on how he was understood by a native english speaker) % \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,96 @@ +Programmers who lock onto a design decision and cling to it in the face of +contradictory new information -- well, that's almost everyone in my +experience, so I better not say what I think of them or people will start +saying bad things about me on c.l.l. + -- Ken Tilton +% +This reminds me of the NYC cabby who accepted a fare to Chicago. When +they got there and could not find the friend who was supposed to pay the +fare he just laughed and said he should have known. + -- Ken Tilton +% +>> Actually, I believe that Aikido, Jazz and Lisp are different appearances +>> of the same thing. +Yes, the Tao. /Everything/ is a different appearance of the tao. + -- Ken Tilton + +"Ken, I went to the library and read up on Buddhism, and believe me, you +are no Buddhist." + -- Kenny's mom +% +That absolutely terrifies the herd-following, lockstep-marching, +mainstream-saluting cowards that obediently dash out or online to +scoop up books on The Latest Thing. They learn and use atrocities like +Java, C++, XML, and even Python for the security it gives them and +then sit there slaving away miserably, tediously, joylously paying off +mortgages and supporting ungrateful teenagers who despise them, only +to look out the double-sealed thermo-pane windows of their +central-heated, sound-proofed, dead-bolted, suffocating little nests +into the howling gale thinking "what do they know that I do not know?" +when they see us under a lean-to hunched over our laptops to shield +them from the rain laughing our asses off as we write great code +between bong hits.... what was the question? + -- Ken Tilton +% +Shut up! (That last phrase has four or more syllables if pronounced as +intended.) + -- Ken Tilton +% +Nonsense. You'll be using it for the GUI, not protein-folding. + -- Ken Tilton + (responding to a comment that LTK was slow because it + was based on TK) +% +Continuations certainly are clever, but if we learned anything from the +rejection of the cover art for "Smell the Glove", it is that "there is a +fine line between stupid... and clever". + -- Ken Tilton +% +Ah, there's no place like academia for dispassionate, intellectually +honest discussion of new ideas on their merits. Thank god for tenure +giving your bold antagonist the protection they needed to shout down +your iconoclastic..... hang on... + -- Ken Tilton +% +Whoever objected must be in my killfile, ... + -- Ken Tilton +% +From memory (but I think I have it right): + +"But Jesus said, Suffer captured variables, and forbid them not, to come +unto thine macro bodies: for of such is are DSLs made." + -- Ken Tilton + +Can I get an Amen? +% +Awareness of defect is the first step to recovery. + -- Ken Tilton +% +You made a bad analogy (there are no good ones, but you found a new +low) ... + -- Ken Tilton +% +Yes, it is true that Kent Pitman was raised by a closet full of Lisp +Machines, but the exception only proves the rule. + -- Ken Tilton + (in a postscript after positing that computer + languages are not learned in infancy) +% +I suggest you try bartender's school to support yourself, start +programming for fun again. + -- Ken Tilton + (responding to a comment that 98% of anything to do + with computers was not interesting code) +% +You could add four lanes to my carpal tunnel and I still could not +write all the code I am dying to write. + -- Ken Tilton +% +Neutrality? I want to bury other languages, not have a gateway to them. + -- Ken Tilton +% +Ken: "Cute puppy. Did you get it for companionship or to pick up chicks?" +Simon: "Hunh? My puppy /always/ gives me companionship." + -- Ken Tilton + (on how he was understood by a native english speaker) +%
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/tilton_utf8_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,96 @@ +Programmers who lock onto a design decision and cling to it in the face of +contradictory new information -- well, that's almost everyone in my +experience, so I better not say what I think of them or people will start +saying bad things about me on c.l.l. + -- Ken Tilton +% +This reminds me of the NYC cabby who accepted a fare to Chicago. When +they got there and could not find the friend who was supposed to pay the +fare he just laughed and said he should have known. + -- Ken Tilton +% +>> Actually, I believe that Aikido, Jazz and Lisp are different appearances +>> of the same thing. +Yes, the Tao. /Everything/ is a different appearance of the tao. + -- Ken Tilton + +"Ken, I went to the library and read up on Buddhism, and believe me, you +are no Buddhist." + -- Kenny's mom +% +That absolutely terrifies the herd-following, lockstep-marching, +mainstream-saluting cowards that obediently dash out or online to +scoop up books on The Latest Thing. They learn and use atrocities like +Java, C++, XML, and even Python for the security it gives them and +then sit there slaving away miserably, tediously, joylously paying off +mortgages and supporting ungrateful teenagers who despise them, only +to look out the double-sealed thermo-pane windows of their +central-heated, sound-proofed, dead-bolted, suffocating little nests +into the howling gale thinking "what do they know that I do not know?" +when they see us under a lean-to hunched over our laptops to shield +them from the rain laughing our asses off as we write great code +between bong hits.... what was the question? + -- Ken Tilton +% +Shut up! (That last phrase has four or more syllables if pronounced as +intended.) + -- Ken Tilton +% +Nonsense. You'll be using it for the GUI, not protein-folding. + -- Ken Tilton + (responding to a comment that LTK was slow because it + was based on TK) +% +Continuations certainly are clever, but if we learned anything from the +rejection of the cover art for "Smell the Glove", it is that "there is a +fine line between stupid... and clever". + -- Ken Tilton +% +Ah, there's no place like academia for dispassionate, intellectually +honest discussion of new ideas on their merits. Thank god for tenure +giving your bold antagonist the protection they needed to shout down +your iconoclastic..... hang on... + -- Ken Tilton +% +Whoever objected must be in my killfile, ... + -- Ken Tilton +% +From memory (but I think I have it right): + +"But Jesus said, Suffer captured variables, and forbid them not, to come +unto thine macro bodies: for of such is are DSLs made." + -- Ken Tilton + +Can I get an Amen? +% +Awareness of defect is the first step to recovery. + -- Ken Tilton +% +You made a bad analogy (there are no good ones, but you found a new +low) ... + -- Ken Tilton +% +Yes, it is true that Kent Pitman was raised by a closet full of Lisp +Machines, but the exception only proves the rule. + -- Ken Tilton + (in a postscript after positing that computer + languages are not learned in infancy) +% +I suggest you try bartender's school to support yourself, start +programming for fun again. + -- Ken Tilton + (responding to a comment that 98% of anything to do + with computers was not interesting code) +% +You could add four lanes to my carpal tunnel and I still could not +write all the code I am dying to write. + -- Ken Tilton +% +Neutrality? I want to bury other languages, not have a gateway to them. + -- Ken Tilton +% +Ken: "Cute puppy. Did you get it for companionship or to pick up chicks?" +Simon: "Hunh? My puppy /always/ gives me companionship." + -- Ken Tilton + (on how he was understood by a native english speaker) +%
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_cr_be.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_cr_be.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_cr_le.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_cr_le.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_crlf_be.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_crlf_be.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_crlf_le.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_crlf_le.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_lf_be.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_lf_be.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_lf_le.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs2_lf_le.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_cr_be.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_cr_be.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_cr_le.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_cr_le.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_crlf_be.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_crlf_be.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_crlf_le.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_crlf_le.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_lf_be.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_lf_be.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_lf_le.txt =================================================================== (Binary files differ)
Property changes on: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_ucs4_lf_le.txt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_cr.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_cr.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_cr.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1 @@ + UTF-8 encoded sample plain-text file ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Markus Kuhn [ˈmaʳkʊs kuːn] http://www.cl.cam.ac.uk/~mgk25/ — 2002-07-25
The ASCII compatible UTF-8 encoding used in this plain-text file is defined in Unicode, ISO 10646-1, and RFC 2279.
Using Unicode/UTF-8, you can write in emails and source code things such as
Mathematics and sciences:
∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫ ⎪⎢⎜│a²+b³ ⎟⎥⎪ ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪ ⎪⎢⎜⎷ c₈ ⎟⎥⎪ ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬ ⎪⎢⎜ ∞ ⎟⎥⎪ ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪ ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪ 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭
Linguistics and dictionaries:
ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]
APL:
((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈
Nicer typography in plain text files:
╔══════════════════════════════════════════╗ ║ ║ ║ • ‘single’ and “double” quotes ║ ║ ║ ║ • Curly apostrophes: “We’ve been here” ║ ║ ║ ║ • Latin-1 apostrophe and accents: '´` ║ ║ ║ ║ • ‚deutsche‘ „Anführungszeichen“ ║ ║ ║ ║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║ ║ ║ ║ • ASCII safety test: 1lI|, 0OD, 8B ║ ║ ╭─────────╮ ║ ║ • the euro symbol: │ 14.95 € │ ║ ║ ╰─────────╯ ║ ╚══════════════════════════════════════════╝
Combining characters:
STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
Greek (in Polytonic):
The Greek anthem:
Σὲ γνωρίζω ἀπὸ τὴν κόψη τοῦ σπαθιοῦ τὴν τρομερή, σὲ γνωρίζω ἀπὸ τὴν ὄψη ποὺ μὲ βία μετράει τὴ γῆ.
᾿Απ᾿ τὰ κόκκαλα βγαλμένη τῶν ῾Ελλήνων τὰ ἱερά καὶ σὰν πρῶτα ἀνδρειωμένη χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
From a speech of Demosthenes in the 4th century BC:
Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι, ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿ εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι, οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
Georgian:
From a Unicode conference invitation:
გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს, ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი, ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში, ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
Russian:
From a Unicode conference invitation:
Зарегистрируйтесь сейчас на Десятую Международную Конференцию по Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии. Конференция соберет широкий круг экспертов по вопросам глобального Интернета и Unicode, локализации и интернационализации, воплощению и применению Unicode в различных операционных системах и программных приложениях, шрифтах, верстке и многоязычных компьютерных системах.
Thai (UCS Level 2):
Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese classic 'San Gua'):
[----------------------------|------------------------] ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่ สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้ ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
(The above is a two-column text. If combining characters are handled correctly, the lines of the second column should be aligned with the | character above.)
Ethiopian:
Proverbs in the Amharic language:
ሰማይ አይታረስ ንጉሥ አይከሰስ። ብላ ካለኝ እንደአባቴ በቆመጠኝ። ጌጥ ያለቤቱ ቁምጥና ነው። ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው። የአፍ ወለምታ በቅቤ አይታሽም። አይጥ በበላ ዳዋ ተመታ። ሲተረጉሙ ይደረግሙ። ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል። ድር ቢያብር አንበሳ ያስር። ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም። እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም። የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ። ሥራ ከመፍታት ልጄን ላፋታት። ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል። የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ። ተንጋሎ ቢተፉ ተመልሶ ባፉ። ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው። እግርህን በፍራሽህ ልክ ዘርጋ።
Runes:
ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ
(Old English, which transcribed into Latin reads 'He cwaeth that he bude thaem lande northweardum with tha Westsae.' and means 'He said that he lived in the northern land near the Western Sea.')
Braille:
⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌
⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞ ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎ ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂ ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙ ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑ ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲
⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹ ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕ ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹ ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎ ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎ ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳ ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
(The first couple of paragraphs of "A Christmas Carol" by Dickens)
Compact font selection example text:
ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789 abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა
Greetings in various languages:
Hello world, Καλημέρα κόσμε, コンニチハ
Box drawing alignment tests: █ ▉ ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳ ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳ ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳ ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳ ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎ ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏ ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█ ▝▀▘▙▄▟ \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_crlf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_crlf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_crlf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,212 @@ + +UTF-8 encoded sample plain-text file +‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +Markus Kuhn [ˈmaʳkʊs kuːn] http://www.cl.cam.ac.uk/~mgk25/ — 2002-07-25 + + +The ASCII compatible UTF-8 encoding used in this plain-text file +is defined in Unicode, ISO 10646-1, and RFC 2279. + + +Using Unicode/UTF-8, you can write in emails and source code things such as + +Mathematics and sciences: + + ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫ + ⎪⎢⎜│a²+b³ ⎟⎥⎪ + ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪ + ⎪⎢⎜⎷ c₈ ⎟⎥⎪ + ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬ + ⎪⎢⎜ ∞ ⎟⎥⎪ + ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪ + ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪ + 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭ + +Linguistics and dictionaries: + + ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn + Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ] + +APL: + + ((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈ + +Nicer typography in plain text files: + + ╔══════════════════════════════════════════╗ + ║ ║ + ║ • ‘single’ and “double” quotes ║ + ║ ║ + ║ • Curly apostrophes: “We’ve been here” ║ + ║ ║ + ║ • Latin-1 apostrophe and accents: '´` ║ + ║ ║ + ║ • ‚deutsche‘ „Anführungszeichen“ ║ + ║ ║ + ║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║ + ║ ║ + ║ • ASCII safety test: 1lI|, 0OD, 8B ║ + ║ ╭─────────╮ ║ + ║ • the euro symbol: │ 14.95 € │ ║ + ║ ╰─────────╯ ║ + ╚══════════════════════════════════════════╝ + +Combining characters: + + STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑ + +Greek (in Polytonic): + + The Greek anthem: + + Σὲ γνωρίζω ἀπὸ τὴν κόψη + τοῦ σπαθιοῦ τὴν τρομερή, + σὲ γνωρίζω ἀπὸ τὴν ὄψη + ποὺ μὲ βία μετράει τὴ γῆ. + + ᾿Απ᾿ τὰ κόκκαλα βγαλμένη + τῶν ῾Ελλήνων τὰ ἱερά + καὶ σὰν πρῶτα ἀνδρειωμένη + χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά! + + From a speech of Demosthenes in the 4th century BC: + + Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι, + ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς + λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ + τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿ + εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ + πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν + οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι, + οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν + ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον + τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι + γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν + προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους + σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ + τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ + τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς + τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον. + + Δημοσθένους, Γ´ ᾿Ολυνθιακὸς + +Georgian: + + From a Unicode conference invitation: + + გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო + კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს, + ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს + ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი, + ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება + ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში, + ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში. + +Russian: + + From a Unicode conference invitation: + + Зарегистрируйтесь сейчас на Десятую Международную Конференцию по + Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии. + Конференция соберет широкий круг экспертов по вопросам глобального + Интернета и Unicode, локализации и интернационализации, воплощению и + применению Unicode в различных операционных системах и программных + приложениях, шрифтах, верстке и многоязычных компьютерных системах. + +Thai (UCS Level 2): + + Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese + classic 'San Gua'): + + [----------------------------|------------------------] + ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่ + สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา + ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา + โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ + เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ + ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ + พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้ + ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ + + (The above is a two-column text. If combining characters are handled + correctly, the lines of the second column should be aligned with the + | character above.) + +Ethiopian: + + Proverbs in the Amharic language: + + ሰማይ አይታረስ ንጉሥ አይከሰስ። + ብላ ካለኝ እንደአባቴ በቆመጠኝ። + ጌጥ ያለቤቱ ቁምጥና ነው። + ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው። + የአፍ ወለምታ በቅቤ አይታሽም። + አይጥ በበላ ዳዋ ተመታ። + ሲተረጉሙ ይደረግሙ። + ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል። + ድር ቢያብር አንበሳ ያስር። + ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም። + እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም። + የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ። + ሥራ ከመፍታት ልጄን ላፋታት። + ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል። + የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ። + ተንጋሎ ቢተፉ ተመልሶ ባፉ። + ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው። + እግርህን በፍራሽህ ልክ ዘርጋ። + +Runes: + + ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ + + (Old English, which transcribed into Latin reads 'He cwaeth that he + bude thaem lande northweardum with tha Westsae.' and means 'He said + that he lived in the northern land near the Western Sea.') + +Braille: + + ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌ + + ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞ + ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎ + ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂ + ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙ + ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑ + ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲ + + ⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ + + ⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹ + ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞ + ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕ + ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹ + ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎ + ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎ + ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳ + ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞ + ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ + + (The first couple of paragraphs of "A Christmas Carol" by Dickens) + +Compact font selection example text: + + ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789 + abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ + –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд + ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა + +Greetings in various languages: + + Hello world, Καλημέρα κόσμε, コンニチハ + +Box drawing alignment tests: █ + ▉ + ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳ + ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳ + ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳ + ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳ + ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎ + ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏ + ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█ + ▝▀▘▙▄▟
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_lf.txt =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_lf.txt 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/test/unicode_demo_utf8_lf.txt 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,212 @@ + +UTF-8 encoded sample plain-text file +‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +Markus Kuhn [ˈmaʳkʊs kuːn] http://www.cl.cam.ac.uk/~mgk25/ — 2002-07-25 + + +The ASCII compatible UTF-8 encoding used in this plain-text file +is defined in Unicode, ISO 10646-1, and RFC 2279. + + +Using Unicode/UTF-8, you can write in emails and source code things such as + +Mathematics and sciences: + + ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫ + ⎪⎢⎜│a²+b³ ⎟⎥⎪ + ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪ + ⎪⎢⎜⎷ c₈ ⎟⎥⎪ + ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬ + ⎪⎢⎜ ∞ ⎟⎥⎪ + ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪ + ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪ + 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭ + +Linguistics and dictionaries: + + ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn + Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ] + +APL: + + ((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈ + +Nicer typography in plain text files: + + ╔══════════════════════════════════════════╗ + ║ ║ + ║ • ‘single’ and “double” quotes ║ + ║ ║ + ║ • Curly apostrophes: “We’ve been here” ║ + ║ ║ + ║ • Latin-1 apostrophe and accents: '´` ║ + ║ ║ + ║ • ‚deutsche‘ „Anführungszeichen“ ║ + ║ ║ + ║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║ + ║ ║ + ║ • ASCII safety test: 1lI|, 0OD, 8B ║ + ║ ╭─────────╮ ║ + ║ • the euro symbol: │ 14.95 € │ ║ + ║ ╰─────────╯ ║ + ╚══════════════════════════════════════════╝ + +Combining characters: + + STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑ + +Greek (in Polytonic): + + The Greek anthem: + + Σὲ γνωρίζω ἀπὸ τὴν κόψη + τοῦ σπαθιοῦ τὴν τρομερή, + σὲ γνωρίζω ἀπὸ τὴν ὄψη + ποὺ μὲ βία μετράει τὴ γῆ. + + ᾿Απ᾿ τὰ κόκκαλα βγαλμένη + τῶν ῾Ελλήνων τὰ ἱερά + καὶ σὰν πρῶτα ἀνδρειωμένη + χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά! + + From a speech of Demosthenes in the 4th century BC: + + Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι, + ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς + λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ + τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿ + εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ + πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν + οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι, + οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν + ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον + τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι + γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν + προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους + σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ + τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ + τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς + τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον. + + Δημοσθένους, Γ´ ᾿Ολυνθιακὸς + +Georgian: + + From a Unicode conference invitation: + + გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო + კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს, + ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს + ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი, + ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება + ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში, + ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში. + +Russian: + + From a Unicode conference invitation: + + Зарегистрируйтесь сейчас на Десятую Международную Конференцию по + Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии. + Конференция соберет широкий круг экспертов по вопросам глобального + Интернета и Unicode, локализации и интернационализации, воплощению и + применению Unicode в различных операционных системах и программных + приложениях, шрифтах, верстке и многоязычных компьютерных системах. + +Thai (UCS Level 2): + + Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese + classic 'San Gua'): + + [----------------------------|------------------------] + ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่ + สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา + ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา + โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ + เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ + ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ + พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้ + ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ + + (The above is a two-column text. If combining characters are handled + correctly, the lines of the second column should be aligned with the + | character above.) + +Ethiopian: + + Proverbs in the Amharic language: + + ሰማይ አይታረስ ንጉሥ አይከሰስ። + ብላ ካለኝ እንደአባቴ በቆመጠኝ። + ጌጥ ያለቤቱ ቁምጥና ነው። + ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው። + የአፍ ወለምታ በቅቤ አይታሽም። + አይጥ በበላ ዳዋ ተመታ። + ሲተረጉሙ ይደረግሙ። + ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል። + ድር ቢያብር አንበሳ ያስር። + ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም። + እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም። + የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ። + ሥራ ከመፍታት ልጄን ላፋታት። + ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል። + የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ። + ተንጋሎ ቢተፉ ተመልሶ ባፉ። + ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው። + እግርህን በፍራሽህ ልክ ዘርጋ። + +Runes: + + ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ + + (Old English, which transcribed into Latin reads 'He cwaeth that he + bude thaem lande northweardum with tha Westsae.' and means 'He said + that he lived in the northern land near the Western Sea.') + +Braille: + + ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌ + + ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞ + ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎ + ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂ + ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙ + ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑ + ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲ + + ⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ + + ⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹ + ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞ + ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕ + ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹ + ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎ + ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎ + ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳ + ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞ + ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ + + (The first couple of paragraphs of "A Christmas Carol" by Dickens) + +Compact font selection example text: + + ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789 + abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ + –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд + ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა + +Greetings in various languages: + + Hello world, Καλημέρα κόσμε, コンニチハ + +Box drawing alignment tests: █ + ▉ + ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳ + ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳ + ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳ + ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳ + ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎ + ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏ + ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█ + ▝▀▘▙▄▟
Added: branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/util.lisp =================================================================== --- branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/util.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/flexi-streams-0.13.1/util.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,166 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- +;;; $Header: /usr/local/cvsrep/flexi-streams/util.lisp,v 1.13 2007/01/01 23:46:49 edi Exp $ + +;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. + +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: + +;;; * Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. + +;;; * Redistributions in binary form must reproduce the above +;;; copyright notice, this list of conditions and the following +;;; disclaimer in the documentation and/or other materials +;;; provided with the distribution. + +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED +;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package :flexi-streams) + +#+:lispworks +(eval-when (:compile-toplevel :load-toplevel :execute) + (import 'lw:with-unique-names)) + +#-:lispworks +(defmacro with-unique-names ((&rest bindings) &body body) + "Syntax: WITH-UNIQUE-NAMES ( { var | (var x) }* ) declaration* form* + +Executes a series of forms with each VAR bound to a fresh, +uninterned symbol. The uninterned symbol is as if returned by a call +to GENSYM with the string denoted by X - or, if X is not supplied, the +string denoted by VAR - as argument. + +The variable bindings created are lexical unless special declarations +are specified. The scopes of the name bindings and declarations do not +include the Xs. + +The forms are evaluated in order, and the values of all but the last +are discarded (that is, the body is an implicit PROGN)." + ;; reference implementation posted to comp.lang.lisp as + ;; cy3bshuf30f.fsf@ljosa.com by Vebjorn Ljosa - see also + ;; http://www.cliki.net/Common%20Lisp%20Utilities + `(let ,(mapcar #'(lambda (binding) + (check-type binding (or cons symbol)) + (if (consp binding) + (destructuring-bind (var x) binding + (check-type var symbol) + `(,var (gensym ,(etypecase x + (symbol (symbol-name x)) + (character (string x)) + (string x))))) + `(,binding (gensym ,(symbol-name binding))))) + bindings) + ,@body)) + +#+:lispworks +(eval-when (:compile-toplevel :load-toplevel :execute) + (setf (macro-function 'with-rebinding) + (macro-function 'lw:rebinding))) + +#-:lispworks +(defmacro with-rebinding (bindings &body body) + "WITH-REBINDING ( { var | (var prefix) }* ) form* + +Evaluates a series of forms in the lexical environment that is +formed by adding the binding of each VAR to a fresh, uninterned +symbol, and the binding of that fresh, uninterned symbol to VAR's +original value, i.e., its value in the current lexical environment. + +The uninterned symbol is created as if by a call to GENSYM with the +string denoted by PREFIX - or, if PREFIX is not supplied, the string +denoted by VAR - as argument. + +The forms are evaluated in order, and the values of all but the last +are discarded (that is, the body is an implicit PROGN)." + ;; reference implementation posted to comp.lang.lisp as + ;; cy3wv0fya0p.fsf@ljosa.com by Vebjorn Ljosa - see also + ;; http://www.cliki.net/Common%20Lisp%20Utilities + (loop for binding in bindings + for var = (if (consp binding) (car binding) binding) + for name = (gensym) + collect `(,name ,var) into renames + collect ``(,,var ,,name) into temps + finally (return `(let ,renames + (with-unique-names ,bindings + `(let (,,@temps) + ,,@body)))))) + +(defun normalize-external-format-name (name) + "Converts NAME (a symbol) to a `canonical' name for an +external format, e.g. :LATIN1 will be converted to :ISO-8859-1. +Also checks if there is an external format with that name and +signals an error otherwise." + (let ((real-name (or (cdr (assoc name +name-map+ + :test #'eq)) + name))) + (unless (find real-name +name-map+ + :test #'eq + :key #'cdr) + (error "~S is not known to be a name for an external format." name)) + real-name)) + +(defun ascii-name-p (name) + "Checks whether NAME is the keyword :ASCII." + (eq name :us-ascii)) + +(defun koi8-r-name-p (name) + "Checks whether NAME is the keyword :KOI8-R." + (eq name :koi8-r)) + +(defun code-page-name-p (name) + "Checks whether NAME is the keyword :CODE-PAGE." + (eq name :code-page)) + +(defun iso-8859-name-p (name) + "Checks whether NAME (a keyword) names one of the known +ISO-8859 encodings." + (find name +iso-8859-tables+ :key #'car)) + +(defun known-code-page-id-p (id) + "Checks whether ID (a number) denotes one of the known Windows +code pages." + (and (find id +code-page-tables+ :key #'car) + id)) + +#+:lispworks +(defun sans (plist &rest keys) + "Returns PLIST with keyword arguments from KEYS removed." + (sys::remove-properties plist keys)) + +#-:lispworks +(defun sans (plist &rest keys) + "Returns PLIST with keyword arguments from KEYS removed." + ;; stolen from Usenet posting 3247672165664225@naggum.no by Erik + ;; Naggum + (let ((sans ())) + (loop + (let ((tail (nth-value 2 (get-properties plist keys)))) + ;; this is how it ends + (unless tail + (return (nreconc sans plist))) + ;; copy all the unmatched keys + (loop until (eq plist tail) do + (push (pop plist) sans) + (push (pop plist) sans)) + ;; skip the matched key + (setq plist (cddr plist)))))) + +#+:lispworks +(defmacro with-accessors (slot-entries instance &body body) + "For LispWorks, we prefer SLOT-VALUE over accessors for better +performance." + `(with-slots ,(mapcar #'car slot-entries) + ,instance + ,@body)) \ No newline at end of file
Added: branches/trunk-reorg/thirdparty/trivial-gray-streams/COPYING =================================================================== --- branches/trunk-reorg/thirdparty/trivial-gray-streams/COPYING 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-gray-streams/COPYING 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,21 @@ + Copyright (c) 2005 David Lichteblau + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE.
Added: branches/trunk-reorg/thirdparty/trivial-gray-streams/Makefile =================================================================== --- branches/trunk-reorg/thirdparty/trivial-gray-streams/Makefile 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-gray-streams/Makefile 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,3 @@ +.PHONY: clean +clean: + rm -f *.fasl *.x86f *.fas *.ufsl *.lib *.pfsl
Added: branches/trunk-reorg/thirdparty/trivial-gray-streams/README =================================================================== --- branches/trunk-reorg/thirdparty/trivial-gray-streams/README 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-gray-streams/README 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,37 @@ +trivial-gray-streams +==================== + +This system provides an extremely thin compatibility layer for gray +streams. It is nearly *too* trivial for a complete package, except that +I have copy&pasted this code into enough projects now that I decided to +factor it out once again now, and then *never* have to touch it again. + + +How to use it +============= + +1. Use the package TRIVIAL-GRAY-STREAMS instead of whatever + implementation-specific package you would have to use otherwise to + get at gray stream symbols. +2. For STREAM-READ-SEQUENCE and STREAM-WRITE-SEQUENCE, notice that we + use two required arguments and allow additional keyword arguments. + So the lambda list when defining a method on either function should look + like this: + (stream sequence start end &key) +3. In order for (2) to work on all Lisps, make sure to subclass all your + stream classes from TRIVIAL-GRAY-STREAM-MIXIN if you intend to define + methods on those two generic functions. + + +Extensions +========== + +Generic function STREAM-READ-SEQUENCE (stream sequence start end &key) +Generic function STREAM-WRITE-SEQUENCE (stream sequence start end &key) + + See above. + +Generic function STREAM-FILE-POSITION (stream) => file position +Generic function (SETF STREAM-FILE-POSITION) (position-spec stream) => successp + + Will only be called by LispWorks and CLISP.
Added: branches/trunk-reorg/thirdparty/trivial-gray-streams/mixin.lisp =================================================================== --- branches/trunk-reorg/thirdparty/trivial-gray-streams/mixin.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-gray-streams/mixin.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,117 @@ +(in-package :trivial-gray-streams) + +(defclass trivial-gray-stream-mixin () ()) + +(defgeneric stream-read-sequence + (stream sequence start end &key &allow-other-keys)) +(defgeneric stream-write-sequence + (stream sequence start end &key &allow-other-keys)) + +(defgeneric stream-file-position (stream)) +(defgeneric (setf stream-file-position) (newval stream)) + +(defmethod stream-write-string + ((stream trivial-gray-stream-mixin) seq &optional start end) + (stream-write-sequence stream seq (or start 0) (or end (length seq)))) + +;; Implementations should provide this default method, I believe, but +;; at least sbcl and allegro don't. +(defmethod stream-terpri ((stream trivial-gray-stream-mixin)) + (write-char #\newline stream)) + +(defmethod stream-file-position ((stream trivial-gray-stream-mixin)) + nil) + +(defmethod (setf stream-file-position) + (newval (stream trivial-gray-stream-mixin)) + (declare (ignore newval)) + nil) + +#+allegro +(progn + (defmethod excl:stream-read-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-read-sequence s seq (or start 0) (or end (length seq)))) + (defmethod stream:stream-write-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-write-sequence s seq (or start 0) (or end (length seq))))) + +#+cmu +(progn + (defmethod ext:stream-read-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-read-sequence s seq (or start 0) (or end (length seq)))) + (defmethod ext:stream-write-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-write-sequence s seq (or start 0) (or end (length seq))))) + +#+lispworks +(progn + (defmethod stream:stream-read-sequence + ((s trivial-gray-stream-mixin) seq start end) + (stream-read-sequence s seq start end)) + (defmethod stream:stream-write-sequence + ((s trivial-gray-stream-mixin) seq start end) + (stream-write-sequence s seq start end)) + + (defmethod stream:stream-file-position ((stream trivial-gray-stream-mixin)) + (stream-file-position stream)) + (defmethod (setf stream:stream-file-position) + (newval (stream trivial-gray-stream-mixin)) + (setf (stream-file-position stream) newval))) + +#+openmcl +(progn + (defmethod ccl:stream-read-vector + ((s trivial-gray-stream-mixin) seq start end) + (stream-read-sequence s seq start end)) + (defmethod ccl:stream-write-vector + ((s trivial-gray-stream-mixin) seq start end) + (stream-write-sequence s seq start end))) + +#+clisp +(progn + (defmethod gray:stream-read-byte-sequence + ((s trivial-gray-stream-mixin) + seq + &optional start end no-hang interactive) + (when no-hang + (error "this stream does not support the NO-HANG argument")) + (when interactive + (error "this stream does not support the INTERACTIVE argument")) + (stream-read-sequence s seq start end)) + + (defmethod gray:stream-write-byte-sequence + ((s trivial-gray-stream-mixin) + seq + &optional start end no-hang interactive) + (when no-hang + (error "this stream does not support the NO-HANG argument")) + (when interactive + (error "this stream does not support the INTERACTIVE argument")) + (stream-write-sequence s seq start end)) + + (defmethod gray:stream-read-char-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-read-sequence s seq start end)) + + (defmethod gray:stream-write-char-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-write-sequence s seq start end)) + + (defmethod gray:stream-position ((stream trivial-gray-stream-mixin) position) + (if position + (setf (stream-file-position stream) position) + (stream-file-position stream)))) + +#+sbcl +(progn + (defmethod sb-gray:stream-read-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-read-sequence s seq (or start 0) (or end (length seq)))) + (defmethod sb-gray:stream-write-sequence + ((s trivial-gray-stream-mixin) seq &optional start end) + (stream-write-sequence s seq (or start 0) (or end (length seq)))) + ;; SBCL extension: + (defmethod sb-gray:stream-line-length ((stream trivial-gray-stream-mixin)) + 80))
Added: branches/trunk-reorg/thirdparty/trivial-gray-streams/package.lisp =================================================================== --- branches/trunk-reorg/thirdparty/trivial-gray-streams/package.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-gray-streams/package.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,44 @@ +(in-package :trivial-gray-streams-system) + +#+cmu +(eval-when (:compile-toplevel :load-toplevel :execute) + (require :gray-streams)) + +#+allegro +(eval-when (:compile-toplevel :load-toplevel :execute) + (unless (fboundp 'stream:stream-write-string) + (require "streamc.fasl"))) + +(macrolet + ((frob () + (let + ((common-symbols + '(#:fundamental-stream #:fundamental-input-stream + #:fundamental-output-stream #:fundamental-character-stream + #:fundamental-binary-stream #:fundamental-character-input-stream + #:fundamental-character-output-stream + #:fundamental-binary-input-stream + #:fundamental-binary-output-stream #:stream-read-char + #:stream-unread-char #:stream-read-char-no-hang + #:stream-peek-char #:stream-listen #:stream-read-line + #:stream-clear-input #:stream-write-char #:stream-line-column + #:stream-start-line-p #:stream-write-string #:stream-terpri + #:stream-fresh-line #:stream-finish-output #:stream-force-output + #:stream-clear-output #:stream-advance-to-column + #:stream-read-byte #:stream-write-byte))) + `(defpackage :trivial-gray-streams + (:use :cl) + (:import-from #+sbcl :sb-gray + #+allegro :excl + #+cmu :ext + #+clisp :gray + #+openmcl :ccl + #+lispworks :stream + #-(or sbcl allegro cmu clisp openmcl lispworks) ... + ,@common-symbols) + (:export #:trivial-gray-stream-mixin + #:stream-read-sequence + #:stream-write-sequence + #:stream-file-position + ,@common-symbols))))) + (frob))
Added: branches/trunk-reorg/thirdparty/trivial-gray-streams/trivial-gray-streams.asd =================================================================== --- branches/trunk-reorg/thirdparty/trivial-gray-streams/trivial-gray-streams.asd 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-gray-streams/trivial-gray-streams.asd 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,9 @@ +;;; -*- mode: lisp -*- + +(defpackage :trivial-gray-streams-system +(:use :cl :asdf)) +(in-package :trivial-gray-streams-system) + +(defsystem :trivial-gray-streams + :serial t + :components ((:file "package") (:file "mixin")))
Added: branches/trunk-reorg/thirdparty/trivial-https/LICENSE =================================================================== --- branches/trunk-reorg/thirdparty/trivial-https/LICENSE 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-https/LICENSE 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,21 @@ +Copyright (c) 2005 Brian Mastenbrook +[ HTTPS support 2005 David Lichteblau ] + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Added: branches/trunk-reorg/thirdparty/trivial-https/README =================================================================== --- branches/trunk-reorg/thirdparty/trivial-https/README 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-https/README 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,18 @@ +[ trivial-https is a fork of trivial-http with support for HTTPS. ] + +trivial-https is a trivial library for doing HTTP POST and GET over a +socket interface. It establishes a package TRIVIAL-HTTPS, from which the +following functions are exported: + +(TRIVIAL-HTTPS:HTTP-GET URL &optional HEADERS) - returns a list of three +elements: a response code as integer, an association list of headers returned +from the server, and a stream from which the request can be read. Optional +argument HEADERS can be supplied as an alist of header name and value pairs +to be sent to the server. + +(TRIVIAL-HTTPS:HTTP-POST URL CONTENT-TYPE CONTENT) - given a URL, a MIME +content type, and the content as a character stream, POST to the URL +and return the list of three elements as described for HTTP-GET. + +(TRIVIAL-HTTPS:ESCAPE-URL-QUERY QUERY) - escapes a query string in accordance +with the HTTP specification.
Added: branches/trunk-reorg/thirdparty/trivial-https/trivial-https.asd =================================================================== --- branches/trunk-reorg/thirdparty/trivial-https/trivial-https.asd 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-https/trivial-https.asd 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,13 @@ +;;;; Silly emacs, this is -*- Lisp -*- (or thereabouts) + +;;this is necessary due to a bug in SBCL +#+sbcl +(require :sb-bsd-sockets) + +(defsystem trivial-https + :name "trivial-https" + :author "Brian Mastenbrook/David Lichteblau" + :licence "MIT" + :description "Trivial support for HTTP GET and POST." + :depends-on (:trivial-sockets :cl+ssl) + :components ((:file "trivial-https")))
Added: branches/trunk-reorg/thirdparty/trivial-https/trivial-https.lisp =================================================================== --- branches/trunk-reorg/thirdparty/trivial-https/trivial-https.lisp 2007-11-14 05:24:08 UTC (rev 2274) +++ branches/trunk-reorg/thirdparty/trivial-https/trivial-https.lisp 2007-11-14 05:26:34 UTC (rev 2275) @@ -0,0 +1,98 @@ +(defpackage :trivial-https + (:use :cl :trivial-sockets) + (:export :http-get :http-post :escape-url-query)) +(in-package :trivial-https) + +(defun url-scheme (url) + (assert (or (string-equal url "http://" :end1 7) + (string-equal url "https://" :end1 8))) + (subseq url 0 (position #: url))) + +(defun url-port (url) + (let* ((scheme (url-scheme url)) + (host-start (+ (length scheme) 3)) + (path-start (position #/ url :start host-start))) + (let ((port-start (position #: url :start host-start :end path-start))) + (if port-start + (parse-integer url :start (1+ port-start) :junk-allowed t) + (if (equal scheme "https") 443 80))))) + +(defun url-host (url) + (let* ((host-start (+ (length (url-scheme url)) 3)) + (port-start (position #: url :start host-start)) + (host-end (min (or (position #/ url :start host-start) (length url)) + (or port-start (length url))))) + (subseq url host-start host-end))) + +(defconstant +crlf+ + (if (boundp '+crlf+) + (symbol-value '+crlf+) + (concatenate 'string + (string (code-char 13)) + (string (code-char 10))))) + +(defun response-read-code (stream) + (let* ((l (read-line stream)) + (space (position #\Space l))) + (parse-integer l :start (1+ space) :junk-allowed t))) + +(defun response-read-headers (stream) + (loop for line = (read-line stream nil nil) + until (or (eql (length line) 0) + (eql (elt line 0) (code-char 13)) + (eql (elt line 0) (code-char 10))) + collect + (let ((colon (position #: line))) + (cons (intern (string-upcase (subseq line 0 colon)) :keyword) + (string-trim (list #\Space (code-char 13) (code-char 10)) + (subseq line (1+ colon))))))) + +(defun http-get (url &optional headers) + (let* ((host (url-host url)) + (port (url-port url)) + (stream + (if (equal (url-scheme url) "https") + (cl+ssl:make-ssl-client-stream + (open-stream host port :element-type '(unsigned-byte 8)) + :external-format :iso-8859-1) + (open-stream host port)))) + (format stream "GET ~A HTTP/1.0~AHost: ~A~AUser-Agent: Trivial HTTP for Common Lisp~A" + url +crlf+ host +crlf+ +crlf+) + (loop for (name . value) in headers do + (format stream "~A: ~A~A" name value +crlf+)) + (write-string +crlf+ stream) + (force-output stream) + (list + (response-read-code stream) + (response-read-headers stream) + stream))) + +(defun http-post (url content-type content) + (let* ((host (url-host url)) + (port (url-port url)) + (stream + (if (equal (url-scheme url) "https") + (cl+ssl:make-ssl-client-stream + (open-stream host port :element-type '(unsigned-byte 8)) + :external-format :iso-8859-1) + (open-stream host port)))) + (format stream "POST ~A HTTP/1.0~AHost: ~A~AUser-Agent: Trivial HTTP for Common Lisp~AContent-Type: ~A~AContent-Length: ~D~A~A~A" url +crlf+ host +crlf+ +crlf+ content-type +crlf+ (length content) +crlf+ +crlf+ content) + (force-output stream) + (list + (response-read-code stream) + (response-read-headers stream) + stream))) + +;; this next method stolen from Araneida + +(defun url-reserved-character-p (c) + (not (or (member c '(#- #_ #. #! #~ #* #' #( #) )) + (alphanumericp c)))) + +(defun escape-url-query (query) + (apply #'concatenate 'string + (loop for c across query + if (url-reserved-character-p c) + collect (format nil "%~2,'0X" (char-code c)) + else + collect (string c))))