aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-12-14 21:58:11 +1000
committerGravatar axel <axel@liljencrantz.se>2006-12-14 21:58:11 +1000
commita971d91a70d4e524e90637563cf0a2688484e21c (patch)
tree563874b56fce00c949446d745526597adb6d4d35
parent52b74f9f343f6162781e0af8cf935ac448149dc5 (diff)
Make tab completion of process expansion consider other processes than those owned by the shell. Also makes tab completion of process expansion properly handle paths in command names
darcs-hash:20061214115811-ac50b-8569bcd30f97fe505dc1e7f2596d2fbd23f31525.gz
-rw-r--r--expand.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/expand.c b/expand.c
index 790865ba..a49b5336 100644
--- a/expand.c
+++ b/expand.c
@@ -272,16 +272,18 @@ static int iswnumeric( const wchar_t *n )
*/
static int match_pid( const wchar_t *cmd,
const wchar_t *proc,
- int flags )
+ int flags,
+ int *offset)
{
/* Test for direct match */
-
+
if( wcsncmp( cmd, proc, wcslen( proc ) ) == 0 )
+ {
+ if( offset )
+ *offset = 0;
return 1;
-
- if( flags & ACCEPT_INCOMPLETE )
- return 0;
-
+ }
+
/*
Test if the commandline is a path to the command, if so we try
to match against only the command part
@@ -309,7 +311,11 @@ static int match_pid( const wchar_t *cmd,
if( wcsncmp( start+1, proc, wcslen( proc ) ) == 0 )
{
+ if( offset )
+ *offset = start+1-first_token;
+
free( first_token );
+
return 1;
}
}
@@ -403,14 +409,16 @@ static int find_process( const wchar_t *proc,
for( j=first_job; j != 0; j=j->next )
{
+ int offset;
+
if( j->command == 0 )
continue;
-
- if( match_pid( j->command, proc, flags ) )
+
+ if( match_pid( j->command, proc, flags, &offset ) )
{
if( flags & ACCEPT_INCOMPLETE )
{
- wchar_t *res = wcsdupcat2( j->command + wcslen(proc),
+ wchar_t *res = wcsdupcat2( j->command + offset + wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_JOB_DESC,
(void *)0 );
@@ -438,15 +446,16 @@ static int find_process( const wchar_t *proc,
continue;
for( p=j->first_process; p; p=p->next )
{
-
+ int offset;
+
if( p->actual_cmd == 0 )
continue;
- if( match_pid( p->actual_cmd, proc, flags ) )
+ if( match_pid( p->actual_cmd, proc, flags, &offset ) )
{
if( flags & ACCEPT_INCOMPLETE )
{
- wchar_t *res = wcsdupcat2( p->actual_cmd + wcslen(proc),
+ wchar_t *res = wcsdupcat2( p->actual_cmd + offset + wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_CHILD_PROCESS_DESC,
(void *)0);
@@ -556,16 +565,19 @@ static int find_process( const wchar_t *proc,
if( cmd != 0 )
{
- if( match_pid( cmd, proc, flags ) )
+ int offset;
+
+ if( match_pid( cmd, proc, flags, &offset ) )
{
if( flags & ACCEPT_INCOMPLETE )
{
- wchar_t *res = wcsdupcat2( cmd + wcslen(proc),
+ wchar_t *res = wcsdupcat2( cmd + offset + wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_PROCESS_DESC,
(void *)0);
if( res )
al_push( out, res );
+
}
else
{