[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.31 and 1.32

version 1.31, 2006/01/20 23:10:19 version 1.32, 2007/01/04 18:01:32
Line 75 
Line 75 
  *      T -> $(varspec) op value   *      T -> $(varspec) op value
  *      T -> $(varspec) == "string"   *      T -> $(varspec) == "string"
  *      T -> $(varspec) != "string"   *      T -> $(varspec) != "string"
    *      T -> "string" == "string"
    *      T -> "string" != "string"
  *      T -> ( E )   *      T -> ( E )
  *      T -> ! T   *      T -> ! T
  *      op -> == | != | > | < | >= | <=   *      op -> == | != | > | < | >= | <=
Line 110 
Line 112 
 static Token CondE(bool);  static Token CondE(bool);
 static Token CondHandleVarSpec(bool);  static Token CondHandleVarSpec(bool);
 static Token CondHandleDefault(bool);  static Token CondHandleDefault(bool);
   static Token CondHandleComparison(char *, bool, bool);
   static Token CondHandleString(bool);
 static const char *find_cond(const char *);  static const char *find_cond(const char *);
   
   
Line 365 
Line 369 
 static Token  static Token
 CondHandleVarSpec(bool doEval)  CondHandleVarSpec(bool doEval)
 {  {
     Token       t;  
     char        *lhs;      char        *lhs;
     const char  *rhs;  
     const char  *op;  
     size_t      varSpecLen;      size_t      varSpecLen;
     bool        doFree;      bool        doFree;
   
     /* Parse the variable spec and skip over it, saving its      /* Parse the variable spec and skip over it, saving its
      * value in lhs.  */       * value in lhs.  */
     t = Err;  
     lhs = Var_Parse(condExpr, NULL, doEval,&varSpecLen,&doFree);      lhs = Var_Parse(condExpr, NULL, doEval,&varSpecLen,&doFree);
     if (lhs == var_Error)      if (lhs == var_Error)
         /* Even if !doEval, we still report syntax errors, which          /* Even if !doEval, we still report syntax errors, which
Line 396 
Line 396 
         for (;*condExpr && !isspace(*condExpr); condExpr++)          for (;*condExpr && !isspace(*condExpr); condExpr++)
             Buf_AddChar(&buf, *condExpr);              Buf_AddChar(&buf, *condExpr);
   
         lhs = Buf_Retrieve(&buf);          lhs = Var_Subst(Buf_Retrieve(&buf), NULL, doEval);
           Buf_Destroy(&buf);
         doFree = true;          doFree = true;
     }      }
   
       return CondHandleComparison(lhs, doFree, doEval);
   }
   
   static Token
   CondHandleString(bool doEval)
   {
           char *lhs;
           const char *begin;
           BUFFER buf;
   
           /* find the extent of the string */
           begin = ++condExpr;
           while (*condExpr && *condExpr != '"') {
                   condExpr++;
           }
   
           Buf_Init(&buf, 0);
           Buf_Addi(&buf, begin, condExpr);
           if (*condExpr == '"')
                   condExpr++;
           lhs = Var_Subst(Buf_Retrieve(&buf), NULL, doEval);
           Buf_Destroy(&buf);
           return CondHandleComparison(lhs, true, doEval);
   }
   
   static Token
   CondHandleComparison(char *lhs, bool doFree, bool doEval)
   {
       Token       t;
       const char  *rhs;
       const char  *op;
   
       t = Err;
     /* Skip whitespace to get to the operator.  */      /* Skip whitespace to get to the operator.  */
     while (isspace(*condExpr))      while (isspace(*condExpr))
         condExpr++;          condExpr++;
Line 707 
Line 740 
         case '\n':          case '\n':
         case '\0':          case '\0':
             return EndOfFile;              return EndOfFile;
           case '"':
               return CondHandleString(doEval);
         case '$':          case '$':
             return CondHandleVarSpec(doEval);              return CondHandleVarSpec(doEval);
         default:          default:

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32