Changeset 3140 for trunk/src/kmk/implicit.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/implicit.c
r2591 r3140 1 1 /* Implicit rule searching 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" 20 18 #include "filedef.h" 21 19 #include "rule.h" … … 39 37 try_implicit_rule (struct file *file, unsigned int depth) 40 38 { 41 DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));39 DBF (DB_IMPLICIT, _("Looking for an implicit rule for '%s'.\n")); 42 40 43 41 /* The order of these searches was previously reversed. My logic now is … … 55 53 { 56 54 DBF (DB_IMPLICIT, 57 _("Looking for archive-member implicit rule for `%s'.\n"));55 _("Looking for archive-member implicit rule for '%s'.\n")); 58 56 if (pattern_search (file, 1, depth, 0)) 59 57 return 1; … … 77 75 78 76 /* Skip any leading whitespace. */ 79 while (isblank ((unsigned char)*p)) 80 ++p; 77 NEXT_TOKEN (p); 81 78 82 79 beg = p; … … 226 223 227 224 /* List of dependencies found recursively. */ 228 struct patdeps *deplist229 = xmalloc (max_pattern_deps * sizeof (struct patdeps));225 unsigned int max_deps = max_pattern_deps; 226 struct patdeps *deplist = xmalloc (max_deps * sizeof (struct patdeps)); 230 227 struct patdeps *pat = deplist; 231 232 /* All the prerequisites actually found for a rule, after expansion. */233 struct dep *deps;234 228 235 229 /* Names of possible dependencies are constructed in this buffer. */ … … 258 252 259 253 /* Nonzero if we have matched a pattern-rule target 260 that is not just `%'. */254 that is not just '%'. */ 261 255 int specific_rule_matched = 0; 262 263 struct dep dep_simple;264 256 265 257 unsigned int ri; /* uninit checks OK */ … … 280 272 but not counting any slash at the end. (foo/bar/ counts as 281 273 bar/ in directory foo/, not empty in directory foo/bar/.) */ 274 lastslash = strrchr (filename, '/'); 282 275 #ifdef VMS 283 lastslash = strrchr (filename, ']'); 284 if (lastslash == 0) 276 if (lastslash == NULL) 277 lastslash = strrchr (filename, ']'); 278 if (lastslash == NULL) 279 lastslash = strrchr (filename, '>'); 280 if (lastslash == NULL) 285 281 lastslash = strrchr (filename, ':'); 286 #else 287 lastslash = strrchr (filename, '/'); 282 #endif 288 283 #ifdef HAVE_DOS_PATHS 289 284 /* Handle backslashes (possibly mixed with forward slashes) … … 297 292 } 298 293 #endif 299 #endif300 294 if (lastslash != 0 && lastslash[1] == '\0') 301 295 lastslash = 0; … … 329 323 const char *target = rule->targets[ti]; 330 324 const char *suffix = rule->suffixes[ti]; 331 intcheck_lastslash;325 char check_lastslash; 332 326 333 327 /* Rules that can match any filename and are not terminal … … 353 347 { 354 348 #ifdef VMS 355 check_lastslash = (strchr (target, ']') == 0 356 && strchr (target, ':') == 0); 349 check_lastslash = strpbrk (target, "/]>:") == NULL; 357 350 #else 358 351 check_lastslash = strchr (target, '/') == 0; 352 #endif 359 353 #ifdef HAVE_DOS_PATHS 360 354 /* Didn't find it yet: check for DOS-type directories. */ … … 364 358 check_lastslash = !(b || (target[0] && target[1] == ':')); 365 359 } 366 #endif367 360 #endif 368 361 } … … 409 402 that rule will be in TRYRULES more than once. */ 410 403 tryrules[nrules].rule = rule; 411 404 tryrules[nrules].matches = ti; 412 405 tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0); 413 406 tryrules[nrules].order = nrules; 414 407 tryrules[nrules].checked_lastslash = check_lastslash; 415 408 ++nrules; 416 409 } … … 451 444 { 452 445 struct dep *dep; 453 intcheck_lastslash;446 char check_lastslash; 454 447 unsigned int failed = 0; 455 448 int file_variables_set = 0; … … 495 488 } 496 489 497 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"), 490 if (stemlen > GET_PATH_MAX) 491 { 492 DBS (DB_IMPLICIT, (_("Stem too long: '%.*s'.\n"), 493 (int) stemlen, stem)); 494 continue; 495 } 496 497 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem '%.*s'.\n"), 498 498 (int) stemlen, stem)); 499 499 … … 537 537 if (! dep->need_2nd_expansion) 538 538 { 539 dep_simple = *dep;540 dep_simple.next = 0;541 539 p = strchr (nptr, '%'); 542 540 if (p == 0) 543 dep_simple.name = nptr;541 strcpy (depname, nptr); 544 542 else 545 543 { … … 555 553 o += stemlen; 556 554 strcpy (o, p + 1); 557 dep_simple.name = strcache_add (depname); 558 } 559 dl = &dep_simple; 555 } 556 557 /* Parse the expanded string. It might have wildcards. */ 558 p = depname; 559 dl = PARSE_SIMPLE_SEQ (&p, struct dep); 560 for (d = dl; d != NULL; d = d->next) 561 { 562 ++deps_found; 563 d->ignore_mtime = dep->ignore_mtime; 564 } 560 565 561 566 /* We've used up this dep, so next time get a new one. */ 562 567 nptr = 0; 563 ++deps_found;564 568 } 565 569 … … 577 581 int add_dir = 0; 578 582 unsigned int len; 583 struct dep **dptr; 579 584 580 585 nptr = get_next_word (nptr, &len); … … 618 623 add_dir = 1; 619 624 } 625 626 /* Set up for the next word. */ 627 nptr += len; 620 628 621 629 /* Initialize and set file variables if we haven't already … … 641 649 /* Perform the 2nd expansion. */ 642 650 p = variable_expand_for_file (depname, file); 643 644 /* Parse the expanded string. */ 645 dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? '\0' : '|', 646 add_dir ? dir : NULL, 0); 647 648 for (d = dl; d != NULL; d = d->next) 649 { 650 ++deps_found; 651 if (order_only) 652 d->ignore_mtime = 1; 653 } 654 655 /* Set up for the next word. */ 656 nptr += len; 651 dptr = &dl; 652 653 /* Parse the results into a deps list. */ 654 do 655 { 656 /* Parse the expanded string. */ 657 struct dep *dp = PARSE_FILE_SEQ (&p, struct dep, 658 order_only ? MAP_NUL : MAP_PIPE, 659 add_dir ? dir : NULL, PARSEFS_NONE); 660 *dptr = dp; 661 662 for (d = dp; d != NULL; d = d->next) 663 { 664 ++deps_found; 665 if (order_only) 666 d->ignore_mtime = 1; 667 dptr = &d->next; 668 } 669 670 /* If we stopped due to an order-only token, note it. */ 671 if (*p == '|') 672 { 673 order_only = 1; 674 ++p; 675 } 676 } 677 while (*p != '\0'); 657 678 } 658 679 … … 660 681 2nd expansion), reset it and realloc the arrays. */ 661 682 662 if (deps_found > max_ pattern_deps)683 if (deps_found > max_deps) 663 684 { 664 685 unsigned int l = pat - deplist; 686 /* This might have changed due to recursion. */ 687 max_pattern_deps = MAX(max_pattern_deps, deps_found); 688 max_deps = max_pattern_deps; 665 689 deplist = xrealloc (deplist, 666 deps_found* sizeof (struct patdeps));690 max_deps * sizeof (struct patdeps)); 667 691 pat = deplist + l; 668 max_pattern_deps = deps_found;669 692 } 670 693 … … 682 705 DBS (DB_IMPLICIT, 683 706 (is_rule 684 ? _("Rejecting impossible rule prerequisite `%s'.\n")685 : _("Rejecting impossible implicit prerequisite `%s'.\n"),707 ? _("Rejecting impossible rule prerequisite '%s'.\n") 708 : _("Rejecting impossible implicit prerequisite '%s'.\n"), 686 709 d->name)); 687 710 tryrules[ri].rule = 0; … … 696 719 DBS (DB_IMPLICIT, 697 720 (is_rule 698 ? _("Trying rule prerequisite `%s'.\n")699 : _("Trying implicit prerequisite `%s'.\n"), d->name));721 ? _("Trying rule prerequisite '%s'.\n") 722 : _("Trying implicit prerequisite '%s'.\n"), d->name)); 700 723 701 724 /* If this prereq is also explicitly mentioned for FILE, … … 736 759 { 737 760 DBS (DB_IMPLICIT, 738 (_("Found prerequisite `%s' as VPATH `%s'\n"),761 (_("Found prerequisite '%s' as VPATH '%s'\n"), 739 762 d->name, vname)); 740 763 (pat++)->name = d->name; … … 750 773 { 751 774 DBS (DB_IMPLICIT, 752 (_("Looking for a rule with intermediate file `%s'.\n"),775 (_("Looking for a rule with intermediate file '%s'.\n"), 753 776 d->name)); 754 777 … … 766 789 int_file->name = d->name; 767 790 pat->file = int_file; 791 int_file = 0; 768 792 (pat++)->name = d->name; 769 int_file = 0;770 793 continue; 771 794 } … … 788 811 789 812 /* Free the ns chain. */ 790 if (dl != &dep_simple) 791 free_dep_chain (dl); 813 free_dep_chain (dl); 792 814 793 815 if (failed) … … 799 821 file->stem = 0; 800 822 801 /* This rule is no longer `in use' for recursive searches. */823 /* This rule is no longer 'in use' for recursive searches. */ 802 824 rule->in_use = 0; 803 825 … … 806 828 break; 807 829 808 /* This pattern rule does not apply. If some of its dependencies 809 succeeded, free the data structure describing them. */ 810 /* free_idep_chain (deps); */ 811 deps = 0; 830 /* This pattern rule does not apply. Keep looking. */ 812 831 } 813 832 … … 855 874 /* We don't want to delete an intermediate file that happened 856 875 to be a prerequisite of some (other) target. Mark it as 857 precious. */ 876 secondary. We don't want it to be precious as that disables 877 DELETE_ON_ERROR etc. */ 858 878 if (f != 0) 859 f-> precious= 1;879 f->secondary = 1; 860 880 else 861 881 f = enter_file (imf->name); … … 901 921 the rule that found it was a terminal one, then we want to mark 902 922 the found file so that it will not have implicit rule search done 903 for it. If we are not entering a `struct file' for it now, we904 indicate this with the `changed' flag. */923 for it. If we are not entering a 'struct file' for it now, we 924 indicate this with the 'changed' flag. */ 905 925 if (dep->file == 0) 906 926 dep->changed = 1; … … 950 970 951 971 /* If this rule builds other targets, too, put the others into FILE's 952 `also_make' member. */972 'also_make' member. */ 953 973 954 974 if (rule->num > 1)
Note:
See TracChangeset
for help on using the changeset viewer.