diff options
author | Ron Yorston <rmy@pobox.com> | 2021-10-12 09:06:35 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-10-12 09:06:35 +0100 |
commit | 0d127fbf4bbcd09f36740019ef129851464f8660 (patch) | |
tree | 02ecc3b3749d3b5f8776cdfe92c7219a92785d47 | |
parent | e19dd7d618434be1336727a5113c1432ac3c6573 (diff) | |
download | busybox-w32-0d127fbf4bbcd09f36740019ef129851464f8660.tar.gz busybox-w32-0d127fbf4bbcd09f36740019ef129851464f8660.tar.bz2 busybox-w32-0d127fbf4bbcd09f36740019ef129851464f8660.zip |
win32: use is_dir_sep() everywhere
The is_dir_sep() macro, which has been around since the start of
busybox-w32, can be used instead of is_path_sep().
-rw-r--r-- | shell/ash.c | 19 | ||||
-rw-r--r-- | win32/mingw.c | 7 |
2 files changed, 12 insertions, 14 deletions
diff --git a/shell/ash.c b/shell/ash.c index 0fa3d4dab..487e477a3 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -3108,7 +3108,6 @@ static const char * | |||
3108 | updatepwd(const char *dir) | 3108 | updatepwd(const char *dir) |
3109 | { | 3109 | { |
3110 | #if ENABLE_PLATFORM_MINGW32 | 3110 | #if ENABLE_PLATFORM_MINGW32 |
3111 | # define is_path_sep(x) ((x) == '/' || (x) == '\\') | ||
3112 | /* | 3111 | /* |
3113 | * Due to Windows drive notion, getting pwd is a completely | 3112 | * Due to Windows drive notion, getting pwd is a completely |
3114 | * different thing. Handle it in a separate routine | 3113 | * different thing. Handle it in a separate routine |
@@ -3139,17 +3138,17 @@ updatepwd(const char *dir) | |||
3139 | enum {ABS_DRIVE, ABS_SHARE, REL_OTHER, REL_ROOT, REL_CWD} target; | 3138 | enum {ABS_DRIVE, ABS_SHARE, REL_OTHER, REL_ROOT, REL_CWD} target; |
3140 | 3139 | ||
3141 | /* skip multiple leading separators unless dir is a UNC path */ | 3140 | /* skip multiple leading separators unless dir is a UNC path */ |
3142 | if (is_path_sep(*dir) && unc_root_len(dir) == 0) { | 3141 | if (is_dir_sep(*dir) && unc_root_len(dir) == 0) { |
3143 | while (is_path_sep(dir[1])) | 3142 | while (is_dir_sep(dir[1])) |
3144 | ++dir; | 3143 | ++dir; |
3145 | } | 3144 | } |
3146 | 3145 | ||
3147 | len = strlen(dir); | 3146 | len = strlen(dir); |
3148 | if (len >= 2 && has_dos_drive_prefix(dir)) | 3147 | if (len >= 2 && has_dos_drive_prefix(dir)) |
3149 | target = len >= 3 && is_path_sep(dir[2]) ? ABS_DRIVE : REL_OTHER; | 3148 | target = len >= 3 && is_dir_sep(dir[2]) ? ABS_DRIVE : REL_OTHER; |
3150 | else if (unc_root_len(dir) != 0) | 3149 | else if (unc_root_len(dir) != 0) |
3151 | target = ABS_SHARE; | 3150 | target = ABS_SHARE; |
3152 | else if (is_path_sep(*dir)) | 3151 | else if (is_dir_sep(*dir)) |
3153 | target = REL_ROOT; | 3152 | target = REL_ROOT; |
3154 | else | 3153 | else |
3155 | target = REL_CWD; | 3154 | target = REL_CWD; |
@@ -3190,15 +3189,15 @@ updatepwd(const char *dir) | |||
3190 | new = makestrspace(strlen(dir) + 2, new); | 3189 | new = makestrspace(strlen(dir) + 2, new); |
3191 | lim = (char *)stackblock() + len + 1; | 3190 | lim = (char *)stackblock() + len + 1; |
3192 | 3191 | ||
3193 | if (!is_path_sep(*dir)) { | 3192 | if (!is_dir_sep(*dir)) { |
3194 | if (!is_path_sep(new[-1])) | 3193 | if (!is_dir_sep(new[-1])) |
3195 | USTPUTC('/', new); | 3194 | USTPUTC('/', new); |
3196 | if (new > lim && is_path_sep(*lim)) | 3195 | if (new > lim && is_dir_sep(*lim)) |
3197 | lim++; | 3196 | lim++; |
3198 | } else { | 3197 | } else { |
3199 | USTPUTC('/', new); | 3198 | USTPUTC('/', new); |
3200 | cdcomppath++; | 3199 | cdcomppath++; |
3201 | if (is_path_sep(dir[1]) && !is_path_sep(dir[2])) { | 3200 | if (is_dir_sep(dir[1]) && !is_dir_sep(dir[2])) { |
3202 | USTPUTC('/', new); | 3201 | USTPUTC('/', new); |
3203 | cdcomppath++; | 3202 | cdcomppath++; |
3204 | lim++; | 3203 | lim++; |
@@ -3211,7 +3210,7 @@ updatepwd(const char *dir) | |||
3211 | if (p[1] == '.' && p[2] == '\0') { | 3210 | if (p[1] == '.' && p[2] == '\0') { |
3212 | while (new > lim) { | 3211 | while (new > lim) { |
3213 | STUNPUTC(new); | 3212 | STUNPUTC(new); |
3214 | if (is_path_sep(new[-1])) | 3213 | if (is_dir_sep(new[-1])) |
3215 | break; | 3214 | break; |
3216 | } | 3215 | } |
3217 | break; | 3216 | break; |
diff --git a/win32/mingw.c b/win32/mingw.c index b8dd6a511..f4ae60d41 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1874,9 +1874,8 @@ void hide_console(void) | |||
1874 | } | 1874 | } |
1875 | #endif | 1875 | #endif |
1876 | 1876 | ||
1877 | #define is_path_sep(x) ((x) == '/' || (x) == '\\') | 1877 | #define is_unc_path(x) (strlen(x) > 4 && is_dir_sep(x[0]) && \ |
1878 | #define is_unc_path(x) (strlen(x) > 4 && is_path_sep(x[0]) && \ | 1878 | is_dir_sep(x[1]) && !is_dir_sep(x[2])) |
1879 | is_path_sep(x[1]) && !is_path_sep(x[2])) | ||
1880 | 1879 | ||
1881 | /* Return the length of the root of a UNC path, i.e. the '//host/share' | 1880 | /* Return the length of the root of a UNC path, i.e. the '//host/share' |
1882 | * component, or 0 if the path doesn't look like that. */ | 1881 | * component, or 0 if the path doesn't look like that. */ |
@@ -2009,7 +2008,7 @@ void fix_path_case(char *path) | |||
2009 | *path = toupper(*path); | 2008 | *path = toupper(*path); |
2010 | } | 2009 | } |
2011 | else if (len != 0) { | 2010 | else if (len != 0) { |
2012 | for (path+=2; !is_path_sep(*path); ++path) { | 2011 | for (path+=2; !is_dir_sep(*path); ++path) { |
2013 | *path = toupper(*path); | 2012 | *path = toupper(*path); |
2014 | } | 2013 | } |
2015 | } | 2014 | } |