Commits

Anonymous committed 37bdb20

Make event_block_t.event not a reference
Stylistic tweaks

Comments (0)

Files changed (5)

         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);
 
 
 void event_remove(const event_t &criterion)
 {
-
-    size_t i;
     event_list_t new_list;
 
     if (debug_level >= 3)
     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))
 static void event_fire_internal(const event_t &event)
 {
 
-    size_t i, j;
     event_list_t fire;
 
     /*
       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);
 
       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;
         */
         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() );
     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);
 
                     int tmp;
                     const wchar_t *cmd = args.at(0).completion.c_str();
-                    wcstring_list_t event_args;
 
                     /*
                      We couldn't find the specified command.
 
                     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);
 
 struct event_block_t : public block_t
 {
-    event_t const &event;
+    event_t const event;
     event_block_t(const event_t &evt);
 };