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/commands.c

    r2754 r3140  
    11/* Command processing 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"
     18#include "filedef.h"
    2019#include "dep.h"
    21 #include "filedef.h"
    2220#include "variable.h"
    2321#include "job.h"
     
    3230
    3331#if VMS
    34 # define FILE_LIST_SEPARATOR ','
     32# define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ')
    3533#else
    3634# define FILE_LIST_SEPARATOR ' '
    3735#endif
    3836
    39 int remote_kill (int id, int sig);
    40 
    41 #ifndef HAVE_UNISTD_H
     37#ifndef HAVE_UNISTD_H
    4238int getpid ();
    4339#endif
     
    176172#endif
    177173
    178 #ifndef NO_ARCHIVES
    179   /* If the target is an archive member `lib(member)',
    180      then $@ is `lib' and $% is `member'.  */
     174#ifndef NO_ARCHIVES
     175  /* If the target is an archive member 'lib(member)',
     176     then $@ is 'lib' and $% is 'member'.  */
    181177
    182178  if (ar_name (file->name))
     
    198194    }
    199195  else
    200 #endif  /* NO_ARCHIVES.  */
     196#endif  /* NO_ARCHIVES.  */
    201197    {
    202198      at = file->name;
     
    208204    {
    209205      /* In Unix make, $* is set to the target name with
    210         any suffix in the .SUFFIXES list stripped off for
    211          explicit rules.  We store this in the `stem' member.  */
     206        any suffix in the .SUFFIXES list stripped off for
     207         explicit rules.  We store this in the 'stem' member.  */
    212208      const char *name;
    213209      unsigned int len;
    214210
    215 #ifndef NO_ARCHIVES
     211#ifndef NO_ARCHIVES
    216212      if (ar_name (file->name))
     213        {
     214          name = strchr (file->name, '(') + 1;
     215          len = strlen (name) - 1;
     216        }
     217      else
     218#endif
    217219        {
    218           name = strchr (file->name, '(') + 1;
    219           len = strlen (name) - 1;
    220         }
    221       else
    222 #endif
    223         {
    224           name = file->name;
     220          name = file->name;
    225221#ifndef CONFIG_WITH_STRCACHE2
    226           len = strlen (name);
    227 #else
    228           len = strcache2_get_len (&file_strcache, name);
    229 #endif
    230         }
     222          len = strlen (name);
     223#else
     224          len = strcache2_get_len (&file_strcache, name);
     225#endif
     226        }
    231227
    232228#ifndef CONFIG_WITH_STRCACHE2
    233229      for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
    234         {
    235           unsigned int slen = strlen (dep_name (d));
     230        {
     231          unsigned int slen = strlen (dep_name (d));
    236232#else
    237233      for (d = enter_file (suffixes_strcached)->deps; d ; d = d->next)
    238234        {
    239           unsigned int slen = strcache2_get_len (&file_strcache, dep_name (d));
    240 #endif
    241           if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
    242             {
    243               file->stem = strcache_add_len (name, len - slen);
    244               break;
    245             }
    246         }
     235          unsigned int slen = strcache2_get_len (&file_strcache, dep_name (d));
     236#endif
     237          if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
     238            {
     239              file->stem = strcache_add_len (name, len - slen);
     240              break;
     241            }
     242        }
    247243      if (d == 0)
    248         file->stem = "";
     244        file->stem = "";
    249245    }
    250246  star = file->stem;
     
    265261    less = at;
    266262
    267 #define DEFINE_VARIABLE(name, len, value) \
     263#define DEFINE_VARIABLE(name, len, value) \
    268264  (void) define_variable_for_file (name,len,value,o_automatic,0,file)
    269265
     
    369365    cp = plus_value;
    370366
    371     qmark_len = plus_len + 1;   /* Will be this or less.  */
     367    qmark_len = plus_len + 1;   /* Will be this or less.  */
    372368    for (d = file->deps; d != 0; d = d->next)
    373369      if (! d->ignore_mtime && ! d->need_2nd_expansion)
     
    375371          const char *c = dep_name (d);
    376372
    377 #ifndef NO_ARCHIVES
     373#ifndef NO_ARCHIVES
    378374          if (ar_name (c))
    379375            {
     
    393389          *cp++ = FILE_LIST_SEPARATOR;
    394390          if (! (d->changed || always_make_flag))
    395             qmark_len -= len + 1;       /* Don't space in $? for this one.  */
     391            qmark_len -= len + 1;       /* Don't space in $? for this one.  */
    396392        }
    397393
     
    448444
    449445        c = dep_name (d);
    450 #ifndef NO_ARCHIVES
     446#ifndef NO_ARCHIVES
    451447        if (ar_name (c))
    452           {
    453             c = strchr (c, '(') + 1;
    454             len = strlen (c) - 1;
    455           }
    456         else
     448          {
     449            c = strchr (c, '(') + 1;
     450            len = strlen (c) - 1;
     451          }
     452        else
    457453#endif
    458454#ifndef CONFIG_WITH_STRCACHE2
    459           len = strlen (c);
    460 #else
    461           len = strcache2_get_len (&file_strcache, c);
     455          len = strlen (c);
     456#else
     457          len = strcache2_get_len (&file_strcache, c);
    462458#endif
    463459
     
    465461          {
    466462            memcpy (bp, c, len);
    467             bp += len;
    468             *bp++ = FILE_LIST_SEPARATOR;
    469           }
    470         else
     463            bp += len;
     464            *bp++ = FILE_LIST_SEPARATOR;
     465          }
     466        else
    471467          {
    472468            memcpy (cp, c, len);
     
    495491    DEFINE_VARIABLE ("|", 1, bar_value);
    496492  }
    497 #undef  DEFINE_VARIABLE
     493#undef  DEFINE_VARIABLE
    498494}
    499495
    500496
    501497/* Chop CMDS up into individual command lines if necessary.
    502    Also set the `lines_flags' and `any_recurse' members.  */
     498   Also set the 'lines_flags' and 'any_recurse' members.  */
    503499
    504500void
     
    577573     CMDS->any_recurse flag.  */
    578574
     575  if (nlines > USHRT_MAX)
     576    ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines);
     577
    579578  cmds->ncommand_lines = nlines;
    580579  cmds->command_lines = lines;
     
    589588  for (idx = 0; idx < nlines; ++idx)
    590589    {
    591       int flags = 0;
     590      unsigned char flags = 0;
    592591      const char *p = lines[idx];
    593592
    594       while (isblank (*p) || *p == '-' || *p == '@' || *p == '+' IF_WITH_COMMANDS_FUNC(|| *p == '%'))
     593      while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+' IF_WITH_COMMANDS_FUNC(|| *p == '%'))
    595594        switch (*(p++))
    596595          {
     
    628627
    629628      cmds->lines_flags[idx] = flags;
    630       cmds->any_recurse |= flags & COMMANDS_RECURSE;
     629      cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0;
    631630    }
    632631}
     
    668667
    669668  for (p = file->cmds->commands; *p != '\0'; ++p)
    670     if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
     669    if (!ISSPACE (*p) && *p != '-' && *p != '@' && *p != '+')
    671670      break;
    672671  if (*p == '\0')
     
    677676#endif
    678677      set_command_state (file, cs_running);
    679       file->update_status = 0;
     678      file->update_status = us_success;
    680679      notice_finished_file (file);
    681680      return;
     
    691690  set_file_variables (file);
    692691#endif
     692
     693  /* If this is a loaded dynamic object, unload it before remaking.
     694     Some systems don't support overwriting a loaded object.  */
     695  if (file->loaded)
     696    unload_file (file->name);
    693697
    694698  /* Start the commands running.  */
     
    737741
    738742      if (susp_count != 0)
    739         fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
     743        fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
    740744      else if (susp_count == (DWORD)-1)
    741         {
    742           DWORD ierr = GetLastError ();
    743 
    744           fprintf (stderr, "SuspendThread: error %ld: %s\n",
    745                    ierr, map_windows32_error_to_string (ierr));
    746         }
     745        {
     746          DWORD ierr = GetLastError ();
     747
     748          fprintf (stderr, "SuspendThread: error %ld: %s\n",
     749                   ierr, map_windows32_error_to_string (ierr));
     750        }
    747751    }
    748752#endif
     
    760764      struct child *c;
    761765      for (c = children; c != 0; c = c->next)
    762         if (!c->remote)
    763           (void) kill (c->pid, SIGTERM);
     766        if (!c->remote)
     767          (void) kill (c->pid, SIGTERM);
    764768    }
    765769
     
    779783
    780784      /* Remote children won't automatically get signals sent
    781         to the process group, so we must send them.  */
     785        to the process group, so we must send them.  */
    782786      for (c = children; c != 0; c = c->next)
    783         if (c->remote)
    784           (void) remote_kill (c->pid, sig);
     787        if (c->remote)
     788          (void) remote_kill (c->pid, sig);
    785789
    786790      for (c = children; c != 0; c = c->next)
    787         delete_child_targets (c);
     791        delete_child_targets (c);
    788792
    789793      /* Clean up the children.  We don't just use the call below because
    790         we don't want to print the "Waiting for children" message.  */
     794        we don't want to print the "Waiting for children" message.  */
    791795      while (job_slots_used > 0)
    792         reap_children (1, 0);
     796        reap_children (1, 0);
    793797    }
    794798  else
     
    804808    /* We don't want to send ourselves SIGQUIT, because it will
    805809       cause a core dump.  Just exit instead.  */
    806     exit (EXIT_FAILURE);
     810    exit (MAKE_TROUBLE);
    807811#endif
    808812
     
    845849    {
    846850      time_t file_date = (file->last_mtime == NONEXISTENT_MTIME
    847                           ? (time_t) -1
    848                           : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
     851                          ? (time_t) -1
     852                          : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
    849853      if (ar_member_date (file->name) != file_date)
    850         {
    851           if (on_behalf_of)
    852             error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"),
    853                    on_behalf_of, file->name);
    854           else
    855             error (NILF, _("*** Archive member `%s' may be bogus; not deleted"),
    856                    file->name);
    857         }
     854        {
     855          if (on_behalf_of)
     856            OSS (error, NILF,
     857                 _("*** [%s] Archive member '%s' may be bogus; not deleted"),
     858                 on_behalf_of, file->name);
     859          else
     860            OS (error, NILF,
     861                _("*** Archive member '%s' may be bogus; not deleted"),
     862                file->name);
     863        }
    858864      return;
    859865    }
     
    866872    {
    867873      if (on_behalf_of)
    868         error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name);
     874        OSS (error, NILF,
     875             _("*** [%s] Deleting file '%s'"), on_behalf_of, file->name);
    869876      else
    870         error (NILF, _("*** Deleting file `%s'"), file->name);
     877        OS (error, NILF, _("*** Deleting file '%s'"), file->name);
    871878      if (unlink (file->name) < 0
    872           && errno != ENOENT)   /* It disappeared; so what.  */
    873         perror_with_name ("unlink: ", file->name);
     879          && errno != ENOENT)   /* It disappeared; so what.  */
     880        perror_with_name ("unlink: ", file->name);
    874881    }
    875882}
     
    890897  delete_target (child->file, NULL);
    891898
    892   /* Also remove any non-precious targets listed in the `also_make' member.  */
     899  /* Also remove any non-precious targets listed in the 'also_make' member.  */
    893900  for (d = child->file->also_make; d != 0; d = d->next)
    894901    delete_target (d->file, child->file->name);
     
    923930    puts (_(" (built-in):"));
    924931  else
    925     printf (_(" (from `%s', line %lu):\n"),
     932    printf (_(" (from '%s', line %lu):\n"),
    926933            cmds->fileinfo.filenm, cmds->fileinfo.lineno);
    927934
     
    930937    {
    931938      const char *end;
    932 
    933       end = strchr (s, '\n');
    934       if (end == 0)
    935         end = s + strlen (s);
     939      int bs;
     940
     941      /* Print one full logical recipe line: find a non-escaped newline.  */
     942      for (end = s, bs = 0; *end != '\0'; ++end)
     943        {
     944          if (*end == '\n' && !bs)
     945            break;
     946
     947          bs = *end == '\\' ? !bs : 0;
     948        }
    936949
    937950      printf ("%c%.*s\n", cmd_prefix, (int) (end - s), s);
Note: See TracChangeset for help on using the changeset viewer.