tweaks: avoid parsing a character twice

Let mbtowc() do all the work, and thus also elide a variable.
This commit is contained in:
Benno Schulenberg 2019-06-10 12:01:10 +02:00
parent 967f581860
commit 15e36956b5

View File

@ -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;
}