tweaks: elide a function that is used just once

master
Benno Schulenberg 2018-07-08 10:40:22 +02:00
parent 9a7ba5db79
commit 7ae8f3bca4
3 changed files with 4 additions and 20 deletions

View File

@ -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 */

View File

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

View File

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