mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Make it possible to cancel a long-winded wildcard match by pressing ^C
darcs-hash:20070109164705-ac50b-d8bf2c22e9ecb6bccec6892da266016dcae79a4c.gz
This commit is contained in:
parent
e1f4aa5fcd
commit
a3aba0269d
3 changed files with 36 additions and 6 deletions
9
expand.c
9
expand.c
|
@ -1747,6 +1747,15 @@ int expand_string( void *context,
|
||||||
al_truncate( out, 0 );
|
al_truncate( out, 0 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
al_foreach( out, &free );
|
||||||
|
al_destroy( in );
|
||||||
|
al_destroy( out );
|
||||||
|
return EXPAND_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
31
wildcard.c
31
wildcard.c
|
@ -447,6 +447,11 @@ int wildcard_expand( const wchar_t *wc,
|
||||||
|
|
||||||
// debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir );
|
// debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir );
|
||||||
|
|
||||||
|
if( reader_interrupted() )
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if( !wc || !base_dir || !out)
|
if( !wc || !base_dir || !out)
|
||||||
{
|
{
|
||||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||||
|
@ -700,6 +705,7 @@ int wildcard_expand( const wchar_t *wc,
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
char *dir_str;
|
char *dir_str;
|
||||||
int stat_res;
|
int stat_res;
|
||||||
|
int new_res;
|
||||||
|
|
||||||
wcscpy(&new_dir[base_len], name );
|
wcscpy(&new_dir[base_len], name );
|
||||||
dir_str = wcs2str( new_dir );
|
dir_str = wcs2str( new_dir );
|
||||||
|
@ -735,10 +741,18 @@ int wildcard_expand( const wchar_t *wc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res |= wildcard_expand( new_wc,
|
new_res = wildcard_expand( new_wc,
|
||||||
new_dir,
|
new_dir,
|
||||||
flags,
|
flags,
|
||||||
out );
|
out );
|
||||||
|
|
||||||
|
if( new_res == -1 )
|
||||||
|
{
|
||||||
|
res = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
res |= new_res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -746,10 +760,17 @@ int wildcard_expand( const wchar_t *wc,
|
||||||
*/
|
*/
|
||||||
if( partial_match )
|
if( partial_match )
|
||||||
{
|
{
|
||||||
res |= wildcard_expand( wcschr( wc, ANY_STRING_RECURSIVE ),
|
new_res = wildcard_expand( wcschr( wc, ANY_STRING_RECURSIVE ),
|
||||||
new_dir,
|
new_dir,
|
||||||
flags | WILDCARD_RECURSIVE,
|
flags | WILDCARD_RECURSIVE,
|
||||||
out );
|
out );
|
||||||
|
if( new_res == -1 )
|
||||||
|
{
|
||||||
|
res = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
res |= new_res;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ enum
|
||||||
\param flags flags for the search. Can be any combination of ACCEPT_INCOMPLETE and EXECUTABLES_ONLY
|
\param flags flags for the search. Can be any combination of ACCEPT_INCOMPLETE and EXECUTABLES_ONLY
|
||||||
\param out The list in which to put the output
|
\param out The list in which to put the output
|
||||||
|
|
||||||
\return 1 if matches where found, 0 otherwise.
|
\return 1 if matches where found, 0 otherwise. Return -1 on abort (I.e. ^C was pressed).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
int wildcard_expand( const wchar_t *wc,
|
int wildcard_expand( const wchar_t *wc,
|
||||||
|
|
Loading…
Reference in a new issue