From 555141e35166c7f7d98c16f6f95fde8e57a651c2 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Sun, 25 Jan 2026 19:24:58 +0000 Subject: Implement runtime OS detection and automatic versioning --- src/repl/repl.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/repl') 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"); -- cgit v1.2.3