X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=a7705c4e77e8b09f8345da293c1b2e09c052605e;hb=098f667a67c83a5c0b8b8d46f4fe0c8d7f9149da;hp=7678dae4160e2ecda21b7d5c26dbdabdabd7370a;hpb=5808ac6ec32f1355eead1c78bf71927b1c91d738;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 7678dae..a7705c4 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -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; } }