Fix ls -q UTF-8 parsing
Thanks FRIGN for the input.
This commit is contained in:
parent
2a3f82a5cd
commit
d40333e702
7
ls.c
7
ls.c
|
@ -209,11 +209,11 @@ lsdir(const char *path)
|
||||||
output(&ent);
|
output(&ent);
|
||||||
} else {
|
} else {
|
||||||
ents = erealloc(ents, ++n * sizeof(*ents));
|
ents = erealloc(ents, ++n * sizeof(*ents));
|
||||||
name = p = estrdup(d->d_name);
|
name = p = emalloc(strlen(d->d_name) + 1);
|
||||||
if (qflag) {
|
if (qflag) {
|
||||||
q = d->d_name;
|
q = d->d_name;
|
||||||
while (*p) {
|
while (*q) {
|
||||||
len = chartorune(&r, p);
|
len = chartorune(&r, q);
|
||||||
if (isprintrune(r)) {
|
if (isprintrune(r)) {
|
||||||
memcpy(p, q, len);
|
memcpy(p, q, len);
|
||||||
p += len, q += len;
|
p += len, q += len;
|
||||||
|
@ -222,6 +222,7 @@ lsdir(const char *path)
|
||||||
q += len;
|
q += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*p = '\0';
|
||||||
}
|
}
|
||||||
mkent(&ents[n - 1], name, tflag || Fflag || lflag || iflag, Lflag);
|
mkent(&ents[n - 1], name, tflag || Fflag || lflag || iflag, Lflag);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user