--- src/grep.c.~1.121.~ 2006-08-25 17:43:30.000000000 +0200 +++ src/grep.c 2007-05-15 14:13:24.000000000 +0200 @@ -789,28 +789,10 @@ print_line_middle (const char *beg, cons size_t match_offset; const char *cur = beg; const char *mid = NULL; - char *buf; /* XXX */ - const char *ibeg; /* XXX */ - - if (match_icase) /* XXX - None of the -i stuff should be here. */ - { - int i = lim - beg; - - ibeg = buf = (char *) xmalloc(i); - /* This can't possibly be correct with UTF-8, - but it's equivalent to what was there so far. */ - while (--i >= 0) - buf[i] = tolower(beg[i]); - } - else - { - buf = NULL; - ibeg = beg; - } while ( lim > cur - && ((match_offset = execute(ibeg, lim - beg, &match_size, - ibeg + (cur - beg))) != (size_t) -1)) + && ((match_offset = execute(beg, lim - beg, &match_size, + beg + (cur - beg))) != (size_t) -1)) { char const *b = beg + match_offset; @@ -854,9 +836,6 @@ print_line_middle (const char *beg, cons cur = b + match_size; } - if (buf) - free(buf); /* XXX */ - if (only_matching) cur = lim; else if (mid) --- src/search.c.~1.40.~ 2005-12-12 16:26:59.000000000 +0100 +++ src/search.c 2007-05-15 14:49:38.000000000 +0200 @@ -192,11 +192,18 @@ GEAcompile (char const *pattern, size_t const char *sep; size_t total = size; char const *motif = pattern; + static char translate[NCHAR]; -#if 0 - if (match_icase) - syntax_bits |= RE_ICASE; + if (match_icase +#ifdef MBS_SUPPORT + && MB_CUR_MAX == 1) #endif + { + int i; + for (i = 0; i < NCHAR; i++) + translate[i] = ISUPPER (i) ? TOLOWER (i) : i; + } + re_set_syntax (syntax_bits); dfasyntax (syntax_bits, match_icase, eolbyte); @@ -224,6 +231,11 @@ GEAcompile (char const *pattern, size_t if (patterns == NULL) error (2, errno, _("memory exhausted")); patterns[pcount] = patterns0; + if (match_icase +#ifdef MBS_SUPPORT + && MB_CUR_MAX == 1) +#endif + patterns[pcount].regexbuf.translate = translate; if ((err = re_compile_pattern (motif, len, &(patterns[pcount].regexbuf))) != 0)