Changeset 24 for branches/FREEBSD/src/kmk/parse.c
- Timestamp:
- Nov 26, 2002, 10:24:54 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/parse.c
r10 r24 35 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 36 * SUCH DAMAGE. 37 * 38 * @(#)parse.c 8.3 (Berkeley) 3/19/94 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/parse.c,v 1.48 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/parse.c,v 1.22 1999/08/28 01:03:35 peter Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 /*- … … 84 88 */ 85 89 90 #ifdef __STDC__ 86 91 #include <stdarg.h> 92 #else 93 #include <varargs.h> 94 #endif 87 95 #include <ctype.h> 88 96 #include <err.h> … … 178 186 179 187 /* 180 * Predecessor node for handling .ORDER. Initialized to N ULLwhen .ORDER188 * Predecessor node for handling .ORDER. Initialized to NILGNODE when .ORDER 181 189 * seen, then set to each successive source on the line. 182 190 */ … … 231 239 }; 232 240 233 static int ParseFindKeyword (char *);234 static int ParseLinkSrc (void *, void *);235 static int ParseDoOp (void *, void *);236 static int ParseAddDep (void *, void *);237 static void ParseDoSrc (int, char *, Lst);238 static int ParseFindMain (void *, void *);239 static int ParseAddDir (void *, void *);240 static int ParseClearPath (void *, void *);241 static void ParseDoDependency (char *);242 static int ParseAddCmd (void *, void *);243 static int ParseReadc (void);244 static void ParseUnreadc (int);245 static void ParseHasCommands (void *);246 static void ParseDoInclude (char *);247 static void ParseDoError (char *);241 static int ParseFindKeyword __P((char *)); 242 static int ParseLinkSrc __P((ClientData, ClientData)); 243 static int ParseDoOp __P((ClientData, ClientData)); 244 static int ParseAddDep __P((ClientData, ClientData)); 245 static void ParseDoSrc __P((int, char *, Lst)); 246 static int ParseFindMain __P((ClientData, ClientData)); 247 static int ParseAddDir __P((ClientData, ClientData)); 248 static int ParseClearPath __P((ClientData, ClientData)); 249 static void ParseDoDependency __P((char *)); 250 static int ParseAddCmd __P((ClientData, ClientData)); 251 static int ParseReadc __P((void)); 252 static void ParseUnreadc __P((int)); 253 static void ParseHasCommands __P((ClientData)); 254 static void ParseDoInclude __P((char *)); 255 static void ParseDoError __P((char *)); 248 256 #ifdef SYSVINCLUDE 249 static void ParseTraditionalInclude (char *);257 static void ParseTraditionalInclude __P((char *)); 250 258 #endif 251 static int ParseEOF (int);252 static char *ParseReadLine (void);253 static char *ParseSkipLine (int);254 static void ParseFinishLine (void);259 static int ParseEOF __P((int)); 260 static char *ParseReadLine __P((void)); 261 static char *ParseSkipLine __P((int)); 262 static void ParseFinishLine __P((void)); 255 263 256 264 /*- … … 267 275 */ 268 276 static int 269 ParseFindKeyword (char *str) 270 { 271 int start, 277 ParseFindKeyword (str) 278 char *str; /* String to find */ 279 { 280 register int start, 272 281 end, 273 282 cur; 274 intdiff;283 register int diff; 275 284 276 285 start = 0; … … 306 315 /* VARARGS */ 307 316 void 308 Parse_Error(int type, const char *fmt, ...) 317 #ifdef __STDC__ 318 Parse_Error(int type, char *fmt, ...) 319 #else 320 Parse_Error(va_alist) 321 va_dcl 322 #endif 309 323 { 310 324 va_list ap; 311 325 #ifdef __STDC__ 312 326 va_start(ap, fmt); 327 #else 328 int type; /* Error type (PARSE_WARNING, PARSE_FATAL) */ 329 char *fmt; 330 331 va_start(ap); 332 type = va_arg(ap, int); 333 fmt = va_arg(ap, char *); 334 #endif 335 313 336 (void)fprintf(stderr, "\"%s\", line %d: ", fname, lineno); 314 337 if (type == PARSE_WARNING) … … 339 362 */ 340 363 static int 341 ParseLinkSrc (void *pgnp, void *cgnp) 364 ParseLinkSrc (pgnp, cgnp) 365 ClientData pgnp; /* The parent node */ 366 ClientData cgnp; /* The child node */ 342 367 { 343 368 GNode *pgn = (GNode *) pgnp; 344 369 GNode *cgn = (GNode *) cgnp; 345 if (Lst_Member (pgn->children, ( void *)cgn) == NULL) {346 (void)Lst_AtEnd (pgn->children, ( void *)cgn);370 if (Lst_Member (pgn->children, (ClientData)cgn) == NILLNODE) { 371 (void)Lst_AtEnd (pgn->children, (ClientData)cgn); 347 372 if (specType == Not) { 348 (void)Lst_AtEnd (cgn->parents, ( void *)pgn);373 (void)Lst_AtEnd (cgn->parents, (ClientData)pgn); 349 374 } 350 375 pgn->unmade += 1; … … 370 395 */ 371 396 static int 372 ParseDoOp (void *gnp, void *opp) 397 ParseDoOp (gnp, opp) 398 ClientData gnp; /* The node to which the operator is to be 399 * applied */ 400 ClientData opp; /* The operator to apply */ 373 401 { 374 402 GNode *gn = (GNode *) gnp; … … 395 423 * instance. 396 424 */ 397 GNode*cohort;425 register GNode *cohort; 398 426 LstNode ln; 399 427 … … 408 436 * sorry. 409 437 */ 410 Lst_ForEach(gn->parents, ParseLinkSrc, ( void *)cohort);438 Lst_ForEach(gn->parents, ParseLinkSrc, (ClientData)cohort); 411 439 cohort->type = OP_DOUBLEDEP|OP_INVISIBLE; 412 (void)Lst_AtEnd(gn->cohorts, ( void *)cohort);440 (void)Lst_AtEnd(gn->cohorts, (ClientData)cohort); 413 441 414 442 /* 415 443 * Replace the node in the targets list with the new copy 416 444 */ 417 ln = Lst_Member(targets, ( void *)gn);418 Lst_Replace(ln, ( void *)cohort);445 ln = Lst_Member(targets, (ClientData)gn); 446 Lst_Replace(ln, (ClientData)cohort); 419 447 gn = cohort; 420 448 } … … 445 473 */ 446 474 static int 447 ParseAddDep(void *pp, void *sp) 475 ParseAddDep(pp, sp) 476 ClientData pp; 477 ClientData sp; 448 478 { 449 479 GNode *p = (GNode *) pp; … … 456 486 * problem 457 487 */ 458 (void)Lst_AtEnd(p->successors, ( void *)s);459 (void)Lst_AtEnd(s->preds, ( void *)p);488 (void)Lst_AtEnd(p->successors, (ClientData)s); 489 (void)Lst_AtEnd(s->preds, (ClientData)p); 460 490 return 0; 461 491 } … … 483 513 */ 484 514 static void 485 ParseDoSrc (int tOp, char *src, Lst allsrc) 515 ParseDoSrc (tOp, src, allsrc) 516 int tOp; /* operator (if any) from special targets */ 517 char *src; /* name of the source to handle */ 518 Lst allsrc; /* List of all sources to wait for */ 486 519 { 487 520 GNode *gn = NULL; 488 521 489 if (*src == '.' && isupper ( (unsigned char)src[1])) {522 if (*src == '.' && isupper (src[1])) { 490 523 int keywd = ParseFindKeyword(src); 491 524 if (keywd != -1) { 492 525 int op = parseKeywords[keywd].op; 493 526 if (op != 0) { 494 Lst_ForEach (targets, ParseDoOp, ( void *)&op);527 Lst_ForEach (targets, ParseDoOp, (ClientData)&op); 495 528 return; 496 529 } … … 512 545 * line. This is to allow #ifmake's to succeed, or something... 513 546 */ 514 (void) Lst_AtEnd (create, ( void *)estrdup(src));547 (void) Lst_AtEnd (create, (ClientData)estrdup(src)); 515 548 /* 516 549 * Add the name to the .TARGETS variable as well, so the user cna … … 526 559 */ 527 560 gn = Targ_FindNode(src, TARG_CREATE); 528 if (predecessor != N ULL) {529 (void)Lst_AtEnd(predecessor->successors, ( void *)gn);530 (void)Lst_AtEnd(gn->preds, ( void *)predecessor);561 if (predecessor != NILGNODE) { 562 (void)Lst_AtEnd(predecessor->successors, (ClientData)gn); 563 (void)Lst_AtEnd(gn->preds, (ClientData)predecessor); 531 564 } 532 565 /* … … 552 585 gn->type |= tOp; 553 586 } else { 554 Lst_ForEach (targets, ParseLinkSrc, ( void *)gn);587 Lst_ForEach (targets, ParseLinkSrc, (ClientData)gn); 555 588 } 556 589 if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) { 557 GNode *cohort;558 LstNode ln;559 560 for (ln=Lst_First(gn->cohorts); ln != N ULL; ln = Lst_Succ(ln)){590 register GNode *cohort; 591 register LstNode ln; 592 593 for (ln=Lst_First(gn->cohorts); ln != NILLNODE; ln = Lst_Succ(ln)){ 561 594 cohort = (GNode *)Lst_Datum(ln); 562 595 if (tOp) { 563 596 cohort->type |= tOp; 564 597 } else { 565 Lst_ForEach(targets, ParseLinkSrc, ( void *)cohort);598 Lst_ForEach(targets, ParseLinkSrc, (ClientData)cohort); 566 599 } 567 600 } … … 571 604 572 605 gn->order = waiting; 573 (void)Lst_AtEnd(allsrc, ( void *)gn);606 (void)Lst_AtEnd(allsrc, (ClientData)gn); 574 607 if (waiting) { 575 Lst_ForEach(allsrc, ParseAddDep, ( void *)gn);608 Lst_ForEach(allsrc, ParseAddDep, (ClientData)gn); 576 609 } 577 610 } … … 593 626 */ 594 627 static int 595 ParseFindMain(void *gnp, void *dummy __unused) 628 ParseFindMain(gnp, dummy) 629 ClientData gnp; /* Node to examine */ 630 ClientData dummy; 596 631 { 597 632 GNode *gn = (GNode *) gnp; … … 599 634 mainNode = gn; 600 635 Targ_SetMain(gn); 601 return ( 1);636 return (dummy ? 1 : 1); 602 637 } else { 603 return ( 0);638 return (dummy ? 0 : 0); 604 639 } 605 640 } … … 619 654 */ 620 655 static int 621 ParseAddDir(void *path, void *name) 656 ParseAddDir(path, name) 657 ClientData path; 658 ClientData name; 622 659 { 623 660 Dir_AddDir((Lst) path, (char *) name); … … 639 676 */ 640 677 static int 641 ParseClearPath(void *path, void *dummy __unused) 678 ParseClearPath(path, dummy) 679 ClientData path; 680 ClientData dummy; 642 681 { 643 682 Dir_ClearPath((Lst) path); 644 return (0);683 return(dummy ? 0 : 0); 645 684 } 646 685 … … 680 719 */ 681 720 static void 682 ParseDoDependency (char *line) 721 ParseDoDependency (line) 722 char *line; /* the line to parse */ 683 723 { 684 724 char *cp; /* our current position */ … … 706 746 do { 707 747 for (cp = line; 708 *cp && !isspace ((unsigned char) *cp) && *cp != '('; 748 *cp && !isspace (*cp) && 749 (*cp != '!') && (*cp != ':') && (*cp != '('); 709 750 cp++) 710 751 { … … 727 768 } 728 769 cp += length-1; 729 } else if (*cp == '!' || *cp == ':') {730 /*731 * We don't want to end a word on ':' or '!' if there is a732 * better match later on in the string. By "better" I mean733 * one that is followed by whitespace. This allows the user734 * to have targets like:735 * fie::fi:fo: fum736 * where "fie::fi:fo" is the target. In real life this is used737 * for perl5 library man pages where "::" separates an object738 * from its class. Ie: "File::Spec::Unix". This behaviour739 * is also consistent with other versions of make.740 */741 char *p = cp + 1;742 743 if (*cp == ':' && *p == ':')744 p++;745 746 /* Found the best match already. */747 if (*p == '\0' || isspace(*p))748 break;749 750 do {751 p += strcspn(p, "!:");752 if (*p == '\0')753 break;754 } while (!isspace(*++p));755 756 /* No better match later on... */757 if (*p == '\0')758 break;759 770 } 760 771 continue; … … 784 795 /* 785 796 * Ending a dependency line without an operator is a Bozo 786 * no-no. As a heuristic, this is also often triggered by 787 * undetected conflicts from cvs/rcs merges. 797 * no-no 788 798 */ 789 if ((strncmp(line, "<<<<<<", 6) == 0) || 790 (strncmp(line, "======", 6) == 0) || 791 (strncmp(line, ">>>>>>", 6) == 0)) 792 Parse_Error (PARSE_FATAL, 793 "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts"); 794 else 795 Parse_Error (PARSE_FATAL, "Need an operator"); 799 Parse_Error (PARSE_FATAL, "Need an operator"); 796 800 return; 797 801 } … … 801 805 * specType to match it. 802 806 */ 803 if (*line == '.' && isupper ( (unsigned char)line[1])) {807 if (*line == '.' && isupper (line[1])) { 804 808 /* 805 809 * See if the target is a special target that must have it … … 842 846 * .NOTPARALLEL Make only one target at a time. 843 847 * .SINGLESHELL Create a shell for each command. 844 * .ORDER Must set initial predecessor to N ULL848 * .ORDER Must set initial predecessor to NIL 845 849 */ 846 850 switch (specType) { … … 849 853 paths = Lst_Init(FALSE); 850 854 } 851 (void)Lst_AtEnd(paths, ( void *)dirSearchPath);855 (void)Lst_AtEnd(paths, (ClientData)dirSearchPath); 852 856 break; 853 857 case Main: … … 861 865 gn = Targ_FindNode(line, TARG_CREATE); 862 866 gn->type |= OP_NOTMAIN; 863 (void)Lst_AtEnd(targets, ( void *)gn);867 (void)Lst_AtEnd(targets, (ClientData)gn); 864 868 break; 865 869 case Default: 866 870 gn = Targ_NewGN(".DEFAULT"); 867 871 gn->type |= (OP_NOTMAIN|OP_TRANSFORM); 868 (void)Lst_AtEnd(targets, ( void *)gn);872 (void)Lst_AtEnd(targets, (ClientData)gn); 869 873 DEFAULT = gn; 870 874 break; 871 875 case NotParallel: 872 876 { 877 extern int maxJobs; 878 873 879 maxJobs = 1; 874 880 break; … … 878 884 break; 879 885 case Order: 880 predecessor = N ULL;886 predecessor = NILGNODE; 881 887 break; 882 888 default: … … 893 899 specType = ExPath; 894 900 path = Suff_GetPath (&line[5]); 895 if (path == N ULL) {901 if (path == NILLST) { 896 902 Parse_Error (PARSE_FATAL, 897 903 "Suffix '%s' not defined (yet)", … … 902 908 paths = Lst_Init(FALSE); 903 909 } 904 (void)Lst_AtEnd(paths, ( void *)path);910 (void)Lst_AtEnd(paths, (ClientData)path); 905 911 } 906 912 } … … 929 935 * so create a list with the word on it. 930 936 */ 931 (void)Lst_AtEnd(curTargs, ( void *)line);937 (void)Lst_AtEnd(curTargs, (ClientData)line); 932 938 } 933 939 … … 941 947 } 942 948 943 (void)Lst_AtEnd (targets, ( void *)gn);949 (void)Lst_AtEnd (targets, (ClientData)gn); 944 950 } 945 951 } else if (specType == ExPath && *line != '.' && *line != '\0') { … … 965 971 } 966 972 } else { 967 while (*cp && isspace ( (unsigned char)*cp)) {973 while (*cp && isspace (*cp)) { 968 974 cp++; 969 975 } … … 1018 1024 cp++; /* Advance beyond operator */ 1019 1025 1020 Lst_ForEach (targets, ParseDoOp, ( void *)&op);1026 Lst_ForEach (targets, ParseDoOp, (ClientData)&op); 1021 1027 1022 1028 /* 1023 1029 * Get to the first source 1024 1030 */ 1025 while (*cp && isspace ( (unsigned char)*cp)) {1031 while (*cp && isspace (*cp)) { 1026 1032 cp++; 1027 1033 } … … 1052 1058 break; 1053 1059 case ExPath: 1054 Lst_ForEach(paths, ParseClearPath, ( void *)NULL);1060 Lst_ForEach(paths, ParseClearPath, (ClientData)NULL); 1055 1061 break; 1056 1062 #ifdef POSIX … … 1112 1118 * has no valid suffix. 1113 1119 */ 1114 char savec h;1115 while (*cp && !isspace ( (unsigned char)*cp)) {1120 char savec; 1121 while (*cp && !isspace (*cp)) { 1116 1122 cp++; 1117 1123 } 1118 savec h= *cp;1124 savec = *cp; 1119 1125 *cp = '\0'; 1120 1126 switch (specType) { … … 1123 1129 break; 1124 1130 case ExPath: 1125 Lst_ForEach(paths, ParseAddDir, ( void *)line);1131 Lst_ForEach(paths, ParseAddDir, (ClientData)line); 1126 1132 break; 1127 1133 case Includes: … … 1137 1143 break; 1138 1144 } 1139 *cp = savec h;1140 if (savec h!= '\0') {1145 *cp = savec; 1146 if (savec != '\0') { 1141 1147 cp++; 1142 1148 } 1143 while (*cp && isspace ( (unsigned char)*cp)) {1149 while (*cp && isspace (*cp)) { 1144 1150 cp++; 1145 1151 } … … 1156 1162 * and handle them accordingly. 1157 1163 */ 1158 while (*cp && !isspace ( (unsigned char)*cp)) {1164 while (*cp && !isspace (*cp)) { 1159 1165 if ((*cp == '(') && (cp > line) && (cp[-1] != '$')) { 1160 1166 /* … … 1171 1177 1172 1178 if (*cp == '(') { 1173 GNode *gn p;1179 GNode *gn; 1174 1180 1175 1181 sources = Lst_Init (FALSE); … … 1181 1187 1182 1188 while (!Lst_IsEmpty (sources)) { 1183 gn p= (GNode *) Lst_DeQueue (sources);1184 ParseDoSrc (tOp, gn p->name, curSrcs);1189 gn = (GNode *) Lst_DeQueue (sources); 1190 ParseDoSrc (tOp, gn->name, curSrcs); 1185 1191 } 1186 1192 Lst_Destroy (sources, NOFREE); … … 1194 1200 ParseDoSrc (tOp, line, curSrcs); 1195 1201 } 1196 while (*cp && isspace ( (unsigned char)*cp)) {1202 while (*cp && isspace (*cp)) { 1197 1203 cp++; 1198 1204 } … … 1201 1207 } 1202 1208 1203 if (mainNode == N ULL) {1209 if (mainNode == NILGNODE) { 1204 1210 /* 1205 1211 * If we have yet to decide on a main target to make, in the … … 1208 1214 * (i.e. isn't a .USE or .EXEC rule) to be made. 1209 1215 */ 1210 Lst_ForEach (targets, ParseFindMain, ( void *)0);1216 Lst_ForEach (targets, ParseFindMain, (ClientData)0); 1211 1217 } 1212 1218 … … 1234 1240 */ 1235 1241 Boolean 1236 Parse_IsVar (char *line) 1237 { 1238 Boolean wasSpace = FALSE; /* set TRUE if found a space */ 1239 Boolean haveName = FALSE; /* Set TRUE if have a variable name */ 1242 Parse_IsVar (line) 1243 register char *line; /* the line to check */ 1244 { 1245 register Boolean wasSpace = FALSE; /* set TRUE if found a space */ 1246 register Boolean haveName = FALSE; /* Set TRUE if have a variable name */ 1240 1247 int level = 0; 1241 #define 1248 #define ISEQOPERATOR(c) \ 1242 1249 (((c) == '+') || ((c) == ':') || ((c) == '?') || ((c) == '!')) 1243 1250 … … 1335 1342 */ 1336 1343 void 1337 Parse_DoVar (char *line, GNode *ctxt) 1344 Parse_DoVar (line, ctxt) 1345 char *line; /* a line guaranteed to be a variable 1346 * assignment. This reduces error checks */ 1347 GNode *ctxt; /* Context in which to do the assignment */ 1338 1348 { 1339 1349 char *cp; /* pointer into line */ … … 1363 1373 */ 1364 1374 for (cp = line + 1; *cp != '='; cp++) { 1365 if (isspace ( (unsigned char)*cp)) {1375 if (isspace (*cp)) { 1366 1376 *cp = '\0'; 1367 1377 } … … 1419 1429 } 1420 1430 1421 while (isspace ( (unsigned char)*cp)) {1431 while (isspace (*cp)) { 1422 1432 cp++; 1423 1433 } … … 1440 1450 1441 1451 oldVars = FALSE; 1442 1443 /*1444 * make sure that we set the variable the first time to nothing1445 * so that it gets substituted!1446 */1447 if (!Var_Exists(line, ctxt))1448 Var_Set(line, "", ctxt);1449 1450 1452 cp = Var_Subst(NULL, cp, ctxt, FALSE); 1451 1453 oldVars = oldOldVars; … … 1456 1458 Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e. 1457 1459 * if any variable expansion was performed */ 1458 char *res, *err or;1460 char *res, *err; 1459 1461 1460 1462 if (strchr(cp, '$') != NULL) { … … 1468 1470 } 1469 1471 1470 res = Cmd_Exec(cp, &err or);1472 res = Cmd_Exec(cp, &err); 1471 1473 Var_Set(line, res, ctxt); 1472 1474 free(res); 1473 1475 1474 if (err or)1475 Parse_Error(PARSE_WARNING, err or, cp);1476 if (err) 1477 Parse_Error(PARSE_WARNING, err, cp); 1476 1478 1477 1479 if (freeCmd) … … 1497 1499 */ 1498 1500 static int 1499 ParseAddCmd(void *gnp, void *cmd) 1501 ParseAddCmd(gnp, cmd) 1502 ClientData gnp; /* the node to which the command is to be added */ 1503 ClientData cmd; /* the command to add */ 1500 1504 { 1501 1505 GNode *gn = (GNode *) gnp; … … 1503 1507 if (!(gn->type & OP_HAS_COMMANDS)) 1504 1508 (void)Lst_AtEnd(gn->commands, cmd); 1505 else1506 Parse_Error(PARSE_WARNING,1507 "duplicate script for target \"%s\" ignored",1508 gn->name);1509 1509 return(0); 1510 1510 } … … 1527 1527 */ 1528 1528 static void 1529 ParseHasCommands(void *gnp) 1529 ParseHasCommands(gnp) 1530 ClientData gnp; /* Node to examine */ 1530 1531 { 1531 1532 GNode *gn = (GNode *) gnp; … … 1550 1551 */ 1551 1552 void 1552 Parse_AddIncludeDir (char *dir) 1553 Parse_AddIncludeDir (dir) 1554 char *dir; /* The name of the directory to add */ 1553 1555 { 1554 1556 Dir_AddDir (parseIncPath, dir); … … 1566 1568 */ 1567 1569 static void 1568 ParseDoError(char *errmsg) 1569 { 1570 if (!isspace((unsigned char) *errmsg)) { 1570 ParseDoError(errmsg) 1571 char *errmsg; /* error message */ 1572 { 1573 if (!isspace(*errmsg)) { 1571 1574 Parse_Error(PARSE_WARNING, "invalid syntax: .error%s", errmsg); 1572 1575 return; 1573 1576 } 1574 1577 1575 while (isspace( (unsigned char)*errmsg))1578 while (isspace(*errmsg)) 1576 1579 errmsg++; 1577 1580 … … 1602 1605 */ 1603 1606 static void 1604 ParseDoInclude (char *file) 1607 ParseDoInclude (file) 1608 char *file; /* file specification */ 1605 1609 { 1606 1610 char *fullname; /* full pathname of file */ … … 1741 1745 oldFile->lineno = lineno; 1742 1746 1743 (void) Lst_AtFront (includes, ( void *)oldFile);1747 (void) Lst_AtFront (includes, (ClientData)oldFile); 1744 1748 1745 1749 /* … … 1779 1783 */ 1780 1784 void 1781 Parse_FromString(char *str) 1785 Parse_FromString(str) 1786 char *str; 1782 1787 { 1783 1788 IFile *oldFile; /* state associated with this file */ 1784 1789 1785 DEBUGF(FOR, ("%s\n----\n", str)); 1790 if (DEBUG(FOR)) 1791 (void) fprintf(stderr, "%s\n----\n", str); 1786 1792 1787 1793 oldFile = (IFile *) emalloc (sizeof (IFile)); … … 1791 1797 oldFile->p = curPTR; 1792 1798 1793 (void) Lst_AtFront (includes, ( void *)oldFile);1799 (void) Lst_AtFront (includes, (ClientData)oldFile); 1794 1800 1795 1801 curFILE = NULL; … … 1819 1825 */ 1820 1826 static void 1821 ParseTraditionalInclude (char *file) 1827 ParseTraditionalInclude (file) 1828 char *file; /* file specification */ 1822 1829 { 1823 1830 char *fullname; /* full pathname of file */ … … 1921 1928 oldFile->lineno = lineno; 1922 1929 1923 (void) Lst_AtFront (includes, ( void *)oldFile);1930 (void) Lst_AtFront (includes, (ClientData)oldFile); 1924 1931 1925 1932 /* … … 1960 1967 */ 1961 1968 static int 1962 ParseEOF (int opened) 1969 ParseEOF (opened) 1970 int opened; 1963 1971 { 1964 1972 IFile *ifile; /* the state on the top of the includes stack */ … … 1969 1977 1970 1978 ifile = (IFile *) Lst_DeQueue (includes); 1971 free ( fname);1979 free ((Address) fname); 1972 1980 fname = ifile->fname; 1973 1981 lineno = ifile->lineno; … … 1975 1983 (void) fclose (curFILE); 1976 1984 if (curPTR) { 1977 free( curPTR->str);1978 free( curPTR);1985 free((Address) curPTR->str); 1986 free((Address) curPTR); 1979 1987 } 1980 1988 curFILE = ifile->F; 1981 1989 curPTR = ifile->p; 1982 free ( ifile);1990 free ((Address)ifile); 1983 1991 return (CONTINUE); 1984 1992 } … … 1996 2004 */ 1997 2005 static int 1998 ParseReadc( void)2006 ParseReadc() 1999 2007 { 2000 2008 if (curFILE) … … 2019 2027 */ 2020 2028 static void 2021 ParseUnreadc(int c) 2029 ParseUnreadc(c) 2030 int c; 2022 2031 { 2023 2032 if (curFILE) { … … 2033 2042 2034 2043 /* ParseSkipLine(): 2035 * Grab the next line unless it begins with a dot (`.') and we're told to 2036 * ignore such lines. 2044 * Grab the next line 2037 2045 */ 2038 2046 static char * 2039 ParseSkipLine(int skip) 2047 ParseSkipLine(skip) 2048 int skip; /* Skip lines that don't start with . */ 2040 2049 { 2041 2050 char *line; … … 2055 2064 lineno++; 2056 2065 2057 while ((c = ParseReadc()) == ' ' || c == '\t') 2058 continue; 2066 while ((c = ParseReadc()) == ' ' || c == '\t'); 2059 2067 2060 2068 if (c == EOF) … … 2100 2108 */ 2101 2109 static char * 2102 ParseReadLine ( void)2110 ParseReadLine () 2103 2111 { 2104 2112 Buffer buf; /* Buffer for current line */ 2105 intc; /* the current character */2106 intlastc; /* The most-recent character */2113 register int c; /* the current character */ 2114 register int lastc; /* The most-recent character */ 2107 2115 Boolean semiNL; /* treat semi-colons as newlines */ 2108 2116 Boolean ignDepOp; /* TRUE if should ignore dependency operators … … 2221 2229 case '#': 2222 2230 if (!ignComment) { 2223 if (lastc != '\\') { 2231 if ( 2232 #if 0 2233 compatMake && 2234 #endif 2235 (lastc != '\\')) { 2224 2236 /* 2225 2237 * If the character is a hash mark and it isn't escaped … … 2252 2264 } 2253 2265 break; 2254 default:2255 break;2256 2266 } 2257 2267 /* … … 2274 2284 /* 2275 2285 * Strip trailing blanks and tabs from the line. 2276 * Do not strip a blank or tab that is prece ded by2286 * Do not strip a blank or tab that is preceeded by 2277 2287 * a '\' 2278 2288 */ … … 2305 2315 /*FALLTHRU*/ 2306 2316 case COND_PARSE: 2307 free ( line);2317 free ((Address) line); 2308 2318 line = ParseReadLine(); 2309 2319 break; … … 2331 2341 } 2332 2342 break; 2333 default:2334 break;2335 2343 } 2336 2344 } … … 2359 2367 */ 2360 2368 static void 2361 ParseFinishLine( void)2369 ParseFinishLine() 2362 2370 { 2363 2371 if (inLine) { 2364 Lst_ForEach(targets, Suff_EndTransform, ( void *)NULL);2372 Lst_ForEach(targets, Suff_EndTransform, (ClientData)NULL); 2365 2373 Lst_Destroy (targets, ParseHasCommands); 2366 2374 targets = NULL; … … 2386 2394 */ 2387 2395 void 2388 Parse_File(char *name, FILE *stream) 2389 { 2390 char *cp, /* pointer into the line */ 2396 Parse_File(name, stream) 2397 char *name; /* the name of the file being read */ 2398 FILE * stream; /* Stream open to makefile to parse */ 2399 { 2400 register char *cp, /* pointer into the line */ 2391 2401 *line; /* the line we're working on */ 2392 2402 … … 2404 2414 * include or undef directives. 2405 2415 */ 2406 for (cp = line + 1; isspace ( (unsigned char)*cp); cp++) {2416 for (cp = line + 1; isspace (*cp); cp++) { 2407 2417 continue; 2408 2418 } … … 2443 2453 shellCommand: 2444 2454 #endif 2445 for (cp = line + 1; isspace ( (unsigned char)*cp); cp++) {2455 for (cp = line + 1; isspace (*cp); cp++) { 2446 2456 continue; 2447 2457 } … … 2454 2464 */ 2455 2465 Lst_ForEach (targets, ParseAddCmd, cp); 2456 Lst_AtEnd(targCmds, ( void *) line);2466 Lst_AtEnd(targCmds, (ClientData) line); 2457 2467 continue; 2458 2468 } else { … … 2569 2579 */ 2570 2580 void 2571 Parse_Init ( void)2572 { 2573 mainNode = N ULL;2581 Parse_Init () 2582 { 2583 mainNode = NILGNODE; 2574 2584 parseIncPath = Lst_Init (FALSE); 2575 2585 sysIncPath = Lst_Init (FALSE); … … 2579 2589 2580 2590 void 2581 Parse_End (void)2582 { 2583 Lst_Destroy(targCmds, (void (*) (void *)) free);2591 Parse_End() 2592 { 2593 Lst_Destroy(targCmds, (void (*) __P((ClientData))) free); 2584 2594 if (targets) 2585 2595 Lst_Destroy(targets, NOFREE); … … 2605 2615 */ 2606 2616 Lst 2607 Parse_MainName( void)2617 Parse_MainName() 2608 2618 { 2609 2619 Lst listmain; /* result list */ … … 2611 2621 listmain = Lst_Init (FALSE); 2612 2622 2613 if (mainNode == N ULL) {2623 if (mainNode == NILGNODE) { 2614 2624 Punt ("no target to make."); 2615 2625 /*NOTREACHED*/ 2616 2626 } else if (mainNode->type & OP_DOUBLEDEP) { 2617 (void) Lst_AtEnd (listmain, ( void *)mainNode);2627 (void) Lst_AtEnd (listmain, (ClientData)mainNode); 2618 2628 Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW); 2619 2629 } 2620 2630 else 2621 (void) Lst_AtEnd (listmain, ( void *)mainNode);2631 (void) Lst_AtEnd (listmain, (ClientData)mainNode); 2622 2632 return (listmain); 2623 2633 }
Note:
See TracChangeset
for help on using the changeset viewer.