Commit 8edaa38a authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: condense two bits of code, and drop two asserts

No related merge requests found
Showing with 8 additions and 17 deletions
+8 -17
...@@ -1813,23 +1813,17 @@ void check_statusblank(void) ...@@ -1813,23 +1813,17 @@ void check_statusblank(void)
* "$" at the beginning or end of the line if it's too long. */ * "$" at the beginning or end of the line if it's too long. */
char *display_string(const char *buf, size_t column, size_t span, bool isdata) char *display_string(const char *buf, size_t column, size_t span, bool isdata)
{ {
size_t start_index; size_t start_index = actual_x(buf, column);
/* Index in buf of the first character shown. */ /* The index of the first character that the caller wishes to show. */
size_t start_col; size_t start_col = strnlenpt(buf, start_index);
/* Screen column that start_index corresponds to. */ /* The actual column where that first character starts. */
char *converted; char *converted;
/* The expanded string we will return. */ /* The expanded string we will return. */
size_t index; size_t index = 0;
/* Current position in converted. */ /* Current position in converted. */
size_t beyond = column + span; size_t beyond = column + span;
/* The column number just beyond the last shown character. */ /* The column number just beyond the last shown character. */
start_index = actual_x(buf, column);
start_col = strnlenpt(buf, start_index);
assert(start_col <= column);
index = 0;
#ifdef USING_OLD_NCURSES #ifdef USING_OLD_NCURSES
seen_wide = FALSE; seen_wide = FALSE;
#endif #endif
...@@ -3371,12 +3365,9 @@ void do_credits(void) ...@@ -3371,12 +3365,9 @@ void do_credits(void)
const char *what; const char *what;
size_t start_col; size_t start_col;
if (credits[crpos] == NULL) { if (credits[crpos] == NULL)
assert(0 <= xlpos && xlpos < XLCREDIT_LEN); what = _(xlcredits[xlpos++]);
else
what = _(xlcredits[xlpos]);
xlpos++;
} else
what = credits[crpos]; what = credits[crpos];
start_col = COLS / 2 - strlenpt(what) / 2 - 1; start_col = COLS / 2 - strlenpt(what) / 2 - 1;
......
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