--- ray/src/util/rfluxmtx.c 2015/05/19 12:13:53 2.28 +++ ray/src/util/rfluxmtx.c 2015/07/22 04:23:27 2.30 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rfluxmtx.c,v 2.28 2015/05/19 12:13:53 greg Exp $"; +static const char RCSid[] = "$Id: rfluxmtx.c,v 2.30 2015/07/22 04:23:27 greg Exp $"; #endif /* * Calculate flux transfer matrix or matrices using rcontrib @@ -142,6 +142,20 @@ surf_type(const char *otype) return(ST_NONE); } +/* Check if any of the characters in str2 are found in str1 */ +static int +matchany(const char *str1, const char *str2) +{ + while (*str1) { + const char *cp = str2; + while (*cp) + if (*cp++ == *str1) + return(*str1); + ++str1; + } + return(0); +} + /* Add arguments to oconv command */ static char * oconv_command(int ac, char *av[]) @@ -156,31 +170,28 @@ oconv_command(int ac, char *av[]) strcpy(cp, *av++); while (*cp) cp++; *cp++ = ' '; - if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) { - fputs(progname, stderr); - fputs(": too many file arguments!\n", stderr); - exit(1); - } + if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) + goto overrun; } - strcpy(cp, recv); /* receiver goes last */ + /* receiver goes last */ + if (matchany(recv, SPECIALS)) { + *cp++ = QUOTCHAR; + while (*recv) { + if (cp >= oconvbuf+(sizeof(oconvbuf)-3)) + goto overrun; + *cp++ = *recv++; + } + *cp++ = QUOTCHAR; + *cp = '\0'; + } else + strcpy(cp, recv); return(oconvbuf); +overrun: + fputs(progname, stderr); + fputs(": too many file arguments!\n", stderr); + exit(1); } -/* Check if any of the characters in str2 are found in str1 */ -static int -matchany(const char *str1, const char *str2) -{ - while (*str1) { - const char *cp = str2; - while (*cp) - if (*cp++ == *str1) - return(*str1); - ++str1; - } - return(0); -} - - /* Convert a set of arguments into a command line for pipe() or system() */ static char * convert_commandline(char *cmd, const int len, char *av[]) @@ -194,10 +205,10 @@ convert_commandline(char *cmd, const int len, char *av fputs(progname, stderr); return(NULL); } - if ((match = matchany(*av, SPECIALS))) { + if (matchany(*av, SPECIALS)) { const int quote = #ifdef ALTQUOT - (match == QUOTCHAR) ? ALTQUOT : + strchr(*av, QUOTCHAR) ? ALTQUOT : #endif QUOTCHAR; *cp++ = quote; @@ -530,7 +541,7 @@ make_axes(FVECT uva[2], const FVECT nrm) { int i; - if (!getperpendicular(uva[0], nrm)) { + if (!getperpendicular(uva[0], nrm, 1)) { fputs(progname, stderr); fputs(": bad surface normal in make_axes!\n", stderr); exit(1);