Changeset 3138 for vendor/gnumake/current/commands.c
- Timestamp:
- Mar 12, 2018, 8:32:29 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/commands.c
r2596 r3138 1 1 /* Command processing for GNU Make. 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make.h" 17 #include "makeint.h" 18 #include "filedef.h" 20 19 #include "dep.h" 21 #include "filedef.h"22 20 #include "variable.h" 23 21 #include "job.h" … … 29 27 30 28 #if VMS 31 # define FILE_LIST_SEPARATOR ','29 # define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ') 32 30 #else 33 31 # define FILE_LIST_SEPARATOR ' ' 34 32 #endif 35 33 36 int remote_kill (int id, int sig); 37 38 #ifndef HAVE_UNISTD_H 34 #ifndef HAVE_UNISTD_H 39 35 int getpid (); 40 36 #endif … … 72 68 const char *at, *percent, *star, *less; 73 69 74 #ifndef 75 /* If the target is an archive member `lib(member)',76 then $@ is `lib' and $% is `member'. */70 #ifndef NO_ARCHIVES 71 /* If the target is an archive member 'lib(member)', 72 then $@ is 'lib' and $% is 'member'. */ 77 73 78 74 if (ar_name (file->name)) … … 94 90 } 95 91 else 96 #endif 92 #endif /* NO_ARCHIVES. */ 97 93 { 98 94 at = file->name; … … 104 100 { 105 101 /* In Unix make, $* is set to the target name with 106 107 explicit rules. We store this in the `stem' member. */102 any suffix in the .SUFFIXES list stripped off for 103 explicit rules. We store this in the 'stem' member. */ 108 104 const char *name; 109 105 unsigned int len; 110 106 111 #ifndef 107 #ifndef NO_ARCHIVES 112 108 if (ar_name (file->name)) 113 114 115 116 109 { 110 name = strchr (file->name, '(') + 1; 111 len = strlen (name) - 1; 112 } 117 113 else 118 114 #endif 119 120 121 122 115 { 116 name = file->name; 117 len = strlen (name); 118 } 123 119 124 120 for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next) 125 126 127 128 129 130 131 132 121 { 122 unsigned int slen = strlen (dep_name (d)); 123 if (len > slen && strneq (dep_name (d), name + (len - slen), slen)) 124 { 125 file->stem = strcache_add_len (name, len - slen); 126 break; 127 } 128 } 133 129 if (d == 0) 134 130 file->stem = ""; 135 131 } 136 132 star = file->stem; … … 151 147 less = at; 152 148 153 #define 149 #define DEFINE_VARIABLE(name, len, value) \ 154 150 (void) define_variable_for_file (name,len,value,o_automatic,0,file) 155 151 … … 204 200 cp = plus_value; 205 201 206 qmark_len = plus_len + 1; 202 qmark_len = plus_len + 1; /* Will be this or less. */ 207 203 for (d = file->deps; d != 0; d = d->next) 208 204 if (! d->ignore_mtime && ! d->need_2nd_expansion) … … 210 206 const char *c = dep_name (d); 211 207 212 #ifndef 208 #ifndef NO_ARCHIVES 213 209 if (ar_name (c)) 214 210 { … … 224 220 *cp++ = FILE_LIST_SEPARATOR; 225 221 if (! (d->changed || always_make_flag)) 226 qmark_len -= len + 1; 222 qmark_len -= len + 1; /* Don't space in $? for this one. */ 227 223 } 228 224 … … 279 275 280 276 c = dep_name (d); 281 #ifndef 277 #ifndef NO_ARCHIVES 282 278 if (ar_name (c)) 283 284 285 286 287 288 #endif 289 279 { 280 c = strchr (c, '(') + 1; 281 len = strlen (c) - 1; 282 } 283 else 284 #endif 285 len = strlen (c); 290 286 291 287 if (d->ignore_mtime) 292 288 { 293 289 memcpy (bp, c, len); 294 295 296 297 290 bp += len; 291 *bp++ = FILE_LIST_SEPARATOR; 292 } 293 else 298 294 { 299 295 memcpy (cp, c, len); … … 323 319 } 324 320 325 #undef 321 #undef DEFINE_VARIABLE 326 322 } 327 323 328 324 329 325 /* Chop CMDS up into individual command lines if necessary. 330 Also set the `lines_flags' and `any_recurse' members. */326 Also set the 'lines_flags' and 'any_recurse' members. */ 331 327 332 328 void … … 405 401 CMDS->any_recurse flag. */ 406 402 403 if (nlines > USHRT_MAX) 404 ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines); 405 407 406 cmds->ncommand_lines = nlines; 408 407 cmds->command_lines = lines; … … 413 412 for (idx = 0; idx < nlines; ++idx) 414 413 { 415 intflags = 0;414 unsigned char flags = 0; 416 415 const char *p = lines[idx]; 417 416 418 while ( isblank(*p) || *p == '-' || *p == '@' || *p == '+')417 while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+') 419 418 switch (*(p++)) 420 419 { … … 436 435 437 436 cmds->lines_flags[idx] = flags; 438 cmds->any_recurse |= flags & COMMANDS_RECURSE ;437 cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0; 439 438 } 440 439 } … … 454 453 455 454 for (p = file->cmds->commands; *p != '\0'; ++p) 456 if (! isspace ((unsigned char)*p) && *p != '-' && *p != '@')455 if (!ISSPACE (*p) && *p != '-' && *p != '@' && *p != '+') 457 456 break; 458 457 if (*p == '\0') … … 460 459 /* If there are no commands, assume everything worked. */ 461 460 set_command_state (file, cs_running); 462 file->update_status = 0;461 file->update_status = us_success; 463 462 notice_finished_file (file); 464 463 return; … … 470 469 471 470 set_file_variables (file); 471 472 /* If this is a loaded dynamic object, unload it before remaking. 473 Some systems don't support overwriting a loaded object. */ 474 if (file->loaded) 475 unload_file (file->name); 472 476 473 477 /* Start the commands running. */ … … 516 520 517 521 if (susp_count != 0) 518 522 fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count); 519 523 else if (susp_count == (DWORD)-1) 520 521 522 523 524 525 524 { 525 DWORD ierr = GetLastError (); 526 527 fprintf (stderr, "SuspendThread: error %ld: %s\n", 528 ierr, map_windows32_error_to_string (ierr)); 529 } 526 530 } 527 531 #endif … … 539 543 struct child *c; 540 544 for (c = children; c != 0; c = c->next) 541 542 545 if (!c->remote) 546 (void) kill (c->pid, SIGTERM); 543 547 } 544 548 … … 558 562 559 563 /* Remote children won't automatically get signals sent 560 564 to the process group, so we must send them. */ 561 565 for (c = children; c != 0; c = c->next) 562 563 566 if (c->remote) 567 (void) remote_kill (c->pid, sig); 564 568 565 569 for (c = children; c != 0; c = c->next) 566 570 delete_child_targets (c); 567 571 568 572 /* Clean up the children. We don't just use the call below because 569 573 we don't want to print the "Waiting for children" message. */ 570 574 while (job_slots_used > 0) 571 575 reap_children (1, 0); 572 576 } 573 577 else … … 584 588 /* We don't want to send ourselves SIGQUIT, because it will 585 589 cause a core dump. Just exit instead. */ 586 exit ( EXIT_FAILURE);590 exit (MAKE_TROUBLE); 587 591 #endif 588 592 … … 620 624 { 621 625 time_t file_date = (file->last_mtime == NONEXISTENT_MTIME 622 623 626 ? (time_t) -1 627 : (time_t) FILE_TIMESTAMP_S (file->last_mtime)); 624 628 if (ar_member_date (file->name) != file_date) 625 { 626 if (on_behalf_of) 627 error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"), 628 on_behalf_of, file->name); 629 else 630 error (NILF, _("*** Archive member `%s' may be bogus; not deleted"), 631 file->name); 632 } 629 { 630 if (on_behalf_of) 631 OSS (error, NILF, 632 _("*** [%s] Archive member '%s' may be bogus; not deleted"), 633 on_behalf_of, file->name); 634 else 635 OS (error, NILF, 636 _("*** Archive member '%s' may be bogus; not deleted"), 637 file->name); 638 } 633 639 return; 634 640 } … … 641 647 { 642 648 if (on_behalf_of) 643 error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name); 649 OSS (error, NILF, 650 _("*** [%s] Deleting file '%s'"), on_behalf_of, file->name); 644 651 else 645 error (NILF, _("*** Deleting file `%s'"), file->name);652 OS (error, NILF, _("*** Deleting file '%s'"), file->name); 646 653 if (unlink (file->name) < 0 647 && errno != ENOENT)/* It disappeared; so what. */648 654 && errno != ENOENT) /* It disappeared; so what. */ 655 perror_with_name ("unlink: ", file->name); 649 656 } 650 657 } … … 665 672 delete_target (child->file, NULL); 666 673 667 /* Also remove any non-precious targets listed in the `also_make' member. */674 /* Also remove any non-precious targets listed in the 'also_make' member. */ 668 675 for (d = child->file->also_make; d != 0; d = d->next) 669 676 delete_target (d->file, child->file->name); … … 685 692 puts (_(" (built-in):")); 686 693 else 687 printf (_(" (from `%s', line %lu):\n"),694 printf (_(" (from '%s', line %lu):\n"), 688 695 cmds->fileinfo.filenm, cmds->fileinfo.lineno); 689 696 … … 692 699 { 693 700 const char *end; 694 695 end = strchr (s, '\n'); 696 if (end == 0) 697 end = s + strlen (s); 701 int bs; 702 703 /* Print one full logical recipe line: find a non-escaped newline. */ 704 for (end = s, bs = 0; *end != '\0'; ++end) 705 { 706 if (*end == '\n' && !bs) 707 break; 708 709 bs = *end == '\\' ? !bs : 0; 710 } 698 711 699 712 printf ("%c%.*s\n", cmd_prefix, (int) (end - s), s);
Note:
See TracChangeset
for help on using the changeset viewer.