15 |
|
|
16 |
|
#include "platform.h" |
17 |
|
#include "calcomp.h" |
18 |
+ |
#include "rterror.h" |
19 |
|
|
19 |
– |
#ifdef CPM |
20 |
– |
#define getc agetc /* text files only, right? */ |
21 |
– |
#endif |
22 |
– |
|
20 |
|
#define isnum(c) (isdigit(c) || (c)=='-' || (c)=='.' \ |
21 |
|
|| (c)=='+' || (c)=='e' || (c)=='E') |
22 |
|
|
147 |
|
nbicols = atoi(argv[i]+3); |
148 |
|
else |
149 |
|
nbicols = 1; |
150 |
+ |
if (nbicols*sizeof(double) > INBSIZ) { |
151 |
+ |
eputs(argv[0]); |
152 |
+ |
eputs(": too many input columns\n"); |
153 |
+ |
quit(1); |
154 |
+ |
} |
155 |
|
break; |
156 |
|
case 'f': |
157 |
|
if (isdigit(argv[i][3])) |
158 |
|
nbicols = -atoi(argv[i]+3); |
159 |
|
else |
160 |
|
nbicols = -1; |
161 |
+ |
if (-nbicols*sizeof(float) > INBSIZ) { |
162 |
+ |
eputs(argv[0]); |
163 |
+ |
eputs(": too many input columns\n"); |
164 |
+ |
quit(1); |
165 |
+ |
} |
166 |
|
break; |
167 |
|
default: |
168 |
|
goto userr; |
623 |
|
register struct field *f |
624 |
|
) |
625 |
|
{ |
626 |
< |
static char buf[MAXWORD+1]; /* no recursion! */ |
626 |
> |
static char buf[RMAXWORD+1]; /* no recursion! */ |
627 |
|
int delim, inword; |
628 |
|
double d; |
629 |
|
char *np; |
656 |
|
delim = f->next->f.sl[0]; |
657 |
|
cp = buf; |
658 |
|
do { |
659 |
< |
if (ipb.chr == EOF) |
659 |
> |
if (ipb.chr == EOF || ipb.chr == '\n') |
660 |
|
inword = 0; |
661 |
|
else if (blnkeq && delim != EOF) |
662 |
|
inword = isblnk(delim) ? |
668 |
|
*cp++ = ipb.chr; |
669 |
|
scaninp(); |
670 |
|
} |
671 |
< |
} while (inword && cp < &buf[MAXWORD]); |
671 |
> |
} while (inword && cp < &buf[RMAXWORD]); |
672 |
|
*cp = '\0'; |
673 |
|
if (f->f.sv->val == NULL) |
674 |
|
f->f.sv->val = savqstr(buf); /* first setting */ |
697 |
|
*cp++ = ipb.chr; |
698 |
|
scaninp(); |
699 |
|
} |
700 |
< |
} while (inword && cp < &buf[MAXWORD]); |
700 |
> |
} while (inword && cp < &buf[RMAXWORD]); |
701 |
|
*cp = '\0'; |
702 |
|
d = np==NULL ? 0. : atof(np); |
703 |
|
if (!vardefined(f->f.nv)) |