aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Winston2024-05-23 21:42:25 -0400
committerBen Winston2024-05-23 21:42:25 -0400
commit82126d94b6e08321a44c5d10dd927daa3cd73653 (patch)
tree048a064754ff9fd255199e45deaedf22fb381f5f
parentae8913bfd92ad4eaaa7bfcf2b2819277568faa59 (diff)
bugfix: only open temp file when editing
-rw-r--r--booki.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/booki.c b/booki.c
index a1215ec..7f462eb 100644
--- a/booki.c
+++ b/booki.c
@@ -480,7 +480,9 @@ char** search(int argc, char* argv[], char* booki_file) {
return NULL;
}
- FILE *output = fopen(EDIT_FILE, "w");
+ FILE *output = NULL;
+ if (search_opts.edit)
+ output = fopen(EDIT_FILE, "w");
// book loop
struct Book books[MAX_BOOKS];
@@ -537,7 +539,8 @@ char** search(int argc, char* argv[], char* booki_file) {
}
free(data);
- fclose(output);
+ if (output)
+ fclose(output);
if (search_opts.edit)
open(EDIT_FILE);