commit 560340341fffe3a5798421cb9ed82d9b09276743
Author: Hiltjo Posthuma <[email protected]>
Date:   Wed Apr 9 15:17:20 2014 +0200

    make parsemode() generic
    
    use for uudecode and chmod
    
    Signed-off-by: Hiltjo Posthuma <[email protected]>

diff --git a/Makefile b/Makefile
index ceed44f..ad1e43b 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ LIB = \
        util/fnck.o      \
        util/getlines.o  \
        util/md5.o       \
+       util/mode.o      \
        util/putword.o   \
        util/recurse.o   \
        util/rm.o        \
diff --git a/chmod.c b/chmod.c
index 74d7c15..901363e 100644
--- a/chmod.c
+++ b/chmod.c
@@ -7,10 +7,9 @@
 #include "util.h"
 
 static void chmodr(const char *);
-static void parsemode(const char *);
 
 static bool rflag = false;
-static char oper = '=';
+static int oper = '=';
 static mode_t mode = 0;
 
 static void
@@ -46,7 +45,7 @@ main(int argc, char *argv[])
        }
 
 done:
-       parsemode(argv[0]);
+       parsemode(argv[0], &mode, &oper);
        argv++;
        argc--;
 
@@ -82,73 +81,3 @@ chmodr(const char *path)
        if(rflag)
                recurse(path, chmodr);
 }
-
-void
-parsemode(const char *str)
-{
-       char *end;
-       const char *p;
-       int octal;
-       mode_t mask = 0;
-
-       octal = strtol(str, &end, 8);
-       if(*end == '

Reply via email to