From: Michael Stapelberg Date: Fri, 12 Nov 2010 19:22:55 +0000 (+0100) Subject: parser: don’t exit(1) on invalid command, use better error message X-Git-Tag: tree-pr1~124 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e07fee447232d375aa913754875dd3bff9cc9a88;p=i3%2Fi3 parser: don’t exit(1) on invalid command, use better error message --- diff --git a/src/cmdparse.y b/src/cmdparse.y index bcf144cd..d79698e4 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -49,8 +49,7 @@ static char *json_output; void cmdyyerror(const char *error_message) { ELOG("\n"); ELOG("CMD: %s\n", error_message); - ELOG("CMD: in file \"%s\", line %d:\n", - context->filename, context->line_number); + ELOG("CMD: in command:\n"); ELOG("CMD: %s\n", context->line_copy); ELOG("CMD: "); for (int c = 1; c <= context->last_column; c++) @@ -66,9 +65,6 @@ int cmdyywrap() { } char *parse_cmd(const char *new) { - - //const char *new = "[level-up workspace] attach $output, focus"; - cmdyy_scan_string(new); match_init(¤t_match); @@ -76,8 +72,10 @@ char *parse_cmd(const char *new) { context->filename = "cmd"; FREE(json_output); if (cmdyyparse() != 0) { - fprintf(stderr, "Could not parse configfile\n"); - exit(1); + fprintf(stderr, "Could not parse command\n"); + FREE(context->line_copy); + free(context); + return; } printf("done, json output = %s\n", json_output); diff --git a/testcases/Makefile b/testcases/Makefile index 462ca397..06a7cfa1 100644 --- a/testcases/Makefile +++ b/testcases/Makefile @@ -1,5 +1,5 @@ test: - PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1)" -It/lib t/*.t + PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1)" -It/lib t/34*.t all: test