diff --git a/1992/gson/.gitignore b/1992/gson/.gitignore index 0c62d5021..d2f81d282 100644 --- a/1992/gson/.gitignore +++ b/1992/gson/.gitignore @@ -1,2 +1,2 @@ gson -og +ag diff --git a/1992/gson/Makefile b/1992/gson/Makefile index 6c793918a..7221834f2 100644 --- a/1992/gson/Makefile +++ b/1992/gson/Makefile @@ -68,7 +68,7 @@ CINCLUDE= # Optimization # -OPT= -O3 +OPT= -ggdb3 # Default flags for ANSI C compilation # @@ -114,7 +114,7 @@ PROG= ${ENTRY} # OBJ= ${PROG}.o DATA= -TARGET= ${PROG} og +TARGET= ${PROG} ag # ALT_OBJ= ALT_TARGET= @@ -134,7 +134,7 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LIBS} -og: ${PROG} +ag: ${PROG} ${RM} -f $@ ${LN} $< $@ diff --git a/1992/gson/README.md b/1992/gson/README.md index 8a24b1f78..976dcb7c8 100644 --- a/1992/gson/README.md +++ b/1992/gson/README.md @@ -10,21 +10,33 @@ make all -### To run +### To run: - ./og word word2 word3 < /path/to/dictionary + ./ag word word2 word3 < /path/to/dictionary -## Judges' comment +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this entry to not +use gets(). Previously it had a buffer size of 256 which could easily overflow. +Now in this entry `gets()` is used in a more complicated way (first `m` is set +to `*++p` in a for loop where `p` is argv and then later `m` is set to point to +`h` which is of size 256) and trying to change it to use fgets() proved more a +problem. Since the input must come from the command line Cody changed the buffer +size to `ARG_MAX+1` which should be enough especially since the command expects +redirecting a dictionary file as part of the command line. This also makes it +possible for longer strings to be read (in case the `gets()` was not used in a +loop). Thank you Cody for your assistance! - Determine where your system dictionary is located. You may find - it located in one of the following places: + +## Judges' comment: + +Determine where your system dictionary is located. You may find +it located in one of the following places: /usr/share/dict/words /usr/share/lib/spell/words /usr/ucblib/dict/words /dev/null # <-- for machines with nothing to say - Then using the proper dictionary: +Then using the proper dictionary: ./ag free software foundation < /usr/share/dict/words ./ag obfuscated c contest < /usr/share/dict/words @@ -34,202 +46,201 @@ ./ag ross perot < /usr/share/dict/words ./ag paul e tsongas < /usr/share/dict/words - Recently some newspapers printed amusing anagrams of one of the - names listed above. Run this program to find the anagrams they - weren't allowed to print! +Recently some newspapers printed amusing anagrams of one of the +names listed above. Run this program to find the anagrams they +weren't allowed to print! -## Author's comments +## Author's comments: - The name of the game: - - AG is short for either Anagram Generator or simply AnaGram. - It might also be construed to mean Alphabet Game, and by pure - coincidence it happens to be the author's initials. +The name of the game: + +AG is short for either Anagram Generator or simply AnaGram. +It might also be construed to mean Alphabet Game, and by pure +coincidence it happens to be the author's initials. - What it does: +### What it does: - AG takes one or more words as arguments, and tries to find - anagrams of those words, i.e. words or sentences containing - exactly the same letters. - - - How to use it: - - To run AG, you need a dictionary file consisting of distinct words - in the natural language of your choice, one word on each line. If - your machine doesn't have one already, you can make your own - dictionary by concatenating a few hundred of your favourite Usenet - articles and piping them through the following obfuscated shell - script: +AG takes one or more words as arguments, and tries to find +anagrams of those words, i.e. words or sentences containing +exactly the same letters. + + +### How to use it: +To run AG, you need a dictionary file consisting of distinct words +in the natural language of your choice, one word on each line. If +your machine doesn't have one already, you can make your own +dictionary by concatenating a few hundred of your favourite Usenet +articles and piping them through the following obfuscated shell +script: + #!/bin/sh z=a-z];tr [A-Z\] \[$z|sed s/[\^$z[\^$z*/_/g|tr _ \\012|grep ..|sort -u - Using articles from alt.folklore.computers is likely to make - a more professional-looking dictionary than rec.arts.erotica. +Using articles from alt.folklore.computers is likely to make +a more professional-looking dictionary than rec.arts.erotica. + +AG must be run with the dictionary file as standard input. + +Because anagrams consisting of just a few words are generally more +meaningful than those consisting of dozens of very short words, the +number of words in the anagrams is limited to 3 by default. This +limit can be changed using a numeric command line option, as in +`./ag -4 international obfuscated c code contest - +#include long a [4],b[ 4],c[4] ,d[0400],e=1; typedef struct f{long g ,h,i[4] ,j;struct f*k;}f;f g,* -l[4096 ]; char h[256],*m,k=3; +l[4096 ]; char h[ARG_MAX+1],*m,k=3; long n (o, p,q)long*o,*p,*q;{ long r =4,s,i=0;for(;r--;s=i^ *o^*p, i=i&*p|(i|*p)&~*o++,*q @@ -33,7 +33,7 @@ s,i=o->h;q.k=o;r>i?j=l[r=i]:r