diff options
Diffstat (limited to 'main.c')
| -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; |
