depot/third_party/nixpkgs/pkgs/games/gimx/env.patch
Default email ae91cbe6cc Project import generated by Copybara.
GitOrigin-RevId: 536fe36e23ab0fc8b7f35c24603422eee9fc17a2
2021-02-05 18:12:51 +01:00

30 lines
1.1 KiB
Diff

--- a/core/config_reader.c
+++ b/core/config_reader.c
@@ -1353,8 +1353,10 @@ static int read_file(char* file_path)
int read_config_file(const char* file)
{
char file_path[PATH_MAX];
-
- snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file);
+ char* e = getenv("GIMXCONF"); if (e) { snprintf(file_path, sizeof(file_path), "%s/%s", e, file); }
+ else {
+ snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file);
+ }
if(read_file(file_path) == -1)
{
--- a/core/gimx.c
+++ b/core/gimx.c
@@ -190,8 +190,10 @@ void show_config()
}
char file_path[PATH_MAX];
-
- snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, gimx_params.config_file);
+ char* e = getenv("GIMXCONF"); if (e) { snprintf(file_path, sizeof(file_path), "%s/%s", e, gimx_params.config_file); }
+ else {
+ snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, gimx_params.config_file);
+ }
FILE * fp = gfile_fopen(file_path, "r");
if (fp == NULL)