82 lines
2.0 KiB
Diff
82 lines
2.0 KiB
Diff
--- src/grep.c
|
|
+++ src/grep.c
|
|
@@ -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
|
|
+++ src/search.c
|
|
@@ -192,11 +192,19 @@ 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 +232,12 @@ 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)
|