fix .gitignore, Makefile and README.md for 2015/howe

This commit is contained in:
Landon Curt Noll committed 2023-03-24 20:37:00 -07:00
1 parent 26e73a9701
commit ae638e3cb1
3 files changed
+69 -57

No files matched your search

+5
View File
@@ -1,2 +1,7 @@
curds.tmp
makeholes
nuked.tmp
prog prog
prog.alt prog.alt
war-and-peace.txt
whey.tmp
+17 -10
View File
@@ -63,7 +63,7 @@ X11_INCDIR= /opt/X11/include
# Common C compiler warnings to silence # Common C compiler warnings to silence
# #
#CSILENCE= #CSILENCE=
CSILENCE= -Wno-long-long -Wno-sign-compare CSILENCE= -Wno-sign-compare
# Common C compiler warning flags # Common C compiler warning flags
# #
@@ -76,7 +76,7 @@ CWARN= -Wall -Wextra -pedantic ${CSILENCE}
# #
#CSTD= #CSTD=
#CSTD= -ansi #CSTD= -ansi
CSTD= -std=gnu90 CSTD= -std=gnu11
# Compiler bit architecture # Compiler bit architecture
# #
@@ -101,8 +101,8 @@ CINCLUDE=
#CINCLUDE= -include stdlib.h #CINCLUDE= -include stdlib.h
#CINCLUDE= -include stdio.h #CINCLUDE= -include stdio.h
#CINCLUDE= -include stdlib.h -include stdio.h #CINCLUDE= -include stdlib.h -include stdio.h
#CINCLUDE= -I ${X11_INCDIR} #CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11
#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2 #CINCLUDE= `${SDL2_CONFIG} --cflags`
# Optimization # Optimization
# #
@@ -126,7 +126,7 @@ CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
LIBS= LIBS=
#LIBS= -lm #LIBS= -lm
#LIBS= -L ${X11_LIBDIR} -lX11 #LIBS= -L ${X11_LIBDIR} -lX11
#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL #LIBS= `${SDL2_CONFIG} --libs`
# C compiler to use # C compiler to use
# #
@@ -165,7 +165,8 @@ ENTRY= howe
PROG= prog PROG= prog
# #
OBJ= ${PROG}.o OBJ= ${PROG}.o
DATA= avgtime.sh prog-test.sh CSRC= ${PROG}.o
DATA= spoiler/Makefile spoiler/err.h spoiler/prog.c
TARGET= ${PROG} TARGET= ${PROG}
# #
ALT_OBJ= ${PROG}.alt.o ALT_OBJ= ${PROG}.alt.o
@@ -186,14 +187,20 @@ all: data ${TARGET}
${PROG}: ${PROG}.c ${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LIBS} ${CC} ${CFLAGS} $< -o $@ ${LIBS}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# alternative executable # alternative executable
# #
alt: data ${ALT_TARGET} alt: data ${ALT_TARGET}
@${TRUE} @${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
test: makeholes prog-test.sh ${TARGET}
${SHELL} ./prog-test.sh
makeholes: makeholes.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# data files # data files
# #
data: ${DATA} data: ${DATA}
@@ -217,6 +224,7 @@ clean:
clobber: clean clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET} ${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -f curds.tmp nuked.tmp war-and-peace.txt whey.tmp
@-if [ -e sandwich ]; then \ @-if [ -e sandwich ]; then \
${RM} -f sandwich; \ ${RM} -f sandwich; \
echo 'ate sandwich'; \ echo 'ate sandwich'; \
@@ -328,4 +336,3 @@ pluto: charon
@echo "dwarf is a type of planet" @echo "dwarf is a type of planet"
@echo "therefore, $@ is a planet" @echo "therefore, $@ is a planet"
@echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them" @echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them"
+47 -47
View File
@@ -1,55 +1,64 @@
# Most Different # Most Different
Anthony Howe <achowe@snert.com> Anthony Howe <achowe@snert.com>
Montreal, Quebec, Canada Montreal, Quebec, Canada
<http://www.snert.com/> <http://www.snert.com/>
Twitter: @SirWumpus Twitter: @SirWumpus
## To build: # To build:
make all ```sh
make
```
### To run ### To run:
./prog file1 file2 ```sh
./prog file1 file2
./prog -d file1 file2 ./prog -d file1 file2
```
### Try: ### Try:
./prog prog.alt.c prog.c ```sh
./prog prog.alt.c prog.c
make test make test
./prog -d ABXYEFCD.tmp ACDBECFD.tmp ./prog -d ABXYEFCD.tmp ACDBECFD.tmp
./prog ABXYEFCD.tmp ACDBECFD.tmp ./prog ABXYEFCD.tmp ACDBECFD.tmp
rm -f curds.tmp whey.tmp rm -f curds.tmp whey.tmp
cp /usr/share/man/man1/cc.1 curds.tmp cp /usr/share/man/man1/cc.1 curds.tmp
cp /usr/share/man/man1/cc.1 whey.tmp cp /usr/share/man/man1/cc.1 whey.tmp
chmod 666 whey.tmp chmod 666 whey.tmp
make makeholes make makeholes
./makeholes -n 1000 whey.tmp ./makeholes -n 1000 whey.tmp
./prog curds.tmp whey.tmp ./prog curds.tmp whey.tmp
./avgtime.sh 100 ./prog curds.tmp whey.tmp ./avgtime.sh 100 ./prog curds.tmp whey.tmp
# Assuming curl(1) installed, grab a really HUGE text file. # Assuming curl(1) installed, grab a really HUGE text file.
curl -L -o war-and-peace.txt http://www.gutenberg.org/ebooks/2600.txt.utf-8 curl -L -o war-and-peace.txt http://www.gutenberg.org/ebooks/2600.txt.utf-8
cp war-and-peace.txt nuked.tmp cp war-and-peace.txt nuked.tmp
./makeholes -c'~' -n 1000 nuked.tmp ./makeholes -c'~' -n 1000 nuked.tmp
./prog war-and-peace.txt nuked.tmp ./prog war-and-peace.txt nuked.tmp
./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp ./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp
```
### Alternate code ### Alternate code
An alternate version of this entry, prog.alt.c, is provided. This alternate code does not use a 64 bit FNV hash. An alternate version of this entry, `prog.alt.c`, is provided.
This alternate code does not use a 64 bit FNV hash.
To compile this alternate version: To compile this alternate version:
make alt ```sh
make alt
```
Use `prog.alt` as you would `prog` above. Use `prog.alt` as you would `prog` above.
### Selected Judges Remarks: ## Judges' comments:
This is the best use of the FNV that we have seen in the IOCCC so far! This is the best use of the FNV that we have seen in the IOCCC so far!
The output, when used without -d, is compatible with POSIX diff and The output, when used without -d, is compatible with POSIX diff and
@@ -74,8 +83,8 @@ NOTE: Unlike the original entry source, prog.alt.c, prog.c uses a
64 bit FNV hash and fixes a function call warning. 64 bit FNV hash and fixes a function call warning.
## Author's comments: ## Author's comments:
Features
-------- ### Features
* "An O(NP) Sequence Comparison Algorithm" by Wu, Manber, Myers, Miller. * "An O(NP) Sequence Comparison Algorithm" by Wu, Manber, Myers, Miller.
@@ -83,25 +92,19 @@ Features
* Strokes one of the judge's ego (I couldn't email chocolate or curry). * Strokes one of the judge's ego (I couldn't email chocolate or curry).
### Description
Description
-----------
This is a functioning micro diff tool using an [O(NP) algorithm][Wu+89], compared to the older [O(ND) difference algorithm][Mye86] used by some versions of diff. Its output is based on the default diff(1) output described by POSIX and [The Open Group Base Specifications][SUSV7]. The output is suitable for use with patch(1). This is a functioning micro diff tool using an [O(NP) algorithm][Wu+89], compared to the older [O(ND) difference algorithm][Mye86] used by some versions of diff. Its output is based on the default diff(1) output described by POSIX and [The Open Group Base Specifications][SUSV7]. The output is suitable for use with patch(1).
The -d option simply writes the edit distance between file1 and file2. The -d option simply writes the edit distance between file1 and file2.
### Observations
Observations
------------
The FNV1a hash is a little slow compared to the trival hash GNU Diff uses. I downloaded a plain text copy of "War And Peace" from Project Gutenberg, used ``makeholes.c`` to make 1000 random changes, then profiled and timed the program verses GNU Diff. The bottle neck appears to be in the file I/O and line hashing with an average +0.05s slower. Using a huge file like "War And Peace" for testing offsets the diff(1) optimised file I/O. The FNV1a hash is a little slow compared to the trival hash GNU Diff uses. I downloaded a plain text copy of "War And Peace" from Project Gutenberg, used ``makeholes.c`` to make 1000 random changes, then profiled and timed the program verses GNU Diff. The bottle neck appears to be in the file I/O and line hashing with an average +0.05s slower. Using a huge file like "War And Peace" for testing offsets the diff(1) optimised file I/O.
There is no hash collision checking, partly because FNV1a appears to generate very [few collisions][HshCmp] and an assumption that localised collisions within a region of edits are highly unlikely. There is no hash collision checking, partly because FNV1a appears to generate very [few collisions][HshCmp] and an assumption that localised collisions within a region of edits are highly unlikely.
### Support Files
Support Files
-------------
* ``prog-test.sh`` * ``prog-test.sh``
Basic test program verifies known test edit distances and patch support. Basic test program verifies known test edit distances and patch support.
@@ -111,9 +114,7 @@ Basic test program verifies known test edit distances and patch support.
* ``makeholes.c`` * ``makeholes.c``
Random edits (holes) made to a file in-place. Random edits (holes) made to a file in-place.
### References
References
----------
Wu, Manber, Myers, and Miller; August 1989; Wu, Manber, Myers, and Miller; August 1989;
"An O(NP) Sequence Comparison Algorithm"; "An O(NP) Sequence Comparison Algorithm";
@@ -160,11 +161,10 @@ Which hashing algorithm is best for uniqueness and speed?
[HshCmp]: http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed [HshCmp]: http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed
-------------------------------------------------------------------------------- ## Copyright:
<!--
(c) Copyright 1984-2016, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved (c) Copyright 1984-2016, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc]. This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
[judges]: http://www.ioccc.org/judges.html [judges]: http://www.ioccc.org/judges.html
[cc]: http://creativecommons.org/licenses/by-sa/3.0/ [cc]: http://creativecommons.org/licenses/by-sa/3.0/
-->