10 |
|
* command line or from a file. Their order together |
11 |
|
* with the extrude direction will determine surface |
12 |
|
* orientation. |
13 |
– |
* |
14 |
– |
* 8/24/87 |
13 |
|
*/ |
14 |
|
|
15 |
|
#include <stdio.h> |
16 |
|
|
17 |
+ |
#include <math.h> |
18 |
+ |
|
19 |
|
#include <ctype.h> |
20 |
|
|
21 |
|
#define MAXVERT 1024 /* maximum # vertices */ |
22 |
|
|
23 |
+ |
#ifdef DCL_ATOF |
24 |
+ |
extern double atof(); |
25 |
+ |
#endif |
26 |
+ |
|
27 |
|
char *pmtype; /* material type */ |
28 |
|
char *pname; /* name */ |
29 |
|
|
40 |
|
int argc; |
41 |
|
char **argv; |
42 |
|
{ |
39 |
– |
double atof(); |
43 |
|
int an; |
44 |
|
|
45 |
|
if (argc < 4) |
53 |
|
an = 4; |
54 |
|
} else if (isdigit(argv[3][0])) { |
55 |
|
nverts = atoi(argv[3]); |
56 |
+ |
if (nverts > MAXVERT) { |
57 |
+ |
fprintf(stderr, "%s: too many vertices (%d limit)\n", |
58 |
+ |
argv[0], MAXVERT); |
59 |
+ |
exit(1); |
60 |
+ |
} |
61 |
|
if (argc-3 < 2*nverts) |
62 |
|
goto userr; |
63 |
|
for (an = 0; an < nverts; an++) { |
114 |
|
{ |
115 |
|
FILE *fp; |
116 |
|
|
117 |
< |
if (fname == NULL) |
117 |
> |
if (fname == NULL) { |
118 |
|
fp = stdin; |
119 |
< |
else if ((fp = fopen(fname, "r")) == NULL) { |
119 |
> |
fname = "<stdin>"; |
120 |
> |
} else if ((fp = fopen(fname, "r")) == NULL) { |
121 |
|
fprintf(stderr, "%s: cannot open\n", fname); |
122 |
|
exit(1); |
123 |
|
} |
124 |
|
while (fscanf(fp, "%lf %lf", &vert[nverts][0], &vert[nverts][1]) == 2) |
125 |
< |
nverts++; |
125 |
> |
if (++nverts >= MAXVERT) { |
126 |
> |
fprintf(stderr, "%s: too many vertices (%d limit)\n", |
127 |
> |
fname, MAXVERT-1); |
128 |
> |
exit(1); |
129 |
> |
} |
130 |
|
fclose(fp); |
131 |
|
} |
132 |
|
|