Changeset 24 for branches/FREEBSD/src/kmk/cond.c
- Timestamp:
- Nov 26, 2002, 10:24:54 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/cond.c
r10 r24 1 1 /* 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. 4 3 * Copyright (c) 1988, 1989 by Adam de Boor 5 4 * Copyright (c) 1989 by Berkeley Softworks … … 36 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 36 * 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 41 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; 42 #else 43 static 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 */ 44 47 45 48 /*- … … 97 100 * last two fields are stored in condInvert and condDefProc, respectively. 98 101 */ 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);102 static void CondPushBack __P((Token)); 103 static int CondGetArg __P((char **, char **, char *, Boolean)); 104 static Boolean CondDoDefined __P((int, char *)); 105 static int CondStrMatch __P((ClientData, ClientData)); 106 static Boolean CondDoMake __P((int, char *)); 107 static Boolean CondDoExists __P((int, char *)); 108 static Boolean CondDoTarget __P((int, char *)); 109 static char * CondCvtArg __P((char *, double *)); 110 static Token CondToken __P((Boolean)); 111 static Token CondT __P((Boolean)); 112 static Token CondF __P((Boolean)); 113 static Token CondE __P((Boolean)); 111 114 112 115 static struct If { … … 114 117 int formlen; /* Length of form */ 115 118 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 */ 117 120 } ifs[] = { 118 121 { "ifdef", 5, FALSE, CondDoDefined }, … … 126 129 static Boolean condInvert; /* Invert the default function */ 127 130 static Boolean (*condDefProc) /* Default function to apply */ 128 (int, char *);131 __P((int, char *)); 129 132 static char *condExpr; /* The expression to parse */ 130 133 static Token condPushBack=None; /* Single push-back token used in … … 154 157 */ 155 158 static void 156 CondPushBack (Token t) 159 CondPushBack (t) 160 Token t; /* Token to push back into the "stream" */ 157 161 { 158 162 condPushBack = t; … … 163 167 *----------------------------------------------------------------------- 164 168 * 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. 167 170 * 168 171 * Results: … … 176 179 */ 177 180 static int 178 CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens) 179 { 180 char *cp; 181 CondGetArg (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; 181 188 int argLen; 182 Bufferbuf;189 register Buffer buf; 183 190 184 191 cp = *linePtr; … … 275 282 */ 276 283 static Boolean 277 CondDoDefined (int argLen, char *arg) 284 CondDoDefined (argLen, arg) 285 int argLen; 286 char *arg; 278 287 { 279 288 char savec = arg[argLen]; … … 308 317 */ 309 318 static int 310 CondStrMatch(void *string, void *pattern) 319 CondStrMatch(string, pattern) 320 ClientData string; 321 ClientData pattern; 311 322 { 312 323 return(!Str_Match((char *) string,(char *) pattern)); … … 328 339 */ 329 340 static Boolean 330 CondDoMake (int argLen, char *arg) 341 CondDoMake (argLen, arg) 342 int argLen; 343 char *arg; 331 344 { 332 345 char savec = arg[argLen]; … … 334 347 335 348 arg[argLen] = '\0'; 336 if (Lst_Find (create, ( void *)arg, CondStrMatch) == NULL) {349 if (Lst_Find (create, (ClientData)arg, CondStrMatch) == NILLNODE) { 337 350 result = FALSE; 338 351 } else { … … 358 371 */ 359 372 static Boolean 360 CondDoExists (int argLen, char *arg) 373 CondDoExists (argLen, arg) 374 int argLen; 375 char *arg; 361 376 { 362 377 char savec = arg[argLen]; … … 391 406 */ 392 407 static Boolean 393 CondDoTarget (int argLen, char *arg) 408 CondDoTarget (argLen, arg) 409 int argLen; 410 char *arg; 394 411 { 395 412 char savec = arg[argLen]; … … 399 416 arg[argLen] = '\0'; 400 417 gn = Targ_FindNode(arg, TARG_NOCREATE); 401 if ((gn != N ULL) && !OP_NOP(gn->type)) {418 if ((gn != NILGNODE) && !OP_NOP(gn->type)) { 402 419 result = TRUE; 403 420 } else { … … 430 447 */ 431 448 static char * 432 CondCvtArg(char *str, double *value) 449 CondCvtArg(str, value) 450 register char *str; 451 double *value; 433 452 { 434 453 if ((*str == '0') && (str[1] == 'x')) { 435 long i;454 register long i; 436 455 437 456 for (str += 2, i = 0; ; str++) { … … 470 489 */ 471 490 static Token 472 CondToken(Boolean doEval) 491 CondToken(doEval) 492 Boolean doEval; 473 493 { 474 494 Token t; … … 649 669 Buf_Destroy(buf, FALSE); 650 670 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 } 653 675 /* 654 676 * Null-terminate rhs and perform the comparison. … … 697 719 } else { 698 720 char *c = CondCvtArg(rhs, &right); 699 if (*c != '\0' && !isspace( (unsigned char)*c))721 if (*c != '\0' && !isspace(*c)) 700 722 goto do_string_compare; 701 723 if (rhs == condExpr) { … … 710 732 } 711 733 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 } 714 738 switch(op[0]) { 715 739 case '!': … … 743 767 } 744 768 break; 745 default:746 break;747 769 } 748 770 } … … 753 775 } 754 776 default: { 755 Boolean (*evalProc) (int, char *);777 Boolean (*evalProc) __P((int, char *)); 756 778 Boolean invert = FALSE; 757 779 char *arg; … … 906 928 */ 907 929 static Token 908 CondT(Boolean doEval) 930 CondT(doEval) 931 Boolean doEval; 909 932 { 910 933 Token t; … … 955 978 */ 956 979 static Token 957 CondF(Boolean doEval) 980 CondF(doEval) 981 Boolean doEval; 958 982 { 959 983 Token l, o; … … 1002 1026 */ 1003 1027 static Token 1004 CondE(Boolean doEval) 1028 CondE(doEval) 1029 Boolean doEval; 1005 1030 { 1006 1031 Token l, o; … … 1057 1082 */ 1058 1083 int 1059 Cond_Eval (char *line) 1084 Cond_Eval (line) 1085 char *line; /* Line to parse */ 1060 1086 { 1061 1087 struct If *ifp; … … 1238 1264 */ 1239 1265 void 1240 Cond_End( void)1266 Cond_End() 1241 1267 { 1242 1268 if (condTop != MAXIF) {
Note:
See TracChangeset
for help on using the changeset viewer.