From 0caa6d6e676c8d28b933066d19c112b02ed59245 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 7 May 2014 00:00:00 -0500
Subject: [PATCH] top: miscellaneous accumulated changes to program code

. prevent any input recall overrun if window downsized
. adjust translation notes for true column hdr maximum

Signed-off-by: Jim Warner <james.warner@comcast.net>
---
 top/top.c     |    5 ++---
 top/top_nls.c |   28 ++++++++++++++--------------
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git top/top.c top/top.c
index 9f33a05..bc755f3 100644
--- top/top.c
+++ top/top.c
@@ -1183,13 +1183,13 @@ static char *ioline (const char *prompt) {
             if (plin->bkw) {
                plin = plin->bkw;
                memset(buf, '\0', sizeof(buf));
-               pos = snprintf(buf, sizeof(buf), "%s", plin->str);
+               pos = snprintf(buf, sizeof(buf), "%.*s", Screen_cols - beg - 1, plin->str);
             }
             break;
          case kbd_DOWN:
             memset(buf, '\0', sizeof(buf));
             if (plin->fwd) plin = plin->fwd;
-            pos = snprintf(buf, sizeof(buf), "%s", plin->str);
+            pos = snprintf(buf, sizeof(buf), "%.*s", Screen_cols - beg - 1, plin->str);
             break;
          default:                      // what we REALLY wanted (maybe)
             if (isprint(key) && logCOL < bufMAX && phyCOL < Screen_cols) {
@@ -4624,7 +4624,6 @@ static void keys_task (int ch) {
             if (*str != kbd_ESC
             && (errmsg = user_certify(w, str, ch)))
                 show_msg(errmsg);
-
          }
          break;
       case 'V':
diff --git top/top_nls.c top/top_nls.c
index 01c8d1e..ea1c088 100644
--- top/top_nls.c
+++ top/top_nls.c
@@ -129,31 +129,31 @@ static void build_two_nlstabs (void) {
 /* Translation Hint: maximum 'UID' = 5 */
    Head_nlstab[EU_UED] = _("UID");
    Desc_nlstab[EU_UED] = _("Effective User Id");
-/* Translation Hint: maximum 'USER' = 8 */
+/* Translation Hint: maximum 'USER' = 7 */
    Head_nlstab[EU_UEN] = _("USER");
    Desc_nlstab[EU_UEN] = _("Effective User Name");
 /* Translation Hint: maximum 'RUID' = 5 */
    Head_nlstab[EU_URD] = _("RUID");
    Desc_nlstab[EU_URD] = _("Real User Id");
-/* Translation Hint: maximum 'RUSER' = 8 */
+/* Translation Hint: maximum 'RUSER' = 7 */
    Head_nlstab[EU_URN] = _("RUSER");
    Desc_nlstab[EU_URN] = _("Real User Name");
 /* Translation Hint: maximum 'SUID' = 5 */
    Head_nlstab[EU_USD] = _("SUID");
    Desc_nlstab[EU_USD] = _("Saved User Id");
-/* Translation Hint: maximum 'SUSER' = 8 */
+/* Translation Hint: maximum 'SUSER' = 7 */
    Head_nlstab[EU_USN] = _("SUSER");
    Desc_nlstab[EU_USN] = _("Saved User Name");
 /* Translation Hint: maximum 'GID' = 5 */
    Head_nlstab[EU_GID] = _("GID");
    Desc_nlstab[EU_GID] = _("Group Id");
-/* Translation Hint: maximum 'GROUP' = 8 */
+/* Translation Hint: maximum 'GROUP' = 7 */
    Head_nlstab[EU_GRP] = _("GROUP");
    Desc_nlstab[EU_GRP] = _("Group Name");
 /* Translation Hint: maximum 'PGRP' = 5 */
    Head_nlstab[EU_PGD] = _("PGRP");
    Desc_nlstab[EU_PGD] = _("Process Group Id");
-/* Translation Hint: maximum 'TTY' = 8 */
+/* Translation Hint: maximum 'TTY' = 7 */
    Head_nlstab[EU_TTY] = _("TTY");
    Desc_nlstab[EU_TTY] = _("Controlling Tty");
 /* Translation Hint: maximum 'TPGID' = 5 */
@@ -180,7 +180,7 @@ static void build_two_nlstabs (void) {
 /* Translation Hint: maximum '' = 6 */
    Head_nlstab[EU_TME] = _("TIME");
    Desc_nlstab[EU_TME] = _("CPU Time");
-/* Translation Hint: maximum 'TIME+' = 9 */
+/* Translation Hint: maximum 'TIME+' = 7 */
    Head_nlstab[EU_TM2] = _("TIME+");
    Desc_nlstab[EU_TM2] = _("CPU Time, hundredths");
 /* Translation Hint: maximum '%MEM' = 4 */
@@ -222,7 +222,7 @@ static void build_two_nlstabs (void) {
 /* Translation Hint: maximum 'WCHAN' = 7 */
    Head_nlstab[EU_WCH] = _("WCHAN");
    Desc_nlstab[EU_WCH] = _("Sleeping in Function");
-/* Translation Hint: maximum 'Flags' = 8 */
+/* Translation Hint: maximum 'Flags' = 7 */
    Head_nlstab[EU_FLG] = _("Flags");
    Desc_nlstab[EU_FLG] = _("Task Flags <sched.h>");
 /* Translation Hint: maximum 'CGROUPS' = 7 */
@@ -241,7 +241,7 @@ static void build_two_nlstabs (void) {
 /* Translation Hint: maximum 'Adj' = 3 */
    Head_nlstab[EU_OOA] = _("Adj");
    Desc_nlstab[EU_OOA] = _("oom_adjustment (2^X)");
-/* Translation Hint: maximum 'Badness' = 8 */
+/* Translation Hint: maximum 'Badness' = 7 */
    Head_nlstab[EU_OOM] = _("Badness");
    Desc_nlstab[EU_OOM] = _("oom_score (badness)");
 #endif
@@ -259,22 +259,22 @@ static void build_two_nlstabs (void) {
 /* Translation Hint: maximum 'USED' = 4 */
    Head_nlstab[EU_USE] = _("USED");
    Desc_nlstab[EU_USE] = _("Res+Swap Size (KiB)");
-/* Translation Hint: maximum 'nsIPC' = 10 */
+/* Translation Hint: maximum 'nsIPC' = 7 */
    Head_nlstab[EU_NS1] = _("nsIPC");
    Desc_nlstab[EU_NS1] = _("IPC namespace Inode");
-/* Translation Hint: maximum 'nsMNT' = 10 */
+/* Translation Hint: maximum 'nsMNT' = 7 */
    Head_nlstab[EU_NS2] = _("nsMNT");
    Desc_nlstab[EU_NS2] = _("MNT namespace Inode");
-/* Translation Hint: maximum 'nsNET' = 10 */
+/* Translation Hint: maximum 'nsNET' = 7 */
    Head_nlstab[EU_NS3] = _("nsNET");
    Desc_nlstab[EU_NS3] = _("NET namespace Inode");
-/* Translation Hint: maximum 'nsPID' = 10 */
+/* Translation Hint: maximum 'nsPID' = 7 */
    Head_nlstab[EU_NS4] = _("nsPID");
    Desc_nlstab[EU_NS4] = _("PID namespace Inode");
-/* Translation Hint: maximum 'nsUSER' = 10 */
+/* Translation Hint: maximum 'nsUSER' = 7 */
    Head_nlstab[EU_NS5] = _("nsUSER");
    Desc_nlstab[EU_NS5] = _("USER namespace Inode");
-/* Translation Hint: maximum 'nsUTS' = 10 */
+/* Translation Hint: maximum 'nsUTS' = 7 */
    Head_nlstab[EU_NS6] = _("nsUTS");
    Desc_nlstab[EU_NS6] = _("UTS namespace Inode");
 }
-- 
1.7.9.2

