aboutsummaryrefslogtreecommitdiffhomepage
path: root/fish_pager.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-10-12 17:03:51 +1000
committerGravatar axel <axel@liljencrantz.se>2005-10-12 17:03:51 +1000
commita3b8b0ab4bad11b05771140afaf6779ef419f5a4 (patch)
treedf58329fda3b22af8eb7b7dc9684b370b34f5396 /fish_pager.c
parent93293b355756ee0f677e8d05c566892f56b612ad (diff)
Check that there are a sufficient number of arguments for fish_pager
darcs-hash:20051012070351-ac50b-b1f72df88819e58542b00ba35cc5d75e125b9655.gz
Diffstat (limited to 'fish_pager.c')
-rw-r--r--fish_pager.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/fish_pager.c b/fish_pager.c
index c7ebb49a..2c4066fb 100644
--- a/fish_pager.c
+++ b/fish_pager.c
@@ -57,7 +57,7 @@ enum
HIGHLIGHT_PAGER_DESCRIPTION,
HIGHLIGHT_PAGER_PROGRESS
}
-;
+ ;
/**
This struct should be continually updated by signals as the term
@@ -654,8 +654,8 @@ static int completion_try_print( int cols,
is_quoted,
l);
/*
- List does not fit on screen. Print one screenfull and
- leave a scrollable interface
+ List does not fit on screen. Print one screenfull and
+ leave a scrollable interface
*/
while(do_loop)
{
@@ -944,49 +944,53 @@ int main( int argc, char **argv )
array_list_t comp;
wchar_t *prefix;
-
+
init();
-
-
- prefix = str2wcs( argv[2] );
- is_quoted = strcmp( "1", argv[1] )==0;
+ if( argc < 3 )
+ {
+ debug( 0, L"Insufficient arguments" );
+ }
+ else
+ {
+ prefix = str2wcs( argv[2] );
+ is_quoted = strcmp( "1", argv[1] )==0;
- debug( 3, L"prefix is '%ls'", prefix );
+ debug( 3, L"prefix is '%ls'", prefix );
- al_init( &comp );
+ al_init( &comp );
- for( i=3; i<argc; i++ )
- {
- al_push( &comp, str2wcs( argv[i] ) );
- }
+ for( i=3; i<argc; i++ )
+ {
+ al_push( &comp, str2wcs( argv[i] ) );
+ }
- mangle_descriptions( &comp );
+ mangle_descriptions( &comp );
- for( i = 6; i>0; i-- )
- {
- switch( completion_try_print( i, prefix, is_quoted, &comp ) )
+ for( i = 6; i>0; i-- )
{
- case 0:
- break;
- case 1:
- i=0;
- break;
- case 2:
- i=7;
- break;
- }
+ switch( completion_try_print( i, prefix, is_quoted, &comp ) )
+ {
+ case 0:
+ break;
+ case 1:
+ i=0;
+ break;
+ case 2:
+ i=7;
+ break;
+ }
- }
+ }
- al_foreach( &comp, (void(*)(const void *))&free );
- al_destroy( &comp );
- free(prefix );
-
- fwprintf( out_file, L"%ls", (wchar_t *)out_buff.buff );
- if( is_ca_mode )
- writembs(exit_ca_mode);
+ al_foreach( &comp, (void(*)(const void *))&free );
+ al_destroy( &comp );
+ free(prefix );
-
+ fwprintf( out_file, L"%ls", (wchar_t *)out_buff.buff );
+ if( is_ca_mode )
+ writembs(exit_ca_mode);
+ }
+
destroy();
}