Changeset 24 in kBuild
- Timestamp:
- Nov 26, 2002 9:24:54 PM (22 years ago)
- Location:
- branches/FREEBSD/src/kmk
- Files:
-
- 59 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/Makefile
r10 r24 1 1 # @(#)Makefile 5.2 (Berkeley) 12/28/90 2 # $Id$ 3 # $FreeBSD: src/usr.bin/make/Makefile,v 1.29 2002/10/10 19:27:48 jmallett Exp $ 2 # $FreeBSD: src/usr.bin/make/Makefile,v 1.13.2.1 2001/05/25 08:33:40 sobomax Exp $ 4 3 5 4 PROG= make 6 CFLAGS+= -I${.CURDIR}5 CFLAGS+= -I${.CURDIR} 7 6 SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \ 8 make.c parse.c str.c suff.c targ.c util.c var.c7 make.c parse.c str.c suff.c targ.c var.c util.c 9 8 SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \ 10 9 lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \ … … 16 15 NOSHARED?= YES 17 16 18 CFLAGS+=-DMAKE_VERSION=\"5200209170\"19 .if defined(_UPGRADING)20 CFLAGS+=-D__FBSDID=__RCSID21 .endif22 23 # XXX: kernel currently broken24 # CFLAGS+=-DUSE_KQUEUE25 26 main.o: ${MAKEFILE}27 28 # Set the shell which make(1) uses. Bourne is the default, but a decent29 # Korn shell works fine, and much faster. Using the C shell for this30 # will almost certainly break everything, but it's Unix tradition to31 # allow you to shoot yourself in the foot if you want to :-)32 33 MAKE_SHELL?= sh34 .if ${MAKE_SHELL} == "csh"35 CFLAGS+= -DDEFSHELL=036 .elif ${MAKE_SHELL} == "sh"37 CFLAGS+= -DDEFSHELL=138 .elif ${MAKE_SHELL} == "ksh"39 CFLAGS+= -DDEFSHELL=240 .else41 .error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"."42 .endif43 44 17 .include <bsd.prog.mk> -
branches/FREEBSD/src/kmk/Makefile.dist
r10 r24 1 # $FreeBSD: src/usr.bin/make/Makefile.dist,v 1.2 2001/03/01 06:26:32 imp Exp $2 1 # a very simple makefile... 3 2 pmake: 4 3 @echo 'make started.' 5 cc - DDEFSHELL=1 -I. -c *.c4 cc -I. -c *.c 6 5 cd lst.lib; cc -I.. -c *.c 7 6 cc *.o lst.lib/*.o -o pmake -
branches/FREEBSD/src/kmk/PSD.doc/stubs
r9 r24 1 .\" $FreeBSD: src/usr.bin/make/PSD.doc/stubs,v 1.1 2000/11/24 10:05:30ru Exp $1 .\" $FreeBSD: src/usr.bin/make/PSD.doc/stubs,v 1.1.2.1 2000/11/24 10:08:45 ru Exp $ 2 2 .\" 3 3 .de Ix -
branches/FREEBSD/src/kmk/PSD.doc/tutorial.ms
r9 r24 36 36 .\" 37 37 .\" @(#)tutorial.ms 8.1 (Berkeley) 8/18/93 38 .\" $FreeBSD: src/usr.bin/make/PSD.doc/tutorial.ms,v 1. 12 2002/05/16 02:19:09 trhodesExp $38 .\" $FreeBSD: src/usr.bin/make/PSD.doc/tutorial.ms,v 1.8.2.2 2000/11/24 10:08:45 ru Exp $ 39 39 .\" 40 40 .so stubs … … 603 603 .LP 604 604 The value of a variable may be retrieved by enclosing the variable 605 name in parentheses or curly braces and prece ding the whole thing605 name in parentheses or curly braces and preceeding the whole thing 606 606 with a dollar sign. 607 607 .LP … … 1244 1244 and various other information on how PMake was configured. 1245 1245 .Ix 0 ref configuration 1246 .Ix 0 ref makefile system1246 .Ix 0 ref makefile system 1247 1247 .IP \fB\-i\fP 1248 1248 .Ix 0 def flags -i … … 2401 2401 .CW .h 2402 2402 suffix is already marked in this way in the system makefile. 2403 .Ix 0 ref makefile system2403 .Ix 0 ref makefile system 2404 2404 E.g. if you have 2405 2405 .DS … … 2641 2641 You are allowed to use any character except 2642 2642 colon or exclamation point to separate the two strings. This so-called 2643 delimiter character may be placed in either string by prece ding it2643 delimiter character may be placed in either string by preceeding it 2644 2644 with a backslash. 2645 2645 .IP T -
branches/FREEBSD/src/kmk/arch.c
r8 r24 35 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 36 * SUCH DAMAGE. 37 * 38 * @(#)arch.c 8.2 (Berkeley) 1/2/94 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/arch.c,v 1.32 2002/10/09 03:42:09 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/arch.c,v 1.15.2.1 2001/02/13 03:13:57 will Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 /*- … … 114 118 } Arch; 115 119 116 static int ArchFindArchive (void *, void *);117 static void ArchFree (void *);118 static struct ar_hdr *ArchStatMember (char *, char *, Boolean);119 static FILE *ArchFindMember (char *, char *, struct ar_hdr *, char *);120 static int ArchFindArchive __P((ClientData, ClientData)); 121 static void ArchFree __P((ClientData)); 122 static struct ar_hdr *ArchStatMember __P((char *, char *, Boolean)); 123 static FILE *ArchFindMember __P((char *, char *, struct ar_hdr *, char *)); 120 124 #if defined(__svr4__) || defined(__SVR4) || defined(__ELF__) 121 #define 122 static int ArchSVR4Entry (Arch *, char *, size_t, FILE *);125 #define SVR4ARCHIVES 126 static int ArchSVR4Entry __P((Arch *, char *, size_t, FILE *)); 123 127 #endif 124 128 … … 137 141 */ 138 142 static void 139 ArchFree(void *ap) 143 ArchFree(ap) 144 ClientData ap; 140 145 { 141 146 Arch *a = (Arch *) ap; … … 147 152 entry != NULL; 148 153 entry = Hash_EnumNext(&search)) 149 free( Hash_GetValue(entry));154 free((Address) Hash_GetValue (entry)); 150 155 151 156 free(a->name); 152 157 efree(a->fnametab); 153 158 Hash_DeleteTable(&a->members); 154 free( a);159 free((Address) a); 155 160 } 156 161 … … 162 167 * Parse the archive specification in the given line and find/create 163 168 * the nodes for the specified archive members, placing their nodes 164 * on the given list, given the pointer to the start of the 165 * specification, a Lst on which to place the nodes, and a context 166 * in which to expand variables. 169 * on the given list. 167 170 * 168 171 * Results: … … 177 180 */ 178 181 ReturnStatus 179 Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt) 180 { 181 char *cp; /* Pointer into line */ 182 Arch_ParseArchive (linePtr, nodeLst, ctxt) 183 char **linePtr; /* Pointer to start of specification */ 184 Lst nodeLst; /* Lst on which to place the nodes */ 185 GNode *ctxt; /* Context in which to expand variables */ 186 { 187 register char *cp; /* Pointer into line */ 182 188 GNode *gn; /* New node */ 183 189 char *libName; /* Library-part of specification */ … … 230 236 Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */ 231 237 232 while (*cp != '\0' && *cp != ')' && isspace ( (unsigned char)*cp)) {238 while (*cp != '\0' && *cp != ')' && isspace (*cp)) { 233 239 cp++; 234 240 } 235 241 memName = cp; 236 while (*cp != '\0' && *cp != ')' && !isspace ( (unsigned char)*cp)) {242 while (*cp != '\0' && *cp != ')' && !isspace (*cp)) { 237 243 if (*cp == '$') { 238 244 /* … … 305 311 * are just placed at the end of the nodeLst we're returning. 306 312 */ 307 308 313 sz = strlen(memName) + strlen(libName) + 3; 309 314 buf = sacrifice = emalloc(sz); 310 311 315 snprintf(buf, sz, "%s(%s)", libName, memName); 312 316 … … 319 323 gn = Targ_FindNode(buf, TARG_CREATE); 320 324 321 if (gn == N ULL) {325 if (gn == NILGNODE) { 322 326 free(buf); 323 327 return(FAILURE); 324 328 } else { 325 329 gn->type |= OP_ARCHV; 326 (void)Lst_AtEnd(nodeLst, ( void *)gn);330 (void)Lst_AtEnd(nodeLst, (ClientData)gn); 327 331 } 328 332 } else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) { … … 355 359 free(member); 356 360 gn = Targ_FindNode (nameBuf, TARG_CREATE); 357 if (gn == N ULL) {361 if (gn == NILGNODE) { 358 362 free(nameBuf); 359 363 return (FAILURE); … … 367 371 */ 368 372 gn->type |= OP_ARCHV; 369 (void) Lst_AtEnd (nodeLst, ( void *)gn);373 (void) Lst_AtEnd (nodeLst, (ClientData)gn); 370 374 } 371 375 } … … 378 382 gn = Targ_FindNode (nameBuf, TARG_CREATE); 379 383 free(nameBuf); 380 if (gn == N ULL) {384 if (gn == NILGNODE) { 381 385 return (FAILURE); 382 386 } else { … … 389 393 */ 390 394 gn->type |= OP_ARCHV; 391 (void) Lst_AtEnd (nodeLst, ( void *)gn);395 (void) Lst_AtEnd (nodeLst, (ClientData)gn); 392 396 } 393 397 } … … 413 417 do { 414 418 cp++; 415 } while (*cp != '\0' && isspace ( (unsigned char)*cp));419 } while (*cp != '\0' && isspace (*cp)); 416 420 417 421 *linePtr = cp; … … 423 427 * ArchFindArchive -- 424 428 * See if the given archive is the one we are looking for. Called 425 * From ArchStatMember and ArchFindMember via Lst_Find with the 426 * current list element and the name we want. 429 * From ArchStatMember and ArchFindMember via Lst_Find. 427 430 * 428 431 * Results: … … 435 438 */ 436 439 static int 437 ArchFindArchive (void *ar, void *archName) 440 ArchFindArchive (ar, archName) 441 ClientData ar; /* Current list element */ 442 ClientData archName; /* Name we want */ 438 443 { 439 444 return (strcmp ((char *) archName, ((Arch *) ar)->name)); … … 444 449 * ArchStatMember -- 445 450 * Locate a member of an archive, given the path of the archive and 446 * the path of the desired member, and a boolean representing whether 447 * or not the archive should be hashed (if not already hashed). 451 * the path of the desired member. 448 452 * 449 453 * Results: … … 459 463 */ 460 464 static struct ar_hdr * 461 ArchStatMember (char *archive, char *member, Boolean hash) 462 { 463 #define AR_MAX_NAME_LEN (sizeof(arh.ar_name)-1) 465 ArchStatMember (archive, member, hash) 466 char *archive; /* Path to the archive */ 467 char *member; /* Name of member. If it is a path, only the 468 * last component is used. */ 469 Boolean hash; /* TRUE if archive should be hashed if not 470 * already so. */ 471 { 472 #define AR_MAX_NAME_LEN (sizeof(arh.ar_name)-1) 464 473 FILE * arch; /* Stream to archive */ 465 474 int size; /* Size of archive member */ … … 483 492 member = cp + 1; 484 493 485 ln = Lst_Find (archives, ( void *) archive, ArchFindArchive);486 if (ln != N ULL) {494 ln = Lst_Find (archives, (ClientData) archive, ArchFindArchive); 495 if (ln != NILLNODE) { 487 496 ar = (Arch *) Lst_Datum (ln); 488 497 … … 494 503 /* Try truncated name */ 495 504 char copy[AR_MAX_NAME_LEN+1]; 496 size_t len = strlen (member);505 int len = strlen (member); 497 506 498 507 if (len > AR_MAX_NAME_LEN) { … … 615 624 memName[elen] = '\0'; 616 625 fseek (arch, -elen, SEEK_CUR); 617 /* XXX Multiple levels may be asked for, make this conditional618 * on one, and use DEBUGF.619 */620 626 if (DEBUG(ARCH) || DEBUG(MAKE)) { 621 fprintf(stderr,"ArchStat: Extended format entry for %s\n", memName);627 printf("ArchStat: Extended format entry for %s\n", memName); 622 628 } 623 629 } … … 625 631 626 632 he = Hash_CreateEntry (&ar->members, memName, NULL); 627 Hash_SetValue (he, ( void *)emalloc (sizeof (struct ar_hdr)));628 memcpy ( Hash_GetValue (he),&arh,633 Hash_SetValue (he, (ClientData)emalloc (sizeof (struct ar_hdr))); 634 memcpy ((Address)Hash_GetValue (he), (Address)&arh, 629 635 sizeof (struct ar_hdr)); 630 636 } … … 634 640 fclose (arch); 635 641 636 (void) Lst_AtEnd (archives, ( void *) ar);642 (void) Lst_AtEnd (archives, (ClientData) ar); 637 643 638 644 /* … … 652 658 Hash_DeleteTable (&ar->members); 653 659 efree(ar->fnametab); 654 free ( ar);660 free ((Address)ar); 655 661 return (NULL); 656 662 } … … 678 684 */ 679 685 static int 680 ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch) 681 { 682 #define ARLONGNAMES1 "//" 683 #define ARLONGNAMES2 "/ARFILENAMES" 686 ArchSVR4Entry(ar, name, size, arch) 687 Arch *ar; 688 char *name; 689 size_t size; 690 FILE *arch; 691 { 692 #define ARLONGNAMES1 "//" 693 #define ARLONGNAMES2 "/ARFILENAMES" 684 694 size_t entry; 685 695 char *ptr, *eptr; … … 689 699 690 700 if (ar->fnametab != NULL) { 691 DEBUGF(ARCH, ("Attempted to redefine an SVR4 name table\n")); 701 if (DEBUG(ARCH)) { 702 printf("Attempted to redefine an SVR4 name table\n"); 703 } 692 704 return -1; 693 705 } … … 701 713 702 714 if (fread(ar->fnametab, size, 1, arch) != 1) { 703 DEBUGF(ARCH, ("Reading an SVR4 name table failed\n")); 715 if (DEBUG(ARCH)) { 716 printf("Reading an SVR4 name table failed\n"); 717 } 704 718 return -1; 705 719 } … … 718 732 break; 719 733 } 720 DEBUGF(ARCH, ("Found svr4 archive name table with %zu entries\n", entry)); 734 if (DEBUG(ARCH)) { 735 printf("Found svr4 archive name table with %d entries\n", entry); 736 } 721 737 return 0; 722 738 } … … 727 743 entry = (size_t) strtol(&name[1], &eptr, 0); 728 744 if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) { 729 DEBUGF(ARCH, ("Could not parse SVR4 name %s\n", name)); 745 if (DEBUG(ARCH)) { 746 printf("Could not parse SVR4 name %s\n", name); 747 } 730 748 return 2; 731 749 } 732 750 if (entry >= ar->fnamesize) { 733 DEBUGF(ARCH, ("SVR4 entry offset %s is greater than %zu\n", 734 name, ar->fnamesize)); 751 if (DEBUG(ARCH)) { 752 printf("SVR4 entry offset %s is greater than %d\n", 753 name, ar->fnamesize); 754 } 735 755 return 2; 736 756 } 737 757 738 DEBUGF(ARCH, ("Replaced %s with %s\n", name, &ar->fnametab[entry])); 758 if (DEBUG(ARCH)) { 759 printf("Replaced %s with %s\n", name, &ar->fnametab[entry]); 760 } 739 761 740 762 (void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN); … … 750 772 * Locate a member of an archive, given the path of the archive and 751 773 * the path of the desired member. If the archive is to be modified, 752 * the mode should be "r+", if not, it should be "r". arhPtr is a 753 * poitner to the header structure to fill in. 774 * the mode should be "r+", if not, it should be "r". 754 775 * 755 776 * Results: … … 764 785 */ 765 786 static FILE * 766 ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode) 787 ArchFindMember (archive, member, arhPtr, mode) 788 char *archive; /* Path to the archive */ 789 char *member; /* Name of member. If it is a path, only the 790 * last component is used. */ 791 struct ar_hdr *arhPtr; /* Pointer to header structure to be filled in */ 792 char *mode; /* The mode for opening the stream */ 767 793 { 768 794 FILE * arch; /* Stream to archive */ … … 770 796 char *cp; /* Useful character pointer */ 771 797 char magic[SARMAG]; 772 size_tlen, tlen;798 int len, tlen; 773 799 774 800 arch = fopen (archive, mode); … … 853 879 } 854 880 ename[elen] = '\0'; 855 /*856 * XXX choose one.857 */858 881 if (DEBUG(ARCH) || DEBUG(MAKE)) { 859 882 printf("ArchFind: Extended format entry for %s\n", ename); … … 907 930 */ 908 931 void 909 Arch_Touch (GNode *gn) 932 Arch_Touch (gn) 933 GNode *gn; /* Node of member to touch */ 910 934 { 911 935 FILE * arch; /* Stream open to archive, positioned properly */ … … 942 966 */ 943 967 void 944 Arch_TouchLib (GNode *gn) 968 Arch_TouchLib (gn) 969 GNode *gn; /* The node of the library to touch */ 945 970 { 946 971 #ifdef RANLIBMAG … … 965 990 *----------------------------------------------------------------------- 966 991 * Arch_MTime -- 967 * Return the modification time of a member of an archive, given its 968 * name. 992 * Return the modification time of a member of an archive. 969 993 * 970 994 * Results: … … 978 1002 */ 979 1003 int 980 Arch_MTime(GNode *gn) 1004 Arch_MTime (gn) 1005 GNode *gn; /* Node describing archive member */ 981 1006 { 982 1007 struct ar_hdr *arhPtr; /* Header of desired member */ … … 1015 1040 */ 1016 1041 int 1017 Arch_MemMTime (GNode *gn) 1042 Arch_MemMTime (gn) 1043 GNode *gn; 1018 1044 { 1019 1045 LstNode ln; … … 1026 1052 return (0); 1027 1053 } 1028 while ((ln = Lst_Next (gn->parents)) != N ULL) {1054 while ((ln = Lst_Next (gn->parents)) != NILLNODE) { 1029 1055 pgn = (GNode *) Lst_Datum (ln); 1030 1056 … … 1062 1088 *----------------------------------------------------------------------- 1063 1089 * Arch_FindLib -- 1064 * Search for a namedlibrary along the given search path.1090 * Search for a library along the given search path. 1065 1091 * 1066 1092 * Results: … … 1080 1106 */ 1081 1107 void 1082 Arch_FindLib (GNode *gn, Lst path) 1108 Arch_FindLib (gn, path) 1109 GNode *gn; /* Node of library to find */ 1110 Lst path; /* Search path */ 1083 1111 { 1084 1112 char *libName; /* file name for archive */ … … 1104 1132 * Arch_LibOODate -- 1105 1133 * Decide if a node with the OP_LIB attribute is out-of-date. Called 1106 * from Make_OODate to make its life easier, with the library's 1107 * graph node. 1134 * from Make_OODate to make its life easier. 1108 1135 * 1109 1136 * There are several ways for a library to be out-of-date that are … … 1138 1165 */ 1139 1166 Boolean 1140 Arch_LibOODate (GNode *gn) 1167 Arch_LibOODate (gn) 1168 GNode *gn; /* The library's graph node */ 1141 1169 { 1142 1170 Boolean oodate; … … 1156 1184 modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10); 1157 1185 1158 /* XXX choose one. */1159 1186 if (DEBUG(ARCH) || DEBUG(MAKE)) { 1160 1187 printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC)); … … 1191 1218 */ 1192 1219 void 1193 Arch_Init ( void)1220 Arch_Init () 1194 1221 { 1195 1222 archives = Lst_Init (FALSE); … … 1212 1239 */ 1213 1240 void 1214 Arch_End ( void)1241 Arch_End () 1215 1242 { 1216 1243 Lst_Destroy(archives, ArchFree); -
branches/FREEBSD/src/kmk/buf.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 * @(#)buf.c 8.1 (Berkeley) 6/6/93 40 */ 41 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/buf.c,v 1.18 2002/10/09 03:42:09 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/buf.c,v 1.11 1999/09/11 13:08:01 hoek Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 /*- … … 53 56 54 57 #ifndef max 55 #define 58 #define max(a,b) ((a) > (b) ? (a) : (b)) 56 59 #endif 57 60 … … 63 66 * buffer in case it holds a string. 64 67 */ 65 #define 68 #define BufExpand(bp,nb) \ 66 69 if (bp->left < (nb)+1) {\ 67 70 int newSize = (bp)->size + max((nb)+1,BUF_ADD_INC); \ … … 75 78 } 76 79 77 #define 78 #define 79 #define 80 #define BUF_DEF_SIZE 256 /* Default buffer size */ 81 #define BUF_ADD_INC 256 /* Expansion increment when Adding */ 82 #define BUF_UNGET_INC 16 /* Expansion increment when Ungetting */ 80 83 81 84 /*- … … 93 96 */ 94 97 void 95 Buf_OvAddByte (Buffer bp, int byte) 96 { 98 Buf_OvAddByte (bp, byte) 99 register Buffer bp; 100 int byte; 101 { 102 int nbytes = 1; 97 103 bp->left = 0; 98 BufExpand (bp, 1);104 BufExpand (bp, nbytes); 99 105 100 106 *bp->inPtr++ = byte; … … 122 128 */ 123 129 void 124 Buf_AddBytes (Buffer bp, int numBytes, const Byte *bytesPtr) 130 Buf_AddBytes (bp, numBytes, bytesPtr) 131 register Buffer bp; 132 int numBytes; 133 const Byte *bytesPtr; 125 134 { 126 135 … … 152 161 */ 153 162 void 154 Buf_UngetByte (Buffer bp, int byte) 163 Buf_UngetByte (bp, byte) 164 register Buffer bp; 165 int byte; 155 166 { 156 167 … … 201 212 */ 202 213 void 203 Buf_UngetBytes (Buffer bp, int numBytes, Byte *bytesPtr) 214 Buf_UngetBytes (bp, numBytes, bytesPtr) 215 register Buffer bp; 216 int numBytes; 217 Byte *bytesPtr; 204 218 { 205 219 … … 244 258 */ 245 259 int 246 Buf_GetByte (Buffer bp) 260 Buf_GetByte (bp) 261 register Buffer bp; 247 262 { 248 263 int res; … … 277 292 */ 278 293 int 279 Buf_GetBytes (Buffer bp, int numBytes, Byte *bytesPtr) 294 Buf_GetBytes (bp, numBytes, bytesPtr) 295 register Buffer bp; 296 int numBytes; 297 Byte *bytesPtr; 280 298 { 281 299 … … 309 327 */ 310 328 Byte * 311 Buf_GetAll (Buffer bp, int *numBytesPtr) 329 Buf_GetAll (bp, numBytesPtr) 330 register Buffer bp; 331 int *numBytesPtr; 312 332 { 313 333 … … 334 354 */ 335 355 void 336 Buf_Discard (Buffer bp, int numBytes) 356 Buf_Discard (bp, numBytes) 357 register Buffer bp; 358 int numBytes; 337 359 { 338 360 … … 362 384 */ 363 385 int 364 Buf_Size (Buffer buf) 386 Buf_Size (buf) 387 Buffer buf; 365 388 { 366 389 return (buf->inPtr - buf->outPtr); … … 384 407 */ 385 408 Buffer 386 Buf_Init (int size) 409 Buf_Init (size) 410 int size; /* Initial size for the buffer */ 387 411 { 388 412 Buffer bp; /* New Buffer */ … … 405 429 *----------------------------------------------------------------------- 406 430 * Buf_Destroy -- 407 * Destroy a buffer, and optionally free its data, too.431 * Nuke a buffer and all its resources. 408 432 * 409 433 * Results: … … 416 440 */ 417 441 void 418 Buf_Destroy (Buffer buf, Boolean freeData) 442 Buf_Destroy (buf, freeData) 443 Buffer buf; /* Buffer to destroy */ 444 Boolean freeData; /* TRUE if the data should be destroyed as well */ 419 445 { 420 446 … … 441 467 */ 442 468 void 443 Buf_ReplaceLastByte (Buffer buf, int byte) 469 Buf_ReplaceLastByte (buf, byte) 470 Buffer buf; /* buffer to augment */ 471 int byte; /* byte to be written */ 444 472 { 445 473 if (buf->inPtr == buf->outPtr) -
branches/FREEBSD/src/kmk/buf.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)buf.h 8.2 (Berkeley) 4/28/9540 * $FreeBSD: src/usr.bin/make/buf.h,v 1. 12 2002/09/17 21:29:06 jmallettExp $38 * from: @(#)buf.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/buf.h,v 1.9 1999/08/28 01:03:26 peter Exp $ 41 40 */ 42 41 … … 47 46 48 47 #ifndef _BUF_H 49 #define 48 #define _BUF_H 50 49 51 50 #include "sprite.h" … … 66 65 (*(bp)->inPtr++ = (byte), *(bp)->inPtr = 0), 1) 67 66 68 #define 67 #define BUF_ERROR 256 69 68 70 void Buf_OvAddByte (Buffer, int);71 void Buf_AddBytes (Buffer, int, const Byte *);72 void Buf_UngetByte (Buffer, int);73 void Buf_UngetBytes (Buffer, int, Byte *);74 int Buf_GetByte (Buffer);75 int Buf_GetBytes (Buffer, int, Byte *);76 Byte *Buf_GetAll (Buffer, int *);77 void Buf_Discard (Buffer, int);78 int Buf_Size (Buffer);79 Buffer Buf_Init (int);80 void Buf_Destroy (Buffer, Boolean);81 void Buf_ReplaceLastByte (Buffer, int);69 void Buf_OvAddByte __P((Buffer, int)); 70 void Buf_AddBytes __P((Buffer, int, const Byte *)); 71 void Buf_UngetByte __P((Buffer, int)); 72 void Buf_UngetBytes __P((Buffer, int, Byte *)); 73 int Buf_GetByte __P((Buffer)); 74 int Buf_GetBytes __P((Buffer, int, Byte *)); 75 Byte *Buf_GetAll __P((Buffer, int *)); 76 void Buf_Discard __P((Buffer, int)); 77 int Buf_Size __P((Buffer)); 78 Buffer Buf_Init __P((int)); 79 void Buf_Destroy __P((Buffer, Boolean)); 80 void Buf_ReplaceLastByte __P((Buffer, int)); 82 81 83 82 #endif /* _BUF_H */ -
branches/FREEBSD/src/kmk/compat.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 * @(#)compat.c 8.2 (Berkeley) 3/19/9440 37 */ 41 38 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/compat.c,v 1.34 2002/10/09 03:42:09 jmallett Exp $"); 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/compat.c,v 1.16.2.2 2000/07/01 12:24:21 ps Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 /*- … … 63 66 #include <errno.h> 64 67 #include <signal.h> 65 #include <unistd.h>66 68 #include "make.h" 67 69 #include "hash.h" … … 78 80 static char meta[256]; 79 81 80 static GNode *curTarg = N ULL;82 static GNode *curTarg = NILGNODE; 81 83 static GNode *ENDNode; 82 static void CompatInterrupt(int); 83 static int CompatRunCommand(void *, void *); 84 static int CompatMake(void *, void *); 85 static int shellneed(char *); 84 static void CompatInterrupt __P((int)); 85 static int CompatRunCommand __P((ClientData, ClientData)); 86 static int CompatMake __P((ClientData, ClientData)); 86 87 87 88 static char *sh_builtin[] = { … … 105 106 */ 106 107 static void 107 CompatInterrupt (int signo) 108 CompatInterrupt (signo) 109 int signo; 108 110 { 109 111 GNode *gn; 110 112 111 if ((curTarg != N ULL) && !Targ_Precious (curTarg)) {113 if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) { 112 114 char *p1; 113 115 char *file = Var_Value (TARGET, curTarg, &p1); … … 123 125 if (signo == SIGINT) { 124 126 gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); 125 if (gn != N ULL) {126 Lst_ForEach(gn->commands, CompatRunCommand, ( void *)gn);127 if (gn != NILGNODE) { 128 Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); 127 129 } 128 130 } … … 150 152 */ 151 153 static int 152 shellneed (char *cmd) 154 shellneed (cmd) 155 char *cmd; 153 156 { 154 157 char **av, **p; … … 168 171 * Execute the next command for a target. If the command returns an 169 172 * error, the node's made field is set to ERROR and creation stops. 170 * The node from which the command came is also given.171 173 * 172 174 * Results: … … 179 181 */ 180 182 static int 181 CompatRunCommand (void *cmdp, void *gnp) 183 CompatRunCommand (cmdp, gnp) 184 ClientData cmdp; /* Command to execute */ 185 ClientData gnp; /* Node from which the command came */ 182 186 { 183 187 char *cmdStart; /* Start of expanded command */ 184 char*cp;188 register char *cp; 185 189 Boolean silent, /* Don't print command */ 186 190 errCheck; /* Check errors */ … … 188 192 int status; /* Description of child's death */ 189 193 int cpid; /* Child actually found */ 190 ReturnStatus rstat;/* Status of fork */194 ReturnStatus stat; /* Status of fork */ 191 195 LstNode cmdNode; /* Node where current command is located */ 192 196 char **av; /* Argument vector for thing to exec */ 193 197 int argc; /* Number of arguments in av or 0 if not 194 198 * dynamically allocated */ 199 Boolean local; /* TRUE if command should be executed 200 * locally */ 195 201 int internal; /* Various values.. */ 196 202 char *cmd = (char *) cmdp; … … 208 214 errCheck = !(gn->type & OP_IGNORE); 209 215 210 cmdNode = Lst_Member (gn->commands, ( void *)cmd);216 cmdNode = Lst_Member (gn->commands, (ClientData)cmd); 211 217 cmdStart = Var_Subst (NULL, cmd, gn, FALSE); 212 218 … … 225 231 cmd = cmdStart; 226 232 } 227 Lst_Replace (cmdNode, ( void *)cmdStart);233 Lst_Replace (cmdNode, (ClientData)cmdStart); 228 234 229 235 if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { 230 (void)Lst_AtEnd(ENDNode->commands, ( void *)cmdStart);236 (void)Lst_AtEnd(ENDNode->commands, (ClientData)cmdStart); 231 237 return(0); 232 238 } else if (strcmp(cmdStart, "...") == 0) { … … 315 321 } 316 322 323 local = TRUE; 324 317 325 /* 318 326 * Fork and execute the single command. If the fork fails, we abort. … … 323 331 } 324 332 if (cpid == 0) { 325 execvp(av[0], av); 326 (void) write (STDERR_FILENO, av[0], strlen (av[0])); 327 (void) write (STDERR_FILENO, ":", 1); 328 (void) write (STDERR_FILENO, strerror(errno), strlen(strerror(errno))); 329 (void) write (STDERR_FILENO, "\n", 1); 333 if (local) { 334 execvp(av[0], av); 335 (void) write (2, av[0], strlen (av[0])); 336 (void) write (2, ":", 1); 337 (void) write (2, strerror(errno), strlen(strerror(errno))); 338 (void) write (2, "\n", 1); 339 } else { 340 (void)execv(av[0], av); 341 } 330 342 exit(1); 331 343 } … … 347 359 while (1) { 348 360 349 while (( rstat = wait(&reason)) != cpid) {350 if ( rstat == -1 && errno != EINTR) {361 while ((stat = wait(&reason)) != cpid) { 362 if (stat == -1 && errno != EINTR) { 351 363 break; 352 364 } 353 365 } 354 366 355 if ( rstat > -1) {367 if (stat > -1) { 356 368 if (WIFSTOPPED(reason)) { 357 369 status = WSTOPSIG(reason); /* stopped */ … … 388 400 break; 389 401 } else { 390 Fatal ("error in wait: %d", rstat);402 Fatal ("error in wait: %d", stat); 391 403 /*NOTREACHED*/ 392 404 } … … 400 412 *----------------------------------------------------------------------- 401 413 * CompatMake -- 402 * Make a target , given the parent, to abort if necessary.414 * Make a target. 403 415 * 404 416 * Results: … … 411 423 */ 412 424 static int 413 CompatMake (void *gnp, void *pgnp) 425 CompatMake (gnp, pgnp) 426 ClientData gnp; /* The node to make */ 427 ClientData pgnp; /* Parent to abort if necessary */ 414 428 { 415 429 GNode *gn = (GNode *) gnp; … … 429 443 gn->made = BEINGMADE; 430 444 Suff_FindDeps (gn); 431 Lst_ForEach (gn->children, CompatMake, ( void *)gn);445 Lst_ForEach (gn->children, CompatMake, (ClientData)gn); 432 446 if (!gn->make) { 433 447 gn->made = ABORTED; … … 436 450 } 437 451 438 if (Lst_Member (gn->iParents, pgn) != N ULL) {452 if (Lst_Member (gn->iParents, pgn) != NILLNODE) { 439 453 char *p1; 440 454 Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn); … … 448 462 * Make_OODate function. 449 463 */ 450 DEBUGF(MAKE, ("Examining %s...", gn->name)); 464 if (DEBUG(MAKE)) { 465 printf("Examining %s...", gn->name); 466 } 451 467 if (! Make_OODate(gn)) { 452 468 gn->made = UPTODATE; 453 DEBUGF(MAKE, ("up-to-date.\n")); 469 if (DEBUG(MAKE)) { 470 printf("up-to-date.\n"); 471 } 454 472 return (0); 455 } else {456 DEBUGF(MAKE, ("out-of-date.\n"));473 } else if (DEBUG(MAKE)) { 474 printf("out-of-date.\n"); 457 475 } 458 476 … … 490 508 if (!touchFlag) { 491 509 curTarg = gn; 492 Lst_ForEach (gn->commands, CompatRunCommand, ( void *)gn);493 curTarg = N ULL;510 Lst_ForEach (gn->commands, CompatRunCommand, (ClientData)gn); 511 curTarg = NILGNODE; 494 512 } else { 495 513 Job_Touch (gn, gn->type & OP_SILENT); … … 561 579 if (gn->cmtime > gn->mtime) 562 580 gn->mtime = gn->cmtime; 563 DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(gn->mtime))); 581 if (DEBUG(MAKE)) { 582 printf("update time: %s\n", Targ_FmtTime(gn->mtime)); 583 } 564 584 #endif 565 585 if (!(gn->type & OP_EXEC)) { … … 583 603 pgn->make = FALSE; 584 604 } else { 585 if (Lst_Member (gn->iParents, pgn) != N ULL) {605 if (Lst_Member (gn->iParents, pgn) != NILLNODE) { 586 606 char *p1; 587 607 Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn); … … 617 637 *----------------------------------------------------------------------- 618 638 * Compat_Run -- 619 * Start making again, given a list of target nodes.639 * Initialize this mode and start making. 620 640 * 621 641 * Results: … … 628 648 */ 629 649 void 630 Compat_Run(Lst targs) 650 Compat_Run(targs) 651 Lst targs; /* List of target nodes to re-create */ 631 652 { 632 653 char *cp; /* Pointer to string of shell meta-characters */ … … 662 683 if (!queryFlag) { 663 684 gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); 664 if (gn != N ULL) {665 Lst_ForEach(gn->commands, CompatRunCommand, ( void *)gn);685 if (gn != NILGNODE) { 686 Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); 666 687 if (gn->made == ERROR) { 667 688 printf("\n\nStop.\n"); … … 698 719 */ 699 720 if (errors == 0) { 700 Lst_ForEach(ENDNode->commands, CompatRunCommand, ( void *)gn);721 Lst_ForEach(ENDNode->commands, CompatRunCommand, (ClientData)gn); 701 722 } 702 723 } -
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) { -
branches/FREEBSD/src/kmk/config.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)config.h 8.2 (Berkeley) 4/28/9540 * $FreeBSD: src/usr.bin/make/config.h,v 1. 12 2002/09/17 21:29:06 jmallettExp $38 * from: @(#)config.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/config.h,v 1.9 1999/09/10 20:51:59 julian Exp $ 41 40 */ 41 42 #define DEFSHELL 1 /* Bourne shell */ 42 43 43 44 /* … … 50 51 * to 0, nothing will ever happen... 51 52 */ 52 #define 53 #define 53 #define DEFMAXJOBS 4 54 #define DEFMAXLOCAL 1 54 55 55 56 /* … … 62 63 * See suff.c for more details. 63 64 */ 64 #define 65 #define 65 #define INCLUDES 66 #define LIBRARIES 66 67 67 68 /* … … 90 91 * - Allow empty command lines if starting with tab. 91 92 */ 92 #define 93 #define POSIX 93 94 94 95 /* … … 98 99 * Recognize system V like ${VAR:x=y} variable substitutions 99 100 */ 100 #define 101 #define 101 #define SYSVINCLUDE 102 #define SYSVVARSUB 102 103 103 104 /* … … 108 109 * # of ${VAR} 109 110 */ 110 #define 111 #define SUNSHCMD 111 112 112 113 #if !defined(__svr4__) && !defined(__SVR4) && !defined(__ELF__) -
branches/FREEBSD/src/kmk/dir.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 * @(#)dir.c 8.2 (Berkeley) 1/2/94 40 */ 41 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/dir.c,v 1.30 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/dir.c,v 1.10.2.1 2001/02/13 03:13:57 will Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 /*- … … 88 91 #include <stdio.h> 89 92 #include <sys/types.h> 93 #include <dirent.h> 90 94 #include <sys/stat.h> 91 #include <dirent.h>92 #include <err.h>93 95 #include "make.h" 94 96 #include "hash.h" … … 190 192 191 193 192 static int DirFindName (void *, void *);193 static int DirMatchFiles (char *, Path *, Lst);194 static void DirExpandCurly (char *, char *, Lst, Lst);195 static void DirExpandInt (char *, Lst, Lst);196 static int DirPrintWord (void *, void *);197 static int DirPrintDir (void *, void *);194 static int DirFindName __P((ClientData, ClientData)); 195 static int DirMatchFiles __P((char *, Path *, Lst)); 196 static void DirExpandCurly __P((char *, char *, Lst, Lst)); 197 static void DirExpandInt __P((char *, Lst, Lst)); 198 static int DirPrintWord __P((ClientData, ClientData)); 199 static int DirPrintDir __P((ClientData, ClientData)); 198 200 199 201 /*- … … 210 212 */ 211 213 void 212 Dir_Init ( void)214 Dir_Init () 213 215 { 214 216 dirSearchPath = Lst_Init (FALSE); … … 247 249 */ 248 250 void 249 Dir_End( void)251 Dir_End() 250 252 { 251 253 dot->refCount -= 1; 252 Dir_Destroy(( void *) dot);254 Dir_Destroy((ClientData) dot); 253 255 Dir_ClearPath(dirSearchPath); 254 256 Lst_Destroy(dirSearchPath, NOFREE); … … 273 275 */ 274 276 static int 275 DirFindName (void *p, void *dname) 277 DirFindName (p, dname) 278 ClientData p; /* Current name */ 279 ClientData dname; /* Desired name */ 276 280 { 277 281 return (strcmp (((Path *)p)->name, (char *) dname)); … … 281 285 *----------------------------------------------------------------------- 282 286 * Dir_HasWildcards -- 283 * See if the given name has any wildcard characters in it.287 * see if the given name has any wildcard characters in it 284 288 * 285 289 * Results: … … 291 295 */ 292 296 Boolean 293 Dir_HasWildcards ( char *name)294 { 295 char *cp; 296 int wild = 0, brace = 0, bracket = 0;297 Dir_HasWildcards (name) 298 char *name; /* name to check */ 299 { 300 register char *cp; 297 301 298 302 for (cp = name; *cp; cp++) { 299 303 switch(*cp) { 300 304 case '{': 301 brace++;302 wild = 1;303 break;304 case '}':305 brace--;306 break;307 305 case '[': 308 bracket++;309 wild = 1;310 break;311 case ']':312 bracket--;313 break;314 306 case '?': 315 307 case '*': 316 wild = 1; 317 break; 318 default: 319 break; 320 } 321 } 322 return wild && bracket == 0 && brace == 0; 308 return (TRUE); 309 } 310 } 311 return (FALSE); 323 312 } 324 313 … … 341 330 */ 342 331 static int 343 DirMatchFiles (char *pattern, Path *p, Lst expansions) 332 DirMatchFiles (pattern, p, expansions) 333 char *pattern; /* Pattern to look for */ 334 Path *p; /* Directory to search */ 335 Lst expansions; /* Place to store the results */ 344 336 { 345 337 Hash_Search search; /* Index into the directory's table */ … … 378 370 * Note the special case: if after the piece of the curly brace is 379 371 * done there are no wildcard characters in the result, the result is 380 * placed on the list WITHOUT CHECKING FOR ITS EXISTENCE. The 381 * given arguments are the entire word to expand, the first curly 382 * brace in the word, the search path, and the list to store the 383 * expansions in. 372 * placed on the list WITHOUT CHECKING FOR ITS EXISTENCE. 384 373 * 385 374 * Results: … … 392 381 */ 393 382 static void 394 DirExpandCurly(char *word, char *brace, Lst path, Lst expansions) 383 DirExpandCurly(word, brace, path, expansions) 384 char *word; /* Entire word to expand */ 385 char *brace; /* First curly brace in it */ 386 Lst path; /* Search path to use */ 387 Lst expansions; /* Place to store the expansions */ 395 388 { 396 389 char *end; /* Character after the closing brace */ … … 466 459 Dir_Expand(file, path, expansions); 467 460 goto next; 468 default:469 break;470 461 } 471 462 } … … 490 481 * Internal expand routine. Passes through the directories in the 491 482 * path one by one, calling DirMatchFiles for each. NOTE: This still 492 * doesn't handle patterns in directories... Works given a word to 493 * expand, a path to look in, and a list to store expansions in. 483 * doesn't handle patterns in directories... 494 484 * 495 485 * Results: … … 502 492 */ 503 493 static void 504 DirExpandInt(char *word, Lst path, Lst expansions) 494 DirExpandInt(word, path, expansions) 495 char *word; /* Word to expand */ 496 Lst path; /* Path on which to look */ 497 Lst expansions; /* Place to store the result */ 505 498 { 506 499 LstNode ln; /* Current node */ … … 508 501 509 502 if (Lst_Open(path) == SUCCESS) { 510 while ((ln = Lst_Next(path)) != N ULL) {503 while ((ln = Lst_Next(path)) != NILLNODE) { 511 504 p = (Path *)Lst_Datum(ln); 512 505 DirMatchFiles(word, p, expansions); … … 531 524 */ 532 525 static int 533 DirPrintWord(void *word, void *dummy __unused) 534 { 535 DEBUGF(DIR, ("%s ", (char *) word)); 536 537 return (0); 526 DirPrintWord(word, dummy) 527 ClientData word; 528 ClientData dummy; 529 { 530 printf("%s ", (char *) word); 531 532 return(dummy ? 0 : 0); 538 533 } 539 534 … … 546 541 * Results: 547 542 * A list of words consisting of the files which exist along the search 548 * path matching the given pattern is placed in expansions.543 * path matching the given pattern. 549 544 * 550 545 * Side Effects: … … 553 548 */ 554 549 void 555 Dir_Expand (char *word, Lst path, Lst expansions) 550 Dir_Expand (word, path, expansions) 551 char *word; /* the word to expand */ 552 Lst path; /* the list of directories in which to find 553 * the resulting files */ 554 Lst expansions; /* the list on which to place the results */ 556 555 { 557 556 char *cp; 558 557 559 DEBUGF(DIR, ("expanding \"%s\"...", word)); 558 if (DEBUG(DIR)) { 559 printf("expanding \"%s\"...", word); 560 } 560 561 561 562 cp = strchr(word, '{'); … … 640 641 } 641 642 if (DEBUG(DIR)) { 642 Lst_ForEach(expansions, DirPrintWord, ( void *) 0);643 DEBUGF(DIR, ("\n"));643 Lst_ForEach(expansions, DirPrintWord, (ClientData) 0); 644 fputc('\n', stdout); 644 645 } 645 646 } … … 664 665 */ 665 666 char * 666 Dir_FindFile (char *name, Lst path) 667 { 668 char *p1; /* pointer into p->name */ 669 char *p2; /* pointer into name */ 667 Dir_FindFile (name, path) 668 char *name; /* the file to find */ 669 Lst path; /* the Lst of directories to search */ 670 { 671 register char *p1; /* pointer into p->name */ 672 register char *p2; /* pointer into name */ 670 673 LstNode ln; /* a list element */ 671 char*file; /* the current filename to check */672 Path*p; /* current path member */673 char*cp; /* index of first slash, if any */674 register char *file; /* the current filename to check */ 675 register Path *p; /* current path member */ 676 register char *cp; /* index of first slash, if any */ 674 677 Boolean hasSlash; /* true if 'name' contains a / */ 675 678 struct stat stb; /* Buffer for stat, if necessary */ … … 689 692 } 690 693 691 DEBUGF(DIR, ("Searching for %s...", name)); 694 if (DEBUG(DIR)) { 695 printf("Searching for %s...", name); 696 } 692 697 /* 693 698 * No matter what, we always look for the file in the current directory … … 698 703 if ((!hasSlash || (cp - name == 2 && *name == '.')) && 699 704 (Hash_FindEntry (&dot->files, cp) != (Hash_Entry *)NULL)) { 700 DEBUGF(DIR, ("in '.'\n")); 705 if (DEBUG(DIR)) { 706 printf("in '.'\n"); 707 } 701 708 hits += 1; 702 709 dot->hits += 1; … … 705 712 706 713 if (Lst_Open (path) == FAILURE) { 707 DEBUGF(DIR, ("couldn't open path, file not found\n")); 714 if (DEBUG(DIR)) { 715 printf("couldn't open path, file not found\n"); 716 } 708 717 misses += 1; 709 718 return ((char *) NULL); … … 718 727 * we go on to phase two... 719 728 */ 720 while ((ln = Lst_Next (path)) != N ULL) {729 while ((ln = Lst_Next (path)) != NILLNODE) { 721 730 p = (Path *) Lst_Datum (ln); 722 DEBUGF(DIR, ("%s...", p->name)); 731 if (DEBUG(DIR)) { 732 printf("%s...", p->name); 733 } 723 734 if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { 724 DEBUGF(DIR, ("here...")); 735 if (DEBUG(DIR)) { 736 printf("here..."); 737 } 725 738 if (hasSlash) { 726 739 /* … … 738 751 } 739 752 if (p2 >= name || (p1 >= p->name && *p1 != '/')) { 740 DEBUGF(DIR, ("component mismatch -- continuing...")); 753 if (DEBUG(DIR)) { 754 printf("component mismatch -- continuing..."); 755 } 741 756 continue; 742 757 } 743 758 } 744 759 file = str_concat (p->name, cp, STR_ADDSLASH); 745 DEBUGF(DIR, ("returning %s\n", file)); 760 if (DEBUG(DIR)) { 761 printf("returning %s\n", file); 762 } 746 763 Lst_Close (path); 747 764 p->hits += 1; … … 758 775 } 759 776 if (*p1 == '\0' && p2 == cp - 1) { 760 DEBUGF(DIR, ("must be here but isn't -- returing NULL\n")); 777 if (DEBUG(DIR)) { 778 printf("must be here but isn't -- returing NULL\n"); 779 } 761 780 Lst_Close (path); 762 781 return ((char *) NULL); … … 778 797 */ 779 798 if (!hasSlash) { 780 DEBUGF(DIR, ("failed.\n")); 799 if (DEBUG(DIR)) { 800 printf("failed.\n"); 801 } 781 802 misses += 1; 782 803 return ((char *) NULL); … … 786 807 Boolean checkedDot = FALSE; 787 808 788 DEBUGF(DIR, ("failed. Trying subdirectories...")); 809 if (DEBUG(DIR)) { 810 printf("failed. Trying subdirectories..."); 811 } 789 812 (void) Lst_Open (path); 790 while ((ln = Lst_Next (path)) != N ULL) {813 while ((ln = Lst_Next (path)) != NILLNODE) { 791 814 p = (Path *) Lst_Datum (ln); 792 815 if (p != dot) { … … 799 822 checkedDot = TRUE; 800 823 } 801 DEBUGF(DIR, ("checking %s...", file)); 824 if (DEBUG(DIR)) { 825 printf("checking %s...", file); 826 } 827 802 828 803 829 if (stat (file, &stb) == 0) { 804 DEBUGF(DIR, ("got it.\n")); 830 if (DEBUG(DIR)) { 831 printf("got it.\n"); 832 } 805 833 806 834 Lst_Close (path); … … 825 853 * to fetch it again. 826 854 */ 827 DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file)); 855 if (DEBUG(DIR)) { 856 printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), 857 file); 858 } 828 859 entry = Hash_CreateEntry(&mtimes, (char *) file, 829 860 (Boolean *)NULL); … … 836 867 } 837 868 838 DEBUGF(DIR, ("failed. ")); 869 if (DEBUG(DIR)) { 870 printf("failed. "); 871 } 839 872 Lst_Close (path); 840 873 … … 844 877 * so no point in proceeding... 845 878 */ 846 DEBUGF(DIR, ("Checked . already, returning NULL\n")); 879 if (DEBUG(DIR)) { 880 printf("Checked . already, returning NULL\n"); 881 } 847 882 return(NULL); 848 883 } … … 873 908 bigmisses += 1; 874 909 ln = Lst_Last (path); 875 if (ln == N ULL) {910 if (ln == NILLNODE) { 876 911 return ((char *) NULL); 877 912 } else { … … 885 920 } 886 921 #else /* !notdef */ 887 DEBUGF(DIR, ("Looking for \"%s\"...", name)); 922 if (DEBUG(DIR)) { 923 printf("Looking for \"%s\"...", name); 924 } 888 925 889 926 bigmisses += 1; 890 927 entry = Hash_FindEntry(&mtimes, name); 891 928 if (entry != (Hash_Entry *)NULL) { 892 DEBUGF(DIR, ("got it (in mtime cache)\n")); 893 return (estrdup(name)); 929 if (DEBUG(DIR)) { 930 printf("got it (in mtime cache)\n"); 931 } 932 return(estrdup(name)); 894 933 } else if (stat (name, &stb) == 0) { 895 934 entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL); 896 DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name)); 935 if (DEBUG(DIR)) { 936 printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), 937 name); 938 } 897 939 Hash_SetValue(entry, (long)stb.st_mtime); 898 940 return (estrdup (name)); 899 941 } else { 900 DEBUGF(DIR, ("failed. Returning NULL\n")); 942 if (DEBUG(DIR)) { 943 printf("failed. Returning NULL\n"); 944 } 901 945 return ((char *)NULL); 902 946 } … … 920 964 */ 921 965 int 922 Dir_MTime (GNode *gn) 966 Dir_MTime (gn) 967 GNode *gn; /* the file whose modification time is 968 * desired */ 923 969 { 924 970 char *fullName; /* the full pathname of name */ … … 943 989 * Only do this once -- the second time folks are checking to 944 990 * see if the file was actually updated, so we need to actually go 945 * to the file system.991 * to the file system. 946 992 */ 947 DEBUGF(DIR, ("Using cached time %s for %s\n", 948 Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName)); 993 if (DEBUG(DIR)) { 994 printf("Using cached time %s for %s\n", 995 Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName); 996 } 949 997 stb.st_mtime = (time_t)(long)Hash_GetValue(entry); 950 998 Hash_DeleteEntry(&mtimes, entry); … … 982 1030 */ 983 1031 void 984 Dir_AddDir (Lst path, char *name) 1032 Dir_AddDir (path, name) 1033 Lst path; /* the path to which the directory should be 1034 * added */ 1035 char *name; /* the name of the directory to add */ 985 1036 { 986 1037 LstNode ln; /* node in case Path structure is found */ 987 Path*p; /* pointer to new Path structure */1038 register Path *p; /* pointer to new Path structure */ 988 1039 DIR *d; /* for reading directory */ 989 struct dirent *dp;/* entry in directory */990 991 ln = Lst_Find (openDirectories, ( void *)name, DirFindName);992 if (ln != N ULL) {1040 register struct dirent *dp; /* entry in directory */ 1041 1042 ln = Lst_Find (openDirectories, (ClientData)name, DirFindName); 1043 if (ln != NILLNODE) { 993 1044 p = (Path *)Lst_Datum (ln); 994 if (Lst_Member(path, ( void *)p) == NULL) {1045 if (Lst_Member(path, (ClientData)p) == NILLNODE) { 995 1046 p->refCount += 1; 996 (void)Lst_AtEnd (path, ( void *)p);1047 (void)Lst_AtEnd (path, (ClientData)p); 997 1048 } 998 1049 } else { 999 DEBUGF(DIR, ("Caching %s...", name)); 1050 if (DEBUG(DIR)) { 1051 printf("Caching %s...", name); 1052 fflush(stdout); 1053 } 1000 1054 1001 1055 if ((d = opendir (name)) != (DIR *) NULL) { … … 1007 1061 1008 1062 while ((dp = readdir (d)) != (struct dirent *) NULL) { 1009 #if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define 1063 #if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */ 1010 1064 /* 1011 1065 * The sun directory library doesn't check for a 0 inode … … 1022 1076 * that order when first going through a directory. This is 1023 1077 * needed for XFS over NFS filesystems since SGI does not 1024 * guarantee that these are the first two entries returned1078 * guarantee that these are * the first two entries returned 1025 1079 * from readdir(). 1026 1080 */ … … 1031 1085 } 1032 1086 (void) closedir (d); 1033 (void)Lst_AtEnd (openDirectories, (void *)p); 1034 (void)Lst_AtEnd (path, (void *)p); 1035 } 1036 DEBUGF(DIR, ("done\n")); 1087 (void)Lst_AtEnd (openDirectories, (ClientData)p); 1088 (void)Lst_AtEnd (path, (ClientData)p); 1089 } 1090 if (DEBUG(DIR)) { 1091 printf("done\n"); 1092 } 1037 1093 } 1038 1094 } … … 1052 1108 *----------------------------------------------------------------------- 1053 1109 */ 1054 void * 1055 Dir_CopyDir(void *p) 1110 ClientData 1111 Dir_CopyDir(p) 1112 ClientData p; 1056 1113 { 1057 1114 ((Path *) p)->refCount += 1; 1058 1115 1059 return (( void *)p);1116 return ((ClientData)p); 1060 1117 } 1061 1118 … … 1078 1135 */ 1079 1136 char * 1080 Dir_MakeFlags (char *flag, Lst path) 1137 Dir_MakeFlags (flag, path) 1138 char *flag; /* flag which should precede each directory */ 1139 Lst path; /* list of directories */ 1081 1140 { 1082 1141 char *str; /* the string which will be returned */ … … 1088 1147 1089 1148 if (Lst_Open (path) == SUCCESS) { 1090 while ((ln = Lst_Next (path)) != N ULL) {1149 while ((ln = Lst_Next (path)) != NILLNODE) { 1091 1150 p = (Path *) Lst_Datum (ln); 1092 1151 tstr = str_concat (flag, p->name, 0); … … 1115 1174 */ 1116 1175 void 1117 Dir_Destroy (void *pp) 1176 Dir_Destroy (pp) 1177 ClientData pp; /* The directory descriptor to nuke */ 1118 1178 { 1119 1179 Path *p = (Path *) pp; … … 1123 1183 LstNode ln; 1124 1184 1125 ln = Lst_Member (openDirectories, ( void *)p);1185 ln = Lst_Member (openDirectories, (ClientData)p); 1126 1186 (void) Lst_Remove (openDirectories, ln); 1127 1187 1128 1188 Hash_DeleteTable (&p->files); 1129 free( p->name);1130 free( p);1189 free((Address)p->name); 1190 free((Address)p); 1131 1191 } 1132 1192 } … … 1147 1207 */ 1148 1208 void 1149 Dir_ClearPath(Lst path) 1209 Dir_ClearPath(path) 1210 Lst path; /* Path to clear */ 1150 1211 { 1151 1212 Path *p; 1152 1213 while (!Lst_IsEmpty(path)) { 1153 1214 p = (Path *)Lst_DeQueue(path); 1154 Dir_Destroy(( void *) p);1215 Dir_Destroy((ClientData) p); 1155 1216 } 1156 1217 } … … 1172 1233 */ 1173 1234 void 1174 Dir_Concat(Lst path1, Lst path2) 1235 Dir_Concat(path1, path2) 1236 Lst path1; /* Dest */ 1237 Lst path2; /* Source */ 1175 1238 { 1176 1239 LstNode ln; 1177 1240 Path *p; 1178 1241 1179 for (ln = Lst_First(path2); ln != N ULL; ln = Lst_Succ(ln)) {1242 for (ln = Lst_First(path2); ln != NILLNODE; ln = Lst_Succ(ln)) { 1180 1243 p = (Path *)Lst_Datum(ln); 1181 if (Lst_Member(path1, ( void *)p) == NULL) {1244 if (Lst_Member(path1, (ClientData)p) == NILLNODE) { 1182 1245 p->refCount += 1; 1183 (void)Lst_AtEnd(path1, ( void *)p);1246 (void)Lst_AtEnd(path1, (ClientData)p); 1184 1247 } 1185 1248 } … … 1188 1251 /********** DEBUG INFO **********/ 1189 1252 void 1190 Dir_PrintDirectories( void)1253 Dir_PrintDirectories() 1191 1254 { 1192 1255 LstNode ln; … … 1200 1263 printf ("# %-20s referenced\thits\n", "directory"); 1201 1264 if (Lst_Open (openDirectories) == SUCCESS) { 1202 while ((ln = Lst_Next (openDirectories)) != N ULL) {1265 while ((ln = Lst_Next (openDirectories)) != NILLNODE) { 1203 1266 p = (Path *) Lst_Datum (ln); 1204 1267 printf ("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits); … … 1208 1271 } 1209 1272 1210 static int 1211 DirPrintDir (void *p, void *dummy __unused) 1273 static int DirPrintDir (p, dummy) 1274 ClientData p; 1275 ClientData dummy; 1212 1276 { 1213 1277 printf ("%s ", ((Path *) p)->name); 1214 1215 return (0); 1278 return (dummy ? 0 : 0); 1216 1279 } 1217 1280 1218 1281 void 1219 Dir_PrintPath (Lst path) 1220 { 1221 Lst_ForEach (path, DirPrintDir, (void *)0); 1222 } 1282 Dir_PrintPath (path) 1283 Lst path; 1284 { 1285 Lst_ForEach (path, DirPrintDir, (ClientData)0); 1286 } -
branches/FREEBSD/src/kmk/dir.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)dir.h 8.2 (Berkeley) 4/28/9540 * $FreeBSD: src/usr.bin/make/dir.h,v 1. 10 2002/04/13 10:57:56 obrienExp $38 * from: @(#)dir.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/dir.h,v 1.7 1999/08/28 01:03:29 peter Exp $ 41 40 */ 42 41 … … 55 54 } Path; 56 55 57 void Dir_Init (void);58 void Dir_End (void);59 Boolean Dir_HasWildcards (char *);60 void Dir_Expand (char *, Lst, Lst);61 char *Dir_FindFile (char *, Lst);62 int Dir_MTime (GNode *);63 void Dir_AddDir (Lst, char *);64 char *Dir_MakeFlags (char *, Lst);65 void Dir_ClearPath (Lst);66 void Dir_Concat (Lst, Lst);67 void Dir_PrintDirectories (void);68 void Dir_PrintPath (Lst);69 void Dir_Destroy (void *);70 void * Dir_CopyDir(void *);56 void Dir_Init __P((void)); 57 void Dir_End __P((void)); 58 Boolean Dir_HasWildcards __P((char *)); 59 void Dir_Expand __P((char *, Lst, Lst)); 60 char *Dir_FindFile __P((char *, Lst)); 61 int Dir_MTime __P((GNode *)); 62 void Dir_AddDir __P((Lst, char *)); 63 char *Dir_MakeFlags __P((char *, Lst)); 64 void Dir_ClearPath __P((Lst)); 65 void Dir_Concat __P((Lst, Lst)); 66 void Dir_PrintDirectories __P((void)); 67 void Dir_PrintPath __P((Lst)); 68 void Dir_Destroy __P((ClientData)); 69 ClientData Dir_CopyDir __P((ClientData)); 71 70 72 71 #endif /* _DIR */ -
branches/FREEBSD/src/kmk/for.c
r10 r24 1 1 /* 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Christos Zoulas. 2 * Copyright (c) 1992, The Regents of the University of California. 3 * All rights reserved. 7 4 * 8 5 * Redistribution and use in source and binary forms, with or without … … 33 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 31 * SUCH DAMAGE. 35 * 36 * @(#)for.c 8.1 (Berkeley) 6/6/93 37 */ 38 39 #include <sys/cdefs.h> 40 __FBSDID("$FreeBSD: src/usr.bin/make/for.c,v 1.19 2002/10/09 03:42:10 jmallett Exp $"); 32 */ 33 34 #ifndef lint 35 #if 0 36 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; 37 #else 38 static const char rcsid[] = 39 "$FreeBSD: src/usr.bin/make/for.c,v 1.10 1999/09/11 13:08:01 hoek Exp $"; 40 #endif 41 #endif /* not lint */ 41 42 42 43 /*- … … 84 85 } For; 85 86 86 static int ForExec (void *, void *);87 static int ForExec __P((ClientData, ClientData)); 87 88 88 89 … … 108 109 */ 109 110 int 110 For_Eval (char *line) 111 For_Eval (line) 112 char *line; /* Line to parse */ 111 113 { 112 114 char *ptr = line, *sub, *wrd; … … 176 178 sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE); 177 179 178 #define 180 #define ADDWORD() \ 179 181 Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \ 180 182 Buf_AddByte(buf, (Byte) '\0'), \ 181 Lst_AtFront(forLst, ( void *) Buf_GetAll(buf, &varlen)), \183 Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \ 182 184 Buf_Destroy(buf, FALSE) 183 185 … … 193 195 wrd = ptr--; 194 196 } 195 DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub)); 197 if (DEBUG(FOR)) 198 (void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub); 196 199 if (ptr - wrd > 0) 197 200 ADDWORD(); 198 201 else 199 202 Buf_Destroy(buf, TRUE); 200 free( sub);203 free((Address) sub); 201 204 202 205 forBuf = Buf_Init(0); … … 211 214 if (strncmp(ptr, "endfor", 6) == 0 && 212 215 (isspace((unsigned char) ptr[6]) || !ptr[6])) { 213 DEBUGF(FOR, ("For: end for %d\n", forLevel)); 216 if (DEBUG(FOR)) 217 (void) fprintf(stderr, "For: end for %d\n", forLevel); 214 218 if (--forLevel < 0) { 215 219 Parse_Error (level, "for-less endfor"); … … 220 224 isspace((unsigned char) ptr[3])) { 221 225 forLevel++; 222 DEBUGF(FOR, ("For: new loop %d\n", forLevel)); 226 if (DEBUG(FOR)) 227 (void) fprintf(stderr, "For: new loop %d\n", forLevel); 223 228 } 224 229 } … … 248 253 */ 249 254 static int 250 ForExec(void *namep, void *argp) 255 ForExec(namep, argp) 256 ClientData namep; 257 ClientData argp; 251 258 { 252 259 char *name = (char *) namep; … … 254 261 int len; 255 262 Var_Set(arg->var, name, VAR_GLOBAL); 256 DEBUGF(FOR, ("--- %s = %s\n", arg->var, name)); 263 if (DEBUG(FOR)) 264 (void) fprintf(stderr, "--- %s = %s\n", arg->var, name); 257 265 Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len), 258 266 VAR_GLOBAL, FALSE)); … … 278 286 */ 279 287 void 280 For_Run( void)288 For_Run() 281 289 { 282 290 For arg; … … 291 299 forLst = NULL; 292 300 293 Lst_ForEach(arg.lst, ForExec, ( void *) &arg);294 295 free( arg.var);296 Lst_Destroy(arg.lst, (void (*) (void *)) free);301 Lst_ForEach(arg.lst, ForExec, (ClientData) &arg); 302 303 free((Address)arg.var); 304 Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free); 297 305 Buf_Destroy(arg.buf, TRUE); 298 306 } -
branches/FREEBSD/src/kmk/hash.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 * @(#)hash.c 8.1 (Berkeley) 6/6/93 40 */ 41 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/hash.c,v 1.18 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/hash.c,v 1.9 1999/09/11 13:08:01 hoek Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 /* hash.c -- … … 50 53 * information increases. 51 54 */ 52 #include <unistd.h>53 55 #include "sprite.h" 54 56 #include "make.h" … … 60 62 */ 61 63 62 static void RebuildTable (Hash_Table *);64 static void RebuildTable __P((Hash_Table *)); 63 65 64 66 /* … … 67 69 */ 68 70 69 #define 71 #define rebuildLimit 8 70 72 71 73 /* … … 73 75 * 74 76 * Hash_InitTable -- 75 * 76 * Set up the hash table t with a given number of buckets, or a 77 * reasonable default if the number requested is less than or 78 * equal to zero. Hash tables will grow in size as needed. 79 * 77 * 78 * This routine just sets up the hash table. 80 79 * 81 80 * Results: … … 89 88 90 89 void 91 Hash_InitTable(Hash_Table *t, int numBuckets) 92 { 93 int i; 94 struct Hash_Entry **hp; 90 Hash_InitTable(t, numBuckets) 91 register Hash_Table *t; /* Structure to use to hold table. */ 92 int numBuckets; /* How many buckets to create for starters. 93 * This number is rounded up to a power of 94 * two. If <= 0, a reasonable default is 95 * chosen. The table will grow in size later 96 * as needed. */ 97 { 98 register int i; 99 register struct Hash_Entry **hp; 95 100 96 101 /* … … 130 135 131 136 void 132 Hash_DeleteTable(Hash_Table *t) 133 { 134 struct Hash_Entry **hp, *h, *nexth = NULL; 135 int i; 137 Hash_DeleteTable(t) 138 Hash_Table *t; 139 { 140 register struct Hash_Entry **hp, *h, *nexth = NULL; 141 register int i; 136 142 137 143 for (hp = t->bucketPtr, i = t->size; --i >= 0;) { … … 169 175 170 176 Hash_Entry * 171 Hash_FindEntry(Hash_Table *t, char *key) 172 { 173 Hash_Entry *e; 174 unsigned h; 175 char *p; 177 Hash_FindEntry(t, key) 178 Hash_Table *t; /* Hash table to search. */ 179 char *key; /* A hash key. */ 180 { 181 register Hash_Entry *e; 182 register unsigned h; 183 register char *p; 176 184 177 185 for (h = 0, p = key; *p;) … … 204 212 205 213 Hash_Entry * 206 Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr) 207 { 208 Hash_Entry *e; 209 unsigned int h; 210 char *p; 214 Hash_CreateEntry(t, key, newPtr) 215 register Hash_Table *t; /* Hash table to search. */ 216 char *key; /* A hash key. */ 217 Boolean *newPtr; /* Filled in with TRUE if new entry created, 218 * FALSE otherwise. */ 219 { 220 register Hash_Entry *e; 221 register unsigned h; 222 register char *p; 211 223 int keylen; 212 224 struct Hash_Entry **hp; … … 267 279 268 280 void 269 Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e) 270 { 271 Hash_Entry **hp, *p; 281 Hash_DeleteEntry(t, e) 282 Hash_Table *t; 283 Hash_Entry *e; 284 { 285 register Hash_Entry **hp, *p; 272 286 273 287 if (e == NULL) … … 282 296 } 283 297 } 284 (void) write( STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);298 (void) write(2, "bad call to Hash_DeleteEntry\n", 29); 285 299 abort(); 286 300 } … … 306 320 307 321 Hash_Entry * 308 Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr) 322 Hash_EnumFirst(t, searchPtr) 323 Hash_Table *t; /* Table to be searched. */ 324 register Hash_Search *searchPtr;/* Area in which to keep state 325 * about search.*/ 309 326 { 310 327 searchPtr->tablePtr = t; … … 333 350 334 351 Hash_Entry * 335 Hash_EnumNext(Hash_Search *searchPtr) 336 { 337 Hash_Entry *e; 352 Hash_EnumNext(searchPtr) 353 register Hash_Search *searchPtr; /* Area used to keep state about 354 search. */ 355 { 356 register Hash_Entry *e; 338 357 Hash_Table *t = searchPtr->tablePtr; 339 358 340 359 /* 341 360 * The hashEntryPtr field points to the most recently returned 342 * entry, or is NULL if we are starting up. If not NULL, we have361 * entry, or is nil if we are starting up. If not nil, we have 343 362 * to start at the next one in the chain. 344 363 */ … … 377 396 378 397 static void 379 RebuildTable(Hash_Table *t) 380 { 381 Hash_Entry *e, *next = NULL, **hp, **xp; 382 int i, mask; 383 Hash_Entry **oldhp; 398 RebuildTable(t) 399 register Hash_Table *t; 400 { 401 register Hash_Entry *e, *next = NULL, **hp, **xp; 402 register int i, mask; 403 register Hash_Entry **oldhp; 384 404 int oldsize; 385 405 -
branches/FREEBSD/src/kmk/hash.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)hash.h 8.1 (Berkeley) 6/6/9340 * $FreeBSD: src/usr.bin/make/hash.h,v 1. 12 2002/09/17 21:29:06 jmallettExp $38 * from: @(#)hash.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/hash.h,v 1.8 1999/08/28 01:03:30 peter Exp $ 41 40 */ 42 41 … … 58 57 * entries associated with the same 59 58 * bucket. */ 60 void *clientData; /* Arbitrary piece of data associated59 ClientData clientData; /* Arbitrary piece of data associated 61 60 * with key. */ 62 61 unsigned namehash; /* hash value of key */ … … 88 87 89 88 /* 90 * void *Hash_GetValue(h)89 * ClientData Hash_GetValue(h) 91 90 * Hash_Entry *h; 92 91 */ 93 92 94 #define 93 #define Hash_GetValue(h) ((h)->clientData) 95 94 96 95 /* … … 100 99 */ 101 100 102 #define Hash_SetValue(h, val) ((h)->clientData = (void *) (val))101 #define Hash_SetValue(h, val) ((h)->clientData = (ClientData) (val)) 103 102 104 103 /* … … 108 107 #define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int)) 109 108 110 void Hash_InitTable (Hash_Table *, int);111 void Hash_DeleteTable (Hash_Table *);112 Hash_Entry *Hash_FindEntry (Hash_Table *, char *);113 Hash_Entry *Hash_CreateEntry (Hash_Table *, char *, Boolean *);114 void Hash_DeleteEntry (Hash_Table *, Hash_Entry *);115 Hash_Entry *Hash_EnumFirst (Hash_Table *, Hash_Search *);116 Hash_Entry *Hash_EnumNext (Hash_Search *);109 void Hash_InitTable __P((Hash_Table *, int)); 110 void Hash_DeleteTable __P((Hash_Table *)); 111 Hash_Entry *Hash_FindEntry __P((Hash_Table *, char *)); 112 Hash_Entry *Hash_CreateEntry __P((Hash_Table *, char *, Boolean *)); 113 void Hash_DeleteEntry __P((Hash_Table *, Hash_Entry *)); 114 Hash_Entry *Hash_EnumFirst __P((Hash_Table *, Hash_Search *)); 115 Hash_Entry *Hash_EnumNext __P((Hash_Search *)); 117 116 118 117 #endif /* _HASH */ -
branches/FREEBSD/src/kmk/job.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 * @(#)job.c 8.2 (Berkeley) 3/19/94 40 */ 41 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/job.c,v 1.45 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/job.c,v 1.17.2.2 2001/02/13 03:13:57 will Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 #ifndef OLD_JOKE 46 #define 49 #define OLD_JOKE 0 47 50 #endif /* OLD_JOKE */ 48 51 … … 84 87 * FAILURE if the spec was incorrect. 85 88 * 86 * Job_ FinishPerform any final processing which needs doing.89 * Job_End Perform any final processing which needs doing. 87 90 * This includes the execution of any commands 88 91 * which have been/were attached to the .END … … 107 110 #include <sys/file.h> 108 111 #include <sys/time.h> 109 #include <sys/event.h>110 112 #include <sys/wait.h> 111 #include < err.h>113 #include <fcntl.h> 112 114 #include <errno.h> 113 #include < fcntl.h>115 #include <utime.h> 114 116 #include <stdio.h> 115 117 #include <string.h> 116 118 #include <signal.h> 117 #include <unistd.h>118 #include <utime.h>119 119 #include "make.h" 120 120 #include "hash.h" … … 134 134 static int errors = 0; /* number of errors reported */ 135 135 static int aborting = 0; /* why is the make aborting? */ 136 #define 137 #define 138 #define 136 #define ABORT_ERROR 1 /* Because of an error */ 137 #define ABORT_INTERRUPT 2 /* Because it was interrupted */ 138 #define ABORT_WAIT 3 /* Waiting for jobs to finish */ 139 139 140 140 /* … … 142 142 * is a char! So when we go above 127 we turn negative! 143 143 */ 144 #define 144 #define FILENO(a) ((unsigned) fileno(a)) 145 145 146 146 /* … … 158 158 * Return values from JobStart. 159 159 */ 160 #define 161 #define 162 #define 163 #define 160 #define JOB_RUNNING 0 /* Job is running */ 161 #define JOB_ERROR 1 /* Error in starting the job */ 162 #define JOB_FINISHED 2 /* The job is already finished */ 163 #define JOB_STOPPED 3 /* The job is stopped */ 164 164 165 165 /* … … 196 196 FALSE, "echo \"%s\"\n", "sh -c '%s || exit 0'\n", 197 197 #endif 198 "v", "e",199 },200 /*201 * KSH description. The Korn shell has a superset of202 * the Bourne shell's functionality.203 */204 {205 "ksh",206 TRUE, "set -", "set -v", "set -", 5,207 TRUE, "set -e", "set +e",208 198 "v", "e", 209 199 }, … … 239 229 * nLocal equals maxLocal */ 240 230 #ifndef RMT_WILL_WATCH 241 #ifdef USE_KQUEUE242 static int kqfd; /* File descriptor obtained by kqueue() */243 #else244 231 static fd_set outputs; /* Set of descriptors of pipes connected to 245 232 * the output channels of children */ 246 #endif247 233 #endif 248 234 … … 290 276 * really ugly, use dramamine sparingly. You have been warned. 291 277 */ 292 #define 278 #define W_SETMASKED(st, val, fun) \ 293 279 { \ 294 280 int sh = (int) ~0; \ … … 300 286 } 301 287 302 #define 303 #define 304 305 306 static int JobCondPassSig (void *, void *);307 static void JobPassSig (int);308 static int JobCmpPid (void *, void *);309 static int JobPrintCommand (void *, void *);310 static int JobSaveCommand (void *, void *);311 static void JobClose (Job *);288 #define W_SETTERMSIG(st, val) W_SETMASKED(st, val, WTERMSIG) 289 #define W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS) 290 291 292 static int JobCondPassSig __P((ClientData, ClientData)); 293 static void JobPassSig __P((int)); 294 static int JobCmpPid __P((ClientData, ClientData)); 295 static int JobPrintCommand __P((ClientData, ClientData)); 296 static int JobSaveCommand __P((ClientData, ClientData)); 297 static void JobClose __P((Job *)); 312 298 #ifdef REMOTE 313 static int JobCmpRmtID (Job *, int);299 static int JobCmpRmtID __P((Job *, int)); 314 300 # ifdef RMT_WILL_WATCH 315 static void JobLocalInput (int, Job *);301 static void JobLocalInput __P((int, Job *)); 316 302 # endif 317 303 #else 318 static void JobFinish (Job *, int *);319 static void JobExec (Job *, char **);320 #endif 321 static void JobMakeArgv (Job *, char **);322 static void JobRestart (Job *);323 static int JobStart (GNode *, int, Job *);324 static char *JobOutput (Job *, char *, char *, int);325 static void JobDoOutput (Job *, Boolean);326 static Shell *JobMatchShell (char *);327 static void JobInterrupt (int, int);328 static void JobRestartJobs (void);304 static void JobFinish __P((Job *, int *)); 305 static void JobExec __P((Job *, char **)); 306 #endif 307 static void JobMakeArgv __P((Job *, char **)); 308 static void JobRestart __P((Job *)); 309 static int JobStart __P((GNode *, int, Job *)); 310 static char *JobOutput __P((Job *, char *, char *, int)); 311 static void JobDoOutput __P((Job *, Boolean)); 312 static Shell *JobMatchShell __P((char *)); 313 static void JobInterrupt __P((int, int)); 314 static void JobRestartJobs __P((void)); 329 315 330 316 /*- … … 343 329 */ 344 330 static int 345 JobCondPassSig(void *jobp, void *signop) 331 JobCondPassSig(jobp, signop) 332 ClientData jobp; /* Job to biff */ 333 ClientData signop; /* Signal to send it */ 346 334 { 347 335 Job *job = (Job *) jobp; … … 358 346 * job as well. 359 347 */ 360 DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n", signo, job->pid)); 348 if (DEBUG(JOB)) { 349 (void) fprintf(stdout, 350 "JobCondPassSig passing signal %d to child %d.\n", 351 signo, job->pid); 352 (void) fflush(stdout); 353 } 361 354 KILL(job->pid, signo); 362 355 #endif … … 379 372 */ 380 373 static void 381 JobPassSig(int signo) 374 JobPassSig(signo) 375 int signo; /* The signal number we've received */ 382 376 { 383 377 sigset_t nmask, omask; 384 378 struct sigaction act; 385 379 386 DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo)); 387 Lst_ForEach(jobs, JobCondPassSig, (void *) &signo); 380 if (DEBUG(JOB)) { 381 (void) fprintf(stdout, "JobPassSig(%d) called.\n", signo); 382 (void) fflush(stdout); 383 } 384 Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo); 388 385 389 386 /* … … 419 416 sigaction(signo, &act, NULL); 420 417 421 DEBUGF(JOB, ("JobPassSig passing signal to self, mask = %x.\n", ~0 & ~(1 << (signo-1)))); 418 if (DEBUG(JOB)) { 419 (void) fprintf(stdout, 420 "JobPassSig passing signal to self, mask = %x.\n", 421 ~0 & ~(1 << (signo-1))); 422 (void) fflush(stdout); 423 } 422 424 (void) signal(signo, SIG_DFL); 423 425 … … 425 427 426 428 signo = SIGCONT; 427 Lst_ForEach(jobs, JobCondPassSig, ( void *) &signo);429 Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo); 428 430 429 431 (void) sigprocmask(SIG_SETMASK, &omask, NULL); … … 448 450 */ 449 451 static int 450 JobCmpPid(void *job, void *pid) 452 JobCmpPid(job, pid) 453 ClientData job; /* job to examine */ 454 ClientData pid; /* process id desired */ 451 455 { 452 456 return *(int *) pid - ((Job *) job)->pid; … … 468 472 */ 469 473 static int 470 JobCmpRmtID(void *job, void *rmtID) 474 JobCmpRmtID(job, rmtID) 475 ClientData job; /* job to examine */ 476 ClientData rmtID; /* remote id desired */ 471 477 { 472 478 return(*(int *) rmtID - *(int *) job->rmtID); … … 487 493 * made and return non-zero to signal that the end of the commands 488 494 * was reached. These commands are later attached to the postCommands 489 * node and executed by Job_ Finishwhen all things are done.495 * node and executed by Job_End when all things are done. 490 496 * This function is called from JobStart via Lst_ForEach. 491 497 * … … 502 508 */ 503 509 static int 504 JobPrintCommand(void *cmdp, void *jobp) 510 JobPrintCommand(cmdp, jobp) 511 ClientData cmdp; /* command string to print */ 512 ClientData jobp; /* job for which to print it */ 505 513 { 506 514 Boolean noSpecials; /* true if we shouldn't worry about … … 525 533 if ((job->flags & JOB_IGNDOTS) == 0) { 526 534 job->tailCmds = Lst_Succ(Lst_Member(job->node->commands, 527 ( void *)cmd));535 (ClientData)cmd)); 528 536 return 1; 529 537 } … … 531 539 } 532 540 533 #define DBPRINTF(fmt, arg) \ 534 DEBUGF(JOB, (fmt, arg)); \ 541 #define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \ 542 (void) fprintf(stdout, fmt, arg); \ 543 (void) fflush(stdout); \ 544 } \ 535 545 (void) fprintf(job->cmdFILE, fmt, arg); \ 536 546 (void) fflush(job->cmdFILE); … … 542 552 * the variables in the command. 543 553 */ 544 cmdNode = Lst_Member(job->node->commands, ( void *)cmd);554 cmdNode = Lst_Member(job->node->commands, (ClientData)cmd); 545 555 cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE); 546 Lst_Replace(cmdNode, ( void *)cmdStart);556 Lst_Replace(cmdNode, (ClientData)cmdStart); 547 557 548 558 cmdTemplate = "%s\n"; … … 659 669 */ 660 670 static int 661 JobSaveCommand(void *cmd, void *gn) 662 { 663 cmd = (void *) Var_Subst(NULL, (char *) cmd, (GNode *) gn, FALSE); 671 JobSaveCommand(cmd, gn) 672 ClientData cmd; 673 ClientData gn; 674 { 675 cmd = (ClientData) Var_Subst(NULL, (char *) cmd, (GNode *) gn, FALSE); 664 676 (void) Lst_AtEnd(postCommands->commands, cmd); 665 677 return(0); … … 681 693 */ 682 694 static void 683 JobClose(Job *job) 695 JobClose(job) 696 Job *job; 684 697 { 685 698 if (usePipes) { 686 699 #ifdef RMT_WILL_WATCH 687 700 Rmt_Ignore(job->inPipe); 688 #el if !defined(USE_KQUEUE)701 #else 689 702 FD_CLR(job->inPipe, &outputs); 690 703 #endif … … 725 738 /*ARGSUSED*/ 726 739 static void 727 JobFinish(Job *job, int *status) 740 JobFinish(job, status) 741 Job *job; /* job to finish */ 742 int *status; /* sub-why job went away */ 728 743 { 729 744 Boolean done; … … 794 809 */ 795 810 out = fdopen(job->outFd, "w"); 796 if (out == NULL)797 Punt("Cannot fdopen");798 811 } else { 799 812 out = stdout; … … 801 814 802 815 if (WIFEXITED(*status)) { 803 DEBUGF(JOB, ("Process %d exited.\n", job->pid)); 816 if (DEBUG(JOB)) { 817 (void) fprintf(stdout, "Process %d exited.\n", job->pid); 818 (void) fflush(stdout); 819 } 804 820 if (WEXITSTATUS(*status) != 0) { 805 821 if (usePipes && job->node != lastNode) { … … 822 838 } 823 839 } else if (WIFSTOPPED(*status)) { 824 DEBUGF(JOB, ("Process %d stopped.\n", job->pid)); 840 if (DEBUG(JOB)) { 841 (void) fprintf(stdout, "Process %d stopped.\n", job->pid); 842 (void) fflush(stdout); 843 } 825 844 if (usePipes && job->node != lastNode) { 826 845 MESSAGE(out, job->node); … … 832 851 } 833 852 job->flags |= JOB_RESUME; 834 (void)Lst_AtEnd(stoppedJobs, ( void *)job);853 (void)Lst_AtEnd(stoppedJobs, (ClientData)job); 835 854 #ifdef REMOTE 836 855 if (job->flags & JOB_REMIGRATE) … … 853 872 } 854 873 if (!(job->flags & JOB_CONTINUING)) { 855 DEBUGF(JOB, ("Warning: process %d was not continuing.\n", job->pid)); 874 if (DEBUG(JOB)) { 875 (void) fprintf(stdout, 876 "Warning: process %d was not continuing.\n", 877 job->pid); 878 (void) fflush(stdout); 879 } 856 880 #ifdef notdef 857 881 /* … … 865 889 } 866 890 job->flags &= ~JOB_CONTINUING; 867 Lst_AtEnd(jobs, ( void *)job);891 Lst_AtEnd(jobs, (ClientData)job); 868 892 nJobs += 1; 869 893 if (!(job->flags & JOB_REMOTE)) { 870 DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid)); 894 if (DEBUG(JOB)) { 895 (void) fprintf(stdout, 896 "Process %d is continuing locally.\n", 897 job->pid); 898 (void) fflush(stdout); 899 } 871 900 nLocal += 1; 872 901 } 873 902 if (nJobs == maxJobs) { 874 903 jobFull = TRUE; 875 DEBUGF(JOB, ("Job queue is full.\n")); 904 if (DEBUG(JOB)) { 905 (void) fprintf(stdout, "Job queue is full.\n"); 906 (void) fflush(stdout); 907 } 876 908 } 877 909 (void) fflush(out); … … 913 945 done = FALSE; 914 946 break; 915 default:916 break;917 947 } 918 948 } else { … … 932 962 * on the .END target. 933 963 */ 934 if (job->tailCmds != N ULL) {964 if (job->tailCmds != NILLNODE) { 935 965 Lst_ForEachFrom(job->node->commands, job->tailCmds, 936 966 JobSaveCommand, 937 ( void *)job->node);967 (ClientData)job->node); 938 968 } 939 969 job->node->made = MADE; 940 970 Make_Update(job->node); 941 free( job);971 free((Address)job); 942 972 } else if (*status != 0) { 943 973 errors += 1; 944 free( job);974 free((Address)job); 945 975 } 946 976 … … 970 1000 * Job_Touch -- 971 1001 * Touch the given target. Called by JobStart when the -t flag was 972 * given . Prints messages unless told to be silent.1002 * given 973 1003 * 974 1004 * Results: … … 981 1011 */ 982 1012 void 983 Job_Touch(GNode *gn, Boolean silent) 1013 Job_Touch(gn, silent) 1014 GNode *gn; /* the node of the file to touch */ 1015 Boolean silent; /* TRUE if should not print messages */ 984 1016 { 985 1017 int streamID; /* ID of stream opened to do the touch */ … … 1022 1054 */ 1023 1055 if (read(streamID, &c, 1) == 1) { 1024 (void) lseek(streamID, (off_t)0, SEEK_SET);1056 (void) lseek(streamID, 0L, SEEK_SET); 1025 1057 (void) write(streamID, &c, 1); 1026 1058 } … … 1050 1082 */ 1051 1083 Boolean 1052 Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) 1084 Job_CheckCommands(gn, abortProc) 1085 GNode *gn; /* The target whose commands need 1086 * verifying */ 1087 void (*abortProc) __P((char *, ...)); 1088 /* Function to abort with message */ 1053 1089 { 1054 1090 if (OP_NOP(gn->type) && Lst_IsEmpty(gn->commands) && … … 1058 1094 * commands 1059 1095 */ 1060 if ((DEFAULT != N ULL) && !Lst_IsEmpty(DEFAULT->commands)) {1096 if ((DEFAULT != NILGNODE) && !Lst_IsEmpty(DEFAULT->commands)) { 1061 1097 char *p1; 1062 1098 /* … … 1118 1154 /*ARGSUSED*/ 1119 1155 static void 1120 JobLocalInput(int stream, Job *job) 1156 JobLocalInput(stream, job) 1157 int stream; /* Stream that's ready (ignored) */ 1158 Job *job; /* Job to which the stream belongs */ 1121 1159 { 1122 1160 JobDoOutput(job, FALSE); … … 1140 1178 */ 1141 1179 static void 1142 JobExec(Job *job, char **argv) 1180 JobExec(job, argv) 1181 Job *job; /* Job to execute */ 1182 char **argv; 1143 1183 { 1144 1184 int cpid; /* ID of new child */ … … 1147 1187 int i; 1148 1188 1149 DEBUGF(JOB, ("Running %s %sly\n", job->node->name,1150 job->flags&JOB_REMOTE?"remote":"local"));1151 DEBUGF(JOB, ("\tCommand: "));1189 (void) fprintf(stdout, "Running %s %sly\n", job->node->name, 1190 job->flags&JOB_REMOTE?"remote":"local"); 1191 (void) fprintf(stdout, "\tCommand: "); 1152 1192 for (i = 0; argv[i] != NULL; i++) { 1153 DEBUGF(JOB, ("%s ", argv[i])); 1154 } 1155 DEBUGF(JOB, ("\n")); 1193 (void) fprintf(stdout, "%s ", argv[i]); 1194 } 1195 (void) fprintf(stdout, "\n"); 1196 (void) fflush(stdout); 1156 1197 } 1157 1198 … … 1186 1227 Punt("Cannot dup2: %s", strerror(errno)); 1187 1228 (void) fcntl(0, F_SETFD, 0); 1188 (void) lseek(0, (off_t)0, SEEK_SET);1229 (void) lseek(0, 0, SEEK_SET); 1189 1230 1190 1231 if (usePipes) { … … 1234 1275 (void) execv(shellPath, argv); 1235 1276 1236 (void) write( STDERR_FILENO, "Could not execute shell\n",1277 (void) write(2, "Could not execute shell\n", 1237 1278 sizeof("Could not execute shell")); 1238 1279 _exit(1); … … 1249 1290 * stream to watch in the outputs mask 1250 1291 */ 1251 #ifdef USE_KQUEUE1252 struct kevent kev[2];1253 #endif1254 1292 job->curPos = 0; 1255 1293 1256 1294 #ifdef RMT_WILL_WATCH 1257 1295 Rmt_Watch(job->inPipe, JobLocalInput, job); 1258 #elif defined(USE_KQUEUE)1259 EV_SET(&kev[0], job->inPipe, EVFILT_READ, EV_ADD, 0, 0, job);1260 EV_SET(&kev[1], job->pid, EVFILT_PROC, EV_ADD | EV_ONESHOT,1261 NOTE_EXIT, 0, NULL);1262 if (kevent(kqfd, kev, 2, NULL, 0, NULL) != 0) {1263 /* kevent() will fail if the job is already finished */1264 if (errno != EBADF && errno != ESRCH)1265 Punt("kevent: %s", strerror(errno));1266 }1267 1296 #else 1268 1297 FD_SET(job->inPipe, &outputs); … … 1298 1327 */ 1299 1328 nJobs += 1; 1300 (void) Lst_AtEnd(jobs, ( void *)job);1329 (void) Lst_AtEnd(jobs, (ClientData)job); 1301 1330 if (nJobs == maxJobs) { 1302 1331 jobFull = TRUE; … … 1317 1346 */ 1318 1347 static void 1319 JobMakeArgv(Job *job, char **argv) 1348 JobMakeArgv(job, argv) 1349 Job *job; 1350 char **argv; 1320 1351 { 1321 1352 int argc; … … 1371 1402 */ 1372 1403 static void 1373 JobRestart(Job *job) 1404 JobRestart(job) 1405 Job *job; /* Job to restart */ 1374 1406 { 1375 1407 #ifdef REMOTE … … 1430 1462 (void) fflush(stdout); 1431 1463 } 1432 (void)Lst_AtFront(stoppedJobs, ( void *)job);1464 (void)Lst_AtFront(stoppedJobs, (ClientData)job); 1433 1465 jobFull = TRUE; 1434 DEBUGF(JOB, ("Job queue is full.\n")); 1466 if (DEBUG(JOB)) { 1467 (void) fprintf(stdout, "Job queue is full.\n"); 1468 (void) fflush(stdout); 1469 } 1435 1470 return; 1436 1471 } … … 1448 1483 #endif 1449 1484 1450 (void)Lst_AtEnd(jobs, ( void *)job);1485 (void)Lst_AtEnd(jobs, (ClientData)job); 1451 1486 nJobs += 1; 1452 1487 if (nJobs == maxJobs) { 1453 1488 jobFull = TRUE; 1454 DEBUGF(JOB, ("Job queue is full.\n")); 1489 if (DEBUG(JOB)) { 1490 (void) fprintf(stdout, "Job queue is full.\n"); 1491 (void) fflush(stdout); 1492 } 1455 1493 } 1456 1494 } else if (job->flags & JOB_RESTART) { … … 1467 1505 JobMakeArgv(job, argv); 1468 1506 1469 DEBUGF(JOB, ("Restarting %s...", job->node->name)); 1507 if (DEBUG(JOB)) { 1508 (void) fprintf(stdout, "Restarting %s...", job->node->name); 1509 (void) fflush(stdout); 1510 } 1470 1511 #ifdef REMOTE 1471 1512 if ((job->node->type&OP_NOEXPORT) || … … 1483 1524 * back on the hold queue and mark the table full 1484 1525 */ 1485 DEBUGF(JOB, ("holding\n")); 1486 (void)Lst_AtFront(stoppedJobs, (void *)job); 1526 if (DEBUG(JOB)) { 1527 (void) fprintf(stdout, "holding\n"); 1528 (void) fflush(stdout); 1529 } 1530 (void)Lst_AtFront(stoppedJobs, (ClientData)job); 1487 1531 jobFull = TRUE; 1488 DEBUGF(JOB, ("Job queue is full.\n")); 1532 if (DEBUG(JOB)) { 1533 (void) fprintf(stdout, "Job queue is full.\n"); 1534 (void) fflush(stdout); 1535 } 1489 1536 return; 1490 1537 } else { … … 1492 1539 * Job may be run locally. 1493 1540 */ 1494 DEBUGF(JOB, ("running locally\n")); 1541 if (DEBUG(JOB)) { 1542 (void) fprintf(stdout, "running locally\n"); 1543 (void) fflush(stdout); 1544 } 1495 1545 job->flags &= ~JOB_REMOTE; 1496 1546 } … … 1501 1551 * Can be exported. Hooray! 1502 1552 */ 1503 DEBUGF(JOB, ("exporting\n")); 1553 if (DEBUG(JOB)) { 1554 (void) fprintf(stdout, "exporting\n"); 1555 (void) fflush(stdout); 1556 } 1504 1557 job->flags |= JOB_REMOTE; 1505 1558 } … … 1511 1564 * we don't know... 1512 1565 */ 1513 DEBUGF(JOB, ("Resuming %s...", job->node->name)); 1566 if (DEBUG(JOB)) { 1567 (void) fprintf(stdout, "Resuming %s...", job->node->name); 1568 (void) fflush(stdout); 1569 } 1514 1570 if (((job->flags & JOB_REMOTE) || 1515 1571 (nLocal < maxLocal) || … … 1551 1607 1552 1608 job->flags &= ~(JOB_RESUME|JOB_CONTINUING); 1553 DEBUGF(JOB, ("done\n")); 1609 if (DEBUG(JOB)) { 1610 (void) fprintf(stdout, "done\n"); 1611 (void) fflush(stdout); 1612 } 1554 1613 } else { 1555 1614 Error("couldn't resume %s: %s", … … 1564 1623 * place the job back on the list of stopped jobs. 1565 1624 */ 1566 DEBUGF(JOB, ("table full\n")); 1567 (void) Lst_AtFront(stoppedJobs, (void *)job); 1625 if (DEBUG(JOB)) { 1626 (void) fprintf(stdout, "table full\n"); 1627 (void) fflush(stdout); 1628 } 1629 (void) Lst_AtFront(stoppedJobs, (ClientData)job); 1568 1630 jobFull = TRUE; 1569 DEBUGF(JOB, ("Job queue is full.\n")); 1631 if (DEBUG(JOB)) { 1632 (void) fprintf(stdout, "Job queue is full.\n"); 1633 (void) fflush(stdout); 1634 } 1570 1635 } 1571 1636 } … … 1589 1654 */ 1590 1655 static int 1591 JobStart(GNode *gn, int flags, Job *previous) 1592 { 1593 Job *job; /* new job descriptor */ 1656 JobStart(gn, flags, previous) 1657 GNode *gn; /* target to create */ 1658 int flags; /* flags for the job to override normal ones. 1659 * e.g. JOB_SPECIAL or JOB_IGNDOTS */ 1660 Job *previous; /* The previous Job structure for this node, 1661 * if any. */ 1662 { 1663 register Job *job; /* new job descriptor */ 1594 1664 char *argv[4]; /* Argument vector to shell */ 1595 1665 Boolean cmdsOK; /* true if the nodes commands were all right */ … … 1603 1673 } else { 1604 1674 job = (Job *) emalloc(sizeof(Job)); 1675 if (job == NULL) { 1676 Punt("JobStart out of memory"); 1677 } 1605 1678 flags |= JOB_FIRST; 1606 1679 } 1607 1680 1608 1681 job->node = gn; 1609 job->tailCmds = N ULL;1682 job->tailCmds = NILLNODE; 1610 1683 1611 1684 /* … … 1682 1755 LstNode ln = Lst_Next(gn->commands); 1683 1756 1684 if ((ln == N ULL) ||1685 JobPrintCommand(( void *) Lst_Datum(ln),1686 ( void *) job))1757 if ((ln == NILLNODE) || 1758 JobPrintCommand((ClientData) Lst_Datum(ln), 1759 (ClientData) job)) 1687 1760 { 1688 1761 noExec = TRUE; … … 1709 1782 */ 1710 1783 numCommands = 0; 1711 Lst_ForEach(gn->commands, JobPrintCommand, ( void *)job);1784 Lst_ForEach(gn->commands, JobPrintCommand, (ClientData)job); 1712 1785 1713 1786 /* … … 1735 1808 */ 1736 1809 if (cmdsOK) { 1737 Lst_ForEach(gn->commands, JobPrintCommand, ( void *)job);1810 Lst_ForEach(gn->commands, JobPrintCommand, (ClientData)job); 1738 1811 } 1739 1812 /* … … 1773 1846 if (cmdsOK) { 1774 1847 if (aborting == 0) { 1775 if (job->tailCmds != N ULL) {1848 if (job->tailCmds != NILLNODE) { 1776 1849 Lst_ForEachFrom(job->node->commands, job->tailCmds, 1777 1850 JobSaveCommand, 1778 ( void *)job->node);1851 (ClientData)job->node); 1779 1852 } 1780 1853 job->node->made = MADE; 1781 1854 Make_Update(job->node); 1782 1855 } 1783 free( job);1856 free((Address)job); 1784 1857 return(JOB_FINISHED); 1785 1858 } else { 1786 free( job);1859 free((Address)job); 1787 1860 return(JOB_ERROR); 1788 1861 } … … 1855 1928 jobFull = TRUE; 1856 1929 1857 DEBUGF(JOB, ("Can only run job locally.\n")); 1930 if (DEBUG(JOB)) { 1931 (void) fprintf(stdout, "Can only run job locally.\n"); 1932 (void) fflush(stdout); 1933 } 1858 1934 job->flags |= JOB_RESTART; 1859 (void) Lst_AtEnd(stoppedJobs, ( void *)job);1935 (void) Lst_AtEnd(stoppedJobs, (ClientData)job); 1860 1936 } else { 1861 1937 if ((nLocal >= maxLocal) && local) { … … 1865 1941 */ 1866 1942 jobFull = TRUE; 1867 DEBUGF(JOB, ("Local job queue is full.\n")); 1943 if (DEBUG(JOB)) { 1944 (void) fprintf(stdout, "Local job queue is full.\n"); 1945 (void) fflush(stdout); 1946 } 1868 1947 } 1869 1948 JobExec(job, argv); … … 1873 1952 1874 1953 static char * 1875 JobOutput(Job *job, char *cp, char *endp, int msg) 1876 { 1877 char *ecp; 1954 JobOutput(job, cp, endp, msg) 1955 register Job *job; 1956 register char *cp, *endp; 1957 int msg; 1958 { 1959 register char *ecp; 1878 1960 1879 1961 if (commandShell->noPrint) { … … 1943 2025 */ 1944 2026 STATIC void 1945 JobDoOutput(Job *job, Boolean finish) 2027 JobDoOutput(job, finish) 2028 register Job *job; /* the job whose output needs printing */ 2029 Boolean finish; /* TRUE if this is the last time we'll be 2030 * called for this job */ 1946 2031 { 1947 2032 Boolean gotNL = FALSE; /* true if got a newline */ 1948 2033 Boolean fbuf; /* true if our buffer filled up */ 1949 intnr; /* number of bytes read */1950 inti; /* auxiliary index into outBuf */1951 intmax; /* limit for i (end of current data) */2034 register int nr; /* number of bytes read */ 2035 register int i; /* auxiliary index into outBuf */ 2036 register int max; /* limit for i (end of current data) */ 1952 2037 int nRead; /* (Temporary) number of bytes read */ 1953 2038 … … 1967 2052 JOB_BUFSIZE - job->curPos); 1968 2053 if (nRead < 0) { 1969 DEBUGF(JOB, ("JobDoOutput(piperead)")); 2054 if (DEBUG(JOB)) { 2055 perror("JobDoOutput(piperead)"); 2056 } 1970 2057 nr = 0; 1971 2058 } else { … … 2021 2108 * first, overwriting the newline character if there was one. 2022 2109 * So long as the line isn't one we should filter (according 2023 * to the shell description), we print the line, prece ded2110 * to the shell description), we print the line, preceeded 2024 2111 * by a target banner if this target isn't the same as the 2025 2112 * one for which we last printed something. … … 2087 2174 (void) fflush(stdout); 2088 2175 while (fgets(inLine, sizeof(inLine), oFILE) != NULL) { 2089 char *cp, *endp, *oendp;2176 register char *cp, *endp, *oendp; 2090 2177 2091 2178 cp = inLine; … … 2134 2221 */ 2135 2222 void 2136 Job_CatchChildren(Boolean block) 2223 Job_CatchChildren(block) 2224 Boolean block; /* TRUE if should block on the wait. */ 2137 2225 { 2138 2226 int pid; /* pid of dead child */ 2139 Job*job; /* job descriptor for dead child */2227 register Job *job; /* job descriptor for dead child */ 2140 2228 LstNode jnode; /* list element for finding job */ 2141 2229 int status; /* Exit/termination status */ … … 2151 2239 (block?0:WNOHANG)|WUNTRACED)) > 0) 2152 2240 { 2153 DEBUGF(JOB, ("Process %d exited or stopped.\n", pid)); 2154 2155 jnode = Lst_Find(jobs, (void *)&pid, JobCmpPid); 2156 2157 if (jnode == NULL) { 2241 if (DEBUG(JOB)) { 2242 (void) fprintf(stdout, "Process %d exited or stopped.\n", pid); 2243 (void) fflush(stdout); 2244 } 2245 2246 2247 jnode = Lst_Find(jobs, (ClientData)&pid, JobCmpPid); 2248 2249 if (jnode == NILLNODE) { 2158 2250 if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) { 2159 jnode = Lst_Find(stoppedJobs, ( void *) &pid, JobCmpPid);2160 if (jnode == N ULL) {2251 jnode = Lst_Find(stoppedJobs, (ClientData) &pid, JobCmpPid); 2252 if (jnode == NILLNODE) { 2161 2253 Error("Resumed child (%d) not in table", pid); 2162 2254 continue; … … 2172 2264 (void) Lst_Remove(jobs, jnode); 2173 2265 nJobs -= 1; 2174 DEBUGF(JOB, ("Job queue is no longer full.\n")); 2266 if (jobFull && DEBUG(JOB)) { 2267 (void) fprintf(stdout, "Job queue is no longer full.\n"); 2268 (void) fflush(stdout); 2269 } 2175 2270 jobFull = FALSE; 2176 2271 #ifdef REMOTE 2177 2272 if (!(job->flags & JOB_REMOTE)) { 2178 DEBUGF(JOB, ("Job queue has one fewer local process.\n")); 2273 if (DEBUG(JOB)) { 2274 (void) fprintf(stdout, 2275 "Job queue has one fewer local process.\n"); 2276 (void) fflush(stdout); 2277 } 2179 2278 nLocal -= 1; 2180 2279 } … … 2205 2304 */ 2206 2305 void 2207 Job_CatchOutput( void)2306 Job_CatchOutput() 2208 2307 { 2209 2308 int nfds; 2210 #ifdef USE_KQUEUE2211 #define KEV_SIZE 42212 struct kevent kev[KEV_SIZE];2213 int i;2214 #else2215 2309 struct timeval timeout; 2216 2310 fd_set readfds; 2217 LstNode ln; 2218 Job *job; 2219 #endif 2311 register LstNode ln; 2312 register Job *job; 2220 2313 #ifdef RMT_WILL_WATCH 2221 2314 int pnJobs; /* Previous nJobs */ … … 2247 2340 #else 2248 2341 if (usePipes) { 2249 #ifdef USE_KQUEUE2250 if ((nfds = kevent(kqfd, NULL, 0, kev, KEV_SIZE, NULL)) == -1) {2251 Punt("kevent: %s", strerror(errno));2252 } else {2253 for (i = 0; i < nfds; i++) {2254 if (kev[i].flags & EV_ERROR) {2255 warnc(kev[i].data, "kevent");2256 continue;2257 }2258 switch (kev[i].filter) {2259 case EVFILT_READ:2260 JobDoOutput(kev[i].udata, FALSE);2261 break;2262 case EVFILT_PROC:2263 /* Just wake up and let Job_CatchChildren() collect the2264 * terminated job. */2265 break;2266 }2267 }2268 }2269 #else2270 2342 readfds = outputs; 2271 2343 timeout.tv_sec = SEL_SEC; … … 2279 2351 Punt("Cannot open job table"); 2280 2352 } 2281 while (nfds && (ln = Lst_Next(jobs)) != N ULL) {2353 while (nfds && (ln = Lst_Next(jobs)) != NILLNODE) { 2282 2354 job = (Job *) Lst_Datum(ln); 2283 2355 if (FD_ISSET(job->inPipe, &readfds)) { … … 2288 2360 Lst_Close(jobs); 2289 2361 } 2290 #endif /* !USE_KQUEUE */2291 2362 } 2292 2363 #endif /* RMT_WILL_WATCH */ … … 2308 2379 */ 2309 2380 void 2310 Job_Make(GNode *gn) 2381 Job_Make(gn) 2382 GNode *gn; 2311 2383 { 2312 2384 (void) JobStart(gn, 0, NULL); … … 2316 2388 *----------------------------------------------------------------------- 2317 2389 * Job_Init -- 2318 * Initialize the process module, given a maximum number of jobs, and 2319 * a maximum number of local jobs. 2390 * Initialize the process module 2320 2391 * 2321 2392 * Results: … … 2327 2398 */ 2328 2399 void 2329 Job_Init(int maxproc, int maxlocal) 2400 Job_Init(maxproc, maxlocal) 2401 int maxproc; /* the greatest number of jobs which may be 2402 * running at one time */ 2403 int maxlocal; /* the greatest number of local jobs which may 2404 * be running at once. */ 2330 2405 { 2331 2406 GNode *begin; /* node for commands to do at the very start */ … … 2342 2417 errors = 0; 2343 2418 2344 lastNode = N ULL;2419 lastNode = NILGNODE; 2345 2420 2346 2421 if (maxJobs == 1 || beVerbose == 0 … … 2414 2489 #endif 2415 2490 2416 #ifdef USE_KQUEUE2417 if ((kqfd = kqueue()) == -1) {2418 Punt("kqueue: %s", strerror(errno));2419 }2420 #endif2421 2422 2491 begin = Targ_FindNode(".BEGIN", TARG_NOCREATE); 2423 2492 2424 if (begin != N ULL) {2493 if (begin != NILGNODE) { 2425 2494 JobStart(begin, JOB_SPECIAL, (Job *)0); 2426 2495 while (nJobs) { … … 2449 2518 */ 2450 2519 Boolean 2451 Job_Full( void)2520 Job_Full() 2452 2521 { 2453 2522 return(aborting || jobFull); … … 2471 2540 */ 2472 2541 Boolean 2473 Job_Empty( void)2542 Job_Empty() 2474 2543 { 2475 2544 if (nJobs == 0) { … … 2504 2573 */ 2505 2574 static Shell * 2506 JobMatchShell(char *name) 2507 { 2508 Shell *sh; /* Pointer into shells table */ 2509 Shell *match; /* Longest-matching shell */ 2510 char *cp1, 2575 JobMatchShell(name) 2576 char *name; /* Final component of shell path */ 2577 { 2578 register Shell *sh; /* Pointer into shells table */ 2579 Shell *match; /* Longest-matching shell */ 2580 register char *cp1, 2511 2581 *cp2; 2512 2582 char *eoname; … … 2575 2645 */ 2576 2646 ReturnStatus 2577 Job_ParseShell(char *line) 2647 Job_ParseShell(line) 2648 char *line; /* The shell spec */ 2578 2649 { 2579 2650 char **words; 2580 2651 int wordCount; 2581 char**argv;2582 intargc;2652 register char **argv; 2653 register int argc; 2583 2654 char *path; 2584 2655 Shell newShell; 2585 2656 Boolean fullSpec = FALSE; 2586 2657 2587 while (isspace( (unsigned char)*line)) {2658 while (isspace(*line)) { 2588 2659 line++; 2589 2660 } 2590 2661 words = brk_string(line, &wordCount, TRUE); 2591 2662 2592 memset( &newShell, 0, sizeof(newShell));2663 memset((Address)&newShell, 0, sizeof(newShell)); 2593 2664 2594 2665 /* … … 2686 2757 } 2687 2758 2759 /* 2760 * Do not free up the words themselves, since they might be in use by the 2761 * shell specification... 2762 */ 2763 free(words); 2688 2764 return SUCCESS; 2689 2765 } … … 2703 2779 */ 2704 2780 static void 2705 JobInterrupt(int runINTERRUPT, int signo) 2781 JobInterrupt(runINTERRUPT, signo) 2782 int runINTERRUPT; /* Non-zero if commands for the .INTERRUPT 2783 * target should be executed */ 2784 int signo; /* signal received */ 2706 2785 { 2707 2786 LstNode ln; /* element in job table */ … … 2711 2790 aborting = ABORT_INTERRUPT; 2712 2791 2713 2714 while ((ln = Lst_Next(jobs)) != N ULL) {2792 (void) Lst_Open(jobs); 2793 while ((ln = Lst_Next(jobs)) != NILLNODE) { 2715 2794 job = (Job *) Lst_Datum(ln); 2716 2795 … … 2744 2823 #else 2745 2824 if (job->pid) { 2746 DEBUGF(JOB, ("JobInterrupt passing signal to child %d.\n", 2747 job->pid)); 2825 if (DEBUG(JOB)) { 2826 (void) fprintf(stdout, 2827 "JobInterrupt passing signal to child %d.\n", 2828 job->pid); 2829 (void) fflush(stdout); 2830 } 2748 2831 KILL(job->pid, signo); 2749 2832 } … … 2752 2835 2753 2836 #ifdef REMOTE 2754 2755 while ((ln = Lst_Next(stoppedJobs)) != N ULL) {2837 (void)Lst_Open(stoppedJobs); 2838 while ((ln = Lst_Next(stoppedJobs)) != NILLNODE) { 2756 2839 job = (Job *) Lst_Datum(ln); 2757 2840 2758 2841 if (job->flags & JOB_RESTART) { 2759 DEBUGF(JOB, "JobInterrupt skipping job on stopped queue" 2760 "-- it was waiting to be restarted.\n"); 2842 if (DEBUG(JOB)) { 2843 (void) fprintf(stdout, "%s%s", 2844 "JobInterrupt skipping job on stopped queue", 2845 "-- it was waiting to be restarted.\n"); 2846 (void) fflush(stdout); 2847 } 2761 2848 continue; 2762 2849 } … … 2772 2859 * Resume the thing so it will take the signal. 2773 2860 */ 2774 DEBUGF(JOB, ("JobInterrupt passing CONT to stopped child %d.\n", job->pid)); 2861 if (DEBUG(JOB)) { 2862 (void) fprintf(stdout, 2863 "JobInterrupt passing CONT to stopped child %d.\n", 2864 job->pid); 2865 (void) fflush(stdout); 2866 } 2775 2867 KILL(job->pid, SIGCONT); 2776 2868 #ifdef RMT_WANTS_SIGNALS … … 2790 2882 } 2791 2883 } else if (job->pid) { 2792 DEBUGF(JOB, "JobInterrupt passing interrupt to stopped child %d.\n", 2793 job->pid); 2884 if (DEBUG(JOB)) { 2885 (void) fprintf(stdout, 2886 "JobInterrupt passing interrupt to stopped child %d.\n", 2887 job->pid); 2888 (void) fflush(stdout); 2889 } 2794 2890 KILL(job->pid, SIGINT); 2795 2891 } … … 2801 2897 if (runINTERRUPT && !touchFlag) { 2802 2898 interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); 2803 if (interrupt != N ULL) {2899 if (interrupt != NILGNODE) { 2804 2900 ignoreErrors = FALSE; 2805 2901 … … 2817 2913 /* 2818 2914 *----------------------------------------------------------------------- 2819 * Job_ Finish--2915 * Job_End -- 2820 2916 * Do final processing such as the running of the commands 2821 2917 * attached to the .END target. … … 2826 2922 */ 2827 2923 int 2828 Job_ Finish(void)2829 { 2830 if (postCommands != N ULL&& !Lst_IsEmpty(postCommands->commands)) {2924 Job_End() 2925 { 2926 if (postCommands != NILGNODE && !Lst_IsEmpty(postCommands->commands)) { 2831 2927 if (errors) { 2832 2928 Error("Errors reported so .END ignored"); … … 2860 2956 */ 2861 2957 void 2862 Job_Wait( void)2958 Job_Wait() 2863 2959 { 2864 2960 aborting = ABORT_WAIT; … … 2887 2983 */ 2888 2984 void 2889 Job_AbortAll( void)2985 Job_AbortAll() 2890 2986 { 2891 2987 LstNode ln; /* element in job table */ … … 2898 2994 2899 2995 (void) Lst_Open(jobs); 2900 while ((ln = Lst_Next(jobs)) != N ULL) {2996 while ((ln = Lst_Next(jobs)) != NILLNODE) { 2901 2997 job = (Job *) Lst_Datum(ln); 2902 2998 … … 2932 3028 * JobFlagForMigration -- 2933 3029 * Handle the eviction of a child. Called from RmtStatusChange. 2934 * Flags the child as remigratable and then suspends it. Takes 2935 * the ID of the host we used, for matching children. 3030 * Flags the child as remigratable and then suspends it. 2936 3031 * 2937 3032 * Results: … … 2944 3039 */ 2945 3040 void 2946 JobFlagForMigration(int hostID) 2947 { 2948 Job *job; /* job descriptor for dead child */ 3041 JobFlagForMigration(hostID) 3042 int hostID; /* ID of host we used, for matching children. */ 3043 { 3044 register Job *job; /* job descriptor for dead child */ 2949 3045 LstNode jnode; /* list element for finding job */ 2950 3046 2951 DEBUGF(JOB, ("JobFlagForMigration(%d) called.\n", hostID)); 2952 jnode = Lst_Find(jobs, (void *)hostID, JobCmpRmtID); 2953 2954 if (jnode == NULL) { 2955 jnode = Lst_Find(stoppedJobs, (void *)hostID, JobCmpRmtID); 2956 if (jnode == NULL) { 3047 if (DEBUG(JOB)) { 3048 (void) fprintf(stdout, "JobFlagForMigration(%d) called.\n", hostID); 3049 (void) fflush(stdout); 3050 } 3051 jnode = Lst_Find(jobs, (ClientData)hostID, JobCmpRmtID); 3052 3053 if (jnode == NILLNODE) { 3054 jnode = Lst_Find(stoppedJobs, (ClientData)hostID, JobCmpRmtID); 3055 if (jnode == NILLNODE) { 2957 3056 if (DEBUG(JOB)) { 2958 3057 Error("Evicting host(%d) not in table", hostID); … … 2963 3062 job = (Job *) Lst_Datum(jnode); 2964 3063 2965 DEBUGF(JOB, ("JobFlagForMigration(%d) found job '%s'.\n", hostID, job->node->name)); 3064 if (DEBUG(JOB)) { 3065 (void) fprintf(stdout, 3066 "JobFlagForMigration(%d) found job '%s'.\n", hostID, 3067 job->node->name); 3068 (void) fflush(stdout); 3069 } 2966 3070 2967 3071 KILL(job->pid, SIGSTOP); … … 2989 3093 */ 2990 3094 static void 2991 JobRestartJobs( void)3095 JobRestartJobs() 2992 3096 { 2993 3097 while (!jobFull && !Lst_IsEmpty(stoppedJobs)) { 2994 DEBUGF(JOB, ("Job queue is not full. Restarting a stopped job.\n")); 3098 if (DEBUG(JOB)) { 3099 (void) fprintf(stdout, 3100 "Job queue is not full. Restarting a stopped job.\n"); 3101 (void) fflush(stdout); 3102 } 2995 3103 JobRestart((Job *)Lst_DeQueue(stoppedJobs)); 2996 3104 } -
branches/FREEBSD/src/kmk/job.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)job.h 8.1 (Berkeley) 6/6/9340 * $FreeBSD: src/usr.bin/make/job.h,v 1. 20 2002/10/09 01:56:02 jmallettExp $38 * from: @(#)job.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/job.h,v 1.11 2000/01/17 06:43:41 kris Exp $ 41 40 */ 42 41 … … 47 46 */ 48 47 #ifndef _JOB_H_ 49 #define _JOB_H_ 50 51 #define TMPPAT "/tmp/makeXXXXXXXXXX" 52 53 #ifndef USE_KQUEUE 48 #define _JOB_H_ 49 50 #define TMPPAT "/tmp/makeXXXXXXXXXX" 51 54 52 /* 55 53 * The SEL_ constants determine the maximum amount of time spent in select … … 57 55 * seconds and SEL_USEC is the number of micro-seconds 58 56 */ 59 #define SEL_SEC 0 60 #define SEL_USEC 100000 61 #endif /* !USE_KQUEUE */ 57 #define SEL_SEC 0 58 #define SEL_USEC 100000 62 59 63 60 … … 70 67 * 2) The graph node describing the target being made by this job 71 68 * 3) A LstNode for the first command to be saved after the job 72 * completes. This is N ULLif there was no "..." in the job's69 * completes. This is NILLNODE if there was no "..." in the job's 73 70 * commands. 74 71 * 4) An FILE* for writing out the commands. This is only … … 95 92 * traversal of the dependency graph. 96 93 */ 97 #define 94 #define JOB_BUFSIZE 1024 98 95 typedef struct Job { 99 96 int pid; /* The child's process ID */ … … 109 106 #define JOB_IGNERR 0x001 /* Ignore non-zero exits */ 110 107 #define JOB_SILENT 0x002 /* no output */ 111 #define 108 #define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally 112 109 * if we can't export it and maxLocal is 0 */ 113 #define 110 #define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing 114 111 * commands */ 115 #define 116 #define 117 #define 118 #define 119 #define 112 #define JOB_REMOTE 0x010 /* Job is running remotely */ 113 #define JOB_FIRST 0x020 /* Job is first job for the node */ 114 #define JOB_REMIGRATE 0x040 /* Job needs to be remigrated */ 115 #define JOB_RESTART 0x080 /* Job needs to be completely restarted */ 116 #define JOB_RESUME 0x100 /* Job needs to be resumed b/c it stopped, 120 117 * for some reason */ 121 #define 118 #define JOB_CONTINUING 0x200 /* We are in the process of resuming this job. 122 119 * Used to avoid infinite recursion between 123 120 * JobFinish and JobRestart */ … … 148 145 } Job; 149 146 150 #define 151 #define 152 #define 153 #define 154 #define 155 #define 147 #define outPipe output.o_pipe.op_outPipe 148 #define inPipe output.o_pipe.op_inPipe 149 #define outBuf output.o_pipe.op_outBuf 150 #define curPos output.o_pipe.op_curPos 151 #define outFile output.o_file.of_outFile 152 #define outFd output.o_file.of_outFd 156 153 157 154 … … 208 205 } Shell; 209 206 210 /* 211 * If REMOTE is defined then these things need exposed, otherwise they are 212 * static to job.c! 213 */ 214 #ifdef REMOTE 207 215 208 extern char *targFmt; /* Format string for banner that separates 216 209 * output from multiple jobs. Contains a … … 227 220 * quite get started */ 228 221 extern Boolean jobFull; /* Non-zero if no more jobs should/will start*/ 229 #endif 230 231 extern int maxJobs; /* Number of jobs that may run */ 232 233 234 void Job_Touch(GNode *, Boolean); 235 Boolean Job_CheckCommands(GNode *, void (*abortProc)(const char *, ...)); 236 void Job_CatchChildren(Boolean); 237 void Job_CatchOutput(void); 238 void Job_Make(GNode *); 239 void Job_Init(int, int); 240 Boolean Job_Full(void); 241 Boolean Job_Empty(void); 242 ReturnStatus Job_ParseShell(char *); 243 int Job_Finish(void); 244 void Job_Wait(void); 245 void Job_AbortAll(void); 246 void JobFlagForMigration(int); 222 223 224 void Job_Touch __P((GNode *, Boolean)); 225 Boolean Job_CheckCommands __P((GNode *, void (*abortProc )(char *, ...))); 226 void Job_CatchChildren __P((Boolean)); 227 void Job_CatchOutput __P((void)); 228 void Job_Make __P((GNode *)); 229 void Job_Init __P((int, int)); 230 Boolean Job_Full __P((void)); 231 Boolean Job_Empty __P((void)); 232 ReturnStatus Job_ParseShell __P((char *)); 233 int Job_End __P((void)); 234 void Job_Wait __P((void)); 235 void Job_AbortAll __P((void)); 236 void JobFlagForMigration __P((int)); 247 237 248 238 #endif /* _JOB_H_ */ -
branches/FREEBSD/src/kmk/list.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)list.h 8.2 (Berkeley) 4/28/9540 * $FreeBSD: src/usr.bin/make/list.h,v 1. 11 2002/09/17 21:29:06 jmallettExp $38 * from: @(#)list.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/list.h,v 1.8 1999/08/28 01:03:32 peter Exp $ 41 40 */ 42 41 … … 48 47 49 48 #ifndef _LIST 50 #define 49 #define _LIST 51 50 52 51 #ifndef _SPRITE … … 131 130 * ---------------------------------------------------------------------------- 132 131 */ 133 #define 134 (elementPtr)->prevPtr = (List_Links *) N ULL; \135 (elementPtr)->nextPtr = (List_Links *) N ULL;132 #define List_InitElement(elementPtr) \ 133 (elementPtr)->prevPtr = (List_Links *) NIL; \ 134 (elementPtr)->nextPtr = (List_Links *) NIL; 136 135 137 136 /* … … 163 162 */ 164 163 165 #define 164 #define LIST_FORALL(headerPtr, itemPtr) \ 166 165 for (itemPtr = List_First(headerPtr); \ 167 166 !List_IsAtEnd((headerPtr),itemPtr); \ … … 181 180 */ 182 181 183 #define 182 #define List_IsEmpty(headerPtr) \ 184 183 ((headerPtr) == (headerPtr)->nextPtr) 185 184 … … 198 197 199 198 200 #define 199 #define List_IsAtEnd(headerPtr, itemPtr) \ 201 200 ((itemPtr) == (headerPtr)) 202 201 … … 216 215 */ 217 216 218 #define 217 #define List_First(headerPtr) ((headerPtr)->nextPtr) 219 218 220 219 /* … … 231 230 */ 232 231 233 #define 232 #define List_Last(headerPtr) ((headerPtr)->prevPtr) 234 233 235 234 /* … … 247 246 */ 248 247 249 #define 248 #define List_Prev(itemPtr) ((itemPtr)->prevPtr) 250 249 251 250 /* … … 263 262 */ 264 263 265 #define 264 #define List_Next(itemPtr) ((itemPtr)->nextPtr) 266 265 267 266 … … 294 293 */ 295 294 296 #define 297 298 #define 299 300 #define 301 302 #define 295 #define LIST_AFTER(itemPtr) ((List_Links *) itemPtr) 296 297 #define LIST_BEFORE(itemPtr) (((List_Links *) itemPtr)->prevPtr) 298 299 #define LIST_ATFRONT(headerPtr) ((List_Links *) headerPtr) 300 301 #define LIST_ATREAR(headerPtr) (((List_Links *) headerPtr)->prevPtr) 303 302 304 303 #endif /* _LIST */ -
branches/FREEBSD/src/kmk/lst.h
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 … … 37 36 * SUCH DAMAGE. 38 37 * 39 * @(#)lst.h 8.2 (Berkeley) 4/28/9540 * $FreeBSD: src/usr.bin/make/lst.h,v 1. 15 2002/09/17 21:29:06 jmallettExp $38 * from: @(#)lst.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/lst.h,v 1.9 1999/08/28 01:03:32 peter Exp $ 41 40 */ 42 41 … … 46 45 */ 47 46 #ifndef _LST_H_ 48 #define 47 #define _LST_H_ 49 48 50 49 #include <sys/param.h> 50 #ifdef __STDC__ 51 51 #include <stdlib.h> 52 #endif 52 53 #include "sprite.h" 53 54 … … 59 60 typedef struct LstNode *LstNode; 60 61 62 #define NILLST ((Lst) NIL) 63 #define NILLNODE ((LstNode) NIL) 64 61 65 /* 62 66 * NOFREE can be used as the freeProc to Lst_Destroy when the elements are … … 64 68 * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate. 65 69 */ 66 #define NOFREE ((void (*)(void *)) 0)67 #define NOCOPY ((void * (*)(void *)) 0)70 #define NOFREE ((void (*) __P((ClientData))) 0) 71 #define NOCOPY ((ClientData (*) __P((ClientData))) 0) 68 72 69 #define 70 #define 73 #define LST_CONCNEW 0 /* create new LstNode's when using Lst_Concat */ 74 #define LST_CONCLINK 1 /* relink LstNode's when using Lst_Concat */ 71 75 72 76 /* … … 74 78 */ 75 79 /* Create a new list */ 76 Lst Lst_Init (Boolean);80 Lst Lst_Init __P((Boolean)); 77 81 /* Duplicate an existing list */ 78 Lst Lst_Duplicate (Lst, void * (*)(void *));82 Lst Lst_Duplicate __P((Lst, ClientData (*)(ClientData))); 79 83 /* Destroy an old one */ 80 void Lst_Destroy (Lst, void (*)(void *));84 void Lst_Destroy __P((Lst, void (*)(ClientData))); 81 85 /* True if list is empty */ 82 Boolean Lst_IsEmpty (Lst);86 Boolean Lst_IsEmpty __P((Lst)); 83 87 84 88 /* … … 86 90 */ 87 91 /* Insert an element before another */ 88 ReturnStatus Lst_Insert (Lst, LstNode, void *);92 ReturnStatus Lst_Insert __P((Lst, LstNode, ClientData)); 89 93 /* Insert an element after another */ 90 ReturnStatus Lst_Append (Lst, LstNode, void *);94 ReturnStatus Lst_Append __P((Lst, LstNode, ClientData)); 91 95 /* Place an element at the front of a lst. */ 92 ReturnStatus Lst_AtFront (Lst, void *);96 ReturnStatus Lst_AtFront __P((Lst, ClientData)); 93 97 /* Place an element at the end of a lst. */ 94 ReturnStatus Lst_AtEnd (Lst, void *);98 ReturnStatus Lst_AtEnd __P((Lst, ClientData)); 95 99 /* Remove an element */ 96 ReturnStatus Lst_Remove (Lst, LstNode);100 ReturnStatus Lst_Remove __P((Lst, LstNode)); 97 101 /* Replace a node with a new value */ 98 ReturnStatus Lst_Replace (LstNode, void *);102 ReturnStatus Lst_Replace __P((LstNode, ClientData)); 99 103 /* Concatenate two lists */ 100 ReturnStatus Lst_Concat (Lst, Lst, int);104 ReturnStatus Lst_Concat __P((Lst, Lst, int)); 101 105 102 106 /* … … 104 108 */ 105 109 /* Return first element in list */ 106 LstNode Lst_First (Lst);110 LstNode Lst_First __P((Lst)); 107 111 /* Return last element in list */ 108 LstNode Lst_Last (Lst);112 LstNode Lst_Last __P((Lst)); 109 113 /* Return successor to given element */ 110 LstNode Lst_Succ (LstNode);114 LstNode Lst_Succ __P((LstNode)); 111 115 /* Get datum from LstNode */ 112 void * Lst_Datum(LstNode);116 ClientData Lst_Datum __P((LstNode)); 113 117 114 118 /* … … 116 120 */ 117 121 /* Find an element in a list */ 118 LstNode Lst_Find(Lst, void *, int (*)(void *, void *)); 122 LstNode Lst_Find __P((Lst, ClientData, 123 int (*)(ClientData, ClientData))); 119 124 /* Find an element starting from somewhere */ 120 LstNode Lst_FindFrom(Lst, LstNode, void *, int (*cProc)(void *, void *)); 125 LstNode Lst_FindFrom __P((Lst, LstNode, ClientData, 126 int (*cProc)(ClientData, ClientData))); 121 127 /* 122 128 * See if the given datum is on the list. Returns the LstNode containing 123 129 * the datum 124 130 */ 125 LstNode Lst_Member (Lst, void *);131 LstNode Lst_Member __P((Lst, ClientData)); 126 132 /* Apply a function to all elements of a lst */ 127 void Lst_ForEach(Lst, int (*)(void *, void *), void *); 133 void Lst_ForEach __P((Lst, int (*)(ClientData, ClientData), 134 ClientData)); 128 135 /* 129 136 * Apply a function to all elements of a lst starting from a certain point. … … 131 138 * beginning of the list again. 132 139 */ 133 void Lst_ForEachFrom(Lst, LstNode, int (*)(void *, void *), void *); 140 void Lst_ForEachFrom __P((Lst, LstNode, 141 int (*)(ClientData, ClientData), 142 ClientData)); 134 143 /* 135 144 * these functions are for dealing with a list as a table, of sorts. … … 138 147 */ 139 148 /* Open the list */ 140 ReturnStatus Lst_Open (Lst);149 ReturnStatus Lst_Open __P((Lst)); 141 150 /* Next element please */ 142 LstNode Lst_Next (Lst);151 LstNode Lst_Next __P((Lst)); 143 152 /* Done yet? */ 144 Boolean Lst_IsAtEnd (Lst);153 Boolean Lst_IsAtEnd __P((Lst)); 145 154 /* Finish table access */ 146 void Lst_Close (Lst);155 void Lst_Close __P((Lst)); 147 156 148 157 /* … … 150 159 */ 151 160 /* Place an element at tail of queue */ 152 ReturnStatus Lst_EnQueue (Lst, void *);161 ReturnStatus Lst_EnQueue __P((Lst, ClientData)); 153 162 /* Remove an element from head of queue */ 154 void * Lst_DeQueue(Lst);163 ClientData Lst_DeQueue __P((Lst)); 155 164 156 165 #endif /* _LST_H_ */ -
branches/FREEBSD/src/kmk/lst.lib/lstAppend.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstAppend.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstAppend.c,v 1.6 1999/08/28 01:03:45 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstAppend.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 61 60 * field of the List will be altered if ln is the last node in the 62 61 * list. lastPtr and firstPtr will alter if the list was empty and 63 * ln was N ULL.62 * ln was NILLNODE. 64 63 * 65 64 *----------------------------------------------------------------------- … … 69 68 Lst l; /* affected list */ 70 69 LstNode ln; /* node after which to append the datum */ 71 void *d; /* said datum */70 ClientData d; /* said datum */ 72 71 { 73 72 register List list; … … 75 74 register ListNode nLNode; 76 75 77 if (LstValid (l) && (ln == N ULL&& LstIsEmpty (l))) {76 if (LstValid (l) && (ln == NILLNODE && LstIsEmpty (l))) { 78 77 goto ok; 79 78 } … … 91 90 nLNode->useCount = nLNode->flags = 0; 92 91 93 if (lNode == N ULL) {92 if (lNode == NilListNode) { 94 93 if (list->isCirc) { 95 94 nLNode->nextPtr = nLNode->prevPtr = nLNode; 96 95 } else { 97 nLNode->nextPtr = nLNode->prevPtr = N ULL;96 nLNode->nextPtr = nLNode->prevPtr = NilListNode; 98 97 } 99 98 list->firstPtr = list->lastPtr = nLNode; … … 103 102 104 103 lNode->nextPtr = nLNode; 105 if (nLNode->nextPtr != N ULL) {104 if (nLNode->nextPtr != NilListNode) { 106 105 nLNode->nextPtr->prevPtr = nLNode; 107 106 } -
branches/FREEBSD/src/kmk/lst.lib/lstAtEnd.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstAtEnd.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstAtEnd.c,v 1.6 1999/08/28 01:03:46 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstAtEnd.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 65 64 Lst_AtEnd (l, d) 66 65 Lst l; /* List to which to add the datum */ 67 void *d; /* Datum to add */66 ClientData d; /* Datum to add */ 68 67 { 69 68 register LstNode end; -
branches/FREEBSD/src/kmk/lst.lib/lstAtFront.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstAtFront.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstAtFront.c,v 1.6 1999/08/28 01:03:47 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstAtFront.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 66 65 Lst_AtFront (l, d) 67 66 Lst l; 68 void *d;67 ClientData d; 69 68 { 70 69 register LstNode front; -
branches/FREEBSD/src/kmk/lst.lib/lstClose.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstClose.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstClose.c,v 1.6 1999/08/28 01:03:47 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstClose.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 -
branches/FREEBSD/src/kmk/lst.lib/lstConcat.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstConcat.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstConcat.c,v 1.7 1999/08/28 01:03:47 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstConcat.c,v 1.11 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 85 84 86 85 if (flags == LST_CONCLINK) { 87 if (list2->firstPtr != N ULL) {86 if (list2->firstPtr != NilListNode) { 88 87 /* 89 88 * We set the nextPtr of the 90 * last element of list two to be N ULL to make the loop easier and89 * last element of list two to be NIL to make the loop easier and 91 90 * so we don't need an extra case should the first list turn 92 91 * out to be non-circular -- the final element will already point 93 * to N ULL space and the first element will be untouched if it94 * existed before and will also point to N ULL space if it didn't.92 * to NIL space and the first element will be untouched if it 93 * existed before and will also point to NIL space if it didn't. 95 94 */ 96 list2->lastPtr->nextPtr = N ULL;95 list2->lastPtr->nextPtr = NilListNode; 97 96 /* 98 97 * So long as the second list isn't empty, we just link the … … 104 103 */ 105 104 list2->firstPtr->prevPtr = list1->lastPtr; 106 if (list1->lastPtr != N ULL) {105 if (list1->lastPtr != NilListNode) { 107 106 list1->lastPtr->nextPtr = list2->firstPtr; 108 107 } else { … … 111 110 list1->lastPtr = list2->lastPtr; 112 111 } 113 if (list1->isCirc && list1->firstPtr != N ULL) {112 if (list1->isCirc && list1->firstPtr != NilListNode) { 114 113 /* 115 114 * If the first list is supposed to be circular and it is (now) … … 120 119 list1->lastPtr->nextPtr = list1->firstPtr; 121 120 } 122 free ( l2);123 } else if (list2->firstPtr != N ULL) {121 free ((Address)l2); 122 } else if (list2->firstPtr != NilListNode) { 124 123 /* 125 * We set the nextPtr of the last element of list 2 to be NULLto make124 * We set the nextPtr of the last element of list 2 to be nil to make 126 125 * the loop less difficult. The loop simply goes through the entire 127 126 * second list creating new LstNodes and filling in the nextPtr, and … … 130 129 * follows the last of the new nodes along until the entire l2 has 131 130 * been appended. Only then does the bookkeeping catch up with the 132 * changes. During the first iteration of the loop, if 'last' is NULL,131 * changes. During the first iteration of the loop, if 'last' is nil, 133 132 * the first list must have been empty so the newly-created node is 134 133 * made the first node of the list. 135 134 */ 136 list2->lastPtr->nextPtr = N ULL;135 list2->lastPtr->nextPtr = NilListNode; 137 136 for (last = list1->lastPtr, ln = list2->firstPtr; 138 ln != N ULL;137 ln != NilListNode; 139 138 ln = ln->nextPtr) 140 139 { 141 140 PAlloc (nln, ListNode); 142 141 nln->datum = ln->datum; 143 if (last != N ULL) {142 if (last != NilListNode) { 144 143 last->nextPtr = nln; 145 144 } else { … … 167 166 list1->firstPtr->prevPtr = list1->lastPtr; 168 167 } else { 169 last->nextPtr = N ULL;168 last->nextPtr = NilListNode; 170 169 } 171 170 -
branches/FREEBSD/src/kmk/lst.lib/lstDatum.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstDatum.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstDatum.c,v 1.5 1999/08/28 01:03:48 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDatum.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 55 54 * 56 55 * Results: 57 * The datum or (ick!) N ULL if the node is invalid.56 * The datum or (ick!) NIL if the node is invalid. 58 57 * 59 58 * Side Effects: … … 62 61 *----------------------------------------------------------------------- 63 62 */ 64 void * 63 ClientData 65 64 Lst_Datum (ln) 66 65 LstNode ln; 67 66 { 68 if (ln != N ULL) {67 if (ln != NILLNODE) { 69 68 return (((ListNode)ln)->datum); 70 69 } else { 71 return (( void *) NULL);70 return ((ClientData) NIL); 72 71 } 73 72 } -
branches/FREEBSD/src/kmk/lst.lib/lstDeQueue.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstDeQueue.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstDeQueue.c,v 1.6 1999/08/28 01:03:48 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDeQueue.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 55 54 * 56 55 * Results: 57 * The datum in the node at the head or (ick) N ULL if the list56 * The datum in the node at the head or (ick) NIL if the list 58 57 * is empty. 59 58 * … … 63 62 *----------------------------------------------------------------------- 64 63 */ 65 void * 64 ClientData 66 65 Lst_DeQueue (l) 67 66 Lst l; 68 67 { 69 void *rd;68 ClientData rd; 70 69 register ListNode tln; 71 70 72 71 tln = (ListNode) Lst_First (l); 73 if (tln == N ULL) {74 return (( void *) NULL);72 if (tln == NilListNode) { 73 return ((ClientData) NIL); 75 74 } 76 75 77 76 rd = tln->datum; 78 77 if (Lst_Remove (l, (LstNode)tln) == FAILURE) { 79 return (( void *) NULL);78 return ((ClientData) NIL); 80 79 } else { 81 80 return (rd); -
branches/FREEBSD/src/kmk/lst.lib/lstDestroy.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstDestroy.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstDestroy.c,v 1.7 1999/08/28 01:03:49 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDestroy.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 67 66 Lst_Destroy (l, freeProc) 68 67 Lst l; 69 register void (*freeProc) (void *);68 register void (*freeProc) __P((ClientData)); 70 69 { 71 70 register ListNode ln; 72 register ListNode tln = N ULL;71 register ListNode tln = NilListNode; 73 72 register List list = (List)l; 74 73 75 if (l == N ULL|| ! l) {74 if (l == NILLST || ! l) { 76 75 /* 77 76 * Note the check for l == (Lst)0 to catch uninitialized static Lst's. … … 82 81 83 82 /* To ease scanning */ 84 if (list->lastPtr != N ULL)85 list->lastPtr->nextPtr = N ULL;83 if (list->lastPtr != NilListNode) 84 list->lastPtr->nextPtr = NilListNode; 86 85 else { 87 free ( l);86 free ((Address)l); 88 87 return; 89 88 } 90 89 91 90 if (freeProc) { 92 for (ln = list->firstPtr; ln != N ULL; ln = tln) {91 for (ln = list->firstPtr; ln != NilListNode; ln = tln) { 93 92 tln = ln->nextPtr; 94 93 (*freeProc) (ln->datum); 95 free ( ln);94 free ((Address)ln); 96 95 } 97 96 } else { 98 for (ln = list->firstPtr; ln != N ULL; ln = tln) {97 for (ln = list->firstPtr; ln != NilListNode; ln = tln) { 99 98 tln = ln->nextPtr; 100 free ( ln);99 free ((Address)ln); 101 100 } 102 101 } 103 102 104 free ( l);103 free ((Address)l); 105 104 } -
branches/FREEBSD/src/kmk/lst.lib/lstDupl.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstDupl.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstDupl.c,v 1.7 1999/08/28 01:03:49 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDupl.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 53 52 *----------------------------------------------------------------------- 54 53 * Lst_Duplicate -- 55 * Duplicate an entire list. If a function to copy a void *is54 * Duplicate an entire list. If a function to copy a ClientData is 56 55 * given, the individual client elements will be duplicated as well. 57 56 * 58 57 * Results: 59 * The new Lst structure or N ULLif failure.58 * The new Lst structure or NILLST if failure. 60 59 * 61 60 * Side Effects: … … 66 65 Lst_Duplicate (l, copyProc) 67 66 Lst l; /* the list to duplicate */ 68 /* A function to duplicate each void **/69 void * (*copyProc)(void *);67 /* A function to duplicate each ClientData */ 68 ClientData (*copyProc) __P((ClientData)); 70 69 { 71 70 register Lst nl; … … 74 73 75 74 if (!LstValid (l)) { 76 return (N ULL);75 return (NILLST); 77 76 } 78 77 79 78 nl = Lst_Init (list->isCirc); 80 if (nl == N ULL) {81 return (N ULL);79 if (nl == NILLST) { 80 return (NILLST); 82 81 } 83 82 84 83 ln = list->firstPtr; 85 while (ln != N ULL) {84 while (ln != NilListNode) { 86 85 if (copyProc != NOCOPY) { 87 86 if (Lst_AtEnd (nl, (*copyProc) (ln->datum)) == FAILURE) { 88 return (N ULL);87 return (NILLST); 89 88 } 90 89 } else if (Lst_AtEnd (nl, ln->datum) == FAILURE) { 91 return (N ULL);90 return (NILLST); 92 91 } 93 92 94 93 if (list->isCirc && ln == list->lastPtr) { 95 ln = N ULL;94 ln = NilListNode; 96 95 } else { 97 96 ln = ln->nextPtr; -
branches/FREEBSD/src/kmk/lst.lib/lstEnQueue.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstEnQueue.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstEnQueue.c,v 1.6 1999/08/28 01:03:50 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstEnQueue.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 66 65 Lst_EnQueue (l, d) 67 66 Lst l; 68 void *d;67 ClientData d; 69 68 { 70 69 if (LstValid (l) == FALSE) { -
branches/FREEBSD/src/kmk/lst.lib/lstFind.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstFind.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstFind.c,v 1.6 1999/08/28 01:03:50 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstFind.c,v 1.11 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 56 55 * 57 56 * Results: 58 * The found node or N ULLif none matches.57 * The found node or NILLNODE if none matches. 59 58 * 60 59 * Side Effects: … … 66 65 Lst_Find (l, d, cProc) 67 66 Lst l; 68 void *d;69 int (*cProc) (void *, void *);67 ClientData d; 68 int (*cProc) __P((ClientData, ClientData)); 70 69 { 71 70 return (Lst_FindFrom (l, Lst_First(l), d, cProc)); -
branches/FREEBSD/src/kmk/lst.lib/lstFindFrom.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstFindFrom.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstFindFrom.c,v 1.7 1999/08/28 01:03:50 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstFindFrom.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 57 56 * 58 57 * Results: 59 * The found node or N ULL58 * The found node or NILLNODE 60 59 * 61 60 * Side Effects: … … 68 67 Lst l; 69 68 register LstNode ln; 70 register void *d;71 register int (*cProc) (void *, void *);69 register ClientData d; 70 register int (*cProc) __P((ClientData, ClientData)); 72 71 { 73 72 register ListNode tln; … … 75 74 76 75 if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) { 77 return (N ULL);76 return (NILLNODE); 78 77 } 79 78 … … 87 86 tln = tln->nextPtr; 88 87 } 89 } while (tln != (ListNode)ln && tln != N ULL);88 } while (tln != (ListNode)ln && tln != NilListNode); 90 89 91 90 if (found) { 92 91 return ((LstNode)tln); 93 92 } else { 94 return (N ULL);93 return (NILLNODE); 95 94 } 96 95 } -
branches/FREEBSD/src/kmk/lst.lib/lstFirst.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstFirst.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstFirst.c,v 1.5 1999/08/28 01:03:51 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstFirst.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 55 54 * 56 55 * Results: 57 * The first node or N ULLif the list is empty.56 * The first node or NILLNODE if the list is empty. 58 57 * 59 58 * Side Effects: … … 67 66 { 68 67 if (!LstValid (l) || LstIsEmpty (l)) { 69 return (N ULL);68 return (NILLNODE); 70 69 } else { 71 70 return ((LstNode)((List)l)->firstPtr); -
branches/FREEBSD/src/kmk/lst.lib/lstForEach.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstForEach.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstForEach.c,v 1.6 1999/08/28 01:03:51 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstForEach.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 68 67 Lst_ForEach (l, proc, d) 69 68 Lst l; 70 register int (*proc) (void *, void *);71 register void *d;69 register int (*proc) __P((ClientData, ClientData)); 70 register ClientData d; 72 71 { 73 72 Lst_ForEachFrom(l, Lst_First(l), proc, d); -
branches/FREEBSD/src/kmk/lst.lib/lstForEachFrom.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstForEachFrom.c,v 1.7 1999/08/28 01:03:52 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstForEachFrom.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 70 69 Lst l; 71 70 LstNode ln; 72 register int (*proc) (void *, void *);73 register void *d;71 register int (*proc) __P((ClientData, ClientData)); 72 register ClientData d; 74 73 { 75 74 register ListNode tln = (ListNode)ln; … … 102 101 */ 103 102 done = (next == tln->nextPtr && 104 (next == N ULL|| next == list->firstPtr));103 (next == NilListNode || next == list->firstPtr)); 105 104 106 105 next = tln->nextPtr; -
branches/FREEBSD/src/kmk/lst.lib/lstInit.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstInit.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstInit.c,v 1.6 1999/08/28 01:03:52 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstInit.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 70 69 PAlloc (nList, List); 71 70 72 nList->firstPtr = N ULL;73 nList->lastPtr = N ULL;71 nList->firstPtr = NilListNode; 72 nList->lastPtr = NilListNode; 74 73 nList->isOpen = FALSE; 75 74 nList->isCirc = circ; -
branches/FREEBSD/src/kmk/lst.lib/lstInsert.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstInsert.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstInsert.c,v 1.6 1999/08/28 01:03:52 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstInsert.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 68 67 Lst l; /* list to manipulate */ 69 68 LstNode ln; /* node before which to insert d */ 70 void *d; /* datum to be inserted */69 ClientData d; /* datum to be inserted */ 71 70 { 72 71 register ListNode nLNode; /* new lnode for d */ … … 78 77 * check validity of arguments 79 78 */ 80 if (LstValid (l) && (LstIsEmpty (l) && ln == N ULL))79 if (LstValid (l) && (LstIsEmpty (l) && ln == NILLNODE)) 81 80 goto ok; 82 81 … … 91 90 nLNode->useCount = nLNode->flags = 0; 92 91 93 if (ln == N ULL) {92 if (ln == NILLNODE) { 94 93 if (list->isCirc) { 95 94 nLNode->prevPtr = nLNode->nextPtr = nLNode; 96 95 } else { 97 nLNode->prevPtr = nLNode->nextPtr = N ULL;96 nLNode->prevPtr = nLNode->nextPtr = NilListNode; 98 97 } 99 98 list->firstPtr = list->lastPtr = nLNode; … … 102 101 nLNode->nextPtr = lNode; 103 102 104 if (nLNode->prevPtr != N ULL) {103 if (nLNode->prevPtr != NilListNode) { 105 104 nLNode->prevPtr->nextPtr = nLNode; 106 105 } -
branches/FREEBSD/src/kmk/lst.lib/lstInt.h
r9 r24 35 35 * 36 36 * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93 37 * $FreeBSD: src/usr.bin/make/lst.lib/lstInt.h,v 1. 10 2002/07/15 06:57:25 jmallettExp $37 * $FreeBSD: src/usr.bin/make/lst.lib/lstInt.h,v 1.7 1999/08/28 01:03:53 peter Exp $ 38 38 */ 39 39 … … 51 51 struct ListNode *prevPtr; /* previous element in list */ 52 52 struct ListNode *nextPtr; /* next in list */ 53 int useCount:8, /* Count of functions using the node.53 short useCount:8, /* Count of functions using the node. 54 54 * node may not be deleted until count 55 55 * goes to 0 */ 56 56 flags:8; /* Node status flags */ 57 void *datum; /* datum associated with this element */57 ClientData datum; /* datum associated with this element */ 58 58 } *ListNode; 59 59 /* … … 61 61 */ 62 62 #define LN_DELETED 0x0001 /* List node should be removed when done */ 63 64 #define NilListNode ((ListNode)-1) 63 65 64 66 typedef enum { … … 76 78 Where atEnd; /* Where in the list the last access was */ 77 79 Boolean isOpen; /* true if list has been Lst_Open'ed */ 78 ListNode curPtr; /* current node, if open. N ULLif80 ListNode curPtr; /* current node, if open. NilListNode if 79 81 * *just* opened */ 80 82 ListNode prevPtr; /* Previous node, if open. Used by 81 83 * Lst_Remove */ 82 84 } *List; 85 86 #define NilList ((List)-1) 83 87 84 88 /* … … 92 96 * Return TRUE if the list l is valid 93 97 */ 94 #define LstValid(l) (((Lst)l == N ULL) ? FALSE : TRUE)98 #define LstValid(l) (((Lst)l == NILLST) ? FALSE : TRUE) 95 99 96 100 /* … … 98 102 * Return TRUE if the LstNode ln is valid with respect to l 99 103 */ 100 #define LstNodeValid(ln, l) ((((LstNode)ln) == N ULL) ? FALSE : TRUE)104 #define LstNodeValid(ln, l) ((((LstNode)ln) == NILLNODE) ? FALSE : TRUE) 101 105 102 106 /* … … 104 108 * TRUE if the list l is empty. 105 109 */ 106 #define LstIsEmpty(l) (((List)l)->firstPtr == N ULL)110 #define LstIsEmpty(l) (((List)l)->firstPtr == NilListNode) 107 111 108 112 #endif /* _LSTINT_H_ */ -
branches/FREEBSD/src/kmk/lst.lib/lstIsAtEnd.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstIsAtEnd.c,v 1.5 1999/08/28 01:03:53 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstIsAtEnd.c,v 1.7 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 -
branches/FREEBSD/src/kmk/lst.lib/lstIsEmpty.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstIsEmpty.c,v 1.5 1999/08/28 01:03:54 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstIsEmpty.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 60 59 * None. 61 60 * 62 * A list is considered empty if its firstPtr == N ULL(or if63 * the list itself is N ULLLIST).61 * A list is considered empty if its firstPtr == NilListNode (or if 62 * the list itself is NILLIST). 64 63 *----------------------------------------------------------------------- 65 64 */ -
branches/FREEBSD/src/kmk/lst.lib/lstLast.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstLast.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstLast.c,v 1.5 1999/08/28 01:03:55 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstLast.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 55 54 * 56 55 * Results: 57 * The requested node or N ULLif the list is empty.56 * The requested node or NILLNODE if the list is empty. 58 57 * 59 58 * Side Effects: … … 67 66 { 68 67 if (!LstValid(l) || LstIsEmpty (l)) { 69 return (N ULL);68 return (NILLNODE); 70 69 } else { 71 70 return ((LstNode)((List)l)->lastPtr); -
branches/FREEBSD/src/kmk/lst.lib/lstMember.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstMember.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstMember.c,v 1.6 1999/08/28 01:03:55 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstMember.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 52 51 Lst_Member (l, d) 53 52 Lst l; 54 void *d;53 ClientData d; 55 54 { 56 55 List list = (List) l; … … 58 57 59 58 lNode = list->firstPtr; 60 if (lNode == N ULL) {61 return N ULL;59 if (lNode == NilListNode) { 60 return NILLNODE; 62 61 } 63 62 … … 67 66 } 68 67 lNode = lNode->nextPtr; 69 } while (lNode != N ULL&& lNode != list->firstPtr);68 } while (lNode != NilListNode && lNode != list->firstPtr); 70 69 71 return N ULL;70 return NILLNODE; 72 71 } -
branches/FREEBSD/src/kmk/lst.lib/lstNext.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstNext.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstNext.c,v 1.6 1999/08/28 01:03:55 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstNext.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 60 59 * 61 60 * Results: 62 * The next node or N ULLif the list has yet to be opened. Also63 * if the list is non-circular and the end has been reached, N ULL61 * The next node or NILLNODE if the list has yet to be opened. Also 62 * if the list is non-circular and the end has been reached, NILLNODE 64 63 * is returned. 65 64 * … … 78 77 if ((LstValid (l) == FALSE) || 79 78 (list->isOpen == FALSE)) { 80 return (N ULL);79 return (NILLNODE); 81 80 } 82 81 83 82 list->prevPtr = list->curPtr; 84 83 85 if (list->curPtr == N ULL) {84 if (list->curPtr == NilListNode) { 86 85 if (list->atEnd == Unknown) { 87 86 /* … … 93 92 list->atEnd = Middle; 94 93 } else { 95 tln = N ULL;94 tln = NilListNode; 96 95 list->atEnd = Tail; 97 96 } … … 100 99 list->curPtr = tln; 101 100 102 if (tln == list->firstPtr || tln == N ULL) {101 if (tln == list->firstPtr || tln == NilListNode) { 103 102 /* 104 103 * If back at the front, then we've hit the end... -
branches/FREEBSD/src/kmk/lst.lib/lstOpen.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstOpen.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstOpen.c,v 1.5 1999/08/28 01:03:56 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstOpen.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 63 62 * 64 63 * Side Effects: 65 * isOpen is set TRUE and curPtr is set to N ULLso the64 * isOpen is set TRUE and curPtr is set to NilListNode so the 66 65 * other sequential functions no it was just opened and can choose 67 66 * the first element accessed based on this. … … 78 77 ((List) l)->isOpen = TRUE; 79 78 ((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown; 80 ((List) l)->curPtr = N ULL;79 ((List) l)->curPtr = NilListNode; 81 80 82 81 return (SUCCESS); -
branches/FREEBSD/src/kmk/lst.lib/lstRemove.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstRemove.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstRemove.c,v 1.6 1999/08/28 01:03:56 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstRemove.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 58 57 * 59 58 * Side Effects: 60 * The list's firstPtr will be set to N ULLif ln is the last59 * The list's firstPtr will be set to NilListNode if ln is the last 61 60 * node on the list. firsPtr and lastPtr will be altered if ln is 62 61 * either the first or last node, respectively, on the list. … … 80 79 * unlink it from the list 81 80 */ 82 if (lNode->nextPtr != N ULL) {81 if (lNode->nextPtr != NilListNode) { 83 82 lNode->nextPtr->prevPtr = lNode->prevPtr; 84 83 } 85 if (lNode->prevPtr != N ULL) {84 if (lNode->prevPtr != NilListNode) { 86 85 lNode->prevPtr->nextPtr = lNode->nextPtr; 87 86 } … … 101 100 * Sequential access stuff. If the node we're removing is the current 102 101 * node in the list, reset the current node to the previous one. If the 103 * previous one was non-existent (prevPtr == N ULL), we set the102 * previous one was non-existent (prevPtr == NilListNode), we set the 104 103 * end to be Unknown, since it is. 105 104 */ 106 105 if (list->isOpen && (list->curPtr == lNode)) { 107 106 list->curPtr = list->prevPtr; 108 if (list->curPtr == N ULL) {107 if (list->curPtr == NilListNode) { 109 108 list->atEnd = Unknown; 110 109 } … … 117 116 */ 118 117 if (list->firstPtr == lNode) { 119 list->firstPtr = N ULL;118 list->firstPtr = NilListNode; 120 119 } 121 120 … … 125 124 */ 126 125 if (lNode->useCount == 0) { 127 free ( ln);126 free ((Address)ln); 128 127 } else { 129 128 lNode->flags |= LN_DELETED; -
branches/FREEBSD/src/kmk/lst.lib/lstReplace.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstReplace.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstReplace.c,v 1.5 1999/08/28 01:03:56 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstReplace.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 65 64 Lst_Replace (ln, d) 66 65 register LstNode ln; 67 void *d;66 ClientData d; 68 67 { 69 if (ln == N ULL) {68 if (ln == NILLNODE) { 70 69 return (FAILURE); 71 70 } else { -
branches/FREEBSD/src/kmk/lst.lib/lstSucc.c
r9 r24 34 34 * SUCH DAMAGE. 35 35 * 36 * @(#)lstSucc.c 8.1 (Berkeley) 6/6/9336 * $FreeBSD: src/usr.bin/make/lst.lib/lstSucc.c,v 1.5 1999/08/28 01:03:57 peter Exp $ 37 37 */ 38 38 39 39 #ifndef lint 40 #include <sys/cdefs.h> 41 __FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstSucc.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $"); 40 static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93"; 42 41 #endif /* not lint */ 43 42 … … 68 67 LstNode ln; 69 68 { 70 if (ln == N ULL) {71 return (N ULL);69 if (ln == NILLNODE) { 70 return (NILLNODE); 72 71 } else { 73 72 return ((LstNode) ((ListNode) ln)->nextPtr); -
branches/FREEBSD/src/kmk/main.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 * @(#)main.c 8.3 (Berkeley) 3/19/94 39 */ 37 */ 38 39 #ifndef lint 40 static const char copyright[] = 41 "@(#) Copyright (c) 1988, 1989, 1990, 1993\n\ 42 The Regents of the University of California. All rights reserved.\n"; 43 #endif /* not lint */ 40 44 41 45 #ifndef lint 42 46 #if 0 43 static char copyright[] = 44 "@(#) Copyright (c) 1988, 1989, 1990, 1993\n\ 45 The Regents of the University of California. All rights reserved.\n"; 47 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; 48 #else 49 static const char rcsid[] = 50 "$FreeBSD: src/usr.bin/make/main.c,v 1.35.2.6 2002/07/24 16:50:18 ru Exp $"; 46 51 #endif 47 52 #endif /* not lint */ 48 #include <sys/cdefs.h>49 __FBSDID("$FreeBSD: src/usr.bin/make/main.c,v 1.79 2002/10/10 19:27:48 jmallett Exp $");50 53 51 54 /*- … … 59 62 * invoked. Used by the parse module to implement 60 63 * the .MFLAGS target. 64 * 65 * Error Print a tagged error message. The global 66 * MAKE variable must have been defined. This 67 * takes a format string and two optional 68 * arguments for it. 69 * 70 * Fatal Print an error message and exit. Also takes 71 * a format string and two arguments. 72 * 73 * Punt Aborts all jobs and exits with a message. Also 74 * takes a format string and two arguments. 75 * 76 * Finish Finish things up by printing the number of 77 * errors which occured, as passed to it, and 78 * exiting. 61 79 */ 62 80 … … 80 98 #include <stdio.h> 81 99 #include <sysexits.h> 100 #ifdef __STDC__ 82 101 #include <stdarg.h> 83 #include <unistd.h> 102 #else 103 #include <varargs.h> 104 #endif 84 105 #include "make.h" 85 106 #include "hash.h" … … 88 109 #include "pathnames.h" 89 110 90 #define WANT_ENV_MKLVL 191 92 111 #ifndef DEFMAXLOCAL 93 112 #define DEFMAXLOCAL DEFMAXJOBS … … 103 122 static Boolean noBuiltins; /* -r flag */ 104 123 static Lst makefiles; /* ordered list of makefiles to read */ 124 static Boolean printVars; /* print value of one or more vars */ 105 125 static Boolean expandVars; /* fully expand printed variables */ 106 126 static Lst variables; /* list of variables to print */ … … 121 141 Boolean checkEnvFirst; /* -e flag */ 122 142 Lst envFirstVars; /* (-E) vars to override from env */ 123 BooleanjobsRunning; /* TRUE if the jobs might be running */124 125 static void MainParseArgs (int, char **);126 char * chdir_verify_path (char *, char *);127 static int ReadMakefile (void *, void *);128 static void usage (void);143 static Boolean jobsRunning; /* TRUE if the jobs might be running */ 144 145 static void MainParseArgs __P((int, char **)); 146 char * chdir_verify_path __P((char *, char *)); 147 static int ReadMakefile __P((ClientData, ClientData)); 148 static void usage __P((void)); 129 149 130 150 static char *curdir; /* startup directory */ … … 146 166 */ 147 167 static void 148 MainParseArgs(int argc, char **argv) 149 { 168 MainParseArgs(argc, argv) 169 int argc; 170 char **argv; 171 { 172 extern int optind; 173 extern char *optarg; 150 174 char *p; 151 175 int c; … … 153 177 optind = 1; /* since we're called more than once */ 154 178 #ifdef REMOTE 155 # define OPTFLAGS "B C:D:E:I:L:PSV:Xd:ef:ij:km:nqrstv"179 # define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv" 156 180 #else 157 # define OPTFLAGS "B C:D:E:I:PSV:Xd:ef:ij:km:nqrstv"181 # define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv" 158 182 #endif 159 183 rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { 160 184 switch(c) { 161 case 'C':162 chdir(optarg);163 break;164 185 case 'D': 165 186 Var_Set(optarg, "1", VAR_GLOBAL); … … 173 194 break; 174 195 case 'V': 175 (void)Lst_AtEnd(variables, (void *)optarg); 196 printVars = TRUE; 197 (void)Lst_AtEnd(variables, (ClientData)optarg); 176 198 Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); 177 199 Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); … … 264 286 } 265 287 case 'E': 266 p = emalloc(strlen(optarg) + 1); 288 p = malloc(strlen(optarg) + 1); 289 if (!p) 290 Punt("make: cannot allocate memory."); 267 291 (void)strcpy(p, optarg); 268 (void)Lst_AtEnd(envFirstVars, ( void *)p);292 (void)Lst_AtEnd(envFirstVars, (ClientData)p); 269 293 Var_Append(MAKEFLAGS, "-E", VAR_GLOBAL); 270 294 Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); … … 275 299 break; 276 300 case 'f': 277 (void)Lst_AtEnd(makefiles, ( void *)optarg);301 (void)Lst_AtEnd(makefiles, (ClientData)optarg); 278 302 break; 279 303 case 'i': … … 358 382 goto rearg; 359 383 } 360 (void)Lst_AtEnd(create, ( void *)estrdup(*argv));384 (void)Lst_AtEnd(create, (ClientData)estrdup(*argv)); 361 385 } 362 386 } … … 378 402 */ 379 403 void 380 Main_ParseArgLine(char *line) 404 Main_ParseArgLine(line) 405 char *line; /* Line to fracture */ 381 406 { 382 407 char **argv; /* Manufactured argument vector */ … … 395 420 396 421 char * 397 chdir_verify_path(char *path, char *obpath) 422 chdir_verify_path(path, obpath) 423 char *path; 424 char *obpath; 398 425 { 399 426 struct stat sb; 400 427 401 428 if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) { 402 if (chdir(path) == -1 || getcwd(obpath, MAXPATHLEN) == NULL) {429 if (chdir(path)) { 403 430 warn("warning: %s", path); 404 431 return 0; 405 432 } 406 return obpath; 433 else { 434 if (path[0] != '/') { 435 (void) snprintf(obpath, MAXPATHLEN, "%s/%s", 436 curdir, path); 437 return obpath; 438 } 439 else 440 return path; 441 } 407 442 } 408 443 … … 429 464 */ 430 465 int 431 main(int argc, char **argv) 466 main(argc, argv) 467 int argc; 468 char **argv; 432 469 { 433 470 Lst targs; /* target nodes to create -- passed to Make_Init */ … … 435 472 struct stat sa; 436 473 char *p, *p1, *path, *pathp; 437 #ifdef WANT_ENV_MKLVL 438 #define MKLVL_MAXVAL 500 439 #define MKLVL_ENVVAR "__MKLVL__" 440 int iMkLvl = 0; 441 char *szMkLvl = getenv(MKLVL_ENVVAR); 442 #endif /* WANT_ENV_MKLVL */ 443 char mdpath[MAXPATHLEN]; 444 char obpath[MAXPATHLEN]; 445 char cdpath[MAXPATHLEN]; 474 #ifdef WANT_ENV_PWD 475 struct stat sb; 476 char *pwd; 477 #endif 478 char mdpath[MAXPATHLEN + 1]; 479 char obpath[MAXPATHLEN + 1]; 480 char cdpath[MAXPATHLEN + 1]; 446 481 char *machine = getenv("MACHINE"); 447 482 char *machine_arch = getenv("MACHINE_ARCH"); … … 452 487 static char syspath[] = _PATH_DEFSYSPATH; 453 488 454 #ifdef WANT_ENV_MKLVL455 if ((iMkLvl = szMkLvl ? atoi(szMkLvl) : 0) < 0) {456 iMkLvl = 0;457 }458 if (iMkLvl++ > MKLVL_MAXVAL) {459 errc(2, EAGAIN,460 "Max recursion level (%d) exceeded.", MKLVL_MAXVAL);461 }462 bzero(szMkLvl = emalloc(32), 32);463 sprintf(szMkLvl, "%d", iMkLvl);464 setenv(MKLVL_ENVVAR, szMkLvl, 1);465 #endif /* WANT_ENV_MKLVL */466 467 #if DEFSHELL == 2468 /*469 * Turn off ENV to make ksh happier.470 */471 unsetenv("ENV");472 #endif473 474 489 #ifdef RLIMIT_NOFILE 475 490 /* … … 486 501 #endif 487 502 /* 488 * Find where we are ...503 * Find where we are and take care of PWD for the automounter... 489 504 * All this code is so that we know where we are when we start up 490 505 * on a different machine with pmake. … … 496 511 if (stat(curdir, &sa) == -1) 497 512 err(2, "%s", curdir); 513 514 #ifdef WANT_ENV_PWD 515 if ((pwd = getenv("PWD")) != NULL) { 516 if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino && 517 sa.st_dev == sb.st_dev) 518 (void) strcpy(curdir, pwd); 519 } 520 #endif 498 521 499 522 #if defined(__i386__) && defined(__FreeBSD_version) && \ … … 532 555 struct utsname utsname; 533 556 534 if (uname(&utsname) == -1) 535 err(2, "uname"); 557 if (uname(&utsname) == -1) { 558 perror("make: uname"); 559 exit(2); 560 } 536 561 machine = utsname.machine; 537 562 #else … … 603 628 } 604 629 630 #ifdef WANT_ENV_PWD 631 setenv("PWD", objdir, 1); 632 #endif 633 605 634 create = Lst_Init(FALSE); 606 635 makefiles = Lst_Init(FALSE); 607 636 envFirstVars = Lst_Init(FALSE); 637 printVars = FALSE; 608 638 expandVars = TRUE; 609 639 variables = Lst_Init(FALSE); … … 659 689 Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL); 660 690 Var_Set("MACHINE_CPU", machine_cpu, VAR_GLOBAL); 661 #ifdef MAKE_VERSION662 Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);663 #endif664 691 665 692 /* … … 691 718 Suff_Init(); 692 719 693 DEFAULT = N ULL;720 DEFAULT = NILGNODE; 694 721 (void)time(&now); 695 722 … … 702 729 LstNode ln; 703 730 704 for (ln = Lst_First(create); ln != N ULL;731 for (ln = Lst_First(create); ln != NILLNODE; 705 732 ln = Lst_Succ(ln)) { 706 733 char *name = (char *)Lst_Datum(ln); … … 742 769 if (Lst_IsEmpty(sysMkPath)) 743 770 Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); 744 ln = Lst_Find(sysMkPath, ( void *)NULL, ReadMakefile);745 if (ln != N ULL)771 ln = Lst_Find(sysMkPath, (ClientData)NULL, ReadMakefile); 772 if (ln != NILLNODE) 746 773 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); 747 774 } … … 750 777 LstNode ln; 751 778 752 ln = Lst_Find(makefiles, ( void *)NULL, ReadMakefile);753 if (ln != N ULL)779 ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile); 780 if (ln != NILLNODE) 754 781 Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); 755 } else if (!ReadMakefile("BSDmakefile", NULL)) 756 if (!ReadMakefile("makefile", NULL)) 782 } else if (!ReadMakefile("makefile", NULL)) 757 783 (void)ReadMakefile("Makefile", NULL); 758 784 … … 778 804 */ 779 805 if (Var_Exists("VPATH", VAR_CMD)) { 780 char *vpath, savec;806 char *vpath, *path, *cp, savec; 781 807 /* 782 808 * GCC stores string constants in read-only memory, but … … 800 826 path = cp + 1; 801 827 } while (savec == ':'); 802 (void)free( vpath);828 (void)free((Address)vpath); 803 829 } 804 830 … … 814 840 815 841 /* print the values of any variables requested by the user */ 816 if ( !Lst_IsEmpty(variables)) {842 if (printVars) { 817 843 LstNode ln; 818 844 819 for (ln = Lst_First(variables); ln != N ULL;845 for (ln = Lst_First(variables); ln != NILLNODE; 820 846 ln = Lst_Succ(ln)) { 821 847 char *value; 822 848 if (expandVars) { 823 p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3); 849 p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3); 850 if (!p1) 851 Punt("make: cannot allocate memory."); 824 852 /* This sprintf is safe, because of the malloc above */ 825 853 (void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln)); … … 833 861 free(p1); 834 862 } 835 } else { 836 863 } 864 865 /* 866 * Have now read the entire graph and need to make a list of targets 867 * to create. If none was given on the command line, we consult the 868 * parsing module to find the main target(s) to create. 869 */ 870 if (Lst_IsEmpty(create)) 871 targs = Parse_MainName(); 872 else 873 targs = Targ_FindList(create, TARG_CREATE); 874 875 if (!compatMake && !printVars) { 837 876 /* 838 * Have now read the entire graph and need to make a list of targets 839 * to create. If none was given on the command line, we consult the 840 * parsing module to find the main target(s) to create. 877 * Initialize job module before traversing the graph, now that 878 * any .BEGIN and .END targets have been read. This is done 879 * only if the -q flag wasn't given (to prevent the .BEGIN from 880 * being executed should it exist). 841 881 */ 842 if (Lst_IsEmpty(create)) 843 targs = Parse_MainName(); 844 else 845 targs = Targ_FindList(create, TARG_CREATE); 846 847 if (!compatMake) { 848 /* 849 * Initialize job module before traversing the graph, now that 850 * any .BEGIN and .END targets have been read. This is done 851 * only if the -q flag wasn't given (to prevent the .BEGIN from 852 * being executed should it exist). 853 */ 854 if (!queryFlag) { 855 if (maxLocal == -1) 856 maxLocal = maxJobs; 857 Job_Init(maxJobs, maxLocal); 858 jobsRunning = TRUE; 859 } 860 861 /* Traverse the graph, checking on all the targets */ 862 outOfDate = Make_Run(targs); 863 } else { 864 /* 865 * Compat_Init will take care of creating all the targets as 866 * well as initializing the module. 867 */ 868 Compat_Run(targs); 869 } 870 Lst_Destroy(targs, NOFREE); 871 } 872 882 if (!queryFlag) { 883 if (maxLocal == -1) 884 maxLocal = maxJobs; 885 Job_Init(maxJobs, maxLocal); 886 jobsRunning = TRUE; 887 } 888 889 /* Traverse the graph, checking on all the targets */ 890 outOfDate = Make_Run(targs); 891 } else if (!printVars) { 892 /* 893 * Compat_Init will take care of creating all the targets as 894 * well as initializing the module. 895 */ 896 Compat_Run(targs); 897 } 898 899 Lst_Destroy(targs, NOFREE); 873 900 Lst_Destroy(variables, NOFREE); 874 901 Lst_Destroy(makefiles, NOFREE); 875 Lst_Destroy(create, (void (*) (void *)) free);902 Lst_Destroy(create, (void (*) __P((ClientData))) free); 876 903 877 904 /* print the graph now it's been processed if the user requested it */ … … 904 931 */ 905 932 static Boolean 906 ReadMakefile(void *p, void *q __unused) 907 { 908 char *fname; /* makefile to read */ 933 ReadMakefile(p, q) 934 ClientData p, q; 935 { 936 char *fname = p; /* makefile to read */ 937 extern Lst parseIncPath; 909 938 FILE *stream; 910 char *name, path[MAXPATHLEN ];939 char *name, path[MAXPATHLEN + 1]; 911 940 char *MAKEFILE; 912 941 int setMAKEFILE; 913 914 fname = p;915 942 916 943 if (!strcmp(fname, "-")) { … … 923 950 if (curdir != objdir && *fname != '/') { 924 951 (void)snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname); 925 /*926 * XXX The realpath stuff breaks relative includes927 * XXX in some cases. The problem likely is in928 * XXX parse.c where it does special things in929 * XXX ParseDoInclude if the file is relateive930 * XXX or absolute and not a system file. There931 * XXX it assumes that if the current file that's932 * XXX being included is absolute, that any files933 * XXX that it includes shouldn't do the -I path934 * XXX stuff, which is inconsistant with historical935 * XXX behavior. However, I can't pentrate the mists936 * XXX further, so I'm putting this workaround in937 * XXX here until such time as the underlying bug938 * XXX can be fixed.939 */940 #if THIS_BREAKS_THINGS941 952 if (realpath(path, path) != NULL && 942 953 (stream = fopen(path, "r")) != NULL) { … … 951 962 goto found; 952 963 } 953 #else954 if ((stream = fopen(path, "r")) != NULL) {955 MAKEFILE = fname;956 fname = path;957 goto found;958 }959 } else {960 MAKEFILE = fname;961 if ((stream = fopen(fname, "r")) != NULL)962 goto found;963 }964 #endif965 964 /* look in -I and system include directories. */ 966 965 name = Dir_FindFile(fname, parseIncPath); … … 991 990 * Results: 992 991 * A string containing the output of the command, or the empty string 993 * If err oris not NULL, it contains the reason for the command failure992 * If err is not NULL, it contains the reason for the command failure 994 993 * 995 994 * Side Effects: … … 997 996 */ 998 997 char * 999 Cmd_Exec(char *cmd, char **error) 998 Cmd_Exec(cmd, err) 999 char *cmd; 1000 char **err; 1000 1001 { 1001 1002 char *args[4]; /* Args for invoking the shell */ … … 1009 1010 int cc; 1010 1011 1011 *error = NULL; 1012 1013 *err = NULL; 1012 1014 1013 1015 /* … … 1023 1025 */ 1024 1026 if (pipe(fds) == -1) { 1025 *err or= "Couldn't create pipe for \"%s\"";1027 *err = "Couldn't create pipe for \"%s\""; 1026 1028 goto bad; 1027 1029 } … … 1045 1047 (void) close(fds[1]); 1046 1048 1047 #if defined(DEFSHELL) && DEFSHELL == 01048 (void) execv("/bin/csh", args);1049 #elif DEFSHELL == 11050 1049 (void) execv("/bin/sh", args); 1051 #elif DEFSHELL == 21052 (void) execv("/bin/ksh", args);1053 #else1054 #error "DEFSHELL must be 1 or 2."1055 #endif1056 1050 _exit(1); 1057 1051 /*NOTREACHED*/ 1058 1052 1059 1053 case -1: 1060 *err or= "Couldn't exec \"%s\"";1054 *err = "Couldn't exec \"%s\""; 1061 1055 goto bad; 1062 1056 … … 1089 1083 1090 1084 if (cc == -1) 1091 *err or= "Error reading shell's output for \"%s\"";1085 *err = "Error reading shell's output for \"%s\""; 1092 1086 1093 1087 res = (char *)Buf_GetAll (buf, &cc); … … 1095 1089 1096 1090 if (status) 1097 *err or= "\"%s\" returned non-zero status";1091 *err = "\"%s\" returned non-zero status"; 1098 1092 1099 1093 /* … … 1125 1119 } 1126 1120 1121 /*- 1122 * Error -- 1123 * Print an error message given its format. 1124 * 1125 * Results: 1126 * None. 1127 * 1128 * Side Effects: 1129 * The message is printed. 1130 */ 1131 /* VARARGS */ 1132 void 1133 #ifdef __STDC__ 1134 Error(char *fmt, ...) 1135 #else 1136 Error(va_alist) 1137 va_dcl 1138 #endif 1139 { 1140 va_list ap; 1141 #ifdef __STDC__ 1142 va_start(ap, fmt); 1143 #else 1144 char *fmt; 1145 1146 va_start(ap); 1147 fmt = va_arg(ap, char *); 1148 #endif 1149 (void)vfprintf(stderr, fmt, ap); 1150 va_end(ap); 1151 (void)fprintf(stderr, "\n"); 1152 (void)fflush(stderr); 1153 } 1154 1155 /*- 1156 * Fatal -- 1157 * Produce a Fatal error message. If jobs are running, waits for them 1158 * to finish. 1159 * 1160 * Results: 1161 * None 1162 * 1163 * Side Effects: 1164 * The program exits 1165 */ 1166 /* VARARGS */ 1167 void 1168 #ifdef __STDC__ 1169 Fatal(char *fmt, ...) 1170 #else 1171 Fatal(va_alist) 1172 va_dcl 1173 #endif 1174 { 1175 va_list ap; 1176 #ifdef __STDC__ 1177 va_start(ap, fmt); 1178 #else 1179 char *fmt; 1180 1181 va_start(ap); 1182 fmt = va_arg(ap, char *); 1183 #endif 1184 if (jobsRunning) 1185 Job_Wait(); 1186 1187 (void)vfprintf(stderr, fmt, ap); 1188 va_end(ap); 1189 (void)fprintf(stderr, "\n"); 1190 (void)fflush(stderr); 1191 1192 if (DEBUG(GRAPH2)) 1193 Targ_PrintGraph(2); 1194 exit(2); /* Not 1 so -q can distinguish error */ 1195 } 1196 1197 /* 1198 * Punt -- 1199 * Major exception once jobs are being created. Kills all jobs, prints 1200 * a message and exits. 1201 * 1202 * Results: 1203 * None 1204 * 1205 * Side Effects: 1206 * All children are killed indiscriminately and the program Lib_Exits 1207 */ 1208 /* VARARGS */ 1209 void 1210 #ifdef __STDC__ 1211 Punt(char *fmt, ...) 1212 #else 1213 Punt(va_alist) 1214 va_dcl 1215 #endif 1216 { 1217 va_list ap; 1218 #if __STDC__ 1219 va_start(ap, fmt); 1220 #else 1221 char *fmt; 1222 1223 va_start(ap); 1224 fmt = va_arg(ap, char *); 1225 #endif 1226 1227 (void)fprintf(stderr, "make: "); 1228 (void)vfprintf(stderr, fmt, ap); 1229 va_end(ap); 1230 (void)fprintf(stderr, "\n"); 1231 (void)fflush(stderr); 1232 1233 DieHorribly(); 1234 } 1235 1236 /*- 1237 * DieHorribly -- 1238 * Exit without giving a message. 1239 * 1240 * Results: 1241 * None 1242 * 1243 * Side Effects: 1244 * A big one... 1245 */ 1246 void 1247 DieHorribly() 1248 { 1249 if (jobsRunning) 1250 Job_AbortAll(); 1251 if (DEBUG(GRAPH2)) 1252 Targ_PrintGraph(2); 1253 exit(2); /* Not 1, so -q can distinguish error */ 1254 } 1255 1256 /* 1257 * Finish -- 1258 * Called when aborting due to errors in child shell to signal 1259 * abnormal exit. 1260 * 1261 * Results: 1262 * None 1263 * 1264 * Side Effects: 1265 * The program exits 1266 */ 1267 void 1268 Finish(errors) 1269 int errors; /* number of errors encountered in Make_Make */ 1270 { 1271 Fatal("%d error%s", errors, errors == 1 ? "" : "s"); 1272 } 1273 1274 /* 1275 * emalloc -- 1276 * malloc, but die on error. 1277 */ 1278 void * 1279 emalloc(len) 1280 size_t len; 1281 { 1282 void *p; 1283 1284 if ((p = malloc(len)) == NULL) 1285 enomem(); 1286 return(p); 1287 } 1288 1289 /* 1290 * estrdup -- 1291 * strdup, but die on error. 1292 */ 1293 char * 1294 estrdup(str) 1295 const char *str; 1296 { 1297 char *p; 1298 1299 if ((p = strdup(str)) == NULL) 1300 enomem(); 1301 return(p); 1302 } 1303 1304 /* 1305 * erealloc -- 1306 * realloc, but die on error. 1307 */ 1308 void * 1309 erealloc(ptr, size) 1310 void *ptr; 1311 size_t size; 1312 { 1313 if ((ptr = realloc(ptr, size)) == NULL) 1314 enomem(); 1315 return(ptr); 1316 } 1317 1318 /* 1319 * enomem -- 1320 * die when out of memory. 1321 */ 1322 void 1323 enomem() 1324 { 1325 err(2, NULL); 1326 } 1327 1328 /* 1329 * enunlink -- 1330 * Remove a file carefully, avoiding directories. 1331 */ 1332 int 1333 eunlink(file) 1334 const char *file; 1335 { 1336 struct stat st; 1337 1338 if (lstat(file, &st) == -1) 1339 return -1; 1340 1341 if (S_ISDIR(st.st_mode)) { 1342 errno = EISDIR; 1343 return -1; 1344 } 1345 return unlink(file); 1346 } 1347 1127 1348 /* 1128 1349 * usage -- … … 1130 1351 */ 1131 1352 static void 1132 usage( void)1353 usage() 1133 1354 { 1134 1355 (void)fprintf(stderr, "%s\n%s\n%s\n", … … 1138 1359 exit(2); 1139 1360 } 1361 1362 1363 int 1364 PrintAddr(a, b) 1365 ClientData a; 1366 ClientData b; 1367 { 1368 printf("%lx ", (unsigned long) a); 1369 return b ? 0 : 0; 1370 } -
branches/FREEBSD/src/kmk/make.1
r10 r24 30 30 .\" SUCH DAMAGE. 31 31 .\" 32 .\" @(#)make.1 8.8 (Berkeley) 6/13/9533 .\" $FreeBSD: src/usr.bin/make/make.1,v 1. 59 2002/09/27 09:21:07 ruExp $32 .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 33 .\" $FreeBSD: src/usr.bin/make/make.1,v 1.29.2.14 2002/09/09 19:06:16 archie Exp $ 34 34 .\" 35 .Dd June 13, 199535 .Dd March 19, 1994 36 36 .Dt MAKE 1 37 37 .Os … … 42 42 .Nm 43 43 .Op Fl BPSXeiknqrstv 44 .Op Fl C Ar directory45 44 .Op Fl D Ar variable 46 45 .Op Fl d Ar flags … … 63 62 files and programs. 64 63 The first of 65 .Ql Pa BSDmakefile ,66 64 .Ql Pa makefile 67 65 and … … 90 88 .Fl j 91 89 is used. 92 .It Fl C Ar directory93 Change to94 .Ar directory95 while running.96 90 .It Fl D Ar variable 97 91 Define … … 178 172 that do not depend on the target whose creation caused the error. 179 173 .It Fl m Ar directory 180 Specify a directory in which to search for 181 .Pa sys.mk 182 and makefiles included via the <...> style. 174 Specify a directory in which to search for sys.mk and makefiles included 175 via the <...> style. 183 176 Multiple directories can be added to form a search path. 184 177 This path will override the default system include path: … … 519 512 is unable to change into any of the remaining three directories, 520 513 then the current directory is used. 521 .Pp522 The523 .Nm524 utility sets525 .Va .OBJDIR526 to the canonical path given by527 .Xr getcwd 3 .528 514 .It Va .MAKEFLAGS 529 515 The environment variable … … 551 537 .Va .MAKEFLAGS 552 538 provided for backward compatibility. 539 .It Ev PWD 540 Alternate path to the current directory. 541 Supported if built with WANT_ENV_PWD defined. 542 .Nm 543 normally sets 544 .Ql Va .CURDIR 545 to the canonical path given by 546 .Xr getcwd 3 . 547 However, if the environment variable 548 .Ev PWD 549 is set and gives a path to the current directory, then 550 .Nm 551 sets 552 .Ql Va .CURDIR 553 to the value of 554 .Ev PWD 555 instead. 556 .Ev PWD 557 is always set to the value of 558 .Ql Va .OBJDIR 559 for all programs which 560 .Nm 561 executes. 553 562 .It Va .TARGETS 554 563 List of targets … … 580 589 These directories will be searched for source files by 581 590 .Nm 582 after it has finished parsing all input makefiles. 591 after 592 .Nm 593 has finished parsing all input makefiles. 583 594 .El 584 595 .Pp … … 700 711 .Pq Ql \&$ , 701 712 not a preceding dollar sign as is usual. 713 .It Cm T 714 Replaces each word in the variable with its last component. 702 715 .It Ar old_string=new_string 703 716 This is the … … 720 733 to be replaced in 721 734 .Ar new_string 722 .It Cm T723 Replaces each word in the variable with its last component.724 735 .It Cm U 725 736 Converts variable to upper-case letters. … … 853 864 .Bl -tag -width "Cm XX" 854 865 .It Cm \&|\&| 855 logical 856 .Tn OR 866 logical OR 857 867 .It Cm \&&& 858 868 Logical … … 1107 1117 Disable parallel mode. 1108 1118 .It Ic .NO_PARALLEL 1109 Same as above, for compatibility with other 1110 .Nm pmake 1111 variants. 1119 Same as above, for compatibility with other pmake variants. 1112 1120 .It Ic .ORDER 1113 1121 The named targets are made in sequence. … … 1191 1199 .Ev MAKEFLAGS , 1192 1200 .Ev MAKEOBJDIR , 1201 .Ev MAKEOBJDIRPREFIX , 1193 1202 and 1194 .Ev MAKEOBJDIRPREFIX.1203 .Ev PWD . 1195 1204 .Sh FILES 1196 1205 .Bl -tag -width /usr/share/doc/psd/12.make -compact … … 1245 1254 .Pp 1246 1255 For loops are expanded before tests, so a fragment such as: 1247 .Bd -literal -offset indent1256 .Bd -literal 1248 1257 \&.for TMACHINE in ${SHARED_ARCHS} 1249 1258 \&.if ${TMACHINE} = ${MACHINE} … … 1252 1261 \&.endfor 1253 1262 .Ed 1254 .Pp1255 1263 won't work, and should be rewritten the other way around. 1256 .Pp1257 The parsing code is broken with respect to handling a semicolon1258 after a colon, so a fragment like this will fail:1259 .Bd -literal -offset indent1260 HDRS= foo.h bar.h1261 1262 all:1263 \&.for h in ${HDRS:S;^;${.CURDIR}/;}1264 ...1265 \&.endfor1266 .Ed1267 1264 .Sh SEE ALSO 1268 1265 .Xr mkdep 1 , … … 1276 1273 A 1277 1274 .Nm 1278 command appeared in PWB UNIX. 1275 command appeared in 1276 .At v7 . -
branches/FREEBSD/src/kmk/make.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 * @(#)make.c 8.1 (Berkeley) 6/6/93 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/make.c,v 1.23 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/make.c,v 1.11 1999/09/11 13:08:01 hoek Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 /*- … … 88 92 * TRUE, there's a cycle in the graph */ 89 93 90 static int MakeAddChild (void *, void *);91 static int MakeAddAllSrc (void *, void *);92 static int MakeTimeStamp (void *, void *);93 static int MakeHandleUse (void *, void *);94 static Boolean MakeStartJobs (void);95 static int MakePrintStatus (void *, void *);94 static int MakeAddChild __P((ClientData, ClientData)); 95 static int MakeAddAllSrc __P((ClientData, ClientData)); 96 static int MakeTimeStamp __P((ClientData, ClientData)); 97 static int MakeHandleUse __P((ClientData, ClientData)); 98 static Boolean MakeStartJobs __P((void)); 99 static int MakePrintStatus __P((ClientData, ClientData)); 96 100 /*- 97 101 *----------------------------------------------------------------------- … … 109 113 */ 110 114 int 111 Make_TimeStamp (GNode *pgn, GNode *cgn) 115 Make_TimeStamp (pgn, cgn) 116 GNode *pgn; /* the current parent */ 117 GNode *cgn; /* the child we've just examined */ 112 118 { 113 119 if (cgn->mtime > pgn->cmtime) { … … 118 124 119 125 static int 120 MakeTimeStamp (void *pgn, void *cgn) 126 MakeTimeStamp (pgn, cgn) 127 ClientData pgn; /* the current parent */ 128 ClientData cgn; /* the child we've just examined */ 121 129 { 122 130 return Make_TimeStamp((GNode *) pgn, (GNode *) cgn); … … 143 151 */ 144 152 Boolean 145 Make_OODate (GNode *gn) 153 Make_OODate (gn) 154 register GNode *gn; /* the node to check */ 146 155 { 147 156 Boolean oodate; … … 153 162 if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) { 154 163 (void) Dir_MTime (gn); 155 if (gn->mtime != 0) { 156 DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime))); 157 } else { 158 DEBUGF(MAKE, ("non-existent...")); 164 if (DEBUG(MAKE)) { 165 if (gn->mtime != 0) { 166 printf ("modified %s...", Targ_FmtTime(gn->mtime)); 167 } else { 168 printf ("non-existent..."); 169 } 159 170 } 160 171 } … … 179 190 * no matter *what*. 180 191 */ 181 DEBUGF(MAKE, (".USE node...")); 192 if (DEBUG(MAKE)) { 193 printf(".USE node..."); 194 } 182 195 oodate = FALSE; 183 196 } else if (gn->type & OP_LIB) { 184 DEBUGF(MAKE, ("library...")); 197 if (DEBUG(MAKE)) { 198 printf("library..."); 199 } 185 200 186 201 /* … … 195 210 * out-of-date if any of its children was out-of-date. 196 211 */ 197 DEBUGF(MAKE, (".JOIN node...")); 212 if (DEBUG(MAKE)) { 213 printf(".JOIN node..."); 214 } 198 215 oodate = gn->childMade; 199 216 } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) { … … 202 219 * the .EXEC attribute is always considered out-of-date. 203 220 */ 204 if (gn->type & OP_FORCE) { 205 DEBUGF(MAKE, ("! operator...")); 206 } else if (gn->type & OP_PHONY) { 207 DEBUGF(MAKE, (".PHONY node...")); 208 } else { 209 DEBUGF(MAKE, (".EXEC node...")); 221 if (DEBUG(MAKE)) { 222 if (gn->type & OP_FORCE) { 223 printf("! operator..."); 224 } else if (gn->type & OP_PHONY) { 225 printf(".PHONY node..."); 226 } else { 227 printf(".EXEC node..."); 228 } 210 229 } 211 230 oodate = TRUE; … … 221 240 * it. 222 241 */ 223 if (gn->mtime < gn->cmtime) { 224 DEBUGF(MAKE, ("modified before source...")); 225 } else if (gn->mtime == 0) { 226 DEBUGF(MAKE, ("non-existent and no sources...")); 227 } else { 228 DEBUGF(MAKE, (":: operator and no sources...")); 242 if (DEBUG(MAKE)) { 243 if (gn->mtime < gn->cmtime) { 244 printf("modified before source..."); 245 } else if (gn->mtime == 0) { 246 printf("non-existent and no sources..."); 247 } else { 248 printf(":: operator and no sources..."); 249 } 229 250 } 230 251 oodate = TRUE; 231 } else 252 } else { 253 #if 0 254 /* WHY? */ 255 if (DEBUG(MAKE)) { 256 printf("source %smade...", gn->childMade ? "" : "not "); 257 } 258 oodate = gn->childMade; 259 #else 232 260 oodate = FALSE; 261 #endif /* 0 */ 262 } 233 263 234 264 /* … … 240 270 */ 241 271 if (!oodate) { 242 Lst_ForEach (gn->parents, MakeTimeStamp, ( void *)gn);272 Lst_ForEach (gn->parents, MakeTimeStamp, (ClientData)gn); 243 273 } 244 274 … … 261 291 */ 262 292 static int 263 MakeAddChild (void *gnp, void *lp) 293 MakeAddChild (gnp, lp) 294 ClientData gnp; /* the node to add */ 295 ClientData lp; /* the list to which to add it */ 264 296 { 265 297 GNode *gn = (GNode *) gnp; … … 267 299 268 300 if (!gn->make && !(gn->type & OP_USE)) { 269 (void)Lst_EnQueue (l, ( void *)gn);301 (void)Lst_EnQueue (l, (ClientData)gn); 270 302 } 271 303 return (0); … … 297 329 */ 298 330 int 299 Make_HandleUse (GNode *cgn, GNode *pgn) 300 { 301 GNode *gn; /* A child of the .USE node */ 302 LstNode ln; /* An element in the children list */ 331 Make_HandleUse (cgn, pgn) 332 register GNode *cgn; /* The .USE node */ 333 register GNode *pgn; /* The target of the .USE node */ 334 { 335 register GNode *gn; /* A child of the .USE node */ 336 register LstNode ln; /* An element in the children list */ 303 337 304 338 if (cgn->type & (OP_USE|OP_TRANSFORM)) { … … 312 346 313 347 if (Lst_Open (cgn->children) == SUCCESS) { 314 while ((ln = Lst_Next (cgn->children)) != N ULL) {348 while ((ln = Lst_Next (cgn->children)) != NILLNODE) { 315 349 gn = (GNode *)Lst_Datum (ln); 316 350 317 if (Lst_Member (pgn->children, gn) == N ULL) {351 if (Lst_Member (pgn->children, gn) == NILLNODE) { 318 352 (void) Lst_AtEnd (pgn->children, gn); 319 353 (void) Lst_AtEnd (gn->parents, pgn); … … 340 374 } 341 375 static int 342 MakeHandleUse (void *pgn, void *cgn) 376 MakeHandleUse (pgn, cgn) 377 ClientData pgn; /* the current parent */ 378 ClientData cgn; /* the child we've just examined */ 343 379 { 344 380 return Make_HandleUse((GNode *) pgn, (GNode *) cgn); … … 372 408 */ 373 409 void 374 Make_Update (GNode *cgn) 375 { 376 GNode *pgn; /* the parent node */ 377 char *cname; /* the child's name */ 378 LstNode ln; /* Element in parents and iParents lists */ 379 char *p1; 410 Make_Update (cgn) 411 register GNode *cgn; /* the child node */ 412 { 413 register GNode *pgn; /* the parent node */ 414 register char *cname; /* the child's name */ 415 register LstNode ln; /* Element in parents and iParents lists */ 416 char *p1; 380 417 381 418 cname = Var_Value (TARGET, cgn, &p1); … … 443 480 cgn->mtime = now; 444 481 } 445 DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(cgn->mtime))); 482 if (DEBUG(MAKE)) { 483 printf("update time: %s\n", Targ_FmtTime(cgn->mtime)); 484 } 446 485 #endif 447 486 } 448 487 449 488 if (Lst_Open (cgn->parents) == SUCCESS) { 450 while ((ln = Lst_Next (cgn->parents)) != N ULL) {489 while ((ln = Lst_Next (cgn->parents)) != NILLNODE) { 451 490 pgn = (GNode *)Lst_Datum (ln); 452 491 if (pgn->make) { … … 468 507 * be dealt with in MakeStartJobs. 469 508 */ 470 (void)Lst_EnQueue (toBeMade, ( void *)pgn);509 (void)Lst_EnQueue (toBeMade, (ClientData)pgn); 471 510 } else if (pgn->unmade < 0) { 472 511 Error ("Graph cycles through %s", pgn->name); … … 482 521 * before. 483 522 */ 484 for (ln = Lst_First(cgn->successors); ln != N ULL; ln = Lst_Succ(ln)) {523 for (ln = Lst_First(cgn->successors); ln != NILLNODE; ln = Lst_Succ(ln)) { 485 524 GNode *succ = (GNode *)Lst_Datum(ln); 486 525 487 526 if (succ->make && succ->unmade == 0 && succ->made == UNMADE && 488 Lst_Member(toBeMade, ( void *)succ) == NULL)527 Lst_Member(toBeMade, (ClientData)succ) == NILLNODE) 489 528 { 490 (void)Lst_EnQueue(toBeMade, ( void *)succ);529 (void)Lst_EnQueue(toBeMade, (ClientData)succ); 491 530 } 492 531 } … … 497 536 */ 498 537 if (Lst_Open (cgn->iParents) == SUCCESS) { 499 char *p tr;500 char *cpref = Var_Value(PREFIX, cgn, &p tr);501 502 while ((ln = Lst_Next (cgn->iParents)) != N ULL) {538 char *p1; 539 char *cpref = Var_Value(PREFIX, cgn, &p1); 540 541 while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) { 503 542 pgn = (GNode *)Lst_Datum (ln); 504 543 if (pgn->make) { … … 507 546 } 508 547 } 509 efree(p tr);548 efree(p1); 510 549 Lst_Close (cgn->iParents); 511 550 } … … 534 573 */ 535 574 static int 536 MakeAddAllSrc (void *cgnp, void *pgnp) 575 MakeAddAllSrc (cgnp, pgnp) 576 ClientData cgnp; /* The child to add */ 577 ClientData pgnp; /* The parent to whose ALLSRC variable it should be */ 578 /* added */ 537 579 { 538 580 GNode *cgn = (GNode *) cgnp; … … 605 647 */ 606 648 void 607 Make_DoAllVar (GNode *gn) 608 { 609 Lst_ForEach (gn->children, MakeAddAllSrc, (void *) gn); 649 Make_DoAllVar (gn) 650 GNode *gn; 651 { 652 Lst_ForEach (gn->children, MakeAddAllSrc, (ClientData) gn); 610 653 611 654 if (!Var_Exists (OODATE, gn)) { … … 641 684 */ 642 685 static Boolean 643 MakeStartJobs ( void)644 { 645 GNode *gn;686 MakeStartJobs () 687 { 688 register GNode *gn; 646 689 647 690 while (!Job_Full() && !Lst_IsEmpty (toBeMade)) { 648 691 gn = (GNode *) Lst_DeQueue (toBeMade); 649 DEBUGF(MAKE, ("Examining %s...", gn->name)); 692 if (DEBUG(MAKE)) { 693 printf ("Examining %s...", gn->name); 694 } 650 695 /* 651 696 * Make sure any and all predecessors that are going to be made, … … 655 700 LstNode ln; 656 701 657 for (ln = Lst_First(gn->preds); ln != N ULL; ln = Lst_Succ(ln)){702 for (ln = Lst_First(gn->preds); ln != NILLNODE; ln = Lst_Succ(ln)){ 658 703 GNode *pgn = (GNode *)Lst_Datum(ln); 659 704 660 705 if (pgn->make && pgn->made == UNMADE) { 661 DEBUGF(MAKE, ("predecessor %s not made yet.\n", pgn->name)); 706 if (DEBUG(MAKE)) { 707 printf("predecessor %s not made yet.\n", pgn->name); 708 } 662 709 break; 663 710 } 664 711 } 665 712 /* 666 * If ln isn't NULL, there's a predecessor as yet unmade, so we713 * If ln isn't nil, there's a predecessor as yet unmade, so we 667 714 * just drop this node on the floor. When the node in question 668 715 * has been made, it will notice this node as being ready to 669 716 * make but as yet unmade and will place the node on the queue. 670 717 */ 671 if (ln != N ULL) {718 if (ln != NILLNODE) { 672 719 continue; 673 720 } … … 676 723 numNodes--; 677 724 if (Make_OODate (gn)) { 678 DEBUGF(MAKE, ("out-of-date\n")); 725 if (DEBUG(MAKE)) { 726 printf ("out-of-date\n"); 727 } 679 728 if (queryFlag) { 680 729 return (TRUE); … … 683 732 Job_Make (gn); 684 733 } else { 685 DEBUGF(MAKE, ("up-to-date\n")); 734 if (DEBUG(MAKE)) { 735 printf ("up-to-date\n"); 736 } 686 737 gn->made = UPTODATE; 687 738 if (gn->type & OP_JOIN) { … … 707 758 * Print the status of a top-level node, viz. it being up-to-date 708 759 * already or not created due to an error in a lower level. 709 * Callback function for Make_Run via Lst_ForEach. If gn->unmade is 710 * nonzero and that is meant to imply a cycle in the graph, then 711 * cycle is TRUE. 760 * Callback function for Make_Run via Lst_ForEach. 712 761 * 713 762 * Results: … … 720 769 */ 721 770 static int 722 MakePrintStatus(void *gnp, void *cyclep) 771 MakePrintStatus(gnp, cyclep) 772 ClientData gnp; /* Node to examine */ 773 ClientData cyclep; /* True if gn->unmade being non-zero implies 774 * a cycle in the graph, not an error in an 775 * inferior */ 723 776 { 724 777 GNode *gn = (GNode *) gnp; … … 742 795 Error("Graph cycles through `%s'", gn->name); 743 796 gn->made = ENDCYCLE; 744 Lst_ForEach(gn->children, MakePrintStatus, ( void *) &t);797 Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t); 745 798 gn->made = UNMADE; 746 799 } else if (gn->made != ENDCYCLE) { 747 800 gn->made = CYCLE; 748 Lst_ForEach(gn->children, MakePrintStatus, ( void *) &t);801 Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t); 749 802 } 750 803 } else { … … 778 831 */ 779 832 Boolean 780 Make_Run (Lst targs) 781 { 782 GNode *gn; /* a temporary pointer */ 783 Lst examine; /* List of targets to examine */ 833 Make_Run (targs) 834 Lst targs; /* the initial list of targets */ 835 { 836 register GNode *gn; /* a temporary pointer */ 837 register Lst examine; /* List of targets to examine */ 784 838 int errors; /* Number of errors the Job module reports */ 785 839 … … 808 862 * to make sure everything has commands that should... 809 863 */ 810 Lst_ForEach (gn->children, MakeHandleUse, ( void *)gn);864 Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn); 811 865 Suff_FindDeps (gn); 812 866 813 867 if (gn->unmade != 0) { 814 Lst_ForEach (gn->children, MakeAddChild, ( void *)examine);868 Lst_ForEach (gn->children, MakeAddChild, (ClientData)examine); 815 869 } else { 816 (void)Lst_EnQueue (toBeMade, ( void *)gn);870 (void)Lst_EnQueue (toBeMade, (ClientData)gn); 817 871 } 818 872 } … … 855 909 } 856 910 857 errors = Job_ Finish();911 errors = Job_End(); 858 912 859 913 /* … … 862 916 */ 863 917 errors = ((errors == 0) && (numNodes != 0)); 864 Lst_ForEach(targs, MakePrintStatus, ( void *) &errors);918 Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors); 865 919 866 920 return (TRUE); -
branches/FREEBSD/src/kmk/make.h
r10 r24 36 36 * SUCH DAMAGE. 37 37 * 38 * @(#)make.h 8.3 (Berkeley) 6/13/9539 * $FreeBSD: src/usr.bin/make/make.h,v 1. 23 2002/10/10 19:27:48 jmallettExp $38 * from: @(#)make.h 8.3 (Berkeley) 6/13/95 39 * $FreeBSD: src/usr.bin/make/make.h,v 1.12.2.2 2001/02/13 03:13:58 will Exp $ 40 40 */ 41 41 … … 46 46 47 47 #ifndef _MAKE_H_ 48 #define 48 #define _MAKE_H_ 49 49 50 50 #include <sys/types.h> … … 52 52 #include <string.h> 53 53 #include <ctype.h> 54 54 #include <err.h> 55 56 #if !defined(MAKE_BOOTSTRAP) && defined(BSD4_4) 57 # include <sys/cdefs.h> 58 #else 59 # ifndef __P 60 # if defined(__STDC__) || defined(__cplusplus) 61 # define __P(protos) protos /* full-blown ANSI C */ 62 # else 63 # define __P(protos) () /* traditional C preprocessor */ 64 # endif 65 # endif 66 # ifndef __STDC__ 67 # ifndef const 68 # define const 69 # endif 70 # ifndef volatile 71 # define volatile 72 # endif 73 # endif 74 #endif 75 76 #ifdef __STDC__ 55 77 #include <stdlib.h> 56 78 #include <unistd.h> 79 #endif 57 80 #include "sprite.h" 58 81 #include "lst.h" … … 64 87 * pieces of data associated with it. 65 88 * 1) the name of the target it describes 66 * 2) the location of the target file in the file system.89 * 2) the location of the target file in the file system. 67 90 * 3) the type of operator used to define its sources (qv. parse.c) 68 91 * 4) whether it is involved in this invocation of make … … 143 166 144 167 /* 168 * Manifest constants 169 */ 170 #define NILGNODE ((GNode *) NIL) 171 172 /* 145 173 * The OP_ constants are used when parsing a dependency line as a way of 146 174 * communicating to other parts of the program the way in which a target … … 151 179 * righthand side... 152 180 */ 153 #define 181 #define OP_DEPENDS 0x00000001 /* Execution of commands depends on 154 182 * kids (:) */ 155 #define 156 #define 183 #define OP_FORCE 0x00000002 /* Always execute commands (!) */ 184 #define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids 157 185 * per line (::) */ 158 #define 159 160 #define 186 #define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP) 187 188 #define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't 161 189 * exist and can't be created */ 162 #define 163 #define 190 #define OP_USE 0x00000010 /* Use associated commands for parents */ 191 #define OP_EXEC 0x00000020 /* Target is never out of date, but always 164 192 * execute commands anyway. Its time 165 193 * doesn't matter, so it has none...sort 166 194 * of */ 167 #define 168 #define 195 #define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */ 196 #define OP_PRECIOUS 0x00000080 /* Don't remove the target when 169 197 * interrupted */ 170 #define 171 #define 198 #define OP_SILENT 0x00000100 /* Don't echo commands when executed */ 199 #define OP_MAKE 0x00000200 /* Target is a recurrsive make so its 172 200 * commands should always be executed when 173 201 * it is out of date, regardless of the 174 202 * state of the -n or -t flags */ 175 #define 203 #define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its 176 204 * children was out-of-date */ 177 #define 205 #define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents. 178 206 * I.e. it doesn't show up in the parents's 179 207 * local variables. */ 180 #define 208 #define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main 181 209 * target' processing in parse.c */ 182 #define 210 #define OP_PHONY 0x00010000 /* Not a file target; run always */ 183 211 /* Attributes applied by PMake */ 184 #define 185 #define 186 #define 187 #define 188 #define 212 #define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */ 213 #define OP_MEMBER 0x40000000 /* Target is a member of an archive */ 214 #define OP_LIB 0x20000000 /* Target is a library */ 215 #define OP_ARCHV 0x10000000 /* Target is an archive construct */ 216 #define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it should. 189 217 * Used when parsing to catch multiple 190 218 * commands for a target */ 191 #define 192 #define 219 #define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */ 220 #define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */ 193 221 194 222 /* … … 196 224 * object of a dependency operator 197 225 */ 198 #define 226 #define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000) 199 227 200 228 /* … … 204 232 * is given, a new, empty node will be created for the target, placed in the 205 233 * table of all targets and its address returned. If TARG_NOCREATE is given, 206 * a N ULL pointer will be returned.207 */ 208 #define 209 #define 234 * a NIL pointer will be returned. 235 */ 236 #define TARG_CREATE 0x01 /* create node if not found */ 237 #define TARG_NOCREATE 0x00 /* don't create it */ 210 238 211 239 /* … … 218 246 * schemes allocate in powers of two. 219 247 */ 220 #define 248 #define MAKE_BSIZE 256 /* starting size for expandable buffers */ 221 249 222 250 /* … … 229 257 * Str_Concat returns. 230 258 */ 231 #define 232 #define 233 #define 259 #define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */ 260 #define STR_DOFREE 0x02 /* free source strings after concatenation */ 261 #define STR_ADDSLASH 0x04 /* add a slash when Str_Concat'ing */ 234 262 235 263 /* … … 238 266 * as the first argument to Parse_Error. 239 267 */ 240 #define 241 #define 268 #define PARSE_WARNING 2 269 #define PARSE_FATAL 1 242 270 243 271 /* 244 272 * Values returned by Cond_Eval. 245 273 */ 246 #define 247 #define 248 #define 274 #define COND_PARSE 0 /* Parse the next lines */ 275 #define COND_SKIP 1 /* Skip the next lines */ 276 #define COND_INVALID 2 /* Not a conditional statement */ 249 277 250 278 /* 251 279 * Definitions for the "local" variables. Used only for clarity. 252 280 */ 253 #define 254 #define 255 #define 256 #define 257 #define 258 #define 259 #define 260 261 #define 262 #define 263 #define 264 #define 265 #define 266 #define 281 #define TARGET "@" /* Target of dependency */ 282 #define OODATE "?" /* All out-of-date sources */ 283 #define ALLSRC ">" /* All sources */ 284 #define IMPSRC "<" /* Source implied by transformation */ 285 #define PREFIX "*" /* Common prefix */ 286 #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ 287 #define MEMBER "%" /* Member in "archive(member)" syntax */ 288 289 #define FTARGET "@F" /* file part of TARGET */ 290 #define DTARGET "@D" /* directory part of TARGET */ 291 #define FIMPSRC "<F" /* file part of IMPSRC */ 292 #define DIMPSRC "<D" /* directory part of IMPSRC */ 293 #define FPREFIX "*F" /* file part of PREFIX */ 294 #define DPREFIX "*D" /* directory part of PREFIX */ 267 295 268 296 /* … … 274 302 extern Lst dirSearchPath; /* The list of directories to search when 275 303 * looking for targets */ 276 extern Lst parseIncPath; /* The list of directories to search when 277 * looking for includes */ 278 279 extern Boolean jobsRunning; /* True if jobs are running */ 304 280 305 extern Boolean compatMake; /* True if we are make compatible */ 281 306 extern Boolean ignoreErrors; /* True if should ignore all errors */ … … 336 361 #define DEBUG_TARG 0x0100 337 362 #define DEBUG_VAR 0x0200 338 #define DEBUG_FOR 0x0400 339 #define DEBUG_LOUD 0x0800 340 341 #define CONCAT(a,b) a##b 363 #define DEBUG_FOR 0x0400 364 #define DEBUG_LOUD 0x0800 365 366 #ifdef __STDC__ 367 #define CONCAT(a,b) a##b 368 #else 369 #define I(a) a 370 #define CONCAT(a,b) I(a)b 371 #endif /* __STDC__ */ 342 372 343 373 #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 344 #define DEBUGF(module,args) \ 345 do { \ 346 if (DEBUG(module)) { \ 347 Debug args ; \ 348 } \ 349 } while (0) 350 #define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/'))) 351 #define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1]))) 374 #define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/'))) 375 #define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1]))) 352 376 353 377 /* … … 357 381 #include "nonints.h" 358 382 359 int Make_TimeStamp (GNode *, GNode *);360 Boolean Make_OODate (GNode *);361 int Make_HandleUse (GNode *, GNode *);362 void Make_Update (GNode *);363 void Make_DoAllVar (GNode *);364 Boolean Make_Run (Lst);383 int Make_TimeStamp __P((GNode *, GNode *)); 384 Boolean Make_OODate __P((GNode *)); 385 int Make_HandleUse __P((GNode *, GNode *)); 386 void Make_Update __P((GNode *)); 387 void Make_DoAllVar __P((GNode *)); 388 Boolean Make_Run __P((Lst)); 365 389 366 390 #endif /* _MAKE_H_ */ -
branches/FREEBSD/src/kmk/nonints.h
r10 r24 36 36 * SUCH DAMAGE. 37 37 * 38 * @(#)nonints.h 8.4 (Berkeley) 4/28/9539 * $FreeBSD: src/usr.bin/make/nonints.h,v 1. 17 2002/09/18 16:13:03 jmallettExp $38 * from: @(#)nonints.h 8.3 (Berkeley) 3/19/94 39 * $FreeBSD: src/usr.bin/make/nonints.h,v 1.8 1999/08/28 01:03:35 peter Exp $ 40 40 */ 41 41 42 42 /* arch.c */ 43 ReturnStatus Arch_ParseArchive (char **, Lst, GNode *);44 void Arch_Touch (GNode *);45 void Arch_TouchLib (GNode *);46 int Arch_MTime (GNode *);47 int Arch_MemMTime (GNode *);48 void Arch_FindLib (GNode *, Lst);49 Boolean Arch_LibOODate (GNode *);50 void Arch_Init (void);51 void Arch_End (void);43 ReturnStatus Arch_ParseArchive __P((char **, Lst, GNode *)); 44 void Arch_Touch __P((GNode *)); 45 void Arch_TouchLib __P((GNode *)); 46 int Arch_MTime __P((GNode *)); 47 int Arch_MemMTime __P((GNode *)); 48 void Arch_FindLib __P((GNode *, Lst)); 49 Boolean Arch_LibOODate __P((GNode *)); 50 void Arch_Init __P((void)); 51 void Arch_End __P((void)); 52 52 53 53 /* compat.c */ 54 void Compat_Run (Lst);54 void Compat_Run __P((Lst)); 55 55 56 56 /* cond.c */ 57 int Cond_Eval (char *);58 void Cond_End (void);57 int Cond_Eval __P((char *)); 58 void Cond_End __P((void)); 59 59 60 60 /* for.c */ 61 int For_Eval (char *);62 void For_Run (void);61 int For_Eval __P((char *)); 62 void For_Run __P((void)); 63 63 64 64 /* main.c */ 65 void Main_ParseArgLine (char *);66 char *Cmd_Exec(char *, char **);67 void Debug(const char *, ...);68 void Error (const char *, ...);69 void Fatal (const char *, ...);70 void Punt (const char *, ...);71 void DieHorribly (void);72 int PrintAddr (void *, void *);73 void Finish (int);74 char *estrdup (const char *);75 void *emalloc (size_t);65 void Main_ParseArgLine __P((char *)); 66 int main __P((int, char **)); 67 char *Cmd_Exec __P((char *, char **)); 68 void Error __P((char *, ...)); 69 void Fatal __P((char *, ...)); 70 void Punt __P((char *, ...)); 71 void DieHorribly __P((void)); 72 int PrintAddr __P((ClientData, ClientData)); 73 void Finish __P((int)); 74 char *estrdup __P((const char *)); 75 void *emalloc __P((size_t)); 76 76 /* efree(x) works when x==NULL. STDC behavior, may need some different 77 77 * definition for cross-builds on deficient systems */ 78 #define 79 void *erealloc (void *, size_t);80 void enomem (void);81 int eunlink (const char *);78 #define efree free 79 void *erealloc __P((void *, size_t)); 80 void enomem __P((void)); 81 int eunlink __P((const char *)); 82 82 83 83 /* parse.c */ 84 void Parse_Error (int, const char *, ...);85 Boolean Parse_AnyExport (void);86 Boolean Parse_IsVar (char *);87 void Parse_DoVar (char *, GNode *);88 void Parse_AddIncludeDir (char *);89 void Parse_File (char *, FILE *);90 void Parse_Init (void);91 void Parse_End (void);92 void Parse_FromString (char *);93 Lst Parse_MainName (void);84 void Parse_Error __P((int, char *, ...)); 85 Boolean Parse_AnyExport __P((void)); 86 Boolean Parse_IsVar __P((char *)); 87 void Parse_DoVar __P((char *, GNode *)); 88 void Parse_AddIncludeDir __P((char *)); 89 void Parse_File __P((char *, FILE *)); 90 void Parse_Init __P((void)); 91 void Parse_End __P((void)); 92 void Parse_FromString __P((char *)); 93 Lst Parse_MainName __P((void)); 94 94 95 95 /* str.c */ 96 void str_init (void);97 void str_end (void);98 char *str_concat (char *, char *, int);99 char **brk_string (char *, int *, Boolean);100 char *Str_FindSubstring (char *, char *);101 int Str_Match (char *, char *);102 char *Str_SYSVMatch (char *, char *, int *len);103 void Str_SYSVSubst (Buffer, char *, char *, int);96 void str_init __P((void)); 97 void str_end __P((void)); 98 char *str_concat __P((char *, char *, int)); 99 char **brk_string __P((char *, int *, Boolean)); 100 char *Str_FindSubstring __P((char *, char *)); 101 int Str_Match __P((char *, char *)); 102 char *Str_SYSVMatch __P((char *, char *, int *len)); 103 void Str_SYSVSubst __P((Buffer, char *, char *, int)); 104 104 105 105 /* suff.c */ 106 void Suff_ClearSuffixes (void);107 Boolean Suff_IsTransform (char *);108 GNode *Suff_AddTransform (char *);109 int Suff_EndTransform (void *, void *);110 void Suff_AddSuffix (char *);111 Lst Suff_GetPath (char *);112 void Suff_DoPaths (void);113 void Suff_AddInclude (char *);114 void Suff_AddLib (char *);115 void Suff_FindDeps (GNode *);116 void Suff_SetNull (char *);117 void Suff_Init (void);118 void Suff_End (void);119 void Suff_PrintAll (void);106 void Suff_ClearSuffixes __P((void)); 107 Boolean Suff_IsTransform __P((char *)); 108 GNode *Suff_AddTransform __P((char *)); 109 int Suff_EndTransform __P((ClientData, ClientData)); 110 void Suff_AddSuffix __P((char *)); 111 Lst Suff_GetPath __P((char *)); 112 void Suff_DoPaths __P((void)); 113 void Suff_AddInclude __P((char *)); 114 void Suff_AddLib __P((char *)); 115 void Suff_FindDeps __P((GNode *)); 116 void Suff_SetNull __P((char *)); 117 void Suff_Init __P((void)); 118 void Suff_End __P((void)); 119 void Suff_PrintAll __P((void)); 120 120 121 121 /* targ.c */ 122 void Targ_Init (void);123 void Targ_End (void);124 GNode *Targ_NewGN (char *);125 GNode *Targ_FindNode (char *, int);126 Lst Targ_FindList (Lst, int);127 Boolean Targ_Ignore (GNode *);128 Boolean Targ_Silent (GNode *);129 Boolean Targ_Precious (GNode *);130 void Targ_SetMain (GNode *);131 int Targ_PrintCmd (void *, void *);132 char *Targ_FmtTime (time_t);133 void Targ_PrintType (int);134 void Targ_PrintGraph (int);122 void Targ_Init __P((void)); 123 void Targ_End __P((void)); 124 GNode *Targ_NewGN __P((char *)); 125 GNode *Targ_FindNode __P((char *, int)); 126 Lst Targ_FindList __P((Lst, int)); 127 Boolean Targ_Ignore __P((GNode *)); 128 Boolean Targ_Silent __P((GNode *)); 129 Boolean Targ_Precious __P((GNode *)); 130 void Targ_SetMain __P((GNode *)); 131 int Targ_PrintCmd __P((ClientData, ClientData)); 132 char *Targ_FmtTime __P((time_t)); 133 void Targ_PrintType __P((int)); 134 void Targ_PrintGraph __P((int)); 135 135 136 136 /* var.c */ 137 void Var_Delete (char *, GNode *);138 void Var_Set (char *, char *, GNode *);139 void Var_Append (char *, char *, GNode *);140 Boolean Var_Exists (char *, GNode *);141 char *Var_Value (char *, GNode *, char **);142 char *Var_Parse (char *, GNode *, Boolean, int *, Boolean *);143 char *Var_Subst (char *, char *, GNode *, Boolean);144 char *Var_GetTail (char *);145 char *Var_GetHead (char *);146 void Var_Init (void);147 void Var_End (void);148 void Var_Dump (GNode *);137 void Var_Delete __P((char *, GNode *)); 138 void Var_Set __P((char *, char *, GNode *)); 139 void Var_Append __P((char *, char *, GNode *)); 140 Boolean Var_Exists __P((char *, GNode *)); 141 char *Var_Value __P((char *, GNode *, char **)); 142 char *Var_Parse __P((char *, GNode *, Boolean, int *, Boolean *)); 143 char *Var_Subst __P((char *, char *, GNode *, Boolean)); 144 char *Var_GetTail __P((char *)); 145 char *Var_GetHead __P((char *)); 146 void Var_Init __P((void)); 147 void Var_End __P((void)); 148 void Var_Dump __P((GNode *)); -
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 } -
branches/FREEBSD/src/kmk/pathnames.h
r10 r24 31 31 * SUCH DAMAGE. 32 32 * 33 * @(#)pathnames.h 8.2 (Berkeley) 4/28/9534 * $FreeBSD: src/usr.bin/make/pathnames.h,v 1. 12 2002/05/24 15:51:27 ruExp $33 * from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90 34 * $FreeBSD: src/usr.bin/make/pathnames.h,v 1.9 1999/08/28 01:03:36 peter Exp $ 35 35 */ 36 36 -
branches/FREEBSD/src/kmk/sprite.h
r10 r24 36 36 * SUCH DAMAGE. 37 37 * 38 * @(#)sprite.h 8.2 (Berkeley) 4/28/9539 * $FreeBSD: src/usr.bin/make/sprite.h,v 1. 13 2002/09/17 21:29:06 jmallettExp $38 * from: @(#)sprite.h 8.1 (Berkeley) 6/6/93 39 * $FreeBSD: src/usr.bin/make/sprite.h,v 1.9 1999/08/28 01:03:36 peter Exp $ 40 40 */ 41 41 … … 47 47 48 48 #ifndef _SPRITE 49 #define _SPRITE 49 #define _SPRITE 50 50 51 51 52 /* … … 56 57 typedef int Boolean; 57 58 #ifndef TRUE 58 #define 59 #define TRUE 1 59 60 #endif /* TRUE */ 60 61 #ifndef FALSE 61 #define 62 #define FALSE 0 62 63 #endif /* FALSE */ 64 65 /* 66 * Functions that must return a status can return a ReturnStatus to 67 * indicate success or type of failure. 68 */ 63 69 64 70 typedef int ReturnStatus; 65 71 66 #define SUCCESS 0 67 #define FAILURE 1 72 /* 73 * The following statuses overlap with the first 2 generic statuses 74 * defined in status.h: 75 * 76 * SUCCESS There was no error. 77 * FAILURE There was a general error. 78 */ 79 80 #define SUCCESS 0x00000000 81 #define FAILURE 0x00000001 82 83 84 /* 85 * A nil pointer must be something that will cause an exception if 86 * referenced. There are two nils: the kernels nil and the nil used 87 * by user processes. 88 */ 89 90 #define NIL ~0 91 #define USER_NIL 0 92 #ifndef NULL 93 #define NULL 0 94 #endif /* NULL */ 95 96 /* 97 * An address is just a pointer in C. It is defined as a character pointer 98 * so that address arithmetic will work properly, a byte at a time. 99 */ 100 101 typedef char *Address; 102 103 /* 104 * ClientData is an uninterpreted word. It is defined as an int so that 105 * kdbx will not interpret client data as a string. Unlike an "Address", 106 * client data will generally not be used in arithmetic. 107 * But we don't have kdbx anymore so we define it as void (christos) 108 */ 109 110 typedef void *ClientData; 68 111 69 112 #endif /* _SPRITE */ -
branches/FREEBSD/src/kmk/str.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 * @(#)str.c 5.8 (Berkeley) 6/1/90 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/str.c,v 1.25 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/str.c,v 1.12.2.1 2002/06/17 04:30:48 jmallett Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 #include "make.h" … … 53 57 */ 54 58 void 55 str_init( void)59 str_init() 56 60 { 57 61 char *p1; … … 67 71 */ 68 72 void 69 str_end( void)73 str_end() 70 74 { 71 75 if (argv) { 72 76 if (argv[0]) 73 77 free(argv[0]); 74 free( argv);78 free((Address) argv); 75 79 } 76 80 if (buffer) … … 87 91 */ 88 92 char * 89 str_concat(char *s1, char *s2, int flags) 90 { 91 int len1, len2; 92 char *result; 93 str_concat(s1, s2, flags) 94 char *s1, *s2; 95 int flags; 96 { 97 register int len1, len2; 98 register char *result; 93 99 94 100 /* get the length of both strings */ … … 116 122 /* free original strings */ 117 123 if (flags & STR_DOFREE) { 118 (void) efree(s1);119 (void) efree(s2);124 (void)free(s1); 125 (void)free(s2); 120 126 } 121 127 return(result); … … 133 139 */ 134 140 char ** 135 brk_string(char *str, int *store_argc, Boolean expand) 136 { 137 int argc, ch; 138 char inquote, *p, *start, *t; 141 brk_string(str, store_argc, expand) 142 register char *str; 143 int *store_argc; 144 Boolean expand; 145 { 146 register int argc, ch; 147 register char inquote, *p, *start, *t; 139 148 int len; 140 149 … … 237 246 ch = '\t'; 238 247 break; 239 default: 240 break; 241 } 242 break; 243 default: 248 } 244 249 break; 245 250 } … … 262 267 * 263 268 * Side effects: None. 264 *265 * XXX should be strstr(3).266 269 */ 267 270 char * 268 Str_FindSubstring(char *string, char *substring) 269 { 270 char *a, *b; 271 Str_FindSubstring(string, substring) 272 register char *string; /* String to search. */ 273 char *substring; /* Substring to find in string */ 274 { 275 register char *a, *b; 271 276 272 277 /* … … 303 308 */ 304 309 int 305 Str_Match(char *string, char *pattern) 310 Str_Match(string, pattern) 311 register char *string; /* String */ 312 register char *pattern; /* Pattern */ 306 313 { 307 314 char c2; … … 406 413 */ 407 414 char * 408 Str_SYSVMatch(char *word, char *pattern, int *len) 415 Str_SYSVMatch(word, pattern, len) 416 char *word; /* Word to examine */ 417 char *pattern; /* Pattern to examine against */ 418 int *len; /* Number of characters to substitute */ 409 419 { 410 420 char *p = pattern; … … 469 479 */ 470 480 void 471 Str_SYSVSubst(Buffer buf, char *pat, char *src, int len) 481 Str_SYSVSubst(buf, pat, src, len) 482 Buffer buf; 483 char *pat; 484 char *src; 485 int len; 472 486 { 473 487 char *m; -
branches/FREEBSD/src/kmk/suff.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 * @(#)suff.c 8.4 (Berkeley) 3/21/94 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/suff.c,v 1.26 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/suff.c,v 1.12.2.1 2001/03/09 01:13:24 tmm Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 /*- … … 89 93 * Suff_FindDeps Find implicit sources for and the location of 90 94 * a target based on its suffix. Returns the 91 * bottom-most node added to the graph or N ULL95 * bottom-most node added to the graph or NILGNODE 92 96 * if the target had no implicit sources. 93 97 */ … … 112 116 int nameLen; /* Length of the suffix */ 113 117 short flags; /* Type of suffix */ 114 #define 115 #define 116 #define 118 #define SUFF_INCLUDE 0x01 /* One which is #include'd */ 119 #define SUFF_LIBRARY 0x02 /* One which contains a library */ 120 #define SUFF_NULL 0x04 /* The empty suffix */ 117 121 Lst searchPath; /* The path along which files of this suffix 118 122 * may be found */ … … 154 158 155 159 156 static char *SuffStrIsPrefix (char *, char *);157 static char *SuffSuffIsSuffix (Suff *, char *);158 static int SuffSuffIsSuffixP (void *, void *);159 static int SuffSuffHasNameP (void *, void *);160 static int SuffSuffIsPrefix (void *, void *);161 static int SuffGNHasNameP (void *, void *);162 static void SuffFree (void *);163 static void SuffInsert (Lst, Suff *);164 static void SuffRemove (Lst, Suff *);165 static Boolean SuffParseTransform (char *, Suff **, Suff **);166 static int SuffRebuildGraph (void *, void *);167 static int SuffAddSrc (void *, void *);168 static int SuffRemoveSrc (Lst);169 static void SuffAddLevel (Lst, Src *);170 static Src *SuffFindThem (Lst, Lst);171 static Src *SuffFindCmds (Src *, Lst);172 static int SuffExpandChildren (void *, void *);173 static Boolean SuffApplyTransform (GNode *, GNode *, Suff *, Suff *);174 static void SuffFindDeps (GNode *, Lst);175 static void SuffFindArchiveDeps (GNode *, Lst);176 static void SuffFindNormalDeps (GNode *, Lst);177 static int SuffPrintName (void *, void *);178 static int SuffPrintSuff (void *, void *);179 static int SuffPrintTrans (void *, void *);160 static char *SuffStrIsPrefix __P((char *, char *)); 161 static char *SuffSuffIsSuffix __P((Suff *, char *)); 162 static int SuffSuffIsSuffixP __P((ClientData, ClientData)); 163 static int SuffSuffHasNameP __P((ClientData, ClientData)); 164 static int SuffSuffIsPrefix __P((ClientData, ClientData)); 165 static int SuffGNHasNameP __P((ClientData, ClientData)); 166 static void SuffFree __P((ClientData)); 167 static void SuffInsert __P((Lst, Suff *)); 168 static void SuffRemove __P((Lst, Suff *)); 169 static Boolean SuffParseTransform __P((char *, Suff **, Suff **)); 170 static int SuffRebuildGraph __P((ClientData, ClientData)); 171 static int SuffAddSrc __P((ClientData, ClientData)); 172 static int SuffRemoveSrc __P((Lst)); 173 static void SuffAddLevel __P((Lst, Src *)); 174 static Src *SuffFindThem __P((Lst, Lst)); 175 static Src *SuffFindCmds __P((Src *, Lst)); 176 static int SuffExpandChildren __P((ClientData, ClientData)); 177 static Boolean SuffApplyTransform __P((GNode *, GNode *, Suff *, Suff *)); 178 static void SuffFindDeps __P((GNode *, Lst)); 179 static void SuffFindArchiveDeps __P((GNode *, Lst)); 180 static void SuffFindNormalDeps __P((GNode *, Lst)); 181 static int SuffPrintName __P((ClientData, ClientData)); 182 static int SuffPrintSuff __P((ClientData, ClientData)); 183 static int SuffPrintTrans __P((ClientData, ClientData)); 180 184 181 185 /*************** Lst Predicates ****************/ … … 193 197 */ 194 198 static char * 195 SuffStrIsPrefix (char *pref, char *str) 199 SuffStrIsPrefix (pref, str) 200 register char *pref; /* possible prefix */ 201 register char *str; /* string to check */ 196 202 { 197 203 while (*str && *pref == *str) { … … 218 224 */ 219 225 static char * 220 SuffSuffIsSuffix (Suff *s, char *str) 221 { 222 char *p1; /* Pointer into suffix name */ 223 char *p2; /* Pointer into string being examined */ 226 SuffSuffIsSuffix (s, str) 227 register Suff *s; /* possible suffix */ 228 char *str; /* string to examine */ 229 { 230 register char *p1; /* Pointer into suffix name */ 231 register char *p2; /* Pointer into string being examined */ 224 232 225 233 p1 = s->name + s->nameLen; … … 249 257 */ 250 258 static int 251 SuffSuffIsSuffixP(void *s, void *str) 259 SuffSuffIsSuffixP(s, str) 260 ClientData s; 261 ClientData str; 252 262 { 253 263 return(!SuffSuffIsSuffix((Suff *) s, (char *) str)); … … 268 278 */ 269 279 static int 270 SuffSuffHasNameP (void *s, void *sname) 280 SuffSuffHasNameP (s, sname) 281 ClientData s; /* Suffix to check */ 282 ClientData sname; /* Desired name */ 271 283 { 272 284 return (strcmp ((char *) sname, ((Suff *) s)->name)); … … 289 301 */ 290 302 static int 291 SuffSuffIsPrefix (void *s, void *str) 303 SuffSuffIsPrefix (s, str) 304 ClientData s; /* suffix to compare */ 305 ClientData str; /* string to examine */ 292 306 { 293 307 return (SuffStrIsPrefix (((Suff *) s)->name, (char *) str) == NULL ? 1 : 0); … … 307 321 */ 308 322 static int 309 SuffGNHasNameP (void *gn, void *name) 323 SuffGNHasNameP (gn, name) 324 ClientData gn; /* current node we're looking at */ 325 ClientData name; /* name we're looking for */ 310 326 { 311 327 return (strcmp ((char *) name, ((GNode *) gn)->name)); … … 327 343 */ 328 344 static void 329 SuffFree (void *sp) 345 SuffFree (sp) 346 ClientData sp; 330 347 { 331 348 Suff *s = (Suff *) sp; … … 342 359 Lst_Destroy (s->searchPath, Dir_Destroy); 343 360 344 free ( s->name);345 free ( s);361 free ((Address)s->name); 362 free ((Address)s); 346 363 } 347 364 … … 359 376 */ 360 377 static void 361 SuffRemove(Lst l, Suff *s) 362 { 363 LstNode ln = Lst_Member(l, (void *)s); 364 if (ln != NULL) { 378 SuffRemove(l, s) 379 Lst l; 380 Suff *s; 381 { 382 LstNode ln = Lst_Member(l, (ClientData)s); 383 if (ln != NILLNODE) { 365 384 Lst_Remove(l, ln); 366 385 s->refCount--; … … 383 402 */ 384 403 static void 385 SuffInsert (Lst l, Suff *s) 404 SuffInsert (l, s) 405 Lst l; /* the list where in s should be inserted */ 406 Suff *s; /* the suffix to insert */ 386 407 { 387 408 LstNode ln; /* current element in l we're examining */ … … 391 412 return; 392 413 } 393 while ((ln = Lst_Next (l)) != N ULL) {414 while ((ln = Lst_Next (l)) != NILLNODE) { 394 415 s2 = (Suff *) Lst_Datum (ln); 395 416 if (s2->sNum >= s->sNum) { … … 397 418 } 398 419 } 399 if (s2 == NULL) {400 DEBUGF(SUFF, ("inserting an empty list?..."));401 }402 420 403 421 Lst_Close (l); 404 DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum)); 405 if (ln == NULL) { 406 DEBUGF(SUFF, ("at end of list\n")); 407 (void)Lst_AtEnd (l, (void *)s); 422 if (DEBUG(SUFF)) { 423 printf("inserting %s(%d)...", s->name, s->sNum); 424 } 425 if (ln == NILLNODE) { 426 if (DEBUG(SUFF)) { 427 printf("at end of list\n"); 428 } 429 (void)Lst_AtEnd (l, (ClientData)s); 408 430 s->refCount++; 409 (void)Lst_AtEnd(s->ref, ( void *) l);431 (void)Lst_AtEnd(s->ref, (ClientData) l); 410 432 } else if (s2->sNum != s->sNum) { 411 DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum)); 412 (void)Lst_Insert (l, ln, (void *)s); 433 if (DEBUG(SUFF)) { 434 printf("before %s(%d)\n", s2->name, s2->sNum); 435 } 436 (void)Lst_Insert (l, ln, (ClientData)s); 413 437 s->refCount++; 414 (void)Lst_AtEnd(s->ref, ( void *) l);415 } else {416 DEBUGF(SUFF, ("already there\n"));438 (void)Lst_AtEnd(s->ref, (ClientData) l); 439 } else if (DEBUG(SUFF)) { 440 printf("already there\n"); 417 441 } 418 442 } … … 436 460 */ 437 461 void 438 Suff_ClearSuffixes ( void)462 Suff_ClearSuffixes () 439 463 { 440 464 Lst_Concat (suffClean, sufflist, LST_CONCLINK); … … 448 472 * suffNull should not have parents. 449 473 */ 450 Lst_Destroy(suffNull->children, NOFREE); 474 Lst_Destroy(suffNull->children, NOFREE); 451 475 suffNull->children = Lst_Init(FALSE); 452 476 } … … 466 490 */ 467 491 static Boolean 468 SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr) 469 { 470 LstNode srcLn; /* element in suffix list of trans source*/ 471 Suff *src; /* Source of transformation */ 472 LstNode targLn; /* element in suffix list of trans target*/ 473 char *str2; /* Extra pointer (maybe target suffix) */ 492 SuffParseTransform(str, srcPtr, targPtr) 493 char *str; /* String being parsed */ 494 Suff **srcPtr; /* Place to store source of trans. */ 495 Suff **targPtr; /* Place to store target of trans. */ 496 { 497 register LstNode srcLn; /* element in suffix list of trans source*/ 498 register Suff *src; /* Source of transformation */ 499 register LstNode targLn; /* element in suffix list of trans target*/ 500 register char *str2; /* Extra pointer (maybe target suffix) */ 474 501 LstNode singleLn; /* element in suffix list of any suffix 475 502 * that exactly matches str */ … … 477 504 * null suffix */ 478 505 479 srcLn = N ULL;480 singleLn = N ULL;506 srcLn = NILLNODE; 507 singleLn = NILLNODE; 481 508 482 509 /* … … 487 514 */ 488 515 for (;;) { 489 if (srcLn == N ULL) {490 srcLn = Lst_Find(sufflist, ( void *)str, SuffSuffIsPrefix);516 if (srcLn == NILLNODE) { 517 srcLn = Lst_Find(sufflist, (ClientData)str, SuffSuffIsPrefix); 491 518 } else { 492 srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), ( void *)str,519 srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (ClientData)str, 493 520 SuffSuffIsPrefix); 494 521 } 495 if (srcLn == N ULL) {522 if (srcLn == NILLNODE) { 496 523 /* 497 524 * Ran out of source suffixes -- no such rule 498 525 */ 499 if (singleLn != N ULL) {526 if (singleLn != NILLNODE) { 500 527 /* 501 528 * Not so fast Mr. Smith! There was a suffix that encompassed … … 519 546 singleLn = srcLn; 520 547 } else { 521 targLn = Lst_Find(sufflist, ( void *)str2, SuffSuffHasNameP);522 if (targLn != N ULL) {548 targLn = Lst_Find(sufflist, (ClientData)str2, SuffSuffHasNameP); 549 if (targLn != NILLNODE) { 523 550 *srcPtr = src; 524 551 *targPtr = (Suff *)Lst_Datum(targLn); … … 544 571 */ 545 572 Boolean 546 Suff_IsTransform (char *str) 573 Suff_IsTransform (str) 574 char *str; /* string to check */ 547 575 { 548 576 Suff *src, *targ; … … 566 594 */ 567 595 GNode * 568 Suff_AddTransform (char *line) 596 Suff_AddTransform (line) 597 char *line; /* name of transformation to add */ 569 598 { 570 599 GNode *gn; /* GNode of transformation rule */ … … 573 602 LstNode ln; /* Node for existing transformation */ 574 603 575 ln = Lst_Find (transforms, ( void *)line, SuffGNHasNameP);576 if (ln == N ULL) {604 ln = Lst_Find (transforms, (ClientData)line, SuffGNHasNameP); 605 if (ln == NILLNODE) { 577 606 /* 578 607 * Make a new graph node for the transformation. It will be filled in … … 580 609 */ 581 610 gn = Targ_NewGN (line); 582 (void)Lst_AtEnd (transforms, ( void *)gn);611 (void)Lst_AtEnd (transforms, (ClientData)gn); 583 612 } else { 584 613 /* … … 602 631 * link the two together in the proper relationship and order 603 632 */ 604 DEBUGF(SUFF, ("defining transformation from `%s' to `%s'\n", 605 s->name, t->name)); 633 if (DEBUG(SUFF)) { 634 printf("defining transformation from `%s' to `%s'\n", 635 s->name, t->name); 636 } 606 637 SuffInsert (t->children, s); 607 638 SuffInsert (s->parents, t); … … 628 659 */ 629 660 int 630 Suff_EndTransform(void *gnp, void *dummy __unused) 661 Suff_EndTransform(gnp, dummy) 662 ClientData gnp; /* Node for transformation */ 663 ClientData dummy; /* Node for transformation */ 631 664 { 632 665 GNode *gn = (GNode *) gnp; … … 639 672 (void)SuffParseTransform(gn->name, &s, &t); 640 673 641 DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n", 642 s->name, t->name)); 674 if (DEBUG(SUFF)) { 675 printf("deleting transformation from `%s' to `%s'\n", 676 s->name, t->name); 677 } 643 678 644 679 /* 645 680 * Remove the source from the target's children list. We check for a 646 * NULLreturn to handle a beanhead saying something like681 * nil return to handle a beanhead saying something like 647 682 * .c.o .c.o: 648 683 * … … 656 691 */ 657 692 SuffRemove(s->parents, t); 658 } else if ( gn->type & OP_TRANSFORM) {659 DEBUGF(SUFF, ("transformation %s complete\n", gn->name));660 } 661 662 return (0);693 } else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) { 694 printf("transformation %s complete\n", gn->name); 695 } 696 697 return(dummy ? 0 : 0); 663 698 } 664 699 … … 683 718 */ 684 719 static int 685 SuffRebuildGraph(void *transformp, void *sp) 720 SuffRebuildGraph(transformp, sp) 721 ClientData transformp; /* Transformation to test */ 722 ClientData sp; /* Suffix to rebuild */ 686 723 { 687 724 GNode *transform = (GNode *) transformp; … … 696 733 cp = SuffStrIsPrefix(s->name, transform->name); 697 734 if (cp != (char *)NULL) { 698 735 if (cp[0] == '\0') /* null rule */ 699 736 s2 = suffNull; 700 737 else { 701 ln = Lst_Find(sufflist, ( void *)cp, SuffSuffHasNameP);702 if (ln != N ULL)703 738 ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffHasNameP); 739 if (ln != NILLNODE) 740 s2 = (Suff *)Lst_Datum(ln); 704 741 } 705 742 if (s2 != NULL) { … … 723 760 */ 724 761 cp[1] = '\0'; 725 ln = Lst_Find(sufflist, ( void *)transform->name, SuffSuffHasNameP);762 ln = Lst_Find(sufflist, (ClientData)transform->name, SuffSuffHasNameP); 726 763 /* 727 764 * Replace the start of the target suffix 728 765 */ 729 766 cp[1] = s->name[0]; 730 if (ln != N ULL) {767 if (ln != NILLNODE) { 731 768 /* 732 769 * Found it -- establish the proper relationship … … 755 792 */ 756 793 void 757 Suff_AddSuffix (char *str) 794 Suff_AddSuffix (str) 795 char *str; /* the name of the suffix to add */ 758 796 { 759 797 Suff *s; /* new suffix descriptor */ 760 798 LstNode ln; 761 799 762 ln = Lst_Find (sufflist, ( void *)str, SuffSuffHasNameP);763 if (ln == N ULL) {800 ln = Lst_Find (sufflist, (ClientData)str, SuffSuffHasNameP); 801 if (ln == NILLNODE) { 764 802 s = (Suff *) emalloc (sizeof (Suff)); 765 803 … … 774 812 s->refCount = 0; 775 813 776 (void)Lst_AtEnd (sufflist, ( void *)s);814 (void)Lst_AtEnd (sufflist, (ClientData)s); 777 815 /* 778 816 * Look for any existing transformations from or to this suffix. 779 817 * XXX: Only do this after a Suff_ClearSuffixes? 780 818 */ 781 Lst_ForEach (transforms, SuffRebuildGraph, ( void *)s);819 Lst_ForEach (transforms, SuffRebuildGraph, (ClientData)s); 782 820 } 783 821 } … … 789 827 * 790 828 * Results: 791 * The searchPath for the desired suffix or N ULLif the suffix isn't829 * The searchPath for the desired suffix or NILLST if the suffix isn't 792 830 * defined. 793 831 * … … 797 835 */ 798 836 Lst 799 Suff_GetPath (char *sname) 837 Suff_GetPath (sname) 838 char *sname; 800 839 { 801 840 LstNode ln; 802 841 Suff *s; 803 842 804 ln = Lst_Find (sufflist, ( void *)sname, SuffSuffHasNameP);805 if (ln == N ULL) {806 return (N ULL);843 ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); 844 if (ln == NILLNODE) { 845 return (NILLST); 807 846 } else { 808 847 s = (Suff *) Lst_Datum (ln); … … 824 863 * directories in dirSearchPath. If paths were specified for the 825 864 * ".h" suffix, the directories are stuffed into a global variable 826 * called ".INCLUDES" with each directory prece ded by a -I. The same865 * called ".INCLUDES" with each directory preceeded by a -I. The same 827 866 * is done for the ".a" suffix, except the variable is called 828 867 * ".LIBS" and the flag is -L. … … 830 869 */ 831 870 void 832 Suff_DoPaths( void)833 { 834 Suff*s;835 LstNodeln;871 Suff_DoPaths() 872 { 873 register Suff *s; 874 register LstNode ln; 836 875 char *ptr; 837 876 Lst inIncludes; /* Cumulative .INCLUDES path */ … … 845 884 inLibs = Lst_Init(FALSE); 846 885 847 while ((ln = Lst_Next (sufflist)) != N ULL) {886 while ((ln = Lst_Next (sufflist)) != NILLNODE) { 848 887 s = (Suff *) Lst_Datum (ln); 849 888 if (!Lst_IsEmpty (s->searchPath)) { … … 892 931 */ 893 932 void 894 Suff_AddInclude (char *sname) 933 Suff_AddInclude (sname) 934 char *sname; /* Name of suffix to mark */ 895 935 { 896 936 LstNode ln; 897 937 Suff *s; 898 938 899 ln = Lst_Find (sufflist, ( void *)sname, SuffSuffHasNameP);900 if (ln != N ULL) {939 ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); 940 if (ln != NILLNODE) { 901 941 s = (Suff *) Lst_Datum (ln); 902 942 s->flags |= SUFF_INCLUDE; … … 921 961 */ 922 962 void 923 Suff_AddLib (char *sname) 963 Suff_AddLib (sname) 964 char *sname; /* Name of suffix to mark */ 924 965 { 925 966 LstNode ln; 926 967 Suff *s; 927 968 928 ln = Lst_Find (sufflist, ( void *)sname, SuffSuffHasNameP);929 if (ln != N ULL) {969 ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); 970 if (ln != NILLNODE) { 930 971 s = (Suff *) Lst_Datum (ln); 931 972 s->flags |= SUFF_LIBRARY; … … 950 991 */ 951 992 static int 952 SuffAddSrc (void *sp, void *lsp) 993 SuffAddSrc (sp, lsp) 994 ClientData sp; /* suffix for which to create a Src structure */ 995 ClientData lsp; /* list and parent for the new Src */ 953 996 { 954 997 Suff *s = (Suff *) sp; … … 969 1012 s2->pref = targ->pref; 970 1013 s2->parent = targ; 971 s2->node = N ULL;1014 s2->node = NILGNODE; 972 1015 s2->suff = s; 973 1016 s->refCount++; 974 1017 s2->children = 0; 975 1018 targ->children += 1; 976 (void)Lst_AtEnd (ls->l, ( void *)s2);1019 (void)Lst_AtEnd (ls->l, (ClientData)s2); 977 1020 #ifdef DEBUG_SRC 978 1021 s2->cp = Lst_Init(FALSE); 979 Lst_AtEnd(targ->cp, ( void *) s2);1022 Lst_AtEnd(targ->cp, (ClientData) s2); 980 1023 printf("1 add %x %x to %x:", targ, s2, ls->l); 981 Lst_ForEach(ls->l, PrintAddr, ( void *) 0);1024 Lst_ForEach(ls->l, PrintAddr, (ClientData) 0); 982 1025 printf("\n"); 983 1026 #endif … … 987 1030 s2->pref = targ->pref; 988 1031 s2->parent = targ; 989 s2->node = N ULL;1032 s2->node = NILGNODE; 990 1033 s2->suff = s; 991 1034 s->refCount++; 992 1035 s2->children = 0; 993 1036 targ->children += 1; 994 (void)Lst_AtEnd (ls->l, ( void *)s2);1037 (void)Lst_AtEnd (ls->l, (ClientData)s2); 995 1038 #ifdef DEBUG_SRC 996 1039 s2->cp = Lst_Init(FALSE); 997 Lst_AtEnd(targ->cp, ( void *) s2);1040 Lst_AtEnd(targ->cp, (ClientData) s2); 998 1041 printf("2 add %x %x to %x:", targ, s2, ls->l); 999 Lst_ForEach(ls->l, PrintAddr, ( void *) 0);1042 Lst_ForEach(ls->l, PrintAddr, (ClientData) 0); 1000 1043 printf("\n"); 1001 1044 #endif … … 1017 1060 */ 1018 1061 static void 1019 SuffAddLevel (Lst l, Src *targ) 1062 SuffAddLevel (l, targ) 1063 Lst l; /* list to which to add the new level */ 1064 Src *targ; /* Src structure to use as the parent */ 1020 1065 { 1021 1066 LstSrc ls; … … 1024 1069 ls.l = l; 1025 1070 1026 Lst_ForEach (targ->suff->children, SuffAddSrc, ( void *)&ls);1071 Lst_ForEach (targ->suff->children, SuffAddSrc, (ClientData)&ls); 1027 1072 } 1028 1073 … … 1040 1085 */ 1041 1086 static int 1042 SuffRemoveSrc (Lst l) 1087 SuffRemoveSrc (l) 1088 Lst l; 1043 1089 { 1044 1090 LstNode ln; … … 1051 1097 #ifdef DEBUG_SRC 1052 1098 printf("cleaning %lx: ", (unsigned long) l); 1053 Lst_ForEach(l, PrintAddr, ( void *) 0);1099 Lst_ForEach(l, PrintAddr, (ClientData) 0); 1054 1100 printf("\n"); 1055 1101 #endif 1056 1102 1057 1103 1058 while ((ln = Lst_Next (l)) != N ULL) {1104 while ((ln = Lst_Next (l)) != NILLNODE) { 1059 1105 s = (Src *) Lst_Datum (ln); 1060 1106 if (s->children == 0) { 1061 free ( s->file);1107 free ((Address)s->file); 1062 1108 if (!s->parent) 1063 free( s->pref);1109 free((Address)s->pref); 1064 1110 else { 1065 1111 #ifdef DEBUG_SRC 1066 LstNode ln = Lst_Member(s->parent->cp, ( void *)s);1067 if (ln != N ULL)1112 LstNode ln = Lst_Member(s->parent->cp, (ClientData)s); 1113 if (ln != NILLNODE) 1068 1114 Lst_Remove(s->parent->cp, ln); 1069 1115 #endif … … 1075 1121 #endif 1076 1122 Lst_Remove(l, ln); 1077 free ( s);1123 free ((Address)s); 1078 1124 t |= 1; 1079 1125 Lst_Close(l); … … 1083 1129 else { 1084 1130 printf("keep: [l=%x] p=%x %d: ", l, s, s->children); 1085 Lst_ForEach(s->cp, PrintAddr, ( void *) 0);1131 Lst_ForEach(s->cp, PrintAddr, (ClientData) 0); 1086 1132 printf("\n"); 1087 1133 } … … 1107 1153 */ 1108 1154 static Src * 1109 SuffFindThem (Lst srcs, Lst slst) 1155 SuffFindThem (srcs, slst) 1156 Lst srcs; /* list of Src structures to search through */ 1157 Lst slst; 1110 1158 { 1111 1159 Src *s; /* current Src */ … … 1118 1166 s = (Src *) Lst_DeQueue (srcs); 1119 1167 1120 DEBUGF(SUFF, ("\ttrying %s...", s->file)); 1168 if (DEBUG(SUFF)) { 1169 printf ("\ttrying %s...", s->file); 1170 } 1121 1171 1122 1172 /* … … 1124 1174 * graph for it or the file actually exists. 1125 1175 */ 1126 if (Targ_FindNode(s->file, TARG_NOCREATE) != N ULL) {1176 if (Targ_FindNode(s->file, TARG_NOCREATE) != NILGNODE) { 1127 1177 #ifdef DEBUG_SRC 1128 1178 printf("remove %x from %x\n", s, srcs); … … 1141 1191 } 1142 1192 1143 DEBUGF(SUFF, ("not there\n")); 1193 if (DEBUG(SUFF)) { 1194 printf ("not there\n"); 1195 } 1144 1196 1145 1197 SuffAddLevel (srcs, s); 1146 Lst_AtEnd(slst, ( void *) s);1147 } 1148 1149 if ( rs) {1150 DEBUGF(SUFF, ("got it\n"));1198 Lst_AtEnd(slst, (ClientData) s); 1199 } 1200 1201 if (DEBUG(SUFF) && rs) { 1202 printf ("got it\n"); 1151 1203 } 1152 1204 return (rs); … … 1161 1213 * 1162 1214 * Results: 1163 * The Src structure of the "winning" child, or N ULL if no such beast.1215 * The Src structure of the "winning" child, or NIL if no such beast. 1164 1216 * 1165 1217 * Side Effects: … … 1169 1221 */ 1170 1222 static Src * 1171 SuffFindCmds (Src *targ, Lst slst) 1223 SuffFindCmds (targ, slst) 1224 Src *targ; /* Src structure to play with */ 1225 Lst slst; 1172 1226 { 1173 1227 LstNode ln; /* General-purpose list node */ 1174 GNode*t, /* Target GNode */1228 register GNode *t, /* Target GNode */ 1175 1229 *s; /* Source GNode */ 1176 1230 int prefLen;/* The length of the defined prefix */ … … 1183 1237 prefLen = strlen (targ->pref); 1184 1238 1185 while ((ln = Lst_Next (t->children)) != N ULL) {1239 while ((ln = Lst_Next (t->children)) != NILLNODE) { 1186 1240 s = (GNode *)Lst_Datum (ln); 1187 1241 … … 1197 1251 * suffix. 1198 1252 */ 1199 ln = Lst_Find (sufflist, ( void *)&cp[prefLen],1253 ln = Lst_Find (sufflist, (ClientData)&cp[prefLen], 1200 1254 SuffSuffHasNameP); 1201 if (ln != N ULL) {1255 if (ln != NILLNODE) { 1202 1256 /* 1203 1257 * It even has a known suffix, see if there's a transformation … … 1209 1263 1210 1264 if (Lst_Member (suff->parents, 1211 ( void *)targ->suff) != NULL)1265 (ClientData)targ->suff) != NILLNODE) 1212 1266 { 1213 1267 /* … … 1229 1283 ret->cp = Lst_Init(FALSE); 1230 1284 printf("3 add %x %x\n", targ, ret); 1231 Lst_AtEnd(targ->cp, ( void *) ret);1285 Lst_AtEnd(targ->cp, (ClientData) ret); 1232 1286 #endif 1233 Lst_AtEnd(slst, (void *) ret); 1234 DEBUGF(SUFF, ("\tusing existing source %s\n", s->name)); 1287 Lst_AtEnd(slst, (ClientData) ret); 1288 if (DEBUG(SUFF)) { 1289 printf ("\tusing existing source %s\n", s->name); 1290 } 1235 1291 return (ret); 1236 1292 } … … 1259 1315 */ 1260 1316 static int 1261 SuffExpandChildren(void *cgnp, void *pgnp) 1317 SuffExpandChildren(cgnp, pgnp) 1318 ClientData cgnp; /* Child to examine */ 1319 ClientData pgnp; /* Parent node being processed */ 1262 1320 { 1263 1321 GNode *cgn = (GNode *) cgnp; … … 1272 1330 * after the child 1273 1331 */ 1274 prevLN = Lst_Member(pgn->children, ( void *)cgn);1332 prevLN = Lst_Member(pgn->children, (ClientData)cgn); 1275 1333 1276 1334 /* … … 1281 1339 */ 1282 1340 if (strchr(cgn->name, '$') != (char *)NULL) { 1283 DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name)); 1341 if (DEBUG(SUFF)) { 1342 printf("Expanding \"%s\"...", cgn->name); 1343 } 1284 1344 cp = Var_Subst(NULL, cgn->name, pgn, TRUE); 1285 1345 … … 1317 1377 *cp++ = '\0'; 1318 1378 gn = Targ_FindNode(start, TARG_CREATE); 1319 (void)Lst_AtEnd(members, ( void *)gn);1379 (void)Lst_AtEnd(members, (ClientData)gn); 1320 1380 while (*cp == ' ' || *cp == '\t') { 1321 1381 cp++; … … 1356 1416 */ 1357 1417 gn = Targ_FindNode(start, TARG_CREATE); 1358 (void)Lst_AtEnd(members, ( void *)gn);1418 (void)Lst_AtEnd(members, (ClientData)gn); 1359 1419 } 1360 1420 /* … … 1370 1430 gn = (GNode *)Lst_DeQueue(members); 1371 1431 1372 DEBUGF(SUFF, ("%s...", gn->name)); 1373 if (Lst_Member(pgn->children, (void *)gn) == NULL) { 1374 (void)Lst_Append(pgn->children, prevLN, (void *)gn); 1432 if (DEBUG(SUFF)) { 1433 printf("%s...", gn->name); 1434 } 1435 if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) { 1436 (void)Lst_Append(pgn->children, prevLN, (ClientData)gn); 1375 1437 prevLN = Lst_Succ(prevLN); 1376 (void)Lst_AtEnd(gn->parents, ( void *)pgn);1438 (void)Lst_AtEnd(gn->parents, (ClientData)pgn); 1377 1439 pgn->unmade++; 1378 1440 } … … 1388 1450 * keep it from being processed. 1389 1451 */ 1390 ln = Lst_Member(pgn->children, ( void *)cgn);1452 ln = Lst_Member(pgn->children, (ClientData)cgn); 1391 1453 pgn->unmade--; 1392 1454 Lst_Remove(pgn->children, ln); 1393 DEBUGF(SUFF, ("\n")); 1455 if (DEBUG(SUFF)) { 1456 printf("\n"); 1457 } 1394 1458 } else if (Dir_HasWildcards(cgn->name)) { 1395 1459 Lst exp; /* List of expansions */ … … 1405 1469 */ 1406 1470 cp = cgn->name + strlen(cgn->name); 1407 ln = Lst_Find(sufflist, (void *)cp, SuffSuffIsSuffixP); 1408 1409 DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name)); 1410 1411 if (ln != NULL) { 1471 ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffIsSuffixP); 1472 1473 if (DEBUG(SUFF)) { 1474 printf("Wildcard expanding \"%s\"...", cgn->name); 1475 } 1476 1477 if (ln != NILLNODE) { 1412 1478 Suff *s = (Suff *)Lst_Datum(ln); 1413 1479 1414 DEBUGF(SUFF, ("suffix is \"%s\"...", s->name)); 1480 if (DEBUG(SUFF)) { 1481 printf("suffix is \"%s\"...", s->name); 1482 } 1415 1483 path = s->searchPath; 1416 1484 } else { … … 1433 1501 cp = (char *)Lst_DeQueue(exp); 1434 1502 1435 DEBUGF(SUFF, ("%s...", cp)); 1503 if (DEBUG(SUFF)) { 1504 printf("%s...", cp); 1505 } 1436 1506 gn = Targ_FindNode(cp, TARG_CREATE); 1437 1507 … … 1440 1510 * up the parent's count of unmade children. 1441 1511 */ 1442 if (Lst_Member(pgn->children, ( void *)gn) == NULL) {1443 (void)Lst_Append(pgn->children, prevLN, ( void *)gn);1512 if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) { 1513 (void)Lst_Append(pgn->children, prevLN, (ClientData)gn); 1444 1514 prevLN = Lst_Succ(prevLN); 1445 (void)Lst_AtEnd(gn->parents, ( void *)pgn);1515 (void)Lst_AtEnd(gn->parents, (ClientData)pgn); 1446 1516 pgn->unmade++; 1447 1517 } … … 1457 1527 * keep it from being processed. 1458 1528 */ 1459 ln = Lst_Member(pgn->children, ( void *)cgn);1529 ln = Lst_Member(pgn->children, (ClientData)cgn); 1460 1530 pgn->unmade--; 1461 1531 Lst_Remove(pgn->children, ln); 1462 DEBUGF(SUFF, ("\n")); 1532 if (DEBUG(SUFF)) { 1533 printf("\n"); 1534 } 1463 1535 } 1464 1536 … … 1485 1557 */ 1486 1558 static Boolean 1487 SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s) 1559 SuffApplyTransform(tGn, sGn, t, s) 1560 GNode *tGn; /* Target node */ 1561 GNode *sGn; /* Source node */ 1562 Suff *t; /* Target suffix */ 1563 Suff *s; /* Source suffix */ 1488 1564 { 1489 1565 LstNode ln; /* General node */ … … 1491 1567 GNode *gn; /* Node for same */ 1492 1568 1493 if (Lst_Member(tGn->children, ( void *)sGn) == NULL) {1569 if (Lst_Member(tGn->children, (ClientData)sGn) == NILLNODE) { 1494 1570 /* 1495 1571 * Not already linked, so form the proper links between the 1496 1572 * target and source. 1497 1573 */ 1498 (void)Lst_AtEnd(tGn->children, ( void *)sGn);1499 (void)Lst_AtEnd(sGn->parents, ( void *)tGn);1574 (void)Lst_AtEnd(tGn->children, (ClientData)sGn); 1575 (void)Lst_AtEnd(sGn->parents, (ClientData)tGn); 1500 1576 tGn->unmade += 1; 1501 1577 } … … 1508 1584 * will be sufficient to get the .IMPSRC variable set for tGn 1509 1585 */ 1510 for (ln=Lst_First(sGn->cohorts); ln != N ULL; ln=Lst_Succ(ln)) {1586 for (ln=Lst_First(sGn->cohorts); ln != NILLNODE; ln=Lst_Succ(ln)) { 1511 1587 gn = (GNode *)Lst_Datum(ln); 1512 1588 1513 if (Lst_Member(tGn->children, ( void *)gn) == NULL) {1589 if (Lst_Member(tGn->children, (ClientData)gn) == NILLNODE) { 1514 1590 /* 1515 1591 * Not already linked, so form the proper links between the 1516 1592 * target and source. 1517 1593 */ 1518 (void)Lst_AtEnd(tGn->children, ( void *)gn);1519 (void)Lst_AtEnd(gn->parents, ( void *)tGn);1594 (void)Lst_AtEnd(tGn->children, (ClientData)gn); 1595 (void)Lst_AtEnd(gn->parents, (ClientData)tGn); 1520 1596 tGn->unmade += 1; 1521 1597 } … … 1526 1602 */ 1527 1603 tname = str_concat(s->name, t->name, 0); 1528 ln = Lst_Find(transforms, ( void *)tname, SuffGNHasNameP);1604 ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP); 1529 1605 free(tname); 1530 1606 1531 if (ln == N ULL) {1607 if (ln == NILLNODE) { 1532 1608 /* 1533 1609 * Not really such a transformation rule (can happen when we're … … 1540 1616 gn = (GNode *)Lst_Datum(ln); 1541 1617 1542 DEBUGF(SUFF, ("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name)); 1618 if (DEBUG(SUFF)) { 1619 printf("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name); 1620 } 1543 1621 1544 1622 /* … … 1556 1634 */ 1557 1635 ln = Lst_Succ(ln); 1558 if (ln != N ULL) {1636 if (ln != NILLNODE) { 1559 1637 Lst_ForEachFrom(tGn->children, ln, 1560 SuffExpandChildren, ( void *)tGn);1638 SuffExpandChildren, (ClientData)tGn); 1561 1639 } 1562 1640 … … 1565 1643 * the .IMPSRC variable can be set correctly for the parent. 1566 1644 */ 1567 (void)Lst_AtEnd(sGn->iParents, ( void *)tGn);1645 (void)Lst_AtEnd(sGn->iParents, (ClientData)tGn); 1568 1646 1569 1647 return(TRUE); … … 1585 1663 */ 1586 1664 static void 1587 SuffFindArchiveDeps(GNode *gn, Lst slst) 1665 SuffFindArchiveDeps(gn, slst) 1666 GNode *gn; /* Node for which to locate dependencies */ 1667 Lst slst; 1588 1668 { 1589 1669 char *eoarch; /* End of archive portion */ … … 1623 1703 * Create the link between the two nodes right off 1624 1704 */ 1625 if (Lst_Member(gn->children, ( void *)mem) == NULL) {1626 (void)Lst_AtEnd(gn->children, ( void *)mem);1627 (void)Lst_AtEnd(mem->parents, ( void *)gn);1705 if (Lst_Member(gn->children, (ClientData)mem) == NILLNODE) { 1706 (void)Lst_AtEnd(gn->children, (ClientData)mem); 1707 (void)Lst_AtEnd(mem->parents, (ClientData)gn); 1628 1708 gn->unmade += 1; 1629 1709 } … … 1644 1724 * Didn't know what it was -- use .NULL suffix if not in make mode 1645 1725 */ 1646 DEBUGF(SUFF, ("using null suffix\n")); 1726 if (DEBUG(SUFF)) { 1727 printf("using null suffix\n"); 1728 } 1647 1729 ms = suffNull; 1648 1730 } … … 1669 1751 ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP); 1670 1752 1671 if (ln != N ULL) {1753 if (ln != NILLNODE) { 1672 1754 /* 1673 1755 * Got one -- apply it 1674 1756 */ 1675 if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms)) { 1676 DEBUGF(SUFF, ("\tNo transformation from %s -> %s\n", 1677 ms->name, ((Suff *)Lst_Datum(ln))->name)); 1757 if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms) && 1758 DEBUG(SUFF)) 1759 { 1760 printf("\tNo transformation from %s -> %s\n", 1761 ms->name, ((Suff *)Lst_Datum(ln))->name); 1678 1762 } 1679 1763 } … … 1716 1800 */ 1717 1801 static void 1718 SuffFindNormalDeps(GNode *gn, Lst slst) 1802 SuffFindNormalDeps(gn, slst) 1803 GNode *gn; /* Node for which to find sources */ 1804 Lst slst; 1719 1805 { 1720 1806 char *eoname; /* End of name */ … … 1761 1847 */ 1762 1848 1763 while (ln != N ULL) {1849 while (ln != NILLNODE) { 1764 1850 /* 1765 1851 * Look for next possible suffix... … … 1767 1853 ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP); 1768 1854 1769 if (ln != N ULL) {1855 if (ln != NILLNODE) { 1770 1856 int prefLen; /* Length of the prefix */ 1771 Src *targ et;1857 Src *targ; 1772 1858 1773 1859 /* 1774 1860 * Allocate a Src structure to which things can be transformed 1775 1861 */ 1776 targ et= (Src *)emalloc(sizeof (Src));1777 targ et->file = estrdup(gn->name);1778 targ et->suff = (Suff *)Lst_Datum(ln);1779 targ et->suff->refCount++;1780 targ et->node = gn;1781 targ et->parent = (Src *)NULL;1782 targ et->children = 0;1862 targ = (Src *)emalloc(sizeof (Src)); 1863 targ->file = estrdup(gn->name); 1864 targ->suff = (Suff *)Lst_Datum(ln); 1865 targ->suff->refCount++; 1866 targ->node = gn; 1867 targ->parent = (Src *)NULL; 1868 targ->children = 0; 1783 1869 #ifdef DEBUG_SRC 1784 targ et->cp = Lst_Init(FALSE);1870 targ->cp = Lst_Init(FALSE); 1785 1871 #endif 1786 1872 … … 1789 1875 * the length of the suffix from the end of the name. 1790 1876 */ 1791 prefLen = (eoname - targ et->suff->nameLen) - sopref;1792 targ et->pref = emalloc(prefLen + 1);1793 memcpy(targ et->pref, sopref, prefLen);1794 targ et->pref[prefLen] = '\0';1877 prefLen = (eoname - targ->suff->nameLen) - sopref; 1878 targ->pref = emalloc(prefLen + 1); 1879 memcpy(targ->pref, sopref, prefLen); 1880 targ->pref[prefLen] = '\0'; 1795 1881 1796 1882 /* 1797 1883 * Add nodes from which the target can be made 1798 1884 */ 1799 SuffAddLevel(srcs, targ et);1885 SuffAddLevel(srcs, targ); 1800 1886 1801 1887 /* 1802 1888 * Record the target so we can nuke it 1803 1889 */ 1804 (void)Lst_AtEnd(targs, ( void *)target);1890 (void)Lst_AtEnd(targs, (ClientData)targ); 1805 1891 1806 1892 /* … … 1815 1901 */ 1816 1902 if (Lst_IsEmpty(targs) && suffNull != NULL) { 1817 DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n", gn->name)); 1903 if (DEBUG(SUFF)) { 1904 printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name); 1905 } 1818 1906 1819 1907 targ = (Src *)emalloc(sizeof (Src)); … … 1836 1924 SuffAddLevel(srcs, targ); 1837 1925 else { 1838 DEBUGF(SUFF, ("not ")); 1839 } 1840 1841 DEBUGF(SUFF, ("adding suffix rules\n")); 1842 1843 (void)Lst_AtEnd(targs, (void *)targ); 1926 if (DEBUG(SUFF)) 1927 printf("not "); 1928 } 1929 1930 if (DEBUG(SUFF)) 1931 printf("adding suffix rules\n"); 1932 1933 (void)Lst_AtEnd(targs, (ClientData)targ); 1844 1934 } 1845 1935 … … 1884 1974 * that still contain variables or wildcards in their names. 1885 1975 */ 1886 Lst_ForEach(gn->children, SuffExpandChildren, ( void *)gn);1976 Lst_ForEach(gn->children, SuffExpandChildren, (ClientData)gn); 1887 1977 1888 1978 if (targ == NULL) { 1889 DEBUGF(SUFF, ("\tNo valid suffix on %s\n", gn->name)); 1979 if (DEBUG(SUFF)) { 1980 printf("\tNo valid suffix on %s\n", gn->name); 1981 } 1890 1982 1891 1983 sfnd_abort: … … 1984 2076 */ 1985 2077 while (bottom && bottom->parent != NULL) { 1986 if (Lst_Member(slst, ( void *) bottom) == NULL) {1987 Lst_AtEnd(slst, ( void *) bottom);2078 if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) { 2079 Lst_AtEnd(slst, (ClientData) bottom); 1988 2080 } 1989 2081 bottom = bottom->parent; … … 2012 2104 * Etc. 2013 2105 */ 2014 if (bottom->node == N ULL) {2106 if (bottom->node == NILGNODE) { 2015 2107 bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); 2016 2108 } … … 2024 2116 src->node->suffix->refCount++; 2025 2117 2026 if (targ->node == N ULL) {2118 if (targ->node == NILGNODE) { 2027 2119 targ->node = Targ_FindNode(targ->file, TARG_CREATE); 2028 2120 } … … 2066 2158 sfnd_return: 2067 2159 if (bottom) 2068 if (Lst_Member(slst, ( void *) bottom) == NULL)2069 Lst_AtEnd(slst, ( void *) bottom);2160 if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) 2161 Lst_AtEnd(slst, (ClientData) bottom); 2070 2162 2071 2163 while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs)) … … 2106 2198 2107 2199 void 2108 Suff_FindDeps(GNode *gn) 2200 Suff_FindDeps(gn) 2201 GNode *gn; 2109 2202 { 2110 2203 … … 2116 2209 2117 2210 static void 2118 SuffFindDeps (GNode *gn, Lst slst) 2211 SuffFindDeps (gn, slst) 2212 GNode *gn; /* node we're dealing with */ 2213 Lst slst; 2119 2214 { 2120 2215 if (gn->type & OP_DEPS_FOUND) { … … 2127 2222 } 2128 2223 2129 DEBUGF(SUFF, ("SuffFindDeps (%s)\n", gn->name)); 2224 if (DEBUG(SUFF)) { 2225 printf ("SuffFindDeps (%s)\n", gn->name); 2226 } 2130 2227 2131 2228 if (gn->type & OP_ARCHV) { … … 2143 2240 Suff *s; 2144 2241 2145 ln = Lst_Find (sufflist, ( void *)LIBSUFF, SuffSuffHasNameP);2242 ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP); 2146 2243 if (gn->suffix) 2147 2244 gn->suffix->refCount--; 2148 if (ln != N ULL) {2245 if (ln != NILLNODE) { 2149 2246 gn->suffix = s = (Suff *) Lst_Datum (ln); 2150 2247 gn->suffix->refCount++; … … 2183 2280 */ 2184 2281 void 2185 Suff_SetNull(char *name) 2282 Suff_SetNull(name) 2283 char *name; /* Name of null suffix */ 2186 2284 { 2187 2285 Suff *s; 2188 2286 LstNode ln; 2189 2287 2190 ln = Lst_Find(sufflist, ( void *)name, SuffSuffHasNameP);2191 if (ln != N ULL) {2288 ln = Lst_Find(sufflist, (ClientData)name, SuffSuffHasNameP); 2289 if (ln != NILLNODE) { 2192 2290 s = (Suff *)Lst_Datum(ln); 2193 2291 if (suffNull != (Suff *)NULL) { … … 2218 2316 */ 2219 2317 void 2220 Suff_Init ( void)2318 Suff_Init () 2221 2319 { 2222 2320 sufflist = Lst_Init (FALSE); … … 2261 2359 2262 2360 void 2263 Suff_End( void)2361 Suff_End() 2264 2362 { 2265 2363 Lst_Destroy(sufflist, SuffFree); … … 2274 2372 /********************* DEBUGGING FUNCTIONS **********************/ 2275 2373 2374 static int SuffPrintName(s, dummy) 2375 ClientData s; 2376 ClientData dummy; 2377 { 2378 printf ("`%s' ", ((Suff *) s)->name); 2379 return (dummy ? 0 : 0); 2380 } 2381 2276 2382 static int 2277 SuffPrintName(void *s, void *dummy __unused) 2278 { 2279 printf ("`%s' ", ((Suff *) s)->name); 2280 return (0); 2281 } 2282 2283 static int 2284 SuffPrintSuff (void *sp, void *dummy __unused) 2383 SuffPrintSuff (sp, dummy) 2384 ClientData sp; 2385 ClientData dummy; 2285 2386 { 2286 2387 Suff *s = (Suff *) sp; … … 2306 2407 printf ("LIBRARY"); 2307 2408 break; 2308 default:2309 break;2310 2409 } 2311 2410 fputc(flags ? '|' : ')', stdout); … … 2314 2413 fputc ('\n', stdout); 2315 2414 printf ("#\tTo: "); 2316 Lst_ForEach (s->parents, SuffPrintName, ( void *)0);2415 Lst_ForEach (s->parents, SuffPrintName, (ClientData)0); 2317 2416 fputc ('\n', stdout); 2318 2417 printf ("#\tFrom: "); 2319 Lst_ForEach (s->children, SuffPrintName, ( void *)0);2418 Lst_ForEach (s->children, SuffPrintName, (ClientData)0); 2320 2419 fputc ('\n', stdout); 2321 2420 printf ("#\tSearch Path: "); 2322 2421 Dir_PrintPath (s->searchPath); 2323 2422 fputc ('\n', stdout); 2324 return ( 0);2423 return (dummy ? 0 : 0); 2325 2424 } 2326 2425 2327 2426 static int 2328 SuffPrintTrans (void *tp, void *dummy __unused) 2427 SuffPrintTrans (tp, dummy) 2428 ClientData tp; 2429 ClientData dummy; 2329 2430 { 2330 2431 GNode *t = (GNode *) tp; … … 2333 2434 Targ_PrintType (t->type); 2334 2435 fputc ('\n', stdout); 2335 Lst_ForEach (t->commands, Targ_PrintCmd, ( void *)0);2436 Lst_ForEach (t->commands, Targ_PrintCmd, (ClientData)0); 2336 2437 fputc ('\n', stdout); 2337 return (0);2438 return(dummy ? 0 : 0); 2338 2439 } 2339 2440 2340 2441 void 2341 Suff_PrintAll( void)2442 Suff_PrintAll() 2342 2443 { 2343 2444 printf ("#*** Suffixes:\n"); 2344 Lst_ForEach (sufflist, SuffPrintSuff, ( void *)0);2445 Lst_ForEach (sufflist, SuffPrintSuff, (ClientData)0); 2345 2446 2346 2447 printf ("#*** Transformations:\n"); 2347 Lst_ForEach (transforms, SuffPrintTrans, ( void *)0);2348 } 2448 Lst_ForEach (transforms, SuffPrintTrans, (ClientData)0); 2449 } -
branches/FREEBSD/src/kmk/targ.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 * @(#)targ.c 8.2 (Berkeley) 3/19/94 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/targ.c,v 1.25 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/targ.c,v 1.10 1999/09/11 13:08:02 hoek Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 /*- … … 93 97 static Hash_Table targets; /* a hash table of same */ 94 98 95 #define 96 97 static int TargPrintOnlySrc (void *, void *);98 static int TargPrintName (void *, void *);99 static int TargPrintNode (void *, void *);100 static void TargFreeGN (void *);99 #define HTSIZE 191 /* initial size of hash table */ 100 101 static int TargPrintOnlySrc __P((ClientData, ClientData)); 102 static int TargPrintName __P((ClientData, ClientData)); 103 static int TargPrintNode __P((ClientData, ClientData)); 104 static void TargFreeGN __P((ClientData)); 101 105 102 106 /*- … … 113 117 */ 114 118 void 115 Targ_Init ( void)119 Targ_Init () 116 120 { 117 121 allTargets = Lst_Init (FALSE); … … 132 136 */ 133 137 void 134 Targ_End ( void)138 Targ_End () 135 139 { 136 140 Lst_Destroy(allTargets, NOFREE); … … 154 158 */ 155 159 GNode * 156 Targ_NewGN (char *name) 157 { 158 GNode *gn; 160 Targ_NewGN (name) 161 char *name; /* the name to stick in the new node */ 162 { 163 register GNode *gn; 159 164 160 165 gn = (GNode *) emalloc (sizeof (GNode)); … … 184 189 if (allGNs == NULL) 185 190 allGNs = Lst_Init(FALSE); 186 Lst_AtEnd(allGNs, ( void *) gn);191 Lst_AtEnd(allGNs, (ClientData) gn); 187 192 188 193 return (gn); … … 202 207 */ 203 208 static void 204 TargFreeGN (void *gnp) 209 TargFreeGN (gnp) 210 ClientData gnp; 205 211 { 206 212 GNode *gn = (GNode *) gnp; … … 218 224 Lst_Destroy(gn->context, NOFREE); 219 225 Lst_Destroy(gn->commands, NOFREE); 220 free( gn);226 free((Address)gn); 221 227 } 222 228 … … 228 234 * 229 235 * Results: 230 * The node in the list if it was. If it wasn't, return N ULLof236 * The node in the list if it was. If it wasn't, return NILGNODE of 231 237 * flags was TARG_NOCREATE or the newly created and initialized node 232 238 * if it was TARG_CREATE … … 237 243 */ 238 244 GNode * 239 Targ_FindNode (char *name, int flags) 245 Targ_FindNode (name, flags) 246 char *name; /* the name to find */ 247 int flags; /* flags governing events when target not 248 * found */ 240 249 { 241 250 GNode *gn; /* node in that element */ … … 250 259 gn = Targ_NewGN (name); 251 260 Hash_SetValue (he, gn); 252 (void) Lst_AtEnd (allTargets, ( void *)gn);261 (void) Lst_AtEnd (allTargets, (ClientData)gn); 253 262 } 254 263 } else { … … 257 266 258 267 if (he == (Hash_Entry *) NULL) { 259 return (N ULL);268 return (NILGNODE); 260 269 } else { 261 270 return ((GNode *) Hash_GetValue (he)); … … 279 288 */ 280 289 Lst 281 Targ_FindList (Lst names, int flags) 290 Targ_FindList (names, flags) 291 Lst names; /* list of names to find */ 292 int flags; /* flags used if no node is found for a given 293 * name */ 282 294 { 283 295 Lst nodes; /* result list */ 284 LstNodeln; /* name list element */285 GNode*gn; /* node in tLn */286 char 296 register LstNode ln; /* name list element */ 297 register GNode *gn; /* node in tLn */ 298 char *name; 287 299 288 300 nodes = Lst_Init (FALSE); … … 291 303 return (nodes); 292 304 } 293 while ((ln = Lst_Next (names)) != N ULL) {305 while ((ln = Lst_Next (names)) != NILLNODE) { 294 306 name = (char *)Lst_Datum(ln); 295 307 gn = Targ_FindNode (name, flags); 296 if (gn != N ULL) {308 if (gn != NILGNODE) { 297 309 /* 298 310 * Note: Lst_AtEnd must come before the Lst_Concat so the nodes … … 300 312 * encountered in the makefile. 301 313 */ 302 (void) Lst_AtEnd (nodes, ( void *)gn);314 (void) Lst_AtEnd (nodes, (ClientData)gn); 303 315 if (gn->type & OP_DOUBLEDEP) { 304 316 (void)Lst_Concat (nodes, gn->cohorts, LST_CONCNEW); … … 325 337 */ 326 338 Boolean 327 Targ_Ignore (GNode *gn) 339 Targ_Ignore (gn) 340 GNode *gn; /* node to check for */ 328 341 { 329 342 if (ignoreErrors || gn->type & OP_IGNORE) { … … 347 360 */ 348 361 Boolean 349 Targ_Silent (GNode *gn) 362 Targ_Silent (gn) 363 GNode *gn; /* node to check for */ 350 364 { 351 365 if (beSilent || gn->type & OP_SILENT) { … … 369 383 */ 370 384 Boolean 371 Targ_Precious (GNode *gn) 385 Targ_Precious (gn) 386 GNode *gn; /* the node to check */ 372 387 { 373 388 if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) { … … 395 410 */ 396 411 void 397 Targ_SetMain (GNode *gn) 412 Targ_SetMain (gn) 413 GNode *gn; /* The main target we'll create */ 398 414 { 399 415 mainTarg = gn; … … 401 417 402 418 static int 403 TargPrintName (void *gnp, void *ppath) 419 TargPrintName (gnp, ppath) 420 ClientData gnp; 421 ClientData ppath; 404 422 { 405 423 GNode *gn = (GNode *) gnp; … … 420 438 421 439 int 422 Targ_PrintCmd (void *cmd, void *dummy __unused) 440 Targ_PrintCmd (cmd, dummy) 441 ClientData cmd; 442 ClientData dummy; 423 443 { 424 444 printf ("\t%s\n", (char *) cmd); 425 return ( 0);445 return (dummy ? 0 : 0); 426 446 } 427 447 … … 441 461 */ 442 462 char * 443 Targ_FmtTime (time_t modtime) 463 Targ_FmtTime (time) 464 time_t time; 444 465 { 445 466 struct tm *parts; 446 467 static char buf[128]; 447 468 448 parts = localtime(& modtime);449 450 strftime(buf, sizeof buf, "% H:%M:%S %b %d, %Y", parts);469 parts = localtime(&time); 470 471 strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts); 451 472 buf[sizeof(buf) - 1] = '\0'; 452 473 return(buf); … … 466 487 */ 467 488 void 468 Targ_PrintType (int type) 469 { 470 int tbit; 471 472 #define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break 473 #define PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, ("." #attr " ")); break 489 Targ_PrintType (type) 490 register int type; 491 { 492 register int tbit; 493 494 #ifdef __STDC__ 495 #define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break 496 #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break 497 #else 498 #define PRINTBIT(attr) case CONCAT(OP_,attr): printf(".attr "); break 499 #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break 500 #endif /* __STDC__ */ 474 501 475 502 type &= ~OP_OPMASK; … … 492 519 PRINTDBIT(LIB); 493 520 /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */ 494 case OP_MEMBER: DEBUGF(TARG, (".MEMBER ")); break;521 case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break; 495 522 PRINTDBIT(ARCHV); 496 523 } … … 505 532 */ 506 533 static int 507 TargPrintNode (void *gnp, void *passp) 534 TargPrintNode (gnp, passp) 535 ClientData gnp; 536 ClientData passp; 508 537 { 509 538 GNode *gn = (GNode *) gnp; … … 540 569 if (!Lst_IsEmpty (gn->iParents)) { 541 570 printf("# implicit parents: "); 542 Lst_ForEach (gn->iParents, TargPrintName, ( void *)0);571 Lst_ForEach (gn->iParents, TargPrintName, (ClientData)0); 543 572 fputc ('\n', stdout); 544 573 } … … 546 575 if (!Lst_IsEmpty (gn->parents)) { 547 576 printf("# parents: "); 548 Lst_ForEach (gn->parents, TargPrintName, ( void *)0);577 Lst_ForEach (gn->parents, TargPrintName, (ClientData)0); 549 578 fputc ('\n', stdout); 550 579 } … … 558 587 case OP_DOUBLEDEP: 559 588 printf(":: "); break; 560 default:561 break;562 589 } 563 590 Targ_PrintType (gn->type); 564 Lst_ForEach (gn->children, TargPrintName, ( void *)0);591 Lst_ForEach (gn->children, TargPrintName, (ClientData)0); 565 592 fputc ('\n', stdout); 566 Lst_ForEach (gn->commands, Targ_PrintCmd, ( void *)0);593 Lst_ForEach (gn->commands, Targ_PrintCmd, (ClientData)0); 567 594 printf("\n\n"); 568 595 if (gn->type & OP_DOUBLEDEP) { 569 Lst_ForEach (gn->cohorts, TargPrintNode, ( void *)&pass);596 Lst_ForEach (gn->cohorts, TargPrintNode, (ClientData)&pass); 570 597 } 571 598 } … … 582 609 * 583 610 * Side Effects: 584 * The name of each file is printed prece ded by #\t611 * The name of each file is printed preceeded by #\t 585 612 * 586 613 *----------------------------------------------------------------------- 587 614 */ 588 615 static int 589 TargPrintOnlySrc(void *gnp, void *dummy __unused) 616 TargPrintOnlySrc(gnp, dummy) 617 ClientData gnp; 618 ClientData dummy; 590 619 { 591 620 GNode *gn = (GNode *) gnp; … … 593 622 printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name); 594 623 595 return ( 0);624 return (dummy ? 0 : 0); 596 625 } 597 626 … … 599 628 *----------------------------------------------------------------------- 600 629 * Targ_PrintGraph -- 601 * Print the entire graph.630 * print the entire graph. heh heh 602 631 * 603 632 * Results: … … 609 638 */ 610 639 void 611 Targ_PrintGraph (int pass) 640 Targ_PrintGraph (pass) 641 int pass; /* Which pass this is. 1 => no processing 642 * 2 => processing done */ 612 643 { 613 644 printf("#*** Input graph:\n"); 614 Lst_ForEach (allTargets, TargPrintNode, ( void *)&pass);645 Lst_ForEach (allTargets, TargPrintNode, (ClientData)&pass); 615 646 printf("\n\n"); 616 647 printf("#\n# Files that are only sources:\n"); 617 Lst_ForEach (allTargets, TargPrintOnlySrc, ( void *) 0);648 Lst_ForEach (allTargets, TargPrintOnlySrc, (ClientData) 0); 618 649 printf("#*** Global Variables:\n"); 619 650 Var_Dump (VAR_GLOBAL); -
branches/FREEBSD/src/kmk/util.c
r10 r24 1 1 /* 2 * Copyright (c) 2002 Juli Mallett. All rights reserved. 3 * Copyright (c) 1988, 1989, 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * Copyright (c) 1989 by Berkeley Softworks 6 * All rights reserved. 2 * Missing stuff from OS's 3 */ 4 5 #ifndef lint 6 static char rcsid[] = "$FreeBSD: src/usr.bin/make/util.c,v 1.5.2.2 2001/02/13 03:13:58 will Exp $"; 7 #endif 8 9 #include <stdio.h> 10 #include <errno.h> 11 #include "make.h" 12 13 #if !__STDC__ 14 # ifndef const 15 # define const 16 # endif 17 #endif 18 19 #ifdef sun 20 extern int errno, sys_nerr; 21 extern char *sys_errlist[]; 22 23 char * 24 strerror(e) 25 int e; 26 { 27 static char buf[100]; 28 if (e < 0 || e >= sys_nerr) { 29 sprintf(buf, "Unknown error %d", e); 30 return buf; 31 } 32 else 33 return sys_errlist[e]; 34 } 35 #endif 36 37 #ifdef ultrix 38 #include <string.h> 39 40 /* strdup 7 41 * 8 * This code is derived from software contributed to Berkeley by 9 * Adam de Boor. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)main.c 8.3 (Berkeley) 3/19/94 40 */ 41 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/util.c,v 1.12 2002/10/10 19:27:48 jmallett Exp $"); 44 45 /*- 46 * util.c -- 47 * General utilitarian routines for make(1). 48 */ 49 50 #include <sys/types.h> 51 #include <sys/stat.h> 52 #include <err.h> 53 #include <stdlib.h> 54 #include <errno.h> 55 #include <fcntl.h> 56 #include <stdio.h> 57 #include <sysexits.h> 58 #include <stdarg.h> 59 #include <unistd.h> 60 61 #include "make.h" 62 #include "hash.h" 63 #include "dir.h" 64 #include "job.h" 65 #include "pathnames.h" 66 67 /*- 68 * Debug -- 69 * Print a debugging message given its format. 70 * 71 * Results: 72 * None. 73 * 74 * Side Effects: 75 * The message is printed. 76 */ 77 /* VARARGS */ 78 void 79 Debug(const char *fmt, ...) 80 { 81 va_list ap; 82 83 va_start(ap, fmt); 84 (void)vfprintf(stderr, fmt, ap); 85 va_end(ap); 86 (void)fflush(stderr); 87 } 88 89 /*- 90 * Error -- 91 * Print an error message given its format. 92 * 93 * Results: 94 * None. 95 * 96 * Side Effects: 97 * The message is printed. 98 */ 99 /* VARARGS */ 100 void 101 Error(const char *fmt, ...) 102 { 103 va_list ap; 104 105 va_start(ap, fmt); 106 (void)vfprintf(stderr, fmt, ap); 107 va_end(ap); 108 (void)fprintf(stderr, "\n"); 109 (void)fflush(stderr); 110 } 111 112 /*- 113 * Fatal -- 114 * Produce a Fatal error message. If jobs are running, waits for them 115 * to finish. 116 * 117 * Results: 118 * None 119 * 120 * Side Effects: 121 * The program exits 122 */ 123 /* VARARGS */ 124 void 125 Fatal(const char *fmt, ...) 126 { 127 va_list ap; 128 129 va_start(ap, fmt); 130 if (jobsRunning) 131 Job_Wait(); 132 133 (void)vfprintf(stderr, fmt, ap); 134 va_end(ap); 135 (void)fprintf(stderr, "\n"); 136 (void)fflush(stderr); 137 138 if (DEBUG(GRAPH2)) 139 Targ_PrintGraph(2); 140 exit(2); /* Not 1 so -q can distinguish error */ 141 } 142 143 /* 144 * Punt -- 145 * Major exception once jobs are being created. Kills all jobs, prints 146 * a message and exits. 147 * 148 * Results: 149 * None 150 * 151 * Side Effects: 152 * All children are killed indiscriminately and the program Lib_Exits 153 */ 154 /* VARARGS */ 155 void 156 Punt(const char *fmt, ...) 157 { 158 va_list ap; 159 160 va_start(ap, fmt); 161 (void)fprintf(stderr, "make: "); 162 (void)vfprintf(stderr, fmt, ap); 163 va_end(ap); 164 (void)fprintf(stderr, "\n"); 165 (void)fflush(stderr); 166 167 DieHorribly(); 168 } 169 170 /*- 171 * DieHorribly -- 172 * Exit without giving a message. 173 * 174 * Results: 175 * None 176 * 177 * Side Effects: 178 * A big one... 179 */ 180 void 181 DieHorribly(void) 182 { 183 if (jobsRunning) 184 Job_AbortAll(); 185 if (DEBUG(GRAPH2)) 186 Targ_PrintGraph(2); 187 exit(2); /* Not 1, so -q can distinguish error */ 188 } 189 190 /* 191 * Finish -- 192 * Called when aborting due to errors in child shell to signal 193 * abnormal exit, with the number of errors encountered in Make_Make. 194 * 195 * Results: 196 * None 197 * 198 * Side Effects: 199 * The program exits 200 */ 201 void 202 Finish(int errors) 203 { 204 Fatal("%d error%s", errors, errors == 1 ? "" : "s"); 205 } 206 207 /* 208 * emalloc -- 209 * malloc, but die on error. 210 */ 211 void * 212 emalloc(size_t len) 213 { 214 void *p; 215 216 if ((p = malloc(len)) == NULL) 217 enomem(); 218 return(p); 219 } 220 221 /* 222 * estrdup -- 223 * strdup, but die on error. 42 * Make a duplicate of a string. 43 * For systems which lack this function. 224 44 */ 225 45 char * 226 estrdup(const char *str) 227 { 228 char *p; 229 230 if ((p = strdup(str)) == NULL) 231 enomem(); 232 return(p); 233 } 234 235 /* 236 * erealloc -- 237 * realloc, but die on error. 46 strdup(str) 47 const char *str; 48 { 49 size_t len; 50 51 if (str == NULL) 52 return NULL; 53 len = strlen(str) + 1; 54 if ((p = malloc(len)) == NULL) 55 return NULL; 56 57 return memcpy(p, str, len); 58 } 59 60 #endif 61 62 #if defined(sun) || defined(__hpux) || defined(__sgi) 63 64 int 65 setenv(name, value, dum) 66 const char *name; 67 const char *value; 68 int dum; 69 { 70 register char *p; 71 int len = strlen(name) + strlen(value) + 2; /* = \0 */ 72 char *ptr = (char*) malloc(len); 73 74 (void) dum; 75 76 if (ptr == NULL) 77 return -1; 78 79 p = ptr; 80 81 while (*name) 82 *p++ = *name++; 83 84 *p++ = '='; 85 86 while (*value) 87 *p++ = *value++; 88 89 *p = '\0'; 90 91 len = putenv(ptr); 92 /* free(ptr); */ 93 return len; 94 } 95 #endif 96 97 #ifdef __hpux 98 #include <sys/types.h> 99 #include <sys/param.h> 100 #include <sys/syscall.h> 101 #include <sys/signal.h> 102 #include <sys/stat.h> 103 #include <stdio.h> 104 #include <dirent.h> 105 #include <sys/time.h> 106 #include <time.h> 107 #include <unistd.h> 108 109 110 int 111 killpg(pid, sig) 112 int pid, sig; 113 { 114 return kill(-pid, sig); 115 } 116 117 void 118 srandom(seed) 119 long seed; 120 { 121 srand48(seed); 122 } 123 124 long 125 random() 126 { 127 return lrand48(); 128 } 129 130 /* turn into bsd signals */ 131 void (* 132 signal(s, a)) () 133 int s; 134 void (*a)(); 135 { 136 struct sigvec osv, sv; 137 138 (void) sigvector(s, (struct sigvec *) 0, &osv); 139 sv = osv; 140 sv.sv_handler = a; 141 #ifdef SV_BSDSIG 142 sv.sv_flags = SV_BSDSIG; 143 #endif 144 145 if (sigvector(s, &sv, (struct sigvec *) 0) == -1) 146 return (BADSIG); 147 return (osv.sv_handler); 148 } 149 150 #if !defined(BSD) && !defined(d_fileno) 151 # define d_fileno d_ino 152 #endif 153 154 #ifndef DEV_DEV_COMPARE 155 # define DEV_DEV_COMPARE(a, b) ((a) == (b)) 156 #endif 157 158 /* strrcpy(): 159 * Like strcpy, going backwards and returning the new pointer 238 160 */ 239 void * 240 erealloc(void *ptr, size_t size) 241 { 242 if ((ptr = realloc(ptr, size)) == NULL) 243 enomem(); 244 return(ptr); 245 } 246 247 /* 248 * enomem -- 249 * die when out of memory. 250 */ 251 void 252 enomem(void) 253 { 254 err(2, NULL); 255 } 256 257 /* 258 * enunlink -- 259 * Remove a file carefully, avoiding directories. 260 */ 161 static char * 162 strrcpy(ptr, str) 163 register char *ptr, *str; 164 { 165 register int len = strlen(str); 166 167 while (len) 168 *--ptr = str[--len]; 169 170 return (ptr); 171 } /* end strrcpy */ 172 173 174 char * 175 getwd(pathname) 176 char *pathname; 177 { 178 DIR *dp; 179 struct dirent *d; 180 181 struct stat st_root, st_cur, st_next, st_dotdot; 182 char pathbuf[MAXPATHLEN], nextpathbuf[MAXPATHLEN * 2]; 183 char *pathptr, *nextpathptr, *cur_name_add; 184 185 /* find the inode of root */ 186 if (stat("/", &st_root) == -1) { 187 (void) sprintf(pathname, 188 "getwd: Cannot stat \"/\" (%s)", strerror(errno)); 189 return (NULL); 190 } 191 pathbuf[MAXPATHLEN - 1] = '\0'; 192 pathptr = &pathbuf[MAXPATHLEN - 1]; 193 nextpathbuf[MAXPATHLEN - 1] = '\0'; 194 cur_name_add = nextpathptr = &nextpathbuf[MAXPATHLEN - 1]; 195 196 /* find the inode of the current directory */ 197 if (lstat(".", &st_cur) == -1) { 198 (void) sprintf(pathname, 199 "getwd: Cannot stat \".\" (%s)", strerror(errno)); 200 return (NULL); 201 } 202 nextpathptr = strrcpy(nextpathptr, "../"); 203 204 /* Descend to root */ 205 for (;;) { 206 207 /* look if we found root yet */ 208 if (st_cur.st_ino == st_root.st_ino && 209 DEV_DEV_COMPARE(st_cur.st_dev, st_root.st_dev)) { 210 (void) strcpy(pathname, *pathptr != '/' ? "/" : pathptr); 211 return (pathname); 212 } 213 214 /* open the parent directory */ 215 if (stat(nextpathptr, &st_dotdot) == -1) { 216 snprintf(pathname, sizeof(pathname), 217 "getwd: Cannot stat directory \"%s\" (%s)", 218 nextpathptr, strerror(errno)); 219 return (NULL); 220 } 221 if ((dp = opendir(nextpathptr)) == NULL) { 222 snprintf(pathname, sizeof(pathname), 223 "getwd: Cannot open directory \"%s\" (%s)", 224 nextpathptr, strerror(errno)); 225 return (NULL); 226 } 227 228 /* look in the parent for the entry with the same inode */ 229 if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) { 230 /* Parent has same device. No need to stat every member */ 231 for (d = readdir(dp); d != NULL; d = readdir(dp)) 232 if (d->d_fileno == st_cur.st_ino) 233 break; 234 } 235 else { 236 /* 237 * Parent has a different device. This is a mount point so we 238 * need to stat every member 239 */ 240 for (d = readdir(dp); d != NULL; d = readdir(dp)) { 241 if (ISDOT(d->d_name) || ISDOTDOT(d->d_name)) 242 continue; 243 (void) strcpy(cur_name_add, d->d_name); 244 if (lstat(nextpathptr, &st_next) == -1) { 245 snprintf(pathname, sizeof(pathname), "getwd: Cannot stat \"%s\" (%s)", 246 d->d_name, strerror(errno)); 247 (void) closedir(dp); 248 return (NULL); 249 } 250 /* check if we found it yet */ 251 if (st_next.st_ino == st_cur.st_ino && 252 DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev)) 253 break; 254 } 255 } 256 if (d == NULL) { 257 (void) sprintf(pathname, "getwd: Cannot find \".\" in \"..\""); 258 (void) closedir(dp); 259 return (NULL); 260 } 261 st_cur = st_dotdot; 262 pathptr = strrcpy(pathptr, d->d_name); 263 pathptr = strrcpy(pathptr, "/"); 264 nextpathptr = strrcpy(nextpathptr, "../"); 265 (void) closedir(dp); 266 *cur_name_add = '\0'; 267 } 268 } /* end getwd */ 269 270 271 char *sys_siglist[] = { 272 "Signal 0", 273 "Hangup", /* SIGHUP */ 274 "Interrupt", /* SIGINT */ 275 "Quit", /* SIGQUIT */ 276 "Illegal instruction", /* SIGILL */ 277 "Trace/BPT trap", /* SIGTRAP */ 278 "IOT trap", /* SIGIOT */ 279 "EMT trap", /* SIGEMT */ 280 "Floating point exception", /* SIGFPE */ 281 "Killed", /* SIGKILL */ 282 "Bus error", /* SIGBUS */ 283 "Segmentation fault", /* SIGSEGV */ 284 "Bad system call", /* SIGSYS */ 285 "Broken pipe", /* SIGPIPE */ 286 "Alarm clock", /* SIGALRM */ 287 "Terminated", /* SIGTERM */ 288 "User defined signal 1", /* SIGUSR1 */ 289 "User defined signal 2", /* SIGUSR2 */ 290 "Child exited", /* SIGCLD */ 291 "Power-fail restart", /* SIGPWR */ 292 "Virtual timer expired", /* SIGVTALRM */ 293 "Profiling timer expired", /* SIGPROF */ 294 "I/O possible", /* SIGIO */ 295 "Window size changes", /* SIGWINDOW */ 296 "Stopped (signal)", /* SIGSTOP */ 297 "Stopped", /* SIGTSTP */ 298 "Continued", /* SIGCONT */ 299 "Stopped (tty input)", /* SIGTTIN */ 300 "Stopped (tty output)", /* SIGTTOU */ 301 "Urgent I/O condition", /* SIGURG */ 302 "Remote lock lost (NFS)", /* SIGLOST */ 303 "Signal 31", /* reserved */ 304 "DIL signal" /* SIGDIL */ 305 }; 306 261 307 int 262 eunlink(const char *file) 263 { 264 struct stat st; 265 266 if (lstat(file, &st) == -1) 267 return -1; 268 269 if (S_ISDIR(st.st_mode)) { 270 errno = EISDIR; 271 return -1; 272 } 273 return unlink(file); 274 } 275 276 /* 277 * Printaddr -- 278 * Print the address of a node, used as an interative function. 279 */ 280 int 281 PrintAddr(void *a, void *b __unused) 282 { 283 printf("%p ", a); 284 return 0; 285 } 308 utimes(file, tvp) 309 char *file; 310 struct timeval tvp[2]; 311 { 312 struct utimbuf t; 313 314 t.actime = tvp[0].tv_sec; 315 t.modtime = tvp[1].tv_sec; 316 return(utime(file, &t)); 317 } 318 319 320 #endif /* __hpux */ 321 322 #if defined(sun) && defined(__svr4__) 323 #include <signal.h> 324 325 /* turn into bsd signals */ 326 void (* 327 signal(s, a)) () 328 int s; 329 void (*a)(); 330 { 331 struct sigaction sa, osa; 332 333 sa.sa_handler = a; 334 sigemptyset(&sa.sa_mask); 335 sa.sa_flags = SA_RESTART; 336 337 if (sigaction(s, &sa, &osa) == -1) 338 return SIG_ERR; 339 else 340 return osa.sa_handler; 341 } 342 343 #endif -
branches/FREEBSD/src/kmk/var.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 * @(#)var.c 8.3 (Berkeley) 3/19/94 39 */ 40 41 #include <sys/cdefs.h> 42 __FBSDID("$FreeBSD: src/usr.bin/make/var.c,v 1.35 2002/10/09 03:42:10 jmallett Exp $"); 37 */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/var.c,v 1.16.2.3 2002/02/27 14:18:57 cjc Exp $"; 45 #endif 46 #endif /* not lint */ 43 47 44 48 /*- … … 126 130 static Lst allVars; /* List of all variables */ 127 131 128 #define 129 #define 130 #define 132 #define FIND_CMD 0x1 /* look in VAR_CMD when searching */ 133 #define FIND_GLOBAL 0x2 /* look in VAR_GLOBAL as well */ 134 #define FIND_ENV 0x4 /* look in the environment also */ 131 135 132 136 typedef struct Var { … … 134 138 Buffer val; /* its value */ 135 139 int flags; /* miscellaneous status flags */ 136 #define 140 #define VAR_IN_USE 1 /* Variable's value currently being used. 137 141 * Used to avoid recursion */ 138 #define 139 #define 142 #define VAR_FROM_ENV 2 /* Variable comes from the environment */ 143 #define VAR_JUNK 4 /* Variable is a junk variable that 140 144 * should be destroyed when done with 141 145 * it. Used by Var_Parse for undefined, … … 144 148 145 149 /* Var*Pattern flags */ 146 #define 147 #define 148 #define 149 #define 150 #define 151 #define 150 #define VAR_SUB_GLOBAL 0x01 /* Apply substitution globally */ 151 #define VAR_SUB_ONE 0x02 /* Apply substitution to one word */ 152 #define VAR_SUB_MATCHED 0x04 /* There was a match */ 153 #define VAR_MATCH_START 0x08 /* Match at start of word */ 154 #define VAR_MATCH_END 0x10 /* Match at end of word */ 155 #define VAR_NOSUBST 0x20 /* don't expand vars in VarGetPattern */ 152 156 153 157 typedef struct { … … 167 171 } VarREPattern; 168 172 169 static int VarCmp(void *, void *); 170 static void VarPossiblyExpand(char **, GNode *); 171 static Var *VarFind(char *, GNode *, int); 172 static void VarAdd(char *, char *, GNode *); 173 static void VarDelete(void *); 174 static Boolean VarHead(char *, Boolean, Buffer, void *); 175 static Boolean VarTail(char *, Boolean, Buffer, void *); 176 static Boolean VarSuffix(char *, Boolean, Buffer, void *); 177 static Boolean VarRoot(char *, Boolean, Buffer, void *); 178 static Boolean VarMatch(char *, Boolean, Buffer, void *); 173 static int VarCmp __P((ClientData, ClientData)); 174 static Var *VarFind __P((char *, GNode *, int)); 175 static void VarAdd __P((char *, char *, GNode *)); 176 static void VarDelete __P((ClientData)); 177 static Boolean VarHead __P((char *, Boolean, Buffer, ClientData)); 178 static Boolean VarTail __P((char *, Boolean, Buffer, ClientData)); 179 static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData)); 180 static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData)); 181 static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData)); 179 182 #ifdef SYSVVARSUB 180 static Boolean VarSYSVMatch (char *, Boolean, Buffer, void *);183 static Boolean VarSYSVMatch __P((char *, Boolean, Buffer, ClientData)); 181 184 #endif 182 static Boolean VarNoMatch(char *, Boolean, Buffer, void *); 183 static void VarREError(int, regex_t *, const char *); 184 static Boolean VarRESubstitute(char *, Boolean, Buffer, void *); 185 static Boolean VarSubstitute(char *, Boolean, Buffer, void *); 186 static char *VarGetPattern(GNode *, int, char **, int, int *, int *, 187 VarPattern *); 188 static char *VarQuote(char *); 189 static char *VarModify(char *, Boolean (*)(char *, Boolean, Buffer, void *), 190 void *); 191 static int VarPrintVar(void *, void *); 185 static Boolean VarNoMatch __P((char *, Boolean, Buffer, ClientData)); 186 static void VarREError __P((int, regex_t *, const char *)); 187 static Boolean VarRESubstitute __P((char *, Boolean, Buffer, ClientData)); 188 static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData)); 189 static char *VarGetPattern __P((GNode *, int, char **, int, int *, int *, 190 VarPattern *)); 191 static char *VarQuote __P((char *)); 192 static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer, 193 ClientData), 194 ClientData)); 195 static int VarPrintVar __P((ClientData, ClientData)); 192 196 193 197 /*- … … 205 209 */ 206 210 static int 207 VarCmp (void *v, void *name) 211 VarCmp (v, name) 212 ClientData v; /* VAR structure to compare */ 213 ClientData name; /* name to look for */ 208 214 { 209 215 return (strcmp ((char *) name, ((Var *) v)->name)); 210 }211 212 /*-213 *-----------------------------------------------------------------------214 * VarPossiblyExpand --215 * Expand a variable name's embedded variables in the given context.216 *217 * Results:218 * The contents of name, possibly expanded.219 *220 * Side Effects:221 * The caller must free the new contents or old contents of name.222 *-----------------------------------------------------------------------223 */224 static void225 VarPossiblyExpand(char **name, GNode *ctxt)226 {227 if (strchr(*name, '$') != NULL)228 *name = Var_Subst(NULL, *name, ctxt, 0);229 else230 *name = estrdup(*name);231 216 } 232 217 … … 237 222 * indicated. 238 223 * 239 * Flags:240 * FIND_GLOBAL set means look in the VAR_GLOBAL context too241 * FIND_CMD set means to look in the VAR_CMD context too242 * FIND_ENV set means to look in the environment243 *244 224 * Results: 245 225 * A pointer to the structure describing the desired variable or 246 * N ULL if the variable does not exist.226 * NIL if the variable does not exist. 247 227 * 248 228 * Side Effects: … … 251 231 */ 252 232 static Var * 253 VarFind (char *name, GNode *ctxt, int flags) 233 VarFind (name, ctxt, flags) 234 char *name; /* name to find */ 235 GNode *ctxt; /* context in which to find it */ 236 int flags; /* FIND_GLOBAL set means to look in the 237 * VAR_GLOBAL context as well. 238 * FIND_CMD set means to look in the VAR_CMD 239 * context also. 240 * FIND_ENV set means to look in the 241 * environment */ 254 242 { 255 243 Boolean localCheckEnvFirst; … … 297 285 * the -E flag to use environment-variable-override for. 298 286 */ 299 if (Lst_Find (envFirstVars, ( void *)name,300 (int (*)( void *, void *)) strcmp) != NULL)287 if (Lst_Find (envFirstVars, (ClientData)name, 288 (int (*)(ClientData, ClientData)) strcmp) != NILLNODE) 301 289 { 302 290 localCheckEnvFirst = TRUE; … … 310 298 * depending on the FIND_* flags in 'flags' 311 299 */ 312 var = Lst_Find (ctxt->context, ( void *)name, VarCmp);313 314 if ((var == N ULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) {315 var = Lst_Find (VAR_CMD->context, ( void *)name, VarCmp);316 } 317 if ((var == N ULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) &&300 var = Lst_Find (ctxt->context, (ClientData)name, VarCmp); 301 302 if ((var == NILLNODE) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) { 303 var = Lst_Find (VAR_CMD->context, (ClientData)name, VarCmp); 304 } 305 if ((var == NILLNODE) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) && 318 306 !checkEnvFirst && !localCheckEnvFirst) 319 307 { 320 var = Lst_Find (VAR_GLOBAL->context, ( void *)name, VarCmp);321 } 322 if ((var == N ULL) && (flags & FIND_ENV)) {308 var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp); 309 } 310 if ((var == NILLNODE) && (flags & FIND_ENV)) { 323 311 char *env; 324 312 … … 339 327 (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) 340 328 { 341 var = Lst_Find (VAR_GLOBAL->context, ( void *)name, VarCmp);342 if (var == N ULL) {343 return ((Var *) N ULL);329 var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp); 330 if (var == NILLNODE) { 331 return ((Var *) NIL); 344 332 } else { 345 333 return ((Var *)Lst_Datum(var)); 346 334 } 347 335 } else { 348 return((Var *)N ULL);336 return((Var *)NIL); 349 337 } 350 } else if (var == N ULL) {351 return ((Var *) N ULL);338 } else if (var == NILLNODE) { 339 return ((Var *) NIL); 352 340 } else { 353 341 return ((Var *) Lst_Datum (var)); … … 358 346 *----------------------------------------------------------------------- 359 347 * VarAdd -- 360 * Add a new variable of name name and value val to the given context .348 * Add a new variable of name name and value val to the given context 361 349 * 362 350 * Results: … … 370 358 */ 371 359 static void 372 VarAdd (char *name, char *val, GNode *ctxt) 373 { 374 Var *v; 360 VarAdd (name, val, ctxt) 361 char *name; /* name of variable to add */ 362 char *val; /* value to set it to */ 363 GNode *ctxt; /* context in which to set it */ 364 { 365 register Var *v; 375 366 int len; 376 367 … … 385 376 v->flags = 0; 386 377 387 (void) Lst_AtFront (ctxt->context, (void *)v); 388 (void) Lst_AtEnd (allVars, (void *) v); 389 DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val)); 378 (void) Lst_AtFront (ctxt->context, (ClientData)v); 379 (void) Lst_AtEnd (allVars, (ClientData) v); 380 if (DEBUG(VAR)) { 381 printf("%s:%s = %s\n", ctxt->name, name, val); 382 } 390 383 } 391 384 … … 404 397 */ 405 398 static void 406 VarDelete(void *vp) 399 VarDelete(vp) 400 ClientData vp; 407 401 { 408 402 Var *v = (Var *) vp; 409 403 free(v->name); 410 404 Buf_Destroy(v->val, TRUE); 411 free( v);405 free((Address) v); 412 406 } 413 407 … … 428 422 */ 429 423 void 430 Var_Delete(char *name, GNode *ctxt) 424 Var_Delete(name, ctxt) 425 char *name; 426 GNode *ctxt; 431 427 { 432 428 LstNode ln; 433 429 434 DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name)); 435 ln = Lst_Find(ctxt->context, (void *)name, VarCmp); 436 if (ln != NULL) { 437 Var *v; 430 if (DEBUG(VAR)) { 431 printf("%s:delete %s\n", ctxt->name, name); 432 } 433 ln = Lst_Find(ctxt->context, (ClientData)name, VarCmp); 434 if (ln != NILLNODE) { 435 register Var *v; 438 436 439 437 v = (Var *)Lst_Datum(ln); … … 441 439 ln = Lst_Member(allVars, v); 442 440 Lst_Remove(allVars, ln); 443 VarDelete(( void *) v);441 VarDelete((ClientData) v); 444 442 } 445 443 } … … 467 465 */ 468 466 void 469 Var_Set (char *name, char *val, GNode *ctxt) 470 { 471 Var *v; 467 Var_Set (name, val, ctxt) 468 char *name; /* name of variable to set */ 469 char *val; /* value to give to the variable */ 470 GNode *ctxt; /* context in which to set it */ 471 { 472 register Var *v; 472 473 473 474 /* … … 476 477 * point in searching them all just to save a bit of memory... 477 478 */ 478 VarPossiblyExpand(&name, ctxt);479 479 v = VarFind (name, ctxt, 0); 480 if (v == (Var *) N ULL) {480 if (v == (Var *) NIL) { 481 481 VarAdd (name, val, ctxt); 482 482 } else { … … 484 484 Buf_AddBytes(v->val, strlen(val), (Byte *)val); 485 485 486 DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val)); 486 if (DEBUG(VAR)) { 487 printf("%s:%s = %s\n", ctxt->name, name, val); 488 } 487 489 } 488 490 /* … … 493 495 setenv(name, val, 1); 494 496 } 495 free(name);496 497 } 497 498 … … 519 520 */ 520 521 void 521 Var_Append (char *name, char *val, GNode *ctxt) 522 { 523 Var *v; 524 525 VarPossiblyExpand(&name, ctxt); 522 Var_Append (name, val, ctxt) 523 char *name; /* Name of variable to modify */ 524 char *val; /* String to append to it */ 525 GNode *ctxt; /* Context in which this should occur */ 526 { 527 register Var *v; 528 526 529 v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); 527 530 528 if (v == (Var *) N ULL) {531 if (v == (Var *) NIL) { 529 532 VarAdd (name, val, ctxt); 530 533 } else { … … 532 535 Buf_AddBytes(v->val, strlen(val), (Byte *)val); 533 536 534 DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, 535 (char *) Buf_GetAll(v->val, (int *)NULL))); 537 if (DEBUG(VAR)) { 538 printf("%s:%s = %s\n", ctxt->name, name, 539 (char *) Buf_GetAll(v->val, (int *)NULL)); 540 } 536 541 537 542 if (v->flags & VAR_FROM_ENV) { … … 543 548 */ 544 549 v->flags &= ~VAR_FROM_ENV; 545 Lst_AtFront(ctxt->context, ( void *)v);550 Lst_AtFront(ctxt->context, (ClientData)v); 546 551 } 547 552 } 548 free(name);549 553 } 550 554 … … 563 567 */ 564 568 Boolean 565 Var_Exists(char *name, GNode *ctxt) 569 Var_Exists(name, ctxt) 570 char *name; /* Variable to find */ 571 GNode *ctxt; /* Context in which to start search */ 566 572 { 567 573 Var *v; 568 574 569 VarPossiblyExpand(&name, ctxt);570 575 v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); 571 free(name); 572 573 if (v == (Var *)NULL) { 576 577 if (v == (Var *)NIL) { 574 578 return(FALSE); 575 579 } else if (v->flags & VAR_FROM_ENV) { … … 594 598 */ 595 599 char * 596 Var_Value (char *name, GNode *ctxt, char **frp) 600 Var_Value (name, ctxt, frp) 601 char *name; /* name to find */ 602 GNode *ctxt; /* context in which to search for it */ 603 char **frp; 597 604 { 598 605 Var *v; 599 606 600 VarPossiblyExpand(&name, ctxt);601 607 v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); 602 free(name);603 608 *frp = NULL; 604 if (v != (Var *) N ULL) {609 if (v != (Var *) NIL) { 605 610 char *p = ((char *)Buf_GetAll(v->val, (int *)NULL)); 606 611 if (v->flags & VAR_FROM_ENV) { 607 612 Buf_Destroy(v->val, FALSE); 608 free( v);613 free((Address) v); 609 614 *frp = p; 610 615 } … … 631 636 */ 632 637 static Boolean 633 VarHead (char *word, Boolean addSpace, Buffer buf, void *dummy __unused) 634 { 635 char *slash; 638 VarHead (word, addSpace, buf, dummy) 639 char *word; /* Word to trim */ 640 Boolean addSpace; /* True if need to add a space to the buffer 641 * before sticking in the head */ 642 Buffer buf; /* Buffer in which to store it */ 643 ClientData dummy; 644 { 645 register char *slash; 636 646 637 647 slash = strrchr (word, '/'); … … 654 664 } 655 665 } 656 return (TRUE);666 return(dummy ? TRUE : TRUE); 657 667 } 658 668 … … 673 683 */ 674 684 static Boolean 675 VarTail (char *word, Boolean addSpace, Buffer buf, void *dummy __unused) 676 { 677 char *slash; 685 VarTail (word, addSpace, buf, dummy) 686 char *word; /* Word to trim */ 687 Boolean addSpace; /* TRUE if need to stick a space in the 688 * buffer before adding the tail */ 689 Buffer buf; /* Buffer in which to store it */ 690 ClientData dummy; 691 { 692 register char *slash; 678 693 679 694 if (addSpace) { … … 689 704 Buf_AddBytes (buf, strlen(word), (Byte *)word); 690 705 } 691 return ( TRUE);706 return (dummy ? TRUE : TRUE); 692 707 } 693 708 … … 707 722 */ 708 723 static Boolean 709 VarSuffix (char *word, Boolean addSpace, Buffer buf, void *dummy __unused) 710 { 711 char *dot; 724 VarSuffix (word, addSpace, buf, dummy) 725 char *word; /* Word to trim */ 726 Boolean addSpace; /* TRUE if need to add a space before placing 727 * the suffix in the buffer */ 728 Buffer buf; /* Buffer in which to store it */ 729 ClientData dummy; 730 { 731 register char *dot; 712 732 713 733 dot = strrchr (word, '.'); … … 721 741 addSpace = TRUE; 722 742 } 723 return ( addSpace);743 return (dummy ? addSpace : addSpace); 724 744 } 725 745 … … 740 760 */ 741 761 static Boolean 742 VarRoot (char *word, Boolean addSpace, Buffer buf, void *dummy __unused) 743 { 744 char *dot; 762 VarRoot (word, addSpace, buf, dummy) 763 char *word; /* Word to trim */ 764 Boolean addSpace; /* TRUE if need to add a space to the buffer 765 * before placing the root in it */ 766 Buffer buf; /* Buffer in which to store it */ 767 ClientData dummy; 768 { 769 register char *dot; 745 770 746 771 if (addSpace) { … … 756 781 Buf_AddBytes (buf, strlen(word), (Byte *)word); 757 782 } 758 return ( TRUE);783 return (dummy ? TRUE : TRUE); 759 784 } 760 785 … … 764 789 * Place the word in the buffer if it matches the given pattern. 765 790 * Callback function for VarModify to implement the :M modifier. 766 * A space will be added if requested. A pattern is supplied767 * which the word must match.768 791 * 769 792 * Results: … … 777 800 */ 778 801 static Boolean 779 VarMatch (char *word, Boolean addSpace, Buffer buf, void *pattern) 802 VarMatch (word, addSpace, buf, pattern) 803 char *word; /* Word to examine */ 804 Boolean addSpace; /* TRUE if need to add a space to the 805 * buffer before adding the word, if it 806 * matches */ 807 Buffer buf; /* Buffer in which to store it */ 808 ClientData pattern; /* Pattern the word must match */ 780 809 { 781 810 if (Str_Match(word, (char *) pattern)) { … … 795 824 * Place the word in the buffer if it matches the given pattern. 796 825 * Callback function for VarModify to implement the System V % 797 * modifiers. A space is added if requested.826 * modifiers. 798 827 * 799 828 * Results: … … 807 836 */ 808 837 static Boolean 809 VarSYSVMatch (char *word, Boolean addSpace, Buffer buf, void *patp) 838 VarSYSVMatch (word, addSpace, buf, patp) 839 char *word; /* Word to examine */ 840 Boolean addSpace; /* TRUE if need to add a space to the 841 * buffer before adding the word, if it 842 * matches */ 843 Buffer buf; /* Buffer in which to store it */ 844 ClientData patp; /* Pattern the word must match */ 810 845 { 811 846 int len; … … 832 867 * VarNoMatch -- 833 868 * Place the word in the buffer if it doesn't match the given pattern. 834 * Callback function for VarModify to implement the :N modifier. A 835 * space is added if requested. 869 * Callback function for VarModify to implement the :N modifier. 836 870 * 837 871 * Results: … … 845 879 */ 846 880 static Boolean 847 VarNoMatch (char *word, Boolean addSpace, Buffer buf, void *pattern) 881 VarNoMatch (word, addSpace, buf, pattern) 882 char *word; /* Word to examine */ 883 Boolean addSpace; /* TRUE if need to add a space to the 884 * buffer before adding the word, if it 885 * matches */ 886 Buffer buf; /* Buffer in which to store it */ 887 ClientData pattern; /* Pattern the word must match */ 848 888 { 849 889 if (!Str_Match(word, (char *) pattern)) { … … 862 902 * VarSubstitute -- 863 903 * Perform a string-substitution on the given word, placing the 864 * result in the passed buffer. A space is added if requested.904 * result in the passed buffer. 865 905 * 866 906 * Results: … … 873 913 */ 874 914 static Boolean 875 VarSubstitute (char *word, Boolean addSpace, Buffer buf, void *patternp) 876 { 877 int wordLen; /* Length of word */ 878 char *cp; /* General pointer */ 915 VarSubstitute (word, addSpace, buf, patternp) 916 char *word; /* Word to modify */ 917 Boolean addSpace; /* True if space should be added before 918 * other characters */ 919 Buffer buf; /* Buffer for result */ 920 ClientData patternp; /* Pattern for substitution */ 921 { 922 register int wordLen; /* Length of word */ 923 register char *cp; /* General pointer */ 879 924 VarPattern *pattern = (VarPattern *) patternp; 880 925 … … 971 1016 * buffer. 972 1017 */ 973 Boolean done;1018 register Boolean done; 974 1019 int origSize; 975 1020 … … 1035 1080 */ 1036 1081 static void 1037 VarREError(int err, regex_t *pat, const char *str) 1082 VarREError(err, pat, str) 1083 int err; 1084 regex_t *pat; 1085 const char *str; 1038 1086 { 1039 1087 char *errbuf; … … 1052 1100 * VarRESubstitute -- 1053 1101 * Perform a regex substitution on the given word, placing the 1054 * result in the passed buffer. A space is added if requested.1102 * result in the passed buffer. 1055 1103 * 1056 1104 * Results: … … 1063 1111 */ 1064 1112 static Boolean 1065 VarRESubstitute(char *word, Boolean addSpace, Buffer buf, void *patternp) 1113 VarRESubstitute(word, addSpace, buf, patternp) 1114 char *word; 1115 Boolean addSpace; 1116 Buffer buf; 1117 ClientData patternp; 1066 1118 { 1067 1119 VarREPattern *pat; … … 1072 1124 int flags = 0; 1073 1125 1074 #define 1126 #define MAYBE_ADD_SPACE() \ 1075 1127 if (addSpace && !added) \ 1076 1128 Buf_AddByte(buf, ' '); \ … … 1191 1243 */ 1192 1244 static char * 1193 VarModify (char *str, Boolean (*modProc)(char *, Boolean, Buffer, void *), 1194 void *datum) 1245 VarModify (str, modProc, datum) 1246 char *str; /* String whose words should be trimmed */ 1247 /* Function to use to modify them */ 1248 Boolean (*modProc) __P((char *, Boolean, Buffer, ClientData)); 1249 ClientData datum; /* Datum to pass it */ 1195 1250 { 1196 1251 Buffer buf; /* Buffer for the new string */ … … 1238 1293 */ 1239 1294 static char * 1240 VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags, 1241 int *length, VarPattern *pattern) 1295 VarGetPattern(ctxt, err, tstr, delim, flags, length, pattern) 1296 GNode *ctxt; 1297 int err; 1298 char **tstr; 1299 int delim; 1300 int *flags; 1301 int *length; 1302 VarPattern *pattern; 1242 1303 { 1243 1304 char *cp; … … 1247 1308 length = &junk; 1248 1309 1249 #define 1310 #define IS_A_MATCH(cp, delim) \ 1250 1311 ((cp[0] == '\\') && ((cp[1] == delim) || \ 1251 1312 (cp[1] == '\\') || (cp[1] == '$') || (pattern && (cp[1] == '&')))) … … 1352 1413 */ 1353 1414 static char * 1354 VarQuote(char *str) 1415 VarQuote(str) 1416 char *str; 1355 1417 { 1356 1418 … … 1392 1454 */ 1393 1455 char * 1394 Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) 1395 { 1396 char *tstr; /* Pointer into str */ 1456 Var_Parse (str, ctxt, err, lengthPtr, freePtr) 1457 char *str; /* The string to parse */ 1458 GNode *ctxt; /* The context for the variable */ 1459 Boolean err; /* TRUE if undefined variables are an error */ 1460 int *lengthPtr; /* OUT: The length of the specification */ 1461 Boolean *freePtr; /* OUT: TRUE if caller should free result */ 1462 { 1463 register char *tstr; /* Pointer into str */ 1397 1464 Var *v; /* Variable in invocation */ 1398 1465 char *cp; /* Secondary pointer into str (place marker 1399 1466 * for tstr) */ 1400 1467 Boolean haveModifier;/* TRUE if have modifiers for the variable */ 1401 charendc; /* Ending character when variable in parens1468 register char endc; /* Ending character when variable in parens 1402 1469 * or braces */ 1403 charstartc=0; /* Starting character when variable in parens1470 register char startc=0; /* Starting character when variable in parens 1404 1471 * or braces */ 1405 1472 int cnt; /* Used to count brace pairs when variable in … … 1430 1497 1431 1498 v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); 1432 if (v == (Var *)N ULL) {1499 if (v == (Var *)NIL) { 1433 1500 *lengthPtr = 2; 1434 1501 … … 1453 1520 case '!': 1454 1521 return("$(.MEMBER)"); 1455 default:1456 break;1457 1522 } 1458 1523 } … … 1512 1577 1513 1578 v = VarFind (str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); 1514 if ((v == (Var *)N ULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&1579 if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) && 1515 1580 (vlen == 2) && (str[1] == 'F' || str[1] == 'D')) 1516 1581 { … … 1537 1602 v = VarFind(vname, ctxt, 0); 1538 1603 1539 if (v != (Var *)N ULL && !haveModifier) {1604 if (v != (Var *)NIL && !haveModifier) { 1540 1605 /* 1541 1606 * No need for nested expansion or anything, as we're … … 1546 1611 1547 1612 if (str[1] == 'D') { 1548 val = VarModify(val, VarHead, ( void *)0);1613 val = VarModify(val, VarHead, (ClientData)0); 1549 1614 } else { 1550 val = VarModify(val, VarTail, ( void *)0);1615 val = VarModify(val, VarTail, (ClientData)0); 1551 1616 } 1552 1617 /* … … 1561 1626 } 1562 1627 break; 1563 default:1564 break;1565 1628 } 1566 1629 } 1567 1630 } 1568 1631 1569 if (v == (Var *)N ULL) {1632 if (v == (Var *)NIL) { 1570 1633 if (((vlen == 1) || 1571 1634 (((vlen == 2) && (str[1] == 'F' || … … 1588 1651 case '!': 1589 1652 dynamic = TRUE; 1590 break;1591 default:1592 1653 break; 1593 1654 } … … 1693 1754 char termc; /* Character which terminated scan */ 1694 1755 1695 DEBUGF(VAR, ("Applying :%c to \"%s\"\n", *tstr, str)); 1756 if (DEBUG(VAR)) { 1757 printf("Applying :%c to \"%s\"\n", *tstr, str); 1758 } 1696 1759 switch (*tstr) { 1697 1760 case 'U': … … 1770 1833 } 1771 1834 if (*tstr == 'M' || *tstr == 'm') { 1772 newStr = VarModify(str, VarMatch, ( void *)pattern);1835 newStr = VarModify(str, VarMatch, (ClientData)pattern); 1773 1836 } else { 1774 1837 newStr = VarModify(str, VarNoMatch, 1775 ( void *)pattern);1838 (ClientData)pattern); 1776 1839 } 1777 1840 if (copy) { … … 1783 1846 { 1784 1847 VarPattern pattern; 1785 char del;1848 register char delim; 1786 1849 Buffer buf; /* Buffer for patterns */ 1787 1850 1788 1851 pattern.flags = 0; 1789 del = tstr[1];1852 delim = tstr[1]; 1790 1853 tstr += 2; 1791 1854 … … 1808 1871 * The result is left in the Buffer buf. 1809 1872 */ 1810 for (cp = tstr; *cp != '\0' && *cp != del ; cp++) {1873 for (cp = tstr; *cp != '\0' && *cp != delim; cp++) { 1811 1874 if ((*cp == '\\') && 1812 ((cp[1] == del ) ||1875 ((cp[1] == delim) || 1813 1876 (cp[1] == '$') || 1814 1877 (cp[1] == '\\'))) … … 1817 1880 cp++; 1818 1881 } else if (*cp == '$') { 1819 if (cp[1] != del ) {1882 if (cp[1] != delim) { 1820 1883 /* 1821 1884 * If unescaped dollar sign not before the … … 1851 1914 * return NULL 1852 1915 */ 1853 if (*cp != del ) {1916 if (*cp != delim) { 1854 1917 *lengthPtr = cp - start + 1; 1855 1918 if (*freePtr) { … … 1858 1921 Buf_Destroy(buf, TRUE); 1859 1922 Error("Unclosed substitution for %s (%c missing)", 1860 v->name, del );1923 v->name, delim); 1861 1924 return (var_Error); 1862 1925 } … … 1883 1946 1884 1947 tstr = cp + 1; 1885 for (cp = tstr; *cp != '\0' && *cp != del ; cp++) {1948 for (cp = tstr; *cp != '\0' && *cp != delim; cp++) { 1886 1949 if ((*cp == '\\') && 1887 ((cp[1] == del ) ||1950 ((cp[1] == delim) || 1888 1951 (cp[1] == '&') || 1889 1952 (cp[1] == '\\') || … … 1892 1955 Buf_AddByte(buf, (Byte)cp[1]); 1893 1956 cp++; 1894 } else if ((*cp == '$') && (cp[1] != del )) {1957 } else if ((*cp == '$') && (cp[1] != delim)) { 1895 1958 char *cp2; 1896 1959 int len; … … 1916 1979 * If didn't end in delimiter character, complain 1917 1980 */ 1918 if (*cp != del ) {1981 if (*cp != delim) { 1919 1982 *lengthPtr = cp - start + 1; 1920 1983 if (*freePtr) { … … 1923 1986 Buf_Destroy(buf, TRUE); 1924 1987 Error("Unclosed substitution for %s (%c missing)", 1925 v->name, del );1988 v->name, delim); 1926 1989 return (var_Error); 1927 1990 } … … 1944 2007 termc = *cp; 1945 2008 newStr = VarModify(str, VarSubstitute, 1946 ( void *)&pattern);2009 (ClientData)&pattern); 1947 2010 /* 1948 2011 * Free the two strings. … … 1998 2061 pattern.flags |= VAR_SUB_ONE; 1999 2062 continue; 2000 default:2001 break;2002 2063 } 2003 2064 break; … … 2023 2084 sizeof(regmatch_t)); 2024 2085 newStr = VarModify(str, VarRESubstitute, 2025 ( void *) &pattern);2086 (ClientData) &pattern); 2026 2087 regfree(&pattern.re); 2027 2088 free(pattern.replace); … … 2039 2100 case 'T': 2040 2101 if (tstr[1] == endc || tstr[1] == ':') { 2041 newStr = VarModify (str, VarTail, ( void *)0);2102 newStr = VarModify (str, VarTail, (ClientData)0); 2042 2103 cp = tstr + 1; 2043 2104 termc = *cp; … … 2047 2108 case 'H': 2048 2109 if (tstr[1] == endc || tstr[1] == ':') { 2049 newStr = VarModify (str, VarHead, ( void *)0);2110 newStr = VarModify (str, VarHead, (ClientData)0); 2050 2111 cp = tstr + 1; 2051 2112 termc = *cp; … … 2055 2116 case 'E': 2056 2117 if (tstr[1] == endc || tstr[1] == ':') { 2057 newStr = VarModify (str, VarSuffix, ( void *)0);2118 newStr = VarModify (str, VarSuffix, (ClientData)0); 2058 2119 cp = tstr + 1; 2059 2120 termc = *cp; … … 2063 2124 case 'R': 2064 2125 if (tstr[1] == endc || tstr[1] == ':') { 2065 newStr = VarModify (str, VarRoot, ( void *)0);2126 newStr = VarModify (str, VarRoot, (ClientData)0); 2066 2127 cp = tstr + 1; 2067 2128 termc = *cp; … … 2072 2133 case 's': 2073 2134 if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) { 2074 char *err or;2075 newStr = Cmd_Exec (str, &err or);2076 if (err or)2077 Error (err or, str);2135 char *err; 2136 newStr = Cmd_Exec (str, &err); 2137 if (err) 2138 Error (err, str); 2078 2139 cp = tstr + 2; 2079 2140 termc = *cp; … … 2143 2204 */ 2144 2205 newStr = VarModify(str, VarSYSVMatch, 2145 ( void *)&pattern);2206 (ClientData)&pattern); 2146 2207 2147 2208 /* … … 2164 2225 } 2165 2226 } 2166 DEBUGF(VAR, ("Result is \"%s\"\n", newStr)); 2227 if (DEBUG(VAR)) { 2228 printf("Result is \"%s\"\n", newStr); 2229 } 2167 2230 2168 2231 if (*freePtr) { … … 2203 2266 } 2204 2267 Buf_Destroy(v->val, destroy); 2205 free( v);2268 free((Address)v); 2206 2269 } else if (v->flags & VAR_JUNK) { 2207 2270 /* … … 2214 2277 *freePtr = FALSE; 2215 2278 Buf_Destroy(v->val, TRUE); 2216 free( v);2279 free((Address)v); 2217 2280 if (dynamic) { 2218 2281 str = emalloc(*lengthPtr + 1); … … 2242 2305 */ 2243 2306 char * 2244 Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr) 2307 Var_Subst (var, str, ctxt, undefErr) 2308 char *var; /* Named variable || NULL for all */ 2309 char *str; /* the string in which to substitute */ 2310 GNode *ctxt; /* the context wherein to find variables */ 2311 Boolean undefErr; /* TRUE if undefineds are an error */ 2245 2312 { 2246 2313 Buffer buf; /* Buffer for forming things */ … … 2377 2444 Buf_AddBytes (buf, strlen (val), (Byte *)val); 2378 2445 if (doFree) { 2379 free ( val);2446 free ((Address)val); 2380 2447 } 2381 2448 } … … 2404 2471 */ 2405 2472 char * 2406 Var_GetTail(char *file) 2407 { 2408 return(VarModify(file, VarTail, (void *)0)); 2473 Var_GetTail(file) 2474 char *file; /* Filename to modify */ 2475 { 2476 return(VarModify(file, VarTail, (ClientData)0)); 2409 2477 } 2410 2478 … … 2425 2493 */ 2426 2494 char * 2427 Var_GetHead(char *file) 2428 { 2429 return(VarModify(file, VarHead, (void *)0)); 2495 Var_GetHead(file) 2496 char *file; /* Filename to manipulate */ 2497 { 2498 return(VarModify(file, VarHead, (ClientData)0)); 2430 2499 } 2431 2500 … … 2443 2512 */ 2444 2513 void 2445 Var_Init ( void)2514 Var_Init () 2446 2515 { 2447 2516 VAR_GLOBAL = Targ_NewGN ("Global"); … … 2453 2522 2454 2523 void 2455 Var_End ( void)2524 Var_End () 2456 2525 { 2457 2526 Lst_Destroy(allVars, VarDelete); … … 2461 2530 /****************** PRINT DEBUGGING INFO *****************/ 2462 2531 static int 2463 VarPrintVar (void *vp, void *dummy __unused) 2532 VarPrintVar (vp, dummy) 2533 ClientData vp; 2534 ClientData dummy; 2464 2535 { 2465 2536 Var *v = (Var *) vp; 2466 2537 printf ("%-16s = %s\n", v->name, (char *) Buf_GetAll(v->val, (int *)NULL)); 2467 return ( 0);2538 return (dummy ? 0 : 0); 2468 2539 } 2469 2540 … … 2475 2546 */ 2476 2547 void 2477 Var_Dump (GNode *ctxt) 2478 { 2479 Lst_ForEach (ctxt->context, VarPrintVar, (void *) 0); 2480 } 2548 Var_Dump (ctxt) 2549 GNode *ctxt; 2550 { 2551 Lst_ForEach (ctxt->context, VarPrintVar, (ClientData) 0); 2552 }
Note:
See TracChangeset
for help on using the changeset viewer.