From a0951f2aa52beb8a4422ef31d39b65a690dc3a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Fri, 12 Aug 2022 23:33:46 -0300 Subject: [PATCH] Only deal with ASCII printable characters. At least for now, it's easier than dealing with unicode properly. --- ef.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ef.c b/ef.c index a4bdc0a..9e71ea0 100644 --- a/ef.c +++ b/ef.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -263,14 +264,19 @@ int main(int argc, char **argv) break; default: - if (n == cap) { - cap *= 2; - name = xrealloc(name, cap); + /* XXX: not unicode aware; + * this is reasonable for now, since otherwise we'd have to + * implement character deletion with unicode */ + if (isprint((unsigned char)c)) { + if (n == cap) { + cap *= 2; + name = xrealloc(name, cap); + } + name[n] = c; + n++; + /* clear chars from previous entries and/or dirty memory */ + name[n] = 0; } - name[n] = c; - n++; - /* clear chars from previous entries and/or dirty memory */ - name[n] = 0; break; }