X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=d60b833cf997b6f87795147b16b94739dd3dca47;hb=3536ccf4ea73a0157ef01ae42c72e5448543eb39;hp=08dc5131af11b0b219c497a28213d44daf16c760;hpb=81a640a52b1e72cc1d26d9d85a6644ffb933b06c;p=xboard.git diff --git a/parser.c b/parser.c index 08dc513..d60b833 100644 --- a/parser.c +++ b/parser.c @@ -1,7 +1,7 @@ /* * parser.c -- * - * Copyright 2011, 2012, 2013 Free Software Foundation, Inc. + * Copyright 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -87,7 +87,7 @@ SkipWhite (char **p) return *p != start; } -inline int +static inline int Match (char *pattern, char **ptr) { char *p = pattern, *s = *ptr; @@ -99,7 +99,7 @@ Match (char *pattern, char **ptr) return 0; // no match, no ptr update } -inline int +static inline int Word (char *pattern, char **p) { if(Match(pattern, p)) return 1; @@ -174,6 +174,10 @@ NextUnit (char **p) if(fromString) return 0; // we are parsing string, so the end is really the end *p = inPtr = inputBuf; if(!ReadLine()) return 0; // EOF + } else if(inPtr > inputBuf + PARSEBUFSIZE/2) { // buffer fills up with already parsed stuff + char *q = *p, *r = inputBuf; + while(*r++ = *q++); + *p = inputBuf; inPtr = r - 1; } parseStart = oldp = *p; // remember where we begin @@ -263,6 +267,7 @@ NextUnit (char **p) fromY = DROP_RANK; fromX = cl.pieceIn; currentMoveString[0] = piece; currentMoveString[1] = '@'; + currentMoveString[4] = NULLCHAR; return LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, fromY, fromX, toY, toX, NULLCHAR); } if(type[1] == NOTHING && type[0] != NOTHING) { // there is a disambiguator