[libiberty] output empty args as a pair of quotes
authorAlexandre Oliva <oliva@adacore.com>
Thu, 16 Jan 2020 06:58:50 +0000 (03:58 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 23 Jan 2020 19:45:24 +0000 (16:45 -0300)
writeargv writes out empty arguments in a way that expandargv skips
them instead of preserving them.  Fixed by writing out a pair of
quotes for them.

for  libiberty/ChangeLog

* argv.c (writeargv): Output empty args as "".

libiberty/ChangeLog
libiberty/argv.c

index c2bab93..17903ea 100644 (file)
@@ -1,3 +1,7 @@
+2020-01-23  Alexandre Oliva <oliva@adacore.com>
+
+       * argv.c (writeargv): Output empty args as "".
+
 2020-01-01  Jakub Jelinek  <jakub@redhat.com>
 
        Update copyright years.
index 8c9794d..6a72208 100644 (file)
@@ -327,6 +327,14 @@ writeargv (char * const *argv, FILE *f)
           arg++;
         }
 
+      /* Write out a pair of quotes for an empty argument.  */
+      if (arg == *argv)
+       if (EOF == fputs ("\"\"", f))
+         {
+           status = 1;
+           goto done;
+         }
+
       if (EOF == fputc ('\n', f))
         {
           status = 1;