/* clean.c - remove nasty characters like '\f' from a text file */ /* * This is used to clean up eg PIP/TB output files which have * embedded ^Ls, ^@s etc that we just want to go away. * With PIP/TB you get a formfeed in the first line ONLY. * One day Unix will be free, until then use clean. */ /* ufilter4.c - prototype filter program - line (actually record) oriented */ /* * Modular, fast, record filter skeleton. * Forces FD.CR on output file. * Gets file names from argv[1],[2]. Too hard to use stdin,stdout. * The record has NOTHING (like free '\n's) added to it. * Howlong = the record size in bytes. * Designed for R.VAR files. */ #include #include #include #include #include char * buffer; /* where the buffer is */ int bufmax; /* maximum record size, needed for recinp() */ FILE *inf; /* input file */ FILE *ouf; /* output file */ FDB * fdbp; /* obsolete kludge */ int howlong; /* char length of this input record */ char * p; /* scan input buffer */ char * emit; /* output buffer */ char * q; /* scan output buffer */ char * n; /* 'end' points just after end of input buffer */ char c; /* */ main(argc,argv) char **argv; BEGIN char * recinp(); /* the record-getter: 0 means end-of-file */ IF ((inf=fopen(argv[1],"urn"))==NULL) THEN error("can't find %s\7",argv[1]); FI fdbp = inf -> io_fdb; IF (!(buffer=malloc(bufmax=fdbp->f_fatt.f_rsiz))) THEN error("max record size=%d.\7",bufmax); FI IF (!(emit=malloc(bufmax))) THEN error("MAX record size=%d.\7",bufmax); FI IF ((ouf=fopen(argv[2],"uwn"))==NULL) THEN error("can't make %s\7",argv[2]); FI fdbp = ouf -> io_fdb; fdbp -> f_fatt . f_ratt |= fd_cr; /* force fd.cr */ /* * this is the simple logic: */ WHILE (recinp(buffer,bufmax,inf,&howlong)) DO FOR (p=buffer,q=emit,n=buffer+howlong; p