2802 |
"Split the string @var{s} into a list of substrings, where each\n" |
"Split the string @var{s} into a list of substrings, where each\n" |
2803 |
"substring is a maximal non-empty contiguous sequence of\n" |
"substring is a maximal non-empty contiguous sequence of\n" |
2804 |
"characters from the character set @var{token_set}, which\n" |
"characters from the character set @var{token_set}, which\n" |
2805 |
"defaults to an equivalent of @code{char-set:graphic}.\n" |
"defaults to @code{char-set:graphic} from module (srfi srfi-14).\n" |
2806 |
"If @var{start} or @var{end} indices are provided, they restrict\n" |
"If @var{start} or @var{end} indices are provided, they restrict\n" |
2807 |
"@code{string-tokenize} to operating on the indicated substring\n" |
"@code{string-tokenize} to operating on the indicated substring\n" |
2808 |
"of @var{s}.") |
"of @var{s}.") |
2812 |
int cstart, cend; |
int cstart, cend; |
2813 |
SCM result = SCM_EOL; |
SCM result = SCM_EOL; |
2814 |
|
|
2815 |
|
static SCM charset_graphic = SCM_BOOL_F; |
2816 |
|
|
2817 |
SCM_VALIDATE_SUBSTRING_SPEC_COPY (1, s, cstr, |
SCM_VALIDATE_SUBSTRING_SPEC_COPY (1, s, cstr, |
2818 |
3, start, cstart, |
3, start, cstart, |
2819 |
4, end, cend); |
4, end, cend); |
2820 |
|
|
2821 |
if (SCM_UNBNDP (token_set)) |
if (SCM_UNBNDP (token_set)) |
2822 |
{ |
{ |
2823 |
int idx; |
if (charset_graphic == SCM_BOOL_F) |
|
|
|
|
while (cstart < cend) |
|
2824 |
{ |
{ |
2825 |
while (cstart < cend) |
SCM srfi_14_module = scm_c_resolve_module ("srfi srfi-14"); |
2826 |
{ |
SCM charset_graphic_var = scm_c_module_lookup (srfi_14_module, |
2827 |
if (isgraph (cstr[cend - 1])) |
"char-set:graphic"); |
2828 |
break; |
charset_graphic = |
2829 |
cend--; |
scm_permanent_object (SCM_VARIABLE_REF (charset_graphic_var)); |
|
} |
|
|
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); |
|
2830 |
} |
} |
2831 |
|
token_set = charset_graphic; |
2832 |
} |
} |
2833 |
else if (SCM_CHARSETP (token_set)) |
|
2834 |
|
if (SCM_CHARSETP (token_set)) |
2835 |
{ |
{ |
2836 |
int idx; |
int idx; |
2837 |
|
|