Browse files

Make event_block_t.event not a reference

Stylistic tweaks
  • Loading branch information...
1 parent e314311 commit 37bdb2009265b401aa1af64336d122949ff5d22b @ridiculousfish ridiculousfish committed Dec 22, 2012
Showing with 10 additions and 18 deletions.
  1. +1 −1 builtin.cpp
  2. +7 −13 event.cpp
  3. +0 −2 event.h
  4. +1 −1 parser.cpp
  5. +1 −1 parser.h
View
2 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);
View
20 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; i<events.size(); i++)
+ for (size_t i=0; i<events.size(); i++)
{
event_t *n = events.at(i);
if (event_match(criterion, *n))
@@ -452,7 +450,6 @@ static int event_is_killed(const event_t &e)
static void event_fire_internal(const event_t &event)
{
- size_t i, j;
event_list_t fire;
/*
@@ -472,7 +469,7 @@ static void event_fire_internal(const event_t &event)
event_add_handler, which will change the contents of the \c
events list.
*/
- for (i=0; i<events.size(); i++)
+ for (size_t i=0; i<events.size(); i++)
{
event_t *criterion = events.at(i);
@@ -495,7 +492,7 @@ static void event_fire_internal(const event_t &event)
Iterate over our list of matching events
*/
- for (i=0; i<fire.size(); i++)
+ for (size_t i=0; i<fire.size(); i++)
{
event_t *criterion = fire.at(i);
int prev_status;
@@ -511,14 +508,11 @@ static void event_fire_internal(const event_t &event)
*/
wcstring buffer = criterion->function_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() );
View
2 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);
View
2 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);
View
2 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);
};

0 comments on commit 37bdb20

Please sign in to comment.