summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2018-06-08 10:09:00 +0100
committerColin Watson <cjwatson@debian.org>2018-06-08 10:09:00 +0100
commit7ef8e4fffc09c568b158fe8015345b1ae4986148 (patch)
tree48ef4f6a428bd9d916ef8e14e6ee205d29888752 /include
parent32995639aa2ee83a07165a82a045b3cb60924dff (diff)
Define an access(2) wrapper with clearer semantics
As usual for system calls, access(2) returns zero on success. However, I generally think of it as "can we access this file in this way", where boolean semantics would be more convenient, and find it too easy to invert logic by accident when using the system call directly. Define a CAN_ACCESS wrapper with boolean semantics. * include/manconfig.h.in (CAN_ACCESS): New macro. * lib/tempfile.c (path_search): Use CAN_ACCESS. * src/catman.c (check_access): Likewise. * src/filenames.c (make_filename): Likewise. * src/man.c (make_roff_command, display): Likewise. * src/ult_src.c (find_include): Likewise. * src/whatis.c (use_grep): Likewise.
Diffstat (limited to 'include')
-rw-r--r--include/manconfig.h.in3
1 files changed, 3 insertions, 0 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() */