Skip to content
Snippets Groups Projects
Commit af5cd1ae authored by rtoy's avatar rtoy
Browse files

extfmts.lisp:

o Update comments for the various slots in DEFINE-EXTERNAL-FORMAT.

fd-stream.lisp:
o Declare the types for the CHAR-TO-OCTETS-ERROR and
  OCTETS-TO-CHAR-ERROR slots in FD-STREAM.
o Update docstrings for MAKE-FD-STREAM and OPEN for :DECODING-ERROR
  and :ENCODING-ERROR parameters.
parent 7b95ed2b
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; domain. ;;; domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/extfmts.lisp,v 1.30 2010/07/03 13:39:19 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/extfmts.lisp,v 1.31 2010/07/03 16:44:37 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -149,29 +149,47 @@ ...@@ -149,29 +149,47 @@
;;; Define an external format based on a previously-defined external ;;; Define an external format based on a previously-defined external
;;; format, Base. The slot names used in Slots must match those in Base. ;;; format, Base. The slot names used in Slots must match those in Base.
;;; ;;;
;;; octets-to-code (state input unput &rest vars) ;;; octets-to-code (state input unput error &rest vars)
;;; Defines a form to be used by the external format to convert ;;; Defines a form to be used by the external format to convert
;;; octets to a code point. State is a form that can be used by the ;;; octets to a code point. State is a form that can be used by the
;;; body to access the state of the stream. Input is a form that ;;; body to access the state of the stream. Input is a form that
;;; can be used to read one octet from the input stream. (It can be ;;; can be used to read one octet from the input stream. (It can be
;;; called as many times as needed.) Similarly, Unput is a form to ;;; called as many times as needed.) Similarly, Unput is a form to
;;; put back one octet to the input stream. Vars is a list of vars ;;; put back one octet to the input stream. Error is an error
;;; that need to be defined for any symbols used within the form. ;;; handler. The default is NIL to indicate that the code should do
;;; its default handling. Otherwise, it should be a function or
;;; symbol to indicate how errors are handled. Vars is a list of
;;; vars that need to be defined for any symbols used within the
;;; form.
;;;
;;; The error handler is a function of 3 arguments: a format message
;;; string, the offending octet (or NIL) and the number of octets
;;; read for this encoding. If the function returns, it should
;;; return the codepoint to be used in place of the erroneous
;;; sequence.
;;; ;;;
;;; This should return two values: the code and the number of octets ;;; This should return two values: the code and the number of octets
;;; read to form the code. ;;; read to form the code.
;;; ;;;
;;; code-to-octets (code state output &rest vars) ;;; code-to-octets (code state output error &rest vars)
;;; Defines a form to be used by the external format to convert a ;;; Defines a form to be used by the external format to convert a
;;; code point to octets for output. Code is the code point to be ;;; code point to octets for output. Code is the code point to be
;;; converted. State is a form to access the current value of the ;;; converted. State is a form to access the current value of the
;;; stream's state variable. Output is a form that writes one octet ;;; stream's state variable. Output is a form that writes one octet
;;; to the output stream. ;;; to the output stream. Error is the error handler. A value of
;;; NIL means the external format should use its default method.
;;; Otherwise, it should be a symbol or function that will e called
;;; to handle the error.
;;;
;;; The error function takes 2 arguments: a format message string
;;; and the offending codepoint. If the function returns, it should
;;; be the desired replacement codepoint.
;;; ;;;
;;; flush-state (state output error &rest vars) ;;; flush-state (state output error &rest vars)
;;; Defines a form to be used by the external format to flush out ;;; Defines a form to be used by the external format to flush out
;;; any state when an output stream is closed. Similar to ;;; any state when an output stream is closed. Similar to
;;; CODE-TO-OCTETS, but there is no code. ;;; CODE-TO-OCTETS, but there is no code. Error is similar to the
;;; error parameter for code-to-octets.
;;; ;;;
;;; copy-state (state &rest vars) ;;; copy-state (state &rest vars)
;;; Defines a form to copy any state needed by the external format. ;;; Defines a form to copy any state needed by the external format.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fd-stream.lisp,v 1.109 2010/07/03 15:20:25 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fd-stream.lisp,v 1.110 2010/07/03 16:44:37 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -275,14 +275,14 @@ ...@@ -275,14 +275,14 @@
;; of octets read so far in decoding; if the function returns it ;; of octets read so far in decoding; if the function returns it
;; should return the codepoint of the desired replacement character. ;; should return the codepoint of the desired replacement character.
#+unicode #+unicode
(octets-to-char-error nil) (octets-to-char-error nil :type (or null symbol function))
;; ;;
;; Like OCTETS-TO-CHAR-ERROR, but for converting characters to ;; Like OCTETS-TO-CHAR-ERROR, but for converting characters to
;; octets for output. The function takes two arguments: a message ;; octets for output. The function takes two arguments: a message
;; string and the codepoint that cannot be converted. The function ;; string and the codepoint that cannot be converted. The function
;; should return the octet that should be output. ;; should return the octet that should be output.
#+unicode #+unicode
(char-to-octets-error nil)) (char-to-octets-error nil :type (or null symbol function)))
(defun %print-fd-stream (fd-stream stream depth) (defun %print-fd-stream (fd-stream stream depth)
(declare (ignore depth) (stream stream)) (declare (ignore depth) (stream stream))
...@@ -1819,7 +1819,10 @@ ...@@ -1819,7 +1819,10 @@
Timeout (if true) is the number of seconds to wait for input. If NIL (the Timeout (if true) is the number of seconds to wait for input. If NIL (the
default), then wait forever. When we time out, we signal IO-TIMEOUT. default), then wait forever. When we time out, we signal IO-TIMEOUT.
File is the name of the file (will be returned by PATHNAME). File is the name of the file (will be returned by PATHNAME).
Name is used to identify the stream when printed." Name is used to identify the stream when printed.
External-format is the external format to use for the stream.
Decoding-error and Encoding-error indicate how decoding/encoding errors on
the stream should be handled. The default is to use a replacement character."
(cond ((not (or input-p output-p)) (cond ((not (or input-p output-p))
(setf input t)) (setf input t))
((not (or input output)) ((not (or input output))
...@@ -1842,7 +1845,7 @@ ...@@ -1842,7 +1845,7 @@
((eq t decoding-error) ((eq t decoding-error)
#'(lambda (&rest args) #'(lambda (&rest args)
(apply 'cerror (apply 'cerror
"Use Unicode replacement character instead" (intl:gettext "Use Unicode replacement character instead")
args) args)
stream:+replacement-character-code+)) stream:+replacement-character-code+))
(t (t
...@@ -2199,6 +2202,17 @@ ...@@ -2199,6 +2202,17 @@
:overwrite, :append, :supersede or nil :overwrite, :append, :supersede or nil
:if-does-not-exist - one of :error, :create or nil :if-does-not-exist - one of :error, :create or nil
:external-format - an external format name :external-format - an external format name
:decoding-error - How to handle decoding errors from the external format.
Should be a symbol or function of 3 arguments. If it
returns, it should return a code point to use as the
replacment. NIL means use the default replacement scheme
specified by the external format. The function arguments
are a format message string, the offending octet, and the
number of octets read in the current encoding.
:encoding-error - Like :decoding-error, but for errors when encoding the
stream. The function arguments are a format message
string and the incorrect codepoint.
See the manual for details." See the manual for details."
(declare (ignore element-type external-format input-handle output-handle (declare (ignore element-type external-format input-handle output-handle
decoding-error encoding-error)) decoding-error encoding-error))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment