diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/more.c | 19 | ||||
-rw-r--r-- | util-linux/rev.c | 10 |
2 files changed, 26 insertions, 3 deletions
diff --git a/util-linux/more.c b/util-linux/more.c index 926cf5f26..fafc80403 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 | ||
@@ -95,9 +98,13 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
95 | * is not a tty and turns into cat. This makes sense. */ | 98 | * is not a tty and turns into cat. This makes sense. */ |
96 | if (!isatty(STDOUT_FILENO)) | 99 | if (!isatty(STDOUT_FILENO)) |
97 | return bb_cat(argv); | 100 | return bb_cat(argv); |
101 | #if !ENABLE_PLATFORM_MINGW32 | ||
98 | tty = fopen_for_read(CURRENT_TTY); | 102 | tty = fopen_for_read(CURRENT_TTY); |
99 | if (!tty) | 103 | if (!tty) |
100 | return bb_cat(argv); | 104 | return bb_cat(argv); |
105 | #else | ||
106 | tty = stdin; | ||
107 | #endif | ||
101 | 108 | ||
102 | G.tty_fileno = fileno(tty); | 109 | G.tty_fileno = fileno(tty); |
103 | 110 | ||
@@ -151,8 +158,12 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
151 | * to get input from the user. | 158 | * to get input from the user. |
152 | */ | 159 | */ |
153 | for (;;) { | 160 | for (;;) { |
161 | #if !ENABLE_PLATFORM_MINGW32 | ||
154 | fflush_all(); | 162 | fflush_all(); |
155 | input = getc(tty); | 163 | input = getc(tty); |
164 | #else | ||
165 | input = _getch(); | ||
166 | #endif | ||
156 | input = tolower(input); | 167 | input = tolower(input); |
157 | /* Erase the last message */ | 168 | /* Erase the last message */ |
158 | printf("\r%*s\r", len, ""); | 169 | printf("\r%*s\r", len, ""); |
@@ -166,6 +177,10 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
166 | * commands, else we show help msg. */ | 177 | * commands, else we show help msg. */ |
167 | if (input == ' ' || input == '\n' || input == 'r') | 178 | if (input == ' ' || input == '\n' || input == 'r') |
168 | break; | 179 | break; |
180 | #if ENABLE_PLATFORM_MINGW32 | ||
181 | if (input == '\r') | ||
182 | break; | ||
183 | #endif | ||
169 | len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); | 184 | len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); |
170 | } | 185 | } |
171 | len = 0; | 186 | len = 0; |
@@ -200,6 +215,10 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
200 | * will move us to a new line. */ | 215 | * will move us to a new line. */ |
201 | if (++lines >= G.terminal_height || input == '\n') | 216 | if (++lines >= G.terminal_height || input == '\n') |
202 | please_display_more_prompt = 1; | 217 | please_display_more_prompt = 1; |
218 | #if ENABLE_PLATFORM_MINGW32 | ||
219 | if (input == '\r') | ||
220 | please_display_more_prompt = 1; | ||
221 | #endif | ||
203 | len = 0; | 222 | len = 0; |
204 | } | 223 | } |
205 | if (c != '\n' && wrap) { | 224 | if (c != '\n' && wrap) { |
diff --git a/util-linux/rev.c b/util-linux/rev.c index 2bef9b9be..b0a0c01aa 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | /* In-place invert */ | 33 | /* In-place invert */ |
34 | static void strrev(CHAR_T *s, int len) | 34 | static void bb_strrev(CHAR_T *s, int len) |
35 | { | 35 | { |
36 | int i; | 36 | int i; |
37 | 37 | ||
@@ -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--) { |
@@ -99,14 +103,14 @@ int rev_main(int argc UNUSED_PARAM, char **argv) | |||
99 | /* Convert to wchar_t (might error out!) */ | 103 | /* Convert to wchar_t (might error out!) */ |
100 | int len = mbstowcs(tmp, buf, bufsize); | 104 | int len = mbstowcs(tmp, buf, bufsize); |
101 | if (len >= 0) { | 105 | if (len >= 0) { |
102 | strrev(tmp, len); | 106 | bb_strrev(tmp, len); |
103 | /* Convert back to char */ | 107 | /* Convert back to char */ |
104 | wcstombs(buf, tmp, bufsize); | 108 | wcstombs(buf, tmp, bufsize); |
105 | } | 109 | } |
106 | free(tmp); | 110 | free(tmp); |
107 | } | 111 | } |
108 | #else | 112 | #else |
109 | strrev(buf, strlen(buf)); | 113 | bb_strrev(buf, strlen(buf)); |
110 | #endif | 114 | #endif |
111 | fputs(buf, stdout); | 115 | fputs(buf, stdout); |
112 | } | 116 | } |