suckless unix tools
git clone
Log | Files | Refs | README | LICENSE

commit ff93350289a96308e73cc5d7ab1d689d08ea0efc
parent 353ac69a93322a8c97db2dad3dee47447de77032
Author: sin <>
Date:   Fri, 17 Oct 2014 21:12:23 +0100

Fix col(1) -f

patch taken from openbsd.

Ingo Schwarze says:

If you call the col(1) utility with the -f option, permitting forward
half-line feeds in the output stream, and the input stream actually
contains half-line feeds in either direction, you end up with corrupt
output, containing meaningless escape-digitnine sequences instead of
the required escape-tab sequences.

   $ hexdump -C half.txt
  00000000  61 1b 09 62 1b 09 63 0a                    |a..b..c.|
   $ col -f < half.txt | hexdump -C
  00000000  61 1b 39 0d 20 62 1b 39  0d 20 20 63 0a    |a.9. b.9.  c.|

Note how the third character changes from 0x09 to 0x39.

OK to commit the following fix?  Don't worry, it isn't dangerous,
it only changes two *bits*, only a quarter of a byte.

The bug was introduced by the original author, Michael Rendell,
and committed by Keith Bostic on May 22, 1990 (SCCS rev. 5.1).

The following operating systems are affected:

 * 4.3BSD Reno, BSD Net/2, 4.4BSD, 4.4BSD Lite1, 4.4BSD Lite2
 * All versions of 386BSD, NetBSD, OpenBSD, FreeBSD and DragonFly
 * All versions of Debian GNU/Linux and probably many other Linuxes

Mcol.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/col.c b/col.c @@ -346,7 +346,7 @@ flush_blanks(void) PUTC('\n'); if (half) { PUTC('\033'); - PUTC('9'); + PUTC('\011'); if (!nb) PUTC('\r'); }