diff options
author | Ron Yorston <rmy@pobox.com> | 2021-10-12 13:43:15 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-10-12 13:43:15 +0100 |
commit | b4b2b2c4fbba12561c5e988177bef699be306b26 (patch) | |
tree | af6ee5b26f0f775264eb8afb1af63415818e2a7e | |
parent | 0d127fbf4bbcd09f36740019ef129851464f8660 (diff) | |
download | busybox-w32-b4b2b2c4fbba12561c5e988177bef699be306b26.tar.gz busybox-w32-b4b2b2c4fbba12561c5e988177bef699be306b26.tar.bz2 busybox-w32-b4b2b2c4fbba12561c5e988177bef699be306b26.zip |
win32: rename is_absolute_path()
As the comment pointed out is_absolute_path() was misnamed. Rename
it to is_relative_path() and change the sense of all tests.
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | libbb/xreadlink.c | 2 | ||||
-rw-r--r-- | shell/ash.c | 6 | ||||
-rw-r--r-- | win32/mingw.c | 16 |
4 files changed, 13 insertions, 13 deletions
diff --git a/include/mingw.h b/include/mingw.h index 74a65116c..6ace91470 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -579,4 +579,4 @@ void make_sparse(int fd, off_t start, off_t end); | |||
579 | int skip_ansi_emulation(int reset); | 579 | int skip_ansi_emulation(int reset); |
580 | int unix_path(const char *path); | 580 | int unix_path(const char *path); |
581 | int has_path(const char *file); | 581 | int has_path(const char *file); |
582 | int is_absolute_path(const char *path); | 582 | int is_relative_path(const char *path); |
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index b64654b33..31680810b 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c | |||
@@ -80,7 +80,7 @@ char* FAST_FUNC xmalloc_follow_symlinks(const char *path) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | #if ENABLE_PLATFORM_MINGW32 | 82 | #if ENABLE_PLATFORM_MINGW32 |
83 | if (!is_absolute_path(linkpath)) { | 83 | if (is_relative_path(linkpath)) { |
84 | #else | 84 | #else |
85 | if (*linkpath != '/') { | 85 | if (*linkpath != '/') { |
86 | #endif | 86 | #endif |
diff --git a/shell/ash.c b/shell/ash.c index 487e477a3..9214982c1 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -344,7 +344,7 @@ typedef long arith_t; | |||
344 | #endif | 344 | #endif |
345 | 345 | ||
346 | #if !ENABLE_PLATFORM_MINGW32 | 346 | #if !ENABLE_PLATFORM_MINGW32 |
347 | # define is_absolute_path(path) ((path)[0] == '/') | 347 | # define is_relative_path(path) ((path)[0] != '/') |
348 | #endif | 348 | #endif |
349 | 349 | ||
350 | #if !BB_MMU | 350 | #if !BB_MMU |
@@ -3379,7 +3379,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
3379 | } | 3379 | } |
3380 | if (!dest) | 3380 | if (!dest) |
3381 | dest = nullstr; | 3381 | dest = nullstr; |
3382 | if (is_absolute_path(dest)) | 3382 | if (!is_relative_path(dest)) |
3383 | goto step6; | 3383 | goto step6; |
3384 | if (*dest == '.') { | 3384 | if (*dest == '.') { |
3385 | c = dest[1]; | 3385 | c = dest[1]; |
@@ -14728,7 +14728,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
14728 | } | 14728 | } |
14729 | } | 14729 | } |
14730 | /* if rehash, don't redo absolute path names */ | 14730 | /* if rehash, don't redo absolute path names */ |
14731 | if (is_absolute_path(fullname) && idx <= prev) { | 14731 | if (!is_relative_path(fullname) && idx <= prev) { |
14732 | if (idx < prev) | 14732 | if (idx < prev) |
14733 | continue; | 14733 | continue; |
14734 | TRACE(("searchexec \"%s\": no change\n", name)); | 14734 | TRACE(("searchexec \"%s\": no change\n", name)); |
diff --git a/win32/mingw.c b/win32/mingw.c index f4ae60d41..7ce60139e 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -811,7 +811,7 @@ int utimensat(int fd, const char *path, const struct timespec times[2], | |||
811 | HANDLE fh; | 811 | HANDLE fh; |
812 | DWORD cflag = FILE_FLAG_BACKUP_SEMANTICS; | 812 | DWORD cflag = FILE_FLAG_BACKUP_SEMANTICS; |
813 | 813 | ||
814 | if (!is_absolute_path(path) && fd != AT_FDCWD) { | 814 | if (is_relative_path(path) && fd != AT_FDCWD) { |
815 | errno = ENOSYS; // partial implementation | 815 | errno = ENOSYS; // partial implementation |
816 | return rc; | 816 | return rc; |
817 | } | 817 | } |
@@ -1202,7 +1202,7 @@ int symlink(const char *target, const char *linkpath) | |||
1202 | return -1; | 1202 | return -1; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | if (!is_absolute_path(target) && has_path(linkpath)) { | 1205 | if (is_relative_path(target) && has_path(linkpath)) { |
1206 | /* make target's path relative to current directory */ | 1206 | /* make target's path relative to current directory */ |
1207 | const char *name = bb_get_last_path_component_nostrip(linkpath); | 1207 | const char *name = bb_get_last_path_component_nostrip(linkpath); |
1208 | relative = xasprintf("%.*s%s", | 1208 | relative = xasprintf("%.*s%s", |
@@ -2082,11 +2082,11 @@ int has_path(const char *file) | |||
2082 | has_dos_drive_prefix(file); | 2082 | has_dos_drive_prefix(file); |
2083 | } | 2083 | } |
2084 | 2084 | ||
2085 | /* This function is misnamed. It's actually a test for 'is not a path | 2085 | /* Test whether a path is relative to a known location (usually the |
2086 | * relative to the current working directory'. On Unix this is the | 2086 | * current working directory or a symlink). On Unix this is a path |
2087 | * same as 'is an absolute path' but Windows also has paths relative to | 2087 | * that doesn't start with a slash but on Windows we also need to |
2088 | * current root and relative to current directory of another drive. */ | 2088 | * exclude paths that start with a backslash or a drive letter. */ |
2089 | int is_absolute_path(const char *path) | 2089 | int is_relative_path(const char *path) |
2090 | { | 2090 | { |
2091 | return path[0] == '/' || path[0] == '\\' || has_dos_drive_prefix(path); | 2091 | return !is_dir_sep(path[0]) && !has_dos_drive_prefix(path); |
2092 | } | 2092 | } |