[comp.sys.amiga] Program to remove control codes from files

fgd3@jc3b21.UUCP (05/19/87)

     This is a rather trivial program which I have found useful on a number
of occasions.  I wrote it because ed rejects files with control codes and
the Lattice C compiler writes a bell at the end of its output if there is an
error.

     Then I discovered it solves another problem.  I download files with
the cat command on a Unix system.  Cat writes LF and CR and the end of each
line.  My terminal program doesn't intercept the extra CRs so AmigaDOS
thinks the files are double spaced.  Stripbin changes those CRs to blanks.

     I'm a little embarrassed to post such a simple program to a forum that
has seen so many significant ones, but someone might be glad to have it.


--Fabbian Dufoe
  350 Ling-A-Mor Terrace South
  St. Petersburg, Florida  33705
  813-823-2350

UUCP: ...akgua!usfvax2!jc3b21!fgd3 

----------------------------------------------------------------------------
/*   stripbin.c

     by Fabbian G. Dufoe, III

     This program reads its standard input, changes any characters except
     newlines whose ASCII code is less than 0x20 to spaces (0x20), and
     writes to standard output. */

#include <stdio.h>
#include <fcntl.h>

main()
{
     int c;
     c = getchar();
     while (c != EOF)
     {
          if ((c < 0x20) && (c != '\n'))
               putchar(0x20);
          else
               putchar(c);
          c = getchar();
     }
     return(0);
}
----------------------------------------------------------------------------