diff --git a/.gitignore b/.gitignore index b24d71e..6aea462 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,7 @@ Thumbs.db *.mov *.wmv +# C files +builds/ +Colleen +Grace diff --git a/1_Colleen/Colleen b/1_Colleen/Colleen deleted file mode 100755 index ddf6173..0000000 Binary files a/1_Colleen/Colleen and /dev/null differ diff --git a/1_Colleen/builds/Colleen.o b/1_Colleen/builds/Colleen.o deleted file mode 100644 index 510ff48..0000000 Binary files a/1_Colleen/builds/Colleen.o and /dev/null differ diff --git a/2_Grace/Grace b/2_Grace/Grace deleted file mode 100755 index 994a32a..0000000 Binary files a/2_Grace/Grace and /dev/null differ diff --git a/2_Grace/Grace.c b/2_Grace/Grace.c index 70b4936..eb53d15 100644 --- a/2_Grace/Grace.c +++ b/2_Grace/Grace.c @@ -1,13 +1,14 @@ /*comment outside*/ #include +#define not_main main char *second_function() { - return "/*comment outside*/%c#include %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 %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; } diff --git a/2_Grace/builds/Grace.o b/2_Grace/builds/Grace.o deleted file mode 100644 index 3ac5ab0..0000000 Binary files a/2_Grace/builds/Grace.o and /dev/null differ diff --git a/2_Grace/tmp_Grace.c b/2_Grace/tmp_Grace.c new file mode 100644 index 0000000..eb53d15 --- /dev/null +++ b/2_Grace/tmp_Grace.c @@ -0,0 +1,14 @@ +/*comment outside*/ +#include +#define not_main main + +char *second_function() { + return "/*comment outside*/%c#include %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; +} diff --git a/MakefileCommon b/MakefileCommon index 81611e5..4905ff8 100644 --- a/MakefileCommon +++ b/MakefileCommon @@ -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)