From 7ae8f3bca4ef49faffd5e7e150d7e06d7bdf8917 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 8 Jul 2018 10:40:22 +0200 Subject: [PATCH] tweaks: elide a function that is used just once --- src/chars.c | 14 -------------- src/proto.h | 3 --- src/rcfile.c | 7 ++++--- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/chars.c b/src/chars.c index fcbc9f4f..9ea0bc07 100644 --- a/src/chars.c +++ b/src/chars.c @@ -712,17 +712,3 @@ bool is_valid_unicode(wchar_t wc) (0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD)); } #endif - -#ifdef ENABLE_NANORC -/* Check if the string s is a valid multibyte string. Return TRUE if it - * is, and FALSE otherwise. */ -bool is_valid_mbstring(const char *s) -{ -#ifdef ENABLE_UTF8 - if (use_utf8) - return (mbstowcs(NULL, s, 0) != (size_t)-1); - else -#endif - return TRUE; -} -#endif /* ENABLE_NANORC */ diff --git a/src/proto.h b/src/proto.h index 399725a8..30d18a75 100644 --- a/src/proto.h +++ b/src/proto.h @@ -236,9 +236,6 @@ bool has_blank_mbchars(const char *s); #ifdef ENABLE_UTF8 bool is_valid_unicode(wchar_t wc); #endif -#ifdef ENABLE_NANORC -bool is_valid_mbstring(const char *s); -#endif /* Most functions in color.c. */ #ifdef ENABLE_COLOR diff --git a/src/rcfile.c b/src/rcfile.c index 2e6675ea..4ab8241f 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -1085,12 +1085,13 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) #ifdef DEBUG fprintf(stderr, " Option argument = \"%s\"\n", option); #endif - /* Make sure the option argument is a valid multibyte string. */ - if (!is_valid_mbstring(option)) { +#ifdef ENABLE_UTF8 + /* When in a UTF-8 locale, ignore arguments with invalid sequences. */ + if (using_utf8() && mbstowcs(NULL, option, 0) == (size_t)-1) { rcfile_error(N_("Argument is not a valid multibyte string")); continue; } - +#endif #ifdef ENABLE_COLOR if (strcasecmp(rcopts[i].name, "titlecolor") == 0) color_combo[TITLE_BAR] = parse_interface_color(option);