From: H.G. Muller Date: Tue, 30 Nov 2010 17:23:12 +0000 (+0100) Subject: Allow line-straddling result comments X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=895402b0d893d236707aeeb4b42af08d57951f2a;p=xboard.git Allow line-straddling result comments Some GUIs (in particular Arena) do not have the decency to keep the result comment on a single line. In this case the parser rules would not recognize it, and treat it as a normal comment, plus an undetailed PGN result. The rules are now fixed to allow linefeeds in the comment, and between comment and PGN result. To correctly process the comment further (e.g. in game-list lines) the linefeeds are replaced by spaces in the back-end routines that do use the result comment. --- diff --git a/backend.c b/backend.c index 5ef3342..18ceb5a 100644 --- a/backend.c +++ b/backend.c @@ -8340,6 +8340,7 @@ ParseGameHistory(game) if (q != NULL) *q = NULLCHAR; p++; } + while(q = strchr(p, '\n')) *q = ' '; // [HGM] crush linefeeds in result message gameInfo.resultDetails = StrSave(p); continue; } @@ -9767,6 +9768,7 @@ LoadGameOneMove(readAhead) if (q != NULL) *q = NULLCHAR; p++; } + while(q = strchr(p, '\n')) *q = ' '; // [HGM] crush linefeeds in result message GameEnds(moveType, p, GE_FILE); done = TRUE; if (cmailMsgLoaded) { diff --git a/parser.l b/parser.l index 88567ef..e78c23c 100644 --- a/parser.l +++ b/parser.l @@ -902,19 +902,19 @@ extern void CopyBoard P((Board to, Board from)); return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins); } -("{"[^\}\n]*"} ")?(1-0|"1 - 0"|"1/0"|"1 / 0"|"1:0"|"1 : 0")(" (".*")"|" {".*"}")? { +("{"[^\}]*"}"[ \n])?(1-0|"1 - 0"|"1/0"|"1 / 0"|"1:0"|"1 : 0")(" (".*")"|" {".*"}")? { return (int) WhiteWins; } -("{"[^\}\n]*"} ")?(0-1|"0 - 1"|"0/1"|"0 / 1"|"0:1"|"0 : 1")(" (".*")"|" {".*"}")? { +("{"[^\}]*"}"[ \n])?(0-1|"0 - 1"|"0/1"|"0 / 1"|"0:1"|"0 : 1")(" (".*")"|" {".*"}")? { return (int) BlackWins; } -("{"[^\}\n]*"} ")?("1/2"|"1 / 2")(" "?[-:]" "?("1/2"|"1 / 2"))?(" (".*")"|" {".*"}")? { +("{"[^\}]*"}"[ \n])?("1/2"|"1 / 2")(" "?[-:]" "?("1/2"|"1 / 2"))?(" (".*")"|" {".*"}")? { return (int) GameIsDrawn; } -("{"[^\}\n]*"} ")?"*"(" (".*")"|" {".*"}")? { +("{"[^\}]*"}"[ \n])?"*"(" (".*")"|" {".*"}")? { return (int) GameUnfinished; }