diff options
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/less.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index 9c75ae7ac..6b5c8c2dd 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
| @@ -121,11 +121,12 @@ | |||
| 121 | //kbuild:lib-$(CONFIG_LESS) += less.o | 121 | //kbuild:lib-$(CONFIG_LESS) += less.o |
| 122 | 122 | ||
| 123 | //usage:#define less_trivial_usage | 123 | //usage:#define less_trivial_usage |
| 124 | //usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") | 124 | //usage: "[-EF" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") |
| 125 | //usage: "N" IF_FEATURE_LESS_TRUNCATE("S") IF_FEATURE_LESS_RAW("R") "h~] [FILE]..." | 125 | //usage: "N" IF_FEATURE_LESS_TRUNCATE("S") IF_FEATURE_LESS_RAW("R") "h~] [FILE]..." |
| 126 | //usage:#define less_full_usage "\n\n" | 126 | //usage:#define less_full_usage "\n\n" |
| 127 | //usage: "View FILE (or stdin) one screenful at a time\n" | 127 | //usage: "View FILE (or stdin) one screenful at a time\n" |
| 128 | //usage: "\n -E Quit once the end of a file is reached" | 128 | //usage: "\n -E Quit once the end of a file is reached" |
| 129 | //usage: "\n -F Quit if entire file fits on first screen" | ||
| 129 | //usage: IF_FEATURE_LESS_REGEXP( | 130 | //usage: IF_FEATURE_LESS_REGEXP( |
| 130 | //usage: "\n -I Ignore case in all searches" | 131 | //usage: "\n -I Ignore case in all searches" |
| 131 | //usage: ) | 132 | //usage: ) |
| @@ -179,8 +180,9 @@ enum { | |||
| 179 | FLAG_N = 1 << 3, | 180 | FLAG_N = 1 << 3, |
| 180 | FLAG_TILDE = 1 << 4, | 181 | FLAG_TILDE = 1 << 4, |
| 181 | FLAG_I = 1 << 5, | 182 | FLAG_I = 1 << 5, |
| 182 | FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_TRUNCATE, | 183 | FLAG_F = 1 << 6, |
| 183 | FLAG_R = (1 << 7) * ENABLE_FEATURE_LESS_RAW, | 184 | FLAG_S = (1 << 7) * ENABLE_FEATURE_LESS_TRUNCATE, |
| 185 | FLAG_R = (1 << 8) * ENABLE_FEATURE_LESS_RAW, | ||
| 184 | /* hijack command line options variable for internal state vars */ | 186 | /* hijack command line options variable for internal state vars */ |
| 185 | LESS_STATE_MATCH_BACKWARDS = 1 << 15, | 187 | LESS_STATE_MATCH_BACKWARDS = 1 << 15, |
| 186 | }; | 188 | }; |
| @@ -938,11 +940,12 @@ static void buffer_print(void) | |||
| 938 | else | 940 | else |
| 939 | print_ascii(buffer[i]); | 941 | print_ascii(buffer[i]); |
| 940 | } | 942 | } |
| 941 | if ((option_mask32 & FLAG_E) | 943 | if ((option_mask32 & (FLAG_E|FLAG_F)) |
| 942 | && eof_error <= 0 | 944 | && eof_error <= 0 |
| 943 | && (max_fline - cur_fline) <= max_displayed_line | ||
| 944 | ) { | 945 | ) { |
| 945 | less_exit(EXIT_SUCCESS); | 946 | i = option_mask32 & FLAG_F ? 0 : cur_fline; |
| 947 | if (max_fline - i <= max_displayed_line) | ||
| 948 | less_exit(EXIT_SUCCESS); | ||
| 946 | } | 949 | } |
| 947 | status_print(); | 950 | status_print(); |
| 948 | } | 951 | } |
| @@ -1894,7 +1897,7 @@ int less_main(int argc, char **argv) | |||
| 1894 | * -s: condense many empty lines to one | 1897 | * -s: condense many empty lines to one |
| 1895 | * (used by some setups for manpage display) | 1898 | * (used by some setups for manpage display) |
| 1896 | */ | 1899 | */ |
| 1897 | getopt32(argv, "EMmN~I" | 1900 | getopt32(argv, "EMmN~IF" |
| 1898 | IF_FEATURE_LESS_TRUNCATE("S") | 1901 | IF_FEATURE_LESS_TRUNCATE("S") |
| 1899 | IF_FEATURE_LESS_RAW("R") | 1902 | IF_FEATURE_LESS_RAW("R") |
| 1900 | /*ignored:*/"s" | 1903 | /*ignored:*/"s" |
| @@ -1908,6 +1911,9 @@ int less_main(int argc, char **argv) | |||
| 1908 | if (ENABLE_FEATURE_LESS_ENV) { | 1911 | if (ENABLE_FEATURE_LESS_ENV) { |
| 1909 | char *c = getenv("LESS"); | 1912 | char *c = getenv("LESS"); |
| 1910 | if (c) while (*c) switch (*c++) { | 1913 | if (c) while (*c) switch (*c++) { |
| 1914 | case 'F': | ||
| 1915 | option_mask32 |= FLAG_F; | ||
| 1916 | break; | ||
| 1911 | case 'M': | 1917 | case 'M': |
| 1912 | option_mask32 |= FLAG_M; | 1918 | option_mask32 |= FLAG_M; |
| 1913 | break; | 1919 | break; |
| @@ -1930,7 +1936,6 @@ int less_main(int argc, char **argv) | |||
| 1930 | if (!num_files) { | 1936 | if (!num_files) { |
| 1931 | if (isatty(STDIN_FILENO)) { | 1937 | if (isatty(STDIN_FILENO)) { |
| 1932 | /* Just "less"? No args and no redirection? */ | 1938 | /* Just "less"? No args and no redirection? */ |
| 1933 | bb_error_msg("missing filename"); | ||
| 1934 | bb_show_usage(); | 1939 | bb_show_usage(); |
| 1935 | } | 1940 | } |
| 1936 | } else { | 1941 | } else { |
| @@ -1971,7 +1976,7 @@ int less_main(int argc, char **argv) | |||
| 1971 | #endif | 1976 | #endif |
| 1972 | 1977 | ||
| 1973 | #if !ENABLE_PLATFORM_MINGW32 | 1978 | #if !ENABLE_PLATFORM_MINGW32 |
| 1974 | get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL); | 1979 | get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL_INPUT); |
| 1975 | #endif | 1980 | #endif |
| 1976 | 1981 | ||
| 1977 | IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line); | 1982 | IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line); |
