Skip to content

Commit 6a1e00d

Browse files
committed
Bugfix for DIRWALK shows inconsistend path separator in Windows
1 parent 2c14c1b commit 6a1e00d

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

src/common/blib_db.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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
/*

src/common/brun.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff 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));

src/common/file.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff 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

src/common/sys.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)