From: William A. Rowe Jr Date: Sat, 14 Sep 2002 03:40:11 +0000 (+0000) Subject: 1. Eliminate perror(), it's not portable. X-Git-Tag: 2.0.42~43 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae2b699a9f50ce8245dcb6629ff5492269e4d083;p=apache 1. Eliminate perror(), it's not portable. 2. Restructure bit tests, ! is a logical, not a bitwise negation. 3. Clean up just a bit of other ! syntax fooness and excess parens. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96802 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/support/htpasswd.c b/support/htpasswd.c index 4dfa314502..03b066f91a 100644 --- a/support/htpasswd.c +++ b/support/htpasswd.c @@ -512,50 +512,46 @@ int main(int argc, const char * const argv[]) "might just not work on this platform.\n"); } #endif - if (! mask & APHTP_NOFILE) { + if (!(mask & APHTP_NOFILE)) { /* * Only do the file checks if we're supposed to frob it. * * Verify that the file exists if -c was omitted. We give a special * message if it doesn't. */ - if ((! mask & APHTP_NEWFILE) && (! exists(pwfilename, pool))) { + if (!(mask & APHTP_NEWFILE) && !exists(pwfilename, pool)) { apr_file_printf(errfile, "%s: cannot modify file %s; use '-c' to create it\n", argv[0], pwfilename); - perror("apr_file_open"); exit(ERR_FILEPERM); } /* * Verify that we can read the existing file in the case of an update * to it (rather than creation of a new one). */ - if ((! mask & APHTP_NEWFILE) && (! readable(pool, pwfilename))) { + if (!(mask & APHTP_NEWFILE) && !readable(pool, pwfilename)) { apr_file_printf(errfile, "%s: cannot open file %s for read " "access\n", argv[0], pwfilename); - perror("apr_file_open"); exit(ERR_FILEPERM); } /* * Now check to see if we can preserve an existing file in case * of password verification errors on a -c operation. */ - if ((mask & APHTP_NEWFILE) && exists(pwfilename, pool) && - (! readable(pool, pwfilename))) { + if ((mask & APHTP_NEWFILE) && exists(pwfilename, pool) + && !readable(pool, pwfilename)) { apr_file_printf(errfile, "%s: cannot open file %s for read access\n" "%s: existing auth data would be lost on " "password mismatch", argv[0], pwfilename, argv[0]); - perror("apr_file_open"); exit(ERR_FILEPERM); } /* * Now verify that the file is writable! */ - if (! writable(pool, pwfilename)) { + if (!writable(pool, pwfilename)) { apr_file_printf(errfile, "%s: cannot open file %s for write " "access\n", argv[0], pwfilename); - perror("apr_file_open"); exit(ERR_FILEPERM); } } @@ -594,7 +590,7 @@ int main(int argc, const char * const argv[]) */ if (apr_file_open(&fpw, pwfilename, APR_READ, APR_OS_DEFAULT, pool) == APR_SUCCESS) { - while (! (apr_file_gets(line, sizeof(line), fpw))) { + while (apr_file_gets(line, sizeof(line), fpw) == APR_SUCCESS) { char *colon; if ((line[0] == '#') || (line[0] == '\0')) {