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.39 by greg, Fri Jul 24 16:58:16 2020 UTC vs.
Revision 2.49 by greg, Wed Jun 4 22:34:27 2025 UTC

# Line 31 | Line 31 | static const char      RCSid[] = "$Id$";
31  
32   #include  "tiff.h"      /* for int32 */
33   #include  "rtio.h"
34 + #include  "color.h"
35   #include  "resolu.h"
36  
37   #define  MAXLINE        2048
# Line 57 | Line 58 | newheader(             /* identifying line of information header
58   {
59          fputs(HDRSTR, fp);
60          fputs(s, fp);
61 <        putc('\n', fp);
61 >        fputc('\n', fp);
62   }
63  
64  
# Line 167 | Line 168 | printargs(             /* print arguments to a file */
168          FILE  *fp
169   )
170   {
170 #if defined(_WIN32) || defined(_WIN64)
171        extern char     *fixargv0(char *arg0);
172        char            myav0[128];
173                                /* clean up Windows executable path */
174        if (ac <= 0) return;
175        fputs(fixargv0(strcpy(myav0, *av++)), fp);
176        fputc(--ac ? ' ' : '\n');
177 #endif
171          while (ac-- > 0) {
172                  fputword(*av++, fp);
173                  fputc(ac ? ' ' : '\n', fp);
# Line 190 | Line 183 | formatval(                     /* get format value (return true if forma
183   {
184          const char  *cp = FMTSTR;
185          char  *r = fmt;
186 <
186 >                                /* check against format string */
187          while (*cp) if (*cp++ != *s++) return(0);
188          while (isspace(*s)) s++;
189          if (!*s) return(0);
190 <        if (r == NULL) return(1);
191 <        do
190 >        if (r == NULL)          /* just checking if format? */
191 >                return(1);
192 >        do                      /* copy format ID */
193                  *r++ = *s++;
194 <        while (*s && !isspace(*s) && r-fmt < MAXFMTLEN-1);
195 <        *r = '\0';
194 >        while (*s && r-fmt < MAXFMTLEN-1);
195 >
196 >        do                      /* remove trailing white space */
197 >                *r-- = '\0';
198 >        while (r > fmt && isspace(*r));
199 >
200          return(1);
201   }
202  
# Line 209 | Line 207 | fputformat(            /* put out a format value */
207          FILE  *fp
208   )
209   {
210 +        int     align = 0;
211 +
212          fputs(FMTSTR, fp);
213          fputs(s, fp);
214 <        putc('\n', fp);
214 >                        /* pad to align binary type for mmap() */
215 >        if (globmatch(PICFMT, s))
216 >                align = 0;      /* not needed for picture data */
217 >        else if (!strncmp("float", s, 5))
218 >                align = sizeof(float);
219 >        else if (!strncmp("double", s, 6))
220 >                align = sizeof(double);
221 >        else if (!strncmp("16-bit", s, 6))
222 >                align = 2;
223 >        else if (!strncmp("32-bit", s, 6))
224 >                align = 4;
225 >        else if (!strncmp("64-bit", s, 6))
226 >                align = 8;
227 >        if (align) {
228 >                long    pos = ftell(fp);
229 >                if (pos >= 0) {
230 >                        pos = (pos + 2) % align;
231 >                        if (pos) align -= pos;
232 >                        else align = 0;
233 >                } else
234 >                        align = 0;
235 >        }
236 >        while (align-- > 0)
237 >                putc(' ', fp);
238 >        fputc('\n', fp);
239   }
240  
241  
# Line 336 | Line 360 | globmatch(                     /* check for match of s against pattern p
360                          while (*s++);
361                          return(0);
362                  case '[':                       /* character set */
363 <                        setmatch = *s == *++p;
363 >                        setmatch = (*s == *++p);
364                          if (!*p)
365                                  return(0);
366                          while (*++p != ']') {
367                                  if (!*p)
368                                          return(0);
369                                  if (*p == '-') {
370 <                                        setmatch += (p[-1] <= *s && *s <= p[1]);
370 >                                        setmatch += (p[-1] <= *s) & (*s <= p[1]);
371                                          if (!*++p)
372                                                  break;
373                                  } else
# Line 354 | Line 378 | globmatch(                     /* check for match of s against pattern p
378                          s++;
379                          break;
380                  case '\\':                      /* literal next */
381 <                        p++;
381 >                        if (!*++p)
382 >                                return(0);
383                  /* fall through */
384                  default:                        /* normal character */
385                          if (*p != *s)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines