- first step in grace : compile without main

- added makefile to keep tmp file
- added builds and executable in gitignore
This commit is contained in:
asus
2024-01-23 15:18:08 +01:00
parent 8f2d83871b
commit 25fadd05a0
8 changed files with 30 additions and 7 deletions

4
.gitignore vendored
View File

@@ -48,3 +48,7 @@ Thumbs.db
*.mov
*.wmv
# C files
builds/
Colleen
Grace

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,13 +1,14 @@
/*comment outside*/
#include <stdio.h>
#define not_main main
char *second_function() {
return "/*comment outside*/%c#include <stdio.h>%c%cchar *second_function() {%c return %c%s%c;%c}%c%cint main() {%c /*comment inside*/%c char *program = second_function();%c printf(program, 10, 10, 10, 10, 34, program, 34, 10, 10, 10, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c";
return "/*comment outside*/%c#include <stdio.h>%c#define not_main main%c%cchar *second_function() {%c return %c%s%c;%c}%c%cint not_main() {%c /*comment inside*/%c char *program = second_function();%c printf(program, 10, 10, 10, 10, 10, 34, program, 34, 10, 10, 10, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c";
}
int main() {
int not_main() {
/*comment inside*/
char *program = second_function();
printf(program, 10, 10, 10, 10, 34, program, 34, 10, 10, 10, 10, 10, 10, 10, 10, 10);
printf(program, 10, 10, 10, 10, 10, 34, program, 34, 10, 10, 10, 10, 10, 10, 10, 10, 10);
return 0;
}

Binary file not shown.

14
2_Grace/tmp_Grace.c Normal file
View File

@@ -0,0 +1,14 @@
/*comment outside*/
#include <stdio.h>
#define not_main main
char *second_function() {
return "/*comment outside*/%c#include <stdio.h>%c#define not_main main%c%cchar *second_function() {%c return %c%s%c;%c}%c%cint not_main() {%c /*comment inside*/%c char *program = second_function();%c printf(program, 10, 10, 10, 10, 10, 34, program, 34, 10, 10, 10, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c";
}
int not_main() {
/*comment inside*/
char *program = second_function();
printf(program, 10, 10, 10, 10, 10, 34, program, 34, 10, 10, 10, 10, 10, 10, 10, 10, 10);
return 0;
}

View File

@@ -55,6 +55,7 @@ ifeq "$(D_OBJS)" "."
else
RM_OBJS = rm -rf $(D_OBJS)
endif
F_DIFF = tmp_$(NAME).c
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
@@ -88,12 +89,15 @@ $(NAME): $(OBJS)
leaks: $(NAME)
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME)
diff: $(NAME)
diff_clean:
rm $(F_DIFF)
diff_exec:
@echo $(CYAN)"compare source with output :"$(RESET)
./$(NAME) > tmp_$(NAME)
- diff --color tmp_$(NAME) $(SRCS); \
./$(NAME) > $(F_DIFF)
- diff --color $(F_DIFF) $(SRCS); \
if [ $$? -eq 0 ]; then echo $(GREEN)"Files $(NAME) and $(SRCS) are identical"$(RESET); else echo $(RED)":Files $(NAME) and $(SRCS) differ"$(RESET); fi
rm tmp_$(NAME)
diff: $(NAME) diff_exec diff_clean
diff_keep: $(NAME) diff_exec
clean:
$(RM_OBJS)