#ifdef ournix #include "ournix.h" #endif char sccsID[] = "@(#) strings.c V2.0 Copyright Vector Systems Ltd(pjc) 1987\n" ; #include /* author pjc */ #include #define MY_BUFSIZ (20*BUFSIZ) char buf[MY_BUFSIZ]; char tbuf[256]; char **ARGV ; settbuf() { register int c; register char *p = "\r\n\t"; for(c = ' '; c <= '~' ; c++) tbuf[c] = 1; while(*p) tbuf[*p++] = 1; } main(argc, argv) int argc; char *argv[]; { int fd; ARGV = argv ; #ifdef VSL /* { */ #include "../../include/vsl.h" #endif /* } */ settbuf(); argc--; argv++; if(argc == 0) doit(fileno(stdin)); else while(argc--){ fd = open(*argv, O_RDONLY #ifdef MSDOS | O_BINARY #endif ); if(fd < 0) fprintf(stderr, "Cannot open '%s'\n", *argv); else { doit(fd); (void) close(fd); } argv++; } exit(0); } doit(fd) int fd; { char lbuf[5]; char *p; int ibuf; register int c; register int ncount = 0; register char *xp; ibuf = 0; p = lbuf; for(;;){ if(--ncount < 0){ ncount = read(fd, buf, MY_BUFSIZ); if(ncount <= 0) return; xp = buf; ncount--; } c = *xp++ & 0377; if( !tbuf[c]){ p = lbuf; ibuf = 0; continue; } *p++ = c; if(++ibuf >= 4){ *p = 0; printf("%s", lbuf); for(;;){ if(--ncount < 0){ ncount = read(fd, buf, MY_BUFSIZ); if(ncount <= 0) return; xp = buf; ncount--; } c = *xp++ & 0377; if(!tbuf[c]) break; putchar(c); } putchar('\n'); p = lbuf; ibuf = 0; } } }