Files
MINGW-packages/mingw-w64-clink-git/0001-Relocation.patch
2015-03-10 23:14:47 +01:00

144 lines
4.3 KiB
Diff

From dc7df971d8acf85c30263c9c267add272a5a3b3d Mon Sep 17 00:00:00 2001
From: David Macek <david.macek.0@gmail.com>
Date: Tue, 10 Mar 2015 02:11:40 +0100
Subject: [PATCH] Relocation
---
clink/dll/lua.c | 1 +
clink/dll/rl_env.c | 2 +-
clink/loader/clink.bat | 18 ++++++++++++------
clink/shared/paths.c | 46 ++++++++++++++++++++++++++--------------------
4 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/clink/dll/lua.c b/clink/dll/lua.c
index f734870..b0d94b9 100644
--- a/clink/dll/lua.c
+++ b/clink/dll/lua.c
@@ -699,6 +699,7 @@ lua_State* initialise_lua()
if (g_inject_args.script_path[0] == '\0')
{
get_dll_dir(buffer, sizeof_array(buffer));
+ str_cat(buffer, "/../share/clink", sizeof_array(buffer));
}
else
{
diff --git a/clink/dll/rl_env.c b/clink/dll/rl_env.c
index 41c527c..fb35bb5 100644
--- a/clink/dll/rl_env.c
+++ b/clink/dll/rl_env.c
@@ -142,7 +142,7 @@ void prepare_env_for_inputrc()
strcpy(buffer, inputrc_eq);
get_dll_dir(buffer + size - 1, sizeof_array(buffer) - size);
- str_cat(buffer, "/clink_inputrc_base", sizeof_array(buffer));
+ str_cat(buffer, "/../share/clink/clink_inputrc_base", sizeof_array(buffer));
putenv(buffer);
}
diff --git a/clink/loader/clink.bat b/clink/loader/clink.bat
index 1cafb84..cd0a524 100644
--- a/clink/loader/clink.bat
+++ b/clink/loader/clink.bat
@@ -58,16 +58,22 @@ goto :eof
:: Helper functions to avoid cmd.exe's issues with brackets.
:loader_x86
-if exist "%~dpn0_x86.exe" (
- "%~dpn0_x86.exe" %*
+if exist "%~dp0../../mingw32/bin/%~n0_x86.exe" (
+ "%~dp0../../mingw32/bin/%~n0_x86.exe" %*
+ exit /b 0
+) else (
+ echo Cannot find "%~dp0../../mingw32/bin/%~n0_x86.exe" >&2
+ exit /b 1
)
-exit /b 0
:loader_x64
-if exist "%~dpn0_x64.exe" (
- "%~dpn0_x64.exe" %*
+if exist "%~dp0../../mingw64/bin/%~n0_x64.exe" (
+ "%~dp0../../mingw64/bin/%~n0_x64.exe" %*
+ exit /b 0
+) else (
+ echo Cannot find "%~dp0../../mingw64/bin/%~n0_x64.exe" >&2
+ exit /b 1
)
-exit /b 0
:launch
start "" cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg% && title Clink"
diff --git a/clink/shared/paths.c b/clink/shared/paths.c
index 35bec17..4d278c7 100644
--- a/clink/shared/paths.c
+++ b/clink/shared/paths.c
@@ -74,18 +74,34 @@ void get_dll_dir(char* buffer, int size)
void get_config_dir(char* buffer, int size)
{
static int once = 1;
+ static char conf_dir[MAX_PATH] = { 1 };
- // Maybe the user specified an alternative location?
- if (g_config_dir_override != NULL)
+ // Just the once, get user's conf folder.
+ if (conf_dir[0] == 1)
{
- str_cpy(buffer, g_config_dir_override, size);
- }
- else
- {
- get_dll_dir(buffer, size);
- str_cat(buffer, ".\\profile", size);
+ // Maybe the user specified an alternative location?
+ if (g_config_dir_override != NULL)
+ {
+ str_cpy(conf_dir, g_config_dir_override, sizeof_array(conf_dir));
+ }
+ else
+ {
+ const char* str;
+ if ((str = getenv("USERPROFILE")) != NULL)
+ {
+ str_cpy(conf_dir, str, sizeof_array(conf_dir));
+ str_cat(conf_dir, "/.clink", sizeof_array(conf_dir));
+ }
+ else
+ {
+ GetTempPath(sizeof_array(conf_dir), conf_dir);
+ str_cat(conf_dir, "./clink", sizeof_array(conf_dir));
+ }
+ }
}
+ str_cpy(buffer, conf_dir, size);
+
// Try and create the directory if it doesn't already exist. Just this once.
if (once)
{
@@ -108,20 +124,10 @@ void get_log_dir(char* buffer, int size)
static once = 1;
static char log_dir[MAX_PATH] = { 1 };
- // Just the once, get user's appdata folder.
+ // Just the once, get user's temp folder.
if (log_dir[0] == 1)
{
- if (SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, NULL, 0, log_dir) != S_OK)
- {
- const char* str;
- if ((str = getenv("USERPROFILE")) == NULL)
- {
- GetTempPath(sizeof_array(log_dir), log_dir);
- }
-
- str_cpy(log_dir, str, sizeof_array(log_dir));
- }
-
+ GetTempPath(sizeof_array(log_dir), log_dir);
str_cat(log_dir, "./clink", sizeof_array(log_dir));
}
--
1.9.4.msysgit.2