From bd920b1f4964709f0e0800babb167e5d9a5a82e2 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey <pooka109@gmail.com> Date: Fri, 9 Dec 2016 11:36:01 -0600 Subject: [PATCH] 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. --- src/proto.h | 4 +++- src/utils.c | 2 +- src/winio.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/proto.h b/src/proto.h index a7f9b606..9ef4cfc3 100644 --- a/src/proto.h +++ b/src/proto.h @@ -651,7 +651,9 @@ void complete_a_word(void); /* All functions in utils.c. */ 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_line_column(const char *str, ssize_t *line, ssize_t *column); void align(char **str); diff --git a/src/utils.c b/src/utils.c index 7c61cebf..06cf3ca5 100644 --- a/src/utils.c +++ b/src/utils.c @@ -54,7 +54,7 @@ void get_homedir(void) #ifdef ENABLE_LINENUMBERS /* 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 < 1000) { diff --git a/src/winio.c b/src/winio.c index 06bc5d2f..0d380073 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2323,7 +2323,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int if (margin > 0) { wattron(edit, interface_color_pair[LINE_NUMBER]); 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 mvwprintw(edit, line, 0, "%*s", margin - 1, " "); wattroff(edit, interface_color_pair[LINE_NUMBER]); -- GitLab