From 4f947015d25028db5b5f161d85bfd563a226c927 Mon Sep 17 00:00:00 2001 From: axel Date: Sat, 4 Feb 2006 23:09:14 +1000 Subject: [PATCH] Minor tweaks, including a few small performance improvements darcs-hash:20060204130914-ac50b-331e83fd8fe472545fce60fc4b76bb8300526d64.gz --- Makefile.in | 4 ++++ init/fish.in | 5 ++--- init/fish_complete.fish.in | 2 ++ init/fish_interactive.fish.in | 6 +++++- parser.c | 16 ++++++++++---- proc.c | 3 --- seq.in | 19 ++++++++++------- signal.c | 19 +++-------------- translate.c | 39 ++++++++++++++++++++++------------- util.c | 14 +++++++++++++ util.h | 14 +++++++++++++ 11 files changed, 93 insertions(+), 48 deletions(-) diff --git a/Makefile.in b/Makefile.in index 8af5df7ed..305519e5f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 diff --git a/init/fish.in b/init/fish.in index f47a695f9..c67a4a5f8 100644 --- a/init/fish.in +++ b/init/fish.in @@ -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 diff --git a/init/fish_complete.fish.in b/init/fish_complete.fish.in index 4d160b79f..ac8b40566 100644 --- a/init/fish_complete.fish.in +++ b/init/fish_complete.fish.in @@ -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 diff --git a/init/fish_interactive.fish.in b/init/fish_interactive.fish.in index acb44c408..124e21a25 100644 --- a/init/fish_interactive.fish.in +++ b/init/fish_interactive.fish.in @@ -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 diff --git a/parser.c b/parser.c index ad3259fb7..df81a49eb 100644 --- a/parser.c +++ b/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; @@ -1133,8 +1134,15 @@ int parser_get_lineno() if( !whole_str ) return -1; + + if( whole_str != prev_str || i>current_tokenizer_pos ) + { + prev_str = whole_str; + i=0; + lineno = 0; + } - for( i=0; inext ); - 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 ); diff --git a/seq.in b/seq.in index 14598778d..0bd242d47 100755 --- a/seq.in +++ b/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" - gettext fish $argv - end -else - function _ -d "Alias for the gettext command" - printf "%s" $argv +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 end end diff --git a/signal.c b/signal.c index bab6dc4da..1afd67de7 100644 --- a/signal.c +++ b/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); } diff --git a/translate.c b/translate.c index 344e5b981..c26be6fc2 100644 --- a/translate.c +++ b/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 %s (%d) -> %ls (%d)\n", in, out, strlen(out) , wres, wcslen(wres) ); - return wres; } void translate_init() { - int i; - - for(i=0; i