Changeset 24 for branches/FREEBSD/src/kmk/targ.c
- Timestamp:
- Nov 26, 2002, 10:24:54 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.