home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* */
- /* Module: de1st.c - Replace 1st Word control flags with spaces */
- /* */
- /* Programmer: George R. Woodside */
- /* */
- /* Date: January 22, 1987 */
- /* */
- /****************************************************************************/
-
- #include <stdio.h>
- #include <ctype.h>
-
- main(argc,argv)
- int argc;
- char *argv[];
-
- {
- register int i;
- FILE *fp;
-
- if (argc > 1) /* if multiple arguments, */
- {
- for (i = 1; i < argc; i++) /* then do each one */
- {
- if( (fp = fopen(argv[i],"r") ) == NULL) /* if error opening file, */
- {
- printf("de1st: Unable to open %s \n",argv[i]);
- continue;
- }
- else /* if file opened OK, */
- {
- decnt(fp); /* de-control it */
- } /* end file opened OK */
- } /* end for one argument */
- } /* end for all arguments */
- else /* if no arguments, */
- decnt(stdin); /* dump standard in */
- } /* end main */
-
- /****************************************************************************/
- /* decnt - de-control character a file. */
- /****************************************************************************/
- decnt(fp)
- FILE *fp; /* file to dump */
-
- {
-
- register int c;
-
- while( (c = getc(fp) ) != EOF) /* read the whole file */
- {
- c = c & 0x7f; /* insure no high bits on */
- if(isprint(c)) /* if a printable character, */
- putchar(c); /* copy it */
- else /* but if a control, */
- { /* check it out */
- switch (c) /* all controls are checked */
- {
- case '\n': /* newlines are ok */
- putchar(c); /* copy it */
- break; /* and call it ok */
-
- case '\r': /* returns are ok */
- putchar(c); /* copy it */
- break; /* and call it ok */
-
- case '\014': /* form feed ok for page break */
- putchar(c); /* copy it */
- break; /* and call it ok */
-
- case '\t': /* tabs are ok */
- putchar(c); /* copy it */
- break; /* and call it ok */
-
- default:
- putchar(' '); /* anything else is a space */
- break;
-
- } /* end switch */
- } /* end control character */
- } /* end of file */
- } /* end decnt */
-