Subject: [3 PATCHES] Whitespace cleanup : Replace code-alignment tabs with spaces.
From: behoffski <[email-masked]>
To: [email-masked]
Date: Fri, 14 Mar 2014 20:33:28 +1030
List-Id: <debbugs-submit.debbugs.gnu.org>

G'day,

I've been looking at the grep sources with various tools, and have found on a
couple of occasions that tab characters (ASCII code 09, ^I) confused me where
they occurred in the code.  For example, in commit ...c73ca06859c0820d9d,
Paul Eggert had to pacify "make dist", which calls "make syntax-check", as a
line had leading tabs:

          * src/dfa.c (parse_bracket_exp): Reindent with spaces.

I've worked on other projects where consistent and concise code formatting is
stringently applied (usually as code commit hooks that run Perl scripts), and
have found this environment useful, as there is a "canonical" representation
of the source to refer to.  GNU grep has made several steps in this direction
(e.g. no leading tabs, no trailing whitespace), but the translation isn't
complete:  Tabs still appear in a few selected places in the code.

One easy way to spot tab characters in C sources (merely .c and .h files here)
is to use "cat -T", which replaces the horizontal tab character with "^I":

         for f in *.[ch] ; do
                 TMPFILE =`mktemp`
                 echo "$f" ; cat -T "$f" >"$TMPFILE" ;        \
                        diff "$f" "$TMPFILE" ; rm -f "$TMPFILE"
         done

Another way (ASCII) is to look for hex code "09" in an octal dump of a source:

         for f in *.[ch] ; do
                 echo "$f" ; od -txC "$f" | grep " 09"
         done

Attached are three small, concise patches, each changing one file in the
grep/src directory (I'm not daring to tackle gnulib at present).  These are
small, self-contained and should be fairly easy to review.  The files
modified are grep.h, kwset.h and dosbuf.c.

Please let me know if these changes are considered to be worthwhile, and,
if so, I'll submit larger patches for kwset.c, main.c and dfa.c.

cheers,

behoffski (Brenton Hoff)
Programmer, Grouse Software
From d83855f738b4084b65088724c71357dc1bd8b861 Mon Sep 17 00:00:00 2001
From: behoffski <[email-masked]>
Date: Fri, 14 Mar 2014 19:39:38 +1030
Subject: [PATCH 3/3] maint: dosbuf.c: Replace code-alignment tabs with spaces.

Tabs are already forbidden as leading character of a line, and trailing
whitespace is also not allowed.  This change is part of an effort to
tighten source layout options to improve consistency and repeatability.
---
 src/dosbuf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..c880ab6 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -35,8 +35,8 @@ typedef enum {
 } File_type;
 
 struct dos_map {
-  off_t pos;	/* position in buffer passed to matcher */
-  off_t add;	/* how much to add when reporting char position */
+  off_t pos;     /* position in buffer passed to matcher */
+  off_t add;     /* how much to add when reporting char position */
 };
 
 static int       dos_report_unix_offset = 0;
-- 
1.8.3.2

From 6dcda3e3e38ad38cfde95252d1baacb44fae30d1 Mon Sep 17 00:00:00 2001
From: behoffski <[email-masked]>
Date: Fri, 14 Mar 2014 19:38:34 +1030
Subject: [PATCH 1/3] maint: grep.h: Replace code-alignment tabs with spaces.

Tabs are already forbidden as leading character of a line, and trailing
whitespace is also not allowed.  This change is part of an effort to
tighten source layout options to improve consistency and repeatability.
---
 src/grep.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/grep.h b/src/grep.h
index 4d642a1..84844a1 100644
--- a/src/grep.h
+++ b/src/grep.h
@@ -39,9 +39,9 @@ extern const char after_options[];
 
 /* The following flags are exported from grep for the matchers
    to look at. */
-extern int match_icase;		/* -i */
-extern int match_words;		/* -w */
-extern int match_lines;		/* -x */
-extern unsigned char eolbyte;	/* -z */
+extern int match_icase;         /* -i */
+extern int match_words;         /* -w */
+extern int match_lines;         /* -x */
+extern unsigned char eolbyte;   /* -z */
 
 #endif
-- 
1.8.3.2

From a41d1a3746610a2693981cbb6bdfcf45e135beb8 Mon Sep 17 00:00:00 2001
From: behoffski <[email-masked]>
Date: Fri, 14 Mar 2014 19:39:06 +1030
Subject: [PATCH 2/3] maint: kwset.h: Replace code-alignment tabs with spaces.

Tabs are already forbidden as leading character of a line, and trailing
whitespace is also not allowed.  This change is part of an effort to
tighten source layout options to improve consistency and repeatability.
---
 src/kwset.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/kwset.h b/src/kwset.h
index 2d3cdd9..977f9f0 100644
--- a/src/kwset.h
+++ b/src/kwset.h
@@ -23,9 +23,9 @@
 
 struct kwsmatch
 {
-  size_t index;			/* Index number of matching keyword. */
-  size_t offset[1];		/* Offset of each submatch. */
-  size_t size[1];		/* Length of each submatch. */
+  size_t index;                 /* Index number of matching keyword. */
+  size_t offset[1];             /* Offset of each submatch. */
+  size_t size[1];               /* Length of each submatch. */
 };
 
 #include "arg-nonnull.h"
-- 
1.8.3.2