(trunk gtk) replace tr_strcmp() with gtr_strcmp0(), a porability wrapper around g_strcmp0()

This commit is contained in:
Charles Kerr 2010-08-01 19:13:34 +00:00
parent 3fa4865863
commit 59f5f3ed6b
3 changed files with 19 additions and 13 deletions

View File

@ -542,16 +542,6 @@ tr_core_apply_defaults( tr_ctor * ctor )
}
}
static int
tr_strcmp( const void * a,
const void * b )
{
if( a && b ) return strcmp( a, b );
if( a ) return 1;
if( b ) return -1;
return 0;
}
static char *
torrentTrackerString( tr_torrent * tor )
{
@ -718,7 +708,7 @@ updateWatchDir( TrCore * core )
PREF_KEY_DIR_WATCH_ENABLED );
struct TrCorePrivate * p = TR_CORE( core )->priv;
if( p->monitor && ( !isEnabled || tr_strcmp( filename, p->monitor_path ) ) )
if( p->monitor && ( !isEnabled || gtr_strcmp0( filename, p->monitor_path ) ) )
{
g_signal_handler_disconnect( p->monitor, p->monitor_tag );
g_free( p->monitor_path );
@ -1339,7 +1329,7 @@ update_foreach( GtkTreeModel * model,
if( ( newActivity != oldActivity )
|| ( newFinished != oldFinished )
|| ( newPriority != oldPriority )
|| tr_strcmp( oldTrackers, newTrackers )
|| gtr_strcmp0( oldTrackers, newTrackers )
|| gtr_compare_double( newUpSpeed, oldUpSpeed, 3 )
|| gtr_compare_double( newDownSpeed, oldDownSpeed, 3 ) )
{
@ -1534,7 +1524,7 @@ tr_core_set_pref( TrCore * self, const char * key, const char * newval )
{
const char * oldval = pref_string_get( key );
if( tr_strcmp( oldval, newval ) )
if( gtr_strcmp0( oldval, newval ) )
{
pref_string_set( key, newval );
commitPrefsChange( self, key );

View File

@ -480,6 +480,19 @@ gtr_object_ref_sink( gpointer object )
return object;
}
int
gtr_strcmp0( const char * str1, const char * str2 )
{
#if GLIB_CHECK_VERSION( 2, 16, 0 )
return g_strcmp0( str1, str2 );
#else
if( str1 && str2 ) return strcmp( str1, str2 );
if( str1 ) return 1;
if( str2 ) return -1;
return 0;
#endif
}
int
gtr_file_trash_or_remove( const char * filename )
{

View File

@ -158,6 +158,9 @@ void gtr_widget_set_visible( GtkWidget *, gboolean );
/* backwards-compatible wrapper around g_object_ref_sink() */
gpointer gtr_object_ref_sink( gpointer object );
/* backwards-comparible wrapper around g_strcmp0() */
int gtr_strcmp0( const char * str1, const char * str2 );
/***
****
***/