diff options
author | 2015-12-01 18:36:13 +0000 | |
---|---|---|
committer | 2015-12-01 18:36:13 +0000 | |
commit | b6203726b0c2b99029f120541ba7391e510b4b99 (patch) | |
tree | 741390d94fe7938726285ac53fcab3e03bb53b8e /bin/ls/print.c | |
parent | Split functions in if_bridge.c into if_bridge.c bridgectl.c . (diff) | |
download | wireguard-openbsd-b6203726b0c2b99029f120541ba7391e510b4b99.tar.xz wireguard-openbsd-b6203726b0c2b99029f120541ba7391e510b4b99.zip |
Support UTF-8: use wcwidth(3) for column adjustment and replace
non-printable Unicode codepoints and invalid bytes with ASCII
question marks. No change for the SMALL version.
Using ideas developed by tedu@, phessler@, bentley@ and feedback from many.
OK yasuoka@ czarkoff@ sthen@.
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r-- | bin/ls/print.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c index 6709c7b27e3..6af6db3366f 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.34 2015/03/15 00:41:27 millert Exp $ */ +/* $OpenBSD: print.c,v 1.35 2015/12/01 18:36:13 schwarze Exp $ */ /* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */ /* @@ -122,7 +122,7 @@ printlong(DISPLAY *dp) printtime(sp->st_ctime); else printtime(sp->st_mtime); - (void)putname(p->fts_name); + (void)mbsprint(p->fts_name, 1); if (f_type || (f_typedir && S_ISDIR(sp->st_mode))) (void)printtype(sp->st_mode); if (S_ISLNK(sp->st_mode)) @@ -231,7 +231,7 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefield) if (f_size) chcnt += printf("%*qd ", (int)sizefield, howmany(sp->st_blocks, blocksize)); - chcnt += putname(p->fts_name); + chcnt += mbsprint(p->fts_name, 1); if (f_type || (f_typedir && S_ISDIR(sp->st_mode))) chcnt += printtype(sp->st_mode); return (chcnt); @@ -310,7 +310,8 @@ printstream(DISPLAY *dp) continue; if (col > 0) { (void)putchar(','), col++; - if (col + 1 + extwidth + p->fts_namelen >= termwidth) + if (col + 1 + extwidth + mbsprint(p->fts_name, 0) >= + termwidth) (void)putchar('\n'), col = 0; else (void)putchar(' '), col++; @@ -361,7 +362,7 @@ printlink(FTSENT *p) } path[lnklen] = '\0'; (void)printf(" -> "); - (void)putname(path); + (void)mbsprint(path, 1); } static void |