From: Sami Kerola Date: Sun, 9 Mar 2014 17:02:52 +0000 (-0500) Subject: kill: move magic numbers in beginning of the file X-Git-Tag: v2.25-rc1~329^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e1bffa886cb72c561f8fb14399042dafd45d1f7;p=thirdparty%2Futil-linux.git kill: move magic numbers in beginning of the file Signed-off-by: Sami Kerola --- diff --git a/misc-utils/kill.c b/misc-utils/kill.c index 877c24e17d..b95e03d416 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -57,6 +57,11 @@ #include "ttyutils.h" #include "xalloc.h" +enum { + KILL_FIELD_WIDTH = 11, + KILL_OUTPUT_WIDTH = 72 +}; + struct signv { const char *name; int val; @@ -388,15 +393,14 @@ static void printsig(int sig) printf("%d\n", sig); } -#define FIELD_WIDTH 11 static void pretty_print_signal(FILE *fp, size_t term_width, size_t *lpos, int signum, const char *name) { - if (term_width < (*lpos + FIELD_WIDTH)) { + if (term_width < (*lpos + KILL_FIELD_WIDTH)) { fputc('\n', fp); *lpos = 0; } - *lpos += FIELD_WIDTH; + *lpos += KILL_FIELD_WIDTH; fprintf(fp, "%2d %-8s", signum, name); } @@ -407,7 +411,7 @@ static void printsignals(FILE *fp, int pretty) if (!pretty) { for (n = 0; n < ARRAY_SIZE(sys_signame); n++) { lth = 1 + strlen(sys_signame[n].name); - if (72 < lpos + lth) { + if (KILL_OUTPUT_WIDTH < lpos + lth) { fputc('\n', fp); lpos = 0; } else if (lpos) @@ -424,7 +428,7 @@ static void printsignals(FILE *fp, int pretty) /* pretty print */ width = get_terminal_width(); if (width == 0) - width = 72; + width = KILL_OUTPUT_WIDTH; else width -= 1; for (n = 0; n < ARRAY_SIZE(sys_signame); n++)