summaryrefslogtreecommitdiff
path: root/libguile/read.c
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2018-10-16 02:34:18 -0400
committerAndy Wingo <wingo@pobox.com>2019-05-23 16:41:53 +0200
commit3ae69f30632dba1677d2ed822297cf4599a8d9dd (patch)
tree4f5d8efb70eb1afeccda49f60e5dcf919d48232a /libguile/read.c
parenta47a5e6828432fb80c82ce002553f59c6447b911 (diff)
downloadguile-3ae69f30632dba1677d2ed822297cf4599a8d9dd.tar.gz
Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.
Partial fix for <https://bugs.gnu.org/33044>. Reported by Tom de Vries <tdevries@suse.de>. Fix several instances of the mistake of using 'scm_from_locale_*' for C strings that originally came from a C string literal. Change several uses of 'scm_from_latin1_*' as well, to promote the practice of writing code that works for arbitrary C string literals. Also add missing years to the copyright notices of changed files, based on the git history. * libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c, libguile/eval.c, libguile/expand.c, libguile/extensions.c, libguile/filesys.c, libguile/init.c, libguile/load.c, libguile/modules.c, libguile/pairs.c, libguile/posix.c, libguile/print.c, libguile/random.c, libguile/read.c, libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c, libguile/stacks.c, libguile/stime.c, libguile/strports.c, libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
Diffstat (limited to 'libguile/read.c')
-rw-r--r--libguile/read.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libguile/read.c b/libguile/read.c
index da21f615a..019ffff7c 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-1997,1999-2001,2003-2004,2006-2012,2014-2015,2018
+/* Copyright 1995-1997,1999-2001,2003-2004,2006-2012,2014-2019
Free Software Foundation, Inc.
This file is part of Guile.
@@ -150,21 +150,21 @@ scm_i_input_error (char const *function,
{
SCM fn = (scm_is_string (SCM_FILENAME(port))
? SCM_FILENAME(port)
- : scm_from_locale_string ("#<unknown port>"));
+ : scm_from_utf8_string ("#<unknown port>"));
SCM string_port = scm_open_output_string ();
SCM string = SCM_EOL;
scm_simple_format (string_port,
- scm_from_locale_string ("~A:~S:~S: ~A"),
+ scm_from_utf8_string ("~A:~S:~S: ~A"),
scm_list_4 (fn,
scm_sum (scm_port_line (port), SCM_INUM1),
scm_sum (scm_port_column (port), SCM_INUM1),
- scm_from_locale_string (message)));
+ scm_from_utf8_string (message)));
string = scm_get_output_string (string_port);
scm_close_output_port (string_port);
- scm_error_scm (scm_from_latin1_symbol ("read-error"),
- function? scm_from_locale_string (function) : SCM_BOOL_F,
+ scm_error_scm (scm_from_utf8_symbol ("read-error"),
+ function? scm_from_utf8_string (function) : SCM_BOOL_F,
string,
arg,
SCM_BOOL_F);
@@ -2219,7 +2219,10 @@ SCM_DEFINE (scm_file_encoding, "file-encoding", 1, 0, 0,
return SCM_BOOL_F;
else
{
- s_enc = scm_string_upcase (scm_from_locale_string (enc));
+ /* It's not obvious what encoding to use here, but latin1 has the
+ advantage of never causing a decoding error, and a valid
+ encoding name should be ASCII anyway. */
+ s_enc = scm_string_upcase (scm_from_latin1_string (enc));
return s_enc;
}