Re: [PATCH] quote empties

2018-03-17 Thread Thorsten Glaser
Hoi Martijn,

>Here's a patch.

Indeed. Thanks, applied.

I’ll look at your other and Stéphane’s bugreport once I’m over
the current edition of the “common cold” ☹

Much appreciated,
//mirabilos
-- 
(gnutls can also be used, but if you are compiling lynx for your own use,
there is no reason to consider using that package)
-- Thomas E. Dickey on the Lynx mailing list, about OpenSSL


[PATCH] quote empties

2018-03-17 Thread Martijn Dekker
$ mksh -c 'trap "" CONT; trap'
trap --  CONT

That is not "suitable for re-entry into the shell". Empties must be
quoted, or they disappear. Expected output:

trap -- '' CONT

Here's a patch.

Index: misc.c
===
RCS file: /cvs/src/bin/mksh/misc.c,v
retrieving revision 1.291
diff -u -r1.291 misc.c
--- misc.c  14 Jan 2018 00:03:03 -  1.291
+++ misc.c  17 Mar 2018 12:03:42 -
@@ -1346,7 +1346,14 @@
const unsigned char *p = (const unsigned char *)s;
bool inquote = true;

-   /* first, check whether any quotes are needed */
+   /* first, check for empty */
+   if (*p == '\0') {
+   shf_putc('\'', shf);
+   shf_putc('\'', shf);
+   return;
+   }
+
+   /* non-empty: check whether any quotes are needed */
while (rtt2asc(c = *p++) >= 32)
if (ctype(c, C_QUOTE | C_SPC))
inquote = false;