--- ray/src/common/header.c 2022/03/14 22:57:24 2.47 +++ ray/src/common/header.c 2025/06/07 05:09:45 2.51 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: header.c,v 2.47 2022/03/14 22:57:24 greg Exp $"; +static const char RCSid[] = "$Id: header.c,v 2.51 2025/06/07 05:09:45 greg Exp $"; #endif /* * header.c - routines for reading and writing information headers. @@ -12,7 +12,6 @@ static const char RCSid[] = "$Id: header.c,v 2.47 2022 * gmtval(t,s) get GMT as UTC * fputdate(t,fp) put out the given UTC * fputnow(fp) put out the current date and time - * printargs(ac,av,fp) print an argument list to fp, followed by '\n' * formatval(r,s) copy the format value in s to r * fputformat(s,fp) write "FORMAT=%s" to fp * nativebigendian() are we native on big-endian machine? @@ -161,28 +160,6 @@ fputnow( /* write out the current time */ } -void -printargs( /* print arguments to a file */ - int ac, - char **av, - FILE *fp -) -{ -#if defined(_WIN32) || defined(_WIN64) - extern char *fixargv0(char *arg0); - char myav0[128]; - /* clean up Windows executable path */ - if (ac-- <= 0) return; - fputs(fixargv0(strcpy(myav0, *av++)), fp); - fputc(ac ? ' ' : '\n', fp); -#endif - while (ac-- > 0) { - fputword(*av++, fp); - fputc(ac ? ' ' : '\n', fp); - } -} - - int formatval( /* get format value (return true if format) */ char fmt[MAXFMTLEN], @@ -191,15 +168,20 @@ formatval( /* get format value (return true if forma { const char *cp = FMTSTR; char *r = fmt; - + /* check against format string */ while (*cp) if (*cp++ != *s++) return(0); while (isspace(*s)) s++; if (!*s) return(0); - if (r == NULL) return(1); - do + if (r == NULL) /* just checking if format? */ + return(1); + do /* copy format ID */ *r++ = *s++; - while (*s && !isspace(*s) && r-fmt < MAXFMTLEN-1); - *r = '\0'; + while (*s && r-fmt < MAXFMTLEN-1); + + do /* remove trailing white space */ + *r-- = '\0'; + while (r > fmt && isspace(*r)); + return(1); }