From 895402b0d893d236707aeeb4b42af08d57951f2a Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 30 Nov 2010 18:23:12 +0100 Subject: [PATCH] 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. --- backend.c | 2 ++ parser.l | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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; } -- 1.7.0.4