commit 7ae8f3bca4ef49faffd5e7e150d7e06d7bdf8917
parent 9a7ba5db7949e441dcdfa7f445aa2a132d41428a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 8 Jul 2018 10:40:22 +0200
tweaks: elide a function that is used just once
Diffstat:
3 files changed, 4 insertions(+), 20 deletions(-)
diff --git 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
@@ -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
@@ -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);