mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-24 21:04:00 +00:00
Avoid interleaved $(info ) output
Since $(info ) function output is written using two system calls for the message and the newline, it's possible for output from another parallel make job to sneak in between them. Reported by Paul Eggert <eggert@cs.ucla.edu>, who saw the report from Lars Ingebrigtsen <https://bugs.gnu.org/53358>. * src/function.c (func_error): Paul provided a fix but instead I rewrote the entire function: it's not possible for it to be invoked with anything other than exactly one argument so don't worry about re-combining the arguments.
This commit is contained in:
parent
cbe0d2e47f
commit
5f2d114c6d
1 changed files with 11 additions and 27 deletions
|
@ -1171,41 +1171,25 @@ func_strip (char *o, char **argv, const char *funcname UNUSED)
|
|||
static char *
|
||||
func_error (char *o, char **argv, const char *funcname)
|
||||
{
|
||||
char **argvp;
|
||||
char *msg, *p;
|
||||
size_t len;
|
||||
|
||||
/* The arguments will be broken on commas. Rather than create yet
|
||||
another special case where function arguments aren't broken up,
|
||||
just create a format string that puts them back together. */
|
||||
for (len=0, argvp=argv; *argvp != 0; ++argvp)
|
||||
len += strlen (*argvp) + 2;
|
||||
|
||||
p = msg = alloca (len + 1);
|
||||
msg[0] = '\0';
|
||||
|
||||
for (argvp=argv; argvp[1] != 0; ++argvp)
|
||||
{
|
||||
strcpy (p, *argvp);
|
||||
p += strlen (*argvp);
|
||||
*(p++) = ',';
|
||||
*(p++) = ' ';
|
||||
}
|
||||
strcpy (p, *argvp);
|
||||
|
||||
switch (*funcname)
|
||||
{
|
||||
case 'e':
|
||||
OS (fatal, reading_file, "%s", msg);
|
||||
OS (fatal, reading_file, "%s", argv[0]);
|
||||
|
||||
case 'w':
|
||||
OS (error, reading_file, "%s", msg);
|
||||
OS (error, reading_file, "%s", argv[0]);
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
outputs (0, msg);
|
||||
outputs (0, "\n");
|
||||
break;
|
||||
{
|
||||
size_t len = strlen (argv[0]);
|
||||
char *msg = alloca (len + 2);
|
||||
strcpy (msg, argv[0]);
|
||||
msg[len] = '\n';
|
||||
msg[len + 1] = '\0';
|
||||
outputs (0, msg);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
OS (fatal, *expanding_var, "Internal error: func_error: '%s'", funcname);
|
||||
|
|
Loading…
Reference in a new issue