From 923f8f78751533ea0ab29eb79225f79eedf5952c Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Tue, 22 Nov 2022 20:38:42 -0800 Subject: [PATCH] Fix SQLite home directory discovery on Windows (reapply 29cb5388) See #193 --- third_party/sqlite3/shell.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/third_party/sqlite3/shell.c b/third_party/sqlite3/shell.c index 36852ccf8..54d60b412 100644 --- a/third_party/sqlite3/shell.c +++ b/third_party/sqlite3/shell.c @@ -11178,7 +11178,8 @@ static char *find_home_dir(int clearFlag){ } if( home_dir ) return home_dir; -#if 0 && !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \ +#if 0 +#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \ && !defined(__RTP__) && !defined(_WRS_KERNEL) { struct passwd *pwent; @@ -11188,6 +11189,7 @@ static char *find_home_dir(int clearFlag){ } } #endif +#endif #if defined(_WIN32_WCE) /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv() @@ -11195,18 +11197,15 @@ static char *find_home_dir(int clearFlag){ home_dir = "/"; #else -#if defined(_WIN32) || defined(WIN32) - if (!home_dir) { + if (IsWindows() && !home_dir) { home_dir = getenv("USERPROFILE"); } -#endif if (!home_dir) { home_dir = getenv("HOME"); } -#if defined(_WIN32) || defined(WIN32) - if (!home_dir) { + if (IsWindows() && !home_dir) { char *zDrive, *zPath; int n; zDrive = getenv("HOMEDRIVE"); @@ -11220,7 +11219,6 @@ static char *find_home_dir(int clearFlag){ } home_dir = "c:\\"; } -#endif #endif /* !_WIN32_WCE */