[plug] Does anyone know where i can get source for dos2unix?

Tom Atkinson tom at tyco.net.au
Sat May 29 01:15:36 WST 1999


Hi David,

See below; this is a version I wrote - reads from stdin, writes to
stdout; ignores command line args so you can use it in printer filters
etc...

"Buddrige, David" wrote:
> 
> Hi all,
> 
> anyway) the dos2unix utility - i was wondering if anyone knew where I might
> get some source that I could compile under DEC-UNIX - otherwise, it comes
> 
> thanks all... 8-)
> 
> David...

#include <stdio.h>
#include <stdlib.h>

#define CR 13
#define LF 10


int main(int argc, char *argv[])
{
 /* ignore all command line arguments */
 /* read from stdin, write to stdout */
 
 int ch;
 int buf[2];
 
 ch = fgetc(stdin);
 if (ch == EOF)
    exit(1);
    
 buf[1] = ch;   
 
 
 while (1)
       {
        ch = fgetc(stdin);
        if (ch == EOF)
           break;
         
        buf[0] = buf[1];
        buf[1] = ch;
        
        if (!(buf[0] == CR && buf[1] == LF))
           printf("%c", buf[0]);
       }
       
 printf("%c", buf[1]);
 
 return 0;
}


More information about the plug mailing list