aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-28 10:16:52 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-28 10:16:52 +0100
commit9352746b95920fc75dfd8c01ecac048e79b7ae02 (patch)
treef35aa96590836fba26a22620ba83d986fe4711ff /src
parent0f65f1b71124cb974cf06c32439c2a2bad422659 (diff)
downloadnissy-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.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/alg.c b/src/alg.c
index cd6834c..4e96925 100644
--- a/src/alg.c
+++ b/src/alg.c
@@ -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

Generated with cgit - Back to sebastiano.tronto.net