I recently modified the Emacs build procedure to use '$(info xxx)'
instead of 'echo xxx' to avoid some fork+execs and simplify
strace-oriented debugging. Unfortunately, Lars Ingebrigtsen reports that
this results in confused output with 'make -j' because $(info xxx)
outputs xxx and the following newline with two syscalls (it should be one).
Proposed patch attached.
From d1d2269fbafde7c1b0115dd5c85d82ac4b58677d Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 19 Jan 2022 15:20:40 -0800
Subject: [PATCH] Fix interleaved $(info) output
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/function.c (func_error): On POSIX-compatible platforms,
cause $(info xxx) output to a pipe to be atomic when xxx is small,
the same way that $(warning xxx) and $(error xxx) is. Problem
reported by Lars Ingebrigtsen <https://bugs.gnu.org/r/53358>.
Also, shrink allocation by 1 byte (the byte isn’t ever used)
and avoid an unnecessary initialization of msg[0].
---
src/function.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/function.c b/src/function.c
index c107a387..05c77c32 100644
--- a/src/function.c
+++ b/src/function.c
@@ -1180,17 +1180,16 @@ func_error (char *o, char **argv, const char *funcname)
for (len=0, argvp=argv; *argvp != 0; ++argvp)
len += strlen (*argvp) + 2;
- p = msg = alloca (len + 1);
- msg[0] = '\0';
+ p = msg = alloca (len);
- for (argvp=argv; argvp[1] != 0; ++argvp)
+ for (argvp=argv; *argvp != 0; ++argvp)
{
strcpy (p, *argvp);
p += strlen (*argvp);
*(p++) = ',';
*(p++) = ' ';
}
- strcpy (p, *argvp);
+ p[-2] = '\0';
switch (*funcname)
{
@@ -1202,8 +1201,8 @@ func_error (char *o, char **argv, const char *funcname)
break;
case 'i':
+ strcpy (p - 2, "\n");
outputs (0, msg);
- outputs (0, "\n");
break;
default:
--
2.32.0