From 07d6da5f23ad895ce19f192c8b8f7a7af81292af Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 2 Dec 2014 15:53:55 +0100 Subject: mds-kbdc: parse --force flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/globals.c | 5 +++++ src/mds-kbdc/globals.h | 5 +++++ src/mds-kbdc/mds-kbdc.c | 17 +++++++++++++++++ src/mds-kbdc/simplify-tree.c | 1 - 4 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mds-kbdc/globals.c b/src/mds-kbdc/globals.c index bf2f91d..d5ae0d6 100644 --- a/src/mds-kbdc/globals.c +++ b/src/mds-kbdc/globals.c @@ -28,3 +28,8 @@ int argc; */ char** argv; +/** + * Whether ‘--force’ is used + */ +int argv_force = 0; + diff --git a/src/mds-kbdc/globals.h b/src/mds-kbdc/globals.h index 85a226d..068a304 100644 --- a/src/mds-kbdc/globals.h +++ b/src/mds-kbdc/globals.h @@ -29,6 +29,11 @@ extern int argc; */ extern char** argv; +/** + * Whether ‘--force’ is used + */ +extern int argv_force; + #endif diff --git a/src/mds-kbdc/mds-kbdc.c b/src/mds-kbdc/mds-kbdc.c index 6f4be18..65960dd 100644 --- a/src/mds-kbdc/mds-kbdc.c +++ b/src/mds-kbdc/mds-kbdc.c @@ -33,6 +33,21 @@ +/** + * Parse command line arguments + */ +void parse_cmdline(void) +{ + int i; + for (i = 0; i < argc; i++) + { + char* arg = argv[i]; + if (strequals(arg, "--force")) + argv_force = 1; + } +} + + /** * Compile a keyboard layout file * @@ -53,6 +68,8 @@ int main(int argc_, char** argv_) argc = argc_; argv = argv_; + parse_cmdline(); + mds_kbdc_parsed_initialise(&result); process (parse_to_tree(argv[1], &result)); process (simplify_tree(&result)); diff --git a/src/mds-kbdc/simplify-tree.c b/src/mds-kbdc/simplify-tree.c index 26a0084..170c9ef 100644 --- a/src/mds-kbdc/simplify-tree.c +++ b/src/mds-kbdc/simplify-tree.c @@ -692,7 +692,6 @@ static int simplify_unordered(mds_kbdc_tree_unordered_t* restrict tree) mds_kbdc_tree_t** here; int allow_long = 0; size_t argument_count; - int argv_force = 0; /* TODO globals.h */ /* Test for ‘(( ))’. */ if (tree->inner && (tree->inner->next == NULL) && (tree->inner->type == C(UNORDERED))) -- cgit v1.2.3-70-g09d2