From owner-svn-src-all@FreeBSD.ORG Mon Feb 6 18:52:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26951106566C; Mon, 6 Feb 2012 18:52:41 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 157C68FC16; Mon, 6 Feb 2012 18:52:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q16IqeJ3049113; Mon, 6 Feb 2012 18:52:40 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q16IqeIx049110; Mon, 6 Feb 2012 18:52:40 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201202061852.q16IqeIx049110@svn.freebsd.org> From: Ed Schouten Date: Mon, 6 Feb 2012 18:52:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r231098 - head/tools/tools/fixwhite X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2012 18:52:41 -0000 Author: ed Date: Mon Feb 6 18:52:40 2012 New Revision: 231098 URL: http://svn.freebsd.org/changeset/base/231098 Log: 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. Modified: head/tools/tools/fixwhite/fixwhite.1 head/tools/tools/fixwhite/fixwhite.c Modified: head/tools/tools/fixwhite/fixwhite.1 ============================================================================== --- head/tools/tools/fixwhite/fixwhite.1 Mon Feb 6 18:47:07 2012 (r231097) +++ head/tools/tools/fixwhite/fixwhite.1 Mon Feb 6 18:52:40 2012 (r231098) @@ -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 Modified: head/tools/tools/fixwhite/fixwhite.c ============================================================================== --- head/tools/tools/fixwhite/fixwhite.c Mon Feb 6 18:47:07 2012 (r231097) +++ head/tools/tools/fixwhite/fixwhite.c Mon Feb 6 18:52:40 2012 (r231098) @@ -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");