diff options
author | tjr <tjr@FreeBSD.org> | 2004-05-02 11:25:37 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-05-02 11:25:37 +0000 |
commit | de72f8ed4193914556f8e7266dc1f52706213d5b (patch) | |
tree | 33ababbec3452462cff8a64581a3fc9f628a2913 /bin/ls/print.c | |
parent | 0342c52a187a490376a081f56bf3b22a229b7cd1 (diff) | |
download | FreeBSD-src-de72f8ed4193914556f8e7266dc1f52706213d5b.zip FreeBSD-src-de72f8ed4193914556f8e7266dc1f52706213d5b.tar.gz |
Treat filenames as multibyte character strings (according to the current
LC_CTYPE setting) when determining which characters are printable.
This is an often-requested feature.
Use wcwidth() to determine the number of column positions a character
takes up, although there are still a few places left where we assume
1 byte = 1 column position, e.g. line-wrapping when handling the -m option.
The error handling here is somewhat more complicated than usual: we do
our best to show what we can of a filename in the presence of conversion
errors, instead of simply aborting.
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r-- | bin/ls/print.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c index 1d6bec9..eb0258e 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -147,7 +147,7 @@ printname(const char *name) else if (f_nonprint) return prn_printable(name); else - return printf("%s", name); + return prn_normal(name); } void @@ -239,6 +239,7 @@ printstream(const DISPLAY *dp) for (p = dp->list, chcnt = 0; p; p = p->fts_link) { if (p->fts_number == NO_PRINT) continue; + /* XXX strlen does not take octal escapes into account. */ if (strlen(p->fts_name) + chcnt + (p->fts_link ? 2 : 0) >= (unsigned)termwidth) { putchar('\n'); |