fix the multibyte equivalent of strnlen() so that it actually works

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2260 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-01-14 04:38:48 +00:00
parent 5508cc5b0a
commit 8f2906ba61
1 changed files with 4 additions and 1 deletions

View File

@ -144,7 +144,7 @@ size_t nstrnlen(const char *s, size_t maxlen)
size_t mbstrnlen(const char *s, size_t maxlen)
{
#ifdef NANO_WIDE
if (ISSET(NO_UTF8)) {
if (!ISSET(NO_UTF8)) {
size_t n = 0;
char *s_mb = charalloc(mb_cur_max());
int s_mb_len;
@ -158,6 +158,9 @@ size_t mbstrnlen(const char *s, size_t maxlen)
#endif
, NULL);
if (s_mb_len > maxlen)
s_mb_len = maxlen;
maxlen -= s_mb_len;
n += s_mb_len;