GNU bug report logs -
#17012
[3 PATCHES] Whitespace cleanup : Replace code-alignment tabs with spaces.
Previous Next
Reported by: behoffski <behoffski <at> grouse.com.au>
Date: Fri, 14 Mar 2014 10:04:01 UTC
Severity: normal
Tags: notabug, patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
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
[maint-dosbuf.c-tabs-spaces.patch (text/x-patch, attachment)]
[maint-grep.h-tabs-spaces.patch (text/x-patch, attachment)]
[maint-kwset.h-tabs-spaces.patch (text/x-patch, attachment)]
This bug report was last modified 11 years and 52 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.