summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-03-19 23:30:15 +0000
committerdavidovski <david@davidovski.xyz>2022-03-19 23:30:15 +0000
commitb69909628b42e2d063dcbdcbe7adaddf5e7ee047 (patch)
tree0771a367fe13bfa28d3ffa79907527c462a540e2 /src
parent4c72e89f2ecb457a212b001bbaabd4c35ff77f82 (diff)
proper unicode character interpretationv1.2.1
Diffstat (limited to 'src')
-rw-r--r--src/hbar.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/hbar.c b/src/hbar.c
index c0272b9..59cf888 100644
--- a/src/hbar.c
+++ b/src/hbar.c
@@ -38,11 +38,9 @@ void human_format(int bytes, char *output) {
size_t len(char *s) {
size_t len = 0;
- for (; *s; s++) {
- if ((*s & 0XC0) != 0x80) {
+ for (; *s; s++)
+ if ((*s & 0XC0) != 0x80)
len++;
- }
- }
return len;
}
@@ -50,17 +48,17 @@ void printat(char *s, size_t index) {
index++;
for (; *s; s++) {
if ((*s & 0XC0) != 0x80) {
+ if (index <= 0)
+ return;
index--;
}
if (index <= 0) {
fwrite(s, 1, 1, stdout);
- if ((*s & 0XC0) == 0x80)
- return;
}
}
}
-int main (int argc, char **argv) {
+int main(int argc, char **argv) {
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
int width = w.ws_col;