From 5561d22f19b8ec671f514f5daae7e9a3a2491502 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 18 Sep 2017 19:57:57 -0500 Subject: [PATCH] search: trim a failed search string for width instead of length When reducing the search string to at most half the screen width, it should employ its width in columns, not its length in bytes. Also adjust the type of a variable. This fixes http://savannah.gnu.org/bugs/?52057. --- src/search.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search.c b/src/search.c index c37813ea..cc5cf5f6 100644 --- a/src/search.c +++ b/src/search.c @@ -70,12 +70,12 @@ void regexp_cleanup(void) void not_found_msg(const char *str) { char *disp; - int numchars; + size_t numchars; assert(str != NULL); disp = display_string(str, 0, (COLS / 2) + 1, FALSE); - numchars = actual_x(disp, mbstrnlen(disp, COLS / 2)); + numchars = actual_x(disp, strnlenpt(disp, COLS / 2)); statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp, (disp[numchars] == '\0') ? "" : "...");