On Wed, 2022-01-19 at 15:49 -0800, Paul Eggert wrote: > On 1/19/22 15:28, Paul Eggert wrote: > > Proposed patch attached. > > I see that patch's commit message has the wrong URL for the bug > report. Here's a fixed patch, attached. Only the commit message is > changed.
I examined this method and in fact, it's not possible for it to be called with anything other than exactly one argument so all the mess around recombining multiple arguments is useless. I rewrote this function and applied this change: Author: Paul Smith <psm...@gnu.org> Date: 2022-01-19 15:49:19 -0800 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 other parallel make job to sneak in between them. Reported by Paul Eggert <egg...@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 bother concatenating the arguments. diff --git a/src/function.c b/src/function.c index c27f573b..d7c13923 100644 --- a/src/function.c +++ b/src/function.c @@ -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);