sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit d40333e702c5f116cbc0650b5dd5512abb17c5e4
parent 2a3f82a5cd9b6712b4e8d501d4f529ec8578c62f
Author: sin <sin@2f30.org>
Date:   Wed, 18 Feb 2015 16:43:18 +0000

Fix ls -q UTF-8 parsing

Thanks FRIGN for the input.

Diffstat:
Mls.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ls.c b/ls.c @@ -209,11 +209,11 @@ lsdir(const char *path) output(&ent); } else { ents = erealloc(ents, ++n * sizeof(*ents)); - name = p = estrdup(d->d_name); + name = p = emalloc(strlen(d->d_name) + 1); if (qflag) { q = d->d_name; - while (*p) { - len = chartorune(&r, p); + while (*q) { + len = chartorune(&r, q); if (isprintrune(r)) { memcpy(p, q, len); p += len, q += len; @@ -222,6 +222,7 @@ lsdir(const char *path) q += len; } } + *p = '\0'; } mkent(&ents[n - 1], name, tflag || Fflag || lflag || iflag, Lflag); }