fs-util: unify code we use to check if dirent's d_name is "." or ".."

We use different idioms at different places. Let's replace this is the
one true new idiom, that is even a bit faster...
This commit is contained in:
Lennart Poettering
2017-02-02 00:06:18 +01:00
parent 1d0106996c
commit 49bfc8774b
12 changed files with 43 additions and 20 deletions
+11
View File
@@ -305,12 +305,23 @@ static void test_var_tmp(void) {
}
}
static void test_dot_or_dot_dot(void) {
assert_se(!dot_or_dot_dot(NULL));
assert_se(!dot_or_dot_dot(""));
assert_se(!dot_or_dot_dot("xxx"));
assert_se(dot_or_dot_dot("."));
assert_se(dot_or_dot_dot(".."));
assert_se(!dot_or_dot_dot(".foo"));
assert_se(!dot_or_dot_dot("..foo"));
}
int main(int argc, char *argv[]) {
test_unlink_noerrno();
test_readlink_and_make_absolute();
test_get_files_in_directory();
test_var_tmp();
test_chase_symlinks();
test_dot_or_dot_dot();
return 0;
}