aboutsummaryrefslogtreecommitdiffhomepage
path: root/wildcard.c
diff options
context:
space:
mode:
authorGravatar liljencrantz <liljencrantz@gmail.com>2007-10-15 19:51:08 +1000
committerGravatar liljencrantz <liljencrantz@gmail.com>2007-10-15 19:51:08 +1000
commitdd02e96712eadbf9c5117ad4dabdbedac03eb314 (patch)
tree13369612bd96bc342fa299505b2a9692e6e1b4ef /wildcard.c
parent4163040e56d26deae1e3e2aade8547af18e92afd (diff)
Second part of improved execve errors - this patch makes the memory limits nicely formated (e.g. 128kB instead of 136549 bytes).
darcs-hash:20071015095108-75c98-51c2ea6ab6edba5d1885eb5938f039054da775e2.gz
Diffstat (limited to 'wildcard.c')
-rw-r--r--wildcard.c51
1 files changed, 5 insertions, 46 deletions
diff --git a/wildcard.c b/wildcard.c
index 60d6dd6b..a2cf09b0 100644
--- a/wildcard.c
+++ b/wildcard.c
@@ -638,10 +638,10 @@ static const wchar_t *file_get_desc( const wchar_t *filename,
\param is_cmd whether we are performing command completion
*/
static void wildcard_completion_allocate( array_list_t *list,
- const wchar_t *fullname,
- const wchar_t *completion,
- const wchar_t *wc,
- int is_cmd )
+ const wchar_t *fullname,
+ const wchar_t *completion,
+ const wchar_t *wc,
+ int is_cmd )
{
const wchar_t *desc;
struct stat buf, lbuf;
@@ -653,16 +653,7 @@ static void wildcard_completion_allocate( array_list_t *list,
int stat_res, lstat_res;
int stat_errno=0;
- /*
- This is a long long, not an off_t since we really need to know
- exactly how large it is when using *printf() to output it.
- */
long long sz;
- wchar_t *sz_name[]=
- {
- L"kB", L"MB", L"GB", L"TB", L"PB", L"EB", L"ZB", L"YB", 0
- }
- ;
if( !sb )
{
@@ -728,42 +719,10 @@ static void wildcard_completion_allocate( array_list_t *list,
else
{
sb_append( sb, desc, L", ", (void *)0 );
- if( sz < 0 )
- {
- sb_append( sb, L"unknown" );
- }
- else if( sz < 1 )
- {
- sb_append( sb, _( L"empty" ) );
- }
- else if( sz < 1024 )
- {
- sb_printf( sb, L"%lldB", sz );
- }
- else
- {
- int i;
-
- for( i=0; sz_name[i]; i++ )
- {
- if( sz < (1024*1024) || !sz_name[i+1] )
- {
- int isz = sz/1024;
- if( isz > 9 )
- sb_printf( sb, L"%d%ls", isz, sz_name[i] );
- else
- sb_printf( sb, L"%.1f%ls", (double)sz/1024, sz_name[i] );
-
- break;
- }
- sz /= 1024;
-
- }
- }
+ sb_format_size( sb, sz );
}
wildcard_complete( completion, wc, (wchar_t *)sb->buff, 0, list, flags );
-
if( free_completion )
free( (void *)completion );
}