aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-02-06 18:52:40 +0000
committerEd Schouten <ed@FreeBSD.org>2012-02-06 18:52:40 +0000
commite048cf369a76e64ed7219111404be032da5d93c6 (patch)
tree87fbe13105ffffd123f6aacfc9178fd69f863912 /tools
parentcd864a19a5ff7bae959028e95b0e53eb1fa7c6b7 (diff)
downloadsrc-e048cf369a76e64ed7219111404be032da5d93c6.tar.gz
src-e048cf369a76e64ed7219111404be032da5d93c6.zip
Add a `fix' for another whitespace bug.
If the sentence starts with a multiple of eight spaces, the sentence should in almost all practical cases have started with tabs instead. Replace these spaces by tabs.
Notes
Notes: svn path=/head/; revision=231098
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/fixwhite/fixwhite.12
-rw-r--r--tools/tools/fixwhite/fixwhite.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/tools/fixwhite/fixwhite.1 b/tools/tools/fixwhite/fixwhite.1
index 852a390261ed..ccf5ecec03dc 100644
--- a/tools/tools/fixwhite/fixwhite.1
+++ b/tools/tools/fixwhite/fixwhite.1
@@ -41,6 +41,8 @@ and prints the result to standard output.
It removes leading and trailing empty lines from the input, as well as
trailing whitespace characters from ever line of text.
Multiple successive empty lines are merged together.
+If the whitespace at the beginning of a sentence is exactly a multiple
+of eight spaces, the whitespace is replaced by tabs.
Also, spaces preceeding tabs will be merged into the tab character.
.Sh AUTHORS
.An Ed Schouten Aq ed@FreeBSD.org
diff --git a/tools/tools/fixwhite/fixwhite.c b/tools/tools/fixwhite/fixwhite.c
index 276ae2e6fb41..903a5a355651 100644
--- a/tools/tools/fixwhite/fixwhite.c
+++ b/tools/tools/fixwhite/fixwhite.c
@@ -110,6 +110,19 @@ savewhite(char c, bool leading)
static void
printwhite(void)
{
+ off_t i;
+
+ /* Merge spaces at the start of a sentence to tabs if possible. */
+ if ((column % 8) == 0) {
+ for (i = 0; i < column; i++)
+ if (!peekbyte(i + 1, ' '))
+ break;
+ if (i == column) {
+ queuelen -= column;
+ for (i = 0; i < column; i += 8)
+ queue[queuelen++] = '\t';
+ }
+ }
if (fwrite(queue, 1, queuelen, stdout) != queuelen) {
perror("write");