tweaks: adjust the type of two arguments

Convert digits() to take a ssize_t instead of an int, since it's
used on ssize_t line numbers.  And properly use the long modifier
when displaying a line number.

Also, conditionalize the digits() prototype.
master
David Lawrence Ramsey 2016-12-09 11:36:01 -06:00 committed by Benno Schulenberg
parent 29e094cd21
commit bd920b1f49
3 changed files with 5 additions and 3 deletions

View File

@ -651,7 +651,9 @@ void complete_a_word(void);
/* All functions in utils.c. */ /* All functions in utils.c. */
void get_homedir(void); void get_homedir(void);
int digits(int n); #ifdef ENABLE_LINENUMBERS
int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *val); bool parse_num(const char *str, ssize_t *val);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column); bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void align(char **str); void align(char **str);

View File

@ -54,7 +54,7 @@ void get_homedir(void)
#ifdef ENABLE_LINENUMBERS #ifdef ENABLE_LINENUMBERS
/* Return the number of digits that the given integer n takes up. */ /* Return the number of digits that the given integer n takes up. */
int digits(int n) int digits(ssize_t n)
{ {
if (n < 100000) { if (n < 100000) {
if (n < 1000) { if (n < 1000) {

View File

@ -2323,7 +2323,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (margin > 0) { if (margin > 0) {
wattron(edit, interface_color_pair[LINE_NUMBER]); wattron(edit, interface_color_pair[LINE_NUMBER]);
if (last_drawn_line != fileptr->lineno || last_line_y >= line) if (last_drawn_line != fileptr->lineno || last_line_y >= line)
mvwprintw(edit, line, 0, "%*i", margin - 1, fileptr->lineno); mvwprintw(edit, line, 0, "%*ld", margin - 1, (long)fileptr->lineno);
else else
mvwprintw(edit, line, 0, "%*s", margin - 1, " "); mvwprintw(edit, line, 0, "%*s", margin - 1, " ");
wattroff(edit, interface_color_pair[LINE_NUMBER]); wattroff(edit, interface_color_pair[LINE_NUMBER]);