cosmetics
authorspiff <spiff@xbmc.org>
Wed, 17 Aug 2011 12:39:07 +0000 (14:39 +0200)
committerspiff <spiff@xbmc.org>
Wed, 17 Aug 2011 12:39:31 +0000 (14:39 +0200)
xbmc/addons/AddonVersion.cpp

index 0c5c55a..76c1bc3 100644 (file)
@@ -35,36 +35,32 @@ namespace ADDON
     if (m_originalVersion.IsEmpty())
       m_originalVersion = "0.0.0";
     const char *epoch_end = strchr(m_originalVersion.c_str(), ':');
-    if (epoch_end != NULL) {
+    if (epoch_end != NULL)
       mEpoch = atoi(m_originalVersion.c_str());
-    } else {
+    else
       mEpoch = 0;
-    }
 
     const char *upstream_start;
-    if (epoch_end) {
+    if (epoch_end)
       upstream_start = epoch_end + 1;
-    } else {
+    else
       upstream_start = m_originalVersion.c_str();
-    }
 
     const char *upstream_end = strrchr(upstream_start, '-');
     size_t upstream_size;
-    if (upstream_end == NULL) {
+    if (upstream_end == NULL)
       upstream_size = strlen(upstream_start);
-    } else {
+    else
       upstream_size = upstream_end - upstream_start;
-    }
 
     mUpstream = (char*) malloc(upstream_size + 1);
     strncpy(mUpstream, upstream_start, upstream_size);
     mUpstream[upstream_size] = '\0';
 
-    if (upstream_end == NULL) {
+    if (upstream_end == NULL)
       mRevision = strdup("0");
-    } else {
+    else
       mRevision = strdup(upstream_end + 1);
-    }
   }
 
   /**Compare two components of a Debian-style version.  Return -1, 0, or 1
@@ -72,10 +68,12 @@ namespace ADDON
    */
   int AddonVersion::CompareComponent(const char *a, const char *b)
   {
-    while (*a && *b) {
-
-      while (*a && *b && !isdigit(*a) && !isdigit(*b)) {
-        if (*a != *b) {
+    while (*a && *b)
+    {
+      while (*a && *b && !isdigit(*a) && !isdigit(*b))
+      {
+        if (*a != *b)
+        {
           if (*a == '~') return -1;
           if (*b == '~') return 1;
           return *a < *b ? -1 : 1;
@@ -83,7 +81,8 @@ namespace ADDON
         a++;
         b++;
       }
-      if (*a && *b && (!isdigit(*a) || !isdigit(*b))) {
+      if (*a && *b && (!isdigit(*a) || !isdigit(*b)))
+      {
         if (*a == '~') return -1;
         if (*b == '~') return 1;
         return isdigit(*a) ? -1 : 1;
@@ -92,34 +91,30 @@ namespace ADDON
       char *next_a, *next_b;
       long int num_a = strtol(a, &next_a, 10);
       long int num_b = strtol(b, &next_b, 10);
-      if (num_a != num_b) {
+      if (num_a != num_b)
         return num_a < num_b ? -1 : 1;
-      }
+
       a = next_a;
       b = next_b;
-
     }
-    if (!*a && !*b) {
+    if (!*a && !*b)
       return 0;
-    } else if (*a) {
+    if (*a)
       return *a == '~' ? -1 : 1;
-    } else {
+    else
       return *b == '~' ? 1 : -1;
-    }
   }
 
   bool AddonVersion::operator<(const AddonVersion& other) const
   {
-    if (Epoch() != other.Epoch()) {
+    if (Epoch() != other.Epoch())
       return Epoch() < other.Epoch();
-    }
 
     int result = CompareComponent(Upstream(), other.Upstream());
-    if (result) {
-      return -1 == result;
-    }
+    if (result)
+      return (-1 == result);
 
-    return -1 == CompareComponent(Revision(), other.Revision());
+    return (-1 == CompareComponent(Revision(), other.Revision()));
   }
 
   CStdString AddonVersion::Print() const