diff options
| author | iryuken <eshwarsajja20@gmail.com> | 2026-01-25 23:57:07 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-25 23:57:07 +0530 |
| commit | a2804ffe502ec31fc3bf561b7e59c25622b15e19 (patch) | |
| tree | 3fb732563d6a282e010bca2d3acb97eb351c925f /src/repl | |
| parent | 123a961710aab45f30367cb8faa2c8ce00e49bdb (diff) | |
| parent | e3ab29bb4d7174cae65de2275f19105eb3d93d91 (diff) | |
Merge branch 'z-libs:main' into main
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) { |
