From 15e36956b5ee2b87fee2b2a2651704641b60399f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 10 Jun 2019 12:01:10 +0200 Subject: [PATCH] tweaks: avoid parsing a character twice Let mbtowc() do all the work, and thus also elide a variable. --- src/chars.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/chars.c b/src/chars.c index 628ec4b8..d2eb5500 100644 --- 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; }