bug-grep
[Top][All Lists]
Advanced

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

bug#17012: [3 PATCHES] Whitespace cleanup : Replace code-alignment tabs


From: behoffski
Subject: bug#17012: [3 PATCHES] Whitespace cleanup : Replace code-alignment tabs with spaces.
Date: Fri, 14 Mar 2014 20:33:28 +1030
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

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

Attachment: maint-dosbuf.c-tabs-spaces.patch
Description: Text Data

Attachment: maint-grep.h-tabs-spaces.patch
Description: Text Data

Attachment: maint-kwset.h-tabs-spaces.patch
Description: Text Data


reply via email to

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