Commit Graph

4 Commits

Author SHA1 Message Date
sin
ff93350289 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.|
  00000008
   $ 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.|
  0000000d

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
2014-10-17 21:14:00 +01:00
sin
41d78c398b Staticise symbols 2014-10-16 12:30:52 +01:00
sin
0c5b7b9155 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:46:59 +01:00
sin
a48b850d3f Import col(1) from OpenBSD with minor modifications
Remove getopt, use arg.h.
2014-09-29 19:52:31 +01:00