aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-01-23 07:10:55 +1000
committerGravatar axel <axel@liljencrantz.se>2006-01-23 07:10:55 +1000
commit0dadd83fdd26368ff7091186398d97bc25624e89 (patch)
tree4ee3c372b21634dc782de04096c13feb38d298fd /builtin.c
parent3e3541a05a4d76d76250d31368cb6d67fa248246 (diff)
Move the complete builtin to it's own file, and make it accept multiple -c, -p, -s, -o and -l switches
darcs-hash:20060122211055-ac50b-6ef8cff7fb02e974d6a8096bf83bcbed429d7322.gz
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c254
1 files changed, 1 insertions, 253 deletions
diff --git a/builtin.c b/builtin.c
index 77dd907b..7be7a48f 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1960,258 +1960,7 @@ static int builtin_cd( wchar_t **argv )
return res;
}
-/**
- The complete builtin. Used for specifying programmable
- tab-completions. Calls the functions in complete.c for any heavy
- lifting.
-*/
-static int builtin_complete( wchar_t **argv )
-{
-
- int argc=0;
- int result_mode=SHARED, long_mode=0;
- int cmd_type=-1;
- int remove = 0;
- int authorative = 1;
-
- wchar_t *cmd=0, short_opt=L'\0', *long_opt=L"", *comp=L"", *desc=L"", *condition=L"", *load=0;
-
- argc = builtin_count_args( argv );
-
- woptind=0;
-
- while( 1 )
- {
- const static struct woption
- long_options[] =
- {
- {
- L"exclusive", no_argument, 0, 'x'
- }
- ,
- {
- L"no-files", no_argument, 0, 'f'
- }
- ,
- {
- L"require-parameter", no_argument, 0, 'r'
- }
- ,
- {
- L"path", required_argument, 0, 'p'
- }
- ,
- {
- L"command", required_argument, 0, 'c'
- }
- ,
- {
- L"short-option", required_argument, 0, 's'
- }
- ,
- {
- L"long-option", required_argument, 0, 'l' }
- ,
- {
- L"old-option", required_argument, 0, 'o'
- }
- ,
- {
- L"description", required_argument, 0, 'd'
- }
- ,
- {
- L"arguments", required_argument, 0, 'a'
- }
- ,
- {
- L"erase", no_argument, 0, 'e'
- }
- ,
- {
- L"unauthorative", no_argument, 0, 'u'
- }
- ,
- {
- L"condition", required_argument, 0, 'n'
- }
- ,
- {
- L"load", required_argument, 0, 'y'
- }
- ,
- {
- 0, 0, 0, 0
- }
- }
- ;
-
- int opt_index = 0;
-
- int opt = wgetopt_long( argc,
- argv,
- L"a:c:p:s:l:o:d:frxeun:y:",
- long_options,
- &opt_index );
- if( opt == -1 )
- break;
-
- switch( opt )
- {
- case 0:
- if(long_options[opt_index].flag != 0)
- break;
- sb_printf( sb_err,
- BUILTIN_ERR_UNKNOWN,
- argv[0],
- long_options[opt_index].name );
- sb_append( sb_err,
- parser_current_line() );
-// builtin_print_help( argv[0], sb_err );
-
-
- return 1;
-
-
- case 'x':
- result_mode |= EXCLUSIVE;
- break;
-
- case 'f':
- result_mode |= NO_FILES;
- break;
-
- case 'r':
- result_mode |= NO_COMMON;
- break;
-
- case 'p':
- cmd_type = PATH;
- cmd = expand_unescape( woptarg, 1);
- break;
-
- case 'c':
- cmd_type = COMMAND;
- cmd = expand_unescape( woptarg, 1);
- break;
-
- case 'd':
- desc = woptarg;
- break;
-
- case 'u':
- authorative=0;
- break;
-
- case 's':
- if( wcslen( woptarg ) > 1 )
- {
- sb_printf( sb_err,
- _( L"%ls: Parameter '%ls' is too long\n" ),
- argv[0],
- woptarg );
-
- sb_append( sb_err,
- parser_current_line() );
-// builtin_print_help( argv[0], sb_err );
-
- return 1;
- }
-
- short_opt = woptarg[0];
- break;
-
- case 'l':
- long_opt = woptarg;
- break;
-
- case 'o':
- long_mode=1;
- long_opt = woptarg;
- break;
-
- case 'a':
- comp = woptarg;
- break;
-
-
- case 'e':
- remove = 1;
-
- break;
- case 'n':
- condition = woptarg;
- break;
-
- case 'y':
- load = woptarg;
- break;
-
-
- case '?':
- // builtin_print_help( argv[0], sb_err );
-
- return 1;
-
- }
-
- }
-
- if( woptind != argc )
- {
- sb_printf( sb_err,
- _( L"%ls: Too many arguments\n" ),
- argv[0] );
- sb_append( sb_err,
- parser_current_line() );
- // builtin_print_help( argv[0], sb_err );
-
- return 1;
- }
-
- if( load )
- {
- complete_load( load, 1 );
- return 0;
- }
-
-
- if( cmd == 0 )
- {
- /* No arguments specified, meaning we print the definitions of
- * all specified completions to stdout.*/
- complete_print( sb_out );
- }
- else
- {
- if( remove )
- {
- /* Remove the specified completion */
- complete_remove( cmd,
- cmd_type,
- short_opt,
- long_opt );
- }
- else
- {
- /* Add the specified completion */
- complete_add( cmd,
- cmd_type,
- short_opt,
- long_opt,
- long_mode,
- result_mode,
- authorative,
- condition,
- comp,
- desc );
- }
- free( cmd );
-
- }
- return 0;
-}
/**
The . (dot) builtin, sometimes called source. Evaluates the contents of a file.
@@ -2321,8 +2070,7 @@ static int builtin_fg( wchar_t **argv )
if( argv[1] == 0 )
{
/*
- Select last constructed job (I.e. first job in the job que)
- that is possible to put in the foreground
+ Select last constructed job (I.e. first job in the job que) that is possible to put in the foreground
*/
for( j=first_job; j; j=j->next )
{