mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Minor tweaks, including a few small performance improvements
darcs-hash:20060204130914-ac50b-331e83fd8fe472545fce60fc4b76bb8300526d64.gz
This commit is contained in:
parent
9f3a7543aa
commit
4f947015d2
11 changed files with 93 additions and 48 deletions
|
@ -16,6 +16,10 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
#
|
||||
# @configure_input@
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for the fish shell. Can build fish and associated
|
||||
# applications, install them, recalculate dependencies and also create
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# Init file for fish
|
||||
#
|
||||
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# 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@
|
||||
|
||||
# Root should also have the sbin directories in the path
|
||||
set -l uid (id -u 2>/dev/null)
|
||||
if test "$uid" = 0
|
||||
if test "$USER" = root
|
||||
set path_list $path_list /sbin /usr/sbin /usr/local/sbin
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Main file for fish command completions. This file contains various
|
||||
# common helper functions for the command completions. All actual
|
||||
# completions are located in the completions subdirectory.
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Don't need completions in non-interactive mode
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#
|
||||
# Initializations that should only be performed when in interactive mode
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
if not status --is-interactive
|
||||
exit
|
||||
|
@ -64,12 +65,14 @@ end
|
|||
# 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"
|
||||
if not set -q $argv[1]
|
||||
set -U -- $argv
|
||||
return
|
||||
end
|
||||
if contains -- $$argv[1] (set_color -c)
|
||||
if contains -- $$argv[1] $all_colors
|
||||
return
|
||||
end
|
||||
set -U -- $argv
|
||||
|
@ -137,3 +140,4 @@ end
|
|||
|
||||
functions -e set_default_color
|
||||
functions -e set_exported_default
|
||||
set -e all_colors
|
||||
|
|
14
parser.c
14
parser.c
|
@ -1120,11 +1120,12 @@ static const wchar_t *is_function()
|
|||
|
||||
int parser_get_lineno()
|
||||
{
|
||||
int i;
|
||||
const wchar_t *whole_str;
|
||||
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 )
|
||||
return -1;
|
||||
|
@ -1134,7 +1135,14 @@ int parser_get_lineno()
|
|||
if( !whole_str )
|
||||
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' )
|
||||
{
|
||||
|
|
3
proc.c
3
proc.c
|
@ -122,14 +122,11 @@ static void free_process( process_t *p )
|
|||
|
||||
|
||||
free_process( p->next );
|
||||
debug( 3, L"Free process %ls", p->actual_cmd );
|
||||
free( p->actual_cmd );
|
||||
if( p->argv != 0 )
|
||||
{
|
||||
debug( 3, L"Process has argument vector" );
|
||||
for( arg=p->argv; *arg; arg++ )
|
||||
{
|
||||
debug( 3, L"Free argument %ls", *arg );
|
||||
free( *arg );
|
||||
}
|
||||
free(p->argv );
|
||||
|
|
13
seq.in
13
seq.in
|
@ -1,16 +1,21 @@
|
|||
#!@prefix@/bin/fish
|
||||
#
|
||||
# Fallback implementation of the seq command
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
set -l from 1
|
||||
set -l step 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"
|
||||
gettext fish $argv
|
||||
end
|
||||
else
|
||||
function _ -d "Alias for the gettext command"
|
||||
printf "%s" $argv
|
||||
end
|
||||
end
|
||||
|
||||
|
|
19
signal.c
19
signal.c
|
@ -41,6 +41,7 @@ struct lookup_entry
|
|||
Signal description
|
||||
*/
|
||||
const wchar_t *desc;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -535,28 +536,14 @@ void signal_handle( int sig, int do_handle )
|
|||
|
||||
void signal_block()
|
||||
{
|
||||
int i;
|
||||
sigset_t chldset;
|
||||
sigemptyset( &chldset );
|
||||
|
||||
for( i=0; lookup[i].desc ; i++ )
|
||||
{
|
||||
sigaddset( &chldset, lookup[i].signal );
|
||||
}
|
||||
|
||||
sigfillset( &chldset );
|
||||
sigprocmask(SIG_BLOCK, &chldset, 0);
|
||||
}
|
||||
|
||||
void signal_unblock()
|
||||
{
|
||||
int i;
|
||||
sigset_t chldset;
|
||||
sigemptyset( &chldset );
|
||||
|
||||
for( i=0; lookup[i].desc ; i++ )
|
||||
{
|
||||
sigaddset( &chldset, lookup[i].signal );
|
||||
}
|
||||
|
||||
sigfillset( &chldset );
|
||||
sigprocmask(SIG_UNBLOCK, &chldset, 0);
|
||||
}
|
||||
|
|
37
translate.c
37
translate.c
|
@ -43,6 +43,22 @@ static char *wcs2str_buff=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
|
||||
avoids exessive calls to malloc
|
||||
|
@ -71,6 +87,9 @@ const wchar_t *wgettext( const wchar_t *in )
|
|||
if( !in )
|
||||
return in;
|
||||
|
||||
if( !is_init )
|
||||
internal_init();
|
||||
|
||||
char *mbs_in = translate_wcs2str( in );
|
||||
char *out = gettext( mbs_in );
|
||||
wchar_t *wres=0;
|
||||
|
@ -81,31 +100,23 @@ const wchar_t *wgettext( const wchar_t *in )
|
|||
wres = (wchar_t *)buff[curr_buff].buff;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !is_init )
|
||||
return;
|
||||
|
||||
is_init = 0;
|
||||
|
||||
for(i=0; i<BUFF_COUNT; i++ )
|
||||
sb_destroy( &buff[i] );
|
||||
|
||||
|
|
14
util.c
14
util.c
|
@ -511,6 +511,20 @@ int hash_wcs_cmp( const void *a, const void *b )
|
|||
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,
|
||||
int (*compare)(void *e1, void *e2) )
|
||||
{
|
||||
|
|
14
util.h
14
util.h
|
@ -298,6 +298,20 @@ int hash_wcs_func( const void *data );
|
|||
int hash_wcs_cmp( const void *a,
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue