- first step in grace : compile without main
- added makefile to keep tmp file - added builds and executable in gitignore
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -48,3 +48,7 @@ Thumbs.db
|
||||
*.mov
|
||||
*.wmv
|
||||
|
||||
# C files
|
||||
builds/
|
||||
Colleen
|
||||
Grace
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
2_Grace/Grace
BIN
2_Grace/Grace
Binary file not shown.
@@ -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
14
2_Grace/tmp_Grace.c
Normal 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;
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user