=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/cond.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/make/cond.c 1996/06/26 05:36:28 1.2 --- src/usr.bin/make/cond.c 1996/11/30 21:08:52 1.3 *************** *** 1,5 **** ! /* $OpenBSD: cond.c,v 1.2 1996/06/26 05:36:28 deraadt Exp $ */ ! /* $NetBSD: cond.c,v 1.6 1995/06/14 15:18:58 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. --- 1,5 ---- ! /* $OpenBSD: cond.c,v 1.3 1996/11/30 21:08:52 millert Exp $ */ ! /* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. *************** *** 41,49 **** #ifndef lint #if 0 ! static char sccsid[] = "@(#)cond.c 5.6 (Berkeley) 6/1/90"; #else ! static char rcsid[] = "$OpenBSD: cond.c,v 1.2 1996/06/26 05:36:28 deraadt Exp $"; #endif #endif /* not lint */ --- 41,49 ---- #ifndef lint #if 0 ! static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else ! static char rcsid[] = "$OpenBSD: cond.c,v 1.3 1996/11/30 21:08:52 millert Exp $"; #endif #endif /* not lint */ *************** *** 101,106 **** --- 101,107 ---- * Structures to handle elegantly the different forms of #if's. The * last two fields are stored in condInvert and condDefProc, respectively. */ + static void CondPushBack __P((Token)); static int CondGetArg __P((char **, char **, char *, Boolean)); static Boolean CondDoDefined __P((int, char *)); static int CondStrMatch __P((ClientData, ClientData)); *************** *** 117,134 **** char *form; /* Form of if */ int formlen; /* Length of form */ Boolean doNot; /* TRUE if default function should be negated */ ! Boolean (*defProc)(); /* Default function to apply */ } ifs[] = { { "ifdef", 5, FALSE, CondDoDefined }, { "ifndef", 6, TRUE, CondDoDefined }, { "ifmake", 6, FALSE, CondDoMake }, { "ifnmake", 7, TRUE, CondDoMake }, { "if", 2, FALSE, CondDoDefined }, ! { (char *)0, 0, FALSE, (Boolean (*)())0 } }; static Boolean condInvert; /* Invert the default function */ ! static Boolean (*condDefProc)(); /* Default function to apply */ static char *condExpr; /* The expression to parse */ static Token condPushBack=None; /* Single push-back token used in * parsing */ --- 118,136 ---- char *form; /* Form of if */ int formlen; /* Length of form */ Boolean doNot; /* TRUE if default function should be negated */ ! Boolean (*defProc) __P((int, char *)); /* Default function to apply */ } ifs[] = { { "ifdef", 5, FALSE, CondDoDefined }, { "ifndef", 6, TRUE, CondDoDefined }, { "ifmake", 6, FALSE, CondDoMake }, { "ifnmake", 7, TRUE, CondDoMake }, { "if", 2, FALSE, CondDoDefined }, ! { NULL, 0, FALSE, NULL } }; static Boolean condInvert; /* Invert the default function */ ! static Boolean (*condDefProc) /* Default function to apply */ ! __P((int, char *)); static char *condExpr; /* The expression to parse */ static Token condPushBack=None; /* Single push-back token used in * parsing */ *************** *** 217,223 **** * long. Why 16? Why not? */ buf = Buf_Init(16); ! while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) { if (*cp == '$') { /* --- 219,225 ---- * long. Why 16? Why not? */ buf = Buf_Init(16); ! while ((strchr(" \t)&|", *cp) == (char *)NULL) && (*cp != '\0')) { if (*cp == '$') { /* *************** *** 260,266 **** */ cp++; } ! *linePtr = cp; return (argLen); } --- 262,268 ---- */ cp++; } ! *linePtr = cp; return (argLen); } *************** *** 434,441 **** * * Side Effects: * Can change 'value' even if string is not a valid number. - * * *----------------------------------------------------------------------- */ static Boolean --- 436,443 ---- * * Side Effects: * Can change 'value' even if string is not a valid number. * + * *----------------------------------------------------------------------- */ static Boolean *************** *** 624,633 **** buf = Buf_Init(0); qt = *rhs == '"' ? 1 : 0; ! ! for (cp = &rhs[qt]; ! ((qt && (*cp != '"')) || ! (!qt && strchr(" \t)", *cp) == NULL)) && (*cp != '\0'); cp++) { if ((*cp == '\\') && (cp[1] != '\0')) { /* --- 626,635 ---- buf = Buf_Init(0); qt = *rhs == '"' ? 1 : 0; ! ! for (cp = &rhs[qt]; ! ((qt && (*cp != '"')) || ! (!qt && strchr(" \t)", *cp) == NULL)) && (*cp != '\0'); cp++) { if ((*cp == '\\') && (cp[1] != '\0')) { /* *************** *** 639,645 **** } else if (*cp == '$') { int len; Boolean freeIt; ! cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt); if (cp2 != var_Error) { Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); --- 641,647 ---- } else if (*cp == '$') { int len; Boolean freeIt; ! cp2 = Var_Parse(cp, VAR_CMD, doEval,&len, &freeIt); if (cp2 != var_Error) { Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); *************** *** 693,699 **** if (*rhs == '$') { int len; Boolean freeIt; ! string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt); if (string == var_Error) { right = 0.0; --- 695,701 ---- if (*rhs == '$') { int len; Boolean freeIt; ! string = Var_Parse(rhs, VAR_CMD, doEval,&len,&freeIt); if (string == var_Error) { right = 0.0; *************** *** 721,727 **** } } } ! if (DEBUG(COND)) { printf("left = %f, right = %f, op = %.2s\n", left, right, op); --- 723,729 ---- } } } ! if (DEBUG(COND)) { printf("left = %f, right = %f, op = %.2s\n", left, right, op); *************** *** 765,775 **** break; } default: { ! Boolean (*evalProc)(); Boolean invert = FALSE; char *arg; int arglen; ! if (strncmp (condExpr, "defined", 7) == 0) { /* * Use CondDoDefined to evaluate the argument and --- 767,777 ---- break; } default: { ! Boolean (*evalProc) __P((int, char *)); Boolean invert = FALSE; char *arg; int arglen; ! if (strncmp (condExpr, "defined", 7) == 0) { /* * Use CondDoDefined to evaluate the argument and *************** *** 831,838 **** if (val == var_Error) { t = Err; } else { ! /* ! * A variable is empty when it just contains * spaces... 4/15/92, christos */ char *p; --- 833,840 ---- if (val == var_Error) { t = Err; } else { ! /* ! * A variable is empty when it just contains * spaces... 4/15/92, christos */ char *p; *************** *** 1114,1120 **** } else { isElse = FALSE; } ! /* * Figure out what sort of conditional it is -- what its default * function is, etc. -- by looking in the table of valid "ifs" --- 1116,1122 ---- } else { isElse = FALSE; } ! /* * Figure out what sort of conditional it is -- what its default * function is, etc. -- by looking in the table of valid "ifs" *************** *** 1174,1189 **** */ condDefProc = ifp->defProc; condInvert = ifp->doNot; ! line += ifp->formlen; ! while (*line == ' ' || *line == '\t') { line++; } ! condExpr = line; condPushBack = None; ! switch (CondE(TRUE)) { case True: if (CondToken(TRUE) == EndOfFile) { --- 1176,1191 ---- */ condDefProc = ifp->defProc; condInvert = ifp->doNot; ! line += ifp->formlen; ! while (*line == ' ' || *line == '\t') { line++; } ! condExpr = line; condPushBack = None; ! switch (CondE(TRUE)) { case True: if (CondToken(TRUE) == EndOfFile) {