Path: utzoo!utgpu!water!watmath!clyde!att!mtunx!rutgers!mit-eddie!uw-beaver!cornell!batcomputer!itsgw!steinmetz!uunet!dalcs!dalcsug!dalegass From: dalegass@dalcsug.UUCP (Dale Gass) Newsgroups: comp.sys.ibm.pc Subject: Re: CR? LF? CRLF???? Message-ID: <480@dalcsug.UUCP> Date: 6 Jun 88 20:21:46 GMT References: <1770@loral.UUCP> <17210@gatech.edu> <1775@loral.UUCP> Reply-To: dalegass@dalcsug.UUCP (Dale Gass) Organization: Dalhousie University, Halifax, N.S., Canada Lines: 45 Jim Harkins writes. . . [discussion of MKS vi as a tool to add CR's to a LF delimited file] . >I found another oddity with this editor. There is a :source command that >allows you to read commands from a file. So I made up a file with 8 >search and replace commands in it, figuring that vi'ing and :source'ing >5 files beats doing things manually. Hey, guess what? As soon as >a search string is not found it aborts execution of the source'd file! >Unfortunatly, not all conversions need be done to all files. At this >point I uploaded things back to the vax, made my changes with sed, >stuck a bloody CR at the end of each line, and re-downloaded the mess. >God I love DOS. I imagine the 'source' command's behavior is simply based upon unix's vi :source behavior. MKS vi behaves exactly as unix vi in all aspects (I can't find one discrepancy). Why upload to the vax to used SED? You should get SED for the PC. GNU's version of SED is public domain, sources are available, and it seems quite complete... As far as a simple way of adding CR's to a LF delimited file, most C compilers stdio library will read LF delimited files properly, and write them out CRLF delimited (as long as you don't select file type of binary)... So all you need to build a pipe command to add cr's is a program such as the following: #includemain() { char line[255]; while (NULL != gets(line)) puts(line); } Just compile this to ADDCR.EXE or ADDCR.COM, and then: C:\> addcr outfile or C:\> type infile | addcr Will nicely add CR's to the file... -uunet!watmath!dalcs!dalegass@dalcsug.uucp