diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/getopt.c | 5 | ||||
-rw-r--r-- | util-linux/more.c | 22 | ||||
-rw-r--r-- | util-linux/rev.c | 4 |
3 files changed, 31 insertions, 0 deletions
diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 213bfab0b..e61d68982 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c | |||
@@ -412,6 +412,11 @@ int getopt_main(int argc, char **argv) | |||
412 | bb_simple_error_msg_and_die("missing optstring argument"); | 412 | bb_simple_error_msg_and_die("missing optstring argument"); |
413 | } | 413 | } |
414 | 414 | ||
415 | #if ENABLE_PLATFORM_MINGW32 | ||
416 | // Mingw-w64 getopt(3) uses __argv[0] in error messages, not the | ||
417 | // first element of its argument array. | ||
418 | __argv[0] = | ||
419 | #endif | ||
415 | argv[n] = name ? name : argv[0]; | 420 | argv[n] = name ? name : argv[0]; |
416 | return generate_output(argv + n, argc - n, optstr, long_options); | 421 | return generate_output(argv + n, argc - n, optstr, long_options); |
417 | } | 422 | } |
diff --git a/util-linux/more.c b/util-linux/more.c index bffe6ee5e..0be8e0b9b 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -35,6 +35,9 @@ | |||
35 | //usage:#define more_example_usage | 35 | //usage:#define more_example_usage |
36 | //usage: "$ dmesg | more\n" | 36 | //usage: "$ dmesg | more\n" |
37 | 37 | ||
38 | #if ENABLE_PLATFORM_MINGW32 | ||
39 | #include <conio.h> | ||
40 | #endif | ||
38 | #include "libbb.h" | 41 | #include "libbb.h" |
39 | #include "common_bufsiz.h" | 42 | #include "common_bufsiz.h" |
40 | 43 | ||
@@ -59,6 +62,7 @@ static void tcsetattr_tty_TCSANOW(struct termios *settings) | |||
59 | tcsetattr(G.tty_fileno, TCSANOW, settings); | 62 | tcsetattr(G.tty_fileno, TCSANOW, settings); |
60 | } | 63 | } |
61 | 64 | ||
65 | #if !ENABLE_PLATFORM_MINGW32 | ||
62 | static void gotsig(int sig UNUSED_PARAM) | 66 | static void gotsig(int sig UNUSED_PARAM) |
63 | { | 67 | { |
64 | /* bb_putchar_stderr doesn't use stdio buffering, | 68 | /* bb_putchar_stderr doesn't use stdio buffering, |
@@ -67,6 +71,7 @@ static void gotsig(int sig UNUSED_PARAM) | |||
67 | tcsetattr_tty_TCSANOW(&G.initial_settings); | 71 | tcsetattr_tty_TCSANOW(&G.initial_settings); |
68 | _exit_FAILURE(); | 72 | _exit_FAILURE(); |
69 | } | 73 | } |
74 | #endif | ||
70 | 75 | ||
71 | #define CONVERTED_TAB_SIZE 8 | 76 | #define CONVERTED_TAB_SIZE 8 |
72 | 77 | ||
@@ -96,9 +101,13 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
96 | * is not a tty and turns into cat. This makes sense. */ | 101 | * is not a tty and turns into cat. This makes sense. */ |
97 | if (!isatty(STDOUT_FILENO)) | 102 | if (!isatty(STDOUT_FILENO)) |
98 | return bb_cat(argv); | 103 | return bb_cat(argv); |
104 | #if !ENABLE_PLATFORM_MINGW32 | ||
99 | tty = fopen_for_read(CURRENT_TTY); | 105 | tty = fopen_for_read(CURRENT_TTY); |
100 | if (!tty) | 106 | if (!tty) |
101 | return bb_cat(argv); | 107 | return bb_cat(argv); |
108 | #else | ||
109 | tty = stdin; | ||
110 | #endif | ||
102 | 111 | ||
103 | G.tty_fileno = fileno(tty); | 112 | G.tty_fileno = fileno(tty); |
104 | 113 | ||
@@ -153,6 +162,11 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
153 | */ | 162 | */ |
154 | for (;;) { | 163 | for (;;) { |
155 | fflush_all(); | 164 | fflush_all(); |
165 | #if ENABLE_PLATFORM_MINGW32 | ||
166 | if (!(terminal_mode(FALSE) & VT_INPUT)) | ||
167 | input = _getch(); | ||
168 | else | ||
169 | #endif | ||
156 | input = getc(tty); | 170 | input = getc(tty); |
157 | input = tolower(input); | 171 | input = tolower(input); |
158 | /* Erase the last message */ | 172 | /* Erase the last message */ |
@@ -167,6 +181,10 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
167 | * commands, else we show help msg. */ | 181 | * commands, else we show help msg. */ |
168 | if (input == ' ' || input == '\n' || input == 'r') | 182 | if (input == ' ' || input == '\n' || input == 'r') |
169 | break; | 183 | break; |
184 | #if ENABLE_PLATFORM_MINGW32 | ||
185 | if (input == '\r') | ||
186 | break; | ||
187 | #endif | ||
170 | len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); | 188 | len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); |
171 | } | 189 | } |
172 | len = 0; | 190 | len = 0; |
@@ -201,6 +219,10 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
201 | * will move us to a new line. */ | 219 | * will move us to a new line. */ |
202 | if (++lines >= G.terminal_height || input == '\n') | 220 | if (++lines >= G.terminal_height || input == '\n') |
203 | please_display_more_prompt = 1; | 221 | please_display_more_prompt = 1; |
222 | #if ENABLE_PLATFORM_MINGW32 | ||
223 | if (input == '\r') | ||
224 | please_display_more_prompt = 1; | ||
225 | #endif | ||
204 | len = 0; | 226 | len = 0; |
205 | } | 227 | } |
206 | if (c != '\n' && wrap) { | 228 | if (c != '\n' && wrap) { |
diff --git a/util-linux/rev.c b/util-linux/rev.c index aad53722d..9a4b887e4 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c | |||
@@ -39,6 +39,10 @@ static void strrev(CHAR_T *s, int len) | |||
39 | len--; | 39 | len--; |
40 | if (len != 0 && s[len] == '\n') | 40 | if (len != 0 && s[len] == '\n') |
41 | len--; | 41 | len--; |
42 | #if ENABLE_PLATFORM_MINGW32 | ||
43 | if (len != 0 && s[len] == '\r') | ||
44 | len--; | ||
45 | #endif | ||
42 | } | 46 | } |
43 | 47 | ||
44 | for (i = 0; i < len; i++, len--) { | 48 | for (i = 0; i < len; i++, len--) { |