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

Comparing ray/src/cv/mgflib/parser.c (file contents):
Revision 1.19 by greg, Fri Oct 27 15:47:18 1995 UTC vs.
Revision 1.20 by greg, Wed Nov 8 09:40:22 1995 UTC

# Line 348 | Line 348 | mg_load(fn)                    /* load an MGF file */
348   char    *fn;
349   {
350          MG_FCTXT        cntxt;
351 <        int     rval;
351 >        register int    rval;
352  
353          if ((rval = mg_open(&cntxt, fn)) != MG_OK) {
354                  fprintf(stderr, "%s: %s\n", fn, mg_err[rval]);
355                  return(rval);
356          }
357 <        while (mg_read())               /* parse each line */
357 >        while ((rval = mg_read()) > 0) {        /* parse each line */
358 >                if (rval >= MG_MAXLINE-1 && cntxt.inpline[rval-1] != '\n') {
359 >                        fprintf(stderr, "%s: %d: %s\n", cntxt.fname,
360 >                                        cntxt.lineno, mg_err[rval=MG_ELINE]);
361 >                        break;
362 >                }
363                  if ((rval = mg_parse()) != MG_OK) {
364                          fprintf(stderr, "%s: %d: %s:\n%s", cntxt.fname,
365                                          cntxt.lineno, mg_err[rval],
366                                          cntxt.inpline);
367                          break;
368                  }
369 +        }
370          mg_close();
371          return(rval);
372   }
# Line 408 | Line 414 | char   **av;
414          char    *xfarg[MG_MAXARGC];
415          MG_FCTXT        ictx;
416          XF_SPEC *xf_orig = xf_context;
417 <        int     rv;
417 >        register int    rv;
418  
419          if (ac < 2)
420                  return(MG_EARGC);
# Line 425 | Line 431 | char   **av;
431                          return(rv);
432          }
433          do {
434 <                while (mg_read())
434 >                while ((rv = mg_read()) > 0) {
435 >                        if (rv >= MG_MAXLINE-1 && ictx.inpline[rv-1] != '\n') {
436 >                                fprintf(stderr, "%s: %d: %s\n", ictx.fname,
437 >                                                ictx.lineno, mg_err[MG_ELINE]);
438 >                                mg_close();
439 >                                return(MG_EINCL);
440 >                        }
441                          if ((rv = mg_parse()) != MG_OK) {
442                                  fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname,
443                                                  ictx.lineno, mg_err[rv],
# Line 433 | Line 445 | char   **av;
445                                  mg_close();
446                                  return(MG_EINCL);
447                          }
448 +                }
449                  if (ac > 2)
450                          if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK)
451                                  return(rv);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines