From c490c51b3c0f8871b6953bd0c74551404f840a74 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Sat, 24 Mar 2012 12:14:00 +0100 Subject: [PATCH] Replaced atooi() with strtoul(..., 8). That's part of C89 and thus okay for us. --- config/config.c | 7 +++---- h/prototypes.h | 1 - man/mh-profile.man5 | 8 ++++---- sbr/Makefile.in | 2 +- sbr/atooi.c | 25 ------------------------- sbr/m_gmprot.c | 7 +++++-- sbr/makedir.c | 20 +++++--------------- 7 files changed, 18 insertions(+), 52 deletions(-) delete mode 100644 sbr/atooi.c diff --git a/config/config.c b/config/config.c index 0e725ee..82c66c3 100644 --- a/config/config.c +++ b/config/config.c @@ -181,14 +181,13 @@ char *altmsglink = "@"; /* ** 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 -** 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"; diff --git a/h/prototypes.h b/h/prototypes.h index 0f61ce4..528da47 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -27,7 +27,6 @@ void admonish(char *, char *, ...); 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); diff --git a/man/mh-profile.man5 b/man/mh-profile.man5 index c652428..5c051fb 100644 --- a/man/mh-profile.man5 +++ b/man/mh-profile.man5 @@ -213,23 +213,23 @@ which is part of mmh, but guesses MIME types by file name extensions only. .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. -(profile, default: 0644) +(profile, default: 0600) .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. -(profile, default: 700) +(profile, default: 0700) .RE .PP .IR program : diff --git a/sbr/Makefile.in b/sbr/Makefile.in index d3782ff..5b40ab3 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -45,7 +45,7 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) 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 \ diff --git a/sbr/atooi.c b/sbr/atooi.c deleted file mode 100644 index cb557b7..0000000 --- a/sbr/atooi.c +++ /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 - - -int -atooi(char *cp) -{ - register int i, base; - - i = 0; - base = 8; - while (*cp >= '0' && *cp <= '7') { - i *= base; - i += *cp++ - '0'; - } - - return i; -} diff --git a/sbr/m_gmprot.c b/sbr/m_gmprot.c index 9c86e77..377be09 100644 --- a/sbr/m_gmprot.c +++ b/sbr/m_gmprot.c @@ -12,7 +12,10 @@ 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); } diff --git a/sbr/makedir.c b/sbr/makedir.c index a76f910..ea39385 100644 --- a/sbr/makedir.c +++ b/sbr/makedir.c @@ -19,7 +19,7 @@ int 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; @@ -27,20 +27,10 @@ makedir(char *dir) 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 -- 1.7.10.4