/[grep]/grep/src/search.c
ViewVC logotype

Diff of /grep/src/search.c

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

revision 1.27 by kasal, Sun Sep 26 20:53:50 2004 UTC revision 1.28 by kasal, Fri Nov 19 16:48:15 2004 UTC
# Line 149  kwsmusts (void) Line 149  kwsmusts (void)
149  static char*  static char*
150  check_multibyte_string(char const *buf, size_t size)  check_multibyte_string(char const *buf, size_t size)
151  {  {
   static char const *precalc_buf = NULL;  
   static size_t precalc_size = 0;  
   static char *precalc_mb_properties = NULL;  
152    char *mb_properties = xmalloc(size);    char *mb_properties = xmalloc(size);
153    mbstate_t cur_state;    mbstate_t cur_state;
154    int i;    int i;
155    
   if (!size ||  
       buf >= precalc_buf && (buf + size) <= (precalc_buf + precalc_size))  
     {  
       memcpy(mb_properties, precalc_mb_properties + (buf - precalc_buf), size);  
       return mb_properties;  
     }  
   
   precalc_mb_properties = xrealloc(precalc_mb_properties, size);  
   precalc_buf = buf;  
   precalc_size = size;  
156    memset(&cur_state, 0, sizeof(mbstate_t));    memset(&cur_state, 0, sizeof(mbstate_t));
157    memset(mb_properties, 0, sizeof(char)*size);    memset(mb_properties, 0, sizeof(char)*size);
158    for (i = 0; i < size ;)    for (i = 0; i < size ;)
# Line 183  check_multibyte_string(char const *buf, Line 170  check_multibyte_string(char const *buf,
170        i += mbclen;        i += mbclen;
171      }      }
172    
   memcpy(precalc_mb_properties, mb_properties, size);  
173    return mb_properties;    return mb_properties;
174  }  }
175  #endif  #endif

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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