mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 23:50:19 +02:00
(scm_string_tokenize): Instead of using "isgraphic" as the subtitute
for char-set:graphic when then token-set hsa been defaulted, grab the real char-set:graphic from (srfi srfi-14).
This commit is contained in:
parent
139e5cb2fb
commit
c8519a82f2
1 changed files with 13 additions and 21 deletions
|
@ -2802,7 +2802,7 @@ SCM_DEFINE (scm_string_tokenize, "string-tokenize", 1, 3, 0,
|
|||
"Split the string @var{s} into a list of substrings, where each\n"
|
||||
"substring is a maximal non-empty contiguous sequence of\n"
|
||||
"characters from the character set @var{token_set}, which\n"
|
||||
"defaults to an equivalent of @code{char-set:graphic}.\n"
|
||||
"defaults to @code{char-set:graphic} from module (srfi srfi-14).\n"
|
||||
"If @var{start} or @var{end} indices are provided, they restrict\n"
|
||||
"@code{string-tokenize} to operating on the indicated substring\n"
|
||||
"of @var{s}.")
|
||||
|
@ -2812,34 +2812,26 @@ SCM_DEFINE (scm_string_tokenize, "string-tokenize", 1, 3, 0,
|
|||
int cstart, cend;
|
||||
SCM result = SCM_EOL;
|
||||
|
||||
static SCM charset_graphic = SCM_BOOL_F;
|
||||
|
||||
SCM_VALIDATE_SUBSTRING_SPEC_COPY (1, s, cstr,
|
||||
3, start, cstart,
|
||||
4, end, cend);
|
||||
|
||||
if (SCM_UNBNDP (token_set))
|
||||
{
|
||||
int idx;
|
||||
if (charset_graphic == SCM_BOOL_F)
|
||||
{
|
||||
SCM srfi_14_module = scm_c_resolve_module ("srfi srfi-14");
|
||||
SCM charset_graphic_var = scm_c_module_lookup (srfi_14_module,
|
||||
"char-set:graphic");
|
||||
charset_graphic =
|
||||
scm_permanent_object (SCM_VARIABLE_REF (charset_graphic_var));
|
||||
}
|
||||
token_set = charset_graphic;
|
||||
}
|
||||
|
||||
while (cstart < cend)
|
||||
{
|
||||
while (cstart < cend)
|
||||
{
|
||||
if (isgraph (cstr[cend - 1]))
|
||||
break;
|
||||
cend--;
|
||||
}
|
||||
if (cstart >= cend)
|
||||
break;
|
||||
idx = cend;
|
||||
while (cstart < cend)
|
||||
{
|
||||
if (!isgraph (cstr[cend - 1]))
|
||||
break;
|
||||
cend--;
|
||||
}
|
||||
result = scm_cons (scm_mem2string (cstr + cend, idx - cend), result);
|
||||
}
|
||||
}
|
||||
else if (SCM_CHARSETP (token_set))
|
||||
if (SCM_CHARSETP (token_set))
|
||||
{
|
||||
int idx;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue