diff options
| author | WormHeamer | 2026-01-02 20:41:09 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-02 20:41:09 -0500 |
| commit | ffb3f1f3915484504e6136a4f028355e72947f8b (patch) | |
| tree | 06823316ad57db0300080e2c79f70c9d6eb24fd4 | |
| parent | 7b0cba02d9266eeb71d3ca095afc25ceb1a79e12 (diff) | |
take an arena parameter in normalize_path()
| -rw-r--r-- | main.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -82,11 +82,11 @@ Editor e = { 0 }; int ed_buf_shell_replace(Editor *e, u32 bufi, TxtLoc start, TxtLoc end, const char *cmd); -static Str normalize_path(Str s); +static Str normalize_path(Str s, Arena *a); int ed_buf_open(Editor *e, const char *path) { Str paths = { 0 }; if (path) { - paths = normalize_path(str_from_cstr(path)); + paths = normalize_path(str_from_cstr(path), &e->scratch); for (u32 i = 0; i < e->bufn; i++) { if (str_eql(e->buf[i].path, paths)) return i; } @@ -1034,11 +1034,11 @@ TxtLoc ins_newline(TxtLoc l) { return l; } -static Str normalize_path(Str s) { - Arena m = e.scratch; - char *p = realpath(str_to_cstr(s, &e.scratch), NULL); - e.scratch = m; - s = str_dup(str_from_cstr(p), &e.scratch); +static Str normalize_path(Str s, Arena *a) { + Arena m = *a; + char *p = realpath(str_to_cstr(s, a), NULL); + *a = m; + s = str_dup(str_from_cstr(p), a); free(p); return s; } @@ -1052,7 +1052,7 @@ static void build_file(Str path, int debugp) { #define WED_DEV_EXE WED_DEV_DIR "wed" int is_wed_path(Str path) { - return str_starts(normalize_path(path), S(WED_DEV_DIR)); + return str_starts(path, S(WED_DEV_DIR)); } void str_cat_u32(Str *out, u32 c, Arena *a) { @@ -1113,7 +1113,6 @@ int parse_edit_args(Editor *e, int argc, const char **argv) { } static void run_file(Str path, int debugp) { - path = normalize_path(path); if (is_wed_path(path)) { vui_disable(); if (system(debugp ? "make DEBUG=1" : "make")) { @@ -1348,7 +1347,7 @@ again:; Str s = str_from_cstr(path); str_catc(&s, '/', &e.scratch); str_cat(&s, opt.v[o], &e.scratch); - s = normalize_path(s); + s = normalize_path(s, &e.scratch); e.perm = perm; path = str_to_cstr(s, &e.scratch); @@ -1368,7 +1367,7 @@ Str select_file(void) { if (eb->type == ED_BUF_FILE || eb->type == ED_BUF_BIN_FILE) { path = dirname(eb->path); } else { - path = normalize_path(S(".")); + path = normalize_path(S("."), &e.scratch); } Str s = select_file_in(str_to_cstr(path, &e.scratch)); return s; |
