8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
+ |
#include <fcntl.h> |
12 |
|
#include <stdio.h> |
13 |
|
#include <string.h> |
14 |
|
#include <math.h> |
15 |
|
#include <ctype.h> |
16 |
|
|
17 |
|
#include "platform.h" |
17 |
– |
#include "calcomp.h" |
18 |
|
#include "rterror.h" |
19 |
+ |
#include "rtmisc.h" |
20 |
+ |
#include "rtio.h" |
21 |
+ |
#include "calcomp.h" |
22 |
|
|
23 |
|
#define isnum(c) (isdigit(c) || (c)=='-' || (c)=='.' \ |
24 |
|
|| (c)=='+' || (c)=='e' || (c)=='E') |
78 |
|
|
79 |
|
int blnkeq = 1; /* blanks compare equal? */ |
80 |
|
int igneol = 0; /* ignore end of line? */ |
81 |
+ |
int passive = 0; /* passive mode (transmit unmatched input) */ |
82 |
|
char sepchar = '\t'; /* input/output separator */ |
83 |
|
int noinput = 0; /* no input records? */ |
84 |
|
int nbicols = 0; /* number of binary input columns */ |
125 |
|
case 'l': |
126 |
|
igneol = !igneol; |
127 |
|
break; |
128 |
+ |
case 'p': |
129 |
+ |
passive = !passive; |
130 |
+ |
break; |
131 |
|
case 't': |
132 |
|
sepchar = argv[i][2]; |
133 |
|
break; |
205 |
|
userr: |
206 |
|
eputs("Usage: "); |
207 |
|
eputs(argv[0]); |
208 |
< |
eputs(" [-b][-l][-n][-w][-u][-tS][-s svar=sval][-e expr][-f source][-i infmt][-o outfmt] [file]\n"); |
208 |
> |
eputs(" [-b][-l][-n][-p][-w][-u][-tS][-s svar=sval][-e expr][-f source][-i infmt][-o outfmt] [file]\n"); |
209 |
|
quit(1); |
210 |
|
} |
211 |
|
|
225 |
|
execute(argv[i]); |
226 |
|
|
227 |
|
quit(0); |
228 |
+ |
return 0; /* pro forma return */ |
229 |
|
} |
230 |
|
|
231 |
|
|
628 |
|
|
629 |
|
|
630 |
|
static int |
631 |
< |
getrec(void) /* get next record from file */ |
631 |
> |
getrec(void) /* get next record from file */ |
632 |
|
{ |
633 |
|
int eatline; |
634 |
|
register struct field *f; |
637 |
|
eatline = !igneol && ipb.chr != '\n'; |
638 |
|
if (blnkeq) /* beware of nbsynch() */ |
639 |
|
while (isblnk(ipb.chr)) |
640 |
< |
scaninp(); |
640 |
> |
resetinp(); |
641 |
|
clearrec(); /* start with fresh record */ |
642 |
|
for (f = inpfmt; f != NULL; f = f->next) |
643 |
|
if (getfield(f) == -1) |
644 |
|
break; |
645 |
|
if (f == NULL) { |
646 |
< |
advinp(); |
646 |
> |
advinp(); /* got one! */ |
647 |
|
return(1); |
648 |
|
} |
649 |
< |
resetinp(); |
649 |
> |
resetinp(); /* eat false start */ |
650 |
|
if (eatline) { /* eat rest of line */ |
651 |
|
while (ipb.chr != '\n') { |
652 |
|
if (ipb.chr == EOF) |
653 |
|
return(0); |
654 |
< |
scaninp(); |
654 |
> |
resetinp(); |
655 |
|
} |
656 |
< |
scaninp(); |
649 |
< |
advinp(); |
656 |
> |
resetinp(); |
657 |
|
} |
658 |
|
} |
659 |
|
return(0); |
850 |
|
ipb.beg = ipb.end; |
851 |
|
ipb.pos = ipb.beg; |
852 |
|
ipb.chr = *ipb.pos; |
853 |
+ |
if (passive) /* transmit unmatched character? */ |
854 |
+ |
fputc(ipb.chr, stdout); |
855 |
|
if (++ipb.beg >= &inpbuf[INBSIZ]) |
856 |
|
ipb.beg = inpbuf; |
857 |
|
scaninp(); |