From 578e943afcd9c818f969502a94375b1a70548bf9 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 23 Mar 2019 08:38:21 +0000 Subject: win32: share code to find root prefix of path Move unc_root_len() from ash to mingw32.c and use it in the new function root_len(), which can be used in make_directory(). This reduces changes to upstream code and saves a few bytes. --- shell/ash.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index cd6196640..34ddc14f1 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -2860,34 +2860,6 @@ cdopt(void) return flags; } -#if ENABLE_PLATFORM_MINGW32 -#define is_path_sep(x) ((x) == '/' || (x) == '\\') -#define is_unc_path(x) (is_path_sep(x[0]) && is_path_sep(x[1])) -#define is_root(x) (is_path_sep(x[0]) && x[1] == '\0') - -/* Return the length of the root of a UNC path, i.e. the '//host/share' - * component, or 0 if the path doesn't look like that. */ -static int -unc_root_len(const char *dir) -{ - const char *s = dir + 2; - int len; - - if (!is_unc_path(dir)) - return 0; - len = strcspn(s, "/\\"); - if (len == 0) - return 0; - s += len + 1; - len = strcspn(s, "/\\"); - if (len == 0) - return 0; - s += len; - - return s - dir; -} -#endif - /* * Update curdir (the name of the current directory) in response to a * cd command. @@ -2896,6 +2868,8 @@ static const char * updatepwd(const char *dir) { #if ENABLE_PLATFORM_MINGW32 +# define is_path_sep(x) ((x) == '/' || (x) == '\\') +# define is_root(x) (is_path_sep(x[0]) && x[1] == '\0') /* * Due to Windows drive notion, getting pwd is a completely * different thing. Handle it in a separate routine -- cgit v1.2.3-55-g6feb