aboutsummaryrefslogtreecommitdiffhomepage
path: root/function.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-06-21 10:48:36 +1000
committerGravatar axel <axel@liljencrantz.se>2006-06-21 10:48:36 +1000
commitb016438c08877cb3b24808d260397a8aa8fe49ce (patch)
tree7d8879449234a75e28b4295725a3df411dcbb3aa /function.c
parent7268a4a4e0ddb8ed10df20005cd78c90e900802f (diff)
Update input validation. Always use the magic CHECK macro, which prints an error message including instructions on how to report this problem.
darcs-hash:20060621004836-ac50b-a47f296634eda0c469eb39034603015b1ad7ab5c.gz
Diffstat (limited to 'function.c')
-rw-r--r--function.c71
1 files changed, 19 insertions, 52 deletions
diff --git a/function.c b/function.c
index e04366e2..0fd05ce2 100644
--- a/function.c
+++ b/function.c
@@ -176,13 +176,9 @@ void function_add( const wchar_t *name,
wchar_t *cmd_end;
function_data_t *d;
+ CHECK( name, );
+ CHECK( val, );
- if( !name || !val )
- {
- debug( 0, L"%s called with null input", __func__ );
- return;
- }
-
function_remove( name );
d = malloc( sizeof( function_data_t ) );
@@ -212,12 +208,8 @@ void function_add( const wchar_t *name,
int function_exists( const wchar_t *cmd )
{
- if( !cmd )
- {
- debug( 0, L"%s called with null input", __func__ );
- return 0;
- }
-
+ CHECK( cmd, 0 );
+
if( parser_is_reserved(cmd) )
return 0;
@@ -232,12 +224,8 @@ void function_remove( const wchar_t *name )
function_data_t *d;
event_t ev;
- if( !name )
- {
- debug( 0, L"%s called with null input", __func__ );
- return;
- }
-
+ CHECK( name, );
+
hash_remove( &function,
name,
&key,
@@ -259,12 +247,8 @@ const wchar_t *function_get_definition( const wchar_t *argv )
{
function_data_t *data;
- if( !argv )
- {
- debug( 0, L"%s called with null input", __func__ );
- return 0;
- }
-
+ CHECK( argv, 0 );
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -275,12 +259,9 @@ const wchar_t *function_get_definition( const wchar_t *argv )
const wchar_t *function_get_desc( const wchar_t *argv )
{
function_data_t *data;
- if( !argv )
- {
- debug( 0, L"%s called with null input", __func__ );
- return 0;
- }
+ CHECK( argv, 0 );
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -292,11 +273,9 @@ const wchar_t *function_get_desc( const wchar_t *argv )
void function_set_desc( const wchar_t *name, const wchar_t *desc )
{
function_data_t *data;
- if( !name || !desc )
- {
- debug( 0, L"%s called with null input", __func__ );
- return;
- }
+
+ CHECK( name, );
+ CHECK( desc, );
load( name );
data = (function_data_t *)hash_get( &function, name );
@@ -355,12 +334,8 @@ static void get_names_internal_all( void *key,
void function_get_names( array_list_t *list, int get_hidden )
{
- if( !list )
- {
- debug( 0, L"%s called with null input", __func__ );
- return;
- }
-
+ CHECK( list, );
+
autoload_names( list, get_hidden );
if( get_hidden )
@@ -378,12 +353,8 @@ const wchar_t *function_get_definition_file( const wchar_t *argv )
{
function_data_t *data;
- if( !argv )
- {
- debug( 0, L"%s called with null input", __func__ );
- return 0;
- }
-
+ CHECK( argv, 0 );
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -397,12 +368,8 @@ int function_get_definition_offset( const wchar_t *argv )
{
function_data_t *data;
- if( !argv )
- {
- debug( 0, L"%s called with null input", __func__ );
- return -1;
- }
-
+ CHECK( argv, -1 );
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )