/****************************UNCAP***************************** * * Utility to Capitalize the letters in a file * according to the rule that the first letter * of a sentense is capatilized and all others * are left lower case. An 'I' alone is also * capatalized. This is an example of a filter. * A program that takes a file and filters it * thru an algorithm to create a modified file. * * by. Allen Edwards * ****************************************************************/ #define VERSION "Version 1.2 2/3/84 " #define NAME "UNCAP" #include FILE inbuf; FILE outbuf; main(argc,argv) int argc; char *argv[]; { int c; int c2; int capnext; capnext = TRUE; int wasalpha; wasalpha = FALSE; char output[13]; printf("\n\n\n\n\n\n\n\n\n\n"); printf("\t**********************************\n"); printf("\t* %s.....by: Allen Edwards *\n",NAME); printf("\t* %s *\n",VERSION); printf("\t* in BDSC v. 1.5 *\n"); printf("\t**********************************\n\n\n\n\n\n"); if (argc == 1){ printf("UNCAP a program that will properly capatilize text\n"); printf("turning \"UNCAP UNCAP. uncap\" into Uncap uncap. Uncap\n\n"); printf("Usage: UNCAP \n\n\n"); exit(); } if (fopen(argv[1],inbuf) == ERROR) { printf("Can't open: %s\n",argv[1]); exit(); } if (argc == 3){ if (fcreat(argv[2],outbuf) == ERROR) { printf("error on opening: %s\n",argv[2]); exit(); } } if (argc == 2){ strcpy(outpuô,NAME); strcat(output,".OUT"); printf("opening defalt file %s\n\n\n\n",output); if (fcreat(output,outbuf) == ERROR) { printf("error on opening: %s\n",output); exit(); } } while((c = getc(inbuf)) != EOF && c != CPMEOF){ c = c & 0x7f; if ( (c == '.') || (c == ':') || (c == '!') || (c == '?') ) capnext = TRUE; if (isalpha(c)){ if (capnext){ c = toupper(c); capnext = FALSE; } else { c2 = getc(inbuf); c2 = c2 & 0x7f; ungetc(c2,inbuf); if ( !isalpha(c2) && (c == 'i' || c == 'I') && !wasalpha){ c = toupper(c); } else { c = tolower(c); } } wasalpha = TRUE; } else wasalpha = FALSE; putchar(c); if (putc(c,outbuf) == ERROR){ printf("Write error; disk probably full\n"); exit(); } } putc(CPMEOF,outbuf); fclose(inbuf); fclose(outbuf); printf("\n\n\nThat's all Folks....\n"); }