display: correctly trim an overshooting character from a prompt answer

Tell display_string() explicitly when we're at a prompt, instead of
letting it glean this from the current menu not being MMAIN, which
fails in some circumstances.

This improves the fix for https://savannah.gnu.org/bugs/?55620,
fixes https://savannah.gnu.org/bugs/?55680 in a better way,
and fixes https://savannah.gnu.org/bugs/?55773.
This commit is contained in:
David Lawrence Ramsey
2019-02-27 14:37:53 -06:00
committed by Benno Schulenberg
parent de47b58dc1
commit f13dd140eb
7 changed files with 25 additions and 22 deletions

View File

@@ -359,13 +359,13 @@ int do_lockfile(const char *filename)
postedname = mallocstrcpy(NULL, "_");
else if (room < strlenpt(filename)) {
char *fragment = display_string(filename,
strlenpt(filename) - room + 3, room, FALSE);
strlenpt(filename) - room + 3, room, FALSE, FALSE);
postedname = charalloc(strlen(fragment) + 4);
strcpy(postedname, "...");
strcat(postedname, fragment);
free(fragment);
} else
postedname = display_string(filename, 0, room, FALSE);
postedname = display_string(filename, 0, room, FALSE, FALSE);
/* Allow extra space for username (14), program name (8), PID (8),
* and terminating \0 (1), minus the %s (2) for the file name. */
@@ -2256,7 +2256,7 @@ int do_writeout(bool exiting, bool withprompt)
if (name_exists) {
char *question = _("File \"%s\" exists; OVERWRITE? ");
char *name = display_string(answer, 0,
COLS - strlenpt(question) + 1, FALSE);
COLS - strlenpt(question) + 1, FALSE, FALSE);
char *message = charalloc(strlen(question) +
strlen(name) + 1);
@@ -2704,7 +2704,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
break;
}
disp = display_string(matches[match], 0, longest_name, FALSE);
disp = display_string(matches[match], 0, longest_name, FALSE, FALSE);
waddstr(edit, disp);
free(disp);