ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/header.c
(Generate patch)

Comparing ray/src/common/header.c (file contents):
Revision 2.5 by greg, Sun Oct 15 14:07:58 1995 UTC vs.
Revision 2.6 by greg, Mon Oct 16 10:53:46 1995 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17   *  formatval(r,s)      copy the format value in s to r
18   *  fputformat(s,fp)    write "FORMAT=%s" to fp
19   *  getheader(fp,f,p)   read header from fp, calling f(s,p) on each line
20 < *  copymatch(pat, str) copy str into pat if glob match
20 > *  globmatch(pat, str) check for glob match of str against pat
21   *  checkheader(i,p,o)  check header format from i against p and copy to o
22   *
23   *  To copy header from input to output, use getheader(fin, fputs, fout)
# Line 176 | Line 176 | register struct check  *cp;
176   }
177  
178  
179 /*
180 * Copymatch(pat,str) checks pat for wildcards, and
181 * copies str into pat if there is a match (returning true).
182 */
183
179   int
180 < copymatch(pat, str)
180 > globmatch(pat, str)             /* check for glob match of str against pat */
181   char    *pat, *str;
182   {
188        int     docopy = 0;
183          register char   *p = pat, *s = str;
184  
185          do {
# Line 193 | Line 187 | char   *pat, *str;
187                  case '?':                       /* match any character */
188                          if (!*s++)
189                                  return(0);
196                        docopy++;
190                          break;
191                  case '*':                       /* match any string */
192                          while (p[1] == '*') p++;
193                          do
194 <                                if ( (p[1]=='?' || p[1]==*s)
195 <                                                && copymatch(p+1,s) ) {
203 <                                        strcpy(pat, str);
194 >                                if ( (p[1]=='?' || p[1]==*s) &&
195 >                                                globmatch(p+1,s) )
196                                          return(1);
205                                }
197                          while (*s++);
198                          return(0);
199                  case '\\':                      /* literal next */
# Line 215 | Line 206 | char   *pat, *str;
206                          break;
207                  }
208          } while (*p++);
218        if (docopy)
219                strcpy(pat, str);
209          return(1);
210   }
211  
# Line 246 | Line 235 | FILE  *fout;
235          cdat.fs[0] = '\0';
236          if (getheader(fin, mycheck, &cdat) < 0)
237                  return(-1);
238 <        if (cdat.fs[0] != '\0')
239 <                return(copymatch(fmt, cdat.fs) ? 1 : -1);
240 <        return(0);
238 >        if (!cdat.fs[0])
239 >                return(0);
240 >        if (globmatch(fmt, cdat.fs)) {
241 >                strcpy(fmt, cdat.fs);
242 >                return(1);
243 >        }
244 >        return(-1);
245   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines