142 |
|
return(ST_NONE); |
143 |
|
} |
144 |
|
|
145 |
+ |
/* Check if any of the characters in str2 are found in str1 */ |
146 |
+ |
static int |
147 |
+ |
matchany(const char *str1, const char *str2) |
148 |
+ |
{ |
149 |
+ |
while (*str1) { |
150 |
+ |
const char *cp = str2; |
151 |
+ |
while (*cp) |
152 |
+ |
if (*cp++ == *str1) |
153 |
+ |
return(*str1); |
154 |
+ |
++str1; |
155 |
+ |
} |
156 |
+ |
return(0); |
157 |
+ |
} |
158 |
+ |
|
159 |
|
/* Add arguments to oconv command */ |
160 |
|
static char * |
161 |
|
oconv_command(int ac, char *av[]) |
170 |
|
strcpy(cp, *av++); |
171 |
|
while (*cp) cp++; |
172 |
|
*cp++ = ' '; |
173 |
< |
if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) { |
174 |
< |
fputs(progname, stderr); |
161 |
< |
fputs(": too many file arguments!\n", stderr); |
162 |
< |
exit(1); |
163 |
< |
} |
173 |
> |
if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) |
174 |
> |
goto overrun; |
175 |
|
} |
176 |
< |
strcpy(cp, recv); /* receiver goes last */ |
176 |
> |
/* receiver goes last */ |
177 |
> |
if (matchany(recv, SPECIALS)) { |
178 |
> |
*cp++ = QUOTCHAR; |
179 |
> |
while (*recv) { |
180 |
> |
if (cp >= oconvbuf+(sizeof(oconvbuf)-3)) |
181 |
> |
goto overrun; |
182 |
> |
*cp++ = *recv++; |
183 |
> |
} |
184 |
> |
*cp++ = QUOTCHAR; |
185 |
> |
*cp = '\0'; |
186 |
> |
} else |
187 |
> |
strcpy(cp, recv); |
188 |
|
return(oconvbuf); |
189 |
+ |
overrun: |
190 |
+ |
fputs(progname, stderr); |
191 |
+ |
fputs(": too many file arguments!\n", stderr); |
192 |
+ |
exit(1); |
193 |
|
} |
194 |
|
|
169 |
– |
/* Check if any of the characters in str2 are found in str1 */ |
170 |
– |
static int |
171 |
– |
matchany(const char *str1, const char *str2) |
172 |
– |
{ |
173 |
– |
while (*str1) { |
174 |
– |
const char *cp = str2; |
175 |
– |
while (*cp) |
176 |
– |
if (*cp++ == *str1) |
177 |
– |
return(*str1); |
178 |
– |
++str1; |
179 |
– |
} |
180 |
– |
return(0); |
181 |
– |
} |
182 |
– |
|
183 |
– |
|
195 |
|
/* Convert a set of arguments into a command line for pipe() or system() */ |
196 |
|
static char * |
197 |
|
convert_commandline(char *cmd, const int len, char *av[]) |
201 |
|
|
202 |
|
for (cp = cmd; *av != NULL; av++) { |
203 |
|
const int n = strlen(*av); |
204 |
< |
if (cp+n >= cmd+(len-3)) { |
194 |
< |
fputs(progname, stderr); |
204 |
> |
if (cp+n >= cmd+(len-3)) |
205 |
|
return(NULL); |
206 |
< |
} |
197 |
< |
if ((match = matchany(*av, SPECIALS))) { |
206 |
> |
if (matchany(*av, SPECIALS)) { |
207 |
|
const int quote = |
208 |
|
#ifdef ALTQUOT |
209 |
< |
(match == QUOTCHAR) ? ALTQUOT : |
209 |
> |
strchr(*av, QUOTCHAR) ? ALTQUOT : |
210 |
|
#endif |
211 |
|
QUOTCHAR; |
212 |
|
*cp++ = quote; |
327 |
|
{ |
328 |
|
char *cp = pargs; |
329 |
|
int nparams = 0; |
330 |
+ |
int quot; |
331 |
|
int i; |
332 |
|
|
333 |
|
for ( ; ; ) { |
364 |
|
case 'o': |
365 |
|
if (*cp++ != '=') |
366 |
|
break; |
367 |
+ |
quot = 0; |
368 |
+ |
if ((*cp == '"') | (*cp == '\'')) |
369 |
+ |
quot = *cp++; |
370 |
|
i = 0; |
371 |
< |
while (*cp && !isspace(*cp++)) |
372 |
< |
i++; |
371 |
> |
while (*cp && (quot ? (*cp != quot) : !isspace(*cp))) { |
372 |
> |
i++; cp++; |
373 |
> |
} |
374 |
|
if (!i) |
375 |
|
break; |
376 |
< |
*--cp = '\0'; |
376 |
> |
if (!*cp) { |
377 |
> |
if (quot) |
378 |
> |
break; |
379 |
> |
cp[1] = '\0'; |
380 |
> |
} |
381 |
> |
*cp = '\0'; |
382 |
|
p->outfn = savqstr(cp-i); |
383 |
< |
*cp++ = ' '; |
383 |
> |
*cp++ = quot ? quot : ' '; |
384 |
|
++nparams; |
385 |
|
continue; |
386 |
|
case ' ': |
549 |
|
{ |
550 |
|
int i; |
551 |
|
|
552 |
< |
if (!getperpendicular(uva[0], nrm)) { |
552 |
> |
if (!getperpendicular(uva[0], nrm, 1)) { |
553 |
|
fputs(progname, stderr); |
554 |
|
fputs(": bad surface normal in make_axes!\n", stderr); |
555 |
|
exit(1); |
693 |
|
/* special case for lone surface */ |
694 |
|
if (p->nsurfs == 1) { |
695 |
|
sp = p->slist; |
696 |
< |
if (DOT(sp->snrm, rdir) >= -FTINY) { |
696 |
> |
if (DOT(sp->snrm, rdir) >= FTINY) { |
697 |
|
fprintf(stderr, |
698 |
|
"%s: internal - sample behind sender '%s'\n", |
699 |
|
progname, sp->sname); |