diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-25 19:24:58 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-25 19:24:58 +0000 |
| commit | 555141e35166c7f7d98c16f6f95fde8e57a651c2 (patch) | |
| tree | e5cce20d7692b2ba99e68ed46ae545ea8923b94c /src/repl/repl.c | |
| parent | d5ad18ff3b97515c12a35f00d940e62bb34b7401 (diff) | |
Implement runtime OS detection and automatic versioningv0.1.2
Diffstat (limited to 'src/repl/repl.c')
| -rw-r--r-- | src/repl/repl.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/repl/repl.c b/src/repl/repl.c index 274c14c..cb63293 100644 --- a/src/repl/repl.c +++ b/src/repl/repl.c @@ -28,12 +28,10 @@ void run_repl(const char *self_path) char history_path[512]; const char *home = getenv("HOME"); -#ifdef _WIN32 - if (!home) + if (z_is_windows() && !home) { home = getenv("USERPROFILE"); } -#endif if (home) { snprintf(history_path, sizeof(history_path), "%s/.zprep_history", home); @@ -273,10 +271,14 @@ void run_repl(const char *self_path) { tmpdir = getenv("TMP"); } - if (!tmpdir) + if (!tmpdir && !z_is_windows()) { tmpdir = "/tmp"; } + if (!tmpdir) + { + tmpdir = "."; + } snprintf(edit_path, sizeof(edit_path), "%s/zprep_edit_%d.zc", tmpdir, rand()); FILE *f = fopen(edit_path, "w"); if (f) @@ -658,10 +660,14 @@ void run_repl(const char *self_path) { tmpdir = getenv("TMP"); } - if (!tmpdir) + if (!tmpdir && !z_is_windows()) { tmpdir = "/tmp"; } + if (!tmpdir) + { + tmpdir = "."; + } snprintf(tmp_path, sizeof(tmp_path), "%s/zprep_repl_type_%d.zc", tmpdir, rand()); FILE *f = fopen(tmp_path, "w"); @@ -752,10 +758,14 @@ void run_repl(const char *self_path) { tmpdir = getenv("TMP"); } - if (!tmpdir) + if (!tmpdir && !z_is_windows()) { tmpdir = "/tmp"; } + if (!tmpdir) + { + tmpdir = "."; + } snprintf(tmp_path, sizeof(tmp_path), "%s/zprep_repl_time_%d.zc", tmpdir, rand()); FILE *f = fopen(tmp_path, "w"); |
