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.20 by greg, Wed Mar 5 16:16:52 2003 UTC vs.
Revision 2.36 by greg, Sat Aug 1 23:27:04 2015 UTC

# Line 20 | Line 20 | static const char      RCSid[] = "$Id$";
20   #include "copyright.h"
21  
22   #include  <stdio.h>
23 <
23 > #include  <string.h>
24   #include  <ctype.h>
25
25   #include  <errno.h>
27
26   #include  <math.h>
29
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 37 | Line 37 | static const char      RCSid[] = "$Id$";
37  
38   #define  isdecimal(c)   (isdigit(c) || (c) == '.')
39  
40 < static double  euminus(), eargument(), enumber();
41 < static double  echannel();
42 < static double  eadd(), esubtr(), emult(), edivi(), epow();
43 < 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   unsigned int  esupport =                /* what to support */
48 <                E_VARIABLE | E_FUNCTION | E_REDEFW;
48 >                E_VARIABLE | E_FUNCTION ;
49  
50 + int  eofc = 0;                          /* optional end-of-file character */
51   int  nextc;                             /* lookahead character */
52  
53 < double  (*eoper[])() = {                /* expression operations */
53 > double  (*eoper[])(EPNODE *) = {        /* expression operations */
54          ebotch,
55          evariable,
56          enumber,
# Line 82 | Line 85 | static int  linepos;                   /* position in buffer */
85  
86  
87   EPNODE *
88 < eparse(expr)                    /* parse an expression string */
89 < char  *expr;
88 > eparse(                 /* parse an expression string */
89 >    char  *expr
90 > )
91   {
92      EPNODE  *ep;
93  
# Line 97 | Line 101 | char  *expr;
101  
102  
103   double
104 < eval(expr)                      /* evaluate an expression string */
105 < char  *expr;
104 > eval(                   /* evaluate an expression string */
105 >    char  *expr
106 > )
107   {
108      register EPNODE  *ep;
109      double  rval;
# Line 111 | Line 116 | char  *expr;
116  
117  
118   int
119 < epcmp(ep1, ep2)                 /* compare two expressions for equivalence */
120 < register EPNODE  *ep1, *ep2;
119 > epcmp(                  /* compare two expressions for equivalence */
120 >    register EPNODE  *ep1,
121 >    register EPNODE  *ep2
122 > )
123   {
124          double  d;
125  
# Line 128 | Line 135 | register EPNODE  *ep1, *ep2;
135                  if (ep2->v.num == 0)
136                          return(ep1->v.num != 0);
137                  d = ep1->v.num / ep2->v.num;
138 <                return(d > 1.000000000001 | d < 0.999999999999);
138 >                return((d > 1.000000000001) | (d < 0.999999999999));
139  
140          case CHAN:
141          case ARG:
# Line 138 | Line 145 | register EPNODE  *ep1, *ep2;
145          case ':':
146                  return(epcmp(ep1->v.kid->sibling, ep2->v.kid->sibling));
147  
148 <        case TICK:
148 >        case CLKT:
149          case SYM:                       /* should never get this one */
150                  return(0);
151  
# Line 159 | Line 166 | register EPNODE  *ep1, *ep2;
166  
167  
168   void
169 < epfree(epar)                    /* free a parse tree */
170 < register EPNODE  *epar;
169 > epfree(                 /* free a parse tree */
170 >    register EPNODE      *epar
171 > )
172   {
173      register EPNODE  *ep;
174  
# Line 177 | Line 185 | register EPNODE         *epar;
185          case NUM:
186          case CHAN:
187          case ARG:
188 <        case TICK:
188 >        case CLKT:
189              break;
190  
191          default:
# Line 194 | Line 202 | register EPNODE         *epar;
202  
203                                  /* the following used to be a switch */
204   static double
205 < eargument(ep)
206 < EPNODE  *ep;
205 > eargument(
206 >    EPNODE      *ep
207 > )
208   {
209      return(argument(ep->v.chan));
210   }
211  
212   static double
213 < enumber(ep)
214 < EPNODE  *ep;
213 > enumber(
214 >    EPNODE      *ep
215 > )
216   {
217      return(ep->v.num);
218   }
219  
220   static double
221 < euminus(ep)
222 < EPNODE  *ep;
221 > euminus(
222 >    EPNODE      *ep
223 > )
224   {
225      register EPNODE  *ep1 = ep->v.kid;
226  
# Line 217 | Line 228 | EPNODE *ep;
228   }
229  
230   static double
231 < echannel(ep)
232 < EPNODE  *ep;
231 > echannel(
232 >    EPNODE      *ep
233 > )
234   {
235      return(chanvalue(ep->v.chan));
236   }
237  
238   static double
239 < eadd(ep)
240 < EPNODE  *ep;
239 > eadd(
240 >    EPNODE      *ep
241 > )
242   {
243      register EPNODE  *ep1 = ep->v.kid;
244  
# Line 233 | Line 246 | EPNODE *ep;
246   }
247  
248   static double
249 < esubtr(ep)
250 < EPNODE  *ep;
249 > esubtr(
250 >    EPNODE      *ep
251 > )
252   {
253      register EPNODE  *ep1 = ep->v.kid;
254  
# Line 242 | Line 256 | EPNODE *ep;
256   }
257  
258   static double
259 < emult(ep)
260 < EPNODE  *ep;
259 > emult(
260 >    EPNODE      *ep
261 > )
262   {
263      register EPNODE  *ep1 = ep->v.kid;
264  
# Line 251 | Line 266 | EPNODE *ep;
266   }
267  
268   static double
269 < edivi(ep)
270 < EPNODE  *ep;
269 > edivi(
270 >    EPNODE      *ep
271 > )
272   {
273      register EPNODE  *ep1 = ep->v.kid;
274      double  d;
# Line 267 | Line 283 | EPNODE *ep;
283   }
284  
285   static double
286 < epow(ep)
287 < EPNODE  *ep;
286 > epow(
287 >    EPNODE      *ep
288 > )
289   {
290      register EPNODE  *ep1 = ep->v.kid;
291      double  d;
# Line 277 | Line 294 | EPNODE *ep;
294      lasterrno = errno;
295      errno = 0;
296      d = pow(evalue(ep1), evalue(ep1->sibling));
297 < #ifdef  IEEE
298 <    if (!finite(d))
299 <        errno = EDOM;
297 > #ifdef  isnan
298 >    if (errno == 0) {
299 >        if (isnan(d))
300 >            errno = EDOM;
301 >        else if (isinf(d))
302 >            errno = ERANGE;
303 >    }
304   #endif
305      if (errno == EDOM || errno == ERANGE) {
306          wputs("Illegal power\n");
# Line 290 | Line 311 | EPNODE *ep;
311   }
312  
313   static double
314 < ebotch(ep)
315 < EPNODE  *ep;
314 > ebotch(
315 >    EPNODE      *ep
316 > )
317   {
318      eputs("Bad expression!\n");
319      quit(1);
320 +        return 0.0; /* pro forma return */
321   }
322  
323  
324   EPNODE *
325 < ekid(ep, n)                     /* return pointer to a node's nth kid */
326 < register EPNODE  *ep;
327 < register int  n;
325 > ekid(                   /* return pointer to a node's nth kid */
326 >    register EPNODE      *ep,
327 >    register int  n
328 > )
329   {
330  
331      for (ep = ep->v.kid; ep != NULL; ep = ep->sibling)
# Line 313 | Line 337 | register int  n;
337  
338  
339   int
340 < nekids(ep)                      /* return # of kids for node ep */
341 < register EPNODE  *ep;
340 > nekids(                 /* return # of kids for node ep */
341 >    register EPNODE      *ep
342 > )
343   {
344      register int  n = 0;
345  
# Line 326 | Line 351 | register EPNODE         *ep;
351  
352  
353   void
354 < initfile(fp, fn, ln)            /* prepare input file */
355 < FILE  *fp;
356 < char  *fn;
357 < int  ln;
354 > initfile(               /* prepare input file */
355 >    FILE  *fp,
356 >    char  *fn,
357 >    int  ln
358 > )
359   {
360      static char  inpbuf[MAXLINE];
361  
# Line 344 | Line 370 | int  ln;
370  
371  
372   void
373 < initstr(s, fn, ln)              /* prepare input string */
374 < char  *s;
375 < char  *fn;
376 < int  ln;
373 > initstr(                /* prepare input string */
374 >    char  *s,
375 >    char  *fn,
376 >    int  ln
377 > )
378   {
379      infp = NULL;
380      infile = fn;
# Line 359 | Line 386 | int  ln;
386  
387  
388   void
389 < getscanpos(fnp, lnp, spp, fpp)  /* return current scan position */
390 < char  **fnp;
391 < int  *lnp;
392 < char  **spp;
393 < FILE  **fpp;
389 > getscanpos(     /* return current scan position */
390 >    char  **fnp,
391 >    int  *lnp,
392 >    char  **spp,
393 >    FILE  **fpp
394 > )
395   {
396      if (fnp != NULL) *fnp = infile;
397      if (lnp != NULL) *lnp = lineno;
# Line 373 | Line 401 | FILE  **fpp;
401  
402  
403   int
404 < scan()                          /* scan next character, return literal next */
404 > scan(void)              /* scan next character, return literal next */
405   {
406      register int  lnext = 0;
407  
# Line 390 | Line 418 | scan()                         /* scan next character, return literal next
418              nextc = linbuf[linepos++];
419          if (!lnext)
420                  lnext = nextc;
421 +        if (nextc == eofc) {
422 +                nextc = EOF;
423 +                break;
424 +        }
425          if (nextc == '{') {
426              scan();
427              while (nextc != '}')
# Line 405 | Line 437 | scan()                         /* scan next character, return literal next
437  
438  
439   char *
440 < long2ascii(l)                         /* convert long to ascii */
441 < long  l;
440 > long2ascii(                           /* convert long to ascii */
441 >    long  l
442 > )
443   {
444      static char  buf[16];
445      register char  *cp;
# Line 431 | Line 464 | long  l;
464  
465  
466   void
467 < syntax(err)                     /* report syntax error and quit */
468 < char  *err;
467 > syntax(                 /* report syntax error and quit */
468 >    char  *err
469 > )
470   {
471      register int  i;
472  
# Line 457 | Line 491 | char  *err;
491  
492  
493   void
494 < addekid(ep, ekid)                       /* add a child to ep */
495 < register EPNODE  *ep;
496 < EPNODE  *ekid;
494 > addekid(                        /* add a child to ep */
495 >    register EPNODE      *ep,
496 >    EPNODE      *ekid
497 > )
498   {
499      if (ep->v.kid == NULL)
500          ep->v.kid = ekid;
# Line 473 | Line 508 | EPNODE *ekid;
508  
509  
510   char *
511 < getname()                       /* scan an identifier */
511 > getname(void)                   /* scan an identifier */
512   {
513 <    static char  str[MAXWORD+1];
513 >    static char  str[RMAXWORD+1];
514      register int  i, lnext;
515  
516      lnext = nextc;
517 <    for (i = 0; i < MAXWORD && isid(lnext); i++, lnext = scan())
517 >    for (i = 0; i < RMAXWORD && isid(lnext); i++, lnext = scan())
518          str[i] = lnext;
519      str[i] = '\0';
520      while (isid(lnext))         /* skip rest of name */
# Line 490 | Line 525 | getname()                      /* scan an identifier */
525  
526  
527   int
528 < getinum()                       /* scan a positive integer */
528 > getinum(void)                   /* scan a positive integer */
529   {
530      register int  n, lnext;
531  
# Line 505 | Line 540 | getinum()                      /* scan a positive integer */
540  
541  
542   double
543 < getnum()                        /* scan a positive float */
543 > getnum(void)                    /* scan a positive float */
544   {
545      register int  i, lnext;
546 <    char  str[MAXWORD+1];
546 >    char  str[RMAXWORD+1];
547  
548      i = 0;
549      lnext = nextc;
550 <    while (isdigit(lnext) && i < MAXWORD) {
550 >    while (isdigit(lnext) && i < RMAXWORD) {
551          str[i++] = lnext;
552          lnext = scan();
553      }
554 <    if (lnext == '.' && i < MAXWORD) {
554 >    if (lnext == '.' && i < RMAXWORD) {
555          str[i++] = lnext;
556          lnext = scan();
557          if (i == 1 && !isdigit(lnext))
558              syntax("badly formed number");
559 <        while (isdigit(lnext) && i < MAXWORD) {
559 >        while (isdigit(lnext) && i < RMAXWORD) {
560              str[i++] = lnext;
561              lnext = scan();
562          }
563      }
564 <    if ((lnext == 'e' | lnext == 'E') && i < MAXWORD) {
564 >    if ((lnext == 'e') | (lnext == 'E') && i < RMAXWORD) {
565          str[i++] = lnext;
566          lnext = scan();
567 <        if ((lnext == '-' | lnext == '+') && i < MAXWORD) {
567 >        if ((lnext == '-') | (lnext == '+') && i < RMAXWORD) {
568              str[i++] = lnext;
569              lnext = scan();
570          }
571          if (!isdigit(lnext))
572              syntax("missing exponent");
573 <        while (isdigit(lnext) && i < MAXWORD) {
573 >        while (isdigit(lnext) && i < RMAXWORD) {
574              str[i++] = lnext;
575              lnext = scan();
576          }
# Line 547 | Line 582 | getnum()                       /* scan a positive float */
582  
583  
584   EPNODE *
585 < getE1()                         /* E1 -> E1 ADDOP E2 */
585 > getE1(void)                     /* E1 -> E1 ADDOP E2 */
586                                  /*       E2 */
587   {
588      register EPNODE  *ep1, *ep2;
# Line 569 | Line 604 | getE1()                                /* E1 -> E1 ADDOP E2 */
604  
605  
606   EPNODE *
607 < getE2()                         /* E2 -> E2 MULOP E3 */
607 > getE2(void)                     /* E2 -> E2 MULOP E3 */
608                                  /*       E3 */
609   {
610      register EPNODE  *ep1, *ep2;
# Line 581 | Line 616 | getE2()                                /* E2 -> E2 MULOP E3 */
616          scan();
617          addekid(ep2, ep1);
618          addekid(ep2, getE3());
619 <        if (esupport&E_RCONST &&
620 <                        ep1->type == NUM && ep1->sibling->type == NUM)
621 <                ep2 = rconst(ep2);
619 >        if (esupport&E_RCONST) {
620 >                EPNODE  *ep3 = ep1->sibling;
621 >                if (ep1->type == NUM && ep3->type == NUM) {
622 >                        ep2 = rconst(ep2);
623 >                } else if (ep3->type == NUM) {
624 >                        if (ep2->type == '/') {
625 >                                if (ep3->v.num == 0)
626 >                                        syntax("divide by zero constant");
627 >                                ep2->type = '*';        /* for speed */
628 >                                ep3->v.num = 1./ep3->v.num;
629 >                        } else if (ep3->v.num == 0) {
630 >                                ep1->sibling = NULL;    /* (E2 * 0) */
631 >                                epfree(ep2);
632 >                                ep2 = ep3;
633 >                        }
634 >                } else if (ep1->type == NUM && ep1->v.num == 0) {
635 >                        epfree(ep3);            /* (0 * E3) or (0 / E3) */
636 >                        ep1->sibling = NULL;
637 >                        efree((char *)ep2);
638 >                        ep2 = ep1;
639 >                }
640 >        }
641          ep1 = ep2;
642      }
643      return(ep1);
# Line 591 | Line 645 | getE2()                                /* E2 -> E2 MULOP E3 */
645  
646  
647   EPNODE *
648 < getE3()                         /* E3 -> E4 ^ E3 */
648 > getE3(void)                     /* E3 -> E4 ^ E3 */
649                                  /*       E4 */
650   {
651 <    register EPNODE  *ep1, *ep2;
651 >        register EPNODE  *ep1, *ep2;
652  
653 <    ep1 = getE4();
654 <    if (nextc == '^') {
653 >        ep1 = getE4();
654 >        if (nextc != '^')
655 >                return(ep1);
656          ep2 = newnode();
657          ep2->type = nextc;
658          scan();
659          addekid(ep2, ep1);
660          addekid(ep2, getE3());
661 <        if (esupport&E_RCONST &&
662 <                        ep1->type == NUM && ep1->sibling->type == NUM)
663 <                ep2 = rconst(ep2);
661 >        if (esupport&E_RCONST) {
662 >                EPNODE  *ep3 = ep1->sibling;
663 >                if (ep1->type == NUM && ep3->type == NUM) {
664 >                        ep2 = rconst(ep2);
665 >                } else if (ep1->type == NUM && ep1->v.num == 0) {
666 >                        epfree(ep3);            /* (0 ^ E3) */
667 >                        ep1->sibling = NULL;
668 >                        efree((char *)ep2);
669 >                        ep2 = ep1;
670 >                } else if ((ep3->type == NUM && ep3->v.num == 0) ||
671 >                                (ep1->type == NUM && ep1->v.num == 1)) {
672 >                        epfree(ep2);            /* (E4 ^ 0) or (1 ^ E3) */
673 >                        ep2 = newnode();
674 >                        ep2->type = NUM;
675 >                        ep2->v.num = 1;
676 >                }
677 >        }
678          return(ep2);
610    }
611    return(ep1);
679   }
680  
681  
682   EPNODE *
683 < getE4()                         /* E4 -> ADDOP E5 */
683 > getE4(void)                     /* E4 -> ADDOP E5 */
684                                  /*       E5 */
685   {
686      register EPNODE  *ep1, *ep2;
# Line 626 | Line 693 | getE4()                                /* E4 -> ADDOP E5 */
693                  return(ep2);
694          }
695          if (ep2->type == UMINUS) {      /* don't generate -(-E5) */
696 +            ep1 = ep2->v.kid;
697              efree((char *)ep2);
698 <            return(ep2->v.kid);
698 >            return(ep1);
699          }
700          ep1 = newnode();
701          ep1->type = UMINUS;
# Line 641 | Line 709 | getE4()                                /* E4 -> ADDOP E5 */
709  
710  
711   EPNODE *
712 < getE5()                         /* E5 -> (E1) */
712 > getE5(void)                     /* E5 -> (E1) */
713                                  /*       VAR */
714                                  /*       NUM */
715                                  /*       $N */
716                                  /*       FUNC(E1,..) */
717                                  /*       ARG */
718   {
719 <    int  i;
720 <    char  *nam;
721 <    register EPNODE  *ep1, *ep2;
719 >        int      i;
720 >        char  *nam;
721 >        register EPNODE  *ep1, *ep2;
722  
723 <    if (nextc == '(') {
724 <        scan();
725 <        ep1 = getE1();
726 <        if (nextc != ')')
727 <            syntax("')' expected");
728 <        scan();
729 <        return(ep1);
730 <    }
723 >        if (nextc == '(') {
724 >                scan();
725 >                ep1 = getE1();
726 >                if (nextc != ')')
727 >                        syntax("')' expected");
728 >                scan();
729 >                return(ep1);
730 >        }
731  
732 <    if (esupport&E_INCHAN && nextc == '$') {
733 <        scan();
734 <        ep1 = newnode();
735 <        ep1->type = CHAN;
736 <        ep1->v.chan = getinum();
737 <        return(ep1);
738 <    }
732 >        if (esupport&E_INCHAN && nextc == '$') {
733 >                scan();
734 >                ep1 = newnode();
735 >                ep1->type = CHAN;
736 >                ep1->v.chan = getinum();
737 >                return(ep1);
738 >        }
739  
740 <  if (esupport&(E_VARIABLE|E_FUNCTION) &&
741 <                (isalpha(nextc) || nextc == CNTXMARK)) {
742 <      nam = getname();
743 <      ep1 = NULL;
744 <      if ((esupport&(E_VARIABLE|E_FUNCTION)) == (E_VARIABLE|E_FUNCTION)
745 <                        && curfunc != NULL)
746 <            for (i = 1, ep2 = curfunc->v.kid->sibling;
747 <                                ep2 != NULL; i++, ep2 = ep2->sibling)
748 <                if (!strcmp(ep2->v.name, nam)) {
749 <                    ep1 = newnode();
750 <                    ep1->type = ARG;
751 <                    ep1->v.chan = i;
752 <                    break;
740 >        if (esupport&(E_VARIABLE|E_FUNCTION) &&
741 >                        (isalpha(nextc) || nextc == CNTXMARK)) {
742 >                nam = getname();
743 >                ep1 = NULL;
744 >                if ((esupport&(E_VARIABLE|E_FUNCTION)) == (E_VARIABLE|E_FUNCTION)
745 >                                && curfunc != NULL)
746 >                        for (i = 1, ep2 = curfunc->v.kid->sibling;
747 >                                        ep2 != NULL; i++, ep2 = ep2->sibling)
748 >                                if (!strcmp(ep2->v.name, nam)) {
749 >                                        ep1 = newnode();
750 >                                        ep1->type = ARG;
751 >                                        ep1->v.chan = i;
752 >                                        break;
753 >                                }
754 >                if (ep1 == NULL) {
755 >                        ep1 = newnode();
756 >                        ep1->type = VAR;
757 >                        ep1->v.ln = varinsert(nam);
758                  }
759 <        if (ep1 == NULL) {
760 <            ep1 = newnode();
761 <            ep1->type = VAR;
762 <            ep1->v.ln = varinsert(nam);
759 >                if (esupport&E_FUNCTION && nextc == '(') {
760 >                        ep2 = newnode();
761 >                        ep2->type = FUNC;
762 >                        addekid(ep2, ep1);
763 >                        ep1 = ep2;
764 >                        do {
765 >                                scan();
766 >                                addekid(ep1, getE1());
767 >                        } while (nextc == ',');
768 >                        if (nextc != ')')
769 >                                syntax("')' expected");
770 >                        scan();
771 >                } else if (!(esupport&E_VARIABLE))
772 >                        syntax("'(' expected");
773 >                if (esupport&E_RCONST && isconstvar(ep1))
774 >                        ep1 = rconst(ep1);
775 >                return(ep1);
776          }
691        if (esupport&E_FUNCTION && nextc == '(') {
692            ep2 = newnode();
693            ep2->type = FUNC;
694            addekid(ep2, ep1);
695            ep1 = ep2;
696            do {
697                scan();
698                addekid(ep1, getE1());
699            } while (nextc == ',');
700            if (nextc != ')')
701                syntax("')' expected");
702            scan();
703        } else if (!(esupport&E_VARIABLE))
704            syntax("'(' expected");
705        if (esupport&E_RCONST && isconstvar(ep1))
706            ep1 = rconst(ep1);
707        return(ep1);
708    }
777  
778 <    if (isdecimal(nextc)) {
779 <        ep1 = newnode();
780 <        ep1->type = NUM;
781 <        ep1->v.num = getnum();
782 <        return(ep1);
783 <    }
784 <    syntax("unexpected character");
778 >        if (isdecimal(nextc)) {
779 >                ep1 = newnode();
780 >                ep1->type = NUM;
781 >                ep1->v.num = getnum();
782 >                return(ep1);
783 >        }
784 >        syntax("unexpected character");
785 >        return NULL; /* pro forma return */
786   }
787  
788  
789   EPNODE *
790 < rconst(epar)                    /* reduce a constant expression */
791 < register EPNODE  *epar;
790 > rconst(                 /* reduce a constant expression */
791 >    register EPNODE      *epar
792 > )
793   {
794      register EPNODE  *ep;
795  
# Line 736 | Line 806 | register EPNODE         *epar;
806  
807  
808   int
809 < isconstvar(ep)                  /* is ep linked to a constant expression? */
810 < register EPNODE  *ep;
809 > isconstvar(                     /* is ep linked to a constant expression? */
810 >    register EPNODE      *ep
811 > )
812   {
813      register EPNODE  *ep1;
814  
# Line 761 | Line 832 | register EPNODE         *ep;
832  
833  
834   int
835 < isconstfun(ep)                  /* is ep linked to a constant function? */
836 < register EPNODE  *ep;
835 > isconstfun(                     /* is ep linked to a constant function? */
836 >    register EPNODE      *ep
837 > )
838   {
839      register EPNODE  *dp;
840      register LIBR  *lp;
841  
842      if (ep->type != VAR)
843          return(0);
844 <    if ((dp = ep->v.ln->def) != NULL)
844 >    if ((dp = ep->v.ln->def) != NULL) {
845          if (dp->v.kid->type == FUNC)
846              return(dp->type == ':');
847          else
848              return(0);          /* don't identify masked library functions */
849 +    }
850      if ((lp = ep->v.ln->lib) != NULL)
851          return(lp->atyp == ':');
852      return(0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines