X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=a7705c4e77e8b09f8345da293c1b2e09c052605e;hb=098f667a67c83a5c0b8b8d46f4fe0c8d7f9149da;hp=1e65185420139d768f9a9d0cde816d0d2bf76545;hpb=45cb613eb2a95c13857b1919c97d3a0db5b8f9ec;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 1e65185..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;