CRLF 1.1

CRLF is yet another utility for changing line termination chars. It has been compiled and used under Unix and Windows. It consists of a single short file that you can download gratis from here for Unices (source) and for PCs (source). You need a compiler to build the executable. For Pentium PCs you can also download a win32 borland 5.5 compiled executable.. You need an unzip utility for this.

Compile and install it with a variation of the following:

	gcc -o /usr/local/bin/crlf crlf.c
	(on MacOs X: gcc -o /bin/crlf -Dunix crlf.c)
	chown bin:bin /usr/local/bin/crlf
	chmod a+x /usr/local/bin/crlf
or
	bcc32 crlf.c c:\borland\bcc55\lib\wildargs.obj
	(using MSVC: cl crlf.c "D:\Program Files\DevStudio\VC\lib\setargv.obj")
	move crlf.exe c:\windows\command

Run it like so

	crlf *.java *.eps
	crlf -l3 *.c
you can use -v for verbose, -s for no warning, and -b to keep backup; you can specify which target line termination you want, including Mac's classic '\r'. Newly added options include the functionality of unexpand/expand utilities:
-l
unexpand leading tabs or spaces on each line
-a
unexpand all tabs or spaces
-e
expand all tabs
-T
replace any amount of tabs or spaces with a single space
-.
same as -T, but put two spaces after a '.'. Dots not followed by a space are unaffected.
Get options summary with crlf -h.

CRLF converts existing files in place, without changing file modification time. It converts files even if they have an inconsistent mix of carriage returns and line feeds, as it often happens with java or postscript files.

CRLF is free for single individuals and small companies. See NOTICE. You may contact the author by e-mail.

Have fun!

Changes:

28 Oct 2004: on Win32, convert / to \ in input parameters
 4 Oct 2004: Use native WIN32 function to reset file time on WIN32
             added removal of trailing ^Z character (*)
             added expand/unexpand functionality
             

*What is ^Z?
Ctrl-Z, ascii 26, is the DOS equivalent of Ctrl-D in Unix: the end of file character. Typing that char marks the end of input, e.g. in Python or in a copy con: file command. The character is usually not written to the file nowadays. It used to: original DOS 1 directory records only held the number of blocks, not the exact length in bytes. The control zed was needed to avoid adding spurious characters at the end.

For compatibility reasons, old editors, e.g. Jim Wyllie's PE2, still write a trailing ^Z at end of file. (Anyone still has any of those 51/4" floppies at 128 bpb around there?)


Copyright © 2001-2004 Alessandro Vesely. All rights reserved.