From 37bdb2009265b401aa1af64336d122949ff5d22b Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 22 Dec 2012 12:40:34 -0800 Subject: [PATCH] Make event_block_t.event not a reference Stylistic tweaks --- builtin.cpp | 2 +- event.cpp | 20 +++++++------------- event.h | 2 -- parser.cpp | 2 +- parser.h | 2 +- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/builtin.cpp b/builtin.cpp index e22d1c803..d7d06e9c5 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1014,7 +1014,7 @@ static int builtin_emit(parser_t &parser, wchar_t **argv) append_format(stderr_buffer, L"%ls: expected event name\n", argv[0]); return STATUS_BUILTIN_ERROR; } - wchar_t *eventname = argv[woptind]; + const wchar_t *eventname = argv[woptind]; wcstring_list_t args(argv + woptind + 1, argv + argc); event_fire_generic(eventname, &args); diff --git a/event.cpp b/event.cpp index 00b9e444f..b43f2e9c7 100644 --- a/event.cpp +++ b/event.cpp @@ -330,8 +330,6 @@ void event_add_handler(const event_t &event) void event_remove(const event_t &criterion) { - - size_t i; event_list_t new_list; if (debug_level >= 3) @@ -352,7 +350,7 @@ void event_remove(const event_t &criterion) if (events.empty()) return; - for (i=0; ifunction_name; - if (! event.arguments.empty()) + for (size_t j=0; j < event.arguments.size(); j++) { - for (j=0; j < event.arguments.size(); j++) - { - wcstring arg_esc = escape_string(event.arguments.at(j), 1); - buffer += L" "; - buffer += arg_esc; - } + wcstring arg_esc = escape_string(event.arguments.at(j), 1); + buffer += L" "; + buffer += arg_esc; } // debug( 1, L"Event handler fires command '%ls'", buffer.c_str() ); diff --git a/event.h b/event.h index 5f497c680..5f7c8080f 100644 --- a/event.h +++ b/event.h @@ -89,8 +89,6 @@ struct event_t event_t(int t) : type(t), param1(), str_param1(), function_name(), arguments() { } /** default copy constructor */ - //event_t(const event_t &x); - static event_t signal_event(int sig); static event_t variable_event(const wcstring &str); diff --git a/parser.cpp b/parser.cpp index a2caebef8..361c3d0f9 100644 --- a/parser.cpp +++ b/parser.cpp @@ -2077,7 +2077,6 @@ int parser_t::parse_job(process_t *p, int tmp; const wchar_t *cmd = args.at(0).completion.c_str(); - wcstring_list_t event_args; /* We couldn't find the specified command. @@ -2159,6 +2158,7 @@ int parser_t::parse_job(process_t *p, job_set_flag(j, JOB_SKIP, 1); + wcstring_list_t event_args; event_args.push_back(args.at(0).completion); event_fire_generic(L"fish_command_not_found", &event_args); proc_set_last_status(err==ENOENT?STATUS_UNKNOWN_COMMAND:STATUS_NOT_EXECUTABLE); diff --git a/parser.h b/parser.h index b956be4d5..e36a1a924 100644 --- a/parser.h +++ b/parser.h @@ -158,7 +158,7 @@ struct if_block_t : public block_t struct event_block_t : public block_t { - event_t const &event; + event_t const event; event_block_t(const event_t &evt); };