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.18 by greg, Thu May 11 20:17:33 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);
# Line 733 | Line 746 | char   **av;
746          static char     *p4ent[5] = {mg_ename[MG_E_POINT],p4[0],p4[1],p4[2]};
747          static char     *n4ent[5] = {mg_ename[MG_E_NORMAL],n4[0],n4[1],n4[2]};
748          static char     *fent[6] = {mg_ename[MG_E_FACE],"_cv1","_cv2","_cv3","_cv4"};
749 +        char    *v1n;
750          register C_VERTEX       *cv1, *cv2;
751          register int    i, j;
752          FVECT   u, v, w;
# Line 748 | Line 762 | char   **av;
762          if ((cv1 = c_getvert(av[1])) == NULL ||
763                          (cv2 = c_getvert(av[3])) == NULL)
764                  return(MG_EUNDEF);
765 +        v1n = av[1];
766          if (!isflt(av[2]) || !isflt(av[4]))
767                  return(MG_ETYPE);
768          rad1 = atof(av[2]);
# Line 766 | Line 781 | char   **av;
781                  cv = cv1;
782                  cv1 = cv2;
783                  cv2 = cv;
784 +                v1n = av[3];
785                  d = rad1;
786                  rad1 = rad2;
787                  rad2 = d;
# Line 799 | Line 815 | char   **av;
815          if ((rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
816                  return(rv);
817          if (rad1 == 0.) {               /* triangles */
818 <                v1ent[3] = av[1];
818 >                v1ent[3] = v1n;
819                  if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
820                          return(rv);
821                  for (j = 0; j < 3; j++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines