--- ray/src/cv/mgflib/parser.c 1995/03/07 14:53:23 1.13 +++ ray/src/cv/mgflib/parser.c 1995/05/09 14:38:22 1.17 @@ -1,4 +1,4 @@ -/* Copyright (c) 1994 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -89,82 +89,83 @@ mg_init() /* initialize alternate entity handlers */ mg_ehand[MG_E_INCLUDE] = e_include; if (mg_ehand[MG_E_SPH] == NULL) { mg_ehand[MG_E_SPH] = e_sph; - ineed |= 1<fid = ++nfids; @@ -231,14 +231,11 @@ char *fn; return(MG_OK); } /* get name relative to this context */ - if (mg_file != NULL && - (cp = strrchr(mg_file->fname, '/')) != NULL) - olen = cp - mg_file->fname + 1; - else - olen = 0; - if (olen) + if (mg_file != NULL && (cp = strrchr(mg_file->fname, '/')) != NULL) { strcpy(ctx->fname, mg_file->fname); - strcpy(ctx->fname+olen, fn); + strcpy(ctx->fname+(cp-mg_file->fname+1), fn); + } else + strcpy(ctx->fname, fn); ctx->fp = fopen(ctx->fname, "r"); if (ctx->fp == NULL) return(MG_ENOFILE); @@ -389,6 +386,7 @@ char **av; { char *xfarg[MG_MAXARGC]; MG_FCTXT ictx; + XF_SPEC *xf_orig = xf_context; int rv; if (ac < 2) @@ -405,7 +403,7 @@ char **av; if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK) return(rv); } - while (!feof(mg_file->fp)) { + do { while (mg_read()) if ((rv = mg_parse()) != MG_OK) { fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname, @@ -417,7 +415,7 @@ char **av; if (ac > 2) if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK) return(rv); - } + } while (xf_context != xf_orig); mg_close(); return(MG_OK); } @@ -1004,7 +1002,7 @@ put_cspec() /* put out current color spectrum */ newav[2] = wl[1]; sf = (double)C_CNSS / c_ccolor->ssum; for (i = 0; i < C_CNSS; i++) { - sprintf(vbuf[i], "%.6f", sf*c_ccolor->ssamp[i]); + sprintf(vbuf[i], "%.4f", sf*c_ccolor->ssamp[i]); newav[i+3] = vbuf[i]; } newav[C_CNSS+3] = NULL;