Changeset 3140 for trunk/src/kmk/commands.c
- Timestamp:
- Mar 14, 2018, 10:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/commands.c
r2754 r3140 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" … … 32 30 33 31 #if VMS 34 # define FILE_LIST_SEPARATOR ','32 # define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ') 35 33 #else 36 34 # define FILE_LIST_SEPARATOR ' ' 37 35 #endif 38 36 39 int remote_kill (int id, int sig); 40 41 #ifndef HAVE_UNISTD_H 37 #ifndef HAVE_UNISTD_H 42 38 int getpid (); 43 39 #endif … … 176 172 #endif 177 173 178 #ifndef 179 /* If the target is an archive member `lib(member)',180 then $@ is `lib' and $% is `member'. */174 #ifndef NO_ARCHIVES 175 /* If the target is an archive member 'lib(member)', 176 then $@ is 'lib' and $% is 'member'. */ 181 177 182 178 if (ar_name (file->name)) … … 198 194 } 199 195 else 200 #endif 196 #endif /* NO_ARCHIVES. */ 201 197 { 202 198 at = file->name; … … 208 204 { 209 205 /* In Unix make, $* is set to the target name with 210 211 explicit rules. We store this in the `stem' member. */206 any suffix in the .SUFFIXES list stripped off for 207 explicit rules. We store this in the 'stem' member. */ 212 208 const char *name; 213 209 unsigned int len; 214 210 215 #ifndef 211 #ifndef NO_ARCHIVES 216 212 if (ar_name (file->name)) 213 { 214 name = strchr (file->name, '(') + 1; 215 len = strlen (name) - 1; 216 } 217 else 218 #endif 217 219 { 218 name = strchr (file->name, '(') + 1; 219 len = strlen (name) - 1; 220 } 221 else 222 #endif 223 { 224 name = file->name; 220 name = file->name; 225 221 #ifndef CONFIG_WITH_STRCACHE2 226 227 #else 228 229 #endif 230 222 len = strlen (name); 223 #else 224 len = strcache2_get_len (&file_strcache, name); 225 #endif 226 } 231 227 232 228 #ifndef CONFIG_WITH_STRCACHE2 233 229 for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next) 234 235 230 { 231 unsigned int slen = strlen (dep_name (d)); 236 232 #else 237 233 for (d = enter_file (suffixes_strcached)->deps; d ; d = d->next) 238 234 { 239 240 #endif 241 242 243 244 245 246 235 unsigned int slen = strcache2_get_len (&file_strcache, dep_name (d)); 236 #endif 237 if (len > slen && strneq (dep_name (d), name + (len - slen), slen)) 238 { 239 file->stem = strcache_add_len (name, len - slen); 240 break; 241 } 242 } 247 243 if (d == 0) 248 244 file->stem = ""; 249 245 } 250 246 star = file->stem; … … 265 261 less = at; 266 262 267 #define 263 #define DEFINE_VARIABLE(name, len, value) \ 268 264 (void) define_variable_for_file (name,len,value,o_automatic,0,file) 269 265 … … 369 365 cp = plus_value; 370 366 371 qmark_len = plus_len + 1; 367 qmark_len = plus_len + 1; /* Will be this or less. */ 372 368 for (d = file->deps; d != 0; d = d->next) 373 369 if (! d->ignore_mtime && ! d->need_2nd_expansion) … … 375 371 const char *c = dep_name (d); 376 372 377 #ifndef 373 #ifndef NO_ARCHIVES 378 374 if (ar_name (c)) 379 375 { … … 393 389 *cp++ = FILE_LIST_SEPARATOR; 394 390 if (! (d->changed || always_make_flag)) 395 qmark_len -= len + 1; 391 qmark_len -= len + 1; /* Don't space in $? for this one. */ 396 392 } 397 393 … … 448 444 449 445 c = dep_name (d); 450 #ifndef 446 #ifndef NO_ARCHIVES 451 447 if (ar_name (c)) 452 453 454 455 456 448 { 449 c = strchr (c, '(') + 1; 450 len = strlen (c) - 1; 451 } 452 else 457 453 #endif 458 454 #ifndef CONFIG_WITH_STRCACHE2 459 460 #else 461 455 len = strlen (c); 456 #else 457 len = strcache2_get_len (&file_strcache, c); 462 458 #endif 463 459 … … 465 461 { 466 462 memcpy (bp, c, len); 467 468 469 470 463 bp += len; 464 *bp++ = FILE_LIST_SEPARATOR; 465 } 466 else 471 467 { 472 468 memcpy (cp, c, len); … … 495 491 DEFINE_VARIABLE ("|", 1, bar_value); 496 492 } 497 #undef 493 #undef DEFINE_VARIABLE 498 494 } 499 495 500 496 501 497 /* Chop CMDS up into individual command lines if necessary. 502 Also set the `lines_flags' and `any_recurse' members. */498 Also set the 'lines_flags' and 'any_recurse' members. */ 503 499 504 500 void … … 577 573 CMDS->any_recurse flag. */ 578 574 575 if (nlines > USHRT_MAX) 576 ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines); 577 579 578 cmds->ncommand_lines = nlines; 580 579 cmds->command_lines = lines; … … 589 588 for (idx = 0; idx < nlines; ++idx) 590 589 { 591 intflags = 0;590 unsigned char flags = 0; 592 591 const char *p = lines[idx]; 593 592 594 while ( isblank(*p) || *p == '-' || *p == '@' || *p == '+' IF_WITH_COMMANDS_FUNC(|| *p == '%'))593 while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+' IF_WITH_COMMANDS_FUNC(|| *p == '%')) 595 594 switch (*(p++)) 596 595 { … … 628 627 629 628 cmds->lines_flags[idx] = flags; 630 cmds->any_recurse |= flags & COMMANDS_RECURSE ;629 cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0; 631 630 } 632 631 } … … 668 667 669 668 for (p = file->cmds->commands; *p != '\0'; ++p) 670 if (! isspace ((unsigned char)*p) && *p != '-' && *p != '@')669 if (!ISSPACE (*p) && *p != '-' && *p != '@' && *p != '+') 671 670 break; 672 671 if (*p == '\0') … … 677 676 #endif 678 677 set_command_state (file, cs_running); 679 file->update_status = 0;678 file->update_status = us_success; 680 679 notice_finished_file (file); 681 680 return; … … 691 690 set_file_variables (file); 692 691 #endif 692 693 /* If this is a loaded dynamic object, unload it before remaking. 694 Some systems don't support overwriting a loaded object. */ 695 if (file->loaded) 696 unload_file (file->name); 693 697 694 698 /* Start the commands running. */ … … 737 741 738 742 if (susp_count != 0) 739 743 fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count); 740 744 else if (susp_count == (DWORD)-1) 741 742 743 744 745 746 745 { 746 DWORD ierr = GetLastError (); 747 748 fprintf (stderr, "SuspendThread: error %ld: %s\n", 749 ierr, map_windows32_error_to_string (ierr)); 750 } 747 751 } 748 752 #endif … … 760 764 struct child *c; 761 765 for (c = children; c != 0; c = c->next) 762 763 766 if (!c->remote) 767 (void) kill (c->pid, SIGTERM); 764 768 } 765 769 … … 779 783 780 784 /* Remote children won't automatically get signals sent 781 785 to the process group, so we must send them. */ 782 786 for (c = children; c != 0; c = c->next) 783 784 787 if (c->remote) 788 (void) remote_kill (c->pid, sig); 785 789 786 790 for (c = children; c != 0; c = c->next) 787 791 delete_child_targets (c); 788 792 789 793 /* Clean up the children. We don't just use the call below because 790 794 we don't want to print the "Waiting for children" message. */ 791 795 while (job_slots_used > 0) 792 796 reap_children (1, 0); 793 797 } 794 798 else … … 804 808 /* We don't want to send ourselves SIGQUIT, because it will 805 809 cause a core dump. Just exit instead. */ 806 exit ( EXIT_FAILURE);810 exit (MAKE_TROUBLE); 807 811 #endif 808 812 … … 845 849 { 846 850 time_t file_date = (file->last_mtime == NONEXISTENT_MTIME 847 848 851 ? (time_t) -1 852 : (time_t) FILE_TIMESTAMP_S (file->last_mtime)); 849 853 if (ar_member_date (file->name) != file_date) 850 { 851 if (on_behalf_of) 852 error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"), 853 on_behalf_of, file->name); 854 else 855 error (NILF, _("*** Archive member `%s' may be bogus; not deleted"), 856 file->name); 857 } 854 { 855 if (on_behalf_of) 856 OSS (error, NILF, 857 _("*** [%s] Archive member '%s' may be bogus; not deleted"), 858 on_behalf_of, file->name); 859 else 860 OS (error, NILF, 861 _("*** Archive member '%s' may be bogus; not deleted"), 862 file->name); 863 } 858 864 return; 859 865 } … … 866 872 { 867 873 if (on_behalf_of) 868 error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name); 874 OSS (error, NILF, 875 _("*** [%s] Deleting file '%s'"), on_behalf_of, file->name); 869 876 else 870 error (NILF, _("*** Deleting file `%s'"), file->name);877 OS (error, NILF, _("*** Deleting file '%s'"), file->name); 871 878 if (unlink (file->name) < 0 872 && errno != ENOENT)/* It disappeared; so what. */873 879 && errno != ENOENT) /* It disappeared; so what. */ 880 perror_with_name ("unlink: ", file->name); 874 881 } 875 882 } … … 890 897 delete_target (child->file, NULL); 891 898 892 /* Also remove any non-precious targets listed in the `also_make' member. */899 /* Also remove any non-precious targets listed in the 'also_make' member. */ 893 900 for (d = child->file->also_make; d != 0; d = d->next) 894 901 delete_target (d->file, child->file->name); … … 923 930 puts (_(" (built-in):")); 924 931 else 925 printf (_(" (from `%s', line %lu):\n"),932 printf (_(" (from '%s', line %lu):\n"), 926 933 cmds->fileinfo.filenm, cmds->fileinfo.lineno); 927 934 … … 930 937 { 931 938 const char *end; 932 933 end = strchr (s, '\n'); 934 if (end == 0) 935 end = s + strlen (s); 939 int bs; 940 941 /* Print one full logical recipe line: find a non-escaped newline. */ 942 for (end = s, bs = 0; *end != '\0'; ++end) 943 { 944 if (*end == '\n' && !bs) 945 break; 946 947 bs = *end == '\\' ? !bs : 0; 948 } 936 949 937 950 printf ("%c%.*s\n", cmd_prefix, (int) (end - s), s);
Note:
See TracChangeset
for help on using the changeset viewer.