summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2007-11-04 21:54:00 +0000
committerPaul Smith <psmith@gnu.org>2007-11-04 21:54:00 +0000
commit43d81ff8669c3705ca3c61270af4a5c7218c2fe6 (patch)
treeabaa4fc983ce53dc44d006bb66d76a9e99505329 /read.c
parentc1f71b0336fbeb105363a389dec27902ff9f280e (diff)
downloadgunmake-43d81ff8669c3705ca3c61270af4a5c7218c2fe6.tar.gz
New special variable: .RECIPEPREFIX
Allows the user to reset the prefix character for introducing recipe lines from the default (tab) to any other single character, and back again. Also, reworked the manual to consistently use the word "recipe" to describe the set of commands we use to update a target, instead of the various phrases used in the past: "commands", "command lines", "command scripts", etc.
Diffstat (limited to 'read.c')
-rw-r--r--read.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/read.c b/read.c
index dacc2a0..5287de8 100644
--- a/read.c
+++ b/read.c
@@ -536,18 +536,31 @@ eval (struct ebuffer *ebuf, int set_default)
/* Yep, this is a shell command, and we don't care. */
continue;
- /* Append this command line to the line being accumulated. */
+ /* Append this command line to the line being accumulated.
+ Strip command prefix chars that appear after newlines. */
if (commands_idx == 0)
cmds_started = ebuf->floc.lineno;
- if (linelen + 1 + commands_idx > commands_len)
+ if (linelen + commands_idx > commands_len)
{
- commands_len = (linelen + 1 + commands_idx) * 2;
+ commands_len = (linelen + commands_idx) * 2;
commands = xrealloc (commands, commands_len);
}
- memcpy (&commands[commands_idx], line, linelen);
- commands_idx += linelen;
- commands[commands_idx++] = '\n';
+ p = &commands[commands_idx];
+ p2 = line + 1;
+ while (--linelen)
+ {
+ ++commands_idx;
+ *(p++) = *p2;
+ if (p2[0] == '\n' && p2[1] == cmd_prefix)
+ {
+ ++p2;
+ --linelen;
+ }
+ ++p2;
+ }
+ *p = '\n';
+ ++commands_idx;
continue;
}
@@ -844,7 +857,7 @@ eval (struct ebuffer *ebuf, int set_default)
was no preceding target, and the line might have been usable as a
variable definition. But now we know it is definitely lossage. */
if (line[0] == cmd_prefix)
- fatal(fstart, _("commands commence before first target"));
+ fatal(fstart, _("recipe commences before first target"));
/* This line describes some target files. This is complicated by
the existence of target-specific variables, because we can't
@@ -895,7 +908,7 @@ eval (struct ebuffer *ebuf, int set_default)
{
case w_eol:
if (cmdleft != 0)
- fatal(fstart, _("missing rule before commands"));
+ fatal(fstart, _("missing rule before recipe"));
/* This line contained something but turned out to be nothing
but whitespace (a comment?). */
continue;
@@ -983,8 +996,8 @@ eval (struct ebuffer *ebuf, int set_default)
/* There's no need to be ivory-tower about this: check for
one of the most common bugs found in makefiles... */
fatal (fstart, _("missing separator%s"),
- !strneq(line, " ", 8) ? ""
- : _(" (did you mean TAB instead of 8 spaces?)"));
+ (cmd_prefix == '\t' && !strneq(line, " ", 8))
+ ? "" : _(" (did you mean TAB instead of 8 spaces?)"));
continue;
}
@@ -1871,7 +1884,7 @@ record_files (struct nameseq *filenames, const char *pattern,
at this time, since they won't get snapped and we'll get core dumps.
See Savannah bug # 12124. */
if (snapped_deps)
- fatal (flocp, _("prerequisites cannot be defined in command scripts"));
+ fatal (flocp, _("prerequisites cannot be defined in recipes"));
if (commands_idx > 0)
{
@@ -1971,10 +1984,10 @@ record_files (struct nameseq *filenames, const char *pattern,
else if (cmds != 0 && f->cmds != 0 && f->is_target)
{
error (&cmds->fileinfo,
- _("warning: overriding commands for target `%s'"),
+ _("warning: overriding recipe for target `%s'"),
f->name);
error (&f->cmds->fileinfo,
- _("warning: ignoring old commands for target `%s'"),
+ _("warning: ignoring old recipe for target `%s'"),
f->name);
}
@@ -2962,7 +2975,7 @@ construct_include_path (const char **arg_dirs)
--len;
if (len > max_incl_len)
max_incl_len = len;
- dirs[idx++] = strcache_add_len (*cpp, len - 1);
+ dirs[idx++] = strcache_add_len (*cpp, len);
}
}