[PATCH 2/5] rpmvercmp: Formatting & comment updates to reduce upstream diff

Dan Nicholson dbn.lists at gmail.com
Sat Apr 20 09:41:55 PDT 2013


No changes to code, only to comments and formatting so that diff with
upstream rpmvercmp is reduced.
---
 rpmvercmp.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/rpmvercmp.c b/rpmvercmp.c
index 3b2e8d6..6de5c02 100644
--- a/rpmvercmp.c
+++ b/rpmvercmp.c
@@ -26,13 +26,14 @@
 /* return 1: a is newer than b */
 /*        0: a and b are the same version */
 /*       -1: b is newer than a */
-int rpmvercmp(const char * a, const char * b) {
+int rpmvercmp(const char * a, const char * b)
+{
     char oldch1, oldch2;
     char * str1, * str2;
     char * one, * two;
     int rc;
     int isnum;
-    
+
     /* easy comparison to see if versions are identical */
     if (!strcmp(a, b)) return 0;
 
@@ -68,7 +69,7 @@ int rpmvercmp(const char * a, const char * b) {
 	    while (*str2 && isalpha((guchar)*str2)) str2++;
 	    isnum = 0;
 	}
-		
+
 	/* save character at the end of the alpha or numeric segment */
 	/* so that they can be restored after the comparison */
 	oldch1 = *str1;
@@ -76,9 +77,13 @@ int rpmvercmp(const char * a, const char * b) {
 	oldch2 = *str2;
 	*str2 = '\0';
 
-	/* take care of the case where the two version segments are */
-	/* different types: one numeric and one alpha */
+	/* this cannot happen, as we previously tested to make sure that */
+	/* the first string has a non-null segment */
 	if (one == str1) return -1;	/* arbitrary */
+
+	/* take care of the case where the two version segments are */
+	/* different types: one numeric, the other alpha (i.e. empty) */
+	/* numeric segments are always newer than alpha segments */
 	/* XXX See patch #60884 (and details) from bugzilla #50977. */
 	if (two == str2) return (isnum ? 1 : -1);
 
@@ -86,7 +91,7 @@ int rpmvercmp(const char * a, const char * b) {
 	    /* this used to be done by converting the digit segments */
 	    /* to ints using atoi() - it's changed because long  */
 	    /* digit segments can overflow an int - this should fix that. */
-	  
+
 	    /* throw away any leading zeros - it's a number, right? */
 	    while (*one == '0') one++;
 	    while (*two == '0') two++;
@@ -102,7 +107,7 @@ int rpmvercmp(const char * a, const char * b) {
 	/* compare */
 	rc = strcmp(one, two);
 	if (rc) return rc;
-	
+
 	/* restore character that was replaced by null above */
 	*str1 = oldch1;
 	one = str1;
-- 
1.8.1.4



More information about the pkg-config mailing list