summaryrefslogtreecommitdiff
path: root/libguile/strings.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-02-02 17:38:03 +0100
committerLudovic Courtès <ludo@gnu.org>2011-02-02 18:06:29 +0100
commit6851d3be80bef46993e192b0f4ea708248f97921 (patch)
treed941bdb5be27848c5b1366e66ad688d1eedb6833 /libguile/strings.c
parent7174bc08ddd6cc64f2ea321910042cf2233d586a (diff)
downloadguile-6851d3be80bef46993e192b0f4ea708248f97921.tar.gz
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.
Diffstat (limited to 'libguile/strings.c')
-rw-r--r--libguile/strings.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/libguile/strings.c b/libguile/strings.c
index 7a580609e..b13cb780f 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1412,21 +1412,17 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
SCM_SYMBOL (scm_encoding_error_key, "encoding-error");
SCM_SYMBOL (scm_decoding_error_key, "decoding-error");
+/* Raise an exception informing that character CHR could not be written
+ to PORT in its current encoding. */
void
scm_encoding_error (const char *subr, int err, const char *message,
- const char *from, const char *to, SCM string_or_bv)
+ SCM port, SCM chr)
{
- /* Raise an exception that conveys all the information needed to debug the
- problem. Only perform locale conversions that are safe; in particular,
- don't try to display STRING_OR_BV when it's a string since converting it to
- the output locale may fail. */
scm_throw (scm_encoding_error_key,
scm_list_n (scm_from_locale_string (subr),
scm_from_locale_string (message),
scm_from_int (err),
- scm_from_locale_string (from),
- scm_from_locale_string (to),
- string_or_bv,
+ port, chr,
SCM_UNDEFINED));
}
@@ -1938,8 +1934,10 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
if (ret != 0)
scm_encoding_error (__func__, errno,
- "cannot convert to output locale",
- "ISO-8859-1", enc, str);
+ "cannot convert narrow string to output locale",
+ SCM_BOOL_F,
+ /* FIXME: Faulty character unknown. */
+ SCM_BOOL_F);
}
else
{
@@ -1951,8 +1949,10 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
NULL, &len);
if (buf == NULL)
scm_encoding_error (__func__, errno,
- "cannot convert to output locale",
- "UTF-32", enc, str);
+ "cannot convert wide string to output locale",
+ SCM_BOOL_F,
+ /* FIXME: Faulty character unknown. */
+ SCM_BOOL_F);
}
if (handler == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE)
{