X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=0e8b132d0e9d7b9c9f4f07632fd5af69c1379f6f;hb=b7a79fc5f838b5553d9d48ac26afad1c21111e95;hp=d539705e3fa89eb3e82297d07b1d50efd4c04336;hpb=262a1501c25d57e39848d21647e607c8319c2088;p=xboard.git diff --git a/xboard.c b/xboard.c index d539705..0e8b132 100644 --- a/xboard.c +++ b/xboard.c @@ -1347,7 +1347,7 @@ XtResource clientResources[] = { XtRImmediate, (XtPointer) "xboard.debug"}, { "engineDebugOutput", "engineDebugOutput", XtRInt, sizeof(int), XtOffset(AppDataPtr, engineComments), - XtRImmediate, (XtPointer) 0}, + XtRImmediate, (XtPointer) 1}, { "noGUI", "noGUI", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, noGUI), XtRImmediate, (XtPointer) 0}, @@ -1401,6 +1401,9 @@ XtResource clientResources[] = { { "delayAfterQuit", "delayAfterQuit", XtRInt, sizeof(int), XtOffset(AppDataPtr, delayAfterQuit), XtRImmediate, (XtPointer) 0}, + { "keepAlive", "keepAlive", XtRInt, + sizeof(int), XtOffset(AppDataPtr, keepAlive), + XtRImmediate, (XtPointer) 0}, }; XrmOptionDescRec shellOptions[] = { @@ -1768,6 +1771,7 @@ XrmOptionDescRec shellOptions[] = { { "-secondOptions", "secondOptions", XrmoptionSepArg, NULL }, { "-firstNeedsNoncompliantFEN", "firstNeedsNoncompliantFEN", XrmoptionSepArg, NULL }, { "-secondNeedsNoncompliantFEN", "secondNeedsNoncompliantFEN", XrmoptionSepArg, NULL }, + { "-keepAlive", "keepAlive", XrmoptionSepArg, NULL }, }; @@ -2290,7 +2294,7 @@ void InitDrawingSizes(BoardSize boardSize, int flags) } #ifdef GOTHIC if(gameInfo.variant == VariantGothic) { - ximMaskPm[(int)WhiteMarshall] = ximMaskPm2[i][(int)WhiteSilver]; + ximMaskPm[(int)WhiteMarshall] = ximMaskPm2[(int)WhiteSilver]; } #endif #endif @@ -2320,6 +2324,19 @@ void InitDrawingSizes(BoardSize boardSize, int flags) } #endif +void EscapeExpand(char *p, char *q) +{ // [HGM] initstring: routine to shape up string arguments + while(*p++ = *q++) if(p[-1] == '\\') + switch(*q++) { + case 'n': p[-1] = '\n'; break; + case 'r': p[-1] = '\r'; break; + case 't': p[-1] = '\t'; break; + case '\\': p[-1] = '\\'; break; + case 0: *p = 0; return; + default: p[-1] = q[-1]; break; + } +} + int main(argc, argv) int argc; @@ -2378,7 +2395,6 @@ main(argc, argv) #endif #endif - setbuf(stdout, NULL); setbuf(stderr, NULL); debugFP = stderr; @@ -2407,7 +2423,7 @@ main(argc, argv) j = fprintf(stderr, " %s%s", shellOptions[i].option, (shellOptions[i].argKind == XrmoptionSepArg ? " ARG" : "")); - if (i++ < XtNumber(shellOptions)) { + if (i++ < XtNumber(shellOptions)) { fprintf(stderr, "%*c%s%s\n", 40 - j, ' ', shellOptions[i].option, (shellOptions[i].argKind == XrmoptionSepArg @@ -2419,16 +2435,6 @@ main(argc, argv) exit(2); } - if ((chessDir = (char *) getenv("CHESSDIR")) == NULL) { - chessDir = "."; - } else { - if (chdir(chessDir) != 0) { - fprintf(stderr, _("%s: can't cd to CHESSDIR: "), programName); - perror(chessDir); - exit(1); - } - } - p = getenv("HOME"); if (p == NULL) p = "/tmp"; i = strlen(p) + strlen("/.xboardXXXXXx.pgn") + 1; @@ -2441,6 +2447,28 @@ main(argc, argv) clientResources, XtNumber(clientResources), NULL, 0); + { // [HGM] initstring: kludge to fix bad bug. expand '\n' characters in init string and computer string. + static char buf[MSG_SIZ]; + EscapeExpand(buf, appData.initString); + appData.initString = strdup(buf); + EscapeExpand(buf, appData.secondInitString); + appData.secondInitString = strdup(buf); + EscapeExpand(buf, appData.firstComputerString); + appData.firstComputerString = strdup(buf); + EscapeExpand(buf, appData.secondComputerString); + appData.secondComputerString = strdup(buf); + } + + if ((chessDir = (char *) getenv("CHESSDIR")) == NULL) { + chessDir = "."; + } else { + if (chdir(chessDir) != 0) { + fprintf(stderr, _("%s: can't cd to CHESSDIR: "), programName); + perror(chessDir); + exit(1); + } + } + if (appData.debugMode && appData.nameOfDebugFile && strcmp(appData.nameOfDebugFile, "stderr")) { /* [DM] debug info to file [HGM] make the filename a command-line option, and allow it to remain stderr */ if ((debugFP = fopen(appData.nameOfDebugFile, "w")) == NULL) { @@ -3953,9 +3981,23 @@ void CreateXPMPieces() if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &(xpmPieceBitmap2[kind][piece]), NULL, &attr)) != 0) { - fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), - r, buf); - exit(1); + if(piece != (int)WhiteKing && piece > (int)WhiteQueen) { + // [HGM] missing: read of unorthodox piece failed; substitute King. + snprintf(buf, sizeof(buf), "%s/k%s%u.xpm", + ExpandPathName(appData.pixmapDirectory), + xpmkind[kind], ss); + if (appData.debugMode) { + fprintf(stderr, _("(Replace by File:%s:) "), buf); + } + r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, + &(xpmPieceBitmap2[kind][piece]), + NULL, &attr); + } + if (r != 0) { + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), + r, buf); + exit(1); + } } if(piece <= (int) WhiteKing) xpmPieceBitmap[kind][piece] = xpmPieceBitmap2[kind][piece]; @@ -8102,6 +8144,9 @@ void ScheduleDelayedEvent(cb, millisec) DelayedEventCallback cb; long millisec; { + if(delayedEventTimerXID && delayedEventCallback == cb) + // [HGM] alive: replace, rather than add or flush identical event + XtRemoveTimeOut(delayedEventTimerXID); delayedEventCallback = cb; delayedEventTimerXID = XtAppAddTimeOut(appContext, millisec,