commit 15e36956b5ee2b87fee2b2a2651704641b60399f
parent 967f581860117fd7a6835d7926d4a81b3cf1c1f5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 10 Jun 2019 12:01:10 +0200
tweaks: avoid parsing a character twice
Let mbtowc() do all the work, and thus also elide a variable.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -541,7 +541,6 @@ char *mbstrchr(const char *s, const char *c)
#ifdef ENABLE_UTF8
if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
- char symbol[MAXCHARLEN];
const char *q = s;
wchar_t ws, wc;
@@ -551,9 +550,9 @@ char *mbstrchr(const char *s, const char *c)
}
while (*s != '\0') {
- int sym_len = parse_mbchar(s, symbol, NULL);
+ int sym_len = mbtowc(&ws, s, MAXCHARLEN);
- if (mbtowc(&ws, symbol, sym_len) < 0) {
+ if (sym_len < 0) {
ws = (unsigned char)*s;
bad_s_mb = TRUE;
}