and NANO_APPEND_KEY are. Changes to shortcut_init(), usage(),
main(), search_init(), nanorc.sample, nano.1, nanorc.5,
nano.texi, etc. (DLR)
- - Various cleanups in chars.c. Remove some unnecessary (w)ctype
- wrappers; change other ctype wrappers to take wint_t instead
- of wchar_t; rename some functions for consistency; and don't
- count matches between valid and invalid multibyte sequences
- anymore, as it causes problems when doing a replace. New
- function is_valid_mbstring(); changes to is_alnum_mbchar(),
+ - Various cleanups and improvements in chars.c. Remove some
+ unnecessary w?ctype wrappers; change other ctype wrappers to
+ take wint_t instead of wchar_t; rename some functions for
+ consistency; add functions to detect blank characters in a
+ string, for use in rcfile option parsing; and don't count
+ matches between valid and invalid multibyte sequences anymore,
+ as it causes problems when doing a replace. New functions
+ is_valid_mbstring(), has_blank_chars(), and
+ has_blank_mbchars(); changes to is_alnum_mbchar(),
is_blank_char() (renamed nisblank()), is_blank_mbchar(),
is_blank_wchar() (renamed niswblank()), is_cntrl_wchar(),
control_rep(), control_mbrep(), make_mbstring() (renamed
parse_rcfile()
- Properly generate an error if we get an invalid multibyte
string for an option, instead of working around it. (DLR)
+ - Use has_blank_mbchars() to check for blank characters in the
+ "punct" and "brackets" options, and clarify the error message
+ displayed when we find blank characters. (DLR)
- search.c:
do_gotoline()
- Properly show an error message if we try to go to line 0,
}
#ifndef DISABLE_JUSTIFY
+#ifdef ENABLE_NANORC
+/* Return TRUE if the string s contains one or more blank characters,
+ * and FALSE otherwise. */
+bool has_blank_chars(const char *s)
+{
+ assert(s != NULL);
+
+ for (; *s != '\0'; s++) {
+ if (isblank(*s))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* Return TRUE if the multibyte string s contains one or more blank
+ * multibyte characters, and FALSE otherwise. */
+bool has_blank_mbchars(const char *s)
+{
+ assert(str != NULL);
+
+#ifdef NANO_WIDE
+ if (!ISSET(NO_UTF8)) {
+ char *chr_mb = charalloc(MB_CUR_MAX);
+ bool retval = FALSE;
+
+ while (*s != '\0') {
+ int chr_mb_len;
+
+ chr_mb_len = parse_mbchar(s, chr_mb, NULL, NULL);
+
+ if (is_blank_mbchar(chr_mb)) {
+ retval = TRUE;
+ break;
+ }
+
+ s += chr_mb_len;
+ }
+
+ free(chr_mb);
+
+ return retval;
+ } else
+#endif
+ return has_blank_chars(s);
+}
+#endif
+
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, char *c)
{
#ifndef DISABLE_JUSTIFY
if (strcasecmp(rcopts[i].name, "punct") == 0) {
punct = option;
- if (strchr(punct, '\t') != NULL ||
- strchr(punct, ' ') != NULL) {
+ if (has_blank_mbchars(punct)) {
rcfile_error(
- N_("Non-tab and non-space characters required"));
+ N_("Non-blank characters required"));
free(punct);
punct = NULL;
}
} else if (strcasecmp(rcopts[i].name,
"brackets") == 0) {
brackets = option;
- if (strchr(brackets, '\t') != NULL ||
- strchr(brackets, ' ') != NULL) {
+ if (has_blank_mbchars(brackets)) {
rcfile_error(
- N_("Non-tab and non-space characters required"));
+ N_("Non-blank characters required"));
free(brackets);
brackets = NULL;
}