sully works
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -53,6 +53,7 @@ builds/
|
||||
Colleen
|
||||
Grace
|
||||
Sully
|
||||
Sully_*
|
||||
a.out
|
||||
Colleen_*.c
|
||||
Grace_*.c
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
NAME = Sully
|
||||
SRCS = Sully.c
|
||||
CLONE = Sully_kid.c
|
||||
CREATE_CLONE = ./$(NAME)
|
||||
NAME = Sully
|
||||
SRCS = Sully.c
|
||||
CLONE = Sully_4.c \
|
||||
Sully_3.c \
|
||||
Sully_2.c \
|
||||
Sully_1.c \
|
||||
Sully_0.c \
|
||||
CREATE_CLONE = ./$(NAME)
|
||||
|
||||
include ../MakefileCommon
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#define _GNU_SOURCE /* for asprintf */
|
||||
#include <stdlib.h> /* for free */
|
||||
#include <stdlib.h> /* for free and system */
|
||||
#include <stdio.h>
|
||||
#define xstr(s) #s
|
||||
#define str(s) xstr(s)
|
||||
#define MAIN(s) int main() { char *before = "#define _GNU_SOURCE /* for asprintf */\n#include <stdlib.h> /* for free */\n#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "; char *quine = s; char *after = "\nint i = %i;\nMAIN(str(MAIN(s)))\n"; i--;char *kid_name; asprintf(&kid_name, "Sully_%i.c", i); FILE *file = fopen(kid_name, "w"); char *decremented_after; asprintf(&decremented_after, after, i); fprintf(file, "%s%s%s", before, quine, decremented_after); fclose(file);free(decremented_after);free(kid_name);return 0; }
|
||||
#define FT(s) int main() { char *before = "#define _GNU_SOURCE /* for asprintf */\n#include <stdlib.h> /* for free and system */\n#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define FT(s) "; char *quine = s; char *after = "\nint i = %i;\nFT(str(FT(s)))\n"; i--; char *kid_name; char *kid_name_c; char *decremented_after; char *cmd; asprintf(&kid_name, "Sully_%i", i); asprintf(&kid_name_c, "%s.c", kid_name); FILE *file = fopen(kid_name_c, "w"); asprintf(&decremented_after, after, i); fprintf(file, "%s%s%s", before, quine, decremented_after); fclose(file); asprintf(&cmd, "clang %1$s -o %2$s ; ./%2$s", kid_name_c, kid_name); printf("cmd: %s\n", cmd); if (i > 0) {system(cmd); }free(kid_name_c); free(kid_name); free(decremented_after); free(cmd); return 0; }
|
||||
int i = 5;
|
||||
MAIN(str(MAIN(s)))
|
||||
FT(str(FT(s)))
|
||||
|
||||
@@ -104,9 +104,11 @@ $(NAME): $(OBJS)
|
||||
leaks: $(NAME)
|
||||
valgrind --leak-check=full --show-leak-kinds=all $(CREATE_CLONE)
|
||||
|
||||
run:
|
||||
$(CREATE_CLONE)
|
||||
|
||||
diff: $(NAME)
|
||||
@echo $(CYAN)"compare source with output :"$(RESET)
|
||||
$(CREATE_CLONE)
|
||||
- diff --color $(CLONE) $(SRCS); \
|
||||
if [ $$? -eq 0 ]; then echo $(GREEN)"Files $(SRCS) and $(CLONE) are identical"$(RESET); else echo $(RED)":Files $(SRCS) and $(CLONE) differ"$(RESET); fi
|
||||
|
||||
@@ -118,5 +120,5 @@ fclean: clean
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY : all clean fclean re concat diff leaks
|
||||
.PHONY : all clean fclean re concat run diff leaks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user