OBJS=grammar.o lex.o map.o decode.o moves.o lists.o apply.o output.o eco.o\
lines.o end.o main.o hashing.o argsfile.o mymalloc.o fenmatcher.o\
- taglines.o
+ taglines.o farmhash-c.o
DEBUGINFO=-g
# These flags are particularly severe on checking warnings.
-I/usr/local/lib/ansi-include \
-O3
CC=gcc
+LDLIBS=-lfarmhash
# AIX 3.2 Users might like to use these alternatives for CFLAGS and CC.
# Thanks to Erol Basturk for providing them.
AIX_CC=xlc
pgn-extract : $(OBJS)
- $(CC) $(DEBUGINFO) $(OBJS) -o pgn-extract
+ $(CC) $(DEBUGINFO) $(OBJS) $(LDLIBS) -o pgn-extract
purify : $(OBJS)
purify $(CC) $(DEBUGINFO) $(OBJS) -o pgn-extract
--- /dev/null
+#include <stdint.h>
+#include <farmhash.h>
+
+extern "C" uint64_t farmhash_32(const char* s, size_t len)
+{
+ return util::Hash32(s, len);
+}
#include "output.h"
#include "mymalloc.h"
#include "eco.h"
+#include "farmhash-c.h"
/* Functions for outputting games in the required format. */
timestamp = 32503680000;
}
+ uint16_t prev_board_hash = 0;
+
for (move = current_game.moves; move != NULL; move = move->next) {
unsigned int opening = move->eco ? move->eco->cumulative_hash_value : 0; // Truncate to 32 bits.
// key
- putc(move->bpfen_len, outputfile);
+ putc(move->bpfen_len + sizeof(prev_board_hash), outputfile);
fwrite(move->bpfen, move->bpfen_len, 1, outputfile);
+ fwrite(&prev_board_hash, sizeof(prev_board_hash), 1, outputfile);
// value
putc(result_int, outputfile);
fwrite(&start_position, sizeof(start_position), 1, outputfile);
putc(strlen((char *)move->move), outputfile);
fwrite(move->move, strlen((char *)move->move), 1, outputfile);
+
+ prev_board_hash = farmhash_32(move->bpfen, move->bpfen_len);
}
}