diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-03 19:37:55 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-03 19:37:55 -0800 |
commit | a0bb2cdc6e697c58ec3ebcd455b56347228092e5 (patch) | |
tree | 25e49dfa40c28a29ff227f063dcadc8aac9af021 /common.cpp | |
parent | 0a5680c3e8c41e5f19b3beb4e6ac31a8560f99dd (diff) |
removed some string_buffer
Diffstat (limited to 'common.cpp')
-rw-r--r-- | common.cpp | 134 |
1 files changed, 0 insertions, 134 deletions
@@ -917,97 +917,6 @@ void write_screen( const wcstring &msg, wcstring &buff ) buff.push_back(L'\n'); } -void write_screen( const wcstring &msg, string_buffer_t *buff ) -{ - const wchar_t *start, *pos; - int line_width = 0; - int tok_width = 0; - int screen_width = common_get_width(); - - CHECK( buff, ); - - if( screen_width ) - { - start = pos = msg.c_str(); - while( 1 ) - { - int overflow = 0; - - tok_width=0; - - /* - Tokenize on whitespace, and also calculate the width of the token - */ - while( *pos && ( !wcschr( L" \n\r\t", *pos ) ) ) - { - - /* - Check is token is wider than one line. - If so we mark it as an overflow and break the token. - */ - if((tok_width + wcwidth(*pos)) > (screen_width-1)) - { - overflow = 1; - break; - } - - tok_width += wcwidth( *pos ); - pos++; - } - - /* - If token is zero character long, we don't do anything - */ - if( pos == start ) - { - start = pos = pos+1; - } - else if( overflow ) - { - /* - In case of overflow, we print a newline, except if we already are at position 0 - */ - wchar_t *token = wcsndup( start, pos-start ); - if( line_width != 0 ) - sb_append_char( buff, L'\n' ); - sb_printf( buff, L"%ls-\n", token ); - free( token ); - line_width=0; - } - else - { - /* - Print the token - */ - wchar_t *token = wcsndup( start, pos-start ); - if( (line_width + (line_width!=0?1:0) + tok_width) > screen_width ) - { - sb_append_char( buff, L'\n' ); - line_width=0; - } - sb_printf( buff, L"%ls%ls", line_width?L" ":L"", token ); - free( token ); - line_width += (line_width!=0?1:0) + tok_width; - } - - /* - Break on end of string - */ - if( !*pos ) - { - break; - } - - start=pos; - } - } - else - { - sb_printf( buff, L"%ls", msg.c_str() ); - } - sb_append_char( buff, L'\n' ); -} - /** Perform string escaping of a strinng by only quoting it. Assumes the string has already been checked for characters that can not be @@ -1856,49 +1765,6 @@ void bugreport() PACKAGE_BUGREPORT ); } - -void sb_format_size( string_buffer_t *sb, - long long sz ) -{ - const wchar_t *sz_name[]= - { - L"kB", L"MB", L"GB", L"TB", L"PB", L"EB", L"ZB", L"YB", 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; - - } - } -} - wcstring format_size(long long sz) { wcstring result; |