wip Sully pbm decrementing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#define xstr(s) #s
|
||||
#define str(s) xstr(s)
|
||||
#define MAIN(s) int main() { char *quine = "#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "s"\n/*\n comment\n*/\nMAIN(str(MAIN(s)))\n"; FILE *file = fopen("Grace_kid.c", "w"); fprintf(file, "%s", quine); return 0; }
|
||||
#define MAIN(s) int main() { char *quine = "#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "s"\n/*\n comment\n*/\nMAIN(str(MAIN(s)))\n"; FILE *file = fopen("Grace_kid.c", "w"); fprintf(file, "%s", quine); fclose(file); return 0; }
|
||||
/*
|
||||
comment
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
NAME = Sully
|
||||
SRCS = Sully.c
|
||||
CLONE = $(NAME)_kid.c
|
||||
CLONE = Sully_kid.c
|
||||
CREATE_CLONE = ./$(NAME)
|
||||
|
||||
include ../MakefileCommon
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#define _GNU_SOURCE /* for asprintf */
|
||||
#include <stdlib.h> /* for free */
|
||||
#include <stdio.h>
|
||||
#define xstr(s) #s
|
||||
#define str(s) xstr(s)
|
||||
#define MAIN(s) int main() { char *quine = "#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "s"\n/*\n comment\n*/\nMAIN(str(MAIN(s)))\n"; FILE *file = fopen("Grace_kid.c", "w"); fprintf(file, "%s", quine); return 0; }
|
||||
/*
|
||||
comment
|
||||
*/
|
||||
#define MAIN(s) int main() { char *quine = "#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) "s"\nint i = %i;\nMAIN(str(MAIN(s,n)))\n"; char *kid_name; char *temp; asprintf(&temp, quine, 10, 20, 30); asprintf(&kid_name, "Sully_%i.c", 40); FILE *file = fopen(kid_name, "w"); fprintf(file, temp, 50, 60); fclose(file);free(temp);free(kid_name);return 0; }
|
||||
int i = 5;
|
||||
MAIN(str(MAIN(s)))
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# it's important to put the input_string inside single quotes
|
||||
input_string='#include <stdio.h>%[\r]#define PRINT %[\s]%[\r]#define FT(...) int main(){%[\\]%[\r]'
|
||||
|
||||
special_cahracters=$(echo -E "$input_string" | grep -o "%\[..\]")
|
||||
echo $special_cahracters
|
||||
|
||||
# assiocative array : https://www.gnu.org/software/bash/manual/html_node/Arrays.html
|
||||
declare -A instructions
|
||||
instructions["%[\r]"]=10
|
||||
instructions["%[\s]"]="S"
|
||||
instructions["%[\\]"]=92
|
||||
instructions["%[\"]"]=34
|
||||
|
||||
for key
|
||||
@@ -102,13 +102,13 @@ $(NAME): $(OBJS)
|
||||
$(CC) $(OBJS) -o $@ $(LIBS)
|
||||
|
||||
leaks: $(NAME)
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME)
|
||||
valgrind --leak-check=full --show-leak-kinds=all $(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 $(NAME) and $(SRCS) differ"$(RESET); fi
|
||||
if [ $$? -eq 0 ]; then echo $(GREEN)"Files $(SRCS) and $(CLONE) are identical"$(RESET); else echo $(RED)":Files $(SRCS) and $(CLONE) differ"$(RESET); fi
|
||||
|
||||
clean:
|
||||
$(RM_OBJS)
|
||||
@@ -120,4 +120,3 @@ re: fclean all
|
||||
|
||||
.PHONY : all clean fclean re concat diff leaks
|
||||
|
||||
|
||||
|
||||
26
notes.md
26
notes.md
@@ -17,20 +17,18 @@
|
||||
|
||||
```
|
||||
dr_quine/
|
||||
│
|
||||
├─ C/
|
||||
│ ├─ Colleen.c
|
||||
│ ├─ Grace.c
|
||||
│ ├─ Sully.c
|
||||
│ ├─ Makefile
|
||||
│ └─ ...
|
||||
│
|
||||
└─ ASM/
|
||||
├─ Colleen.asm
|
||||
├─ Grace.asm
|
||||
├─ Sully.asm
|
||||
├─ Makefile
|
||||
└─ ...
|
||||
| C/
|
||||
| | Colleen.c
|
||||
| | Grace.c
|
||||
| | Sully.c
|
||||
| | Makefile
|
||||
| | ...
|
||||
| ASM/
|
||||
| | Colleen.asm
|
||||
| | Grace.asm
|
||||
| | Sully.asm
|
||||
| | Makefile
|
||||
| | ...
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user