VirtualBox

Changeset 3138 in kBuild for vendor/gnumake/current/implicit.c


Ignore:
Timestamp:
Mar 12, 2018 7:32:29 PM (7 years ago)
Author:
bird
Message:

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/implicit.c

    r2596 r3138  
    11/* 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.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "rule.h"
     
    3937try_implicit_rule (struct file *file, unsigned int depth)
    4038{
    41   DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));
     39  DBF (DB_IMPLICIT, _("Looking for an implicit rule for '%s'.\n"));
    4240
    4341  /* The order of these searches was previously reversed.  My logic now is
     
    5553    {
    5654      DBF (DB_IMPLICIT,
    57            _("Looking for archive-member implicit rule for `%s'.\n"));
     55           _("Looking for archive-member implicit rule for '%s'.\n"));
    5856      if (pattern_search (file, 1, depth, 0))
    5957        return 1;
     
    7775
    7876  /* Skip any leading whitespace.  */
    79   while (isblank ((unsigned char)*p))
    80     ++p;
     77  NEXT_TOKEN (p);
    8178
    8279  beg = p;
     
    222219
    223220  /* List of dependencies found recursively.  */
    224   struct patdeps *deplist
    225     = 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));
    226223  struct patdeps *pat = deplist;
    227 
    228   /* All the prerequisites actually found for a rule, after expansion.  */
    229   struct dep *deps;
    230224
    231225  /* Names of possible dependencies are constructed in this buffer.  */
     
    254248
    255249  /* Nonzero if we have matched a pattern-rule target
    256      that is not just `%'.  */
     250     that is not just '%'.  */
    257251  int specific_rule_matched = 0;
    258 
    259   struct dep dep_simple;
    260252
    261253  unsigned int ri;  /* uninit checks OK */
     
    276268         but not counting any slash at the end.  (foo/bar/ counts as
    277269         bar/ in directory foo/, not empty in directory foo/bar/.)  */
     270      lastslash = strrchr (filename, '/');
    278271#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)
    281277        lastslash = strrchr (filename, ':');
    282 #else
    283       lastslash = strrchr (filename, '/');
     278#endif
    284279#ifdef HAVE_DOS_PATHS
    285280      /* Handle backslashes (possibly mixed with forward slashes)
     
    293288      }
    294289#endif
    295 #endif
    296290      if (lastslash != 0 && lastslash[1] == '\0')
    297291        lastslash = 0;
     
    325319          const char *target = rule->targets[ti];
    326320          const char *suffix = rule->suffixes[ti];
    327           int check_lastslash;
     321          char check_lastslash;
    328322
    329323          /* Rules that can match any filename and are not terminal
     
    349343            {
    350344#ifdef VMS
    351               check_lastslash = (strchr (target, ']') == 0
    352                                  && strchr (target, ':') == 0);
     345              check_lastslash = strpbrk (target, "/]>:") == NULL;
    353346#else
    354347              check_lastslash = strchr (target, '/') == 0;
     348#endif
    355349#ifdef HAVE_DOS_PATHS
    356350              /* Didn't find it yet: check for DOS-type directories.  */
     
    360354                  check_lastslash = !(b || (target[0] && target[1] == ':'));
    361355                }
    362 #endif
    363356#endif
    364357            }
     
    405398             that rule will be in TRYRULES more than once.  */
    406399          tryrules[nrules].rule = rule;
    407           tryrules[nrules].matches = ti;
     400          tryrules[nrules].matches = ti;
    408401          tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0);
    409402          tryrules[nrules].order = nrules;
    410           tryrules[nrules].checked_lastslash = check_lastslash;
     403          tryrules[nrules].checked_lastslash = check_lastslash;
    411404          ++nrules;
    412405        }
     
    447440        {
    448441          struct dep *dep;
    449           int check_lastslash;
     442          char check_lastslash;
    450443          unsigned int failed = 0;
    451444          int file_variables_set = 0;
     
    491484            }
    492485
    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"),
    494494                             (int) stemlen, stem));
    495495
     
    533533              if (! dep->need_2nd_expansion)
    534534                {
    535                   dep_simple = *dep;
    536                   dep_simple.next = 0;
    537535                  p = strchr (nptr, '%');
    538536                  if (p == 0)
    539                     dep_simple.name = nptr;
     537                    strcpy (depname, nptr);
    540538                  else
    541539                    {
     
    551549                      o += stemlen;
    552550                      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                    }
    556561
    557562                  /* We've used up this dep, so next time get a new one.  */
    558563                  nptr = 0;
    559                   ++deps_found;
    560564                }
    561565
     
    573577                  int add_dir = 0;
    574578                  unsigned int len;
     579                  struct dep **dptr;
    575580
    576581                  nptr = get_next_word (nptr, &len);
     
    615620                    }
    616621
     622                  /* Set up for the next word.  */
     623                  nptr += len;
     624
    617625                  /* Initialize and set file variables if we haven't already
    618626                     done so. */
     
    633641                  /* Perform the 2nd expansion.  */
    634642                  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');
    649670                }
    650671
     
    652673                 2nd expansion), reset it and realloc the arrays.  */
    653674
    654               if (deps_found > max_pattern_deps)
     675              if (deps_found > max_deps)
    655676                {
    656677                  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;
    657681                  deplist = xrealloc (deplist,
    658                                       deps_found * sizeof (struct patdeps));
     682                                      max_deps * sizeof (struct patdeps));
    659683                  pat = deplist + l;
    660                   max_pattern_deps = deps_found;
    661684                }
    662685
     
    674697                      DBS (DB_IMPLICIT,
    675698                           (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"),
    678701                            d->name));
    679702                      tryrules[ri].rule = 0;
     
    688711                  DBS (DB_IMPLICIT,
    689712                       (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));
    692715
    693716                  /* If this prereq is also explicitly mentioned for FILE,
     
    728751                      {
    729752                        DBS (DB_IMPLICIT,
    730                              (_("Found prerequisite `%s' as VPATH `%s'\n"),
     753                             (_("Found prerequisite '%s' as VPATH '%s'\n"),
    731754                              d->name, vname));
    732755                        (pat++)->name = d->name;
     
    742765                    {
    743766                      DBS (DB_IMPLICIT,
    744                            (_("Looking for a rule with intermediate file `%s'.\n"),
     767                           (_("Looking for a rule with intermediate file '%s'.\n"),
    745768                            d->name));
    746769
     
    758781                          int_file->name = d->name;
    759782                          pat->file = int_file;
     783                          int_file = 0;
    760784                          (pat++)->name = d->name;
    761                           int_file = 0;
    762785                          continue;
    763786                        }
     
    780803
    781804              /* Free the ns chain.  */
    782               if (dl != &dep_simple)
    783                 free_dep_chain (dl);
     805              free_dep_chain (dl);
    784806
    785807              if (failed)
     
    791813          file->stem = 0;
    792814
    793           /* This rule is no longer `in use' for recursive searches.  */
     815          /* This rule is no longer 'in use' for recursive searches.  */
    794816          rule->in_use = 0;
    795817
     
    798820            break;
    799821
    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.  */
    804823        }
    805824
     
    847866          /* We don't want to delete an intermediate file that happened
    848867             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.  */
    850870          if (f != 0)
    851             f->precious = 1;
     871            f->secondary = 1;
    852872          else
    853873            f = enter_file (imf->name);
     
    893913             the rule that found it was a terminal one, then we want to mark
    894914             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, we
    896              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.  */
    897917          if (dep->file == 0)
    898918            dep->changed = 1;
     
    938958
    939959  /* If this rule builds other targets, too, put the others into FILE's
    940      `also_make' member.  */
     960     'also_make' member.  */
    941961
    942962  if (rule->num > 1)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette