[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: whitespace cleanup
From: |
Jim Meyering |
Subject: |
Re: whitespace cleanup |
Date: |
Tue, 17 Oct 2006 09:53:28 +0200 |
address@hidden (Karl Berry) wrote:
> Personally, I fail to see the problem with trailing whitespace. If no
> one ever checked for it, it would (basically) never cause a problem. So
> why do people check for it? I've never understood this, even though you
> and Jim and others seem to be religious about it, and usually I'm
> totally on board with whatever you guys do :). It just seems like a
> waste of time to me to even think about it. Ever.
Hi Karl,
Over the years, my tolerance for trailing white space has
gone to zero. I've spent too much time diagnosing problems
that could have been so easily avoided.
There are lots of reasons to remove trailing blanks, and even
some to normalize non-trailing white space, SP-TAB vs. TAB-SP.
Here are a few:
- trailing blanks can change the semantics of your code
- these differences can lead to unnecessary merge conflicts
- some people use editors that automatically convert / +\t/
sequences to just TABs (this is relevant not just for leading
indentation, but also for e.g., regular expressions, where
it's easy to write a e.g. "[ ]" (space-TAB) as part of a
grep or sed pattern. Of course, if you're using a modern
enough tool, you can avoid the problem by using "\t". This
is why it is better to write the above as "[ ]" (TAB-space).
- some packages (coreutils :-) have a "make distcheck" rule that will
fail if it finds any such offending sequence in its sources.
Two things you can do:
- make your editors (emacs and/or vi) highlight trailing white space
- add a commit hook to prohibit any check-in that adds trailing white space
I do both, with a vengeance :-)
Jim