X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=a7705c4e77e8b09f8345da293c1b2e09c052605e;hb=098f667a67c83a5c0b8b8d46f4fe0c8d7f9149da;hp=5a8df2b4bfe96f11faec8f040d76c91be1270457;hpb=d7ba1f9301bde533d4eaf67586922a7b7ab30ce8;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 5a8df2b..a7705c4 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -435,7 +435,7 @@ BOOLEAN evalGraphDialogUp = FALSE; WindowPlacement wpEvalGraph; HWND engineOutputDialog = NULL; -BOOLEAN engineOutputDialogUp = FALSE; +int engineOutputDialogUp = FALSE; WindowPlacement wpEngineOutput; WindowPlacement wpGameList; @@ -1462,6 +1462,15 @@ ExitArgError(char *msg, char *badArg) exit(2); } +int +ValidateInt(char *s) +{ + char *p = s; + if(*p == '-' || *p == '+') p++; + while(*p) if(!isdigit(*p++)) ExitArgError("Bad integer value", s); + return atoi(s); +} + /* Command line font name parser. NULL name means do nothing. Syntax like "Courier New:10.0 bi" or "Arial:10" or "Arial:10b" For backward compatibility, syntax without the colon is also @@ -1773,19 +1782,19 @@ ParseArgs(GetFunc get, void *cl) switch (ad->argType) { case ArgInt: - *(int *) ad->argLoc = atoi(argValue); + *(int *) ad->argLoc = ValidateInt(argValue); break; case ArgX: - *(int *) ad->argLoc = atoi(argValue) + boardX; // [HGM] placement: translate stored relative to absolute + *(int *) ad->argLoc = ValidateInt(argValue) + boardX; // [HGM] placement: translate stored relative to absolute break; case ArgY: - *(int *) ad->argLoc = atoi(argValue) + boardY; // (this is really kludgey, it should be done where used...) + *(int *) ad->argLoc = ValidateInt(argValue) + boardY; // (this is really kludgey, it should be done where used...) break; case ArgZ: - *(int *) ad->argLoc = atoi(argValue); + *(int *) ad->argLoc = ValidateInt(argValue); EnsureOnScreen(&boardX, &boardY, minX, minY); break; @@ -7186,13 +7195,8 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } // [HGM] movenum: allow move number to be typed in any mode if(sscanf(move, "%d", &n) == 1 && n != 0 ) { - currentMove = 2*n-1; - if(currentMove > forwardMostMove) currentMove = forwardMostMove; - if(currentMove < backwardMostMove) currentMove = backwardMostMove; + ToNrEvent(2*n-1); EndDialog(hDlg, TRUE); - DrawPosition(TRUE, boards[currentMove]); - if(currentMove > backwardMostMove) DisplayMove(currentMove - 1); - else DisplayMessage("", ""); return TRUE; } }