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

Christian christian at global.net.au
Sat May 29 11:09:54 WST 1999


Tom Atkinson wrote:
> 
> 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...

Ditto for below. :)

#!/usr/bin/perl
while(<>)
{
	s/\r//;
	print;
}

for comparison purposes... ;-)

> #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;
> }

-- 
========================================================================
I'm not trying to give users what they want, I'm trying to give them
freedom, which they can then accept or reject. If people don't want
freedom, they may be out of luck with me, but I won't allow them to 
define for me what is right, what is worth spending my life for.
                                                    - Richard Stallman


More information about the plug mailing list