From 26bbd972dd3bdc73baa9362a2794dfc3ec3ad085 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 25 Sep 2020 17:21:33 -0400 Subject: [PATCH] Cast ctype.h inputs to unsigned char Fuckings to glibc, jesus christ that code was a nightmare Read glibc's ctype.h and then compare it to musl's src/ctype/isalpha.c --- src/main.c | 9 ++++++--- diff --git a/src/main.c b/src/main.c index 8c5ffeb23fb9850c072e7568fa995fc0bc68de4f..cc104f177a4cbfb57d86755d1de3ccd45df42150 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ struct str *section = str_create(); uint32_t ch; char *subsection; while ((ch = parser_getch(p)) != UTF8_INVALID) { - if (ch < 0x80 && isalnum(ch)) { + if (ch < 0x80 && isalnum((unsigned char)ch)) { int ret = str_append_ch(section, ch); assert(ret != -1); } else if (ch == ')') { @@ -112,7 +112,8 @@ } struct tm *date_tm = gmtime(&date_time); strftime(date, sizeof(date), "%F", date_tm); while ((ch = parser_getch(p)) != UTF8_INVALID) { - if ((ch < 0x80 && isalnum(ch)) || ch == '_' || ch == '-' || ch == '.') { + if ((ch < 0x80 && isalnum((unsigned char)ch)) + || ch == '_' || ch == '-' || ch == '.') { int ret = str_append_ch(name, ch); assert(ret != -1); } else if (ch == '(') { @@ -220,7 +221,9 @@ parse_format(p, FORMAT_BOLD); break; case '_': next = parser_getch(p); - if (!isalnum(last) || ((p->flags & FORMAT_UNDERLINE) && !isalnum(next))) { + if (!isalnum((unsigned char)last) || ( + (p->flags & FORMAT_UNDERLINE) && + !isalnum((unsigned char)next))) { parse_format(p, FORMAT_UNDERLINE); } else { utf8_fputch(p->output, ch); -- 2.48.1