From 9352746b95920fc75dfd8c01ecac048e79b7ae02 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 28 Nov 2021 10:16:52 +0100 Subject: Added possibility of having end-of-line comments with double slash (single slash actually); fixed a small memory leak --- src/alg.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') 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) continue; } + /* Single slash for comments */ + if (str[i] == '/') { + while (str[i] && str[i] != '\n') + i++; + + if (!str[i]) + i--; + + continue; + } + move_read = false; for (j = U; j < NMOVES; j++) { if (str[i] == move_string(j)[0] || @@ -270,8 +281,8 @@ new_alg(char *str) } if (!move_read) { - alg = new_alg(""); - return alg; + free(alg); + return new_alg(""); } } -- cgit v1.3