diff --git a/src/proto.h b/src/proto.h
index a7f9b6066bf8c1c1a91f69daf81aad9beb582ac3..9ef4cfc3ab199a663f951fc56ea7f847445b8ead 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 7c61cebf7a17955537a80d304bed513f5d88ee10..06cf3ca5ffb4a16ac06fb51c6e51155306a29650 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 06bc5d2f997672d99acfda16dec68ec85990cdf8..0d3800739eed4ed9b44e148991490de4df43abf5 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]);