Changeset 5220


Ignore:
Timestamp:
Mar 7, 2008, 7:27:46 PM (14 years ago)
Author:
charles
Message:

(gtk) r5212 tr_strltime() cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/util.c

    r5213 r5220  
    7070tr_strlsize( char * buf, guint64 size, size_t buflen )
    7171{
     72    if( !size )
     73        g_strlcpy( buf, _( "None" ), buflen );
    7274#if GLIB_CHECK_VERSION(2,16,0)
    73     char * tmp = g_format_size_for_display( s );
    74     g_strlcpy( buf, tmp, buflen );
    75     g_free( tmp );
     75    else{
     76        char * tmp = g_format_size_for_display( s );
     77        g_strlcpy( buf, tmp, buflen );
     78        g_free( tmp );
     79    }
    7680#else
    77     if( size < (guint64)KILOBYTE_FACTOR )
     81    else if( size < (guint64)KILOBYTE_FACTOR )
    7882        g_snprintf( buf, buflen, ngettext("%u byte", "%u bytes", (guint)size), (guint)size );
    7983    else {
     
    121125    if( seconds < 60 )
    122126    {
    123         g_snprintf( buf, sizeof( buf ), ngettext( "%'d second", "%'d seconds", (int)seconds ), (int) seconds );
     127        g_snprintf( buf, buflen, ngettext( "%'d second", "%'d seconds", (int)seconds ), (int) seconds );
    124128        return buf;
    125129    }
     
    128132    {
    129133        const int minutes = ( seconds + 30 ) / 60;
    130         g_snprintf( buf, sizeof( buf ), ngettext( "%'d minute", "%'d minutes", minutes ), minutes );
     134        g_snprintf( buf, buflen, ngettext( "%'d minute", "%'d minutes", minutes ), minutes );
    131135        return buf;
    132136    }
     
    147151    }
    148152
    149     g_snprintf( buf, sizeof( buf ), ngettext( "%'d hour", "%'d hours", hours ), hours );
     153    g_snprintf( buf, buflen, ngettext( "%'d hour", "%'d hours", hours ), hours );
    150154    return buf;
    151155}
Note: See TracChangeset for help on using the changeset viewer.