]> granicus.if.org Git - procps-ng/commitdiff
top: needed 'Ctrl' bottom window fixes were discovered <=== port of newlib da36ff2b
authorJim Warner <james.warner@comcast.net>
Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sun, 19 Jun 2022 10:58:51 +0000 (20:58 +1000)
______________________________ original newlib message

As it turns out, some of the 'environ' strings are big
enough to overrun the initial buffer sizes. And, while
no real harm was done (other than to silently truncate
the output), this patch will increase the buffer size.

While we're at it. we will normalize a few more buffer
declarations along with correcting a couple typos too.

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c
top/top.h

index 917c5a2939c97c4d5d0f2ccd866e03e5d3feafd8..cb573bf378b517c5b94597dc2275b34eaa5a93a1 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -5008,7 +5008,7 @@ static void forest_create (WIN_t *q) {
          * if we are in forest view mode otherwise he just returns them. | */
 static inline const char *forest_display (const WIN_t *q, int idx) {
 #ifndef SCROLLVAR_NO
-   static char buf[1024*64*2]; // the same as readproc's MAX_BUFSZ
+   static char buf[MAXBUFSIZ];
 #else
    static char buf[ROWMINSIZ];
 #endif
@@ -5105,12 +5105,12 @@ static void bot_do (const char *str, int focus) {
         /*
          * This guy draws that bottom window's header |
          * then parses/arranges to show the contents. |
-         * ( returns the number of elements printed ) | */
+         * ( returns relative # of elements printed ) | */
 static int bot_focus (const char *hdr, const char *str) {
  #define maxRSVD ( Screen_rows - 1 )
-   static char sav[BIGBUFSIZ*2];
+   static char sav[BOTBUFSIZ];
    const char *end, *beg;
-   char tmp[SCREENMAX];
+   char tmp[BIGBUFSIZ];
    int n, x;
 
    if (str) {
@@ -5307,7 +5307,7 @@ static void bot_pick_toggle (void) {
       Bot_sep = '\t';
       Bot_what = BOT_MENU_ON;
       Bot_indx = 0;
-      Bot_name = (char*)"a menu, please choose among the following ...";
+      Bot_name = (char*)"a menu, please choose among the following, then press <Enter> ...";
       Bot_func = bot_pick_show;
       Bot_task = Curwin->ppt[Curwin->begtask]->tid;
    }
index 86c942db7f921f911819af85219f555986204b3c..9466a31c1cad7614f2ee27ef3372e0e5b60dfb38 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -153,6 +153,9 @@ char *strcasestr(const char *haystack, const char *needle);
 #define LRGBUFSIZ   512
 #define OURPATHSZ  1024
 #define BIGBUFSIZ  2048
+#define BOTBUFSIZ 16384
+        // next is same as library's max buffer size
+#define MAXBUFSIZ (1024*64*2)
    /* in addition to the actual display data, our row might have to accommodate
       many termcap/color transitions - these definitions ensure we have room */
 #define ROWMINSIZ  ( SCREENMAX +  8 * (CAPBUFSIZ + CLRBUFSIZ) )