Ignore:
Timestamp:
Mar 12, 2018, 8: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/commands.c

    r2596 r3138  
    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"
     
    2927
    3028#if VMS
    31 # define FILE_LIST_SEPARATOR ','
     29# define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ')
    3230#else
    3331# define FILE_LIST_SEPARATOR ' '
    3432#endif
    3533
    36 int remote_kill (int id, int sig);
    37 
    38 #ifndef HAVE_UNISTD_H
     34#ifndef HAVE_UNISTD_H
    3935int getpid ();
    4036#endif
     
    7268  const char *at, *percent, *star, *less;
    7369
    74 #ifndef NO_ARCHIVES
    75   /* If the target is an archive member `lib(member)',
    76      then $@ is `lib' and $% is `member'.  */
     70#ifndef NO_ARCHIVES
     71  /* If the target is an archive member 'lib(member)',
     72     then $@ is 'lib' and $% is 'member'.  */
    7773
    7874  if (ar_name (file->name))
     
    9490    }
    9591  else
    96 #endif  /* NO_ARCHIVES.  */
     92#endif  /* NO_ARCHIVES.  */
    9793    {
    9894      at = file->name;
     
    104100    {
    105101      /* In Unix make, $* is set to the target name with
    106         any suffix in the .SUFFIXES list stripped off for
    107          explicit rules.  We store this in the `stem' member.  */
     102        any suffix in the .SUFFIXES list stripped off for
     103         explicit rules.  We store this in the 'stem' member.  */
    108104      const char *name;
    109105      unsigned int len;
    110106
    111 #ifndef NO_ARCHIVES
     107#ifndef NO_ARCHIVES
    112108      if (ar_name (file->name))
    113         {
    114           name = strchr (file->name, '(') + 1;
    115           len = strlen (name) - 1;
    116         }
     109        {
     110          name = strchr (file->name, '(') + 1;
     111          len = strlen (name) - 1;
     112        }
    117113      else
    118114#endif
    119         {
    120           name = file->name;
    121           len = strlen (name);
    122         }
     115        {
     116          name = file->name;
     117          len = strlen (name);
     118        }
    123119
    124120      for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
    125         {
    126           unsigned int slen = strlen (dep_name (d));
    127           if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
    128             {
    129               file->stem = strcache_add_len (name, len - slen);
    130               break;
    131             }
    132         }
     121        {
     122          unsigned int slen = strlen (dep_name (d));
     123          if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
     124            {
     125              file->stem = strcache_add_len (name, len - slen);
     126              break;
     127            }
     128        }
    133129      if (d == 0)
    134         file->stem = "";
     130        file->stem = "";
    135131    }
    136132  star = file->stem;
     
    151147    less = at;
    152148
    153 #define DEFINE_VARIABLE(name, len, value) \
     149#define DEFINE_VARIABLE(name, len, value) \
    154150  (void) define_variable_for_file (name,len,value,o_automatic,0,file)
    155151
     
    204200    cp = plus_value;
    205201
    206     qmark_len = plus_len + 1;   /* Will be this or less.  */
     202    qmark_len = plus_len + 1;   /* Will be this or less.  */
    207203    for (d = file->deps; d != 0; d = d->next)
    208204      if (! d->ignore_mtime && ! d->need_2nd_expansion)
     
    210206          const char *c = dep_name (d);
    211207
    212 #ifndef NO_ARCHIVES
     208#ifndef NO_ARCHIVES
    213209          if (ar_name (c))
    214210            {
     
    224220          *cp++ = FILE_LIST_SEPARATOR;
    225221          if (! (d->changed || always_make_flag))
    226             qmark_len -= len + 1;       /* Don't space in $? for this one.  */
     222            qmark_len -= len + 1;       /* Don't space in $? for this one.  */
    227223        }
    228224
     
    279275
    280276        c = dep_name (d);
    281 #ifndef NO_ARCHIVES
     277#ifndef NO_ARCHIVES
    282278        if (ar_name (c))
    283           {
    284             c = strchr (c, '(') + 1;
    285             len = strlen (c) - 1;
    286           }
    287         else
    288 #endif
    289           len = strlen (c);
     279          {
     280            c = strchr (c, '(') + 1;
     281            len = strlen (c) - 1;
     282          }
     283        else
     284#endif
     285          len = strlen (c);
    290286
    291287        if (d->ignore_mtime)
    292288          {
    293289            memcpy (bp, c, len);
    294             bp += len;
    295             *bp++ = FILE_LIST_SEPARATOR;
    296           }
    297         else
     290            bp += len;
     291            *bp++ = FILE_LIST_SEPARATOR;
     292          }
     293        else
    298294          {
    299295            memcpy (cp, c, len);
     
    323319  }
    324320
    325 #undef  DEFINE_VARIABLE
     321#undef  DEFINE_VARIABLE
    326322}
    327323
    328324
    329325/* Chop CMDS up into individual command lines if necessary.
    330    Also set the `lines_flags' and `any_recurse' members.  */
     326   Also set the 'lines_flags' and 'any_recurse' members.  */
    331327
    332328void
     
    405401     CMDS->any_recurse flag.  */
    406402
     403  if (nlines > USHRT_MAX)
     404    ON (fatal, &cmds->fileinfo, _("Recipe has too many lines (%ud)"), nlines);
     405
    407406  cmds->ncommand_lines = nlines;
    408407  cmds->command_lines = lines;
     
    413412  for (idx = 0; idx < nlines; ++idx)
    414413    {
    415       int flags = 0;
     414      unsigned char flags = 0;
    416415      const char *p = lines[idx];
    417416
    418       while (isblank (*p) || *p == '-' || *p == '@' || *p == '+')
     417      while (ISBLANK (*p) || *p == '-' || *p == '@' || *p == '+')
    419418        switch (*(p++))
    420419          {
     
    436435
    437436      cmds->lines_flags[idx] = flags;
    438       cmds->any_recurse |= flags & COMMANDS_RECURSE;
     437      cmds->any_recurse |= flags & COMMANDS_RECURSE ? 1 : 0;
    439438    }
    440439}
     
    454453
    455454  for (p = file->cmds->commands; *p != '\0'; ++p)
    456     if (!isspace ((unsigned char)*p) && *p != '-' && *p != '@')
     455    if (!ISSPACE (*p) && *p != '-' && *p != '@' && *p != '+')
    457456      break;
    458457  if (*p == '\0')
     
    460459      /* If there are no commands, assume everything worked.  */
    461460      set_command_state (file, cs_running);
    462       file->update_status = 0;
     461      file->update_status = us_success;
    463462      notice_finished_file (file);
    464463      return;
     
    470469
    471470  set_file_variables (file);
     471
     472  /* If this is a loaded dynamic object, unload it before remaking.
     473     Some systems don't support overwriting a loaded object.  */
     474  if (file->loaded)
     475    unload_file (file->name);
    472476
    473477  /* Start the commands running.  */
     
    516520
    517521      if (susp_count != 0)
    518         fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
     522        fprintf (stderr, "SuspendThread: suspend count = %ld\n", susp_count);
    519523      else if (susp_count == (DWORD)-1)
    520         {
    521           DWORD ierr = GetLastError ();
    522 
    523           fprintf (stderr, "SuspendThread: error %ld: %s\n",
    524                    ierr, map_windows32_error_to_string (ierr));
    525         }
     524        {
     525          DWORD ierr = GetLastError ();
     526
     527          fprintf (stderr, "SuspendThread: error %ld: %s\n",
     528                   ierr, map_windows32_error_to_string (ierr));
     529        }
    526530    }
    527531#endif
     
    539543      struct child *c;
    540544      for (c = children; c != 0; c = c->next)
    541         if (!c->remote)
    542           (void) kill (c->pid, SIGTERM);
     545        if (!c->remote)
     546          (void) kill (c->pid, SIGTERM);
    543547    }
    544548
     
    558562
    559563      /* Remote children won't automatically get signals sent
    560         to the process group, so we must send them.  */
     564        to the process group, so we must send them.  */
    561565      for (c = children; c != 0; c = c->next)
    562         if (c->remote)
    563           (void) remote_kill (c->pid, sig);
     566        if (c->remote)
     567          (void) remote_kill (c->pid, sig);
    564568
    565569      for (c = children; c != 0; c = c->next)
    566         delete_child_targets (c);
     570        delete_child_targets (c);
    567571
    568572      /* Clean up the children.  We don't just use the call below because
    569         we don't want to print the "Waiting for children" message.  */
     573        we don't want to print the "Waiting for children" message.  */
    570574      while (job_slots_used > 0)
    571         reap_children (1, 0);
     575        reap_children (1, 0);
    572576    }
    573577  else
     
    584588    /* We don't want to send ourselves SIGQUIT, because it will
    585589       cause a core dump.  Just exit instead.  */
    586     exit (EXIT_FAILURE);
     590    exit (MAKE_TROUBLE);
    587591#endif
    588592
     
    620624    {
    621625      time_t file_date = (file->last_mtime == NONEXISTENT_MTIME
    622                           ? (time_t) -1
    623                           : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
     626                          ? (time_t) -1
     627                          : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
    624628      if (ar_member_date (file->name) != file_date)
    625         {
    626           if (on_behalf_of)
    627             error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"),
    628                    on_behalf_of, file->name);
    629           else
    630             error (NILF, _("*** Archive member `%s' may be bogus; not deleted"),
    631                    file->name);
    632         }
     629        {
     630          if (on_behalf_of)
     631            OSS (error, NILF,
     632                 _("*** [%s] Archive member '%s' may be bogus; not deleted"),
     633                 on_behalf_of, file->name);
     634          else
     635            OS (error, NILF,
     636                _("*** Archive member '%s' may be bogus; not deleted"),
     637                file->name);
     638        }
    633639      return;
    634640    }
     
    641647    {
    642648      if (on_behalf_of)
    643         error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name);
     649        OSS (error, NILF,
     650             _("*** [%s] Deleting file '%s'"), on_behalf_of, file->name);
    644651      else
    645         error (NILF, _("*** Deleting file `%s'"), file->name);
     652        OS (error, NILF, _("*** Deleting file '%s'"), file->name);
    646653      if (unlink (file->name) < 0
    647           && errno != ENOENT)   /* It disappeared; so what.  */
    648         perror_with_name ("unlink: ", file->name);
     654          && errno != ENOENT)   /* It disappeared; so what.  */
     655        perror_with_name ("unlink: ", file->name);
    649656    }
    650657}
     
    665672  delete_target (child->file, NULL);
    666673
    667   /* Also remove any non-precious targets listed in the `also_make' member.  */
     674  /* Also remove any non-precious targets listed in the 'also_make' member.  */
    668675  for (d = child->file->also_make; d != 0; d = d->next)
    669676    delete_target (d->file, child->file->name);
     
    685692    puts (_(" (built-in):"));
    686693  else
    687     printf (_(" (from `%s', line %lu):\n"),
     694    printf (_(" (from '%s', line %lu):\n"),
    688695            cmds->fileinfo.filenm, cmds->fileinfo.lineno);
    689696
     
    692699    {
    693700      const char *end;
    694 
    695       end = strchr (s, '\n');
    696       if (end == 0)
    697         end = s + strlen (s);
     701      int bs;
     702
     703      /* Print one full logical recipe line: find a non-escaped newline.  */
     704      for (end = s, bs = 0; *end != '\0'; ++end)
     705        {
     706          if (*end == '\n' && !bs)
     707            break;
     708
     709          bs = *end == '\\' ? !bs : 0;
     710        }
    698711
    699712      printf ("%c%.*s\n", cmd_prefix, (int) (end - s), s);
Note: See TracChangeset for help on using the changeset viewer.