aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-01 20:07:29 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-01 20:07:29 +0000
commitdcf4de20a1904bb31d498b6cc999a37f20b2783d (patch)
tree9c4c939bb250f37bd4f405b74723824cde1e8d7b
parentf20de5bb42f9a4f2c8417f6a1a2db7e2f2cafd5b (diff)
downloadbusybox-w32-dcf4de20a1904bb31d498b6cc999a37f20b2783d.tar.gz
busybox-w32-dcf4de20a1904bb31d498b6cc999a37f20b2783d.tar.bz2
busybox-w32-dcf4de20a1904bb31d498b6cc999a37f20b2783d.zip
test: code size saving, no logic changes
ps: fix warning, make a bit smaller kill -l: make smaller & know much more signals function old new delta get_signum 121 153 +32 kill_main 826 843 +17 get_signame 44 36 -8 signals 252 224 -28 .rodata 131955 131923 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/3 up/down: 49/-68) Total: -19 bytes
-rw-r--r--coreutils/test.c177
-rw-r--r--libbb/u_signal_names.c148
-rw-r--r--procps/kill.c4
-rw-r--r--procps/ps.c15
4 files changed, 228 insertions, 116 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index e9b627638..70b392f38 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -85,12 +85,12 @@ enum token {
85 RPAREN, 85 RPAREN,
86 OPERAND 86 OPERAND
87}; 87};
88#define __is_int_op(a) (((unsigned char)((a) - INTEQ)) <= 5) 88#define is_int_op(a) (((unsigned char)((a) - INTEQ)) <= 5)
89#define __is_str_op(a) (((unsigned char)((a) - STREZ)) <= 5) 89#define is_str_op(a) (((unsigned char)((a) - STREZ)) <= 5)
90#define __is_file_op(a) (((unsigned char)((a) - FILNT)) <= 2) 90#define is_file_op(a) (((unsigned char)((a) - FILNT)) <= 2)
91#define __is_file_access(a) (((unsigned char)((a) - FILRD)) <= 2) 91#define is_file_access(a) (((unsigned char)((a) - FILRD)) <= 2)
92#define __is_file_type(a) (((unsigned char)((a) - FILREG)) <= 5) 92#define is_file_type(a) (((unsigned char)((a) - FILREG)) <= 5)
93#define __is_file_bit(a) (((unsigned char)((a) - FILSUID)) <= 2) 93#define is_file_bit(a) (((unsigned char)((a) - FILSUID)) <= 2)
94enum token_types { 94enum token_types {
95 UNOP, 95 UNOP,
96 BINOP, 96 BINOP,
@@ -100,64 +100,67 @@ enum token_types {
100}; 100};
101 101
102static const struct t_op { 102static const struct t_op {
103 const char * const op_text; 103 char op_text[4];
104 unsigned char op_num, op_type; 104 unsigned char op_num, op_type;
105} ops[] = { 105} ops[] = {
106 { 106 { "-r", FILRD , UNOP },
107 "-r", FILRD, UNOP}, { 107 { "-w", FILWR , UNOP },
108 "-w", FILWR, UNOP}, { 108 { "-x", FILEX , UNOP },
109 "-x", FILEX, UNOP}, { 109 { "-e", FILEXIST, UNOP },
110 "-e", FILEXIST, UNOP}, { 110 { "-f", FILREG , UNOP },
111 "-f", FILREG, UNOP}, { 111 { "-d", FILDIR , UNOP },
112 "-d", FILDIR, UNOP}, { 112 { "-c", FILCDEV , UNOP },
113 "-c", FILCDEV, UNOP}, { 113 { "-b", FILBDEV , UNOP },
114 "-b", FILBDEV, UNOP}, { 114 { "-p", FILFIFO , UNOP },
115 "-p", FILFIFO, UNOP}, { 115 { "-u", FILSUID , UNOP },
116 "-u", FILSUID, UNOP}, { 116 { "-g", FILSGID , UNOP },
117 "-g", FILSGID, UNOP}, { 117 { "-k", FILSTCK , UNOP },
118 "-k", FILSTCK, UNOP}, { 118 { "-s", FILGZ , UNOP },
119 "-s", FILGZ, UNOP}, { 119 { "-t", FILTT , UNOP },
120 "-t", FILTT, UNOP}, { 120 { "-z", STREZ , UNOP },
121 "-z", STREZ, UNOP}, { 121 { "-n", STRNZ , UNOP },
122 "-n", STRNZ, UNOP}, { 122 { "-h", FILSYM , UNOP }, /* for backwards compat */
123 "-h", FILSYM, UNOP}, /* for backwards compat */ 123
124 { 124 { "-O" , FILUID , UNOP },
125 "-O", FILUID, UNOP}, { 125 { "-G" , FILGID , UNOP },
126 "-G", FILGID, UNOP}, { 126 { "-L" , FILSYM , UNOP },
127 "-L", FILSYM, UNOP}, { 127 { "-S" , FILSOCK, UNOP },
128 "-S", FILSOCK, UNOP}, { 128 { "=" , STREQ , BINOP },
129 "=", STREQ, BINOP}, { 129 { "==" , STREQ , BINOP },
130 "==", STREQ, BINOP}, { 130 { "!=" , STRNE , BINOP },
131 "!=", STRNE, BINOP}, { 131 { "<" , STRLT , BINOP },
132 "<", STRLT, BINOP}, { 132 { ">" , STRGT , BINOP },
133 ">", STRGT, BINOP}, { 133 { "-eq", INTEQ , BINOP },
134 "-eq", INTEQ, BINOP}, { 134 { "-ne", INTNE , BINOP },
135 "-ne", INTNE, BINOP}, { 135 { "-ge", INTGE , BINOP },
136 "-ge", INTGE, BINOP}, { 136 { "-gt", INTGT , BINOP },
137 "-gt", INTGT, BINOP}, { 137 { "-le", INTLE , BINOP },
138 "-le", INTLE, BINOP}, { 138 { "-lt", INTLT , BINOP },
139 "-lt", INTLT, BINOP}, { 139 { "-nt", FILNT , BINOP },
140 "-nt", FILNT, BINOP}, { 140 { "-ot", FILOT , BINOP },
141 "-ot", FILOT, BINOP}, { 141 { "-ef", FILEQ , BINOP },
142 "-ef", FILEQ, BINOP}, { 142 { "!" , UNOT , BUNOP },
143 "!", UNOT, BUNOP}, { 143 { "-a" , BAND , BBINOP },
144 "-a", BAND, BBINOP}, { 144 { "-o" , BOR , BBINOP },
145 "-o", BOR, BBINOP}, { 145 { "(" , LPAREN , PAREN },
146 "(", LPAREN, PAREN}, { 146 { ")" , RPAREN , PAREN },
147 ")", RPAREN, PAREN}, {
148 0, 0, 0}
149}; 147};
150 148
151#ifdef CONFIG_FEATURE_TEST_64 149enum { NUM_OPS = sizeof(ops) / sizeof(ops[0]) };
150
151#if ENABLE_FEATURE_TEST_64
152typedef int64_t arith_t; 152typedef int64_t arith_t;
153#else 153#else
154typedef int arith_t; 154typedef int arith_t;
155#endif 155#endif
156 156
157/* Cannot eliminate these static data (do the G trick)
158 * because of bb_test usage from other applets */
157static char **t_wp; 159static char **t_wp;
158static struct t_op const *t_wp_op; 160static struct t_op const *t_wp_op;
159static gid_t *group_array; 161static gid_t *group_array;
160static int ngroups; 162static int ngroups;
163static jmp_buf leaving;
161 164
162static enum token t_lex(char *s); 165static enum token t_lex(char *s);
163static arith_t oexpr(enum token n); 166static arith_t oexpr(enum token n);
@@ -176,8 +179,6 @@ static int test_eaccess(char *path, int mode);
176static int is_a_group_member(gid_t gid); 179static int is_a_group_member(gid_t gid);
177static void initialize_group_array(void); 180static void initialize_group_array(void);
178 181
179static jmp_buf leaving;
180
181int bb_test(int argc, char **argv) 182int bb_test(int argc, char **argv)
182{ 183{
183 int res; 184 int res;
@@ -210,7 +211,7 @@ int bb_test(int argc, char **argv)
210 * isn't likely in the case of a shell. paranoia 211 * isn't likely in the case of a shell. paranoia
211 * prevails... 212 * prevails...
212 */ 213 */
213 ngroups = 0; 214 ngroups = 0;
214 215
215 /* Implement special cases from POSIX.2, section 4.62.4 */ 216 /* Implement special cases from POSIX.2, section 4.62.4 */
216 if (argc == 1) 217 if (argc == 1)
@@ -223,8 +224,9 @@ int bb_test(int argc, char **argv)
223 if (argc == 3) 224 if (argc == 3)
224 return *argv[2] != '\0'; 225 return *argv[2] != '\0';
225 _off = argc - 4; 226 _off = argc - 4;
226 if (t_lex(argv[2+_off]), t_wp_op && t_wp_op->op_type == BINOP) { 227 t_lex(argv[2 + _off]);
227 t_wp = &argv[1+_off]; 228 if (t_wp_op && t_wp_op->op_type == BINOP) {
229 t_wp = &argv[1 + _off];
228 return binop() == 0; 230 return binop() == 0;
229 } 231 }
230 } 232 }
@@ -238,6 +240,7 @@ int bb_test(int argc, char **argv)
238 return res; 240 return res;
239} 241}
240 242
243static void syntax(const char *op, const char *msg) ATTRIBUTE_NORETURN;
241static void syntax(const char *op, const char *msg) 244static void syntax(const char *op, const char *msg)
242{ 245{
243 if (op && *op) { 246 if (op && *op) {
@@ -296,20 +299,20 @@ static arith_t primary(enum token n)
296 if (*++t_wp == NULL) 299 if (*++t_wp == NULL)
297 syntax(t_wp_op->op_text, "argument expected"); 300 syntax(t_wp_op->op_text, "argument expected");
298 if (n == STREZ) 301 if (n == STREZ)
299 return strlen(*t_wp) == 0; 302 return t_wp[0][0] == '\0';
300 else if (n == STRNZ) 303 if (n == STRNZ)
301 return strlen(*t_wp) != 0; 304 return t_wp[0][0] != '\0';
302 else if (n == FILTT) 305 if (n == FILTT)
303 return isatty(getn(*t_wp)); 306 return isatty(getn(*t_wp));
304 else 307 return filstat(*t_wp, n);
305 return filstat(*t_wp, n);
306 } 308 }
307 309
308 if (t_lex(t_wp[1]), t_wp_op && t_wp_op->op_type == BINOP) { 310 t_lex(t_wp[1]);
311 if (t_wp_op && t_wp_op->op_type == BINOP) {
309 return binop(); 312 return binop();
310 } 313 }
311 314
312 return strlen(*t_wp) > 0; 315 return t_wp[0][0] != '\0';
313} 316}
314 317
315static int binop(void) 318static int binop(void)
@@ -322,10 +325,11 @@ static int binop(void)
322 (void) t_lex(*++t_wp); 325 (void) t_lex(*++t_wp);
323 op = t_wp_op; 326 op = t_wp_op;
324 327
325 if ((opnd2 = *++t_wp) == (char *) 0) 328 opnd2 = *++t_wp;
329 if (opnd2 == NULL)
326 syntax(op->op_text, "argument expected"); 330 syntax(op->op_text, "argument expected");
327 331
328 if (__is_int_op(op->op_num)) { 332 if (is_int_op(op->op_num)) {
329 val1 = getn(opnd1); 333 val1 = getn(opnd1);
330 val2 = getn(opnd2); 334 val2 = getn(opnd2);
331 if (op->op_num == INTEQ) 335 if (op->op_num == INTEQ)
@@ -341,7 +345,7 @@ static int binop(void)
341 if (op->op_num == INTLT) 345 if (op->op_num == INTLT)
342 return val1 < val2; 346 return val1 < val2;
343 } 347 }
344 if (__is_str_op(op->op_num)) { 348 if (is_str_op(op->op_num)) {
345 val1 = strcmp(opnd1, opnd2); 349 val1 = strcmp(opnd1, opnd2);
346 if (op->op_num == STREQ) 350 if (op->op_num == STREQ)
347 return val1 == 0; 351 return val1 == 0;
@@ -355,7 +359,7 @@ static int binop(void)
355 /* We are sure that these three are by now the only binops we didn't check 359 /* We are sure that these three are by now the only binops we didn't check
356 * yet, so we do not check if the class is correct: 360 * yet, so we do not check if the class is correct:
357 */ 361 */
358/* if (__is_file_op(op->op_num)) */ 362/* if (is_file_op(op->op_num)) */
359 { 363 {
360 struct stat b1, b2; 364 struct stat b1, b2;
361 365
@@ -390,7 +394,7 @@ static int filstat(char *nm, enum token mode)
390 return 0; 394 return 0;
391 if (mode == FILEXIST) 395 if (mode == FILEXIST)
392 return 1; 396 return 1;
393 else if (__is_file_access(mode)) { 397 if (is_file_access(mode)) {
394 if (mode == FILRD) 398 if (mode == FILRD)
395 i = R_OK; 399 i = R_OK;
396 if (mode == FILWR) 400 if (mode == FILWR)
@@ -399,7 +403,7 @@ static int filstat(char *nm, enum token mode)
399 i = X_OK; 403 i = X_OK;
400 return test_eaccess(nm, i) == 0; 404 return test_eaccess(nm, i) == 0;
401 } 405 }
402 else if (__is_file_type(mode)) { 406 if (is_file_type(mode)) {
403 if (mode == FILREG) 407 if (mode == FILREG)
404 i = S_IFREG; 408 i = S_IFREG;
405 if (mode == FILDIR) 409 if (mode == FILDIR)
@@ -422,10 +426,10 @@ static int filstat(char *nm, enum token mode)
422 return 0; 426 return 0;
423#endif 427#endif
424 } 428 }
425filetype: 429 filetype:
426 return ((s.st_mode & S_IFMT) == i); 430 return ((s.st_mode & S_IFMT) == i);
427 } 431 }
428 else if (__is_file_bit(mode)) { 432 if (is_file_bit(mode)) {
429 if (mode == FILSUID) 433 if (mode == FILSUID)
430 i = S_ISUID; 434 i = S_ISUID;
431 if (mode == FILSGID) 435 if (mode == FILSGID)
@@ -434,33 +438,33 @@ filetype:
434 i = S_ISVTX; 438 i = S_ISVTX;
435 return ((s.st_mode & i) != 0); 439 return ((s.st_mode & i) != 0);
436 } 440 }
437 else if (mode == FILGZ) 441 if (mode == FILGZ)
438 return s.st_size > 0L; 442 return s.st_size > 0L;
439 else if (mode == FILUID) 443 if (mode == FILUID)
440 return s.st_uid == geteuid(); 444 return s.st_uid == geteuid();
441 else if (mode == FILGID) 445 if (mode == FILGID)
442 return s.st_gid == getegid(); 446 return s.st_gid == getegid();
443 else 447 return 1; /* NOTREACHED */
444 return 1; /* NOTREACHED */
445
446} 448}
447 449
448static enum token t_lex(char *s) 450static enum token t_lex(char *s)
449{ 451{
450 struct t_op const *op = ops; 452 const struct t_op *op;
451 453
452 if (s == 0) { 454 t_wp_op = NULL;
453 t_wp_op = (struct t_op *) 0; 455 if (s == NULL) {
454 return EOI; 456 return EOI;
455 } 457 }
456 while (op->op_text) { 458
459 op = ops;
460 do {
457 if (strcmp(s, op->op_text) == 0) { 461 if (strcmp(s, op->op_text) == 0) {
458 t_wp_op = op; 462 t_wp_op = op;
459 return op->op_num; 463 return op->op_num;
460 } 464 }
461 op++; 465 op++;
462 } 466 } while (op < ops + NUM_OPS);
463 t_wp_op = (struct t_op *) 0; 467
464 return OPERAND; 468 return OPERAND;
465} 469}
466 470
@@ -469,14 +473,14 @@ static enum token t_lex(char *s)
469static arith_t getn(const char *s) 473static arith_t getn(const char *s)
470{ 474{
471 char *p; 475 char *p;
472#ifdef CONFIG_FEATURE_TEST_64 476#if ENABLE_FEATURE_TEST_64
473 long long r; 477 long long r;
474#else 478#else
475 long r; 479 long r;
476#endif 480#endif
477 481
478 errno = 0; 482 errno = 0;
479#ifdef CONFIG_FEATURE_TEST_64 483#if ENABLE_FEATURE_TEST_64
480 r = strtoll(s, &p, 10); 484 r = strtoll(s, &p, 10);
481#else 485#else
482 r = strtol(s, &p, 10); 486 r = strtol(s, &p, 10);
@@ -591,4 +595,3 @@ int test_main(int argc, char **argv)
591{ 595{
592 return bb_test(argc, argv); 596 return bb_test(argc, argv);
593} 597}
594
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c
index 52861d405..dc4c0b237 100644
--- a/libbb/u_signal_names.c
+++ b/libbb/u_signal_names.c
@@ -9,20 +9,111 @@
9 9
10#include "libbb.h" 10#include "libbb.h"
11 11
12static const struct signal_name { 12static const char signals[32][7] = {
13 int number;
14 char name[5];
15} signals[] = {
16 // SUSv3 says kill must support these, and specifies the numerical values, 13 // SUSv3 says kill must support these, and specifies the numerical values,
17 // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html 14 // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
18 // TODO: "[SIG]EXIT" shouldn't work for kill, right? 15 // TODO: "[SIG]EXIT" shouldn't work for kill, right?
19 {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, {6, "ABRT"}, {9, "KILL"}, 16 // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"},
20 {14, "ALRM"}, {15, "TERM"}, 17 // {6, "ABRT"}, {9, "KILL"}, {14, "ALRM"}, {15, "TERM"}
21 // And Posix adds the following: 18 // And Posix adds the following:
22 {SIGILL, "ILL"}, {SIGTRAP, "TRAP"}, {SIGFPE, "FPE"}, {SIGUSR1, "USR1"}, 19 // {SIGILL, "ILL"}, {SIGTRAP, "TRAP"}, {SIGFPE, "FPE"}, {SIGUSR1, "USR1"},
23 {SIGSEGV, "SEGV"}, {SIGUSR2, "USR2"}, {SIGPIPE, "PIPE"}, {SIGCHLD, "CHLD"}, 20 // {SIGSEGV, "SEGV"}, {SIGUSR2, "USR2"}, {SIGPIPE, "PIPE"}, {SIGCHLD, "CHLD"},
24 {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"}, 21 // {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"},
25 {SIGTTOU, "TTOU"} 22 // {SIGTTOU, "TTOU"}
23 [0] = "EXIT",
24#ifdef SIGHUP
25 [SIGHUP ] = "HUP",
26#endif
27#ifdef SIGINT
28 [SIGINT ] = "INT",
29#endif
30#ifdef SIGQUIT
31 [SIGQUIT ] = "QUIT",
32#endif
33#ifdef SIGILL
34 [SIGILL ] = "ILL",
35#endif
36#ifdef SIGTRAP
37 [SIGTRAP ] = "TRAP",
38#endif
39#ifdef SIGABRT
40 [SIGABRT ] = "ABRT",
41#endif
42#ifdef SIGBUS
43 [SIGBUS ] = "BUS",
44#endif
45#ifdef SIGFPE
46 [SIGFPE ] = "FPE",
47#endif
48#ifdef SIGKILL
49 [SIGKILL ] = "KILL",
50#endif
51#ifdef SIGUSR1
52 [SIGUSR1 ] = "USR1",
53#endif
54#ifdef SIGSEGV
55 [SIGSEGV ] = "SEGV",
56#endif
57#ifdef SIGUSR2
58 [SIGUSR2 ] = "USR2",
59#endif
60#ifdef SIGPIPE
61 [SIGPIPE ] = "PIPE",
62#endif
63#ifdef SIGALRM
64 [SIGALRM ] = "ALRM",
65#endif
66#ifdef SIGTERM
67 [SIGTERM ] = "TERM",
68#endif
69#ifdef SIGSTKFLT
70 [SIGSTKFLT] = "STKFLT",
71#endif
72#ifdef SIGCHLD
73 [SIGCHLD ] = "CHLD",
74#endif
75#ifdef SIGCONT
76 [SIGCONT ] = "CONT",
77#endif
78#ifdef SIGSTOP
79 [SIGSTOP ] = "STOP",
80#endif
81#ifdef SIGTSTP
82 [SIGTSTP ] = "TSTP",
83#endif
84#ifdef SIGTTIN
85 [SIGTTIN ] = "TTIN",
86#endif
87#ifdef SIGTTOU
88 [SIGTTOU ] = "TTOU",
89#endif
90#ifdef SIGURG
91 [SIGURG ] = "URG",
92#endif
93#ifdef SIGXCPU
94 [SIGXCPU ] = "XCPU",
95#endif
96#ifdef SIGXFSZ
97 [SIGXFSZ ] = "XFSZ",
98#endif
99#ifdef SIGVTALRM
100 [SIGVTALRM] = "VTALRM",
101#endif
102#ifdef SIGPROF
103 [SIGPROF ] = "PROF",
104#endif
105#ifdef SIGWINCH
106 [SIGWINCH ] = "WINCH",
107#endif
108#ifdef SIGPOLL
109 [SIGPOLL ] = "POLL",
110#endif
111#ifdef SIGPWR
112 [SIGPWR ] = "PWR",
113#endif
114#ifdef SIGSYS
115 [SIGSYS ] = "SYS",
116#endif
26}; 117};
27 118
28// Convert signal name to number. 119// Convert signal name to number.
@@ -32,12 +123,28 @@ int get_signum(const char *name)
32 int i; 123 int i;
33 124
34 i = bb_strtou(name, NULL, 10); 125 i = bb_strtou(name, NULL, 10);
35 if (!errno) return i; 126 if (!errno)
36 for (i = 0; i < sizeof(signals) / sizeof(struct signal_name); i++) 127 return i;
37 if (strcasecmp(name, signals[i].name) == 0 128 if (strncasecmp(name, "SIG", 3) == 0)
38 || (strncasecmp(name, "SIG", 3) == 0 129 name += 3;
39 && strcasecmp(&name[3], signals[i].name) == 0)) 130 for (i = 0; i < sizeof(signals) / sizeof(signals[0]); i++)
40 return signals[i].number; 131 if (strcasecmp(name, signals[i]) == 0)
132 return i;
133
134#if ENABLE_DESKTOP && (defined(SIGIOT) || defined(SIGIO))
135 /* These are aliased to other names */
136 if ((name[0] | 0x20) == 'i' && (name[1] | 0x20) == 'o') {
137#ifdef SIGIO
138 if (!name[2])
139 return SIGIO;
140#endif
141#ifdef SIGIOT
142 if ((name[2] | 0x20) == 't' && !name[3])
143 return SIGIOT;
144#endif
145 }
146#endif
147
41 return -1; 148 return -1;
42} 149}
43 150
@@ -45,12 +152,9 @@ int get_signum(const char *name)
45 152
46const char *get_signame(int number) 153const char *get_signame(int number)
47{ 154{
48 int i; 155 if ((unsigned)number < sizeof(signals) / sizeof(signals[0])) {
49 156 if (signals[number][0]) /* if it's not an empty str */
50 for (i=0; i < sizeof(signals) / sizeof(struct signal_name); i++) { 157 return signals[number];
51 if (number == signals[i].number) {
52 return signals[i].name;
53 }
54 } 158 }
55 159
56 return itoa(number); 160 return itoa(number);
diff --git a/procps/kill.c b/procps/kill.c
index e2b029d20..b3257492d 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -51,7 +51,9 @@ int kill_main(int argc, char **argv)
51 if (argc == 1) { 51 if (argc == 1) {
52 /* Print the whole signal list */ 52 /* Print the whole signal list */
53 for (signo = 1; signo < 32; signo++) { 53 for (signo = 1; signo < 32; signo++) {
54 puts(get_signame(signo)); 54 const char *name = get_signame(signo);
55 if (!isdigit(name[0]))
56 puts(name);
55 } 57 }
56 } else { /* -l <sig list> */ 58 } else { /* -l <sig list> */
57 while ((arg = *++argv)) { 59 while ((arg = *++argv)) {
diff --git a/procps/ps.c b/procps/ps.c
index 5128c3d59..55453131e 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -47,18 +47,21 @@ static void func_pgid(char *buf, int size, const procps_status_t *ps)
47 sprintf(buf, "%*u", size, ps->pgid); 47 sprintf(buf, "%*u", size, ps->pgid);
48} 48}
49 49
50static void func_vsz(char *buf, int size, const procps_status_t *ps) 50static void put_u(char *buf, int size, unsigned u)
51{ 51{
52 char buf5[5]; 52 char buf5[5];
53 smart_ulltoa5( ((unsigned long long)ps->vsz) << 10, buf5); 53 smart_ulltoa5( ((unsigned long long)u) << 10, buf5);
54 sprintf(buf, "%.*s", size, buf5); 54 sprintf(buf, "%.*s", size, buf5);
55} 55}
56 56
57static void func_vsz(char *buf, int size, const procps_status_t *ps)
58{
59 put_u(buf, size, ps->vsz);
60}
61
57static void func_rss(char *buf, int size, const procps_status_t *ps) 62static void func_rss(char *buf, int size, const procps_status_t *ps)
58{ 63{
59 char buf5[5]; 64 put_u(buf, size, ps->rss);
60 smart_ulltoa5( ((unsigned long long)ps->rss) << 10, buf5);
61 sprintf(buf, "%.*s", size, buf5);
62} 65}
63 66
64static void func_tty(char *buf, int size, const procps_status_t *ps) 67static void func_tty(char *buf, int size, const procps_status_t *ps)
@@ -383,7 +386,7 @@ int ps_main(int argc, char **argv)
383 len = printf("%5u %-8s %s ", 386 len = printf("%5u %-8s %s ",
384 p->pid, user, p->state); 387 p->pid, user, p->state);
385 else 388 else
386 len = printf("%5u %-8s %6ld %s ", 389 len = printf("%5u %-8s %6u %s ",
387 p->pid, user, p->vsz, p->state); 390 p->pid, user, p->vsz, p->state);
388 } 391 }
389 392