Skip to content

Commit

Permalink
Comment updates, minor code cleanups and other janitorial jobs
Browse files Browse the repository at this point in the history
darcs-hash:20071002100937-75c98-d4040e70a256e36a6334cca0a05d60500680132b.gz
  • Loading branch information
liljencrantz committed Oct 2, 2007
1 parent dac2129 commit d34d05c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 61 deletions.
38 changes: 18 additions & 20 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,17 @@ static int count_char( const wchar_t *str, wchar_t c )
return res;
}

/**
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.
*/

wchar_t *builtin_help_get( const wchar_t *name )
{
array_list_t lst;
string_buffer_t cmd;
wchar_t *name_esc;

/*
Because the contents of this buffer is returned by this
function, it must not be free'd on exit, so we allocate it
using halloc.
*/
static string_buffer_t *out = 0;
int i;

Expand Down Expand Up @@ -239,6 +234,16 @@ wchar_t *builtin_help_get( const wchar_t *name )

}

/**
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.
*/

static void builtin_print_help( const wchar_t *cmd, string_buffer_t *b )
{
Expand Down Expand Up @@ -565,7 +570,6 @@ static int builtin_bind( wchar_t **argv )
}
;

int i;
int argc=builtin_count_args( argv );
int mode = BIND_INSERT;
int res = STATUS_BUILTIN_OK;
Expand Down Expand Up @@ -3772,13 +3776,8 @@ int builtin_exists( wchar_t *cmd )
static int internal_help( wchar_t *cmd )
{
CHECK( cmd, 0 );

return ( wcscmp( cmd, L"for" ) == 0 ||
wcscmp( cmd, L"while" ) == 0 ||
wcscmp( cmd, L"function" ) == 0 ||
wcscmp( cmd, L"if" ) == 0 ||
wcscmp( cmd, L"end" ) == 0 ||
wcscmp( cmd, L"switch" ) == 0 );
return contains( cmd, L"for", L"while", L"function",
L"if", L"end", L"switch" );
}


Expand Down Expand Up @@ -3819,8 +3818,7 @@ int builtin_run( wchar_t **argv, io_data_t *io )

void builtin_get_names( array_list_t *list )
{
CHECK( list, );

CHECK( list, );
hash_get_keys( &builtin, list );
}

Expand Down
7 changes: 4 additions & 3 deletions builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,11 @@ const wchar_t *builtin_complete_get_temporary_buffer();


/**
Return the help text for the specified builtin command.
\param cmd The command for which to obtain help text
Run the __fish_print_help function to obtain the help information
for the specified command. The resulting string will be valid until
the next time this function is called, and must never be free'd manually.
*/

wchar_t *builtin_help_get( const wchar_t *cmd );

#endif
6 changes: 3 additions & 3 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ wchar_t *str2wcs_internal( const char *in, wchar_t *out )
{
res = mbrtowc( &out[out_pos], &in[in_pos], len-in_pos, &state );

if( ( out[out_pos] >= ENCODE_DIRECT_BASE) &&
( out[out_pos] < ENCODE_DIRECT_BASE+256) ||
out[out_pos] == INTERNAL_SEPARATOR )
if( ( ( out[out_pos] >= ENCODE_DIRECT_BASE) &&
( out[out_pos] < ENCODE_DIRECT_BASE+256)) ||
( out[out_pos] == INTERNAL_SEPARATOR ) )
{
out[out_pos] = ENCODE_DIRECT_BASE + (unsigned char)in[in_pos];
in_pos++;
Expand Down
10 changes: 5 additions & 5 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ static array_list_t *killme;
*/
static array_list_t *blocked;

/**
String buffer used for formating event descriptions in event_get_desc()
*/
static string_buffer_t *get_desc_buff=0;

/**
Tests if one event instance matches the definition of a event
class. If both the class and the instance name a function,
Expand Down Expand Up @@ -207,6 +202,11 @@ static int event_is_blocked( event_t *e )
const wchar_t *event_get_desc( event_t *e )
{

/*
String buffer used for formating event descriptions in event_get_desc()
*/
static string_buffer_t *get_desc_buff=0;

CHECK( e, 0 );

if( !get_desc_buff )
Expand Down
20 changes: 17 additions & 3 deletions event.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Functions for handling event triggers
Because most of these functions can be called by signal
handler, it is important to make it well defined when these
functions produce output or perform memory allocations, since
such functions may not be safely called by signal handlers.
*/
#ifndef FISH_EVENT_H
#define FISH_EVENT_H
Expand Down Expand Up @@ -91,11 +97,15 @@ typedef struct

/**
Add an event handler
May not be called by a signal handler, since it may allocate new memory.
*/
void event_add_handler( event_t *event );

/**
Remove all events matching the specified criterion.
May not be called by a signal handler, since it may free allocated memory.
*/
void event_remove( event_t *event );

Expand All @@ -120,9 +130,13 @@ int event_get( event_t *criterion, array_list_t *out );
dispatched.
This function is safe to call from a signal handler _ONLY_ if the
event parameter is for a signal.
event parameter is for a signal. Signal events not be fired, by the
call to event_fire, instead they will be fired the next time
event_fire is called with anull argument. This is needed to make
sure that no code evaluation is ever performed by a signal handler.
\param event the specific event whose handlers should fire
\param event the specific event whose handlers should fire. If
null, then all delayed events will be fired.
*/
void event_fire( event_t *event );

Expand All @@ -137,7 +151,7 @@ void event_init();
void event_destroy();

/**
Free all memory used by event
Free all memory used by the specified event
*/
void event_free( event_t *e );

Expand Down
32 changes: 6 additions & 26 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,27 +243,6 @@ static int is_init = 0;
static void input_terminfo_init();
static void input_terminfo_destroy();




/**
Returns the function name for the given function code.
*/
/*
static const wchar_t *input_get_name( wchar_t c )
{
int i;
for( i = 0; i<(sizeof( code_arr )/sizeof(wchar_t)) ; i++ )
{
if( c == code_arr[i] )
{
return name_arr[i];
}
}
return 0;
}
*/
/**
Returns the function description for the given function code.
*/
Expand Down Expand Up @@ -427,7 +406,7 @@ static wint_t input_exec_binding( input_mapping_t *m, const wchar_t *seq )
Bindings that produce output should emit a R_REPAINT
function by calling 'commandline -f repaint' to tell
fish that a repaint is in order.
fish that a repaint is in order.
*/

return R_NULL;
Expand Down Expand Up @@ -534,7 +513,7 @@ wint_t input_readch()
;
arr[0] = input_common_readch(0);

return input_exec_binding( m, arr );
return input_exec_binding( generic, arr );
}

/*
Expand Down Expand Up @@ -660,9 +639,10 @@ static void input_terminfo_init()
TERMINFO_ADD(key_f19);
TERMINFO_ADD(key_f20);
/*
I know of no key board with more than 20 function keys, so
adding the rest here makes very little sense, since it will
take up a lot of room in any listings, but with no benefit.
I know of no keyboard with more than 20 function keys, so
adding the rest here makes very little sense, since it will
take up a lot of room in any listings (like tab completions),
but with no benefit.
*/
/*
TERMINFO_ADD(key_f21);
Expand Down
2 changes: 1 addition & 1 deletion signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static void handle_winch( int sig, siginfo_t *info, void *context )
}

/**
Respond to a hup signal by exiting, unless it is vcaught by a
Respond to a hup signal by exiting, unless it is caught by a
shellscript function, in which case we do nothing.
*/
static void handle_hup( int sig, siginfo_t *info, void *context )
Expand Down

0 comments on commit d34d05c

Please sign in to comment.