From 65658ef574672491e2ec0e3020cb66d87fcc1a03 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sun, 16 Jan 2005 20:05:36 +0000 Subject: [PATCH] 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 --- src/chars.c | 10 +++++----- src/search.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chars.c b/src/chars.c index 5b82ad8f..5c160ce1 100644 --- a/src/chars.c +++ b/src/chars.c @@ -552,12 +552,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n) ws2 = (unsigned char)*s2_mb; } - if (s1_mb_len > n || towlower(ws1) != towlower(ws2)) + if (n == 0 || towlower(ws1) != towlower(ws2)) break; s1 += s1_mb_len; s2 += s2_mb_len; - n -= s1_mb_len; + n--; } free(s1_mb); @@ -648,16 +648,16 @@ size_t mbstrnlen(const char *s, size_t maxlen) #endif , NULL); - if (s_mb_len > maxlen) + if (maxlen == 0) break; - maxlen -= s_mb_len; + maxlen--; n += s_mb_len; } free(s_mb); - return n; + return strnlenpt(s, n); } else #endif return diff --git a/src/search.c b/src/search.c index 10d67979..6f657810 100644 --- a/src/search.c +++ b/src/search.c @@ -84,7 +84,7 @@ void not_found_msg(const char *str) assert(str != NULL); 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, (disp[numchars] == '\0') ? "" : "..."); -- 2.39.5