BUILD = jethro kraut cockney jive nyc ken ky00te newspeak nethackify scramble
OTHER = eleet b1ff chef jibberish upside-down rasterman studly fudd \
censor spammer uniencode pirate kenny scottish fanboy LOLCAT
-CFLAGS = -O2 -lfl
+CFLAGS = -O2
export CFLAGS
INSTALL_PROGRAM = install
clean:
$(RM) -f core *.o *~ $(BUILD) SAMPLES
cd ky00te.dir && make clean
- rm -f kraut.dir/lex.yy.c
cd nethackify.dir && make clean
- cd scramble.dir && make clean
.SUFFIXES: .l
.l:
$(RM) $*.c
$(LEX) -t $< > $*.c
- $(CC) -o $@ $*.c $(CFLAGS)
+ $(CC) -o $@ $*.c $(CFLAGS) -lfl
$(RM) $*.c
.SUFFIXES: .dir
ky00te:
cd ky00te.dir && make
-kraut:
- cd kraut.dir && lex kraut.l
- cd kraut.dir && $(CC) kraut.c lex.yy.c -o ../kraut
-
nethackify:
cd nethackify.dir && make
-scramble:
- cd scramble.dir && make
+scramble: scramble.c
License: other
** Public domain. Use at your own risk. Y'all come back now, heah?
-Files: kraut.dir/*
+Files: kraut.l
Copyright: 1989 John Sparks
License: other
/* This is in the public domain. Do with it as you will. *\
+++ /dev/null
- Kraut
- +++++++++++++++++
-Compiling Kraut:
-
-You should have the files: kraut.c and kraut.l and lex.yy.c
-
-
-kraut.l must be run thru the unix 'lex' utility to produce the file lex.yy.c
-Then compile kraut.c and lex.yy.c to produce kraut
-
- $lex kraut.l
- $cc kraut.c lex.yy.c -o kraut
- (You may get a list of warnings from the compiler. Ignore them.)
-
-Note: lex.yy.c is included in this package. You only need to use lex if you
-wish to make changes to kraut.
-
-Using Kraut:
-
- Kraut uses standard input and output.
-
-examples:
-
-To translate a file called 'note' and output kraut to a file called 'knote':
-
- $ cat note | kraut > knote
-
-To translate a file called 'note' and just print it to the screen:
-
- $ cat note | kraut
-
-To have kraut wait to translate what you type at the keyboard and return it in
-kraut on your screen:
-
- $ kraut
-
+++ /dev/null
-#include <stdio.h>
-/* Kraut v0.9 */
-/* by */
-/* John Sparks */
-/* 5-5-1989 */
-
-/* This is in the public domain. Do with it as you will. */
-
-const char *yylex(void);
-
-int main()
-{
- char *line;
-
- while((line = (char *) yylex())) {
- printf("%s", line);
- }
-
- return 0;
-}
-
-int yywrap ()
-{
- return (1);
-}
+++ /dev/null
-%e 2000
-%p 5000
-%n 1000
-%k 500
-%a 4000
-%o 2000
-BW [ ]
-EW [ .,;!?]
-
-%{
-#define YY_DECL const char *yylex(void)
- char buf[128];
-
-%}
-
-%%
-ing return("ingkt");
-" the " return(" ze ");
-"The " return("Ze ");
-" with " return(" mitt ");
-"With " return("Mitt ");
-wr return("w-r-r");
-Wr return("W-r-r");
-R return("R-r-r");
-"Yes " return("Jawohl ");
-" r" return(" r-r-r");
-"Yes." return("Jawohl.");
-"Yes!" return("Jawohl!");
-"YES!" return("JAWOHL!");
-" yes " return(" ja ");
-" yes." return(" ja.");
-" yes!" return(" yes!");
-"No " return("Nein ");
-"No!" return("Nein!");
-"No?" return("Nein?");
-" no " return(" nein ");
-" no." return(" nein.");
-" no!" return(" nein!");
-" no?" return(" nein?");
-[Mm]"r." return("Herr");
-[Mm]"rs." return("Frau");
-Miss return("Fraulein");
-" of " return(" uff ");
-"Of " return("Uff ");
-my return("mein");
-My return("Mein");
-" and " return(" undt ");
-"And " return("Undt ");
-"One " return("Ein ");
-" one" return(" ein");
-"Is " return("Ist ");
-" is " return(" ist ");
-"ow " return("ow ");
-"w " return("w ");
-sh return("sch");
-Sh return("Sch");
-ch return("ch");
-Ch return("Ch");
-" c" return(" k");
-" C" return(" K");
-
-v return("f");
-V return("F");
-" w" return(" v");
-W return("V");
-th return("d");
-Th return("D");
-[Jj]ohn return("Johann");
-[Ww]illiam return("Wilhelm");
-[Bb]rad return("Wilhelm");
-[Gg]ary return("Gerhardt");
-[Jj]on return("Hansel");
-
-[a-f]"!" {sprintf(buf,"%s Naturlich!",yytext);return(buf);}
-[p-z]"!" {sprintf(buf,"%s Sieg Heil!",yytext);return(buf);}
-. return(yytext);
-\n return("\n");
-
-%%
-
-
--- /dev/null
+%e 2000
+%p 5000
+%n 1000
+%k 500
+%a 4000
+%o 2000
+BW [ ]
+EW [ .,;!?]
+
+%%
+ing printf("ingkt");
+" the " printf(" ze ");
+"The " printf("Ze ");
+" with " printf(" mitt ");
+"With " printf("Mitt ");
+wr printf("w-r-r");
+Wr printf("W-r-r");
+R printf("R-r-r");
+"Yes " printf("Jawohl ");
+" r" printf(" r-r-r");
+"Yes." printf("Jawohl.");
+"Yes!" printf("Jawohl!");
+"YES!" printf("JAWOHL!");
+" yes " printf(" ja ");
+" yes." printf(" ja.");
+" yes!" printf(" yes!");
+"No " printf("Nein ");
+"No!" printf("Nein!");
+"No?" printf("Nein?");
+" no " printf(" nein ");
+" no." printf(" nein.");
+" no!" printf(" nein!");
+" no?" printf(" nein?");
+[Mm]"r." printf("Herr");
+[Mm]"rs." printf("Frau");
+Miss printf("Fraulein");
+" of " printf(" uff ");
+"Of " printf("Uff ");
+my printf("mein");
+My printf("Mein");
+" and " printf(" undt ");
+"And " printf("Undt ");
+"One " printf("Ein ");
+" one" printf(" ein");
+"Is " printf("Ist ");
+" is " printf(" ist ");
+"ow " printf("ow ");
+"w " printf("w ");
+sh printf("sch");
+Sh printf("Sch");
+ch printf("ch");
+Ch printf("Ch");
+" c" printf(" k");
+" C" printf(" K");
+
+v printf("f");
+V printf("F");
+" w" printf(" v");
+W printf("V");
+th printf("d");
+Th printf("D");
+[Jj]ohn printf("Johann");
+[Ww]illiam printf("Wilhelm");
+[Bb]rad printf("Wilhelm");
+[Gg]ary printf("Gerhardt");
+[Jj]on printf("Hansel");
+
+[a-f]"!" {printf("%s Naturlich!",yytext);}
+[p-z]"!" {printf("%s Sieg Heil!",yytext);}
+. printf("%s", yytext);
+\n printf("\n");
+
+%%
+
+
rm -f ../ky00te
../ky00te: y.tab.o lex.yy.o
- $(CC) -o ../ky00te lex.yy.o y.tab.o $(CFLAGS)
+ $(CC) -o ../ky00te lex.yy.o y.tab.o $(CFLAGS) -lfl
lex.yy.o: lex.yy.c y.tab.h
$(CC) $(CFLAGS) -c lex.yy.c
--- /dev/null
+/* Scramble the "inner" letters of each word in the input into a random order, and output the result. Non-word (that is, non-alphabetical) characters, and the first and last letters of each word, are left alone.
+ * Output to something other than stdout will append to the file instead of overwriting it - this may be undesirable, and can be changed if so.
+ */
+
+/* Copyright 2009-07-11 Andrew J. Buehler.
+ */
+
+/* This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <ctype.h> // for isalpha()
+#include <stdlib.h> // for malloc()/calloc()/realloc()/free() and rand()/srand()
+#include <string.h> // for strlen()
+#include <time.h> // for time()
+
+#define ALLOW_FILE_IO 0
+
+
+/* strips 'reduction' characters from the end of the input string and returns the result
+ * works only if strlen(string> >= reduction, which is the case in the only place it is presently called
+ */
+char *shorten_string(char *string, int reduction) {
+ int i;
+
+ i = strlen(string);
+
+ for (; reduction > 0; reduction--, i--) {
+ string[i-1] = '\0'; // would it work to use an 'i-reduction' approach instead, similar to what was later done in narrow_string()?
+ }
+
+ return string;
+}
+
+/* strips 'reduction' characters from the beginning and the end of the input string and returns the result
+ * works only if(strlen(string) >= 2*reduction), which is the case in the only place it is presently called
+ */
+char *narrow_string(char *string, int reduction) {
+ int i = reduction;
+
+ while(string[i]) {
+ string[i-reduction] = string[i];
+ i++;
+ }
+ string[i-reduction] = '\0';
+
+ return shorten_string(string, reduction);
+}
+
+int all_one_letter(char *string) {
+ char c;
+ int i;
+
+ c = string[0];
+ for(i = 1; string[i] != '\0'; i++) {
+ if(c != string[i]) {
+ return 0; // a nonduplicate letter has been found
+ }
+ c = string[i];
+ }
+
+ return 1; // reached the end of the string having found only duplicate letters, so it's all one letter
+}
+
+/* randomly reorders the contents of the string
+ * WARNING: frees the input string and returns a replacement
+ */
+char *scramble_string(char *string) {
+ char *ret, *tmpstr;
+ int len, i, j;
+
+ len = strlen(string);
+ if(len < 2) return string; // can't scramble a 1-character string or an empty string!
+ if(all_one_letter(string)) return(string); // can't scramble a string which consists entirely of one letter!
+
+ ret = strdup(string);
+
+ while(strcmp(string, ret) == 0) {
+ j = 0;
+ tmpstr = strdup(string);
+ while(len > 0) {
+ i = rand() % len;
+ ret[j] = tmpstr[i];
+ j++;
+ while(tmpstr[i] != '\0') {
+ tmpstr[i] = tmpstr[i+1];
+ i++;
+ }
+ len--;
+ }
+ free(tmpstr);
+ len = strlen(string);
+ }
+
+
+ free(string);
+ return ret;
+}
+
+char *clear_string(char *string) {
+ int i;
+
+ i = strlen(string);
+
+ for(; i >= 0 ; i--) {
+ string[i] = '\0';
+ }
+
+ return string;
+}
+
+int main(int argc, char **argv) {
+ int word_length;
+ char c, tempchar, *word;
+ FILE *infile, *outfile;
+
+#if ALLOW_FILE_IO
+ /* open files, if any other than stdin and stdout */
+ if(argc > 1) {
+ if(!strcmp(argv[1], "--help") ||
+ !strcmp(argv[1], "-h")) {
+ printf("Usage: %s [INPUT_FILENAME] [OUTPUT_FILENAME]\n", argv[0]);
+ printf("If INPUT_FILENAME is omitted or is '-', read from standard input\nIf OUTPUT_FILENAME is omitted or is '-', print to standard output\n");
+ return 0;
+ }
+
+ if(strcmp(argv[1], "-")) {
+ infile = fopen(argv[1], "r");
+ if(infile == NULL) {
+ fprintf(stderr, "Unable to open input file %s for reading\n", argv[1]);
+ return 1;
+ }
+ } else {
+ infile = stdin;
+ }
+
+ if(argc > 2) {
+ if(strcmp(argv[2], "-")) {
+ outfile = fopen(argv[2], "a");
+ if(outfile == NULL) {
+ fprintf(stderr, "Unable to open output file %s for writing\n", argv[2]);
+ return 2;
+ }
+ } else {
+ outfile = stdout;
+ }
+ }
+ } else { // no arguments specified
+ infile = stdin;
+ outfile = stdout;
+ }
+#else
+ infile = stdin;
+ outfile = stdout;
+#endif
+
+ srand(time(NULL)); // needed for scramble_string() to actually be random
+
+ word_length = 0;
+ word = malloc(sizeof(char));
+ word[0] = '\0';
+ c = fgetc(infile);
+
+ if(feof(infile)) {
+ printf("Reached EOF while reading the first character of the input file!\n");
+ return 4;
+ }
+
+ while(!feof(infile)) {
+ if(isalpha(c)) {
+ word = realloc(word, word_length+2); // one for the new character, one for the null
+ word[word_length] = c;
+ word[word_length + 1] = '\0'; // duplicate addition with the next line, but possibly more readable
+ word_length++;
+ } else {
+ if(word_length) {
+ word_length--;
+ fputc(word[0], outfile);
+ if(word_length) {
+ tempchar = word[word_length];
+ word = scramble_string(narrow_string(word, 1));
+ fprintf(outfile, "%s", word);
+ fputc(tempchar, outfile);
+ }
+ word = clear_string(word);
+ word_length = 0;
+ }
+ fputc(c, outfile);
+ }
+ fflush(outfile);
+ c = fgetc(infile);
+ }
+
+ free(word);
+ return 0;
+}
+++ /dev/null
-../scramble: scramble.c
- $(CC) -o $@ $< -O2 -g
-
-clean:
- rm -f ../scramble
+++ /dev/null
-/* Scramble the "inner" letters of each word in the input into a random order, and output the result. Non-word (that is, non-alphabetical) characters, and the first and last letters of each word, are left alone.
- * Output to something other than stdout will append to the file instead of overwriting it - this may be undesirable, and can be changed if so.
- */
-
-/* Copyright 2009-07-11 Andrew J. Buehler.
- */
-
-/* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <ctype.h> // for isalpha()
-#include <stdlib.h> // for malloc()/calloc()/realloc()/free() and rand()/srand()
-#include <string.h> // for strlen()
-#include <time.h> // for time()
-
-#define ALLOW_FILE_IO 0
-
-
-/* strips 'reduction' characters from the end of the input string and returns the result
- * works only if strlen(string> >= reduction, which is the case in the only place it is presently called
- */
-char *shorten_string(char *string, int reduction) {
- int i;
-
- i = strlen(string);
-
- for (; reduction > 0; reduction--, i--) {
- string[i-1] = '\0'; // would it work to use an 'i-reduction' approach instead, similar to what was later done in narrow_string()?
- }
-
- return string;
-}
-
-/* strips 'reduction' characters from the beginning and the end of the input string and returns the result
- * works only if(strlen(string) >= 2*reduction), which is the case in the only place it is presently called
- */
-char *narrow_string(char *string, int reduction) {
- int i = reduction;
-
- while(string[i]) {
- string[i-reduction] = string[i];
- i++;
- }
- string[i-reduction] = '\0';
-
- return shorten_string(string, reduction);
-}
-
-int all_one_letter(char *string) {
- char c;
- int i;
-
- c = string[0];
- for(i = 1; string[i] != '\0'; i++) {
- if(c != string[i]) {
- return 0; // a nonduplicate letter has been found
- }
- c = string[i];
- }
-
- return 1; // reached the end of the string having found only duplicate letters, so it's all one letter
-}
-
-/* randomly reorders the contents of the string
- * WARNING: frees the input string and returns a replacement
- */
-char *scramble_string(char *string) {
- char *ret, *tmpstr;
- int len, i, j;
-
- len = strlen(string);
- if(len < 2) return string; // can't scramble a 1-character string or an empty string!
- if(all_one_letter(string)) return(string); // can't scramble a string which consists entirely of one letter!
-
- ret = strdup(string);
-
- while(strcmp(string, ret) == 0) {
- j = 0;
- tmpstr = strdup(string);
- while(len > 0) {
- i = rand() % len;
- ret[j] = tmpstr[i];
- j++;
- while(tmpstr[i] != '\0') {
- tmpstr[i] = tmpstr[i+1];
- i++;
- }
- len--;
- }
- free(tmpstr);
- len = strlen(string);
- }
-
-
- free(string);
- return ret;
-}
-
-char *clear_string(char *string) {
- int i;
-
- i = strlen(string);
-
- for(; i >= 0 ; i--) {
- string[i] = '\0';
- }
-
- return string;
-}
-
-int main(int argc, char **argv) {
- int word_length;
- char c, tempchar, *word;
- FILE *infile, *outfile;
-
-#if ALLOW_FILE_IO
- /* open files, if any other than stdin and stdout */
- if(argc > 1) {
- if(!strcmp(argv[1], "--help") ||
- !strcmp(argv[1], "-h")) {
- printf("Usage: %s [INPUT_FILENAME] [OUTPUT_FILENAME]\n", argv[0]);
- printf("If INPUT_FILENAME is omitted or is '-', read from standard input\nIf OUTPUT_FILENAME is omitted or is '-', print to standard output\n");
- return 0;
- }
-
- if(strcmp(argv[1], "-")) {
- infile = fopen(argv[1], "r");
- if(infile == NULL) {
- fprintf(stderr, "Unable to open input file %s for reading\n", argv[1]);
- return 1;
- }
- } else {
- infile = stdin;
- }
-
- if(argc > 2) {
- if(strcmp(argv[2], "-")) {
- outfile = fopen(argv[2], "a");
- if(outfile == NULL) {
- fprintf(stderr, "Unable to open output file %s for writing\n", argv[2]);
- return 2;
- }
- } else {
- outfile = stdout;
- }
- }
- } else { // no arguments specified
- infile = stdin;
- outfile = stdout;
- }
-#else
- infile = stdin;
- outfile = stdout;
-#endif
-
- srand(time(NULL)); // needed for scramble_string() to actually be random
-
- word_length = 0;
- word = malloc(sizeof(char));
- word[0] = '\0';
- c = fgetc(infile);
-
- if(feof(infile)) {
- printf("Reached EOF while reading the first character of the input file!\n");
- return 4;
- }
-
- while(!feof(infile)) {
- if(isalpha(c)) {
- word = realloc(word, word_length+2); // one for the new character, one for the null
- word[word_length] = c;
- word[word_length + 1] = '\0'; // duplicate addition with the next line, but possibly more readable
- word_length++;
- } else {
- if(word_length) {
- word_length--;
- fputc(word[0], outfile);
- if(word_length) {
- tempchar = word[word_length];
- word = scramble_string(narrow_string(word, 1));
- fprintf(outfile, "%s", word);
- fputc(tempchar, outfile);
- }
- word = clear_string(word);
- word_length = 0;
- }
- fputc(c, outfile);
- }
- fflush(outfile);
- c = fgetc(infile);
- }
-
- free(word);
- return 0;
-}