diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-28 10:16:52 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-28 10:16:52 +0100 |
| commit | 9352746b95920fc75dfd8c01ecac048e79b7ae02 (patch) | |
| tree | f35aa96590836fba26a22620ba83d986fe4711ff /src | |
| parent | 0f65f1b71124cb974cf06c32439c2a2bad422659 (diff) | |
| download | nissy-9352746b95920fc75dfd8c01ecac048e79b7ae02.tar.gz nissy-9352746b95920fc75dfd8c01ecac048e79b7ae02.zip | |
Added possibility of having end-of-line comments with double slash (single slash actually); fixed a small memory leak
Diffstat (limited to '')
| -rw-r--r-- | src/alg.c | 15 |
1 files changed, 13 insertions, 2 deletions
| @@ -230,6 +230,17 @@ new_alg(char *str) | |||
| 230 | continue; | 230 | continue; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | /* Single slash for comments */ | ||
| 234 | if (str[i] == '/') { | ||
| 235 | while (str[i] && str[i] != '\n') | ||
| 236 | i++; | ||
| 237 | |||
| 238 | if (!str[i]) | ||
| 239 | i--; | ||
| 240 | |||
| 241 | continue; | ||
| 242 | } | ||
| 243 | |||
| 233 | move_read = false; | 244 | move_read = false; |
| 234 | for (j = U; j < NMOVES; j++) { | 245 | for (j = U; j < NMOVES; j++) { |
| 235 | if (str[i] == move_string(j)[0] || | 246 | if (str[i] == move_string(j)[0] || |
| @@ -270,8 +281,8 @@ new_alg(char *str) | |||
| 270 | } | 281 | } |
| 271 | 282 | ||
| 272 | if (!move_read) { | 283 | if (!move_read) { |
| 273 | alg = new_alg(""); | 284 | free(alg); |
| 274 | return alg; | 285 | return new_alg(""); |
| 275 | } | 286 | } |
| 276 | } | 287 | } |
| 277 | 288 | ||
