Subject: bug#16581: closed (Re: suggested code simplification in dfa.c)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 08 Mar 2014 18:17:02 +0000

Your bug report

#16581: suggested code simplification in dfa.c

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
16581: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16581
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: suggested code simplification in dfa.c
From: Paul Eggert <[email-masked]>
To: [email-masked]
Date: Sat, 08 Mar 2014 10:16:45 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

This particular issue seems to have been put to bed in the savannah git 
master so I'm marking it as done.

Subject: suggested code simplification in dfa.c
From: Aharon Robbins <[email-masked]>
To: [email-masked]
Date: Tue, 28 Jan 2014 22:11:14 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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 ();