Ignore:
Timestamp:
Mar 14, 2018, 10:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/implicit.c

    r2591 r3140  
    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;
     
    226223
    227224  /* List of dependencies found recursively.  */
    228   struct patdeps *deplist
    229     = 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));
    230227  struct patdeps *pat = deplist;
    231 
    232   /* All the prerequisites actually found for a rule, after expansion.  */
    233   struct dep *deps;
    234228
    235229  /* Names of possible dependencies are constructed in this buffer.  */
     
    258252
    259253  /* Nonzero if we have matched a pattern-rule target
    260      that is not just `%'.  */
     254     that is not just '%'.  */
    261255  int specific_rule_matched = 0;
    262 
    263   struct dep dep_simple;
    264256
    265257  unsigned int ri;  /* uninit checks OK */
     
    280272         but not counting any slash at the end.  (foo/bar/ counts as
    281273         bar/ in directory foo/, not empty in directory foo/bar/.)  */
     274      lastslash = strrchr (filename, '/');
    282275#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)
    285281        lastslash = strrchr (filename, ':');
    286 #else
    287       lastslash = strrchr (filename, '/');
     282#endif
    288283#ifdef HAVE_DOS_PATHS
    289284      /* Handle backslashes (possibly mixed with forward slashes)
     
    297292      }
    298293#endif
    299 #endif
    300294      if (lastslash != 0 && lastslash[1] == '\0')
    301295        lastslash = 0;
     
    329323          const char *target = rule->targets[ti];
    330324          const char *suffix = rule->suffixes[ti];
    331           int check_lastslash;
     325          char check_lastslash;
    332326
    333327          /* Rules that can match any filename and are not terminal
     
    353347            {
    354348#ifdef VMS
    355               check_lastslash = (strchr (target, ']') == 0
    356                                  && strchr (target, ':') == 0);
     349              check_lastslash = strpbrk (target, "/]>:") == NULL;
    357350#else
    358351              check_lastslash = strchr (target, '/') == 0;
     352#endif
    359353#ifdef HAVE_DOS_PATHS
    360354              /* Didn't find it yet: check for DOS-type directories.  */
     
    364358                  check_lastslash = !(b || (target[0] && target[1] == ':'));
    365359                }
    366 #endif
    367360#endif
    368361            }
     
    409402             that rule will be in TRYRULES more than once.  */
    410403          tryrules[nrules].rule = rule;
    411           tryrules[nrules].matches = ti;
     404          tryrules[nrules].matches = ti;
    412405          tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0);
    413406          tryrules[nrules].order = nrules;
    414           tryrules[nrules].checked_lastslash = check_lastslash;
     407          tryrules[nrules].checked_lastslash = check_lastslash;
    415408          ++nrules;
    416409        }
     
    451444        {
    452445          struct dep *dep;
    453           int check_lastslash;
     446          char check_lastslash;
    454447          unsigned int failed = 0;
    455448          int file_variables_set = 0;
     
    495488            }
    496489
    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"),
    498498                             (int) stemlen, stem));
    499499
     
    537537              if (! dep->need_2nd_expansion)
    538538                {
    539                   dep_simple = *dep;
    540                   dep_simple.next = 0;
    541539                  p = strchr (nptr, '%');
    542540                  if (p == 0)
    543                     dep_simple.name = nptr;
     541                    strcpy (depname, nptr);
    544542                  else
    545543                    {
     
    555553                      o += stemlen;
    556554                      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                    }
    560565
    561566                  /* We've used up this dep, so next time get a new one.  */
    562567                  nptr = 0;
    563                   ++deps_found;
    564568                }
    565569
     
    577581                  int add_dir = 0;
    578582                  unsigned int len;
     583                  struct dep **dptr;
    579584
    580585                  nptr = get_next_word (nptr, &len);
     
    618623                        add_dir = 1;
    619624                    }
     625
     626                  /* Set up for the next word.  */
     627                  nptr += len;
    620628
    621629                  /* Initialize and set file variables if we haven't already
     
    641649                  /* Perform the 2nd expansion.  */
    642650                  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');
    657678                }
    658679
     
    660681                 2nd expansion), reset it and realloc the arrays.  */
    661682
    662               if (deps_found > max_pattern_deps)
     683              if (deps_found > max_deps)
    663684                {
    664685                  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;
    665689                  deplist = xrealloc (deplist,
    666                                       deps_found * sizeof (struct patdeps));
     690                                      max_deps * sizeof (struct patdeps));
    667691                  pat = deplist + l;
    668                   max_pattern_deps = deps_found;
    669692                }
    670693
     
    682705                      DBS (DB_IMPLICIT,
    683706                           (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"),
    686709                            d->name));
    687710                      tryrules[ri].rule = 0;
     
    696719                  DBS (DB_IMPLICIT,
    697720                       (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));
    700723
    701724                  /* If this prereq is also explicitly mentioned for FILE,
     
    736759                      {
    737760                        DBS (DB_IMPLICIT,
    738                              (_("Found prerequisite `%s' as VPATH `%s'\n"),
     761                             (_("Found prerequisite '%s' as VPATH '%s'\n"),
    739762                              d->name, vname));
    740763                        (pat++)->name = d->name;
     
    750773                    {
    751774                      DBS (DB_IMPLICIT,
    752                            (_("Looking for a rule with intermediate file `%s'.\n"),
     775                           (_("Looking for a rule with intermediate file '%s'.\n"),
    753776                            d->name));
    754777
     
    766789                          int_file->name = d->name;
    767790                          pat->file = int_file;
     791                          int_file = 0;
    768792                          (pat++)->name = d->name;
    769                           int_file = 0;
    770793                          continue;
    771794                        }
     
    788811
    789812              /* Free the ns chain.  */
    790               if (dl != &dep_simple)
    791                 free_dep_chain (dl);
     813              free_dep_chain (dl);
    792814
    793815              if (failed)
     
    799821          file->stem = 0;
    800822
    801           /* This rule is no longer `in use' for recursive searches.  */
     823          /* This rule is no longer 'in use' for recursive searches.  */
    802824          rule->in_use = 0;
    803825
     
    806828            break;
    807829
    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.  */
    812831        }
    813832
     
    855874          /* We don't want to delete an intermediate file that happened
    856875             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.  */
    858878          if (f != 0)
    859             f->precious = 1;
     879            f->secondary = 1;
    860880          else
    861881            f = enter_file (imf->name);
     
    901921             the rule that found it was a terminal one, then we want to mark
    902922             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, we
    904              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.  */
    905925          if (dep->file == 0)
    906926            dep->changed = 1;
     
    950970
    951971  /* If this rule builds other targets, too, put the others into FILE's
    952      `also_make' member.  */
     972     'also_make' member.  */
    953973
    954974  if (rule->num > 1)
Note: See TracChangeset for help on using the changeset viewer.