aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-24 16:17:16 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-24 16:17:16 +0100
commit5d1796920e7c20e8f99f106935e10b8ec9296aba (patch)
tree231e2e02c96e4399cab5d5748c9bfb366e7ee510
parent4179c0505603f8a4fab46e1e9effea0e11aa64fe (diff)
Take into account move annotations such as !! !? +-
-rw-r--r--src/PGN.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/PGN.cpp b/src/PGN.cpp
index dcc0661..155c815 100644
--- a/src/PGN.cpp
+++ b/src/PGN.cpp
@@ -4,10 +4,24 @@
#include <string>
#define IS_BLANK(c) (c == ' ' || c == '\n' || c == '\t' || c == '\r')
+#define IS_ALPHA(c) \
+ ((c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || \
+ c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || \
+ c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || \
+ c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || \
+ c == 'y' || c == 'z') || \
+ (c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || \
+ c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == 'K' || c == 'L' || \
+ c == 'M' || c == 'N' || c == 'O' || c == 'P' || c == 'Q' || c == 'R' || \
+ c == 'S' || c == 'T' || c == 'U' || c == 'V' || c == 'W' || c == 'X' || \
+ c == 'Y' || c == 'Z'))
#define IS_DIGIT(c) \
(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || \
c == '6' || c == '7' || c == '8' || c == '9')
#define IS_EOF (pgn_content.IsEOF())
+#define IS_TOKEN(c) \
+ (IS_DIGIT(c) || IS_ALPHA(c) || c == '{' || c == '}' || c == '(' || \
+ c == ')' || c == '[' || c == ']' || c == '$' || c == '"' || c=='*')
#define EOF_CHECK(loc) \
{ \
if (IS_EOF) \
@@ -61,7 +75,7 @@ void PGN::ParseNextGame() {
break;
} else if (c == '*') {
result = "*";
- LastGameEndLoc=loc+1;
+ LastGameEndLoc = loc + 1;
break;
} else if (c == '{') {
loc = ParseComment(loc, moves);
@@ -326,7 +340,7 @@ std::string PGN::Dump() {
loctype PGN::GotoNextToken(loctype loc) {
char c = pgn_content[loc];
- while (IS_BLANK(c)) {
+ while (IS_BLANK(c) || !IS_TOKEN(c)) {
loc++;
if (IS_EOF) {
return (loc);
@@ -341,7 +355,6 @@ loctype PGN::GotoNextToken(loctype loc) {
}
}
}
-
return (loc);
}