File tree Expand file tree Collapse file tree 4 files changed +9
-14
lines changed Expand file tree Collapse file tree 4 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -781,7 +781,8 @@ void join_path(char *path, char *ext) {
781781 int len = strlen (path );
782782 if (path [len - 1 ] != OS_DIRSEP ) {
783783 if (ext [0 ] != OS_DIRSEP ) {
784- strcat (path , "/" );
784+ char ch [] = {OS_DIRSEP , '\0' };
785+ strcat (path , ch );
785786 strcat (path , ext );
786787 } else {
787788 strcat (path , ext );
@@ -793,6 +794,11 @@ void join_path(char *path, char *ext) {
793794 strcat (path , ext + 1 );
794795 }
795796 }
797+ // don't end with trailing slash
798+ len = strlen (path );
799+ if (path [len - 1 ] == OS_DIRSEP ) {
800+ path [len - 1 ] = '\0' ;
801+ }
796802}
797803
798804/*
Original file line number Diff line number Diff line change @@ -287,11 +287,6 @@ void exec_setup_predefined_variables() {
287287 * p = '\0' ;
288288 }
289289 }
290- for (char * p = homedir ; * p ; p ++ ) {
291- if (* p == '\\' ) {
292- * p = '/' ;
293- }
294- }
295290#elif defined(_UnixOS )
296291 if (getenv ("HOME" )) {
297292 strlcpy (homedir , getenv ("HOME" ), sizeof (homedir ));
Original file line number Diff line number Diff line change @@ -674,13 +674,6 @@ char *dev_getcwd() {
674674 retbuf [l ] = OS_DIRSEP ;
675675 retbuf [l + 1 ] = '\0' ;
676676 }
677- #if defined(_Win32 )
678- for (int i = 0 ; i < l ; i ++ ) {
679- if (retbuf [i ] == '\\' ) {
680- retbuf [i ] = OS_DIRSEP ;
681- }
682- }
683- #endif
684677 return retbuf ;
685678}
686679
Original file line number Diff line number Diff line change @@ -50,14 +50,15 @@ extern "C" {
5050#define OS_PATHNAME_SIZE 1024
5151#define OS_FILENAME_SIZE 256
5252#define OS_FILEHANDLES 256
53- #define OS_DIRSEP '/'
5453
5554#if defined(_Win32 )
5655 #define SB_VERSYS "Win"
5756 #define OS_LINESEPARATOR "\r\n"
57+ #define OS_DIRSEP '\\'
5858#else
5959 #define SB_VERSYS "Unix"
6060 #define OS_LINESEPARATOR "\n"
61+ #define OS_DIRSEP '/'
6162#endif
6263
6364#define STRLEN (s ) ((sizeof(s) / sizeof(s[0])) - 1)
You can’t perform that action at this time.
0 commit comments