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

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/make/cond.c between version 1.14 and 1.19

version 1.14, 2002/12/30 18:03:09 version 1.19, 2004/01/06 01:18:52
Line 2 
Line 2 
   
 /*  /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.   * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
    * All rights reserved.
    *
    * This code is derived from software contributed to Berkeley by
    * Adam de Boor.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the
    *    documentation and/or other materials provided with the distribution.
    * 3. Neither the name of the University nor the names of its contributors
    *    may be used to endorse or promote products derived from this software
    *    without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    * SUCH DAMAGE.
    */
   
   /*
  * Copyright (c) 1988, 1989 by Adam de Boor   * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks   * Copyright (c) 1989 by Berkeley Softworks
  * All rights reserved.   * All rights reserved.
Line 61  __RCSID("$NetBSD$");
Line 92  __RCSID("$NetBSD$");
  */   */
   
 #include    <ctype.h>  #include    <ctype.h>
 #include    <math.h>  
   
 #include    "make.h"  #include    "make.h"
 #include    "hash.h"  #include    "hash.h"
Line 108  typedef enum {
Line 138  typedef enum {
  * last two fields are stored in condInvert and condDefProc, respectively.   * last two fields are stored in condInvert and condDefProc, respectively.
  */   */
 static void CondPushBack(Token);  static void CondPushBack(Token);
 static int CondGetArg(char **, char **, char *, Boolean);  static int CondGetArg(char **, char **, const char *, Boolean);
 static Boolean CondDoDefined(int, char *);  static Boolean CondDoDefined(int, char *);
 static int CondStrMatch(ClientData, ClientData);  static int CondStrMatch(ClientData, ClientData);
 static Boolean CondDoMake(int, char *);  static Boolean CondDoMake(int, char *);
 static Boolean CondDoExists(int, char *);  static Boolean CondDoExists(int, char *);
 static Boolean CondDoTarget(int, char *);  static Boolean CondDoTarget(int, char *);
 static Boolean CondDoCommands(int, char *);  static Boolean CondDoCommands(int, char *);
 static Boolean CondCvtArg(char *, double *);  static char * CondCvtArg(char *, double *);
 static Token CondToken(Boolean);  static Token CondToken(Boolean);
 static Token CondT(Boolean);  static Token CondT(Boolean);
 static Token CondF(Boolean);  static Token CondF(Boolean);
 static Token CondE(Boolean);  static Token CondE(Boolean);
   
 static struct If {  static struct If {
     char        *form;        /* Form of if */      const char  *form;        /* Form of if */
     int         formlen;      /* Length of form */      int         formlen;      /* Length of form */
     Boolean     doNot;        /* TRUE if default function should be negated */      Boolean     doNot;        /* TRUE if default function should be negated */
     Boolean     (*defProc)(int, char *); /* Default function to apply */      Boolean     (*defProc)(int, char *); /* Default function to apply */
Line 190  CondPushBack(Token t)
Line 220  CondPushBack(Token t)
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  */   */
 static int  static int
 CondGetArg(char **linePtr, char **argPtr, char *func, Boolean parens)  CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
 {  {
     char          *cp;      char          *cp;
     int           argLen;      int           argLen;
Line 461  CondDoCommands(int argLen, char *arg)
Line 491  CondDoCommands(int argLen, char *arg)
  *   *
  * Results:   * Results:
  *      Sets 'value' to double value of string.   *      Sets 'value' to double value of string.
  *      Returns true if the string was a valid number, false o.w.   *      Returns NULL if string was fully consumed,
    *      else returns remaining input.
  *   *
  * Side Effects:   * Side Effects:
  *      Can change 'value' even if string is not a valid number.   *      Can change 'value' even if string is not a valid number.
Line 469  CondDoCommands(int argLen, char *arg)
Line 500  CondDoCommands(int argLen, char *arg)
  *   *
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  */   */
 static Boolean  static char *
 CondCvtArg(char *str, double *value)  CondCvtArg(char *str, double *value)
 {  {
     if ((*str == '0') && (str[1] == 'x')) {      if ((*str == '0') && (str[1] == 'x')) {
Line 482  CondCvtArg(char *str, double *value)
Line 513  CondCvtArg(char *str, double *value)
             else if (isxdigit((unsigned char) *str))              else if (isxdigit((unsigned char) *str))
                 x = 10 + *str - isupper((unsigned char) *str) ? 'A' : 'a';                  x = 10 + *str - isupper((unsigned char) *str) ? 'A' : 'a';
             else              else
                 return FALSE;                  break;
             i = (i << 4) + x;              i = (i << 4) + x;
         }          }
         *value = (double) i;          *value = (double) i;
         return TRUE;          return *str ? str : NULL;
     }      } else {
     else {  
         char *eptr;          char *eptr;
         *value = strtod(str, &eptr);          *value = strtod(str, &eptr);
         return *eptr == '\0';          return *eptr ? eptr : NULL;
     }      }
 }  }
   
Line 619  CondToken(Boolean doEval)
Line 649  CondToken(Boolean doEval)
                         }                          }
                         break;                          break;
                     default:                      default:
                         op = "!=";                          op = UNCONST("!=");
                         rhs = "0";                          rhs = UNCONST("0");
   
                         goto do_compare;                          goto do_compare;
                 }                  }
Line 717  do_string_compare:
Line 747  do_string_compare:
                     double      left, right;                      double      left, right;
                     char        *string;                      char        *string;
   
                     if (!CondCvtArg(lhs, &left))                      if (CondCvtArg(lhs, &left))
                         goto do_string_compare;                          goto do_string_compare;
                     if (*rhs == '$') {                      if (*rhs == '$') {
                         int     len;                          int     len;
Line 727  do_string_compare:
Line 757  do_string_compare:
                         if (string == var_Error) {                          if (string == var_Error) {
                             right = 0.0;                              right = 0.0;
                         } else {                          } else {
                             if (!CondCvtArg(string, &right)) {                              if (CondCvtArg(string, &right)) {
                                 if (freeIt)                                  if (freeIt)
                                     free(string);                                      free(string);
                                 goto do_string_compare;                                  goto do_string_compare;
Line 738  do_string_compare:
Line 768  do_string_compare:
                                 condExpr += len;                                  condExpr += len;
                         }                          }
                     } else {                      } else {
                         if (!CondCvtArg(rhs, &right))                          char *cp;
   
                           if ((cp = CondCvtArg(rhs, &right)) &&
                               cp == rhs)
                             goto do_string_compare;                              goto do_string_compare;
                         if (rhs == condExpr) {                          if (rhs == condExpr) {
                             /*                              /*
                              * Skip over the right-hand side                               * Skip over the right-hand side
                              */                               */
                             while(!isspace((unsigned char) *condExpr) &&                              if (cp)
                                   (*condExpr != '\0')) {                                  condExpr = cp;
                                 condExpr++;                              else
                             }                                  condExpr = strchr(rhs, '\0');
                         }                          }
                     }                      }
   
Line 856  error:
Line 889  error:
   
                     if (condExpr[arglen] != '\0') {                      if (condExpr[arglen] != '\0') {
                         val = Var_Parse(&condExpr[arglen - 1], VAR_CMD,                          val = Var_Parse(&condExpr[arglen - 1], VAR_CMD,
                                         doEval, &length, &doFree);                                          FALSE, &length, &doFree);
                         if (val == var_Error) {                          if (val == var_Error) {
                             t = Err;                              t = Err;
                         } else {                          } else {

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.19

CVSweb <webmaster@jp.NetBSD.org>