diff options
author | Marius Vollmer <mvo@zagadka.de> | 2002-05-06 18:44:02 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2002-05-06 18:44:02 +0000 |
commit | c8519a82f2743f5dce0f019f8aa3290d311722f5 (patch) | |
tree | bb15be376c7b76a8382fdce5a10766a95bca7370 /srfi/srfi-13.c | |
parent | 139e5cb2fb65ef64e6abdb8b7d80265940fb33f9 (diff) | |
download | guile-c8519a82f2743f5dce0f019f8aa3290d311722f5.tar.gz |
(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).
Diffstat (limited to 'srfi/srfi-13.c')
-rw-r--r-- | srfi/srfi-13.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/srfi/srfi-13.c b/srfi/srfi-13.c index 0c4c3e91d..8b9f4933c 100644 --- a/srfi/srfi-13.c +++ b/srfi/srfi-13.c @@ -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; - - while (cstart < cend) + if (charset_graphic == SCM_BOOL_F) { - 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); + 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; } - else if (SCM_CHARSETP (token_set)) + + if (SCM_CHARSETP (token_set)) { int idx; |