diff options
-rw-r--r-- | miscutils/less.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index 4cdfa3b..8fd0874 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -609,33 +609,15 @@ static int safe_lineno(int fline) return LINENO(flines[fline]) + 1; } -/* Print a status line if -M was specified */ -static void m_status_print(void) +/* count number of lines in file */ +static void update_num_lines(void) { - int first, last; - unsigned percent; - - if (less_gets_pos >= 0) /* don't touch statusline while input is done! */ - return; - - clear_line(); - printf(HIGHLIGHT"%s", filename); - if (num_files > 1) - printf(" (file %i of %i)", current_file, num_files); - - first = safe_lineno(cur_fline); - last = (option_mask32 & FLAG_S) - ? MIN(first + max_displayed_line, max_lineno) - : safe_lineno(cur_fline + max_displayed_line); - printf(" lines %i-%i", first, last); + int count, fd; + ssize_t len, i; + char buf[4096]; + struct stat stbuf; if (num_lines == READING_FILE) { - int count, fd; - ssize_t len, i; - char buf[4096]; - struct stat stbuf; - - /* count number of lines in file */ count = 0; fd = open(filename, O_RDONLY); if (fd < 0) @@ -654,7 +636,29 @@ static void m_status_print(void) close(fd); skip: ; } +} + +/* Print a status line if -M was specified */ +static void m_status_print(void) +{ + int first, last; + unsigned percent; + + if (less_gets_pos >= 0) /* don't touch statusline while input is done! */ + return; + + clear_line(); + printf(HIGHLIGHT"%s", filename); + if (num_files > 1) + printf(" (file %i of %i)", current_file, num_files); + + first = safe_lineno(cur_fline); + last = (option_mask32 & FLAG_S) + ? MIN(first + max_displayed_line, max_lineno) + : safe_lineno(cur_fline + max_displayed_line); + printf(" lines %i-%i", first, last); + update_num_lines(); if (num_lines >= 0) printf("/%i", num_lines); |