On Fri, 9 Oct 2020 12:53:47 +0300
Shlomi Fish <shlo...@shlomifish.org> wrote:

> Hi Norihiro Tanaka!
> 
> On Thu, 08 Oct 2020 18:55:50 +0900
> Norihiro Tanaka <nori...@kcn.ne.jp> wrote:

Thanks, not 'unusable' but 'unused' is right.
From 4d91494963ab1645417682af548d162021607f40 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <nori...@kcn.ne.jp>
Date: Thu, 8 Oct 2020 18:46:32 +0900
Subject: [PATCH] grep: remove unused code

* src/kwsearch.c (Fcompile, Fexecute): Remove unused code.  No longer these
are used after commit 016e590a8198009bce0e1078f6d4c7e037e2df3c.
---
 src/kwsearch.c |   47 -----------------------------------------------
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/src/kwsearch.c b/src/kwsearch.c
index 1174dbc..1b31917 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -89,38 +89,6 @@ Fcompile (char *pattern, size_t size, reg_syntax_t ignored, 
bool exact)
   free (buf);
   ptrdiff_t words = kwswords (kwset);
 
-  if (match_icase)
-    {
-      /* For each pattern character C that has a case folded
-         counterpart F that is multibyte and so cannot easily be
-         implemented via translating a single byte, append a pattern
-         containing just F.  That way, if the data contains F, the
-         matcher can fall back on DFA.  For example, if C is 'i' and
-         the locale is en_US.utf8, append a pattern containing just
-         the character U+0131 (LATIN SMALL LETTER DOTLESS I), so that
-         Fexecute will use a DFA if the data contain U+0131.  */
-      mbstate_t mbs = { 0 };
-      char checked[NCHAR] = {0,};
-      for (p = pattern; p < pattern + size; p++)
-        {
-          unsigned char c = *p;
-          if (checked[c])
-            continue;
-          checked[c] = true;
-
-          wint_t wc = localeinfo.sbctowc[c];
-          wchar_t folded[CASE_FOLDED_BUFSIZE];
-
-          for (int i = case_folded_counterparts (wc, folded); 0 <= --i; )
-            {
-              char s[MB_LEN_MAX];
-              int nbytes = wcrtomb (s, folded[i], &mbs);
-              if (1 < nbytes)
-                kwsincr (kwset, s, nbytes);
-            }
-        }
-    }
-
   kwsprep (kwset);
 
   struct kwsearch *kwsearch = xmalloc (sizeof *kwsearch);
@@ -168,21 +136,6 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t 
*match_size,
         break;
       len = kwsmatch.size[0] - 2 * match_lines;
 
-      if (kwsearch->words <= kwsmatch.index)
-        {
-          /* The data contain a multibyte character that matches
-             some pattern character that is a case folded counterpart.
-             Since the kwset code cannot handle this case, fall back
-             on the DFA code, which can.  */
-          if (! kwsearch->re)
-            {
-              fgrep_to_grep_pattern (&kwsearch->pattern, &kwsearch->size);
-              kwsearch->re = GEAcompile (kwsearch->pattern, kwsearch->size,
-                                         RE_SYNTAX_GREP, !!start_ptr);
-            }
-          return EGexecute (kwsearch->re, buf, size, match_size, start_ptr);
-        }
-
       mbclen = 0;
       if (mb_check
           && mb_goback (&mb_start, &mbclen, beg + offset, buf + size) != 0)
-- 
1.7.1

Reply via email to