Commit 8f2906ba authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
No related merge requests found
Showing with 4 additions and 1 deletion
+4 -1
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment