bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: $(info xxx) output interleaved with other $(info) output


From: Paul Smith
Subject: Re: $(info xxx) output interleaved with other $(info) output
Date: Thu, 20 Jan 2022 02:11:25 -0500
User-agent: Evolution 3.36.5-0ubuntu1

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 <psmith@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 <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 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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]