summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-08-27 19:34:28 +0000
committerJim Meyering <jim@meyering.net>2006-08-27 19:34:28 +0000
commit07446625096ddeb9246fb36572d5fe644f56cd1f (patch)
tree607b82beccc330d0af2703c4e204218afea74d64 /src
parent0a94897cfea53424289dc32ddb8efa9728561003 (diff)
downloadcoreutils-07446625096ddeb9246fb36572d5fe644f56cd1f.tar.xz
* src/system.h (DOT_OR_DOTDOT): Remove macro. Rewrite as a...
(dot_or_dotdot): ...new static inline function. * src/remove.c (rm_1): Reflect this renaming. * src/ls.c (basename_is_dot_or_dotdot): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c2
-rw-r--r--src/remove.c2
-rw-r--r--src/system.h13
3 files changed, 11 insertions, 6 deletions
diff --git a/src/ls.c b/src/ls.c
index 8b4fb2e43..4d71f3286 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2814,7 +2814,7 @@ static bool
basename_is_dot_or_dotdot (const char *name)
{
char const *base = last_component (name);
- return DOT_OR_DOTDOT (base);
+ return dot_or_dotdot (base);
}
/* Remove any entries from FILES that are for directories,
diff --git a/src/remove.c b/src/remove.c
index 5de52df23..368375864 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -1372,7 +1372,7 @@ rm_1 (Dirstack_state *ds, char const *filename,
struct rm_options const *x, int *cwd_errno)
{
char const *base = last_component (filename);
- if (DOT_OR_DOTDOT (base))
+ if (dot_or_dotdot (base))
{
error (0, 0, _("cannot remove `.' or `..'"));
return RM_ERROR;
diff --git a/src/system.h b/src/system.h
index 29bd1be55..226c863c9 100644
--- a/src/system.h
+++ b/src/system.h
@@ -447,9 +447,14 @@ uid_t getuid ();
#include "unlocked-io.h"
#include "same-inode.h"
-#define DOT_OR_DOTDOT(Basename) \
- (Basename[0] == '.' && (Basename[1] == '\0' \
- || (Basename[1] == '.' && Basename[2] == '\0')))
+static inline bool
+dot_or_dotdot (char const *file_name)
+{
+ return (file_name[0] == '.'
+ && (file_name[1] == '\0'
+ || (file_name[1] == '.'
+ && file_name[2] == '\0')));
+}
/* A wrapper for readdir so that callers don't see entries for `.' or `..'. */
static inline struct dirent const *
@@ -458,7 +463,7 @@ readdir_ignoring_dot_and_dotdot (DIR *dirp)
while (1)
{
struct dirent const *dp = readdir (dirp);
- if (dp == NULL || ! DOT_OR_DOTDOT (dp->d_name))
+ if (dp == NULL || ! dot_or_dotdot (dp->d_name))
return dp;
}
}