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

Comparing ray/src/common/calexpr.c (file contents):
Revision 2.16 by greg, Thu Feb 16 09:49:29 1995 UTC vs.
Revision 2.29 by schorsch, Sun Mar 28 20:33:12 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  Compute data values using expression parser
6   *
# Line 16 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13   *  1/29/87  Made variables conditional (VARIABLE)
14   *
15   *  5/19/88  Added constant subexpression elimination (RCONST)
16 + *
17 + *  2/19/03     Eliminated conditional compiles in favor of esupport extern.
18   */
19  
20 < #include  <stdio.h>
20 > #include "copyright.h"
21  
22 + #include  <stdio.h>
23 + #include  <string.h>
24   #include  <ctype.h>
24
25   #include  <errno.h>
26
26   #include  <math.h>
27 + #include  <stdlib.h>
28  
29 + #include  "rtmisc.h"
30 + #include  "rtio.h"
31 + #include  "rterror.h"
32   #include  "calcomp.h"
33  
34   #define  MAXLINE        256             /* maximum line length */
# Line 34 | Line 37 | static char SCCSid[] = "$SunId$ LBL";
37  
38   #define  isdecimal(c)   (isdigit(c) || (c) == '.')
39  
40 < extern char  *savestr();
41 < extern char  *emalloc(), *ecalloc();
42 < extern EPNODE  *curfunc;
43 < extern double  efunc(), evariable();
44 < static double  euminus(), eargument(), enumber();
45 < #ifdef  INCHAN
43 < static double  echannel();
44 < #endif
45 < static double  eadd(), esubtr(), emult(), edivi(), epow();
46 < static double  ebotch();
40 > static double  euminus(EPNODE *), eargument(EPNODE *), enumber(EPNODE *);
41 > static double  echannel(EPNODE *);
42 > static double  eadd(EPNODE *), esubtr(EPNODE *),
43 >               emult(EPNODE *), edivi(EPNODE *),
44 >               epow(EPNODE *);
45 > static double  ebotch(EPNODE *);
46  
47 < #ifdef  DCL_ATOF
48 < extern double  atof();
50 < #endif
47 > unsigned int  esupport =                /* what to support */
48 >                E_VARIABLE | E_FUNCTION ;
49  
50   int  nextc;                             /* lookahead character */
51  
52 < double  (*eoper[])() = {                /* expression operations */
52 > double  (*eoper[])(EPNODE *) = {        /* expression operations */
53          ebotch,
56 #ifdef  VARIABLE
54          evariable,
58 #else
59        ebotch,
60 #endif
55          enumber,
56          euminus,
63 #ifdef  INCHAN
57          echannel,
65 #else
66        ebotch,
67 #endif
68 #ifdef  FUNCTION
58          efunc,
59          eargument,
71 #else
60          ebotch,
61          ebotch,
74 #endif
75        ebotch,
76        ebotch,
62          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
63          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
64          emult,
# Line 99 | Line 84 | static int  linepos;                   /* position in buffer */
84  
85  
86   EPNODE *
87 < eparse(expr)                    /* parse an expression string */
88 < char  *expr;
87 > eparse(                 /* parse an expression string */
88 >    char  *expr
89 > )
90   {
91      EPNODE  *ep;
92  
93      initstr(expr, NULL, 0);
108 #if  defined(VARIABLE) && defined(FUNCTION)
94      curfunc = NULL;
110 #endif
95      ep = getE1();
96      if (nextc != EOF)
97          syntax("unexpected character");
# Line 116 | Line 100 | char  *expr;
100  
101  
102   double
103 < eval(expr)                      /* evaluate an expression string */
104 < char  *expr;
103 > eval(                   /* evaluate an expression string */
104 >    char  *expr
105 > )
106   {
107      register EPNODE  *ep;
108      double  rval;
# Line 129 | Line 114 | char  *expr;
114   }
115  
116  
117 < epcmp(ep1, ep2)                 /* compare two expressions for equivalence */
118 < register EPNODE  *ep1, *ep2;
117 > int
118 > epcmp(                  /* compare two expressions for equivalence */
119 >    register EPNODE  *ep1,
120 >    register EPNODE  *ep2
121 > )
122   {
123          double  d;
124  
# Line 146 | Line 134 | register EPNODE  *ep1, *ep2;
134                  if (ep2->v.num == 0)
135                          return(ep1->v.num != 0);
136                  d = ep1->v.num / ep2->v.num;
137 <                return(d > 1.000000000001 | d < 0.999999999999);
137 >                return((d > 1.000000000001) | (d < 0.999999999999));
138  
139          case CHAN:
140          case ARG:
# Line 176 | Line 164 | register EPNODE  *ep1, *ep2;
164   }
165  
166  
167 < epfree(epar)                    /* free a parse tree */
168 < register EPNODE  *epar;
167 > void
168 > epfree(                 /* free a parse tree */
169 >    register EPNODE      *epar
170 > )
171   {
172      register EPNODE  *ep;
173  
174      switch (epar->type) {
175  
186 #if  defined(VARIABLE) || defined(FUNCTION)
176          case VAR:
177              varfree(epar->v.ln);
178              break;
# Line 191 | Line 180 | register EPNODE         *epar;
180          case SYM:
181              freestr(epar->v.name);
182              break;
194 #endif
183  
184          case NUM:
185          case CHAN:
# Line 212 | Line 200 | register EPNODE         *epar;
200   }
201  
202                                  /* the following used to be a switch */
215 #ifdef  FUNCTION
203   static double
204 < eargument(ep)
205 < EPNODE  *ep;
204 > eargument(
205 >    EPNODE      *ep
206 > )
207   {
208      return(argument(ep->v.chan));
209   }
222 #endif
210  
211   static double
212 < enumber(ep)
213 < EPNODE  *ep;
212 > enumber(
213 >    EPNODE      *ep
214 > )
215   {
216      return(ep->v.num);
217   }
218  
219   static double
220 < euminus(ep)
221 < EPNODE  *ep;
220 > euminus(
221 >    EPNODE      *ep
222 > )
223   {
224      register EPNODE  *ep1 = ep->v.kid;
225  
226      return(-evalue(ep1));
227   }
228  
240 #ifdef  INCHAN
229   static double
230 < echannel(ep)
231 < EPNODE  *ep;
230 > echannel(
231 >    EPNODE      *ep
232 > )
233   {
234      return(chanvalue(ep->v.chan));
235   }
247 #endif
236  
237   static double
238 < eadd(ep)
239 < EPNODE  *ep;
238 > eadd(
239 >    EPNODE      *ep
240 > )
241   {
242      register EPNODE  *ep1 = ep->v.kid;
243  
# Line 256 | Line 245 | EPNODE *ep;
245   }
246  
247   static double
248 < esubtr(ep)
249 < EPNODE  *ep;
248 > esubtr(
249 >    EPNODE      *ep
250 > )
251   {
252      register EPNODE  *ep1 = ep->v.kid;
253  
# Line 265 | Line 255 | EPNODE *ep;
255   }
256  
257   static double
258 < emult(ep)
259 < EPNODE  *ep;
258 > emult(
259 >    EPNODE      *ep
260 > )
261   {
262      register EPNODE  *ep1 = ep->v.kid;
263  
# Line 274 | Line 265 | EPNODE *ep;
265   }
266  
267   static double
268 < edivi(ep)
269 < EPNODE  *ep;
268 > edivi(
269 >    EPNODE      *ep
270 > )
271   {
272      register EPNODE  *ep1 = ep->v.kid;
273      double  d;
# Line 290 | Line 282 | EPNODE *ep;
282   }
283  
284   static double
285 < epow(ep)
286 < EPNODE  *ep;
285 > epow(
286 >    EPNODE      *ep
287 > )
288   {
289      register EPNODE  *ep1 = ep->v.kid;
290      double  d;
# Line 304 | Line 297 | EPNODE *ep;
297      if (!finite(d))
298          errno = EDOM;
299   #endif
300 <    if (errno) {
300 >    if (errno == EDOM || errno == ERANGE) {
301          wputs("Illegal power\n");
302          return(0.0);
303      }
# Line 313 | Line 306 | EPNODE *ep;
306   }
307  
308   static double
309 < ebotch(ep)
310 < EPNODE  *ep;
309 > ebotch(
310 >    EPNODE      *ep
311 > )
312   {
313      eputs("Bad expression!\n");
314      quit(1);
315 +        return 0.0; /* pro forma return */
316   }
317  
318  
319   EPNODE *
320 < ekid(ep, n)                     /* return pointer to a node's nth kid */
321 < register EPNODE  *ep;
322 < register int  n;
320 > ekid(                   /* return pointer to a node's nth kid */
321 >    register EPNODE      *ep,
322 >    register int  n
323 > )
324   {
325  
326      for (ep = ep->v.kid; ep != NULL; ep = ep->sibling)
# Line 336 | Line 332 | register int  n;
332  
333  
334   int
335 < nekids(ep)                      /* return # of kids for node ep */
336 < register EPNODE  *ep;
335 > nekids(                 /* return # of kids for node ep */
336 >    register EPNODE      *ep
337 > )
338   {
339      register int  n = 0;
340  
# Line 348 | Line 345 | register EPNODE         *ep;
345   }
346  
347  
348 < initfile(fp, fn, ln)            /* prepare input file */
349 < FILE  *fp;
350 < char  *fn;
351 < int  ln;
348 > void
349 > initfile(               /* prepare input file */
350 >    FILE  *fp,
351 >    char  *fn,
352 >    int  ln
353 > )
354   {
355      static char  inpbuf[MAXLINE];
356  
# Line 365 | Line 364 | int  ln;
364   }
365  
366  
367 < initstr(s, fn, ln)              /* prepare input string */
368 < char  *s;
369 < char  *fn;
370 < int  ln;
367 > void
368 > initstr(                /* prepare input string */
369 >    char  *s,
370 >    char  *fn,
371 >    int  ln
372 > )
373   {
374      infp = NULL;
375      infile = fn;
# Line 379 | Line 380 | int  ln;
380   }
381  
382  
383 < getscanpos(fnp, lnp, spp, fpp)  /* return current scan position */
384 < char  **fnp;
385 < int  *lnp;
386 < char  **spp;
387 < FILE  **fpp;
383 > void
384 > getscanpos(     /* return current scan position */
385 >    char  **fnp,
386 >    int  *lnp,
387 >    char  **spp,
388 >    FILE  **fpp
389 > )
390   {
391      if (fnp != NULL) *fnp = infile;
392      if (lnp != NULL) *lnp = lineno;
# Line 393 | Line 396 | FILE  **fpp;
396  
397  
398   int
399 < scan()                          /* scan next character, return literal next */
399 > scan(void)              /* scan next character, return literal next */
400   {
401      register int  lnext = 0;
402  
# Line 425 | Line 428 | scan()                         /* scan next character, return literal next
428  
429  
430   char *
431 < long2ascii(l)                         /* convert long to ascii */
432 < long  l;
431 > long2ascii(                           /* convert long to ascii */
432 >    long  l
433 > )
434   {
435      static char  buf[16];
436      register char  *cp;
# Line 450 | Line 454 | long  l;
454   }
455  
456  
457 < syntax(err)                     /* report syntax error and quit */
458 < char  *err;
457 > void
458 > syntax(                 /* report syntax error and quit */
459 >    char  *err
460 > )
461   {
462      register int  i;
463  
# Line 475 | Line 481 | char  *err;
481   }
482  
483  
484 < addekid(ep, ekid)                       /* add a child to ep */
485 < register EPNODE  *ep;
486 < EPNODE  *ekid;
484 > void
485 > addekid(                        /* add a child to ep */
486 >    register EPNODE      *ep,
487 >    EPNODE      *ekid
488 > )
489   {
490      if (ep->v.kid == NULL)
491          ep->v.kid = ekid;
# Line 490 | Line 498 | EPNODE *ekid;
498   }
499  
500  
493 #if  defined(VARIABLE) || defined(FUNCTION)
501   char *
502 < getname()                       /* scan an identifier */
502 > getname(void)                   /* scan an identifier */
503   {
504 <    static char  str[MAXWORD+1];
504 >    static char  str[RMAXWORD+1];
505      register int  i, lnext;
506  
507      lnext = nextc;
508 <    for (i = 0; i < MAXWORD && isid(lnext); i++, lnext = scan())
508 >    for (i = 0; i < RMAXWORD && isid(lnext); i++, lnext = scan())
509          str[i] = lnext;
510      str[i] = '\0';
511      while (isid(lnext))         /* skip rest of name */
# Line 506 | Line 513 | getname()                      /* scan an identifier */
513  
514      return(str);
515   }
509 #endif
516  
517  
518   int
519 < getinum()                       /* scan a positive integer */
519 > getinum(void)                   /* scan a positive integer */
520   {
521      register int  n, lnext;
522  
# Line 525 | Line 531 | getinum()                      /* scan a positive integer */
531  
532  
533   double
534 < getnum()                        /* scan a positive float */
534 > getnum(void)                    /* scan a positive float */
535   {
536      register int  i, lnext;
537 <    char  str[MAXWORD+1];
537 >    char  str[RMAXWORD+1];
538  
539      i = 0;
540      lnext = nextc;
541 <    while (isdigit(lnext) && i < MAXWORD) {
541 >    while (isdigit(lnext) && i < RMAXWORD) {
542          str[i++] = lnext;
543          lnext = scan();
544      }
545 <    if (lnext == '.' && i < MAXWORD) {
545 >    if (lnext == '.' && i < RMAXWORD) {
546          str[i++] = lnext;
547          lnext = scan();
548 <        while (isdigit(lnext) && i < MAXWORD) {
548 >        if (i == 1 && !isdigit(lnext))
549 >            syntax("badly formed number");
550 >        while (isdigit(lnext) && i < RMAXWORD) {
551              str[i++] = lnext;
552              lnext = scan();
553          }
554      }
555 <    if ((lnext == 'e' || lnext == 'E') && i < MAXWORD) {
555 >    if ((lnext == 'e') | (lnext == 'E') && i < RMAXWORD) {
556          str[i++] = lnext;
557          lnext = scan();
558 <        if ((lnext == '-' || lnext == '+') && i < MAXWORD) {
558 >        if ((lnext == '-') | (lnext == '+') && i < RMAXWORD) {
559              str[i++] = lnext;
560              lnext = scan();
561          }
562 <        while (isdigit(lnext) && i < MAXWORD) {
562 >        if (!isdigit(lnext))
563 >            syntax("missing exponent");
564 >        while (isdigit(lnext) && i < RMAXWORD) {
565              str[i++] = lnext;
566              lnext = scan();
567          }
# Line 563 | Line 573 | getnum()                       /* scan a positive float */
573  
574  
575   EPNODE *
576 < getE1()                         /* E1 -> E1 ADDOP E2 */
576 > getE1(void)                             /* E1 -> E1 ADDOP E2 */
577                                  /*       E2 */
578   {
579      register EPNODE  *ep1, *ep2;
# Line 575 | Line 585 | getE1()                                /* E1 -> E1 ADDOP E2 */
585          scan();
586          addekid(ep2, ep1);
587          addekid(ep2, getE2());
588 < #ifdef  RCONST
589 <        if (ep1->type == NUM && ep1->sibling->type == NUM)
588 >        if (esupport&E_RCONST &&
589 >                        ep1->type == NUM && ep1->sibling->type == NUM)
590                  ep2 = rconst(ep2);
581 #endif
591          ep1 = ep2;
592      }
593      return(ep1);
# Line 586 | Line 595 | getE1()                                /* E1 -> E1 ADDOP E2 */
595  
596  
597   EPNODE *
598 < getE2()                         /* E2 -> E2 MULOP E3 */
598 > getE2(void)                             /* E2 -> E2 MULOP E3 */
599                                  /*       E3 */
600   {
601      register EPNODE  *ep1, *ep2;
# Line 598 | Line 607 | getE2()                                /* E2 -> E2 MULOP E3 */
607          scan();
608          addekid(ep2, ep1);
609          addekid(ep2, getE3());
610 < #ifdef  RCONST
611 <        if (ep1->type == NUM && ep1->sibling->type == NUM)
610 >        if (esupport&E_RCONST &&
611 >                        ep1->type == NUM && ep1->sibling->type == NUM)
612                  ep2 = rconst(ep2);
604 #endif
613          ep1 = ep2;
614      }
615      return(ep1);
# Line 609 | Line 617 | getE2()                                /* E2 -> E2 MULOP E3 */
617  
618  
619   EPNODE *
620 < getE3()                         /* E3 -> E4 ^ E3 */
620 > getE3(void)                             /* E3 -> E4 ^ E3 */
621                                  /*       E4 */
622   {
623      register EPNODE  *ep1, *ep2;
# Line 621 | Line 629 | getE3()                                /* E3 -> E4 ^ E3 */
629          scan();
630          addekid(ep2, ep1);
631          addekid(ep2, getE3());
632 < #ifdef  RCONST
633 <        if (ep1->type == NUM && ep1->sibling->type == NUM)
632 >        if (esupport&E_RCONST &&
633 >                        ep1->type == NUM && ep1->sibling->type == NUM)
634                  ep2 = rconst(ep2);
627 #endif
635          return(ep2);
636      }
637      return(ep1);
# Line 632 | Line 639 | getE3()                                /* E3 -> E4 ^ E3 */
639  
640  
641   EPNODE *
642 < getE4()                         /* E4 -> ADDOP E5 */
642 > getE4(void)                             /* E4 -> ADDOP E5 */
643                                  /*       E5 */
644   {
645      register EPNODE  *ep1, *ep2;
# Line 660 | Line 667 | getE4()                                /* E4 -> ADDOP E5 */
667  
668  
669   EPNODE *
670 < getE5()                         /* E5 -> (E1) */
670 > getE5(void)                     /* E5 -> (E1) */
671                                  /*       VAR */
672                                  /*       NUM */
673                                  /*       $N */
674                                  /*       FUNC(E1,..) */
675                                  /*       ARG */
676   {
677 <    int  i;
678 <    char  *nam;
679 <    register EPNODE  *ep1, *ep2;
677 >        int      i;
678 >        char  *nam;
679 >        register EPNODE  *ep1, *ep2;
680  
681 <    if (nextc == '(') {
682 <        scan();
683 <        ep1 = getE1();
684 <        if (nextc != ')')
685 <            syntax("')' expected");
686 <        scan();
687 <        return(ep1);
688 <    }
681 >        if (nextc == '(') {
682 >                scan();
683 >                ep1 = getE1();
684 >                if (nextc != ')')
685 >                        syntax("')' expected");
686 >                scan();
687 >                return(ep1);
688 >        }
689  
690 < #ifdef  INCHAN
691 <    if (nextc == '$') {
692 <        scan();
693 <        ep1 = newnode();
694 <        ep1->type = CHAN;
695 <        ep1->v.chan = getinum();
696 <        return(ep1);
690 <    }
691 < #endif
690 >        if (esupport&E_INCHAN && nextc == '$') {
691 >                scan();
692 >                ep1 = newnode();
693 >                ep1->type = CHAN;
694 >                ep1->v.chan = getinum();
695 >                return(ep1);
696 >        }
697  
698 < #if  defined(VARIABLE) || defined(FUNCTION)
699 <    if (isalpha(nextc) || nextc == CNTXMARK) {
700 <        nam = getname();
701 < #if  defined(VARIABLE) && defined(FUNCTION)
702 <        ep1 = NULL;
703 <        if (curfunc != NULL)
704 <            for (i = 1, ep2 = curfunc->v.kid->sibling;
705 <                                ep2 != NULL; i++, ep2 = ep2->sibling)
706 <                if (!strcmp(ep2->v.name, nam)) {
707 <                    ep1 = newnode();
708 <                    ep1->type = ARG;
709 <                    ep1->v.chan = i;
710 <                    break;
698 >        if (esupport&(E_VARIABLE|E_FUNCTION) &&
699 >                        (isalpha(nextc) || nextc == CNTXMARK)) {
700 >                nam = getname();
701 >                ep1 = NULL;
702 >                if ((esupport&(E_VARIABLE|E_FUNCTION)) == (E_VARIABLE|E_FUNCTION)
703 >                                && curfunc != NULL)
704 >                        for (i = 1, ep2 = curfunc->v.kid->sibling;
705 >                                        ep2 != NULL; i++, ep2 = ep2->sibling)
706 >                                if (!strcmp(ep2->v.name, nam)) {
707 >                                        ep1 = newnode();
708 >                                        ep1->type = ARG;
709 >                                        ep1->v.chan = i;
710 >                                        break;
711 >                                }
712 >                if (ep1 == NULL) {
713 >                        ep1 = newnode();
714 >                        ep1->type = VAR;
715 >                        ep1->v.ln = varinsert(nam);
716                  }
717 <        if (ep1 == NULL)
718 < #endif
719 <        {
720 <            ep1 = newnode();
721 <            ep1->type = VAR;
722 <            ep1->v.ln = varinsert(nam);
717 >                if (esupport&E_FUNCTION && nextc == '(') {
718 >                        ep2 = newnode();
719 >                        ep2->type = FUNC;
720 >                        addekid(ep2, ep1);
721 >                        ep1 = ep2;
722 >                        do {
723 >                                scan();
724 >                                addekid(ep1, getE1());
725 >                        } while (nextc == ',');
726 >                        if (nextc != ')')
727 >                                syntax("')' expected");
728 >                        scan();
729 >                } else if (!(esupport&E_VARIABLE))
730 >                        syntax("'(' expected");
731 >                if (esupport&E_RCONST && isconstvar(ep1))
732 >                        ep1 = rconst(ep1);
733 >                return(ep1);
734          }
714 #ifdef  FUNCTION
715        if (nextc == '(') {
716            ep2 = newnode();
717            ep2->type = FUNC;
718            addekid(ep2, ep1);
719            ep1 = ep2;
720            do {
721                scan();
722                addekid(ep1, getE1());
723            } while (nextc == ',');
724            if (nextc != ')')
725                syntax("')' expected");
726            scan();
727        }
728 #ifndef  VARIABLE
729        else
730            syntax("'(' expected");
731 #endif
732 #endif
733 #ifdef  RCONST
734        if (isconstvar(ep1))
735            ep1 = rconst(ep1);
736 #endif
737        return(ep1);
738    }
739 #endif
735  
736 <    if (isdecimal(nextc)) {
737 <        ep1 = newnode();
738 <        ep1->type = NUM;
739 <        ep1->v.num = getnum();
740 <        return(ep1);
741 <    }
742 <    syntax("unexpected character");
736 >        if (isdecimal(nextc)) {
737 >                ep1 = newnode();
738 >                ep1->type = NUM;
739 >                ep1->v.num = getnum();
740 >                return(ep1);
741 >        }
742 >        syntax("unexpected character");
743 >        return NULL; /* pro forma return */
744   }
745  
746  
751 #ifdef  RCONST
747   EPNODE *
748 < rconst(epar)                    /* reduce a constant expression */
749 < register EPNODE  *epar;
748 > rconst(                 /* reduce a constant expression */
749 >    register EPNODE      *epar
750 > )
751   {
752      register EPNODE  *ep;
753  
# Line 759 | Line 755 | register EPNODE         *epar;
755      ep->type = NUM;
756      errno = 0;
757      ep->v.num = evalue(epar);
758 <    if (errno)
758 >    if (errno == EDOM || errno == ERANGE)
759          syntax("bad constant expression");
760      epfree(epar);
761  
# Line 767 | Line 763 | register EPNODE         *epar;
763   }
764  
765  
766 < isconstvar(ep)                  /* is ep linked to a constant expression? */
767 < register EPNODE  *ep;
766 > int
767 > isconstvar(                     /* is ep linked to a constant expression? */
768 >    register EPNODE      *ep
769 > )
770   {
773 #ifdef  VARIABLE
771      register EPNODE  *ep1;
775 #ifdef  FUNCTION
772  
773 <    if (ep->type == FUNC) {
773 >    if (esupport&E_FUNCTION && ep->type == FUNC) {
774          if (!isconstfun(ep->v.kid))
775                  return(0);
776          for (ep1 = ep->v.kid->sibling; ep1 != NULL; ep1 = ep1->sibling)
# Line 782 | Line 778 | register EPNODE         *ep;
778                  return(0);
779          return(1);
780      }
785 #endif
781      if (ep->type != VAR)
782          return(0);
783      ep1 = ep->v.ln->def;
784      if (ep1 == NULL || ep1->type != ':')
785          return(0);
786 < #ifdef  FUNCTION
792 <    if (ep1->v.kid->type != SYM)
786 >    if (esupport&E_FUNCTION && ep1->v.kid->type != SYM)
787          return(0);
794 #endif
788      return(1);
796 #else
797    return(ep->type == FUNC);
798 #endif
789   }
790  
791  
792 < #if  defined(FUNCTION) && defined(VARIABLE)
793 < isconstfun(ep)                  /* is ep linked to a constant function? */
794 < register EPNODE  *ep;
792 > int
793 > isconstfun(                     /* is ep linked to a constant function? */
794 >    register EPNODE      *ep
795 > )
796   {
797      register EPNODE  *dp;
798      register LIBR  *lp;
799  
800      if (ep->type != VAR)
801          return(0);
802 <    if ((dp = ep->v.ln->def) != NULL && dp->v.kid->type == FUNC)
803 <        return(dp->type == ':');
802 >    if ((dp = ep->v.ln->def) != NULL) {
803 >        if (dp->v.kid->type == FUNC)
804 >            return(dp->type == ':');
805 >        else
806 >            return(0);          /* don't identify masked library functions */
807 >    }
808      if ((lp = ep->v.ln->lib) != NULL)
809          return(lp->atyp == ':');
810      return(0);
811   }
817 #endif
818 #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines