aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-10-15 14:07:17 +0200
committerThomas Voss <mail@thomasvoss.com> 2022-10-15 14:07:17 +0200
commit0a25a86c098a2a06d8f6948bdb074e2bc0dcaf4e (patch)
treef6a17c0ce62ff696d5a46d4b7e733a4a50fb3586
parente918d8b8a6ba41a84b7b74a7fb8da39adb773c2e (diff)
Properly handle backspace charactersv1.1.0
-rw-r--r--center.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/center.c b/center.c
index 7ac5d69..61193a1 100644
--- a/center.c
+++ b/center.c
@@ -230,8 +230,8 @@ utf8len(const char *s)
{
int l = 0;
- while (*s)
- l += (*s++ & 0xC0) != 0x80;
+ for (; *s; s++)
+ l += *s == '\b' ? -1 : (*s & 0xC0) != 0x80;
if (l > 0 && s[-1] == '\n')
l--;