[hackers] [sbase] Handle the special-case signal 0 and "0" properly || sin

From: <git_AT_suckless.org>
Date: Tue, 11 Nov 2014 18:40:29 +0100

commit 3ffe690384e637276c2fefbf7ba93f9ca689ecbb
Author: sin <sin_AT_2f30.org>
Date: Tue Nov 11 17:40:09 2014 +0000

    Handle the special-case signal 0 and "0" properly

diff --git a/kill.c b/kill.c
index f7f30b7..2ac022d 100644
--- a/kill.c
+++ b/kill.c
_AT_@ -69,7 +69,7 @@ main(int argc, char *argv[])
                 argc--, argv++;
                 if (argc == 0)
                         usage();
- sig = strcmp(argv[0], "0") == 0 ? 0 : name2sig(argv[0]);
+ sig = name2sig(argv[0]);
                 argc--, argv++;
         } else if (argv[0][0] == '-') {
                 if (isdigit(argv[0][1])) {
_AT_@ -82,7 +82,7 @@ main(int argc, char *argv[])
                         argc--, argv++;
                 } else if (argv[0][1] != '-') {
                         /* handle XSI extension -signame */
- sig = strcmp(&argv[0][1], "0") == 0 ? 0 : name2sig(&argv[0][1]);
+ sig = name2sig(&argv[0][1]);
                         argc--, argv++;
                 }
         }
_AT_@ -115,6 +115,8 @@ sig2name(int sig)
 {
         size_t i;
 
+ if (sig == 0)
+ return "0";
         for (i = 0; i < LEN(sigs); i++)
                 if (sigs[i].sig == sig)
                         return sigs[i].name;
_AT_@ -128,6 +130,8 @@ name2sig(const char *name)
 {
         size_t i;
 
+ if (strcmp(name, "0") == 0)
+ return 0;
         for (i = 0; i < LEN(sigs); i++)
                 if (strcasecmp(sigs[i].name, name) == 0)
                         return sigs[i].sig;
Received on Tue Nov 11 2014 - 18:40:29 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 11 2014 - 18:48:09 CET