From 8a056d9eb63290daa521cbe31bea88d10999ca9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E4=BA=91?= <71159641+littlewhitecloud@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:06:38 +0800 Subject: [PATCH 1/5] emm --- src/output.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/output.c b/src/output.c index aa6f40ad..4b3421f5 100644 --- a/src/output.c +++ b/src/output.c @@ -7,6 +7,7 @@ #endif #include "jou_compiler.h" +#include #include #include #include @@ -103,6 +104,16 @@ static void mkdir_exist_ok(const char *p) exit(1); } +static void write_gitinore(const char *p) +{ + char *filename = malloc_sprintf("%s/.gitinore", p); + if (access(filename, F_OK)) + return; + FILE *gitinore = fopen(filename, "w"); + fprintf(gitinore, "*"); + fclose(gitinore); +} + static char *get_path_to_file_in_jou_compiled(const char *filename) { /* @@ -120,6 +131,7 @@ static char *get_path_to_file_in_jou_compiled(const char *filename) // path1 is known to exist mkdir_exist_ok(path2); + write_gitinore(path2); mkdir_exist_ok(path3); free(path1); free(path2); From dbbea314980daa0e9366dd265535437841fcb8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E4=BA=91?= <71159641+littlewhitecloud@users.noreply.github.com> Date: Sat, 9 Dec 2023 18:45:48 +0800 Subject: [PATCH 2/5] free --- src/output.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/output.c b/src/output.c index 4b3421f5..fb75a9d4 100644 --- a/src/output.c +++ b/src/output.c @@ -111,7 +111,9 @@ static void write_gitinore(const char *p) return; FILE *gitinore = fopen(filename, "w"); fprintf(gitinore, "*"); + fclose(gitinore); + free(filename); } static char *get_path_to_file_in_jou_compiled(const char *filename) From 8b80382ad036d41bbdca24e24ba6e3470b2119c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E4=BA=91?= <71159641+littlewhitecloud@users.noreply.github.com> Date: Sat, 9 Dec 2023 19:07:46 +0800 Subject: [PATCH 3/5] my fault --- src/output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index fb75a9d4..2264dfed 100644 --- a/src/output.c +++ b/src/output.c @@ -107,8 +107,10 @@ static void mkdir_exist_ok(const char *p) static void write_gitinore(const char *p) { char *filename = malloc_sprintf("%s/.gitinore", p); - if (access(filename, F_OK)) + if (access(filename, F_OK)) { + free(filename); return; + } FILE *gitinore = fopen(filename, "w"); fprintf(gitinore, "*"); From 822af4cd6002e0b332c73aac01efcc7d3a18e329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E4=BA=91?= <71159641+littlewhitecloud@users.noreply.github.com> Date: Sun, 10 Dec 2023 11:21:42 +0800 Subject: [PATCH 4/5] nicer check Co-authored-by: Akuli --- src/output.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/output.c b/src/output.c index 2264dfed..ae2f7236 100644 --- a/src/output.c +++ b/src/output.c @@ -112,9 +112,10 @@ static void write_gitinore(const char *p) return; } FILE *gitinore = fopen(filename, "w"); - fprintf(gitinore, "*"); - - fclose(gitinore); + if (gitinore != NULL) { + fprintf(gitinore, "*"); + fclose(gitinore); + } free(filename); } From abfbfeed872e214ff205256e3a6045689cd7494f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E4=BA=91?= <71159641+littlewhitecloud@users.noreply.github.com> Date: Sun, 10 Dec 2023 11:21:58 +0800 Subject: [PATCH 5/5] LOL Co-authored-by: Akuli --- src/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index ae2f7236..bf4ee7ba 100644 --- a/src/output.c +++ b/src/output.c @@ -106,7 +106,7 @@ static void mkdir_exist_ok(const char *p) static void write_gitinore(const char *p) { - char *filename = malloc_sprintf("%s/.gitinore", p); + char *filename = malloc_sprintf("%s/.gitignore", p); if (access(filename, F_OK)) { free(filename); return;