[vlc-devel] commit: update: Correctly compare the version number. (Pierre d'Herbemont )

git version control git at videolan.org
Sun Aug 3 21:01:03 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Sun Aug  3 21:02:43 2008 +0200| [c459891a450ee8c6a476c38dd45805f147f0a73f] | committer: Pierre d'Herbemont 

update: Correctly compare the version number.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c459891a450ee8c6a476c38dd45805f147f0a73f
---

 src/misc/update.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/misc/update.c b/src/misc/update.c
index c8abdcd..b421034 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -1403,14 +1403,32 @@ void update_CheckReal( update_check_thread_t *p_uct )
  * \param p_update structure
  * \return true if we have to upgrade to the given version to be up to date
  */
+static bool is_strictly_greater( int * a, int * b, int n)
+{
+    if( n <= 0 ) return false;
+    if(a[0] > b[0] ) return true;
+    if(a[0] == b[0] ) return is_strictly_greater( a+1, b+1, n-1 );
+    /* a[0] < b[0] */ return false;
+}
+
 bool update_NeedUpgrade( update_t *p_update )
 {
     assert( p_update );
 
-    return  p_update->release.i_major    < *PACKAGE_VERSION_MAJOR    - '0'  ||
-            p_update->release.i_minor    < *PACKAGE_VERSION_MINOR    - '0'  ||
-            p_update->release.i_revision < *PACKAGE_VERSION_REVISION - '0'  ||
-            p_update->release.extra      < *PACKAGE_VERSION_EXTRA;
+    int current_version[] = {
+        *PACKAGE_VERSION_MAJOR - '0',
+        *PACKAGE_VERSION_MINOR - '0',
+        *PACKAGE_VERSION_REVISION - '0',
+        *PACKAGE_VERSION_EXTRA
+    };
+    int latest_version[] = {
+        p_update->release.i_major,
+        p_update->release.i_minor,
+        p_update->release.i_revision,
+        p_update->release.extra
+    };
+
+    return is_strictly_greater( latest_version, current_version, 4 );
 }
 
 /**




More information about the vlc-devel mailing list