From 84f9a8ee1b68abededde761bc99764e764874fc0 Mon Sep 17 00:00:00 2001 From: Lucas RODRIGUEZ Date: Tue, 11 Jun 2024 13:23:15 +0000 Subject: [PATCH] Fix cascade parsing Signed-off-by: Lucas RODRIGUEZ --- cli-version | 2 +- cognac_gen.sh | 4 ++-- main_tpl.c | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cli-version b/cli-version index 1270e85..1d0ba9e 100644 --- a/cli-version +++ b/cli-version @@ -1 +1 @@ -DEV-VERSION +0.4.0 diff --git a/cognac_gen.sh b/cognac_gen.sh index dfe1696..fcc7606 100755 --- a/cognac_gen.sh +++ b/cognac_gen.sh @@ -340,7 +340,7 @@ EOF aa = eq_ptr + 1; } else { CHK_BAD_RET(!aa, "cascade need an argument\n"); - META_ARGS() + META_ARGS({CHK_BAD_RET(aa[0] == '-', "cascade need an argument"); }) } STRY(cascade_parser(cascade_struct, next_a, aa, pa)); i += incr; @@ -356,7 +356,7 @@ EOF (void)str; if (aa && aa[0] == '-' && aa[1] == '-' && aa[2] != '-') { - META_ARGS(); + META_ARGS({ aa = 0; incr = 1; }); } EOF diff --git a/main_tpl.c b/main_tpl.c index 6333030..242119a 100644 --- a/main_tpl.c +++ b/main_tpl.c @@ -61,7 +61,7 @@ if (f) {fprintf(stderr, args); return -1;} \ } while(0) -#define META_ARGS() \ +#define META_ARGS(else_cnd) \ if (!strcmp(aa, "--file")) { \ TRY(i + 3 >= ac, "file name require"); \ ++incr; \ @@ -84,10 +84,9 @@ TRY(!var_found, "--var could not find osc variable '%s'", av[i + 3]); \ ++incr; \ STRY(!aa); \ - } else { \ - aa = 0; \ - incr = 1; \ - } + } else \ + else_cnd + #define VAR_NAME_SIZE 128 #define VAR_VAL_SIZE 512