--- ray/src/common/header.c 1995/10/16 10:53:46 2.6 +++ ray/src/common/header.c 1997/10/31 11:40:52 2.9 @@ -1,4 +1,4 @@ -/* Copyright (c) 1994 Regents of the University of California */ +/* Copyright (c) 1996 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -57,7 +57,7 @@ register char *r, *s; while (*cp) if (*cp++ != *s++) return(0); if (r == NULL) return(1); - while (*s) *r++ = *s++; + while (*s && !isspace(*s)) *r++ = *s++; *r = '\0'; return(1); } @@ -89,9 +89,8 @@ register FILE *fp; putc(quote, fp); } else fputs(*av++, fp); - putc(' ', fp); + putc(ac ? ' ' : '\n', fp); } - putc('\n', fp); } @@ -218,7 +217,8 @@ char *pat, *str; * if any input format is found (or there is an error), and 0 otherwise. * If fmt contains any '*' or '?' characters, then checkheader * does wildcard expansion and copies a matching result into fmt. - * Be sure that fmt is big enough to hold the match in such cases! + * Be sure that fmt is big enough to hold the match in such cases, + * and that it is not a static, read-only string! * The input header (minus any format lines) is copied to fout * if fout is not NULL. */ @@ -230,6 +230,7 @@ char *fmt; FILE *fout; { struct check cdat; + register char *cp; cdat.fp = fout; cdat.fs[0] = '\0'; @@ -237,9 +238,12 @@ FILE *fout; return(-1); if (!cdat.fs[0]) return(0); - if (globmatch(fmt, cdat.fs)) { - strcpy(fmt, cdat.fs); - return(1); - } - return(-1); + for (cp = fmt; *cp; cp++) /* check for globbing */ + if (*cp == '?' | *cp == '*') + if (globmatch(fmt, cdat.fs)) { + strcpy(fmt, cdat.fs); + return(1); + } else + return(-1); + return(strcmp(fmt, cdat.fs) ? -1 : 1); /* literal match */ }