Commit dfff78df authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

titlebar: always pass a pathname through display_string()

So that embedded control characters will be represented
instead of acted upon.

This fixes the first part of https://savannah.gnu.org/bugs/?49867.
No related merge requests found
Showing with 10 additions and 8 deletions
+10 -8
...@@ -1969,8 +1969,8 @@ void titlebar(const char *path) ...@@ -1969,8 +1969,8 @@ void titlebar(const char *path)
/* What is shown before the path -- "File:", "DIR:", or "". */ /* What is shown before the path -- "File:", "DIR:", or "". */
const char *state = ""; const char *state = "";
/* The state of the current buffer -- "Modified", "View", or "". */ /* The state of the current buffer -- "Modified", "View", or "". */
char *fragment; char *caption;
/* The tail part of the pathname when dottified. */ /* The presentable form of the pathname. */
/* If the screen is too small, there is no titlebar. */ /* If the screen is too small, there is no titlebar. */
if (topwin == NULL) if (topwin == NULL)
...@@ -2049,14 +2049,16 @@ void titlebar(const char *path) ...@@ -2049,14 +2049,16 @@ void titlebar(const char *path)
wmove(topwin, 0, offset); wmove(topwin, 0, offset);
/* Print the full path if there's room; otherwise, dottify it. */ /* Print the full path if there's room; otherwise, dottify it. */
if (pathlen + pluglen + statelen <= COLS) if (pathlen + pluglen + statelen <= COLS) {
waddstr(topwin, path); caption = display_string(path, 0, pathlen, FALSE);
else if (5 + statelen <= COLS) { waddstr(topwin, caption);
free(caption);
} else if (5 + statelen <= COLS) {
waddstr(topwin, "..."); waddstr(topwin, "...");
fragment = display_string(path, 3 + pathlen - COLS + statelen, caption = display_string(path, 3 + pathlen - COLS + statelen,
COLS - statelen, FALSE); COLS - statelen, FALSE);
waddstr(topwin, fragment); waddstr(topwin, caption);
free(fragment); free(caption);
} }
/* Right-align the state if there's room; otherwise, trim it. */ /* Right-align the state if there's room; otherwise, trim it. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment