less: make -E work
authorAaro Koskinen <aaro.koskinen@iki.fi>
Tue, 23 Sep 2014 20:58:18 +0000 (22:58 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 23 Sep 2014 20:58:18 +0000 (22:58 +0200)
function                                             old     new   delta
buffer_print                                          71     104     +33

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/less.c

index c5820d325506ce0e9f17c01a3aa66800df82ec87..554e546875847f1b5a47c9e3c5cdffafeb90511b 100644 (file)
@@ -802,11 +802,18 @@ static void buffer_print(void)
        unsigned i;
 
        move_cursor(0, 0);
-       for (i = 0; i <= max_displayed_line; i++)
+       for (i = 0; i <= max_displayed_line; i++) {
                if (pattern_valid)
                        print_found(buffer[i]);
                else
                        print_ascii(buffer[i]);
+       }
+       if ((option_mask32 & FLAG_E)
+        && eof_error <= 0
+        && (max_fline - cur_fline) <= max_displayed_line
+       ) {
+               less_exit(EXIT_SUCCESS);
+       }
        status_print();
 }