projects
/
platform
/
upstream
/
toybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4a86c81
)
Don't go into an endless loop if we hit a bad utf8 sequence without -q.
author
Rob Landley
<rob@landley.net>
Mon, 21 Jul 2014 03:08:46 +0000
(22:08 -0500)
committer
Rob Landley
<rob@landley.net>
Mon, 21 Jul 2014 03:08:46 +0000
(22:08 -0500)
toys/posix/ls.c
patch
|
blob
|
history
diff --git
a/toys/posix/ls.c
b/toys/posix/ls.c
index
b955c41
..
3a7de63
100644
(file)
--- a/
toys/posix/ls.c
+++ b/
toys/posix/ls.c
@@
-75,12
+75,12
@@
int strwidth(char *s)
len = mbrtowc(&c, s, MB_CUR_MAX, 0);
if (len < 1 || (width = wcwidth(c)) < 0) {
total++;
- if (toys.optflags & FLAG_q) *(s++) = '?';
-
- continue;
+ if (toys.optflags & FLAG_q) *s = '?';
+ s++;
+ } else {
+ s += len;
+ total += width;
}
- s += len;
- total += width;
}
return total;