Rev 69 | Rev 72 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 69 | Rev 71 | ||
|---|---|---|---|
| Line 32... | Line 32... | ||
| 32 | { |
32 | { |
| 33 | // this function loads a PGN file and builds the game databases of the games described in this file |
33 | // this function loads a PGN file and builds the game databases of the games described in this file |
| 34 | 34 | ||
| 35 | char line_buffer[256]; // PGN files have 256 chars max per line by design |
35 | char line_buffer[256]; // PGN files have 256 chars max per line by design |
| 36 | char *buffer; |
36 | char *buffer; |
| - | 37 | char *ptr; |
|
| 37 | int file_index; |
38 | int file_index; |
| 38 | int char_index; |
39 | int char_index; |
| 39 | int entry_count; |
40 | int entry_count; |
| 40 | FILE *fp; |
41 | FILE *fp; |
| 41 | size_t converted_count; // used by the STRING_TO_CHAR macro |
42 | size_t converted_count; // used by the STRING_TO_CHAR macro |
| Line 86... | Line 87... | ||
| 86 | } |
87 | } |
| 87 | 88 | ||
| 88 | // else have we found a game already ? |
89 | // else have we found a game already ? |
| 89 | else if (entry_count > 0) |
90 | else if (entry_count > 0) |
| 90 | { |
91 | { |
| 91 | // is it |
92 | // is it a tag ? (i.e: line BEGINS with a opening bracket and the first closing bracket ENDS it) |
| 92 | if (line_buffer[0] == '[') |
93 | if ((line_buffer[0] == '[') && (ptr = strchr (line_buffer, ']')) && ((ptr[1] == '\r') || (ptr[1] == 0))) |
| 93 | { |
94 | { |
| 94 | if (strncmp (&line_buffer[1], "Site \"", 6) == 0) |
95 | if (strncmp (&line_buffer[1], "Site \"", 6) == 0) |
| 95 | COPY_TIL_LAST_QUOTEMARK (games[entry_count - 1].site_str, &line_buffer[7]) // copy site |
96 | COPY_TIL_LAST_QUOTEMARK (games[entry_count - 1].site_str, &line_buffer[7]) // copy site |
| 96 | else if (strncmp (&line_buffer[1], "Date \"", 6) == 0) |
97 | else if (strncmp (&line_buffer[1], "Date \"", 6) == 0) |
| 97 | COPY_TIL_LAST_QUOTEMARK (games[entry_count - 1].date_str, &line_buffer[7]) // copy date |
98 | COPY_TIL_LAST_QUOTEMARK (games[entry_count - 1].date_str, &line_buffer[7]) // copy date |