}
/* Return TRUE for a multibyte character found in a word (currently only
- * an alphanumeric or punctuation character) and FALSE otherwise. */
-bool is_word_mbchar(const char *c)
+ * an alphanumeric or punctuation character, and the latter only if
+ * allow_punct is TRUE) and FALSE otherwise. */
+bool is_word_mbchar(const char *c, bool allow_punct)
{
assert(c != NULL);
wc = (unsigned char)*c;
}
- return iswalnum(wc) || iswpunct(wc);
+ return iswalnum(wc) || (allow_punct ? iswpunct(wc) : FALSE);
} else
#endif
- return isalnum((unsigned char)*c) || ispunct((unsigned char)*c);
+ return isalnum((unsigned char)*c) || (allow_punct ?
+ ispunct((unsigned char)*c) : FALSE);
}
/* c is a control character. It displays as ^@, ^?, or ^[ch], where ch
{
return
#ifdef NANO_WIDE
- (!ISSET(NO_UTF8)) ? MB_CUR_MAX :
+ !ISSET(NO_UTF8) ? MB_CUR_MAX :
#endif
1;
}
free(r_mb);
free(q_mb);
- return (found_needle) ? haystack : NULL;
+ return found_needle ? haystack : NULL;
} else
#endif
return strcasestr(haystack, needle);
free(r_mb);
free(q_mb);
- return (found_needle) ? rev_start : NULL;
+ return found_needle ? rev_start : NULL;
} else
#endif
return revstrcasestr(haystack, needle, rev_start);
/* If we've found it, stop moving forward through the current
* line. */
- if (!is_word_mbchar(char_mb))
+ if (!is_word_mbchar(char_mb, TRUE))
break;
/* If we haven't found it, then we've started on a word, so set
/* If we've found it, stop moving forward through the
* current line. */
- if (is_word_mbchar(char_mb))
+ if (is_word_mbchar(char_mb, TRUE))
break;
current_x += char_mb_len;
/* If we've found it, stop moving backward through the current
* line. */
- if (!is_word_mbchar(char_mb))
+ if (!is_word_mbchar(char_mb, TRUE))
break;
if (current_x == 0)
/* If we've found it, stop moving backward through the
* current line. */
- if (is_word_mbchar(char_mb))
+ if (is_word_mbchar(char_mb, TRUE))
break;
if (current_x == 0)
/* If we've found it, stop moving backward through the
* current line. */
- if (!is_word_mbchar(char_mb))
+ if (!is_word_mbchar(char_mb, TRUE))
break;
if (current_x == 0)
bool is_cntrl_wchar(wint_t wc);
#endif
bool is_cntrl_mbchar(const char *c);
-bool is_word_mbchar(const char *c);
+bool is_word_mbchar(const char *c, bool allow_punct);
char control_rep(char c);
#ifdef NANO_WIDE
wchar_t control_wrep(wchar_t c);
parse_mbchar(buf + word_end, r, NULL, NULL);
/* If we're at the beginning of the line or the character before the
- * word isn't a "word" character, and if we're at the end of the
- * line or the character after the word isn't a "word" character, we
- * have a whole word. */
- retval = (pos == 0 || !is_word_mbchar(p)) &&
- (word_end == strlen(buf) || !is_word_mbchar(r));
+ * word isn't a non-punctuation "word" character, and if we're at
+ * the end of the line or the character after the word isn't a
+ * non-punctuation "word" character, we have a whole word. */
+ retval = (pos == 0 || !is_word_mbchar(p, FALSE)) &&
+ (word_end == strlen(buf) || !is_word_mbchar(r, FALSE));
free(p);
free(r);
/* If we've found it, stop moving forward through the current
* line. */
- if (!is_word_mbchar(char_mb))
+ if (!is_word_mbchar(char_mb, TRUE))
break;
statusbar_x += char_mb_len;
/* If we've found it, stop moving forward through the current
* line. */
- if (is_word_mbchar(char_mb))
+ if (is_word_mbchar(char_mb, TRUE))
break;
statusbar_x += char_mb_len;
/* If we've found it, stop moving backward through the current
* line. */
- if (!is_word_mbchar(char_mb))
+ if (!is_word_mbchar(char_mb, TRUE))
break;
if (statusbar_x == 0)
/* If we've found it, stop moving backward through the current
* line. */
- if (is_word_mbchar(char_mb))
+ if (is_word_mbchar(char_mb, TRUE))
break;
if (statusbar_x == 0)
/* If we've found it, stop moving backward through the
* current line. */
- if (!is_word_mbchar(char_mb))
+ if (!is_word_mbchar(char_mb, TRUE))
break;
if (statusbar_x == 0)