Changeset 3138 in kBuild for vendor/gnumake/current/implicit.c
- Timestamp:
- Mar 12, 2018 7:32:29 PM (7 years ago)
- File:
-
- 1 edited
-
vendor/gnumake/current/implicit.c (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/implicit.c
r2596 r3138 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; … … 222 219 223 220 /* List of dependencies found recursively. */ 224 struct patdeps *deplist225 = xmalloc (max_pattern_deps * sizeof (struct patdeps));221 unsigned int max_deps = max_pattern_deps; 222 struct patdeps *deplist = xmalloc (max_deps * sizeof (struct patdeps)); 226 223 struct patdeps *pat = deplist; 227 228 /* All the prerequisites actually found for a rule, after expansion. */229 struct dep *deps;230 224 231 225 /* Names of possible dependencies are constructed in this buffer. */ … … 254 248 255 249 /* Nonzero if we have matched a pattern-rule target 256 that is not just `%'. */250 that is not just '%'. */ 257 251 int specific_rule_matched = 0; 258 259 struct dep dep_simple;260 252 261 253 unsigned int ri; /* uninit checks OK */ … … 276 268 but not counting any slash at the end. (foo/bar/ counts as 277 269 bar/ in directory foo/, not empty in directory foo/bar/.) */ 270 lastslash = strrchr (filename, '/'); 278 271 #ifdef VMS 279 lastslash = strrchr (filename, ']'); 280 if (lastslash == 0) 272 if (lastslash == NULL) 273 lastslash = strrchr (filename, ']'); 274 if (lastslash == NULL) 275 lastslash = strrchr (filename, '>'); 276 if (lastslash == NULL) 281 277 lastslash = strrchr (filename, ':'); 282 #else 283 lastslash = strrchr (filename, '/'); 278 #endif 284 279 #ifdef HAVE_DOS_PATHS 285 280 /* Handle backslashes (possibly mixed with forward slashes) … … 293 288 } 294 289 #endif 295 #endif296 290 if (lastslash != 0 && lastslash[1] == '\0') 297 291 lastslash = 0; … … 325 319 const char *target = rule->targets[ti]; 326 320 const char *suffix = rule->suffixes[ti]; 327 intcheck_lastslash;321 char check_lastslash; 328 322 329 323 /* Rules that can match any filename and are not terminal … … 349 343 { 350 344 #ifdef VMS 351 check_lastslash = (strchr (target, ']') == 0 352 && strchr (target, ':') == 0); 345 check_lastslash = strpbrk (target, "/]>:") == NULL; 353 346 #else 354 347 check_lastslash = strchr (target, '/') == 0; 348 #endif 355 349 #ifdef HAVE_DOS_PATHS 356 350 /* Didn't find it yet: check for DOS-type directories. */ … … 360 354 check_lastslash = !(b || (target[0] && target[1] == ':')); 361 355 } 362 #endif363 356 #endif 364 357 } … … 405 398 that rule will be in TRYRULES more than once. */ 406 399 tryrules[nrules].rule = rule; 407 tryrules[nrules].matches = ti;400 tryrules[nrules].matches = ti; 408 401 tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0); 409 402 tryrules[nrules].order = nrules; 410 tryrules[nrules].checked_lastslash = check_lastslash;403 tryrules[nrules].checked_lastslash = check_lastslash; 411 404 ++nrules; 412 405 } … … 447 440 { 448 441 struct dep *dep; 449 intcheck_lastslash;442 char check_lastslash; 450 443 unsigned int failed = 0; 451 444 int file_variables_set = 0; … … 491 484 } 492 485 493 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"), 486 if (stemlen > GET_PATH_MAX) 487 { 488 DBS (DB_IMPLICIT, (_("Stem too long: '%.*s'.\n"), 489 (int) stemlen, stem)); 490 continue; 491 } 492 493 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem '%.*s'.\n"), 494 494 (int) stemlen, stem)); 495 495 … … 533 533 if (! dep->need_2nd_expansion) 534 534 { 535 dep_simple = *dep;536 dep_simple.next = 0;537 535 p = strchr (nptr, '%'); 538 536 if (p == 0) 539 dep_simple.name = nptr;537 strcpy (depname, nptr); 540 538 else 541 539 { … … 551 549 o += stemlen; 552 550 strcpy (o, p + 1); 553 dep_simple.name = strcache_add (depname); 554 } 555 dl = &dep_simple; 551 } 552 553 /* Parse the expanded string. It might have wildcards. */ 554 p = depname; 555 dl = PARSE_SIMPLE_SEQ (&p, struct dep); 556 for (d = dl; d != NULL; d = d->next) 557 { 558 ++deps_found; 559 d->ignore_mtime = dep->ignore_mtime; 560 } 556 561 557 562 /* We've used up this dep, so next time get a new one. */ 558 563 nptr = 0; 559 ++deps_found;560 564 } 561 565 … … 573 577 int add_dir = 0; 574 578 unsigned int len; 579 struct dep **dptr; 575 580 576 581 nptr = get_next_word (nptr, &len); … … 615 620 } 616 621 622 /* Set up for the next word. */ 623 nptr += len; 624 617 625 /* Initialize and set file variables if we haven't already 618 626 done so. */ … … 633 641 /* Perform the 2nd expansion. */ 634 642 p = variable_expand_for_file (depname, file); 635 636 /* Parse the expanded string. */ 637 dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? '\0' : '|', 638 add_dir ? dir : NULL, 0); 639 640 for (d = dl; d != NULL; d = d->next) 641 { 642 ++deps_found; 643 if (order_only) 644 d->ignore_mtime = 1; 645 } 646 647 /* Set up for the next word. */ 648 nptr += len; 643 dptr = &dl; 644 645 /* Parse the results into a deps list. */ 646 do 647 { 648 /* Parse the expanded string. */ 649 struct dep *dp = PARSE_FILE_SEQ (&p, struct dep, 650 order_only ? MAP_NUL : MAP_PIPE, 651 add_dir ? dir : NULL, PARSEFS_NONE); 652 *dptr = dp; 653 654 for (d = dp; d != NULL; d = d->next) 655 { 656 ++deps_found; 657 if (order_only) 658 d->ignore_mtime = 1; 659 dptr = &d->next; 660 } 661 662 /* If we stopped due to an order-only token, note it. */ 663 if (*p == '|') 664 { 665 order_only = 1; 666 ++p; 667 } 668 } 669 while (*p != '\0'); 649 670 } 650 671 … … 652 673 2nd expansion), reset it and realloc the arrays. */ 653 674 654 if (deps_found > max_ pattern_deps)675 if (deps_found > max_deps) 655 676 { 656 677 unsigned int l = pat - deplist; 678 /* This might have changed due to recursion. */ 679 max_pattern_deps = MAX(max_pattern_deps, deps_found); 680 max_deps = max_pattern_deps; 657 681 deplist = xrealloc (deplist, 658 deps_found* sizeof (struct patdeps));682 max_deps * sizeof (struct patdeps)); 659 683 pat = deplist + l; 660 max_pattern_deps = deps_found;661 684 } 662 685 … … 674 697 DBS (DB_IMPLICIT, 675 698 (is_rule 676 ? _("Rejecting impossible rule prerequisite `%s'.\n")677 : _("Rejecting impossible implicit prerequisite `%s'.\n"),699 ? _("Rejecting impossible rule prerequisite '%s'.\n") 700 : _("Rejecting impossible implicit prerequisite '%s'.\n"), 678 701 d->name)); 679 702 tryrules[ri].rule = 0; … … 688 711 DBS (DB_IMPLICIT, 689 712 (is_rule 690 ? _("Trying rule prerequisite `%s'.\n")691 : _("Trying implicit prerequisite `%s'.\n"), d->name));713 ? _("Trying rule prerequisite '%s'.\n") 714 : _("Trying implicit prerequisite '%s'.\n"), d->name)); 692 715 693 716 /* If this prereq is also explicitly mentioned for FILE, … … 728 751 { 729 752 DBS (DB_IMPLICIT, 730 (_("Found prerequisite `%s' as VPATH `%s'\n"),753 (_("Found prerequisite '%s' as VPATH '%s'\n"), 731 754 d->name, vname)); 732 755 (pat++)->name = d->name; … … 742 765 { 743 766 DBS (DB_IMPLICIT, 744 (_("Looking for a rule with intermediate file `%s'.\n"),767 (_("Looking for a rule with intermediate file '%s'.\n"), 745 768 d->name)); 746 769 … … 758 781 int_file->name = d->name; 759 782 pat->file = int_file; 783 int_file = 0; 760 784 (pat++)->name = d->name; 761 int_file = 0;762 785 continue; 763 786 } … … 780 803 781 804 /* Free the ns chain. */ 782 if (dl != &dep_simple) 783 free_dep_chain (dl); 805 free_dep_chain (dl); 784 806 785 807 if (failed) … … 791 813 file->stem = 0; 792 814 793 /* This rule is no longer `in use' for recursive searches. */815 /* This rule is no longer 'in use' for recursive searches. */ 794 816 rule->in_use = 0; 795 817 … … 798 820 break; 799 821 800 /* This pattern rule does not apply. If some of its dependencies 801 succeeded, free the data structure describing them. */ 802 /* free_idep_chain (deps); */ 803 deps = 0; 822 /* This pattern rule does not apply. Keep looking. */ 804 823 } 805 824 … … 847 866 /* We don't want to delete an intermediate file that happened 848 867 to be a prerequisite of some (other) target. Mark it as 849 precious. */ 868 secondary. We don't want it to be precious as that disables 869 DELETE_ON_ERROR etc. */ 850 870 if (f != 0) 851 f-> precious= 1;871 f->secondary = 1; 852 872 else 853 873 f = enter_file (imf->name); … … 893 913 the rule that found it was a terminal one, then we want to mark 894 914 the found file so that it will not have implicit rule search done 895 for it. If we are not entering a `struct file' for it now, we896 indicate this with the `changed' flag. */915 for it. If we are not entering a 'struct file' for it now, we 916 indicate this with the 'changed' flag. */ 897 917 if (dep->file == 0) 898 918 dep->changed = 1; … … 938 958 939 959 /* If this rule builds other targets, too, put the others into FILE's 940 `also_make' member. */960 'also_make' member. */ 941 961 942 962 if (rule->num > 1)
Note:
See TracChangeset
for help on using the changeset viewer.

