summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/manconfig.h.in3
-rw-r--r--lib/tempfile.c8
-rw-r--r--src/catman.c2
-rw-r--r--src/filenames.c2
-rw-r--r--src/man.c11
-rw-r--r--src/ult_src.c6
-rw-r--r--src/whatis.c2
7 files changed, 19 insertions, 15 deletions
diff --git a/include/manconfig.h.in b/include/manconfig.h.in
index 64a0d992..5c3ad648 100644
--- a/include/manconfig.h.in
+++ b/include/manconfig.h.in
@@ -403,6 +403,9 @@ extern int quiet; /* be quiet(er) if 1 */
*/
#define CTYPE(func,arg) (func((unsigned char)(arg)))
+/* access(2), but with boolean semantics. */
+#define CAN_ACCESS(pathname, mode) (access (pathname, mode) == 0)
+
/* FSSTND directories */
#define CAT_ROOT "/var/catman" /* required by fsstnd() */
#define MAN_ROOT "/usr" /* required by fsstnd() */
diff --git a/lib/tempfile.c b/lib/tempfile.c
index 3a9678d4..91ee0fb1 100644
--- a/lib/tempfile.c
+++ b/lib/tempfile.c
@@ -38,24 +38,24 @@ static const char *path_search (void)
if (getuid () == geteuid () && getgid () == getegid ()) {
dir = getenv ("TMPDIR");
- if (!dir || access (dir, W_OK) == -1)
+ if (!dir || !CAN_ACCESS (dir, W_OK))
dir = NULL;
if (!dir) {
dir = getenv ("TMP");
- if (!dir || access (dir, W_OK) == -1)
+ if (!dir || !CAN_ACCESS (dir, W_OK))
dir = NULL;
}
}
#ifdef P_tmpdir
if (!dir) {
dir = P_tmpdir;
- if (!dir || access (dir, W_OK) == -1)
+ if (!dir || !CAN_ACCESS (dir, W_OK))
dir = NULL;
}
#endif
if (!dir) {
dir = "/tmp";
- if (access (dir, W_OK) == -1)
+ if (!CAN_ACCESS (dir, W_OK))
dir = NULL;
}
diff --git a/src/catman.c b/src/catman.c
index d240f94e..a4c964aa 100644
--- a/src/catman.c
+++ b/src/catman.c
@@ -342,7 +342,7 @@ static int parse_for_sec (const char *manpath, const char *section)
static int check_access (const char *directory)
{
- if (access (directory, W_OK)) {
+ if (!CAN_ACCESS (directory, W_OK)) {
error (0, errno, _("cannot write within %s"), directory);
return 1;
}
diff --git a/src/filenames.c b/src/filenames.c
index f0251ace..966e0de5 100644
--- a/src/filenames.c
+++ b/src/filenames.c
@@ -63,7 +63,7 @@ char *make_filename (const char *path, const char *name,
file = appendstr (file, ".", in->comp, NULL);
debug ("Checking physical location: %s\n", file);
- if (access (file, R_OK) != 0) {
+ if (!CAN_ACCESS (file, R_OK)) {
free (file);
return NULL;
}
diff --git a/src/man.c b/src/man.c
index 34945bca..55d7c28f 100644
--- a/src/man.c
+++ b/src/man.c
@@ -1154,11 +1154,11 @@ static pipeline *make_roff_command (const char *dir, const char *file,
fmt_prog = appendstr (catpath, "/",
troff ? TFMT_PROG : NFMT_PROG,
NULL);
- if (access (fmt_prog, X_OK)) {
+ if (!CAN_ACCESS (fmt_prog, X_OK)) {
free (fmt_prog);
fmt_prog = xstrdup (troff ? TFMT_PROG :
NFMT_PROG);
- if (access (fmt_prog, X_OK)) {
+ if (!CAN_ACCESS (fmt_prog, X_OK)) {
free (fmt_prog);
fmt_prog = NULL;
}
@@ -1168,7 +1168,7 @@ static pipeline *make_roff_command (const char *dir, const char *file,
#endif /* ALT_EXT_FORMAT */
fmt_prog = xstrdup (troff ? TFMT_PROG : NFMT_PROG);
- if (access (fmt_prog, X_OK)) {
+ if (!CAN_ACCESS (fmt_prog, X_OK)) {
free (fmt_prog);
fmt_prog = NULL;
}
@@ -2315,7 +2315,7 @@ static int display (const char *dir, const char *man_file,
if (*man_file == '\0')
found = 1;
else
- found = !access (man_file, R_OK);
+ found = CAN_ACCESS (man_file, R_OK);
if (found) {
int status;
if (prompt && do_prompt (title)) {
@@ -2404,7 +2404,8 @@ static int display (const char *dir, const char *man_file,
if (format == 1 && *man_file == '\0')
found = 1;
else
- found = !access (format ? man_file : cat_file, R_OK);
+ found = CAN_ACCESS
+ (format ? man_file : cat_file, R_OK);
debug ("format: %d, save_cat: %d, found: %d\n",
format, save_cat, found);
diff --git a/src/ult_src.c b/src/ult_src.c
index f0de35c0..15c2e52b 100644
--- a/src/ult_src.c
+++ b/src/ult_src.c
@@ -191,14 +191,14 @@ static char *find_include (const char *name, const char *path,
/* If the original path from above doesn't exist, try to create new
* path as if the "include" was relative to the current man page.
*/
- if (access (ret, F_OK) == 0)
+ if (CAN_ACCESS (ret, F_OK))
return ret;
dirname = dir_name (name);
temp_file = xasprintf ("%s/%s", dirname, include);
free (dirname);
- if (access (temp_file, F_OK) == 0) {
+ if (CAN_ACCESS (temp_file, F_OK)) {
/* Just plain include. */
free (ret);
ret = canonicalize_file_name (temp_file);
@@ -209,7 +209,7 @@ static char *find_include (const char *name, const char *path,
int i;
free (temp_file_asterisk);
- if (access (candidate_files[0], F_OK) == 0) {
+ if (CAN_ACCESS (candidate_files[0], F_OK)) {
free (ret);
ret = canonicalize_file_name (candidate_files[0]);
}
diff --git a/src/whatis.c b/src/whatis.c
index 0918344d..0dd7be12 100644
--- a/src/whatis.c
+++ b/src/whatis.c
@@ -325,7 +325,7 @@ static void use_grep (const char * const *pages, int num_pages, char *manpath,
{
char *whatis_file = xasprintf ("%s/whatis", manpath);
- if (access (whatis_file, R_OK) == 0) {
+ if (CAN_ACCESS (whatis_file, R_OK)) {
const char *flags;
int i;