+++ /dev/null
---- annotate.c
-+++ annotate.c
-@@ -554,7 +554,7 @@
-
- void AnnotatePositionHTML(TREE * RESTRICT tree, int wtm, FILE * annotate_out)
- {
-- char filename[32], html_piece;
-+ char filename[64], html_piece;
- char alt[32];
- char xlate[15] =
- { 'q', 'r', 'b', 0, 'k', 'n', 'p', 0, 'P', 'N', 'K', 0, 'B', 'R', 'Q' };
-@@ -566,7 +566,7 @@
- for (rank = RANK8; rank >= RANK1; rank--) {
- fprintf(annotate_out, "<TR>\n");
- for (file = FILEA; file <= FILEH; file++) {
-- (void) strcpy(filename, "bitmaps/");
-+ (void) strcpy(filename, "/usr/share/crafty/bitmaps/");
- if ((rank + file) % 2)
- (void) strcat(filename, "w");
- else
-@@ -665,7 +665,7 @@
- fprintf(annotate_out, "\\usepackage{times}\n");
- fprintf(annotate_out, "\\usepackage{a4wide}\n");
- fprintf(annotate_out, "\\usepackage{chess}\n");
-- fprintf(annotate_out, "\\usepackage{bdfchess}\n");
-+ fprintf(annotate_out, "%% \\usepackage{bdfchess}\n");
- fprintf(annotate_out, "\\usepackage[T1]{fontenc}\n");
- fprintf(annotate_out, "\n");
- fprintf(annotate_out, "\\setlength{\\columnsep}{7mm}\n");
---- egtb.cpp
-+++ egtb.cpp
-@@ -4490,7 +4490,8 @@
- #if defined (SMP)
- static lock_t lockDecode;
- #endif
--extern "C" int TB_CRC_CHECK = 0;
-+extern "C" int TB_CRC_CHECK;
-+int TB_CRC_CHECK = 0;
- static int cCompressed = 0;
- static decode_block *rgpdbDecodeBlocks[CPUS];
-
---- lock.h
-+++ lock.h
-@@ -64,7 +64,7 @@
- *******************************************************************************
- */
-
--#if defined(ALPHA)
-+#if defined(__alpha__)
-
- # include <machine/builtins.h>
-
---- main.c
-+++ main.c
-@@ -1,6 +1,10 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-+#include <sys/stat.h>
-+#include <sys/types.h>
-+#include <fcntl.h>
-+#include <unistd.h>
- #include "chess.h"
- #include "data.h"
- #if defined(UNIX) || defined(AMIGA)
-@@ -3230,8 +3234,58 @@
- #if !defined(UNIX)
- char crafty_rc_file_spec[FILENAME_MAX];
- #endif
--/* Collect environmental variables */
-- char *directory_spec = getenv("CRAFTY_BOOK_PATH");
-+
-+ char *directory_spec;
-+
-+/*
-+ set log_path & rc_path to some reasonable value
-+ create default .craftyrc
-+*/
-+ {
-+ char l[128], *h = getenv("HOME");
-+ struct stat st;
-+ FILE *f;
-+
-+ if(!h || strlen(h) > 100) h = "/tmp";
-+ strcpy(rc_path, h);
-+ sprintf(log_path, "%s/%s", h, ".crafty");
-+
-+ if(stat(log_path, &st) || !S_ISDIR(st.st_mode)) {
-+ mkdir(log_path, 0755);
-+ }
-+
-+ sprintf(l, "%s/.craftyrc", rc_path);
-+ if(lstat(l, &st)) {
-+ if((f = fopen(l, "w"))) {
-+ fprintf(f, "egtb\n");
-+ fclose(f);
-+ }
-+ }
-+ }
-+
-+/*
-+ set book_path to some reasonable value
-+*/
-+ {
-+ char l[128], *h = getenv("HOME");
-+ struct stat st;
-+
-+ if(!h || strlen(h) > 100) h = "/tmp";
-+ sprintf(book_path, "%s/%s", h, ".crafty");
-+
-+ if(stat(book_path, &st) || !S_ISDIR(st.st_mode)) {
-+ mkdir(book_path, 0755);
-+ }
-+
-+ sprintf(l, "%s/book.bin", book_path);
-+ if(lstat(l, &st)) symlink("/usr/share/crafty/book.bin", l);
-+
-+ sprintf(l, "%s/books.bin", book_path);
-+ if(lstat(l, &st)) symlink("/usr/share/crafty/books.bin", l);
-+ }
-+
-+ /* Collect environmental variables */
-+ directory_spec=getenv("CRAFTY_BOOK_PATH");
-
- #if defined(NUMA) && defined(LINUX)
- if (numa_available() >= 0) {
---- Makefile
-+++ Makefile
-@@ -72,8 +72,21 @@
- # with the large egtb.cpp code/templates.
- #
-
-+ARCH = $(shell uname -m | sed -e 's/^i./i3/')
-+
-+opt = -DCOMPACT_ATTACKS -DUSE_ATTACK_FUNCTIONS -DFAST -DDGT -DEGTB6
-+
-+# EGTB code seems to have problems with SMP
-+ifneq ($(findstring $(ARCH),i386),)
-+ opt += -O2 -DUSE_ASSEMBLY_A -DUSE_ASSEMBLY_B # -DSMP -DCPUS=4
-+ asm = X86-elf.o
-+else
-+ opt += -O # -DSMP -DCPUS=4 -DMUTEX
-+ asm =
-+endif
-+
- default:
-- $(MAKE) -j linux-icc
-+ $(MAKE) linux-suse
- help:
- @echo "You must specify the system which you want to compile for:"
- @echo ""
-@@ -173,6 +186,15 @@
- LDFLAGS='$(LDFLAGS) +O3 +Onolimit $(CFLAGS)' \
- crafty-make
-
-+linux-suse:
-+ $(MAKE) target=LINUX \
-+ CC=gcc CXX=g++ \
-+ CFLAGS='$(CFLAGS) -Wall -pipe -D_REENTRANT' \
-+ CXFLAGS='$(CFLAGS) \
-+ -fforce-mem -fomit-frame-pointer' \
-+ LDFLAGS='$(LDFLAGS) -lpthread' \
-+ crafty-make
-+
- linux:
- $(MAKE) target=LINUX \
- CC=gcc CXX=g++ \
---- option.c
-+++ option.c
-@@ -11,6 +11,8 @@
- #endif
- #include "epdglue.h"
-
-+#define safe_strcpy(dst, src) strncpy(dst, src, sizeof dst - 1)[sizeof dst - 1] = 0
-+
- /* last modified 10/10/05 */
- /*
- *******************************************************************************
-@@ -843,7 +845,7 @@
- char filename[256];
- FILE *file;
-
-- strcpy(filename, args[2]);
-+ safe_strcpy(filename, args[2]);
- strcat(filename, ".cpf");
- file = fopen(filename, "w");
- if (!file) {
-@@ -1129,7 +1131,7 @@
- movenum = shared->move_number;
- if (wtm)
- movenum--;
-- strcpy(text, args[1]);
-+ safe_strcpy(text, args[1]);
- sprintf(buffer, "reset %d", movenum);
- wtm = Flip(wtm);
- (void) Option(tree);
-@@ -1357,7 +1359,7 @@
- char *readstat = (char *) -1;
- int lines = 0;
-
-- helpfile = fopen("crafty.hlp", "r");
-+ helpfile = fopen("/usr/share/crafty/crafty.hlp", "r");
- if (!helpfile) {
- printf("ERROR. Unable to open \"crafty.hlp\" -- help unavailable\n");
- return (1);
-@@ -1858,7 +1860,7 @@
- printf("file does not exist.\n");
- return (1);
- }
-- strcpy(title, args[2]);
-+ safe_strcpy(title, args[2]);
- while (!feof(prob_file)) {
- readstat = fgets(buffer, 128, prob_file);
- if (readstat) {
-@@ -2154,10 +2156,10 @@
- return (1);
- }
- if (wtm) {
-- strcpy(pgn_white, args[1]);
-+ safe_strcpy(pgn_white, args[1]);
- sprintf(pgn_black, "Crafty %s", version);
- } else {
-- strcpy(pgn_black, args[1]);
-+ safe_strcpy(pgn_black, args[1]);
- sprintf(pgn_white, "Crafty %s", version);
- }
- Print(128, "Crafty %s vs %s\n", version, args[1]);
-@@ -2368,14 +2370,14 @@
- }
- if (!strchr(args[1], '(')) {
- if (strstr(args[0], "bookpath"))
-- strcpy(book_path, args[1]);
-+ safe_strcpy(book_path, args[1]);
- else if (strstr(args[0], "perspath"))
-- strcpy(personality_path, args[1]);
-+ safe_strcpy(personality_path, args[1]);
- else if (strstr(args[0], "logpath"))
-- strcpy(log_path, args[1]);
-+ safe_strcpy(log_path, args[1]);
- #if !defined(NOEGTB)
- else if (strstr(args[0], "tbpath")) {
-- strcpy(tb_path, args[1]);
-+ safe_strcpy(tb_path, args[1]);
- EGTBlimit = IInitializeTb(tb_path);
- Print(128, "%d piece tablebase files found\n", EGTBlimit);
- if (0 != cbEGTBCompBytes)
-@@ -2398,12 +2400,12 @@
- if (strchr(args[1], ')')) {
- *strchr(args[1], ')') = 0;
- if (strstr(args[0], "bookpath"))
-- strcpy(book_path, args[1] + 1);
-+ safe_strcpy(book_path, args[1] + 1);
- else if (strstr(args[0], "logpath"))
-- strcpy(log_path, args[1] + 1);
-+ safe_strcpy(log_path, args[1] + 1);
- #if !defined(NOEGTB)
- else if (strstr(args[0], "tbpath")) {
-- strcpy(tb_path, args[1] + 1);
-+ safe_strcpy(tb_path, args[1] + 1);
- EGTBlimit = IInitializeTb(tb_path);
- Print(128, "%d piece tablebase files found\n", EGTBlimit);
- if (0 != cbEGTBCompBytes)
---- speak
-+++ speak
-@@ -4,13 +4,13 @@
- #
-
- # The program used for Sound Output
--my $playprg = "/usr/bin/esdplay";
-+my $playprg = "/usr/bin/play";
-
- # Where the sound files are located
--my $soundpath = "/opt/chess/sound";
-+my $soundpath = "/usr/share/crafty/sound";
- # Which language to use (each supported language is in a separate
- # subdir of $soundpath)
--my $language = "english";
-+my $language = "en";
-
- # The move sent by crafty
- my $move = $ARGV[0];
-@@ -18,11 +18,28 @@
- # Set soundpath to the correct language
- $soundpath = $soundpath . "/" . $language;
-
-+%piece = (
-+ 'B' => 'Bishop',
-+ 'K' => 'King',
-+ 'N' => 'Knight',
-+ 'Q' => 'Queen',
-+ 'R' => 'Rook'
-+);
-+
-+
-+%moves = (
-+ 'O-O' => '0-0',
-+ 'O-O-O' => '0-0-0',
-+ 'Stalemate' => 'Stalemate',
-+ 'Drawaccept' => 'Drawaccept',
-+ 'Drawoffer' => 'Drawoffer',
-+ 'Resign' => 'Resign'
-+);
-+
- # First check some specials
--if (($move =~ /O-O/) || ($move eq "Stalemate") ||
-- ($move eq "Drawaccept") || ($move eq "Drawoffer") ||
-- ($move eq "Resign") || ($move eq "Checkmate")) {
-- system("$playprg $soundpath/$move.wav");
-+
-+if($moves{$move}) {
-+ system("$playprg $soundpath/$moves{$move}.wav");
- }
- # Handle all normal moves. All that needs to be done is announce
- # each character sent by crafty alone. Set some pause beteween each
-@@ -42,9 +59,14 @@
- else {
- for (my $i=0; $i<length($move); $i++) {
- my $char = substr $move, $i, 1;
-+
-+ if($i == 0 && $char =~ /[a-h]/) {
-+ system("$playprg $soundpath/Pawn.wav");
-+ }
-+
- if ($char =~ /[^=]/) {
- if ($char =~ /x/) {
-- system("$playprg $soundpath/x.wav");
-+ system("$playprg $soundpath/takes.wav");
- system("usleep 400000");
- }
- elsif ($char =~ /#/) {
-@@ -53,9 +75,21 @@
- elsif ($char =~ /\+/) {
- system("$playprg $soundpath/Check.wav");
- }
-+ elsif ($char =~ /[1-8]/) {
-+ system("$playprg $soundpath/${char}from.wav");
-+ }
-+ elsif ($char =~ /[a-h]/) {
-+ system("$playprg $soundpath/\U${char}\Efrom.wav");
-+ }
-+ elsif ($char =~ /[QKNBR]/) {
-+ system("$playprg $soundpath/$piece{$char}.wav");
-+ }
- else {
- system("$playprg $soundpath/$char".".wav");
- }
- }
- }
-+
-+ system("$playprg $soundpath/click.wav");
-+
- }
---- utility.c
-+++ utility.c
-@@ -133,10 +133,12 @@
- float BookIn32f(unsigned char *ch)
- {
- int v1;
-- float *v2 = (float *) &v1;
-+ float v2;
-
- v1 = (ch[3] << 24) | (ch[2] << 16) | (ch[1] << 8) | ch[0];
-- return (*v2);
-+ memcpy(&v2, &v1, sizeof v2);
-+
-+ return v2;
- }
-
- /*
-@@ -201,14 +203,15 @@
- */
- unsigned char *BookOut32f(float val)
- {
-- float v1;
-- int *v2 = (int *) &v1;
-+ int v2;
-+
-+ memcpy(&v2, &val, sizeof v2);
-+
-+ convert_buff[3] = (v2 >> 24) & 0xff;
-+ convert_buff[2] = (v2 >> 16) & 0xff;
-+ convert_buff[1] = (v2 >> 8) & 0xff;
-+ convert_buff[0] = v2 & 0xff;
-
-- v1 = val;
-- convert_buff[3] = (*v2 >> 24) & 0xff;
-- convert_buff[2] = (*v2 >> 16) & 0xff;
-- convert_buff[1] = (*v2 >> 8) & 0xff;
-- convert_buff[0] = *v2 & 0xff;
- return (convert_buff);
- }
-
-@@ -1547,14 +1550,16 @@
- if (vb & shared->display_options)
- vprintf(fmt, ap);
- fflush(stdout);
-+ va_end(ap);
-+
- if (shared->time_limit > 99 || shared->tc_time_remaining > 6000 || vb == 4095) {
- va_start(ap, fmt);
- if (log_file)
- vfprintf(log_file, fmt, ap);
- if (log_file)
- fflush(log_file);
-+ va_end(ap);
- }
-- va_end(ap);
- }
-
- char *PrintKM(size_t val, int realK)