From 310768e8d2dc3dc25ad729c7f2a241776c745b50 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 8 Nov 2006 04:19:11 +1000 Subject: [PATCH] Try to avoid the ' darcs-hash:20061107181911-ac50b-fda6044a81b3a09707f17d4017c2c3dacf4e1801.gz --- complete.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/complete.c b/complete.c index b80320575..fa464dc5e 100644 --- a/complete.c +++ b/complete.c @@ -1748,24 +1748,22 @@ static int complete_param( wchar_t *cmd_orig, if( wcsncmp( str, (wchar_t *)whole_opt->buff, wcslen(str) )==0) { + int has_arg=0; + int req_arg=0; + /* - If the option requires arguments, add - option with an appended '=' . If the - option does not accept arguments, add - option. If option accepts but does not - require arguments, add both. + If the switch has an _optional_ + argument, it needs to be specified using + '=', otherwise we complete without the + '=' since quite a few programs don't + support it. + */ - if( o->old_mode || !(o->result_mode & NO_COMMON ) ) - { - al_push( comp_out, - wcsdupcat2( &((wchar_t *)whole_opt->buff)[wcslen(str)], - COMPLETE_SEP_STR, - C_(o->desc), - (void *)0) ); - } + has_arg = !!wcslen( o->comp ); + req_arg = (o->result_mode & NO_COMMON ); - if( !o->old_mode && ( wcslen(o->comp) || (o->result_mode & NO_COMMON ) ) ) + if( !o->old_mode && ( has_arg && !req_arg ) ) { al_push( comp_out, wcsdupcat2( &((wchar_t *)whole_opt->buff)[wcslen(str)], @@ -1774,6 +1772,12 @@ static int complete_param( wchar_t *cmd_orig, C_(o->desc), (void *)0) ); } + + al_push( comp_out, + wcsdupcat2( &((wchar_t *)whole_opt->buff)[wcslen(str)], + COMPLETE_SEP_STR, + C_(o->desc), + (void *)0) ); } } }