make sure the multibyte string operations operate using multibyte

character counts instead of byte character counts


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2280 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2005-01-16 20:05:36 +00:00
parent 18d616f253
commit 65658ef574
2 changed files with 6 additions and 6 deletions

View File

@ -552,12 +552,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
ws2 = (unsigned char)*s2_mb; ws2 = (unsigned char)*s2_mb;
} }
if (s1_mb_len > n || towlower(ws1) != towlower(ws2)) if (n == 0 || towlower(ws1) != towlower(ws2))
break; break;
s1 += s1_mb_len; s1 += s1_mb_len;
s2 += s2_mb_len; s2 += s2_mb_len;
n -= s1_mb_len; n--;
} }
free(s1_mb); free(s1_mb);
@ -648,16 +648,16 @@ size_t mbstrnlen(const char *s, size_t maxlen)
#endif #endif
, NULL); , NULL);
if (s_mb_len > maxlen) if (maxlen == 0)
break; break;
maxlen -= s_mb_len; maxlen--;
n += s_mb_len; n += s_mb_len;
} }
free(s_mb); free(s_mb);
return n; return strnlenpt(s, n);
} else } else
#endif #endif
return return

View File

@ -84,7 +84,7 @@ void not_found_msg(const char *str)
assert(str != NULL); assert(str != NULL);
disp = display_string(str, 0, (COLS / 2) + 1, FALSE); disp = display_string(str, 0, (COLS / 2) + 1, FALSE);
numchars = mbstrnlen(disp, actual_x(disp, COLS / 2)); numchars = actual_x(disp, mbstrnlen(disp, COLS / 2));
statusbar(_("\"%.*s%s\" not found"), numchars, disp, statusbar(_("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "..."); (disp[numchars] == '\0') ? "" : "...");