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.
master
David Lawrence Ramsey 2017-09-18 19:57:57 -05:00 committed by Benno Schulenberg
parent aa45994bbb
commit 5561d22f19
1 changed files with 2 additions and 2 deletions

View File

@ -70,12 +70,12 @@ void regexp_cleanup(void)
void not_found_msg(const char *str) void not_found_msg(const char *str)
{ {
char *disp; char *disp;
int numchars; size_t numchars;
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 = actual_x(disp, mbstrnlen(disp, COLS / 2)); numchars = actual_x(disp, strnlenpt(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp, statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "..."); (disp[numchars] == '\0') ? "" : "...");