]> granicus.if.org Git - procps-ng/commitdiff
remove trailing spaces in top batch mode
authorJim Warner <james.warner@comcast.net>
Wed, 1 Jun 2011 11:58:06 +0000 (13:58 +0200)
committerJan Görig <jgorig@redhat.com>
Wed, 1 Jun 2011 11:58:06 +0000 (13:58 +0200)
Signed-off-by: Jan Görig <jgorig@redhat.com>
top.h

diff --git a/top.h b/top.h
index f978178191710d23c1dbb943a98355dcf2437569..308b863fbe1be0847551c6db36a8f9247dda1fdf 100644 (file)
--- a/top.h
+++ b/top.h
@@ -401,9 +401,10 @@ typedef struct WIN_t {
                . assumed to represent a complete screen ROW
                . subject to optimization, thus MAY be discarded */
 #define PUFF(fmt,arg...) do { \
-      char _str[ROWMAXSIZ]; \
-      snprintf(_str, sizeof(_str), fmt, ## arg); \
-      if (Batch) putp(_str); \
+      char _str[ROWMAXSIZ], *_eol; \
+      _eol = _str + snprintf(_str, sizeof(_str), fmt, ## arg); \
+      if (Batch) { \
+         while (*(--_eol) == ' '); *(++_eol) = '\0'; putp(_str); } \
       else { \
          char *_ptr = &Pseudo_screen[Pseudo_row * ROWMAXSIZ]; \
          if (Pseudo_row + 1 < Screen_rows) ++Pseudo_row; \