Fix problem bug breaking completion in commands with multiple subshells

darcs-hash:20051025110352-ac50b-fff319ddcbafb722b9bc3c61aa1b250b290716a5.gz
This commit is contained in:
axel 2005-10-25 21:03:52 +10:00
parent d332293245
commit ddcb84aa07
9 changed files with 39 additions and 26 deletions

View file

@ -911,7 +911,7 @@ void debug( int level, wchar_t *msg, ... )
} }
putwc( L'\n', stderr ); putwc( L'\n', stderr );
sb_destroy( &sb );
} }
wchar_t *escape( const wchar_t *in, wchar_t *escape( const wchar_t *in,

View file

@ -270,7 +270,7 @@ wchar_t *escape( const wchar_t *in,
counterparts. Also optionally change the wildcards, the tilde counterparts. Also optionally change the wildcards, the tilde
character and a few more into constants which are defined in a character and a few more into constants which are defined in a
private use area of Unicode. This assumes wchar_t is a unicode private use area of Unicode. This assumes wchar_t is a unicode
character. character set. character set.
The result must be free()d. The original string is not modified. If The result must be free()d. The original string is not modified. If
an invalid sequence is specified, 0 is returned. an invalid sequence is specified, 0 is returned.

View file

@ -1766,9 +1766,9 @@ static void complete_param_expand( wchar_t *str,
else else
comp_str = str; comp_str = str;
// fwprintf( stderr, L"expand_string( \"%ls\", [list], ACCEPT_INCOMPLETE | %ls )\n", comp_str, do_file?L"0":L"EXPAND_SKIP_WILDCARDS" ); // fwprintf( stderr, L"expand_string( \"%ls\", [list], EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | %ls )\n", comp_str, do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
expand_string( wcsdup(comp_str), comp_out, ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) ); expand_string( wcsdup(comp_str), comp_out, EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
} }
/** /**

10
env.c
View file

@ -388,8 +388,12 @@ void env_init()
pw = getpwuid( getuid() ); pw = getpwuid( getuid() );
uname = str2wcs( pw->pw_name ); if( pw )
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT ); {
uname = str2wcs( pw->pw_name );
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
free( uname );
}
env_universal_init( env_get( L"FISHD_SOKET_DIR"), env_universal_init( env_get( L"FISHD_SOKET_DIR"),
env_get( L"USER" ), env_get( L"USER" ),
@ -411,6 +415,8 @@ void env_destroy()
hash_destroy( &env_read_only ); hash_destroy( &env_read_only );
hash_destroy( &env_electric );
hash_foreach( global, &clear_hash_entry ); hash_foreach( global, &clear_hash_entry );
hash_destroy( global ); hash_destroy( global );
free( top ); free( top );

View file

@ -1328,6 +1328,7 @@ int expand_string( wchar_t *str,
if( (pos == str) || ( *(pos-1) != L'\\' ) ) if( (pos == str) || ( *(pos-1) != L'\\' ) )
{ {
error( SUBSHELL_ERROR, L"Subshells not allowed", -1 ); error( SUBSHELL_ERROR, L"Subshells not allowed", -1 );
free( str );
al_destroy( &list1 ); al_destroy( &list1 );
al_destroy( &list2 ); al_destroy( &list2 );
return 0; return 0;
@ -1505,7 +1506,6 @@ wchar_t *expand_one( wchar_t *string, int flags )
res = expand_string( string, &l, flags ); res = expand_string( string, &l, flags );
if( !res ) if( !res )
{ {
free( string );
one = 0; one = 0;
} }
else else

View file

@ -162,7 +162,7 @@ wchar_t *expand_escape_variable( const wchar_t *in );
wchar_t *expand_tilde(wchar_t *in); wchar_t *expand_tilde(wchar_t *in);
/** /**
Locate the last subshell in the specified string. Locate the first subshell in the specified string.
\param in the string to search for subshells \param in the string to search for subshells
\param begin the starting paranthesis of the subshell \param begin the starting paranthesis of the subshell

View file

@ -386,8 +386,9 @@ void highlight_shell( wchar_t * buff,
break; break;
subpos = end+1; subpos = end+1;
} }
free( buffcpy ); free( buffcpy);
last_val=0; last_val=0;

View file

@ -942,7 +942,7 @@ function psub -d "Read from stdin into a file and output the filename. Remove th
end end
if not status --is-command-substitution if not status --is-command-substitution
echo psub: Not inside of command substitution echo psub: Not inside of command substitution >&2
return return
end end

View file

@ -1548,8 +1548,8 @@ void reader_sanity_check()
void reader_current_subshell_extent( wchar_t **a, wchar_t **b ) void reader_current_subshell_extent( wchar_t **a, wchar_t **b )
{ {
wchar_t *buffcpy = wcsdup( data->buff );
wchar_t *begin, *end; wchar_t *begin, *end;
wchar_t *pos;
if( a ) if( a )
*a=0; *a=0;
@ -1559,35 +1559,41 @@ void reader_current_subshell_extent( wchar_t **a, wchar_t **b )
if( !data ) if( !data )
return; return;
pos = data->buff;
while( 1 ) while( 1 )
{ {
int bc, ec; int bc, ec;
if( expand_locate_subshell( buffcpy, if( expand_locate_subshell( pos,
&begin, &begin,
&end, &end,
1 ) <= 0) 1 ) <= 0)
{ {
begin=buffcpy; begin=data->buff;
end = buffcpy + wcslen(data->buff); end = data->buff + wcslen(data->buff);
break; break;
} }
bc = begin-buffcpy;
ec = end-buffcpy; if( !end )
{
end = data->buff + wcslen(data->buff);
}
bc = begin-data->buff;
ec = end-data->buff;
if(( bc < data->buff_pos ) && (ec >= data->buff_pos) ) if(( bc < data->buff_pos ) && (ec >= data->buff_pos) )
{ {
begin++; begin++;
//fwprintf( stderr, L"Subshell!\n" );
break; break;
} }
*begin=0; pos = end+1;
} }
if( a ) if( a )
*a = data->buff + (begin-buffcpy); *a = begin;
if( b ) if( b )
*b = data->buff + (end-buffcpy); *b = end;
free( buffcpy );
} }
static void reader_current_job_or_process_extent( wchar_t **a, static void reader_current_job_or_process_extent( wchar_t **a,