[BACK]Return to cond.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/cond.c between version 1.15 and 1.16

version 1.15, 2000/03/26 16:21:32 version 1.16, 2000/04/17 23:50:45
Line 137 
Line 137 
   
 #define MAXIF           30        /* greatest depth of #if'ing */  #define MAXIF           30        /* greatest depth of #if'ing */
   
 static Boolean    condStack[MAXIF];     /* Stack of conditionals's values */  static struct {
           Boolean         value;
           unsigned long   lineno;
           const char      *filename;
   } condStack[MAXIF];                     /* Stack of conditionals */
 static int        condTop = MAXIF;      /* Top-most conditional */  static int        condTop = MAXIF;      /* Top-most conditional */
 static int        skipIfLevel=0;        /* Depth of skipped conditionals */  static int        skipIfLevel=0;        /* Depth of skipped conditionals */
 static Boolean    skipLine = FALSE;     /* Whether the parse module is skipping  static Boolean    skipLine = FALSE;     /* Whether the parse module is skipping
Line 1128 
Line 1132 
                 Parse_Error (level, "if-less else");                  Parse_Error (level, "if-less else");
                 return (COND_INVALID);                  return (COND_INVALID);
             } else if (skipIfLevel == 0) {              } else if (skipIfLevel == 0) {
                 value = !condStack[condTop];                  value = !condStack[condTop].value;
             } else {              } else {
                 return (COND_SKIP);                  return (COND_SKIP);
             }              }
Line 1201 
Line 1205 
     }      }
     if (!isElse) {      if (!isElse) {
         condTop -= 1;          condTop -= 1;
     } else if ((skipIfLevel != 0) || condStack[condTop]) {      } else if ((skipIfLevel != 0) || condStack[condTop].value) {
         /*          /*
          * If this is an else-type conditional, it should only take effect           * If this is an else-type conditional, it should only take effect
          * if its corresponding if was evaluated and FALSE. If its if was           * if its corresponding if was evaluated and FALSE. If its if was
Line 1221 
Line 1225 
         Parse_Error (PARSE_FATAL, "Too many nested if's. %d max.", MAXIF);          Parse_Error (PARSE_FATAL, "Too many nested if's. %d max.", MAXIF);
         return (COND_INVALID);          return (COND_INVALID);
     } else {      } else {
         condStack[condTop] = value;          condStack[condTop].value = value;
           condStack[condTop].lineno = Parse_Getlineno();
           condStack[condTop].filename = Parse_Getfilename();
         skipLine = !value;          skipLine = !value;
         return (value ? COND_PARSE : COND_SKIP);          return (value ? COND_PARSE : COND_SKIP);
     }      }
Line 1243 
Line 1249 
 void  void
 Cond_End()  Cond_End()
 {  {
       int i;
   
     if (condTop != MAXIF) {      if (condTop != MAXIF) {
         Parse_Error(PARSE_FATAL, "%d open conditional%s", MAXIF-condTop,          Parse_Error(PARSE_FATAL, "%d open conditional%s", MAXIF-condTop,
                     MAXIF-condTop == 1 ? "" : "s");                      MAXIF-condTop == 1 ? "" : "s");
           for (i = MAXIF-1; i >= condTop; i--) {
               fprintf(stderr, "\t at line %lu of %s\n", condStack[i].lineno,
                   condStack[i].filename);
           }
     }      }
     condTop = MAXIF;      condTop = MAXIF;
 }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16