From 07446625096ddeb9246fb36572d5fe644f56cd1f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 27 Aug 2006 19:34:28 +0000 Subject: * 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. --- src/ls.c | 2 +- src/remove.c | 2 +- src/system.h | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') 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; } } -- cgit v1.2.3-70-g09d2