Replaced atooi() with strtoul(..., 8). That's part of C89 and thus okay for us.
authormarkus schnalke <meillo@marmaro.de>
Sat, 24 Mar 2012 11:14:00 +0000 (12:14 +0100)
committermarkus schnalke <meillo@marmaro.de>
Sat, 24 Mar 2012 11:14:00 +0000 (12:14 +0100)
config/config.c
h/prototypes.h
man/mh-profile.man5
sbr/Makefile.in
sbr/atooi.c [deleted file]
sbr/m_gmprot.c
sbr/makedir.c

index 0e725ee..82c66c3 100644 (file)
@@ -181,14 +181,13 @@ char *altmsglink = "@";
 /*
 ** Folders (directories) are created with this protection (mode)
 */
 /*
 ** Folders (directories) are created with this protection (mode)
 */
-char *foldprot = "700";
+char *foldprot = "0700";
 
 /*
 ** Every NEW message will be created with this protection.  When a
 
 /*
 ** Every NEW message will be created with this protection.  When a
-** message is filed it retains its protection, so this only applies
-** to messages coming in through inc.
+** message is filed it retains its protection.
 */
 */
-char *msgprot = "600";
+char *msgprot = "0600";
 
 
 
 
 
 
index 0f61ce4..528da47 100644 (file)
@@ -27,7 +27,6 @@ void admonish(char *, char *, ...);
 void advertise(char *, char *, char *, va_list);
 void advise(char *, char *, ...);
 void ambigsw(char *, struct swit *);
 void advertise(char *, char *, char *, va_list);
 void advise(char *, char *, ...);
 void ambigsw(char *, struct swit *);
-int atooi(char *);
 char **brkstring(char *, char *, char *);
 int check_charset(char *, int);
 void closefds(int);
 char **brkstring(char *, char *, char *);
 int check_charset(char *, int);
 void closefds(int);
index c652428..5c051fb 100644 (file)
@@ -213,23 +213,23 @@ which is part of mmh, but guesses MIME types by file name extensions only.
 .RE
 .PP
 .BR Msg\-Protect :
 .RE
 .PP
 .BR Msg\-Protect :
-644
+0644
 .RS 5
 An octal number which defines the permission bits for new message files.
 See
 .BR chmod (1)
 for an explanation of the octal number.
 .RS 5
 An octal number which defines the permission bits for new message files.
 See
 .BR chmod (1)
 for an explanation of the octal number.
-(profile, default: 0644)
+(profile, default: 0600)
 .RE
 .PP
 .BR Folder\-Protect :
 .RE
 .PP
 .BR Folder\-Protect :
-750
+0750
 .RS 5
 An octal number which defines the permission bits for new folder
 directories.  See
 .BR chmod (1)
 for an explanation of the octal number.
 .RS 5
 An octal number which defines the permission bits for new folder
 directories.  See
 .BR chmod (1)
 for an explanation of the octal number.
-(profile, default: 700)
+(profile, default: 0700)
 .RE
 .PP
 .IR program :
 .RE
 .PP
 .IR program :
index d3782ff..5b40ab3 100644 (file)
@@ -45,7 +45,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS)
 SIGNAL_H = @SIGNAL_H@
 
 # source for library functions
 SIGNAL_H = @SIGNAL_H@
 
 # source for library functions
-SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c  \
+SRCS = addrsbr.c ambigsw.c brkstring.c  \
        check_charset.c closefds.c concat.c context_del.c  \
        context_find.c context_foil.c context_read.c  \
        context_replace.c context_save.c \
        check_charset.c closefds.c concat.c context_del.c  \
        context_find.c context_foil.c context_read.c  \
        context_replace.c context_save.c \
diff --git a/sbr/atooi.c b/sbr/atooi.c
deleted file mode 100644 (file)
index cb557b7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-** atooi.c -- octal version of atoi()
-**
-** This code is Copyright (c) 2002, by the authors of nmh.  See the
-** COPYRIGHT file in the root directory of the nmh distribution for
-** complete copyright information.
-*/
-
-#include <h/mh.h>
-
-
-int
-atooi(char *cp)
-{
-       register int i, base;
-
-       i = 0;
-       base = 8;
-       while (*cp >= '0' && *cp <= '7') {
-               i *= base;
-               i += *cp++ - '0';
-       }
-
-       return i;
-}
index 9c86e77..377be09 100644 (file)
 int
 m_gmprot(void)
 {
 int
 m_gmprot(void)
 {
-       register char *cp;
+       char *cp;
 
 
-       return atooi ((cp = context_find("msg-protect")) && *cp ? cp : msgprot);
+       if (!(cp = context_find("msg-protect")) || !*cp) {
+               cp = msgprot;
+       }
+       return strtol(cp, NULL, 8);
 }
 }
index a76f910..ea39385 100644 (file)
@@ -19,7 +19,7 @@ int
 makedir(char *dir)
 {
        char path[PATH_MAX];
 makedir(char *dir)
 {
        char path[PATH_MAX];
-       char* folder_perms_ASCII;
+       char *cp;
        int had_an_error = 0;
        mode_t folder_perms, saved_umask;
        register char* c;
        int had_an_error = 0;
        mode_t folder_perms, saved_umask;
        register char* c;
@@ -27,20 +27,10 @@ makedir(char *dir)
        context_save();  /* save the context file */
        fflush(stdout);
 
        context_save();  /* save the context file */
        fflush(stdout);
 
-       if (!(folder_perms_ASCII = context_find("folder-protect")))
-               folder_perms_ASCII = foldprot;  /* defaults to "700" */
-
-       /*
-       ** Because mh-profile.man documents "Folder-Protect:" as an octal
-       ** constant, and we don't want to force the user to remember to
-       ** include a leading zero, we call atooi(folder_perms_ASCII) here
-       ** rather than strtoul(folder_perms_ASCII, NULL, 0).  Therefore,
-       ** if anyone ever tries to specify a mode in say, hex, they'll
-       ** get garbage.  (I guess nmh uses its atooi() function rather
-       ** than calling strtoul() with a radix of 8 because some ancient
-       ** platforms are missing that functionality.
-       */
-       folder_perms = atooi(folder_perms_ASCII);
+       if (!(cp = context_find("folder-protect")) || !*cp) {
+               cp = foldprot;
+       }
+       folder_perms = strtoul(cp, NULL, 8);
 
        /*
        ** Folders have definite desired permissions that are set -- we
 
        /*
        ** Folders have definite desired permissions that are set -- we