summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-02-06 03:58:09 +0000
committerJim Meyering <jim@meyering.net>1997-02-06 03:58:09 +0000
commitb7a12bb1109eee3c58c4d763d1bfe19001378e6e (patch)
tree9d9207a43f4fbe9c9cdccc40a76e64917ccdfca6 /src/ls.c
parent155fa29f270845198dad6ffb1944245fe45487e3 (diff)
downloadcoreutils-b7a12bb1109eee3c58c4d763d1bfe19001378e6e.tar.xz
(quote_filename): Allocate two more bytes (for quotes)
when using --quote-name (-Q). Feb 2 change wasn't complete. Patch from Mark Harris.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ls.c b/src/ls.c
index 9a16e30be..fc0b7b544 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2230,7 +2230,12 @@ quote_filename (register const char *p, size_t *quoted_length)
}
p = p0;
- quoted = xmalloc (4 * strlen (p) + 1);
+
+ quoted = xmalloc (4 * strlen (p)
+ /* Add two (one for beginning and one for ending quote)
+ if --quote-name (-Q) was specified. */
+ + (quote_as_string ? 2 : 0)
+ + 1);
q = quoted;
#define SAVECHAR(c) *q++ = (c)
@@ -2276,7 +2281,9 @@ quote_filename (register const char *p, size_t *quoted_length)
break;
case '"':
- SAVE_2_CHARS ("\\\"");
+ if (quote_as_string)
+ SAVECHAR ('\\');
+ SAVECHAR ('"');
break;
default: