diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-25 12:48:46 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-25 12:48:46 +0200 |
commit | ffe03f04cb44f1ef606de4997c3032995b20518f (patch) | |
tree | bfe202c5d090b472d63144a323512f1e9eea6660 | |
parent | 42be921d486ee0fb43e982341cd54c41f15f55ee (diff) | |
download | busybox-w32-ffe03f04cb44f1ef606de4997c3032995b20518f.tar.gz busybox-w32-ffe03f04cb44f1ef606de4997c3032995b20518f.tar.bz2 busybox-w32-ffe03f04cb44f1ef606de4997c3032995b20518f.zip |
top: fix build failure in !USE_TERMIOS case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/top.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/procps/top.c b/procps/top.c index 00cb44896..dc5ea7360 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -153,10 +153,13 @@ struct globals { | |||
153 | #if ENABLE_FEATURE_TOP_SMP_CPU | 153 | #if ENABLE_FEATURE_TOP_SMP_CPU |
154 | smallint smp_cpu_info; /* one/many cpu info lines? */ | 154 | smallint smp_cpu_info; /* one/many cpu info lines? */ |
155 | #endif | 155 | #endif |
156 | unsigned lines; /* screen height */ | ||
156 | #if ENABLE_FEATURE_USE_TERMIOS | 157 | #if ENABLE_FEATURE_USE_TERMIOS |
157 | struct termios initial_settings; | 158 | struct termios initial_settings; |
158 | unsigned lines; /* screen height */ | ||
159 | int scroll_ofs; | 159 | int scroll_ofs; |
160 | #define G_scroll_ofs G.scroll_ofs | ||
161 | #else | ||
162 | #define G_scroll_ofs 0 | ||
160 | #endif | 163 | #endif |
161 | #if !ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 164 | #if !ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
162 | cmp_funcp sort_function[1]; | 165 | cmp_funcp sort_function[1]; |
@@ -661,9 +664,9 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
661 | 664 | ||
662 | /* Ok, all preliminary data is ready, go through the list */ | 665 | /* Ok, all preliminary data is ready, go through the list */ |
663 | scr_width += 2; /* account for leading '\n' and trailing NUL */ | 666 | scr_width += 2; /* account for leading '\n' and trailing NUL */ |
664 | if (lines_rem > ntop - G.scroll_ofs) | 667 | if (lines_rem > ntop - G_scroll_ofs) |
665 | lines_rem = ntop - G.scroll_ofs; | 668 | lines_rem = ntop - G_scroll_ofs; |
666 | s = top + G.scroll_ofs; | 669 | s = top + G_scroll_ofs; |
667 | while (--lines_rem >= 0) { | 670 | while (--lines_rem >= 0) { |
668 | unsigned col; | 671 | unsigned col; |
669 | CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift); | 672 | CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift); |
@@ -851,7 +854,7 @@ static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) | |||
851 | { | 854 | { |
852 | #define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK" | 855 | #define HDR_STR " PID VSZ VSZRW RSS (SHR) DIRTY (SHR) STACK" |
853 | #define MIN_WIDTH sizeof(HDR_STR) | 856 | #define MIN_WIDTH sizeof(HDR_STR) |
854 | const topmem_status_t *s = topmem + G.scroll_ofs; | 857 | const topmem_status_t *s = topmem + G_scroll_ofs; |
855 | 858 | ||
856 | display_topmem_header(scr_width, &lines_rem); | 859 | display_topmem_header(scr_width, &lines_rem); |
857 | strcpy(line_buf, HDR_STR " COMMAND"); | 860 | strcpy(line_buf, HDR_STR " COMMAND"); |
@@ -859,8 +862,8 @@ static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) | |||
859 | printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); | 862 | printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); |
860 | lines_rem--; | 863 | lines_rem--; |
861 | 864 | ||
862 | if (lines_rem > ntop - G.scroll_ofs) | 865 | if (lines_rem > ntop - G_scroll_ofs) |
863 | lines_rem = ntop - G.scroll_ofs; | 866 | lines_rem = ntop - G_scroll_ofs; |
864 | while (--lines_rem >= 0) { | 867 | while (--lines_rem >= 0) { |
865 | /* PID VSZ VSZRW RSS (SHR) DIRTY (SHR) COMMAND */ | 868 | /* PID VSZ VSZRW RSS (SHR) DIRTY (SHR) COMMAND */ |
866 | ulltoa6_and_space(s->pid , &line_buf[0*6]); | 869 | ulltoa6_and_space(s->pid , &line_buf[0*6]); |
@@ -936,32 +939,32 @@ static unsigned handle_input(unsigned scan_mask, unsigned interval) | |||
936 | return EXIT_MASK; | 939 | return EXIT_MASK; |
937 | 940 | ||
938 | if (c == KEYCODE_UP) { | 941 | if (c == KEYCODE_UP) { |
939 | G.scroll_ofs--; | 942 | G_scroll_ofs--; |
940 | goto normalize_ofs; | 943 | goto normalize_ofs; |
941 | } | 944 | } |
942 | if (c == KEYCODE_DOWN) { | 945 | if (c == KEYCODE_DOWN) { |
943 | G.scroll_ofs++; | 946 | G_scroll_ofs++; |
944 | goto normalize_ofs; | 947 | goto normalize_ofs; |
945 | } | 948 | } |
946 | if (c == KEYCODE_HOME) { | 949 | if (c == KEYCODE_HOME) { |
947 | G.scroll_ofs = 0; | 950 | G_scroll_ofs = 0; |
948 | break; | 951 | break; |
949 | } | 952 | } |
950 | if (c == KEYCODE_END) { | 953 | if (c == KEYCODE_END) { |
951 | G.scroll_ofs = ntop - G.lines / 2; | 954 | G_scroll_ofs = ntop - G.lines / 2; |
952 | goto normalize_ofs; | 955 | goto normalize_ofs; |
953 | } | 956 | } |
954 | if (c == KEYCODE_PAGEUP) { | 957 | if (c == KEYCODE_PAGEUP) { |
955 | G.scroll_ofs -= G.lines / 2; | 958 | G_scroll_ofs -= G.lines / 2; |
956 | goto normalize_ofs; | 959 | goto normalize_ofs; |
957 | } | 960 | } |
958 | if (c == KEYCODE_PAGEDOWN) { | 961 | if (c == KEYCODE_PAGEDOWN) { |
959 | G.scroll_ofs += G.lines / 2; | 962 | G_scroll_ofs += G.lines / 2; |
960 | normalize_ofs: | 963 | normalize_ofs: |
961 | if (G.scroll_ofs >= ntop) | 964 | if (G_scroll_ofs >= ntop) |
962 | G.scroll_ofs = ntop - 1; | 965 | G_scroll_ofs = ntop - 1; |
963 | if (G.scroll_ofs < 0) | 966 | if (G_scroll_ofs < 0) |
964 | G.scroll_ofs = 0; | 967 | G_scroll_ofs = 0; |
965 | break; | 968 | break; |
966 | } | 969 | } |
967 | 970 | ||