summaryrefslogtreecommitdiff
path: root/libguile/load.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/load.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/load.c')
-rw-r--r--libguile/load.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/libguile/load.c b/libguile/load.c
index f6ad92de8..e95c36db1 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-1996,1998-2001,2004,2006,2008-2014,2017-2018
+/* Copyright 1995-1996,1998-2001,2004,2006,2008-2019
Free Software Foundation, Inc.
This file is part of Guile.
@@ -154,7 +154,7 @@ SCM_DEFINE (scm_sys_package_data_dir, "%package-data-dir", 0, 0, 0,
"@samp{/usr/local/share/guile}.")
#define FUNC_NAME s_scm_sys_package_data_dir
{
- return scm_from_locale_string (SCM_PKGDATA_DIR);
+ return scm_from_utf8_string (SCM_PKGDATA_DIR);
}
#undef FUNC_NAME
#endif /* SCM_PKGDATA_DIR */
@@ -166,7 +166,7 @@ SCM_DEFINE (scm_sys_library_dir, "%library-dir", 0,0,0,
"E.g., may return \"/usr/share/guile/1.3.5\".")
#define FUNC_NAME s_scm_sys_library_dir
{
- return scm_from_locale_string (SCM_LIBRARY_DIR);
+ return scm_from_utf8_string (SCM_LIBRARY_DIR);
}
#undef FUNC_NAME
#endif /* SCM_LIBRARY_DIR */
@@ -192,7 +192,7 @@ SCM_DEFINE (scm_sys_global_site_dir, "%global-site-dir", 0,0,0,
"E.g., may return \"/usr/share/guile/site\".")
#define FUNC_NAME s_scm_sys_global_site_dir
{
- return scm_from_locale_string (SCM_GLOBAL_SITE_DIR);
+ return scm_from_utf8_string (SCM_GLOBAL_SITE_DIR);
}
#undef FUNC_NAME
#endif /* SCM_GLOBAL_SITE_DIR */
@@ -205,7 +205,7 @@ SCM_DEFINE (scm_sys_site_ccache_dir, "%site-ccache-dir", 0,0,0,
"E.g., may return \"/usr/lib/guile/" SCM_EFFECTIVE_VERSION "/site-ccache\".")
#define FUNC_NAME s_scm_sys_site_ccache_dir
{
- return scm_from_locale_string (SCM_SITE_CCACHE_DIR);
+ return scm_from_utf8_string (SCM_SITE_CCACHE_DIR);
}
#undef FUNC_NAME
#endif /* SCM_SITE_CCACHE_DIR */
@@ -310,6 +310,9 @@ scm_i_mirror_backslashes (char *path)
while (*p)
{
+ /* FIXME: When the locale encoding is Shift_JIS, backslash '\'
+ has a multibyte representation, so this code will
+ misbehave. */
if (*p == '\\')
*p = '/';
p++;
@@ -339,10 +342,10 @@ scm_init_load_path ()
else if (env)
path = scm_parse_path (scm_from_locale_string (env), path);
else
- path = scm_list_4 (scm_from_locale_string (SCM_LIBRARY_DIR),
- scm_from_locale_string (SCM_SITE_DIR),
- scm_from_locale_string (SCM_GLOBAL_SITE_DIR),
- scm_from_locale_string (SCM_PKGDATA_DIR));
+ path = scm_list_4 (scm_from_utf8_string (SCM_LIBRARY_DIR),
+ scm_from_utf8_string (SCM_SITE_DIR),
+ scm_from_utf8_string (SCM_GLOBAL_SITE_DIR),
+ scm_from_utf8_string (SCM_PKGDATA_DIR));
env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH"));
if (env && strcmp (env, "") == 0)
@@ -352,8 +355,8 @@ scm_init_load_path ()
cpath = scm_parse_path (scm_from_locale_string (env), cpath);
else
{
- cpath = scm_list_2 (scm_from_locale_string (SCM_CCACHE_DIR),
- scm_from_locale_string (SCM_SITE_CCACHE_DIR));
+ cpath = scm_list_2 (scm_from_utf8_string (SCM_CCACHE_DIR),
+ scm_from_utf8_string (SCM_SITE_CCACHE_DIR));
}
#endif /* SCM_LIBRARY_DIR */
@@ -954,7 +957,7 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
{
require_exts = SCM_CADR (rest);
if (SCM_UNLIKELY (!scm_is_null (SCM_CDDR (rest))))
- scm_wrong_num_args (scm_from_locale_string (FUNC_NAME));
+ scm_wrong_num_args (scm_from_utf8_string (FUNC_NAME));
}
}
else
@@ -1280,10 +1283,10 @@ scm_init_eval_in_scheme (void)
int found_stale_eval_go = 0;
eval_scm = search_path (*scm_loc_load_path,
- scm_from_locale_string ("ice-9/eval.scm"),
+ scm_from_utf8_string ("ice-9/eval.scm"),
SCM_EOL, SCM_BOOL_F, &stat_source);
eval_thunk =
- load_thunk_from_path (scm_from_locale_string ("ice-9/eval.go"),
+ load_thunk_from_path (scm_from_utf8_string ("ice-9/eval.go"),
eval_scm, &stat_source, &found_stale_eval_go);
if (scm_is_true (eval_thunk))
@@ -1341,13 +1344,13 @@ scm_init_load ()
scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL));
scm_loc_load_extensions
= SCM_VARIABLE_LOC (scm_c_define ("%load-extensions",
- scm_list_2 (scm_from_locale_string (".scm"),
+ scm_list_2 (scm_from_utf8_string (".scm"),
scm_nullstr)));
scm_loc_load_compiled_path
= SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-path", SCM_EOL));
scm_loc_load_compiled_extensions
= SCM_VARIABLE_LOC (scm_c_define ("%load-compiled-extensions",
- scm_list_1 (scm_from_locale_string (".go"))));
+ scm_list_1 (scm_from_utf8_string (".go"))));
scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F));
scm_loc_compile_fallback_path