X-Git-Url: http://git.pld-linux.org/?p=packages%2Fcrafty.git;a=blobdiff_plain;f=crafty-MDK.patch;fp=crafty-MDK.patch;h=f7d25403fe4972e5bf6aca3985f373ef0ac34f81;hp=0000000000000000000000000000000000000000;hb=e5eb4e43b2bf010b1708b9168599349eeb976d4d;hpb=cc87d8c66cd3e115c7b501470600e24faed1cace diff --git a/crafty-MDK.patch b/crafty-MDK.patch new file mode 100644 index 0000000..f7d2540 --- /dev/null +++ b/crafty-MDK.patch @@ -0,0 +1,410 @@ +--- 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, "\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 + +--- main.c ++++ main.c +@@ -1,6 +1,10 @@ + #include + #include + #include ++#include ++#include ++#include ++#include + #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> 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)