ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/gen/loadEPW.c
(Generate patch)

Comparing ray/src/gen/loadEPW.c (file contents):
Revision 2.3 by greg, Tue Mar 4 17:45:41 2025 UTC vs.
Revision 2.7 by greg, Fri Aug 22 00:08:45 2025 UTC

# Line 210 | Line 210 | EPWopen(const char *fname)
210                  goto badformat;
211          if (hdr->isWEA) {               /* getting WEA header */
212                  cp = linbuf+6;
213 <                if (sscanf(cp, "%[^_]_%[^\r\n]q",
214 <                                hdr->loc.city, hdr->loc.country) != 2)
213 >                if (sscanf(cp, "%[^_]_%[^\r\n]",
214 >                                hdr->loc.city, hdr->loc.country) < 1)
215                          goto badformat;
216                  if (!fgets(linbuf, sizeof(linbuf), hdr->fp))
217                          goto readerr;
# Line 295 | Line 295 | EPWopen(const char *fname)
295                  hdr->comments1 = (char *)malloc(n);
296                  if (hdr->comments1 == NULL)
297                          goto memerr;
298 <                memcpy(hdr->comments1, linbuf+11, n);
299 <                hdr->comments1[n] = '\0';
298 >                memcpy(hdr->comments1, linbuf+11, n-1);
299 >                hdr->comments1[n-1] = '\0';
300          }
301          if (!fgets(linbuf, sizeof(linbuf), hdr->fp))
302                  goto readerr;
# Line 308 | Line 308 | EPWopen(const char *fname)
308                  hdr->comments2 = (char *)malloc(n);
309                  if (hdr->comments2 == NULL)
310                          goto memerr;
311 <                memcpy(hdr->comments2, linbuf+11, n);
312 <                hdr->comments2[n] = '\0';
311 >                memcpy(hdr->comments2, linbuf+11, n-1);
312 >                hdr->comments2[n-1] = '\0';
313          }
314          if (!fgets(linbuf, sizeof(linbuf), hdr->fp))
315                  goto readerr;
# Line 512 | Line 512 | EPWread(EPWheader *epw, EPWrecord *rp)
512          }
513          if (!cp++) goto badformat;
514          if (*cp != ',') {
515 <                rp->diffillum = atof(cp);
516 <                if (rp->diffillum >= 999900.f)
517 <                        rp->diffillum = EPWrecInit.diffillum;
515 >                rp->dirillum = atof(cp);
516 >                if (rp->dirillum >= 999900.f)
517 >                        rp->dirillum = EPWrecInit.dirillum;
518                  cp = strchr(cp, ',');
519          }
520          if (!cp++) goto badformat;
521          if (*cp != ',') {
522 <                rp->dirillum = atof(cp);
523 <                if (rp->dirillum >= 999900.f)
524 <                        rp->dirillum = EPWrecInit.dirillum;
522 >                rp->diffillum = atof(cp);
523 >                if (rp->diffillum >= 999900.f)
524 >                        rp->diffillum = EPWrecInit.diffillum;
525                  cp = strchr(cp, ',');
526          }
527          if (!cp++) goto badformat;
# Line 585 | Line 585 | EPWread(EPWheader *epw, EPWrecord *rp)
585                  rp->nosnowdays = atoi(cp);
586                  cp = strchr(cp, ',');
587          }
588 <        if (!cp++) goto badformat;
588 >        if (!cp++) goto skiprest;
589          if (*cp != ',') {
590                  rp->albedo = atof(cp);
591                  cp = strchr(cp, ',');
592          }
593 <        if (!cp++) goto badformat;
593 >        if (!cp++) goto skiprest;
594          if (*cp != ',') {
595                  rp->liqpdepth = atof(cp) * 1e-3;
596                  cp = strchr(cp, ',');
597          }
598 <        if (!cp++) goto badformat;
598 >        if (!cp++) goto skiprest;
599          if ((*cp != ',') & (*cp != '\n'))
600                  rp->liqhours = atof(cp);
601 + skiprest:
602          if (scan_date(epw) || feof(epw->fp))
603                  return(1);      /* normal return (even if next is EOF) */
604   badformat:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines