diff --git a/builtin.c b/builtin.c index 6f3e2afbf..c8ddab6f2 100644 --- a/builtin.c +++ b/builtin.c @@ -66,12 +66,7 @@ #include "parse_util.h" #include "expand.h" -#include "builtin_help.c" -#include "builtin_set.c" -#include "builtin_commandline.c" -#include "builtin_complete.c" -#include "builtin_ulimit.c" -#include "builtin_jobs.c" + /** The default prompt for the read command @@ -139,7 +134,11 @@ static int builtin_stdin; */ static hash_table_t *desc=0; -int builtin_count_args( wchar_t **argv ) +/** + Counts the number of non null pointers in the specified array +*/ + +static int builtin_count_args( wchar_t **argv ) { int argc = 1; while( argv[argc] != 0 ) @@ -149,8 +148,13 @@ int builtin_count_args( wchar_t **argv ) return argc; } +/** + This function works like wperror, but it prints its result into + the sb_err string_buffer_t instead of to stderr. Used by the builtin + commands. +*/ -void builtin_wperror( const wchar_t *s) +static void builtin_wperror( const wchar_t *s) { if( s != 0 ) { @@ -178,26 +182,18 @@ static int count_char( const wchar_t *str, wchar_t c ) return res; } -/* - Here follows the definition of all builtin commands. The function - names are all on the form builtin_NAME where NAME is the name of the - builtin. so the function name for the builtin 'fg' is - 'builtin_fg'. +/** + Print help for the specified builtin. If \c b is sb_err, also print + the line information - A few builtins, including 'while', 'command' and 'builtin' are not - defined here as they are handled directly by the parser. (They are - not parsed as commands, instead they only alter the parser state) - - The builtins 'break' and 'continue' are so closely related that they - share the same implementation, namely 'builtin_break_continue. - - Several other builtins, including jobs, ulimit and set are so big - that they have been given their own file. These files are all named - 'builtin_NAME.c', where NAME is the name of the builtin. + If \c b is the buffer representing standard error, and the help + message is about to be printed to an interactive screen, it may be + shortened to fit the screen. */ -void builtin_print_help( wchar_t *cmd, string_buffer_t *b ) + +static void builtin_print_help( wchar_t *cmd, string_buffer_t *b ) { const char *h; @@ -260,6 +256,35 @@ void builtin_print_help( wchar_t *cmd, string_buffer_t *b ) free( str ); } } + +/* + Here follows the definition of all builtin commands. The function + names are all on the form builtin_NAME where NAME is the name of the + builtin. so the function name for the builtin 'fg' is + 'builtin_fg'. + + A few builtins, including 'while', 'command' and 'builtin' are not + defined here as they are handled directly by the parser. (They are + not parsed as commands, instead they only alter the parser state) + + The builtins 'break' and 'continue' are so closely related that they + share the same implementation, namely 'builtin_break_continue. + + Several other builtins, including jobs, ulimit and set are so big + that they have been given their own file. These files are all named + 'builtin_NAME.c', where NAME is the name of the builtin. + +*/ + + +#include "builtin_help.c" +#include "builtin_set.c" +#include "builtin_commandline.c" +#include "builtin_complete.c" +#include "builtin_ulimit.c" +#include "builtin_jobs.c" + + /** The bind builtin, used for setting character sequences */ diff --git a/builtin.h b/builtin.h index bd99808af..8ef136339 100644 --- a/builtin.h +++ b/builtin.h @@ -136,22 +136,6 @@ void builtin_pop_io(); */ const wchar_t *builtin_get_desc( const wchar_t *b ); -/** - Counts the number of non null pointers in the specified array -*/ -int builtin_count_args( wchar_t **argv ); - -/** - Print help for the specified builtin. If \c b is sb_err, also print - the line information - - If \c b is the buffer representing standard error, and the help - message is about to be printed to an interactive screen, it may be - shortened to fit the screen. - -*/ -void builtin_print_help( wchar_t *cmd, string_buffer_t *b ); - /** Slightly kludgy function used with 'complete -C' in order to make @@ -160,12 +144,6 @@ void builtin_print_help( wchar_t *cmd, string_buffer_t *b ); */ const wchar_t *builtin_complete_get_temporary_buffer(); -/** - This function works like wperror, but it prints its result into - the sb_err string_buffer_t instead of to stderr. Used by the builtin - commands. -*/ -void builtin_wperror( const wchar_t *s); /** Return the help text for the specified builtin command. Use diff --git a/builtin_set.c b/builtin_set.c index c41cd4376..f4aaf920d 100644 --- a/builtin_set.c +++ b/builtin_set.c @@ -179,7 +179,7 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope ) \param indexes the list to insert the new indexes into \param src the source string to parse \param name the name of the element. Return null if the name in \c src does not match this name - \param the number of elements in the array to parse. + \param var_count the number of elements in the array to parse. \return the total number of indexes parsed, or -1 on error */ diff --git a/common.c b/common.c index 893992c59..bbbd8fca3 100644 --- a/common.c +++ b/common.c @@ -74,8 +74,6 @@ parts of fish. struct termios shell_modes; -int error_max=1; - wchar_t ellipsis_char; char *profile=0; diff --git a/common.h b/common.h index 900cd5676..c231d6a07 100644 --- a/common.h +++ b/common.h @@ -51,11 +51,6 @@ extern struct termios shell_modes; */ extern wchar_t ellipsis_char; -/** - The maximum number of charset convertion errors to report -*/ -extern int error_max; - /** The verbosity of fish */ diff --git a/complete.c b/complete.c index 4d00abbc8..71c14d78e 100644 --- a/complete.c +++ b/complete.c @@ -1776,12 +1776,12 @@ static void complete_param_expand( wchar_t *str, { comp_str = str; } - + /* debug( 3, L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | %ls );", comp_str, do_file?L"0":L"EXPAND_SKIP_WILDCARDS" ); - + */ expand_string( 0, wcsdup(comp_str), comp_out, @@ -1974,7 +1974,6 @@ void complete( const wchar_t *cmd, int on_command=0; int pos; - int old_error_max = error_max; int done=0; int cursor_pos = wcslen(cmd ); @@ -1985,8 +1984,6 @@ void complete( const wchar_t *cmd, return; } - error_max=0; - /** If we are completing a variable name or a tilde expansion user name, we do that and return. No need for any other competions. @@ -2135,7 +2132,6 @@ void complete( const wchar_t *cmd, free( current_command ); free( prev_token ); - error_max=old_error_max; condition_cache_clear(); } diff --git a/wildcard.c b/wildcard.c index 61fb13f04..6e90a8b4d 100644 --- a/wildcard.c +++ b/wildcard.c @@ -70,6 +70,12 @@ static void al_push_check( array_list_t *l, const wchar_t *new ) int wildcard_has( const wchar_t *str, int internal ) { wchar_t prev=0; + if( !str ) + { + debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); + return 0; + } + if( internal ) { for( ; *str; str++ ) @@ -162,19 +168,7 @@ static int wildcard_complete_internal( const wchar_t *orig, const wchar_t *(*desc_func)(const wchar_t *), array_list_t *out ) { - if( !wc ) - { - debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); - return 0; - } - - if( !str ) - { - debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); - return 0; - } - - if( !orig ) + if( !wc || !str || !orig) { debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); return 0; @@ -318,6 +312,11 @@ static void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd ) } ; + if( !fn || !sb ) + { + debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); + return; + } sb_clear( sb ); @@ -437,6 +436,12 @@ int wildcard_expand( const wchar_t *wc, // debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir ); + if( !wc || !base_dir || !out) + { + debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); + return 0; + } + if( flags & ACCEPT_INCOMPLETE ) { /*