aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-18 19:57:54 +0000
committerRon Yorston <rmy@pobox.com>2018-03-18 19:57:54 +0000
commit411d8b4cf9887c108853a25388837c1aaf31edce (patch)
treebd88371b4720d19fe08209a800c8576d46fa44fd
parent2cbc61ac77a4e661ad97143c3f53db55506d8349 (diff)
downloadbusybox-w32-411d8b4cf9887c108853a25388837c1aaf31edce.tar.gz
busybox-w32-411d8b4cf9887c108853a25388837c1aaf31edce.tar.bz2
busybox-w32-411d8b4cf9887c108853a25388837c1aaf31edce.zip
win32: add a function to convert backslashes to slashes
-rw-r--r--include/mingw.h3
-rw-r--r--libbb/make_directory.c6
-rw-r--r--shell/ash.c8
-rw-r--r--win32/mingw.c25
4 files changed, 18 insertions, 24 deletions
diff --git a/include/mingw.h b/include/mingw.h
index 386540b37..a54a6ac85 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -442,8 +442,6 @@ const char * next_path_sep(const char *path);
442 * helpers 442 * helpers
443 */ 443 */
444 444
445char **env_setenv(char **env, const char *name);
446
447const char *get_busybox_exec_path(void); 445const char *get_busybox_exec_path(void);
448void init_winsock(void); 446void init_winsock(void);
449 447
@@ -451,6 +449,7 @@ int has_bat_suffix(const char *p);
451int has_exe_suffix(const char *p); 449int has_exe_suffix(const char *p);
452int has_exe_suffix_or_dot(const char *name); 450int has_exe_suffix_or_dot(const char *name);
453char *add_win32_extension(const char *p); 451char *add_win32_extension(const char *p);
452void FAST_FUNC convert_slashes(char *p);
454 453
455int err_win_to_posix(DWORD winerr); 454int err_win_to_posix(DWORD winerr);
456 455
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 1f3aecf40..ef0a8acd8 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -51,11 +51,7 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
51 org_mask = cur_mask = (mode_t)-1L; 51 org_mask = cur_mask = (mode_t)-1L;
52#if ENABLE_PLATFORM_MINGW32 52#if ENABLE_PLATFORM_MINGW32
53 /* normalise path separators, path is already assumed writable */ 53 /* normalise path separators, path is already assumed writable */
54 for (s=path; *s; ++s) { 54 convert_slashes(path);
55 if (*s == '\\') {
56 *s = '/';
57 }
58 }
59#endif 55#endif
60 s = path; 56 s = path;
61 while (1) { 57 while (1) {
diff --git a/shell/ash.c b/shell/ash.c
index 778d8bd9d..c7c514417 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14430,7 +14430,7 @@ init(void)
14430 * variable called something other than PATH. This suggests we 14430 * variable called something other than PATH. This suggests we
14431 * haven't been invoked from an earlier instance of BusyBox. 14431 * haven't been invoked from an earlier instance of BusyBox.
14432 */ 14432 */
14433 char *start, *end, *s; 14433 char *start, *end;
14434 struct passwd *pw; 14434 struct passwd *pw;
14435 14435
14436 for (envp = environ; envp && *envp; envp++) { 14436 for (envp = environ; envp && *envp; envp++) {
@@ -14449,11 +14449,7 @@ init(void)
14449 14449
14450 /* convert backslashes to forward slashes in value */ 14450 /* convert backslashes to forward slashes in value */
14451 if (!xp) { 14451 if (!xp) {
14452 for ( s=end+1; *s; ++s ) { 14452 convert_slashes(end+1);
14453 if ( *s == '\\' ) {
14454 *s = '/';
14455 }
14456 }
14457 } 14453 }
14458 14454
14459 /* check for invalid characters in name */ 14455 /* check for invalid characters in name */
diff --git a/win32/mingw.c b/win32/mingw.c
index ee549c311..112b2a54e 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -665,13 +665,10 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
665#undef getcwd 665#undef getcwd
666char *mingw_getcwd(char *pointer, int len) 666char *mingw_getcwd(char *pointer, int len)
667{ 667{
668 int i;
669 char *ret = getcwd(pointer, len); 668 char *ret = getcwd(pointer, len);
670 if (!ret) 669 if (!ret)
671 return ret; 670 return ret;
672 for (i = 0; ret[i]; i++) 671 convert_slashes(ret);
673 if (ret[i] == '\\')
674 ret[i] = '/';
675 return ret; 672 return ret;
676} 673}
677 674
@@ -714,7 +711,6 @@ static char *gethomedir(void)
714 static char *buf = NULL; 711 static char *buf = NULL;
715 DWORD len = PATH_MAX; 712 DWORD len = PATH_MAX;
716 HANDLE h; 713 HANDLE h;
717 char *s;
718 714
719 if (!buf) 715 if (!buf)
720 buf = xmalloc(PATH_MAX); 716 buf = xmalloc(PATH_MAX);
@@ -730,11 +726,7 @@ static char *gethomedir(void)
730 726
731 CloseHandle(h); 727 CloseHandle(h);
732 728
733 for ( s=buf; *s; ++s ) { 729 convert_slashes(buf);
734 if ( *s == '\\' ) {
735 *s = '/';
736 }
737 }
738 730
739 return buf; 731 return buf;
740} 732}
@@ -908,8 +900,10 @@ const char *get_busybox_exec_path(void)
908 path[0] = '\0'; 900 path[0] = '\0';
909 } 901 }
910 902
911 if (!*path) 903 if (!*path) {
912 GetModuleFileName(NULL, path, PATH_MAX); 904 GetModuleFileName(NULL, path, PATH_MAX);
905 convert_slashes(path);
906 }
913 return path; 907 return path;
914} 908}
915 909
@@ -1174,6 +1168,15 @@ char *add_win32_extension(const char *p)
1174 return NULL; 1168 return NULL;
1175} 1169}
1176 1170
1171void FAST_FUNC convert_slashes(char *p)
1172{
1173 for (; *p; ++p) {
1174 if ( *p == '\\' ) {
1175 *p = '/';
1176 }
1177 }
1178}
1179
1177#undef opendir 1180#undef opendir
1178DIR *mingw_opendir(const char *path) 1181DIR *mingw_opendir(const char *path)
1179{ 1182{