prompt: show whitespace only in the filename, not in the whole line

That is, call display_string() just on the filename, not on the rest
of the prompt text.

This fixes https://savannah.gnu.org/bugs/?52967.
Reported-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
master
Benno Schulenberg 2018-01-25 11:00:19 +01:00
parent 7b9bd65362
commit 97cbbb0cc8
2 changed files with 12 additions and 7 deletions

View File

@ -345,6 +345,9 @@ int do_lockfile(const char *filename)
pidstring = charalloc(11);
sprintf (pidstring, "%u", (unsigned int)lockpid);
/* Display newlines in filenames as ^J. */
as_an_at = FALSE;
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
question = _("File %s is being edited (by %s with %s, PID %s); continue?");
room = COLS - strlenpt(question) + 7 - strlenpt(lockuser) -
@ -359,7 +362,7 @@ int do_lockfile(const char *filename)
strcat(postedname, fragment);
free(fragment);
} else
postedname = mallocstrcpy(NULL, filename);
postedname = display_string(filename, 0, room, FALSE);
/* Allow extra space for username (14), program name (8), PID (8),
* and terminating \0 (1), minus the %s (2) for the file name. */
@ -2193,12 +2196,17 @@ 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);
char *message = charalloc(strlen(question) +
strlen(answer) + 1);
sprintf(message, question, answer);
strlen(name) + 1);
sprintf(message, question, name);
i = do_yesno_prompt(FALSE, message);
free(message);
free(name);
if (i < 1)
continue;

View File

@ -669,7 +669,6 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg)
{
int response = -2, width = 16;
char *message = display_string(msg, 0, COLS, FALSE);
/* TRANSLATORS: For the next three strings, if possible, specify
* the single-byte letters for both your language and English.
@ -717,7 +716,7 @@ int do_yesno_prompt(bool all, const char *msg)
/* Color the statusbar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, message, actual_x(message, COLS - 1));
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wnoutrefresh(bottomwin);
@ -755,7 +754,5 @@ int do_yesno_prompt(bool all, const char *msg)
#endif /* ENABLE_MOUSE */
}
free(message);
return response;
}