diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-25 18:24:05 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-25 18:24:05 +0000 |
| commit | e3ab29bb4d7174cae65de2275f19105eb3d93d91 (patch) | |
| tree | 89970111c1be4c3ddd291b720d4fdf496f10b2d5 /src/repl | |
| parent | 489336b2101bf16edeec7bfc4379408eb19b936e (diff) | |
APE shall never kill APE
Diffstat (limited to 'src/repl')
| -rw-r--r-- | src/repl/repl.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/repl/repl.c b/src/repl/repl.c index 22fe95d..274c14c 100644 --- a/src/repl/repl.c +++ b/src/repl/repl.c @@ -28,6 +28,12 @@ void run_repl(const char *self_path) char history_path[512]; const char *home = getenv("HOME"); +#ifdef _WIN32 + if (!home) + { + home = getenv("USERPROFILE"); + } +#endif if (home) { snprintf(history_path, sizeof(history_path), "%s/.zprep_history", home); @@ -262,7 +268,16 @@ void run_repl(const char *self_path) } char edit_path[256]; - sprintf(edit_path, "/tmp/zprep_edit_%d.zc", rand()); + const char *tmpdir = getenv("TEMP"); + if (!tmpdir) + { + tmpdir = getenv("TMP"); + } + if (!tmpdir) + { + tmpdir = "/tmp"; + } + snprintf(edit_path, sizeof(edit_path), "%s/zprep_edit_%d.zc", tmpdir, rand()); FILE *f = fopen(edit_path, "w"); if (f) { @@ -638,7 +653,17 @@ void run_repl(const char *self_path) strcat(probe_code, "); }"); char tmp_path[256]; - sprintf(tmp_path, "/tmp/zprep_repl_type_%d.zc", rand()); + const char *tmpdir = getenv("TEMP"); + if (!tmpdir) + { + tmpdir = getenv("TMP"); + } + if (!tmpdir) + { + tmpdir = "/tmp"; + } + snprintf(tmp_path, sizeof(tmp_path), "%s/zprep_repl_type_%d.zc", tmpdir, + rand()); FILE *f = fopen(tmp_path, "w"); if (f) { @@ -722,7 +747,17 @@ void run_repl(const char *self_path) strcat(code, "}"); char tmp_path[256]; - sprintf(tmp_path, "/tmp/zprep_repl_time_%d.zc", rand()); + const char *tmpdir = getenv("TEMP"); + if (!tmpdir) + { + tmpdir = getenv("TMP"); + } + if (!tmpdir) + { + tmpdir = "/tmp"; + } + snprintf(tmp_path, sizeof(tmp_path), "%s/zprep_repl_time_%d.zc", tmpdir, + rand()); FILE *f = fopen(tmp_path, "w"); if (f) { |
