Minor tweaks, including a few small performance improvements

darcs-hash:20060204130914-ac50b-331e83fd8fe472545fce60fc4b76bb8300526d64.gz
This commit is contained in:
axel 2006-02-04 23:09:14 +10:00
parent 9f3a7543aa
commit 4f947015d2
11 changed files with 93 additions and 48 deletions

View file

@ -16,6 +16,10 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
#
# @configure_input@
#
# #
# Makefile for the fish shell. Can build fish and associated # Makefile for the fish shell. Can build fish and associated
# applications, install them, recalculate dependencies and also create # applications, install them, recalculate dependencies and also create

View file

@ -1,7 +1,7 @@
# #
# Init file for fish # Init file for fish
# #
# @configure_input@
# #
# Set default field separators # Set default field separators
@ -18,8 +18,7 @@ set -g IFS \ \t\n
set -l path_list /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin @optbindirs@ set -l path_list /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin @optbindirs@
# Root should also have the sbin directories in the path # Root should also have the sbin directories in the path
set -l uid (id -u 2>/dev/null) if test "$USER" = root
if test "$uid" = 0
set path_list $path_list /sbin /usr/sbin /usr/local/sbin set path_list $path_list /sbin /usr/sbin /usr/local/sbin
end end

View file

@ -1,6 +1,8 @@
# Main file for fish command completions. This file contains various # Main file for fish command completions. This file contains various
# common helper functions for the command completions. All actual # common helper functions for the command completions. All actual
# completions are located in the completions subdirectory. # completions are located in the completions subdirectory.
#
# @configure_input@
# #
# Don't need completions in non-interactive mode # Don't need completions in non-interactive mode

View file

@ -1,6 +1,7 @@
# #
# Initializations that should only be performed when in interactive mode # Initializations that should only be performed when in interactive mode
# #
# @configure_input@
if not status --is-interactive if not status --is-interactive
exit exit
@ -64,12 +65,14 @@ end
# Set various color values # Set various color values
# #
set -g all_colors (set_color -c)
function set_default_color -d "Set an universal variable, unless it has already been set. If set, verify that it is a valid color name" function set_default_color -d "Set an universal variable, unless it has already been set. If set, verify that it is a valid color name"
if not set -q $argv[1] if not set -q $argv[1]
set -U -- $argv set -U -- $argv
return return
end end
if contains -- $$argv[1] (set_color -c) if contains -- $$argv[1] $all_colors
return return
end end
set -U -- $argv set -U -- $argv
@ -137,3 +140,4 @@ end
functions -e set_default_color functions -e set_default_color
functions -e set_exported_default functions -e set_exported_default
set -e all_colors

View file

@ -1120,11 +1120,12 @@ static const wchar_t *is_function()
int parser_get_lineno() int parser_get_lineno()
{ {
int i;
const wchar_t *whole_str; const wchar_t *whole_str;
const wchar_t *function_name; const wchar_t *function_name;
int lineno = 1; static const wchar_t *prev_str = 0;
static int i=0;
static int lineno=1;
if( !current_tokenizer ) if( !current_tokenizer )
return -1; return -1;
@ -1134,7 +1135,14 @@ int parser_get_lineno()
if( !whole_str ) if( !whole_str )
return -1; return -1;
for( i=0; i<current_tokenizer_pos && whole_str[i]; i++ ) if( whole_str != prev_str || i>current_tokenizer_pos )
{
prev_str = whole_str;
i=0;
lineno = 0;
}
for( ; i<current_tokenizer_pos && whole_str[i]; i++ )
{ {
if( whole_str[i] == L'\n' ) if( whole_str[i] == L'\n' )
{ {

3
proc.c
View file

@ -122,14 +122,11 @@ static void free_process( process_t *p )
free_process( p->next ); free_process( p->next );
debug( 3, L"Free process %ls", p->actual_cmd );
free( p->actual_cmd ); free( p->actual_cmd );
if( p->argv != 0 ) if( p->argv != 0 )
{ {
debug( 3, L"Process has argument vector" );
for( arg=p->argv; *arg; arg++ ) for( arg=p->argv; *arg; arg++ )
{ {
debug( 3, L"Free argument %ls", *arg );
free( *arg ); free( *arg );
} }
free(p->argv ); free(p->argv );

13
seq.in
View file

@ -1,16 +1,21 @@
#!@prefix@/bin/fish #!@prefix@/bin/fish
#
# Fallback implementation of the seq command
#
# @configure_input@
set -l from 1 set -l from 1
set -l step 1 set -l step 1
set -l to 1 set -l to 1
if test 1 = "@HAVE_GETTEXT@"; and which gettext >/dev/null ^/dev/null function _ -d "Alias for the gettext command"
printf "%s" $argv
end
if test 1 = "@HAVE_GETTEXT@"
if which gettext ^/dev/null >/dev/null
function _ -d "Alias for the gettext command" function _ -d "Alias for the gettext command"
gettext fish $argv gettext fish $argv
end end
else
function _ -d "Alias for the gettext command"
printf "%s" $argv
end end
end end

View file

@ -41,6 +41,7 @@ struct lookup_entry
Signal description Signal description
*/ */
const wchar_t *desc; const wchar_t *desc;
}; };
/** /**
@ -535,28 +536,14 @@ void signal_handle( int sig, int do_handle )
void signal_block() void signal_block()
{ {
int i;
sigset_t chldset; sigset_t chldset;
sigemptyset( &chldset ); sigfillset( &chldset );
for( i=0; lookup[i].desc ; i++ )
{
sigaddset( &chldset, lookup[i].signal );
}
sigprocmask(SIG_BLOCK, &chldset, 0); sigprocmask(SIG_BLOCK, &chldset, 0);
} }
void signal_unblock() void signal_unblock()
{ {
int i;
sigset_t chldset; sigset_t chldset;
sigemptyset( &chldset ); sigfillset( &chldset );
for( i=0; lookup[i].desc ; i++ )
{
sigaddset( &chldset, lookup[i].signal );
}
sigprocmask(SIG_UNBLOCK, &chldset, 0); sigprocmask(SIG_UNBLOCK, &chldset, 0);
} }

View file

@ -43,6 +43,22 @@ static char *wcs2str_buff=0;
*/ */
static size_t wcs2str_buff_count=0; static size_t wcs2str_buff_count=0;
static int is_init = 0;
static void internal_init()
{
int i;
is_init = 1;
for(i=0; i<BUFF_COUNT; i++ )
sb_init( &buff[i] );
bindtextdomain( PACKAGE_NAME, LOCALEDIR );
textdomain( PACKAGE_NAME );
}
/** /**
Wide to narrow character conversion. Internal implementation that Wide to narrow character conversion. Internal implementation that
avoids exessive calls to malloc avoids exessive calls to malloc
@ -71,6 +87,9 @@ const wchar_t *wgettext( const wchar_t *in )
if( !in ) if( !in )
return in; return in;
if( !is_init )
internal_init();
char *mbs_in = translate_wcs2str( in ); char *mbs_in = translate_wcs2str( in );
char *out = gettext( mbs_in ); char *out = gettext( mbs_in );
wchar_t *wres=0; wchar_t *wres=0;
@ -81,31 +100,23 @@ const wchar_t *wgettext( const wchar_t *in )
wres = (wchar_t *)buff[curr_buff].buff; wres = (wchar_t *)buff[curr_buff].buff;
curr_buff = (curr_buff+1)%BUFF_COUNT; curr_buff = (curr_buff+1)%BUFF_COUNT;
/*
write( 2, res, strlen(res) );
*/
// debug( 1, L"%ls -> %s (%d) -> %ls (%d)\n", in, out, strlen(out) , wres, wcslen(wres) );
return wres; return wres;
} }
void translate_init() void translate_init()
{ {
int i;
for(i=0; i<BUFF_COUNT; i++ )
sb_init( &buff[i] );
bindtextdomain( PACKAGE_NAME, LOCALEDIR );
textdomain( PACKAGE_NAME );
} }
void translate_destroy() void translate_destroy()
{ {
int i; int i;
if( !is_init )
return;
is_init = 0;
for(i=0; i<BUFF_COUNT; i++ ) for(i=0; i<BUFF_COUNT; i++ )
sb_destroy( &buff[i] ); sb_destroy( &buff[i] );

14
util.c
View file

@ -511,6 +511,20 @@ int hash_wcs_cmp( const void *a, const void *b )
return wcscmp((wchar_t *)a,(wchar_t *)b) == 0; return wcscmp((wchar_t *)a,(wchar_t *)b) == 0;
} }
int hash_ptr_func( const void *data )
{
return (int)(long) data;
}
/**
Hash comparison function suitable for direct pointer comparison
*/
int hash_ptr_cmp( const void *a,
const void *b )
{
return a == b;
}
void pq_init( priority_queue_t *q, void pq_init( priority_queue_t *q,
int (*compare)(void *e1, void *e2) ) int (*compare)(void *e1, void *e2) )
{ {

14
util.h
View file

@ -298,6 +298,20 @@ int hash_wcs_func( const void *data );
int hash_wcs_cmp( const void *a, int hash_wcs_cmp( const void *a,
const void *b ); const void *b );
/**
Hash function suitable for direct pointer comparison
*/
int hash_ptr_func( const void *data );
/**
Hash comparison function suitable for direct pointer comparison
*/
int hash_ptr_cmp( const void *a,
const void *b );
/** /**
Initialize the priority queue Initialize the priority queue