I propose to make this change now, in spite of the fact that there are bug fixes in the pipe. If anyone knows of a reason to keep this code, please demonstrate how removing it causes trouble.
This commit is intended to induce no semantic change. (other than the improvement of eliminating an unnecessary xmalloc) >From af297dbf8661cd41549c9f4527abbfe834c41881 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Thu, 25 Mar 2010 08:28:28 +0100 Subject: [PATCH] grep: remove unnecessary code * src/main.c (print_line_middle): Now that we use RE_ICASE (enabled in commit 70e23616, "dfa: rewrite handling of multibyte case_fold lexing"), this case-conversion code is useless and wasteful. Remove it. --- src/main.c | 30 +++--------------------------- 1 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/main.c b/src/main.c index e5bf50f..4fedc32 100644 --- a/src/main.c +++ b/src/main.c @@ -724,32 +724,10 @@ print_line_middle (const char *beg, const char *lim, size_t match_offset; const char *cur = beg; const char *mid = NULL; - char *buf; - const char *ibeg; - /* XXX - should not be needed anymore now that we use RE_ICASE. - Revisit after 2.6.x stabilizes. */ - if (match_icase -#ifdef MBS_SUPPORT - && MB_CUR_MAX == 1 -#endif - ) - { - int i = lim - beg; - - ibeg = buf = xmalloc(i); - while (--i >= 0) - buf[i] = tolower((unsigned char) beg[i]); - } - else - { - buf = NULL; - ibeg = beg; - } - - while ( lim > cur - && ((match_offset = execute(ibeg, lim - beg, &match_size, - ibeg + (cur - beg))) != (size_t) -1)) + while (cur < lim + && ((match_offset = execute(beg, lim - beg, &match_size, + beg + (cur - beg))) != (size_t) -1)) { char const *b = beg + match_offset; @@ -793,8 +771,6 @@ print_line_middle (const char *beg, const char *lim, cur = b + match_size; } - free (buf); /* XXX */ - if (only_matching) cur = lim; else if (mid) -- 1.7.0.3.448.g82eeb
