/[guile]/guile/guile-core/srfi/srfi-13.c
ViewVC logotype

Diff of /guile/guile-core/srfi/srfi-13.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by mvo, Fri Apr 26 18:34:21 2002 UTC revision 1.18 by mvo, Mon May 6 18:44:02 2002 UTC
# Line 2802  SCM_DEFINE (scm_string_tokenize, "string Line 2802  SCM_DEFINE (scm_string_tokenize, "string
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}.")
# Line 2812  SCM_DEFINE (scm_string_tokenize, "string Line 2812  SCM_DEFINE (scm_string_tokenize, "string
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    

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26