mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 07:30:32 +02:00
fix scm_to_latin1_stringn for substrings
* libguile/strings.c (scm_to_latin1_stringn): Fix for substrings. * test-suite/standalone/Makefile.am: * test-suite/standalone/test-scm-to-latin1-string.c: Add test case. Thanks to David Hansen for the bug report and test case, and Stefan Israelsson Tampe for the fix.
This commit is contained in:
parent
cb7bcfca35
commit
fe13364050
3 changed files with 91 additions and 4 deletions
|
@ -1779,14 +1779,16 @@ scm_to_latin1_stringn (SCM str, size_t *lenp)
|
|||
|
||||
if (scm_i_is_narrow_string (str))
|
||||
{
|
||||
if (lenp)
|
||||
*lenp = scm_i_string_length (str);
|
||||
size_t len = scm_i_string_length (str);
|
||||
|
||||
result = scm_strdup (scm_i_string_data (str));
|
||||
if (lenp)
|
||||
*lenp = len;
|
||||
|
||||
result = scm_strndup (scm_i_string_data (str), len);
|
||||
}
|
||||
else
|
||||
result = scm_to_stringn (str, lenp, NULL,
|
||||
SCM_FAILED_CONVERSION_ERROR);
|
||||
SCM_FAILED_CONVERSION_ERROR);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue