mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
scm_to_stringn: Avoid passing NULL to c_strcasecmp.
Reported by Massimiliano Gubinelli <m.gubinelli@gmail.com> in <https://lists.gnu.org/archive/html/guile-user/2019-05/msg00070.html>. * libguile/strings.c (scm_to_stringn): Check for (encoding == NULL) before passing it to 'c_strcasecmp'. Eliminate redundant 'enc' variable.
This commit is contained in:
parent
75f3ba7759
commit
a23ee74fab
1 changed files with 5 additions and 6 deletions
|
@ -2190,11 +2190,13 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
|
|||
char *buf;
|
||||
size_t ilen, len, i;
|
||||
int ret;
|
||||
const char *enc;
|
||||
|
||||
if (!scm_is_string (str))
|
||||
scm_wrong_type_arg_msg (NULL, 0, str, "string");
|
||||
|
||||
if (encoding == NULL)
|
||||
encoding = "ISO-8859-1";
|
||||
|
||||
if (c_strcasecmp (encoding, "UTF-8") == 0)
|
||||
/* This is the most common case--e.g., when calling libc bindings
|
||||
while using a UTF-8 locale. */
|
||||
|
@ -2242,13 +2244,10 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
|
|||
|
||||
buf = NULL;
|
||||
len = 0;
|
||||
enc = encoding;
|
||||
if (enc == NULL)
|
||||
enc = "ISO-8859-1";
|
||||
if (scm_i_is_narrow_string (str))
|
||||
{
|
||||
ret = mem_iconveh (scm_i_string_chars (str), ilen,
|
||||
"ISO-8859-1", enc,
|
||||
"ISO-8859-1", encoding,
|
||||
(enum iconv_ilseq_handler) handler, NULL,
|
||||
&buf, &len);
|
||||
|
||||
|
@ -2261,7 +2260,7 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
|
|||
}
|
||||
else
|
||||
{
|
||||
buf = u32_conv_to_encoding (enc,
|
||||
buf = u32_conv_to_encoding (encoding,
|
||||
(enum iconv_ilseq_handler) handler,
|
||||
(scm_t_uint32 *) scm_i_string_wide_chars (str),
|
||||
ilen,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue