Skip to content

Commit 59cdf93

Browse files
committed
SDL: fix HOME path variable for Win32
1 parent 092a2fc commit 59cdf93

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2020-02-13 (0.12.18)
2+
Fix path for HOME constant
3+
14
2020-02-08 (0.12.18)
25
SDL: fix issue #81 - numlock handling
36
FLTK: added live editing menu item

src/common/brun.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,14 @@ void exec_setup_predefined_variables() {
272272
if (getenv("HOME_DIR")) {
273273
strlcpy(homedir, getenv("HOME_DIR"), sizeof(homedir));
274274
}
275-
#else
276-
#if defined(_Win32)
275+
#elif defined(_Win32)
277276
if (getenv("HOMEPATH")) {
278-
strlcpy(homedir, getenv("HOMEPATH"), sizeof(homedir));
277+
if (getenv("HOMEDRIVE")) {
278+
strlcpy(homedir, getenv("HOMEDRIVE"), sizeof(homedir));
279+
strlcat(homedir, getenv("HOMEPATH"), sizeof(homedir));
280+
} else {
281+
strlcpy(homedir, getenv("HOMEPATH"), sizeof(homedir));
282+
}
279283
} else {
280284
GetModuleFileName(NULL, homedir, sizeof(homedir) - 1);
281285
char *p = strrchr(homedir, '\\');
@@ -295,12 +299,11 @@ void exec_setup_predefined_variables() {
295299
strcpy(homedir, "/tmp/");
296300
}
297301
#endif
302+
// don't end with trailing slash
298303
int l = strlen(homedir);
299-
if (homedir[l - 1] != OS_DIRSEP) {
300-
homedir[l] = OS_DIRSEP;
301-
homedir[l + 1] = '\0';
304+
if (homedir[l - 1] == OS_DIRSEP) {
305+
homedir[l - 1] = '\0';
302306
}
303-
#endif
304307
setsysvar_str(SYSVAR_HOME, homedir);
305308
}
306309

src/common/proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ int sys_search_path(const char *path, const char *file, char *retbuf) {
6767
if (getenv("HOME")) {
6868
strlcpy(cur_path, getenv("HOME"), sizeof(cur_path));
6969
} else {
70-
strlcpy(cur_path, getenv("HOMEPATH"), sizeof(cur_path));
70+
strlcpy(cur_path, getenv("HOMEDRIVE"), sizeof(cur_path));
71+
strlcat(cur_path, getenv("HOMEPATH"), sizeof(cur_path));
7172
}
7273
strlcat(cur_path, "/", sizeof(cur_path));
7374
strlcat(cur_path, old_path, sizeof(cur_path));

src/platform/android/app/src/main/assets/main.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ func mk_scratch()
7373
result = true
7474
catch e
7575
local wnd = window()
76-
wnd.alert("Failed to create scratch file: " + e)
76+
logprint e
77+
wnd.alert("Failed to create: " + scratch_file)
7778
end try
7879
else
7980
result = true

0 commit comments

Comments
 (0)