From 4977be1b1896ed12ab59f0daa6b0d47a69ab8761 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 14 Jan 2022 15:39:37 -0500 Subject: Fix windows --- main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 5b6bd52..0a3c8b7 100644 --- a/main.c +++ b/main.c @@ -168,13 +168,16 @@ int edit_file(const char *filename) { // Allow the user to override the default editor (vi/notepad) user_editor = getenv("EDITOR"); + char *editor_path; if (user_editor != NULL) { - strcpy(editor, find_program(user_editor)); + editor_path = find_program(user_editor); + if (editor_path != NULL) { + sprintf(editor, "\"%s\"", editor_path); + } } else { - char *editor_path; editor_path = find_program("vim"); if (editor_path != NULL) { - strcpy(editor, editor_path); + sprintf(editor, "\"%s\"", editor_path); } #if HAVE_WINDOWS else { @@ -183,7 +186,7 @@ int edit_file(const char *filename) { #endif } - if (!find_program(editor)) { + if (!strlen(editor)) { fprintf(stderr, "Unable to find editor: %s\n", editor); exit(1); } -- cgit