make command-line arguments more flexible - chess-puzzles - chess puzzle book g… | |
git clone git://git.codemadness.org/chess-puzzles | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 0bf730b426ada19f487f1791faf13269989abc04 | |
parent 132c4a50aae9c410bf3b505f4c61b322c388cf83 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 20 Dec 2023 18:50:17 +0100 | |
make command-line arguments more flexible | |
Diffstat: | |
M fen_to_svg.c | 18 +++++++++++++----- | |
1 file changed, 13 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/fen_to_svg.c b/fen_to_svg.c | |
@@ -391,17 +391,25 @@ main(int argc, char *argv[]) | |
char square[3]; | |
long l; | |
- if (argc != 3) { | |
- fprintf(stderr, "usage: %s <FEN> <moves>\n", argv[0]); | |
+ if (argc > 3) { | |
+ fprintf(stderr, "usage: %s <FEN> [moves] or\n", argv[0]); | |
+ fprintf(stderr, " %s <FEN> or\n", argv[0]); | |
+ fprintf(stderr, " %s\n", argv[0]); | |
return 1; | |
} | |
+ if (argc > 1) | |
+ fen = argv[1]; | |
+ else | |
+ fen = "startpos"; | |
+ | |
+ if (argc > 2) | |
+ moves = argv[2]; | |
+ else | |
+ moves = ""; | |
- fen = argv[1]; | |
if (!strcmp(fen, "startpos")) | |
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 … | |
- moves = argv[2]; | |
- | |
/* initial board state, FEN format */ | |
x = y = field = 0; | |
for (s = fen; *s; s++) { |