diff --git a/src/help.c b/src/help.c index 556270f7..e799f0c3 100644 --- a/src/help.c +++ b/src/help.c @@ -356,29 +356,6 @@ void help_init(void) assert(strlen(help_text) <= allocsize + 1); } -/* Calculate the next line of help_text, starting at ptr. */ -size_t help_line_len(const char *ptr) -{ - int help_cols = (COLS > 24) ? COLS - 8 : 24; - - /* Try to break the line at (COLS - 8) columns if we have more than - * 24 columns, and at 24 columns otherwise. */ - size_t retval = break_line(ptr, help_cols, TRUE); - size_t retval_save = retval; - - /* Get the length of the entire line up to a null or a newline. */ - while (*(ptr + retval) != '\0' && *(ptr + retval) != '\n') - retval += move_mbright(ptr + retval, 0); - - /* If the entire line doesn't go more than 8 columns beyond where we - * tried to break it, we should display it as-is. Otherwise, we - * should display it only up to the break. */ - if (strnlenpt(ptr, retval) > help_cols + 8) - retval = retval_save; - - return retval; -} - /* Our dynamic, shortcut-list-compliant help function. */ void do_help(void) { @@ -514,4 +491,27 @@ void do_help(void) help_text = NULL; } +/* Calculate the next line of help_text, starting at ptr. */ +size_t help_line_len(const char *ptr) +{ + int help_cols = (COLS > 24) ? COLS - 8 : 24; + + /* Try to break the line at (COLS - 8) columns if we have more than + * 24 columns, and at 24 columns otherwise. */ + size_t retval = break_line(ptr, help_cols, TRUE); + size_t retval_save = retval; + + /* Get the length of the entire line up to a null or a newline. */ + while (*(ptr + retval) != '\0' && *(ptr + retval) != '\n') + retval += move_mbright(ptr + retval, 0); + + /* If the entire line doesn't go more than 8 columns beyond where we + * tried to break it, we should display it as-is. Otherwise, we + * should display it only up to the break. */ + if (strnlenpt(ptr, retval) > help_cols + 8) + retval = retval_save; + + return retval; +} + #endif /* !DISABLE_HELP */ diff --git a/src/proto.h b/src/proto.h index 6f6fbc48..a3247cee 100644 --- a/src/proto.h +++ b/src/proto.h @@ -313,8 +313,8 @@ void thanks_for_all_the_fish(void); /* Public functions in help.c. */ #ifndef DISABLE_HELP void help_init(void); -size_t help_line_len(const char *ptr); void do_help(void); +size_t help_line_len(const char *ptr); #endif /* Public functions in move.c. */