[hackers] [sbase] Audit unexpand(1) || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 24 Mar 2015 23:54:18 +0100 (CET)

commit 5af4cdcd60d85e855893c96b6ea88dd60fc785ca
Author: FRIGN <dev_AT_frign.de>
Date: Tue Mar 17 23:45:03 2015 +0100

    Audit unexpand(1)
    
    I checked the algorithm already a while ago. What was left was a
    couple of style-fixes.

diff --git a/README b/README
index e21dd35..92f76f7 100644
--- a/README
+++ b/README
_AT_@ -81,7 +81,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
 =*| true yes none
 =*| tty yes none
 =*| uname yes none
-#* unexpand yes none
+#*| unexpand yes none
 =* uniq yes none
 =*| unlink yes none
 =* uudecode yes none
diff --git a/unexpand.c b/unexpand.c
index c565670..c0f6d38 100644
--- a/unexpand.c
+++ b/unexpand.c
_AT_@ -25,6 +25,7 @@ parselist(const char *s)
                         eprintf("tablist must be ascending\n");
         }
         tablist = ereallocarray(tablist, i + 1, sizeof(*tablist));
+
         return i;
 }
 
_AT_@ -148,18 +149,19 @@ main(int argc, char *argv[])
 
         tablistlen = parselist(tl);
 
- if (argc == 0) {
+ if (!argc) {
                 unexpand("<stdin>", stdin);
         } else {
- for (; argc > 0; argc--, argv++) {
- if (!(fp = fopen(argv[0], "r"))) {
- weprintf("fopen %s:", argv[0]);
+ for (; *argv; argc--, argv++) {
+ if (!(fp = fopen(*argv, "r"))) {
+ weprintf("fopen %s:", *argv);
                                 ret = 1;
                                 continue;
                         }
- unexpand(argv[0], fp);
+ unexpand(*argv, fp);
                         fclose(fp);
                 }
         }
+
         return ret;
 }
Received on Tue Mar 24 2015 - 23:54:18 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 25 2015 - 00:11:41 CET