bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16581: suggested code simplification in dfa.c


From: Aharon Robbins
Subject: bug#16581: suggested code simplification in dfa.c
Date: Tue, 28 Jan 2014 22:11:14 +0200
User-agent: Heirloom mailx 12.5 6/20/10

Hi.

The code in atom() looks to me like it could use a little refactoring
and simplification. I suggest the diff below. With it both grep and gawk
still pass their tests.

Thanks,

Arnold

diff --git a/src/dfa.c b/src/dfa.c
index b79c604..d2916ee 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1725,17 +1725,20 @@ add_utf8_anychar (void)
 static void
 atom (void)
 {
-  if (0)
+  if (MBS_SUPPORT && tok == WCHAR)
     {
-      /* empty */
-    }
-  else if (MBS_SUPPORT && tok == WCHAR)
-    {
-      addtok_wc (case_fold ? towlower (wctok) : wctok);
-      if (case_fold && iswalpha (wctok))
+      if (! case_fold)
+        {
+          addtok_wc (wctok);
+        }
+      else
         {
-          addtok_wc (towupper (wctok));
-          addtok (OR);
+          addtok_wc (towlower (wctok));
+          if (iswalpha (wctok))
+         {
+                addtok_wc (towupper (wctok));
+                addtok (OR);
+         }
         }
 
       tok = lex ();





reply via email to

[Prev in Thread] Current Thread [Next in Thread]