Ignore:
Timestamp:
Nov 26, 2002, 10:24:54 PM (23 years ago)
Author:
bird
Message:

Import of RELENG_4_7_0_RELEASE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FREEBSD/src/kmk/cond.c

    r10 r24  
    11/*
    2  * Copyright (c) 1988, 1989, 1990, 1993
    3  *      The Regents of the University of California.  All rights reserved.
     2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
    43 * Copyright (c) 1988, 1989 by Adam de Boor
    54 * Copyright (c) 1989 by Berkeley Softworks
     
    3635 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3736 * SUCH DAMAGE.
    38  *
    39  * @(#)cond.c   8.2 (Berkeley) 1/2/94
    40  */
    41 
    42 #include <sys/cdefs.h>
    43 __FBSDID("$FreeBSD: src/usr.bin/make/cond.c,v 1.24 2002/10/09 03:42:09 jmallett Exp $");
     37 */
     38
     39#ifndef lint
     40#if 0
     41static char sccsid[] = "@(#)cond.c      8.2 (Berkeley) 1/2/94";
     42#else
     43static const char rcsid[] =
     44  "$FreeBSD: src/usr.bin/make/cond.c,v 1.12 1999/09/11 13:08:01 hoek Exp $";
     45#endif
     46#endif /* not lint */
    4447
    4548/*-
     
    97100 * last two fields are stored in condInvert and condDefProc, respectively.
    98101 */
    99 static void CondPushBack(Token);
    100 static int CondGetArg(char **, char **, char *, Boolean);
    101 static Boolean CondDoDefined(int, char *);
    102 static int CondStrMatch(void *, void *);
    103 static Boolean CondDoMake(int, char *);
    104 static Boolean CondDoExists(int, char *);
    105 static Boolean CondDoTarget(int, char *);
    106 static char * CondCvtArg(char *, double *);
    107 static Token CondToken(Boolean);
    108 static Token CondT(Boolean);
    109 static Token CondF(Boolean);
    110 static Token CondE(Boolean);
     102static void CondPushBack __P((Token));
     103static int CondGetArg __P((char **, char **, char *, Boolean));
     104static Boolean CondDoDefined __P((int, char *));
     105static int CondStrMatch __P((ClientData, ClientData));
     106static Boolean CondDoMake __P((int, char *));
     107static Boolean CondDoExists __P((int, char *));
     108static Boolean CondDoTarget __P((int, char *));
     109static char * CondCvtArg __P((char *, double *));
     110static Token CondToken __P((Boolean));
     111static Token CondT __P((Boolean));
     112static Token CondF __P((Boolean));
     113static Token CondE __P((Boolean));
    111114
    112115static struct If {
     
    114117    int         formlen;      /* Length of form */
    115118    Boolean     doNot;        /* TRUE if default function should be negated */
    116     Boolean     (*defProc)(int, char *); /* Default function to apply */
     119    Boolean     (*defProc) __P((int, char *)); /* Default function to apply */
    117120} ifs[] = {
    118121    { "ifdef",    5,      FALSE,  CondDoDefined },
     
    126129static Boolean    condInvert;           /* Invert the default function */
    127130static Boolean    (*condDefProc)        /* Default function to apply */
    128 (int, char *);
     131                    __P((int, char *));
    129132static char       *condExpr;            /* The expression to parse */
    130133static Token      condPushBack=None;    /* Single push-back token used in
     
    154157 */
    155158static void
    156 CondPushBack (Token t)
     159CondPushBack (t)
     160    Token         t;    /* Token to push back into the "stream" */
    157161{
    158162    condPushBack = t;
     
    163167 *-----------------------------------------------------------------------
    164168 * CondGetArg --
    165  *      Find the argument of a built-in function.  parens is set to TRUE
    166  *      if the arguments are bounded by parens.
     169 *      Find the argument of a built-in function.
    167170 *
    168171 * Results:
     
    176179 */
    177180static int
    178 CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens)
    179 {
    180     char          *cp;
     181CondGetArg (linePtr, argPtr, func, parens)
     182    char          **linePtr;
     183    char          **argPtr;
     184    char          *func;
     185    Boolean       parens;       /* TRUE if arg should be bounded by parens */
     186{
     187    register char *cp;
    181188    int           argLen;
    182     Buffer        buf;
     189    register Buffer buf;
    183190
    184191    cp = *linePtr;
     
    275282 */
    276283static Boolean
    277 CondDoDefined (int argLen, char *arg)
     284CondDoDefined (argLen, arg)
     285    int     argLen;
     286    char    *arg;
    278287{
    279288    char    savec = arg[argLen];
     
    308317 */
    309318static int
    310 CondStrMatch(void *string, void *pattern)
     319CondStrMatch(string, pattern)
     320    ClientData    string;
     321    ClientData    pattern;
    311322{
    312323    return(!Str_Match((char *) string,(char *) pattern));
     
    328339 */
    329340static Boolean
    330 CondDoMake (int argLen, char *arg)
     341CondDoMake (argLen, arg)
     342    int     argLen;
     343    char    *arg;
    331344{
    332345    char    savec = arg[argLen];
     
    334347
    335348    arg[argLen] = '\0';
    336     if (Lst_Find (create, (void *)arg, CondStrMatch) == NULL) {
     349    if (Lst_Find (create, (ClientData)arg, CondStrMatch) == NILLNODE) {
    337350        result = FALSE;
    338351    } else {
     
    358371 */
    359372static Boolean
    360 CondDoExists (int argLen, char *arg)
     373CondDoExists (argLen, arg)
     374    int     argLen;
     375    char    *arg;
    361376{
    362377    char    savec = arg[argLen];
     
    391406 */
    392407static Boolean
    393 CondDoTarget (int argLen, char *arg)
     408CondDoTarget (argLen, arg)
     409    int     argLen;
     410    char    *arg;
    394411{
    395412    char    savec = arg[argLen];
     
    399416    arg[argLen] = '\0';
    400417    gn = Targ_FindNode(arg, TARG_NOCREATE);
    401     if ((gn != NULL) && !OP_NOP(gn->type)) {
     418    if ((gn != NILGNODE) && !OP_NOP(gn->type)) {
    402419        result = TRUE;
    403420    } else {
     
    430447 */
    431448static char *
    432 CondCvtArg(char *str, double *value)
     449CondCvtArg(str, value)
     450    register char       *str;
     451    double              *value;
    433452{
    434453    if ((*str == '0') && (str[1] == 'x')) {
    435         long i;
     454        register long i;
    436455
    437456        for (str += 2, i = 0; ; str++) {
     
    470489 */
    471490static Token
    472 CondToken(Boolean doEval)
     491CondToken(doEval)
     492    Boolean doEval;
    473493{
    474494    Token         t;
     
    649669                    Buf_Destroy(buf, FALSE);
    650670
    651                     DEBUGF(COND, ("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
    652                            lhs, string, op));
     671                    if (DEBUG(COND)) {
     672                        printf("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
     673                               lhs, string, op);
     674                    }
    653675                    /*
    654676                     * Null-terminate rhs and perform the comparison.
     
    697719                    } else {
    698720                        char *c = CondCvtArg(rhs, &right);
    699                         if (*c != '\0' && !isspace((unsigned char) *c))
     721                        if (*c != '\0' && !isspace(*c))
    700722                            goto do_string_compare;
    701723                        if (rhs == condExpr) {
     
    710732                    }
    711733
    712                     DEBUGF(COND, ("left = %f, right = %f, op = %.2s\n", left,
    713                            right, op));
     734                    if (DEBUG(COND)) {
     735                        printf("left = %f, right = %f, op = %.2s\n", left,
     736                               right, op);
     737                    }
    714738                    switch(op[0]) {
    715739                    case '!':
     
    743767                        }
    744768                        break;
    745                     default:
    746                         break;
    747769                    }
    748770                }
     
    753775            }
    754776            default: {
    755                 Boolean (*evalProc)(int, char *);
     777                Boolean (*evalProc) __P((int, char *));
    756778                Boolean invert = FALSE;
    757779                char    *arg;
     
    906928 */
    907929static Token
    908 CondT(Boolean doEval)
     930CondT(doEval)
     931    Boolean doEval;
    909932{
    910933    Token   t;
     
    955978 */
    956979static Token
    957 CondF(Boolean doEval)
     980CondF(doEval)
     981    Boolean doEval;
    958982{
    959983    Token   l, o;
     
    10021026 */
    10031027static Token
    1004 CondE(Boolean doEval)
     1028CondE(doEval)
     1029    Boolean doEval;
    10051030{
    10061031    Token   l, o;
     
    10571082 */
    10581083int
    1059 Cond_Eval (char *line)
     1084Cond_Eval (line)
     1085    char            *line;    /* Line to parse */
    10601086{
    10611087    struct If       *ifp;
     
    12381264 */
    12391265void
    1240 Cond_End(void)
     1266Cond_End()
    12411267{
    12421268    if (condTop != MAXIF) {
Note: See TracChangeset for help on using the changeset viewer.