From e07fee447232d375aa913754875dd3bff9cc9a88 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 12 Nov 2010 20:22:55 +0100 Subject: [PATCH] =?utf8?q?parser:=20don=E2=80=99t=20exit(1)=20on=20invalid?= =?utf8?q?=20command,=20use=20better=20error=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmdparse.y | 12 +++++------- testcases/Makefile | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) 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 -- 2.39.5