summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-07-31 19:24:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-07-31 19:24:08 +0200
commitbb18473216253b8602ce081dd944f854aad9e572 (patch)
tree8706012491f4ca326dd883869ab2a69b51723ae2 /coreutils
parent551bfdb97f45f0277a408ec2d44ee18967b98304 (diff)
ls: lack of -q should not suppress -Q
function old new delta print_name 134 137 +3 display_files 374 375 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 4/0) Total: 4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index eaccd1a17..c725be92d 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -454,16 +454,17 @@ static unsigned calc_name_len(const char *name)
unsigned len;
uni_stat_t uni_stat;
- if (!(option_mask32 & OPT_q))
+ if (!(option_mask32 & (OPT_q|OPT_Q)))
return strlen(name);
- // TODO: quote tab as \t, etc, if -Q
name = printable_string2(&uni_stat, name);
if (!(option_mask32 & OPT_Q)) {
return uni_stat.unicode_width;
}
+ // TODO: quote chars 7..13 as \a,b,t,n,v,f,r
+ // other chars <32 or >127 as \ooo octal
len = 2 + uni_stat.unicode_width;
while (*name) {
if (*name == '"' || *name == '\\') {
@@ -486,12 +487,11 @@ static unsigned print_name(const char *name)
unsigned len;
uni_stat_t uni_stat;
- if (!(option_mask32 & OPT_q)) {
+ if (!(option_mask32 & (OPT_q|OPT_Q))) {
fputs_stdout(name);
return strlen(name);
}
- // TODO: quote tab as \t, etc, if -Q
name = printable_string2(&uni_stat, name);
if (!(option_mask32 & OPT_Q)) {
@@ -499,6 +499,8 @@ static unsigned print_name(const char *name)
return uni_stat.unicode_width;
}
+ // TODO: quote chars 7..13 as \a,b,t,n,v,f,r
+ // other chars <32 or >127 as \ooo octal
len = 2 + uni_stat.unicode_width;
putchar('"');
while (*name) {