diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..791138f --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2013 + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d688886 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +CC=cc +CFLAGS=-O2 + +all: bfstring + +bfstring: + ${CC} ${CFLAGS} bfstring.c -o bfstring diff --git a/README b/README new file mode 100644 index 0000000..4012faf --- /dev/null +++ b/README @@ -0,0 +1 @@ +Converts text to Brainfuck! (Still too unoptimized) diff --git a/bfstring.c b/bfstring.c new file mode 100644 index 0000000..609d145 --- /dev/null +++ b/bfstring.c @@ -0,0 +1,46 @@ +/* + * BRAIN FUCK CONVERTER SHIT + * + * TODO: have separate "sections" for upper case, lower case, certain + * symbols + * + * Have "looping" to avoid spitting out too many ++++++++'s or ------'s IF + * IT SAVES SPACE. + */ +#include + +int +main(int argc, char *argv[]) +{ + int curv = 120, curc; + + /* store space (32) in second element */ + printf("++++[>++++++++<-]>"); + + /* set first cell thing to 120 */ + printf(">++++++++++[<<++++++++++++>>-]<<"); + + while ((curc = getchar()) != EOF) { + + if (curc == ' ') { + printf(">.<"); + continue; + } + + while (curv != curc) { + if (curv < curc) { + curv++; + putchar('+'); + } else { + curv--; + putchar('-'); + } + } + + putchar('.'); + } + // >.< <.> >.> <.< + + putchar('\n'); + return 0; +}