is_alnum_mbchar(), is_alnum_wchar(), is_blank_mbchar(),
is_blank_wchar(), is_cntrl_mbchar(), is_cntrl_wchar(),
control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(),
- make_mbchar(), mbstrnlen(), mbstrcasecmp(), mbstrncasecmp(),
- mbstrcasestr(), and mbrevstrcasestr(); changes to is_byte()
- (moved to chars.c), is_blank_char() (moved to chars.c),
- is_cntrl_char() (moved to chars.c), nstricmp() (renamed
- nstrcasecmp() and moved to chars.c), nstrnicmp() (renamed
- nstrncasecmp() and moved to chars.c), nstristr() (renamed
- nstrcasestr() and moved to chars.c), revstrstr() (moved to
- chars.c), revstristr() (renamed revstrcasestr() and moved to
- chars.c), nstrnlen() (moved to chars.c), parse_char()
- (renamed parse_mbchar() and moved to chars.c), move_left()
- (renamed move_mbleft() and moved to chars.c), move_right()
- (renamed move_mbright() and moved to chars.c), do_home(),
- do_verbatim_input(), do_delete(), do_tab(), do_next_word(),
- do_prev_word(), do_input(), do_output(), strstrwrapper(),
- get_buffer(), unget_input(), unget_kbinput(), get_input(),
- parse_kbinput(), unparse_kbinput(), parse_verbatim_kbinput(),
+ make_mbchar(), mbstrlen(), mbstrnlen(), mbstrcasecmp(),
+ mbstrncasecmp(), mbstrcasestr(), and mbrevstrcasestr();
+ changes to is_byte() (moved to chars.c), is_blank_char()
+ (moved to chars.c), is_cntrl_char() (moved to chars.c),
+ nstricmp() (renamed nstrcasecmp() and moved to chars.c),
+ nstrnicmp() (renamed nstrncasecmp() and moved to chars.c),
+ nstristr() (renamed nstrcasestr() and moved to chars.c),
+ revstrstr() (moved to chars.c), revstristr() (renamed
+ revstrcasestr() and moved to chars.c), nstrnlen() (moved to
+ chars.c), parse_char() (renamed parse_mbchar() and moved to
+ chars.c), move_left() (renamed move_mbleft() and moved to
+ chars.c), move_right() (renamed move_mbright() and moved to
+ chars.c), do_home(), do_verbatim_input(), do_delete(),
+ do_tab(), do_next_word(), do_prev_word(), do_input(),
+ do_output(), strstrwrapper(), get_buffer(), unget_input(),
+ unget_kbinput(), get_input(), parse_kbinput(),
+ unparse_kbinput(), parse_verbatim_kbinput(),
do_statusbar_input(), do_statusbar_home(),
do_statusbar_verbatim_kbinput(), do_statusbar_output(), and
display_string(); removal of buffer_to_keys() and
/* This function is equivalent to strcasecmp(). */
int nstrcasecmp(const char *s1, const char *s2)
{
- assert(s1 != NULL && s2 != NULL);
-
- for (; *s1 != '\0' && *s2 != '\0'; s1++, s2++) {
- if (tolower(*s1) != tolower(*s2))
- break;
- }
-
- return (tolower(*s1) - tolower(*s2));
+ return
+#ifdef HAVE_STRNCASECMP
+ strncasecmp(s1, s2, (size_t)-1);
+#else
+ nstrncasecmp(s1, s2, (size_t)-1);
+#endif
}
#endif
/* This function is equivalent to strcasecmp() for multibyte strings. */
int mbstrcasecmp(const char *s1, const char *s2)
{
-#ifdef NANO_WIDE
- if (!ISSET(NO_UTF8)) {
- char *s1_mb = charalloc(MB_CUR_MAX);
- char *s2_mb = charalloc(MB_CUR_MAX);
- wchar_t ws1, ws2;
-
- assert(s1 != NULL && s2 != NULL);
-
- while (*s1 != '\0' && *s2 != '\0') {
- int s1_mb_len, s2_mb_len;
-
- s1_mb_len = parse_mbchar(s1, s1_mb, NULL, NULL);
-
- if (mbtowc(&ws1, s1_mb, s1_mb_len) <= 0) {
- mbtowc(NULL, NULL, 0);
- ws1 = (unsigned char)*s1_mb;
- }
-
-
- s2_mb_len = parse_mbchar(s2, s2_mb, NULL, NULL);
-
- if (mbtowc(&ws2, s2_mb, s2_mb_len) <= 0) {
- mbtowc(NULL, NULL, 0);
- ws2 = (unsigned char)*s2_mb;
- }
-
-
- if (towlower(ws1) != towlower(ws2))
- break;
-
- s1 += s1_mb_len;
- s2 += s2_mb_len;
- }
-
- free(s1_mb);
- free(s2_mb);
-
- return (towlower(ws1) - towlower(ws2));
- } else
-#endif
- return
-#ifdef HAVE_STRCASECMP
- strcasecmp(s1, s2);
-#else
- nstrcasecmp(s1, s2);
-#endif
+ return mbstrncasecmp(s1, s2, (size_t)-1);
}
#ifndef HAVE_STRNCASECMP
}
#endif
+/* This function is equivalent to strlen() for multibyte strings. */
+size_t mbstrlen(const char *s)
+{
+ return mbstrnlen(s, (size_t)-1);
+}
+
#ifndef HAVE_STRNLEN
/* This function is equivalent to strnlen(). */
size_t nstrnlen(const char *s, size_t maxlen)
int s_mb_len;
while (*s != '\0') {
- s_mb_len = parse_mbchar(s + n, s_mb, NULL, NULL);
+ s_mb_len = parse_mbchar(s, s_mb, NULL, NULL);
if (maxlen == 0)
break;
maxlen--;
- n += s_mb_len;
+ s += s_mb_len;
+ n++;
}
free(s_mb);
- return strnlenpt(s, n);
+ return n;
} else
#endif
return