Changeset 1993 for trunk/src/kmk/read.c


Ignore:
Timestamp:
Oct 29, 2008, 1:37:51 AM (17 years ago)
Author:
bird
Message:

Merged in current GNU Make code (CVS from 2008-10-28). Ref #55.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/read.c

    r1980 r1993  
    11/* Reading and parsing of makefiles 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 Free Software
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    44Foundation, Inc.
    55This file is part of GNU Make.
     
    77GNU Make is free software; you can redistribute it and/or modify it under the
    88terms of the GNU General Public License as published by the Free Software
    9 Foundation; either version 2, or (at your option) any later version.
     9Foundation; either version 3 of the License, or (at your option) any later
     10version.
    1011
    1112GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     
    1415
    1516You should have received a copy of the GNU General Public License along with
    16 GNU Make; see the file COPYING.  If not, write to the Free Software
    17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
     17this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1818
    1919#include "make.h"
     
    591591#define record_waiting_files()                                                \
    592592  do                                                                          \
    593     {                                                                         \
     593    {                                                                         \
    594594      if (filenames != 0)                                                     \
    595595        {                                                                     \
     
    672672                continue;
    673673
    674               /* Append this command line to the line being accumulated.  */
     674              /* Append this command line to the line being accumulated.
     675                 Strip command prefix chars that appear after newlines.  */
    675676              if (commands_idx == 0)
    676677                cmds_started = ebuf->floc.lineno;
    677678
    678               if (linelen + 1 + commands_idx > commands_len)
     679              if (linelen + commands_idx > commands_len)
    679680                {
    680                   commands_len = (linelen + 1 + commands_idx) * 2;
     681                  commands_len = (linelen + commands_idx) * 2;
    681682                  commands = xrealloc (commands, commands_len);
    682683                }
    683               memcpy (&commands[commands_idx], line, linelen);
    684               commands_idx += linelen;
    685               commands[commands_idx++] = '\n';
     684              p = &commands[commands_idx];
     685              p2 = line + 1;
     686              while (--linelen)
     687                {
     688                  ++commands_idx;
     689                  *(p++) = *p2;
     690                  if (p2[0] == '\n' && p2[1] == cmd_prefix)
     691                    {
     692                      ++p2;
     693                      --linelen;
     694                    }
     695                  ++p2;
     696                }
     697              *p = '\n';
     698              ++commands_idx;
    686699
    687700              continue;
     
    715728
    716729      /* Compare a word, both length and contents. */
    717 #define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
     730#define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
    718731      p = collapsed;
    719732      while (isspace ((unsigned char)*p))
     
    11211134         variable definition.  But now we know it is definitely lossage.  */
    11221135      if (line[0] == cmd_prefix)
    1123         fatal(fstart, _("commands commence before first target"));
     1136        fatal(fstart, _("recipe commences before first target"));
    11241137
    11251138      /* This line describes some target files.  This is complicated by
     
    11801193          case w_eol:
    11811194            if (cmdleft != 0)
    1182               fatal(fstart, _("missing rule before commands"));
     1195              fatal(fstart, _("missing rule before recipe"));
    11831196            /* This line contained something but turned out to be nothing
    11841197               but whitespace (a comment?).  */
     
    12991312                 one of the most common bugs found in makefiles...  */
    13001313              fatal (fstart, _("missing separator%s"),
    1301                      !strneq(line, "        ", 8) ? ""
    1302                      : _(" (did you mean TAB instead of 8 spaces?)"));
     1314                     (cmd_prefix == '\t' && !strneq(line, "        ", 8))
     1315                     ? "" : _(" (did you mean TAB instead of 8 spaces?)"));
    13031316            continue;
    13041317          }
     
    25142527     See Savannah bug # 12124.  */
    25152528  if (snapped_deps)
    2516     fatal (flocp, _("prerequisites cannot be defined in command scripts"));
     2529    fatal (flocp, _("prerequisites cannot be defined in recipes"));
    25172530
    25182531  if (commands_idx > 0)
     
    26732686            {
    26742687              error (&cmds->fileinfo,
    2675                      _("warning: overriding commands for target `%s'"),
     2688                     _("warning: overriding recipe for target `%s'"),
    26762689                     f->name);
    26772690              error (&f->cmds->fileinfo,
    2678                      _("warning: ignoring old commands for target `%s'"),
     2691                     _("warning: ignoring old recipe for target `%s'"),
    26792692                     f->name);
    26802693            }
     
    32073220#ifndef CONFIG_WITH_ALLOC_CACHES
    32083221      new1 = xmalloc (size);
    3209 #else
    3210       new1 = (struct nameseq *)alloccache_alloc (cache);
     3222      memset (new1, '\0', size);
     3223#else
     3224      new1 = (struct nameseq *) alloccache_calloc (cache);
    32113225#endif
    32123226      new1->name = name;
     
    38213835          if (len > max_incl_len)
    38223836            max_incl_len = len;
    3823           dirs[idx++] = strcache_add_len (*cpp, len - 1);
     3837          dirs[idx++] = strcache_add_len (*cpp, len);
    38243838        }
    38253839    }
Note: See TracChangeset for help on using the changeset viewer.