aboutsummaryrefslogtreecommitdiffhomepage
path: root/function.c
diff options
context:
space:
mode:
authorGravatar Christopher Nilsson <christopher@otherchirps.net>2010-09-09 23:48:18 +1000
committerGravatar Christopher Nilsson <christopher@otherchirps.net>2010-09-09 23:48:18 +1000
commit7914c92824dfbb07466a37f12c7a06c7dd5f4de4 (patch)
tree359478875512128c95ab68b4b4cbfbd93ce01832 /function.c
parent208be0f4d4f42abe8e01eae0e41e22e8ac6bae0f (diff)
replaced the functions '--rename' option with '--copy'.
Copying the function implementation was the main point. Actually removing the original isn't necessary, as that functionality already exists (functions -e).
Diffstat (limited to 'function.c')
-rw-r--r--function.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/function.c b/function.c
index 678f6cea..5b2dcd5a 100644
--- a/function.c
+++ b/function.c
@@ -222,8 +222,6 @@ int function_copy( const wchar_t *name, const wchar_t *new_name )
{
int i;
function_internal_data_t *d, *orig_d;
- event_t ev, *orig_ev;
- array_list_t *fn_events;
CHECK( name, 0 );
CHECK( new_name, 0 );
@@ -245,41 +243,19 @@ int function_copy( const wchar_t *name, const wchar_t *new_name )
al_push( d->named_arguments, halloc_wcsdup( d, (wchar_t *)al_get( orig_d->named_arguments, i ) ) );
}
d->description = orig_d->description?halloc_wcsdup(d, orig_d->description):0;
+ d->shadows = orig_d->shadows;
+
+ // This new instance of the function shouldn't be tied to the def
+ // file of the original.
d->definition_file = 0;
d->is_autoload = 0;
- d->shadows = orig_d->shadows;
}
hash_put( &function, intern(new_name), d );
- // wire up the same events... if any.
- ev.type = EVENT_ANY;
- ev.function_name = name;
- event_get(&ev, fn_events);
-
- if( fn_events )
- {
- ev.function_name = new_name;
-
- for( i=0; i<al_get_count( fn_events ); i++ )
- {
- orig_ev = (event_t *)al_get( fn_events, i );
-
- // event_add_handler will deep-copy ev, so we can reuse.
- ev.type = orig_ev->type;
- ev.param1 = orig_ev->param1;
- event_add_handler( &ev );
- }
- }
return 1;
}
-void function_rename( const wchar_t *name, const wchar_t *new_name )
-{
- if( function_copy( name, new_name ) )
- function_remove( name );
-}
-
int function_exists( const wchar_t *cmd )
{