Ignore:
Timestamp:
Jun 20, 2012, 12:44:52 AM (13 years ago)
Author:
bird
Message:

gnumake/current -> 3.82-cvs.

Location:
vendor/gnumake/current
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current

    • Property svn:ignore deleted
  • vendor/gnumake/current/commands.c

    r1989 r2596  
    11/* Command processing for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    4141
    4242
     43
     44static unsigned long
     45dep_hash_1 (const void *key)
     46{
     47  const struct dep *d = key;
     48  return_STRING_HASH_1 (dep_name (d));
     49}
     50
     51static unsigned long
     52dep_hash_2 (const void *key)
     53{
     54  const struct dep *d = key;
     55  return_STRING_HASH_2 (dep_name (d));
     56}
     57
     58static int
     59dep_hash_cmp (const void *x, const void *y)
     60{
     61  const struct dep *dx = x;
     62  const struct dep *dy = y;
     63  return strcmp (dep_name (dx), dep_name (dy));
     64}
     65
    4366/* Set FILE's automatic variables up.  */
    4467
     
    4669set_file_variables (struct file *file)
    4770{
    48   const struct dep *d;
     71  struct dep *d;
    4972  const char *at, *percent, *star, *less;
    5073
     
    118141    if (!d->ignore_mtime)
    119142      {
    120         less = dep_name (d);
     143        if (!d->need_2nd_expansion)
     144          less = dep_name (d);
    121145        break;
    122146      }
     
    150174    unsigned int len;
    151175
     176    struct hash_table dep_hash;
     177    void **slot;
     178
    152179    /* Compute first the value for $+, which is supposed to contain
    153180       duplicate dependencies as they were listed in the makefile.  */
    154181
    155182    plus_len = 0;
     183    bar_len = 0;
    156184    for (d = file->deps; d != 0; d = d->next)
    157       if (! d->ignore_mtime)
    158         plus_len += strlen (dep_name (d)) + 1;
     185      {
     186        if (!d->need_2nd_expansion)
     187          {
     188            if (d->ignore_mtime)
     189              bar_len += strlen (dep_name (d)) + 1;
     190            else
     191              plus_len += strlen (dep_name (d)) + 1;
     192          }
     193      }
     194
     195    if (bar_len == 0)
     196      bar_len++;
     197
    159198    if (plus_len == 0)
    160199      plus_len++;
     
    162201    if (plus_len > plus_max)
    163202      plus_value = xrealloc (plus_value, plus_max = plus_len);
     203
    164204    cp = plus_value;
    165205
    166206    qmark_len = plus_len + 1;   /* Will be this or less.  */
    167207    for (d = file->deps; d != 0; d = d->next)
    168       if (! d->ignore_mtime)
     208      if (! d->ignore_mtime && ! d->need_2nd_expansion)
    169209        {
    170210          const char *c = dep_name (d);
     
    183223          cp += len;
    184224          *cp++ = FILE_LIST_SEPARATOR;
    185           if (! d->changed)
     225          if (! (d->changed || always_make_flag))
    186226            qmark_len -= len + 1;       /* Don't space in $? for this one.  */
    187227        }
     
    191231    cp[cp > plus_value ? -1 : 0] = '\0';
    192232    DEFINE_VARIABLE ("+", 1, plus_value);
    193 
    194     /* Make sure that no dependencies are repeated.  This does not
    195        really matter for the purpose of updating targets, but it
    196        might make some names be listed twice for $^ and $?.  */
    197 
    198     uniquize_deps (file->deps);
    199 
    200     bar_len = 0;
    201     for (d = file->deps; d != 0; d = d->next)
    202       if (d->ignore_mtime)
    203         bar_len += strlen (dep_name (d)) + 1;
    204     if (bar_len == 0)
    205       bar_len++;
    206233
    207234    /* Compute the values for $^, $?, and $|.  */
     
    217244    bp = bar_value;
    218245
     246    /* Make sure that no dependencies are repeated in $^, $?, and $|.  It
     247       would be natural to combine the next two loops but we can't do it
     248       because of a situation where we have two dep entries, the first
     249       is order-only and the second is normal (see below).  */
     250
     251    hash_init (&dep_hash, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);
     252
    219253    for (d = file->deps; d != 0; d = d->next)
    220254      {
    221         const char *c = dep_name (d);
    222 
     255        if (d->need_2nd_expansion)
     256          continue;
     257
     258        slot = hash_find_slot (&dep_hash, d);
     259        if (HASH_VACANT (*slot))
     260          hash_insert_at (&dep_hash, d, slot);
     261        else
     262          {
     263            /* Check if the two prerequisites have different ignore_mtime.
     264               If so then we need to "upgrade" one that is order-only.  */
     265
     266            struct dep* hd = (struct dep*) *slot;
     267
     268            if (d->ignore_mtime != hd->ignore_mtime)
     269              d->ignore_mtime = hd->ignore_mtime = 0;
     270          }
     271      }
     272
     273    for (d = file->deps; d != 0; d = d->next)
     274      {
     275        const char *c;
     276
     277        if (d->need_2nd_expansion || hash_find_item (&dep_hash, d) != d)
     278          continue;
     279
     280        c = dep_name (d);
    223281#ifndef NO_ARCHIVES
    224         if (ar_name (c))
     282        if (ar_name (c))
    225283          {
    226284            c = strchr (c, '(') + 1;
     
    233291        if (d->ignore_mtime)
    234292          {
    235             memcpy (bp, c, len);
     293            memcpy (bp, c, len);
    236294            bp += len;
    237295            *bp++ = FILE_LIST_SEPARATOR;
    238296          }
    239297        else
    240           {
     298          {
    241299            memcpy (cp, c, len);
    242300            cp += len;
    243301            *cp++ = FILE_LIST_SEPARATOR;
    244             if (d->changed)
     302            if (d->changed || always_make_flag)
    245303              {
    246304                memcpy (qp, c, len);
     
    251309      }
    252310
     311    hash_free (&dep_hash, 0);
     312
    253313    /* Kill the last spaces and define the variables.  */
    254314
     
    273333chop_commands (struct commands *cmds)
    274334{
    275   const char *p;
    276335  unsigned int nlines, idx;
    277336  char **lines;
     
    283342    return;
    284343
    285   /* Chop CMDS->commands up into lines in CMDS->command_lines.
    286          Also set the corresponding CMDS->lines_flags elements,
    287          and the CMDS->any_recurse flag.  */
    288 
    289   nlines = 5;
    290   lines = xmalloc (5 * sizeof (char *));
    291   idx = 0;
    292   p = cmds->commands;
    293   while (*p != '\0')
    294     {
    295       const char *end = p;
    296     find_end:;
    297       end = strchr (end, '\n');
    298       if (end == 0)
    299         end = p + strlen (p);
    300       else if (end > p && end[-1] == '\\')
     344  /* Chop CMDS->commands up into lines in CMDS->command_lines.  */
     345
     346  if (one_shell)
     347    {
     348      int l = strlen (cmds->commands);
     349
     350      nlines = 1;
     351      lines = xmalloc (nlines * sizeof (char *));
     352      lines[0] = xstrdup (cmds->commands);
     353
     354      /* Strip the trailing newline.  */
     355      if (l > 0 && lines[0][l-1] == '\n')
     356        lines[0][l-1] = '\0';
     357    }
     358  else
     359    {
     360      const char *p;
     361
     362      nlines = 5;
     363      lines = xmalloc (nlines * sizeof (char *));
     364      idx = 0;
     365      p = cmds->commands;
     366      while (*p != '\0')
    301367        {
    302           int backslash = 1;
    303           const char *b;
    304           for (b = end - 2; b >= p && *b == '\\'; --b)
    305             backslash = !backslash;
    306           if (backslash)
     368          const char *end = p;
     369        find_end:;
     370          end = strchr (end, '\n');
     371          if (end == 0)
     372            end = p + strlen (p);
     373          else if (end > p && end[-1] == '\\')
    307374            {
    308               ++end;
    309               goto find_end;
     375              int backslash = 1;
     376              const char *b;
     377              for (b = end - 2; b >= p && *b == '\\'; --b)
     378                backslash = !backslash;
     379              if (backslash)
     380                {
     381                  ++end;
     382                  goto find_end;
     383                }
    310384            }
     385
     386          if (idx == nlines)
     387            {
     388              nlines += 2;
     389              lines = xrealloc (lines, nlines * sizeof (char *));
     390            }
     391          lines[idx++] = xstrndup (p, end - p);
     392          p = end;
     393          if (*p != '\0')
     394            ++p;
    311395        }
    312396
    313       if (idx == nlines)
     397      if (idx != nlines)
    314398        {
    315           nlines += 2;
     399          nlines = idx;
    316400          lines = xrealloc (lines, nlines * sizeof (char *));
    317401        }
    318       lines[idx++] = savestring (p, end - p);
    319       p = end;
    320       if (*p != '\0')
    321         ++p;
    322     }
    323 
    324   if (idx != nlines)
    325     {
    326       nlines = idx;
    327       lines = xrealloc (lines, nlines * sizeof (char *));
    328     }
     402    }
     403
     404  /* Finally, set the corresponding CMDS->lines_flags elements and the
     405     CMDS->any_recurse flag.  */
    329406
    330407  cmds->ncommand_lines = nlines;
     
    333410  cmds->any_recurse = 0;
    334411  cmds->lines_flags = xmalloc (nlines);
     412
    335413  for (idx = 0; idx < nlines; ++idx)
    336414    {
    337415      int flags = 0;
    338 
    339       for (p = lines[idx];
    340            isblank ((unsigned char)*p) || *p == '-' || *p == '@' || *p == '+';
    341            ++p)
    342         switch (*p)
     416      const char *p = lines[idx];
     417
     418      while (isblank (*p) || *p == '-' || *p == '@' || *p == '+')
     419        switch (*(p++))
    343420          {
    344421          case '+':
Note: See TracChangeset for help on using the changeset viewer.