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.5 by greg, Fri Jun 24 09:40:29 1994 UTC vs.
Revision 1.19 by greg, Fri Oct 27 15:47:18 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 27 | Line 27 | char   mg_ename[MG_NENTITIES][MG_MAXELEN] = MG_NAMELIST;
27  
28   int     (*mg_ehand[MG_NENTITIES])();
29  
30 +                        /* Handler routine for unknown entities */
31 +
32 + int     (*mg_uhand)() = mg_defuhand;
33 +
34 + unsigned        mg_nunknown;    /* count of unknown entities */
35 +
36                          /* error messages */
37  
38   char    *mg_err[MG_NERRS] = MG_ERRLIST;
# Line 53 | Line 59 | int    mg_nqcdivs = MG_NQCD;   /* number of divisions per q
59  
60   /* temporary settings for testing */
61   #define e_ies e_any_toss
56 #define e_cmix e_any_toss
57 #define e_cspec e_any_toss
62                                  /* alternate handler routines */
63  
64   static int      e_any_toss(),           /* discard unneeded entity */
65                  e_ies(),                /* IES luminaire file */
66                  e_include(),            /* include file */
67                  e_sph(),                /* sphere */
68 +                e_cct(),                /* color temperature */
69                  e_cmix(),               /* color mixtures */
70 <                e_cspec();              /* color spectra */
70 >                e_cspec(),              /* color spectra */
71                  e_cyl(),                /* cylinder */
72                  e_cone(),               /* cone */
73                  e_prism(),              /* prism */
# Line 90 | Line 95 | mg_init()                      /* initialize alternate entity handlers */
95                  mg_ehand[MG_E_INCLUDE] = e_include;
96          if (mg_ehand[MG_E_SPH] == NULL) {
97                  mg_ehand[MG_E_SPH] = e_sph;
98 <                ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX;
98 >                ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX;
99          } else
100 <                uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF;
100 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF;
101          if (mg_ehand[MG_E_CYL] == NULL) {
102                  mg_ehand[MG_E_CYL] = e_cyl;
103 <                ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX;
103 >                ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX;
104          } else
105 <                uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF;
105 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF;
106          if (mg_ehand[MG_E_CONE] == NULL) {
107                  mg_ehand[MG_E_CONE] = e_cone;
108 <                ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX;
108 >                ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX;
109          } else
110 <                uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF;
110 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF;
111          if (mg_ehand[MG_E_RING] == NULL) {
112                  mg_ehand[MG_E_RING] = e_ring;
113 <                ineed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX;
113 >                ineed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX;
114          } else
115 <                uneed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX|1<<MG_E_XF;
115 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX|1L<<MG_E_XF;
116          if (mg_ehand[MG_E_PRISM] == NULL) {
117                  mg_ehand[MG_E_PRISM] = e_prism;
118 <                ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX;
118 >                ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX;
119          } else
120 <                uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF;
120 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF;
121          if (mg_ehand[MG_E_TORUS] == NULL) {
122                  mg_ehand[MG_E_TORUS] = e_torus;
123 <                ineed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX;
123 >                ineed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX;
124          } else
125 <                uneed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX|1<<MG_E_XF;
125 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX|1L<<MG_E_XF;
126          if (mg_ehand[MG_E_COLOR] != NULL) {
127 <                if (mg_ehand[MG_E_CMIX] == NULL)
127 >                if (mg_ehand[MG_E_CMIX] == NULL) {
128                          mg_ehand[MG_E_CMIX] = e_cmix;
129 <                if (mg_ehand[MG_E_CSPEC] == NULL)
129 >                        ineed |= 1L<<MG_E_COLOR|1L<<MG_E_CXY|1L<<MG_E_CSPEC|1L<<MG_E_CMIX|1L<<MG_E_CCT;
130 >                }
131 >                if (mg_ehand[MG_E_CSPEC] == NULL) {
132                          mg_ehand[MG_E_CSPEC] = e_cspec;
133 +                        ineed |= 1L<<MG_E_COLOR|1L<<MG_E_CXY|1L<<MG_E_CSPEC|1L<<MG_E_CMIX|1L<<MG_E_CCT;
134 +                }
135 +                if (mg_ehand[MG_E_CCT] == NULL) {
136 +                        mg_ehand[MG_E_CCT] = e_cct;
137 +                        ineed |= 1L<<MG_E_COLOR|1L<<MG_E_CXY|1L<<MG_E_CSPEC|1L<<MG_E_CMIX|1L<<MG_E_CCT;
138 +                }
139          }
140                                          /* check for consistency */
141          if (mg_ehand[MG_E_FACE] != NULL)
142 <                uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF;
143 <        if (mg_ehand[MG_E_CXY] != NULL)
144 <                uneed |= 1<<MG_E_COLOR;
142 >                uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF;
143 >        if (mg_ehand[MG_E_CXY] != NULL || mg_ehand[MG_E_CSPEC] != NULL ||
144 >                        mg_ehand[MG_E_CMIX] != NULL)
145 >                uneed |= 1L<<MG_E_COLOR;
146          if (mg_ehand[MG_E_RD] != NULL || mg_ehand[MG_E_TD] != NULL ||
147 +                        mg_ehand[MG_E_IR] != NULL ||
148                          mg_ehand[MG_E_ED] != NULL ||
149                          mg_ehand[MG_E_RS] != NULL ||
150 <                        mg_ehand[MG_E_TS] != NULL)
151 <                uneed |= 1<<MG_E_MATERIAL;
150 >                        mg_ehand[MG_E_TS] != NULL ||
151 >                        mg_ehand[MG_E_SIDES] != NULL)
152 >                uneed |= 1L<<MG_E_MATERIAL;
153          for (i = 0; i < MG_NENTITIES; i++)
154 <                if (uneed & 1<<i && mg_ehand[i] == NULL) {
154 >                if (uneed & 1L<<i && mg_ehand[i] == NULL) {
155                          fprintf(stderr, "Missing support for \"%s\" entity\n",
156                                          mg_ename[i]);
157                          exit(1);
158                  }
159                                          /* add support as needed */
160 <        if (ineed & 1<<MG_E_VERTEX && mg_ehand[MG_E_VERTEX] != c_hvertex)
160 >        if (ineed & 1L<<MG_E_VERTEX && mg_ehand[MG_E_VERTEX] != c_hvertex)
161                  e_supp[MG_E_VERTEX] = c_hvertex;
162 <        if (ineed & 1<<MG_E_POINT && mg_ehand[MG_E_POINT] != c_hvertex)
162 >        if (ineed & 1L<<MG_E_POINT && mg_ehand[MG_E_POINT] != c_hvertex)
163                  e_supp[MG_E_POINT] = c_hvertex;
164 <        if (ineed & 1<<MG_E_NORMAL && mg_ehand[MG_E_NORMAL] != c_hvertex)
164 >        if (ineed & 1L<<MG_E_NORMAL && mg_ehand[MG_E_NORMAL] != c_hvertex)
165                  e_supp[MG_E_NORMAL] = c_hvertex;
166 +        if (ineed & 1L<<MG_E_COLOR && mg_ehand[MG_E_COLOR] != c_hcolor)
167 +                e_supp[MG_E_COLOR] = c_hcolor;
168 +        if (ineed & 1L<<MG_E_CXY && mg_ehand[MG_E_CXY] != c_hcolor)
169 +                e_supp[MG_E_CXY] = c_hcolor;
170 +        if (ineed & 1L<<MG_E_CSPEC && mg_ehand[MG_E_CSPEC] != c_hcolor)
171 +                e_supp[MG_E_CSPEC] = c_hcolor;
172 +        if (ineed & 1L<<MG_E_CMIX && mg_ehand[MG_E_CMIX] != c_hcolor)
173 +                e_supp[MG_E_CMIX] = c_hcolor;
174 +        if (ineed & 1L<<MG_E_CCT && mg_ehand[MG_E_CCT] != c_hcolor)
175 +                e_supp[MG_E_CCT] = c_hcolor;
176                                          /* discard remaining entities */
177          for (i = 0; i < MG_NENTITIES; i++)
178                  if (mg_ehand[i] == NULL)
# Line 154 | Line 180 | mg_init()                      /* initialize alternate entity handlers */
180   }
181  
182  
157
183   int
184   mg_entity(name)                 /* get entity number from its name */
185   char    *name;
186   {
187 <        static LUTAB    ent_tab;        /* entity lookup table */
187 >        static LUTAB    ent_tab = LU_SINIT(NULL,NULL);  /* lookup table */
188          register char   *cp;
189  
190          if (!ent_tab.tsiz) {            /* initialize hash table */
# Line 176 | Line 201 | char   *name;
201   }
202  
203  
204 < static int
205 < handle_it(en, ac, av)           /* pass entity to appropriate handler */
204 > int
205 > mg_handle(en, ac, av)           /* pass entity to appropriate handler */
206   register int    en;
207   int     ac;
208   char    **av;
209   {
210          int     rv;
211  
212 <        if (en < 0 && (en = mg_entity(av[0])) < 0)
212 >        if (en < 0 && (en = mg_entity(av[0])) < 0) {    /* unknown entity */
213 >                if (mg_uhand != NULL)
214 >                        return((*mg_uhand)(ac, av));
215                  return(MG_EUNK);
216 <        if (e_supp[en] != NULL) {
216 >        }
217 >        if (e_supp[en] != NULL) {                       /* support handler */
218                  if ((rv = (*e_supp[en])(ac, av)) != MG_OK)
219                          return(rv);
220          }
221 <        return((*mg_ehand[en])(ac, av));
221 >        return((*mg_ehand[en])(ac, av));                /* assigned handler */
222   }
223  
224  
# Line 199 | Line 227 | mg_open(ctx, fn)                       /* open new input file */
227   register MG_FCTXT       *ctx;
228   char    *fn;
229   {
230 <        int     olen;
230 >        static int      nfids;
231          register char   *cp;
232  
233 +        ctx->fid = ++nfids;
234          ctx->lineno = 0;
235          if (fn == NULL) {
236 <                ctx->fname = "<stdin>";
236 >                strcpy(ctx->fname, "<stdin>");
237                  ctx->fp = stdin;
238                  ctx->prev = mg_file;
239                  mg_file = ctx;
240                  return(MG_OK);
241          }
242                                          /* get name relative to this context */
243 <        if (mg_file != NULL &&
215 <                        (cp = strrchr(mg_file->fname, '/')) != NULL)
216 <                olen = cp - mg_file->fname + 1;
217 <        else
218 <                olen = 0;
219 <        ctx->fname = (char *)malloc(olen+strlen(fn)+1);
220 <        if (ctx->fname == NULL)
221 <                return(MG_EMEM);
222 <        if (olen)
243 >        if (mg_file != NULL && (cp = strrchr(mg_file->fname, '/')) != NULL) {
244                  strcpy(ctx->fname, mg_file->fname);
245 <        strcpy(ctx->fname+olen, fn);
245 >                strcpy(ctx->fname+(cp-mg_file->fname+1), fn);
246 >        } else
247 >                strcpy(ctx->fname, fn);
248          ctx->fp = fopen(ctx->fname, "r");
249 <        if (ctx->fp == NULL) {
227 <                free((MEM_PTR)ctx->fname);
249 >        if (ctx->fp == NULL)
250                  return(MG_ENOFILE);
229        }
251          ctx->prev = mg_file;            /* establish new context */
252          mg_file = ctx;
253          return(MG_OK);
# Line 242 | Line 263 | mg_close()                     /* close input file */
263          if (ctx->fp == stdin)
264                  return;                 /* don't close standard input */
265          fclose(ctx->fp);
245        free((MEM_PTR)ctx->fname);
266   }
267  
268  
269 + void
270 + mg_fgetpos(pos)                 /* get current position in input file */
271 + register MG_FPOS        *pos;
272 + {
273 +        extern long     ftell();
274 +
275 +        pos->fid = mg_file->fid;
276 +        pos->lineno = mg_file->lineno;
277 +        pos->offset = ftell(mg_file->fp);
278 + }
279 +
280 +
281   int
282 < mg_rewind()                     /* rewind input file */
282 > mg_fgoto(pos)                   /* reposition input file pointer */
283 > register MG_FPOS        *pos;
284   {
285 <        if (mg_file->lineno == 0)
285 >        if (pos->fid != mg_file->fid)
286 >                return(MG_ESEEK);
287 >        if (pos->lineno == mg_file->lineno)
288                  return(MG_OK);
289          if (mg_file->fp == stdin)
290                  return(MG_ESEEK);       /* cannot seek on standard input */
291 <        if (fseek(mg_file->fp, 0L, 0) == EOF)
291 >        if (fseek(mg_file->fp, pos->offset, 0) == EOF)
292                  return(MG_ESEEK);
293 <        mg_file->lineno = 0;
293 >        mg_file->lineno = pos->lineno;
294          return(MG_OK);
295   }
296  
# Line 304 | Line 339 | mg_parse()                     /* parse current input line */
339                  return(MG_OK);          /* no words in line */
340          *ap = NULL;
341                                          /* else handle it */
342 <        return(handle_it(-1, ap-argv, argv));
342 >        return(mg_handle(-1, ap-argv, argv));
343   }
344  
345  
# Line 331 | Line 366 | char   *fn;
366   }
367  
368  
369 + int
370 + mg_defuhand(ac, av)             /* default handler for unknown entities */
371 + int     ac;
372 + char    **av;
373 + {
374 +        if (mg_nunknown++ == 0)         /* report first incident */
375 +                fprintf(stderr, "%s: %d: %s: %s\n", mg_file->fname,
376 +                                mg_file->lineno, mg_err[MG_EUNK], av[0]);
377 +        return(MG_OK);
378 + }
379 +
380 +
381   void
382   mg_clear()                      /* clear parser history */
383   {
# Line 339 | Line 386 | mg_clear()                     /* clear parser history */
386   }
387  
388  
342 int
343 mg_iterate(ac, av, f)           /* iterate on statement */
344 int     ac;
345 register char   **av;
346 int     (*f)();
347 {
348        int     niter, rval;
349        register int    i, j;
350        char    *argv[MG_MAXARGC];
351        char    cntbuf[10];
352                                        /* build partial transformation */
353        for (i = 0; i < ac; i++) {
354                if (av[i][0] == '-' && av[i][1] == 'a' && av[i][2] == '\0')
355                        break;
356                argv[i+1] = av[i];
357        }
358        argv[i+1] = NULL;
359        if (i) {                        /* handle transformation */
360                argv[0] = mg_ename[MG_E_XF];
361                if ((rval = handle_it(MG_E_XF, i+1, argv)) != MG_OK)
362                        return(rval);
363        }
364        if (i < ac) {                   /* run array */
365                if (i+1 >= ac || !isint(av[i+1]))
366                        return(MG_ETYPE);
367                niter = atoi(av[i+1]);
368                argv[0] = mg_ename[MG_E_OBJECT];
369                argv[1] = cntbuf;
370                for (j = 2; j+i < ac; j++)
371                        argv[j] = av[j+i];
372                argv[j] = NULL;
373                for (j = 0; j < niter; j++) {
374                        sprintf(cntbuf, "%d", j);
375                        if ((rval = handle_it(MG_E_OBJECT, 2, argv)) != MG_OK)
376                                return(rval);
377                        argv[0] = "-i";
378                        if ((rval = mg_iterate(ac-i, argv, f)) != MG_OK)
379                                return(rval);
380                        argv[0] = mg_ename[MG_E_OBJECT];
381                        if ((rval = handle_it(MG_E_OBJECT, 1, argv)) != MG_OK)
382                                return(rval);
383                }
384        } else if ((rval = (*f)()) != MG_OK)    /* else do this instance */
385                        return(rval);
386        if (i) {                        /* reset the transform */
387                argv[0] = mg_ename[MG_E_XF];
388                argv[1] = NULL;
389                (void)handle_it(MG_E_XF, 1, argv);
390        }
391        return(MG_OK);
392 }
393
394
389   /****************************************************************************
390   *      The following routines handle unsupported entities
391   */
# Line 407 | Line 401 | char   **av;
401  
402  
403   static int
410 reload_file()                   /* reload current MGF file */
411 {
412        register int    rval;
413
414        if ((rval = mg_rewind()) != MG_OK)
415                return(rval);
416        while (mg_read())
417                if ((rval = mg_parse()) != MG_OK)
418                        return(rval);
419        return(MG_OK);
420 }
421
422
423 static int
404   e_include(ac, av)               /* include file */
405   int     ac;
406   char    **av;
407   {
408 +        char    *xfarg[MG_MAXARGC];
409          MG_FCTXT        ictx;
410 +        XF_SPEC *xf_orig = xf_context;
411          int     rv;
412  
413          if (ac < 2)
414                  return(MG_EARGC);
415          if ((rv = mg_open(&ictx, av[1])) != MG_OK)
416                  return(rv);
417 <        if ((rv = mg_iterate(ac-2, av+2, reload_file)) != MG_OK) {
418 <                fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname,
419 <                                ictx.lineno, mg_err[rv], ictx.inpline);
420 <                mg_close();
421 <                return(MG_EINCL);
417 >        if (ac > 2) {
418 >                register int    i;
419 >
420 >                xfarg[0] = mg_ename[MG_E_XF];
421 >                for (i = 1; i < ac-1; i++)
422 >                        xfarg[i] = av[i+1];
423 >                xfarg[ac-1] = NULL;
424 >                if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK)
425 >                        return(rv);
426          }
427 +        do {
428 +                while (mg_read())
429 +                        if ((rv = mg_parse()) != MG_OK) {
430 +                                fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname,
431 +                                                ictx.lineno, mg_err[rv],
432 +                                                ictx.inpline);
433 +                                mg_close();
434 +                                return(MG_EINCL);
435 +                        }
436 +                if (ac > 2)
437 +                        if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK)
438 +                                return(rv);
439 +        } while (xf_context != xf_orig);
440          mg_close();
441          return(MG_OK);
442   }
# Line 485 | Line 484 | char   **av;
484          rad = atof(av[2]);
485                                          /* initialize */
486          warpconends = 1;
487 <        if ((rval = handle_it(MG_E_VERTEX, 3, v2ent)) != MG_OK)
487 >        if ((rval = mg_handle(MG_E_VERTEX, 3, v2ent)) != MG_OK)
488                  return(rval);
489          sprintf(p2x, FLTFMT, cv->p[0]);
490          sprintf(p2y, FLTFMT, cv->p[1]);
491          sprintf(p2z, FLTFMT, cv->p[2]+rad);
492 <        if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
492 >        if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
493                  return(rval);
494          r2[0] = '0'; r2[1] = '\0';
495          for (i = 1; i <= 2*mg_nqcdivs; i++) {
496                  theta = i*(PI/2)/mg_nqcdivs;
497 <                if ((rval = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
497 >                if ((rval = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
498                          return(rval);
499                  sprintf(p2z, FLTFMT, cv->p[2]+rad*cos(theta));
500 <                if ((rval = handle_it(MG_E_VERTEX, 2, v2ent)) != MG_OK)
500 >                if ((rval = mg_handle(MG_E_VERTEX, 2, v2ent)) != MG_OK)
501                          return(rval);
502 <                if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
502 >                if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
503                          return(rval);
504                  strcpy(r1, r2);
505                  sprintf(r2, FLTFMT, rad*sin(theta));
506 <                if ((rval = handle_it(MG_E_CONE, 5, conent)) != MG_OK)
506 >                if ((rval = mg_handle(MG_E_CONE, 5, conent)) != MG_OK)
507                          return(rval);
508          }
509          warpconends = 0;
# Line 559 | Line 558 | char   **av;
558          for (j = 0; j < 3; j++)
559                  sprintf(p2[j], FLTFMT, cv->p[j] +
560                                  .5*sgn*(maxrad-minrad)*cv->n[j]);
561 <        if ((rval = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
561 >        if ((rval = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
562                  return(rval);
563 <        if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
563 >        if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
564                  return(rval);
565          sprintf(r2, FLTFMT, avgrad=.5*(minrad+maxrad));
566                                          /* run outer section */
567          for (i = 1; i <= 2*mg_nqcdivs; i++) {
568                  theta = i*(PI/2)/mg_nqcdivs;
569 <                if ((rval = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
569 >                if ((rval = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
570                          return(rval);
571                  for (j = 0; j < 3; j++)
572                          sprintf(p2[j], FLTFMT, cv->p[j] +
573                                  .5*sgn*(maxrad-minrad)*cos(theta)*cv->n[j]);
574 <                if ((rval = handle_it(MG_E_VERTEX, 2, v2ent)) != MG_OK)
574 >                if ((rval = mg_handle(MG_E_VERTEX, 2, v2ent)) != MG_OK)
575                          return(rval);
576 <                if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
576 >                if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
577                          return(rval);
578                  strcpy(r1, r2);
579                  sprintf(r2, FLTFMT, avgrad + .5*(maxrad-minrad)*sin(theta));
580 <                if ((rval = handle_it(MG_E_CONE, 5, conent)) != MG_OK)
580 >                if ((rval = mg_handle(MG_E_CONE, 5, conent)) != MG_OK)
581                          return(rval);
582          }
583                                          /* run inner section */
# Line 588 | Line 587 | char   **av;
587                  for (j = 0; j < 3; j++)
588                          sprintf(p2[j], FLTFMT, cv->p[j] +
589                                  .5*sgn*(maxrad-minrad)*cos(theta)*cv->n[j]);
590 <                if ((rval = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
590 >                if ((rval = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
591                          return(rval);
592 <                if ((rval = handle_it(MG_E_VERTEX, 2, v2ent)) != MG_OK)
592 >                if ((rval = mg_handle(MG_E_VERTEX, 2, v2ent)) != MG_OK)
593                          return(rval);
594 <                if ((rval = handle_it(MG_E_POINT, 4, p2ent)) != MG_OK)
594 >                if ((rval = mg_handle(MG_E_POINT, 4, p2ent)) != MG_OK)
595                          return(rval);
596                  strcpy(r1, r2);
597                  sprintf(r2, FLTFMT, -avgrad - .5*(maxrad-minrad)*sin(theta));
598 <                if ((rval = handle_it(MG_E_CONE, 5, conent)) != MG_OK)
598 >                if ((rval = mg_handle(MG_E_CONE, 5, conent)) != MG_OK)
599                          return(rval);
600          }
601          warpconends = 0;
# Line 617 | Line 616 | char   **av;
616          avnew[2] = av[2];
617          avnew[3] = av[3];
618          avnew[4] = av[2];
619 <        return(handle_it(MG_E_CONE, 5, avnew));
619 >        return(mg_handle(MG_E_CONE, 5, avnew));
620   }
621  
622  
# Line 659 | Line 658 | char   **av;
658          make_axes(u, v, cv->n);
659          for (j = 0; j < 3; j++)
660                  sprintf(p3[j], FLTFMT, cv->p[j] + maxrad*u[j]);
661 <        if ((rv = handle_it(MG_E_VERTEX, 3, v3ent)) != MG_OK)
661 >        if ((rv = mg_handle(MG_E_VERTEX, 3, v3ent)) != MG_OK)
662                  return(rv);
663 <        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
663 >        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
664                  return(rv);
665          if (minrad == 0.) {             /* closed */
666                  v1ent[3] = av[1];
667 <                if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
667 >                if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
668                          return(rv);
669 <                if ((rv = handle_it(MG_E_NORMAL, 4, nzent)) != MG_OK)
669 >                if ((rv = mg_handle(MG_E_NORMAL, 4, nzent)) != MG_OK)
670                          return(rv);
671                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
672                          theta = i*(PI/2)/mg_nqcdivs;
673 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
673 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
674                                  return(rv);
675                          for (j = 0; j < 3; j++)
676                                  sprintf(p3[j], FLTFMT, cv->p[j] +
677                                                  maxrad*u[j]*cos(theta) +
678                                                  maxrad*v[j]*sin(theta));
679 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
679 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
680                                  return(rv);
681 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
681 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
682                                  return(rv);
683 <                        if ((rv = handle_it(MG_E_FACE, 4, fent)) != MG_OK)
683 >                        if ((rv = mg_handle(MG_E_FACE, 4, fent)) != MG_OK)
684                                  return(rv);
685                  }
686          } else {                        /* open */
687 <                if ((rv = handle_it(MG_E_VERTEX, 3, v4ent)) != MG_OK)
687 >                if ((rv = mg_handle(MG_E_VERTEX, 3, v4ent)) != MG_OK)
688                          return(rv);
689                  for (j = 0; j < 3; j++)
690                          sprintf(p4[j], FLTFMT, cv->p[j] + minrad*u[j]);
691 <                if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
691 >                if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
692                          return(rv);
693                  v1ent[3] = "_rv4";
694                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
695                          theta = i*(PI/2)/mg_nqcdivs;
696 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
696 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
697                                  return(rv);
698 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
698 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
699                                  return(rv);
700                          for (j = 0; j < 3; j++) {
701                                  d = u[j]*cos(theta) + v[j]*sin(theta);
702                                  sprintf(p3[j], FLTFMT, cv->p[j] + maxrad*d);
703                                  sprintf(p4[j], FLTFMT, cv->p[j] + minrad*d);
704                          }
705 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
705 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
706                                  return(rv);
707 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
707 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
708                                  return(rv);
709 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v4ent)) != MG_OK)
709 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v4ent)) != MG_OK)
710                                  return(rv);
711 <                        if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
711 >                        if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
712                                  return(rv);
713 <                        if ((rv = handle_it(MG_E_FACE, 5, fent)) != MG_OK)
713 >                        if ((rv = mg_handle(MG_E_FACE, 5, fent)) != MG_OK)
714                                  return(rv);
715                  }
716          }
# Line 734 | Line 733 | char   **av;
733          static char     *p4ent[5] = {mg_ename[MG_E_POINT],p4[0],p4[1],p4[2]};
734          static char     *n4ent[5] = {mg_ename[MG_E_NORMAL],n4[0],n4[1],n4[2]};
735          static char     *fent[6] = {mg_ename[MG_E_FACE],"_cv1","_cv2","_cv3","_cv4"};
736 +        char    *v1n;
737          register C_VERTEX       *cv1, *cv2;
738          register int    i, j;
739          FVECT   u, v, w;
# Line 749 | Line 749 | char   **av;
749          if ((cv1 = c_getvert(av[1])) == NULL ||
750                          (cv2 = c_getvert(av[3])) == NULL)
751                  return(MG_EUNDEF);
752 +        v1n = av[1];
753          if (!isflt(av[2]) || !isflt(av[4]))
754                  return(MG_ETYPE);
755          rad1 = atof(av[2]);
# Line 767 | Line 768 | char   **av;
768                  cv = cv1;
769                  cv1 = cv2;
770                  cv2 = cv;
771 +                v1n = av[3];
772                  d = rad1;
773                  rad1 = rad2;
774                  rad2 = d;
# Line 793 | Line 795 | char   **av;
795                  else
796                          sprintf(n3[j], FLTFMT, u[j] + w[j]*n2off);
797          }
798 <        if ((rv = handle_it(MG_E_VERTEX, 3, v3ent)) != MG_OK)
798 >        if ((rv = mg_handle(MG_E_VERTEX, 3, v3ent)) != MG_OK)
799                  return(rv);
800 <        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
800 >        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
801                  return(rv);
802 <        if ((rv = handle_it(MG_E_NORMAL, 4, n3ent)) != MG_OK)
802 >        if ((rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
803                  return(rv);
804          if (rad1 == 0.) {               /* triangles */
805 <                v1ent[3] = av[1];
806 <                if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
805 >                v1ent[3] = v1n;
806 >                if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
807                          return(rv);
808                  for (j = 0; j < 3; j++)
809                          sprintf(n4[j], FLTFMT, w[j]);
810 <                if ((rv = handle_it(MG_E_NORMAL, 4, n4ent)) != MG_OK)
810 >                if ((rv = mg_handle(MG_E_NORMAL, 4, n4ent)) != MG_OK)
811                          return(rv);
812                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
813                          theta = sgn*i*(PI/2)/mg_nqcdivs;
814 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
814 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
815                                  return(rv);
816                          for (j = 0; j < 3; j++) {
817                                  d = u[j]*cos(theta) + v[j]*sin(theta);
# Line 817 | Line 819 | char   **av;
819                                  if (n2off > -FHUGE)
820                                          sprintf(n3[j], FLTFMT, d + w[j]*n2off);
821                          }
822 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
822 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
823                                  return(rv);
824 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
824 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
825                                  return(rv);
826                          if (n2off > -FHUGE &&
827 <                        (rv = handle_it(MG_E_NORMAL, 4, n3ent)) != MG_OK)
827 >                        (rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
828                                  return(rv);
829 <                        if ((rv = handle_it(MG_E_FACE, 4, fent)) != MG_OK)
829 >                        if ((rv = mg_handle(MG_E_FACE, 4, fent)) != MG_OK)
830                                  return(rv);
831                  }
832          } else {                        /* quads */
# Line 843 | Line 845 | char   **av;
845                          else
846                                  sprintf(n4[j], FLTFMT, u[j] + w[j]*n1off);
847                  }
848 <                if ((rv = handle_it(MG_E_VERTEX, 3, v4ent)) != MG_OK)
848 >                if ((rv = mg_handle(MG_E_VERTEX, 3, v4ent)) != MG_OK)
849                          return(rv);
850 <                if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
850 >                if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
851                          return(rv);
852 <                if ((rv = handle_it(MG_E_NORMAL, 4, n4ent)) != MG_OK)
852 >                if ((rv = mg_handle(MG_E_NORMAL, 4, n4ent)) != MG_OK)
853                          return(rv);
854                  for (i = 1; i <= 4*mg_nqcdivs; i++) {
855                          theta = sgn*i*(PI/2)/mg_nqcdivs;
856 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v1ent)) != MG_OK)
856 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK)
857                                  return(rv);
858 <                        if ((rv = handle_it(MG_E_VERTEX, 4, v2ent)) != MG_OK)
858 >                        if ((rv = mg_handle(MG_E_VERTEX, 4, v2ent)) != MG_OK)
859                                  return(rv);
860                          for (j = 0; j < 3; j++) {
861                                  d = u[j]*cos(theta) + v[j]*sin(theta);
# Line 864 | Line 866 | char   **av;
866                                  if (n1off < FHUGE)
867                                          sprintf(n4[j], FLTFMT, d + w[j]*n1off);
868                          }
869 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v3ent)) != MG_OK)
869 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v3ent)) != MG_OK)
870                                  return(rv);
871 <                        if ((rv = handle_it(MG_E_POINT, 4, p3ent)) != MG_OK)
871 >                        if ((rv = mg_handle(MG_E_POINT, 4, p3ent)) != MG_OK)
872                                  return(rv);
873                          if (n2off > -FHUGE &&
874 <                        (rv = handle_it(MG_E_NORMAL, 4, n3ent)) != MG_OK)
874 >                        (rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK)
875                                  return(rv);
876 <                        if ((rv = handle_it(MG_E_VERTEX, 2, v4ent)) != MG_OK)
876 >                        if ((rv = mg_handle(MG_E_VERTEX, 2, v4ent)) != MG_OK)
877                                  return(rv);
878 <                        if ((rv = handle_it(MG_E_POINT, 4, p4ent)) != MG_OK)
878 >                        if ((rv = mg_handle(MG_E_POINT, 4, p4ent)) != MG_OK)
879                                  return(rv);
880                          if (n1off < FHUGE &&
881 <                        (rv = handle_it(MG_E_NORMAL, 4, n4ent)) != MG_OK)
881 >                        (rv = mg_handle(MG_E_NORMAL, 4, n4ent)) != MG_OK)
882                                  return(rv);
883 <                        if ((rv = handle_it(MG_E_FACE, 5, fent)) != MG_OK)
883 >                        if ((rv = mg_handle(MG_E_FACE, 5, fent)) != MG_OK)
884                                  return(rv);
885                  }
886          }
# Line 892 | Line 894 | int    ac;
894   char    **av;
895   {
896          static char     p[3][24];
897 <        static char     *vent[4] = {mg_ename[MG_E_VERTEX],NULL,"="};
897 >        static char     *vent[5] = {mg_ename[MG_E_VERTEX],NULL,"="};
898          static char     *pent[5] = {mg_ename[MG_E_POINT],p[0],p[1],p[2]};
899 +        static char     *znorm[5] = {mg_ename[MG_E_NORMAL],"0","0","0"};
900          char    *newav[MG_MAXARGC], nvn[MG_MAXARGC-1][8];
901          double  length;
902 +        int     hasnorm;
903          FVECT   v1, v2, v3, norm;
904          register C_VERTEX       *cv;
905          C_VERTEX        *cv0;
906          int     rv;
907          register int    i, j;
908 <
908 >                                                /* check arguments */
909          if (ac < 5)
910                  return(MG_EARGC);
911          if (!isflt(av[ac-1]))
# Line 909 | Line 913 | char   **av;
913          length = atof(av[ac-1]);
914          if (length <= FTINY && length >= -FTINY)
915                  return(MG_EILL);
916 <                                        /* do bottom face */
917 <        newav[0] = mg_ename[MG_E_FACE];
914 <        for (i = 1; i < ac-1; i++)
915 <                newav[i] = av[i];
916 <        newav[i] = NULL;
917 <        if ((rv = handle_it(MG_E_FACE, i, newav)) != MG_OK)
918 <                return(rv);
919 <                                        /* compute face normal */
920 <        if ((cv0 = c_getvert(av[2])) == NULL)
916 >                                                /* compute face normal */
917 >        if ((cv0 = c_getvert(av[1])) == NULL)
918                  return(MG_EUNDEF);
919 +        hasnorm = 0;
920          norm[0] = norm[1] = norm[2] = 0.;
921          v1[0] = v1[1] = v1[2] = 0.;
922          for (i = 2; i < ac-1; i++) {
923                  if ((cv = c_getvert(av[i])) == NULL)
924                          return(MG_EUNDEF);
925 +                hasnorm += !is0vect(cv->n);
926                  v2[0] = cv->p[0] - cv0->p[0];
927                  v2[1] = cv->p[1] - cv0->p[1];
928                  v2[2] = cv->p[2] - cv0->p[2];
# Line 935 | Line 934 | char   **av;
934          }
935          if (normalize(norm) == 0.)
936                  return(MG_EILL);
937 <                                        /* create moved vertices */
937 >                                                /* create moved vertices */
938          for (i = 1; i < ac-1; i++) {
939                  sprintf(nvn[i-1], "_pv%d", i);
940                  vent[1] = nvn[i-1];
941 <                if ((rv = handle_it(MG_E_VERTEX, 3, vent)) != MG_OK)
941 >                vent[3] = av[i];
942 >                if ((rv = mg_handle(MG_E_VERTEX, 4, vent)) != MG_OK)
943                          return(rv);
944                  cv = c_getvert(av[i]);          /* checked above */
945                  for (j = 0; j < 3; j++)
946                          sprintf(p[j], FLTFMT, cv->p[j] - length*norm[j]);
947 <                if ((rv = handle_it(MG_E_POINT, 4, pent)) != MG_OK)
947 >                if ((rv = mg_handle(MG_E_POINT, 4, pent)) != MG_OK)
948                          return(rv);
949                newav[ac-1-i] = nvn[i-1];       /* reverse */
949          }
950 <                                                /* do top face */
951 <        if ((rv = handle_it(MG_E_FACE, ac-1, newav)) != MG_OK)
953 <                return(rv);
950 >                                                /* make faces */
951 >        newav[0] = mg_ename[MG_E_FACE];
952                                                  /* do the side faces */
953          newav[5] = NULL;
954          newav[3] = av[ac-2];
# Line 958 | Line 956 | char   **av;
956          for (i = 1; i < ac-1; i++) {
957                  newav[1] = nvn[i-1];
958                  newav[2] = av[i];
959 <                if ((rv = handle_it(MG_E_FACE, 5, newav)) != MG_OK)
959 >                if ((rv = mg_handle(MG_E_FACE, 5, newav)) != MG_OK)
960                          return(rv);
961                  newav[3] = newav[2];
962                  newav[4] = newav[1];
963          }
964 +                                                /* do top face */
965 +        for (i = 1; i < ac-1; i++) {
966 +                if (hasnorm) {                  /* zero normals */
967 +                        vent[1] = nvn[i-1];
968 +                        if ((rv = mg_handle(MG_E_VERTEX, 2, vent)) != MG_OK)
969 +                                return(rv);
970 +                        if ((rv = mg_handle(MG_E_NORMAL, 4, znorm)) != MG_OK)
971 +                                return(rv);
972 +                }
973 +                newav[ac-1-i] = nvn[i-1];       /* reverse */
974 +        }
975 +        if ((rv = mg_handle(MG_E_FACE, ac-1, newav)) != MG_OK)
976 +                return(rv);
977 +                                                /* do bottom face */
978 +        if (hasnorm)
979 +                for (i = 1; i < ac-1; i++) {
980 +                        vent[1] = nvn[i-1];
981 +                        vent[3] = av[i];
982 +                        if ((rv = mg_handle(MG_E_VERTEX, 4, vent)) != MG_OK)
983 +                                return(rv);
984 +                        if ((rv = mg_handle(MG_E_NORMAL, 4, znorm)) != MG_OK)
985 +                                return(rv);
986 +                        newav[i] = nvn[i-1];
987 +                }
988 +        else
989 +                for (i = 1; i < ac-1; i++)
990 +                        newav[i] = av[i];
991 +        newav[i] = NULL;
992 +        if ((rv = mg_handle(MG_E_FACE, i, newav)) != MG_OK)
993 +                return(rv);
994 +        return(MG_OK);
995 + }
996 +
997 +
998 + static int
999 + put_cxy()                       /* put out current xy chromaticities */
1000 + {
1001 +        static char     xbuf[24], ybuf[24];
1002 +        static char     *ccom[4] = {mg_ename[MG_E_CXY], xbuf, ybuf};
1003 +        int     rv;
1004 +
1005 +        sprintf(xbuf, "%.4f", c_ccolor->cx);
1006 +        sprintf(ybuf, "%.4f", c_ccolor->cy);
1007 +        if ((rv = mg_handle(MG_E_CXY, 3, ccom)) != MG_OK)
1008 +                return(rv);
1009 +        return(MG_OK);
1010 + }
1011 +
1012 +
1013 + static int
1014 + put_cspec()                     /* put out current color spectrum */
1015 + {
1016 +        char    wl[2][6], vbuf[C_CNSS][24];
1017 +        char    *newav[C_CNSS+4];
1018 +        double  sf;
1019 +        register int    i;
1020 +
1021 +        if (mg_ehand[MG_E_CSPEC] != c_hcolor) {
1022 +                sprintf(wl[0], "%d", C_CMINWL);
1023 +                sprintf(wl[1], "%d", C_CMAXWL);
1024 +                newav[0] = mg_ename[MG_E_CSPEC];
1025 +                newav[1] = wl[0];
1026 +                newav[2] = wl[1];
1027 +                sf = (double)C_CNSS / c_ccolor->ssum;
1028 +                for (i = 0; i < C_CNSS; i++) {
1029 +                        sprintf(vbuf[i], "%.4f", sf*c_ccolor->ssamp[i]);
1030 +                        newav[i+3] = vbuf[i];
1031 +                }
1032 +                newav[C_CNSS+3] = NULL;
1033 +                if ((i = mg_handle(MG_E_CSPEC, C_CNSS+3, newav)) != MG_OK)
1034 +                        return(i);
1035 +        }
1036 +        return(MG_OK);
1037 + }
1038 +
1039 +
1040 + static int
1041 + e_cspec(ac, av)                 /* handle spectral color */
1042 + int     ac;
1043 + char    **av;
1044 + {
1045 +                                /* convert to xy chromaticity */
1046 +        c_ccvt(c_ccolor, C_CSXY);
1047 +                                /* if it's really their handler, use it */
1048 +        if (mg_ehand[MG_E_CXY] != c_hcolor)
1049 +                return(put_cxy());
1050 +        return(MG_OK);
1051 + }
1052 +
1053 +
1054 + static int
1055 + e_cmix(ac, av)                  /* handle mixing of colors */
1056 + int     ac;
1057 + char    **av;
1058 + {
1059 +        /*
1060 +         * Contorted logic works as follows:
1061 +         *      1. the colors are already mixed in c_hcolor() support function
1062 +         *      2. if we would handle a spectral result, make sure it's not
1063 +         *      3. if c_hcolor() would handle a spectral result, don't bother
1064 +         *      4. otherwise, make cspec entity and pass it to their handler
1065 +         *      5. if we have only xy results, handle it as c_spec() would
1066 +         */
1067 +        if (mg_ehand[MG_E_CSPEC] == e_cspec)
1068 +                c_ccvt(c_ccolor, C_CSXY);
1069 +        else if (c_ccolor->flags & C_CDSPEC)
1070 +                return(put_cspec());
1071 +        if (mg_ehand[MG_E_CXY] != c_hcolor)
1072 +                return(put_cxy());
1073 +        return(MG_OK);
1074 + }
1075 +
1076 +
1077 + static int
1078 + e_cct(ac, av)                   /* handle color temperature */
1079 + int     ac;
1080 + char    **av;
1081 + {
1082 +        /*
1083 +         * Logic is similar to e_cmix here.  Support handler has already
1084 +         * converted temperature to spectral color.  Put it out as such
1085 +         * if they support it, otherwise convert to xy chromaticity and
1086 +         * put it out if they handle it.
1087 +         */
1088 +        if (mg_ehand[MG_E_CSPEC] != e_cspec)
1089 +                return(put_cspec());
1090 +        c_ccvt(c_ccolor, C_CSXY);
1091 +        if (mg_ehand[MG_E_CXY] != c_hcolor)
1092 +                return(put_cxy());
1093          return(MG_OK);
1094   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines