Change `scm_encoding_error' to pass the port and faulty character.
* libguile/strings.c (scm_encoding_error): Remove the `from', `to', and
`string_or_bv' parameters; add `port' and `chr'.
(scm_to_stringn): Update accordingly.
* libguile/strings.h (scm_encoding_error): Update accordingly.
* libguile/ports.c (scm_ungetc): Update accordingly.
* libguile/print.c (iprin1, scm_write_char): Update accordingly.
* test-suite/tests/encoding-escapes.test ("display output
errors")["ultima", "Rashomon"]: Check the arguments of
`encoding-error'.
["tekniko"]: New test.
* test-suite/tests/ports.test ("string ports")["wrong encoding"]: Adjust
to new `encoding-error' arguments.
This commit is contained in:
parent
7174bc08dd
commit
6851d3be80
6 changed files with 59 additions and 47 deletions
|
|
@ -67,19 +67,45 @@
|
|||
|
||||
(with-test-prefix "display output errors"
|
||||
|
||||
(pass-if-exception "ultima"
|
||||
exception:encoding-error
|
||||
(let ((pt (open-output-string)))
|
||||
(set-port-encoding! pt "ASCII")
|
||||
(set-port-conversion-strategy! pt 'error)
|
||||
(display s1 pt)))
|
||||
(pass-if "ultima"
|
||||
(let ((pt (open-output-string)))
|
||||
(set-port-encoding! pt "ASCII")
|
||||
(set-port-conversion-strategy! pt 'error)
|
||||
(catch 'encoding-error
|
||||
(lambda ()
|
||||
(display s1 pt)
|
||||
#f)
|
||||
(lambda (key subr message errno port chr)
|
||||
(and (eq? port pt)
|
||||
(char=? chr (string-ref s1 0))
|
||||
(string=? (get-output-string pt) ""))))))
|
||||
|
||||
(pass-if-exception "Rashomon"
|
||||
exception:encoding-error
|
||||
(let ((pt (open-output-string)))
|
||||
(set-port-encoding! pt "ASCII")
|
||||
(set-port-conversion-strategy! pt 'error)
|
||||
(display s4 pt))))
|
||||
(pass-if "Rashomon"
|
||||
(let ((pt (open-output-string)))
|
||||
(set-port-encoding! pt "ASCII")
|
||||
(set-port-conversion-strategy! pt 'error)
|
||||
(catch 'encoding-error
|
||||
(lambda ()
|
||||
(display s4 pt)
|
||||
#f)
|
||||
(lambda (key subr message errno port chr)
|
||||
(and (eq? port pt)
|
||||
(char=? chr (string-ref s4 0))
|
||||
(string=? (get-output-string pt) ""))))))
|
||||
|
||||
(pass-if "tekniko"
|
||||
(let ((pt (open-output-string)))
|
||||
(set-port-encoding! pt "ASCII")
|
||||
(set-port-conversion-strategy! pt 'error)
|
||||
(catch 'encoding-error
|
||||
(lambda ()
|
||||
;; This time encoding should fail on the 3rd character.
|
||||
(display "teĥniko" pt)
|
||||
#f)
|
||||
(lambda (key subr message errno port chr)
|
||||
(and (eq? port pt)
|
||||
(char=? chr #\ĥ)
|
||||
(string=? "te" (get-output-string pt))))))))
|
||||
|
||||
;; Check that questions marks or substitutions appear when the conversion
|
||||
;; mode is substitute
|
||||
|
|
|
|||
|
|
@ -420,10 +420,8 @@
|
|||
(with-output-to-string
|
||||
(lambda ()
|
||||
(display str)))))
|
||||
(lambda (key subr message errno from to faulty-str)
|
||||
(and (eq? faulty-str str)
|
||||
(string=? from "UTF-32")
|
||||
(string=? to "ISO-8859-1")
|
||||
(lambda (key subr message errno port chr)
|
||||
(and (eq? chr #\ĉ)
|
||||
(string? (strerror errno)))))))
|
||||
|
||||
(pass-if "wrong encoding, substitute"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue