Commit 7bca27a5 authored by Rémi Duraffort's avatar Rémi Duraffort

Simplify the version test dans remove useless things

parent 0761ae5e
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
* Misc defines * Misc defines
*****************************************************************************/ *****************************************************************************/
//#define UPDATE_VLC_STATUS_URL "http://zen.via.ecp.fr/~ivoire/videolan/update"
#if defined( UNDER_CE ) #if defined( UNDER_CE )
# define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-ce" # define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-ce"
#elif defined( WIN32 ) #elif defined( WIN32 )
...@@ -74,7 +72,7 @@ ...@@ -74,7 +72,7 @@
*****************************************************************************/ *****************************************************************************/
static void EmptyRelease( update_t *p_update ); static void EmptyRelease( update_t *p_update );
static void GetUpdateFile( update_t *p_update ); static void GetUpdateFile( update_t *p_update );
static int cmp( int i1, int i2 ); static int extracmp( char *psz_1, char *psz_2 );
static int CompareReleases( const struct update_release_t *p1, static int CompareReleases( const struct update_release_t *p1,
const struct update_release_t *p2 ); const struct update_release_t *p2 );
...@@ -122,29 +120,10 @@ void update_Delete( update_t *p_update ) ...@@ -122,29 +120,10 @@ void update_Delete( update_t *p_update )
vlc_mutex_destroy( &p_update->lock ); vlc_mutex_destroy( &p_update->lock );
if( p_update->release.psz_svnrev ) FREENULL( p_update->release.psz_svnrev );
{ FREENULL( p_update->release.psz_extra );
free( p_update->release.psz_svnrev ); FREENULL( p_update->release.psz_url );
p_update->release.psz_svnrev = NULL; FREENULL( p_update->release.psz_desc );
}
if( p_update->release.psz_extra )
{
free( p_update->release.psz_extra );
p_update->release.psz_extra = NULL;
}
if( p_update->release.psz_url )
{
free( p_update->release.psz_url );
p_update->release.psz_url = NULL;
}
if( p_update->release.psz_desc )
{
free( p_update->release.psz_desc );
p_update->release.psz_desc = NULL;
}
free( p_update ); free( p_update );
} }
...@@ -161,29 +140,10 @@ static void EmptyRelease( update_t *p_update ) ...@@ -161,29 +140,10 @@ static void EmptyRelease( update_t *p_update )
p_update->release.i_minor = 0; p_update->release.i_minor = 0;
p_update->release.i_revision = 0; p_update->release.i_revision = 0;
if( p_update->release.psz_svnrev ) FREENULL( p_update->release.psz_svnrev );
{ FREENULL( p_update->release.psz_extra );
free( p_update->release.psz_svnrev ); FREENULL( p_update->release.psz_url );
p_update->release.psz_svnrev = NULL; FREENULL( p_update->release.psz_desc );
}
if( p_update->release.psz_extra )
{
free( p_update->release.psz_extra );
p_update->release.psz_extra = NULL;
}
if( p_update->release.psz_url )
{
free( p_update->release.psz_url );
p_update->release.psz_url = NULL;
}
if( p_update->release.psz_desc )
{
free( p_update->release.psz_desc );
p_update->release.psz_desc = NULL;
}
} }
/** /**
...@@ -228,15 +188,8 @@ static void GetUpdateFile( update_t *p_update ) ...@@ -228,15 +188,8 @@ static void GetUpdateFile( update_t *p_update )
p_update->release.i_minor = i_minor; p_update->release.i_minor = i_minor;
p_update->release.i_revision = i_revision; p_update->release.i_revision = i_revision;
if( psz_svnrev ) p_update->release.psz_svnrev = psz_svnrev ? psz_svnrev : STRDUP( "" );
p_update->release.psz_svnrev = psz_svnrev; p_update->release.psz_extra = psz_extra ? psz_extra : STRDUP( "" );
else
p_update->release.psz_svnrev = STRDUP( "" );
if( psz_extra )
p_update->release.psz_extra = psz_extra;
else
p_update->release.psz_extra = STRDUP( "" );
} }
else else
{ {
...@@ -287,22 +240,29 @@ void update_Check( update_t *p_update ) ...@@ -287,22 +240,29 @@ void update_Check( update_t *p_update )
} }
/** /**
* Compare two integers * Compare two extra
* *
* \param p1 first integer * \param p1 first integer
* \param p2 second integer * \param p2 second integer
* \return like strcmp * \return like strcmp
*/ */
static int cmp( int i1, int i2 ) static int extracmp( char *psz_1, char *psz_2 )
{ {
if( i1 < i2 ) if( psz_1[0] == '-' )
return -1; {
else if(i1 == i2) if( psz_2[0] == '-' )
return 0; return strcmp( psz_1, psz_2 );
else
return 1;
}
else else
return 1; {
if( psz_2[0] == '-' )
return -1;
else
return strcmp( psz_1, psz_2 );
}
} }
/** /**
* Compare two release numbers * Compare two release numbers
* *
...@@ -313,29 +273,13 @@ static int cmp( int i1, int i2 ) ...@@ -313,29 +273,13 @@ static int cmp( int i1, int i2 )
static int CompareReleases( const struct update_release_t *p1, static int CompareReleases( const struct update_release_t *p1,
const struct update_release_t *p2 ) const struct update_release_t *p2 )
{ {
int d; int32_t d;
if( ( d = cmp( p1->i_major, p2->i_major ) ) ) ; d = ( p1->i_major << 24 ) + ( p1->i_minor << 16 ) + ( p1->i_revision << 8 );
else if( ( d = cmp( p1->i_minor, p2->i_minor ) ) ) ; d = d - ( p2->i_major << 24 ) - ( p2->i_minor << 16 ) - ( p2->i_revision << 8 );
else if( ( d = cmp( p1->i_revision, p2->i_revision ) ) ) ; d += extracmp( p1->psz_extra, p2->psz_extra );
else
{ if( d == 0 )
if( p1->psz_extra[0] == '-' ) d = strcmp( p1->psz_svnrev, p2->psz_svnrev );
{
if( p2->psz_extra[0] == '-' )
d = strcmp( p1->psz_extra, p2->psz_extra );
else
d = 1;
}
else
{
if( p2->psz_extra[0] == '-' )
d = -1;
else
d = strcmp(p1->psz_extra, p2->psz_extra );
}
if( d == 0 )
d = strcmp( p1->psz_svnrev, p2->psz_svnrev );
}
if( d < 0 ) if( d < 0 )
return UpdateReleaseStatusOlder; return UpdateReleaseStatusOlder;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment