We are linking with glibc now, so use strverscmp() in place of the rpmvercmp() function in loadermisc.c. --- loader/Makefile | 2 +- loader/dirbrowser.c | 2 +- loader/loadermisc.c | 110 +++----------------------------------------------- 3 files changed, 9 insertions(+), 105 deletions(-) diff --git a/loader/Makefile b/loader/Makefile index e83d0f2..25dfb64 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -65,7 +65,7 @@ SOURCES = $(subst .o,.c,$(OBJS)) loader.c LIBS += -CFLAGS += -DUSE_LOGDEV -DVERSION='"$(VERSION)"' +CFLAGS += -DUSE_LOGDEV -DVERSION='"$(VERSION)"' -D_GNU_SOURCE REALCC=gcc # linuxrc + shutdown on s390, init everywhere else diff --git a/loader/dirbrowser.c b/loader/dirbrowser.c index 4d9c25c..6c713ec 100644 --- a/loader/dirbrowser.c +++ b/loader/dirbrowser.c @@ -43,7 +43,7 @@ static int simpleStringCmp(const void * a, const void * b) { const char * first = *((const char **) a); const char * second = *((const char **) b); - + return strcmp(first, second); } #endif diff --git a/loader/loadermisc.c b/loader/loadermisc.c index a156007..03d26bb 100644 --- a/loader/loadermisc.c +++ b/loader/loadermisc.c @@ -86,107 +86,11 @@ int copyFile(char * source, char * dest) { return rc; } -/* FIXME: when we only depend on glibc, we could use strvercmp instead */ -/* compare alpha and numeric segments of two versions */ -/* return 1: a is newer than b */ -/* 0: a and b are the same version */ -/* -1: b is newer than a */ -static 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; - - str1 = alloca(strlen(a) + 1); - str2 = alloca(strlen(b) + 1); - - strcpy(str1, a); - strcpy(str2, b); - - one = str1; - two = str2; - - /* loop through each version segment of str1 and str2 and compare them */ - while (*one && *two) { - while (*one && !isalnum(*one)) one++; - while (*two && !isalnum(*two)) two++; - - str1 = one; - str2 = two; - - /* grab first completely alpha or completely numeric segment */ - /* leave one and two pointing to the start of the alpha or numeric */ - /* segment and walk str1 and str2 to end of segment */ - if (isdigit(*str1)) { - while (*str1 && isdigit(*str1)) str1++; - while (*str2 && isdigit(*str2)) str2++; - isnum = 1; - } else { - while (*str1 && isalpha(*str1)) str1++; - while (*str2 && isalpha(*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; - *str1 = '\0'; - oldch2 = *str2; - *str2 = '\0'; - - /* take care of the case where the two version segments are */ - /* different types: one numeric, the other alpha (i.e. empty) */ - if (one == str1) return -1; /* arbitrary */ - /* XXX See patch #60884 (and details) from bugzilla #50977. */ - if (two == str2) return (isnum ? 1 : -1); - - if (isnum) { - /* 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++; - - /* whichever number has more digits wins */ - if (strlen(one) > strlen(two)) return 1; - if (strlen(two) > strlen(one)) return -1; - } - - /* strcmp will return which one is greater - even if the two */ - /* segments are alpha or if they are numeric. don't return */ - /* if they are equal because there might be more segments to */ - /* compare */ - rc = strcmp(one, two); - if (rc) return (rc < 1 ? -1 : 1); - - /* restore character that was replaced by null above */ - *str1 = oldch1; - one = str1; - *str2 = oldch2; - two = str2; - } - - /* this catches the case where all numeric and alpha segments have */ - /* compared identically but the segment sepparating characters were */ - /* different */ - if ((!*one) && (!*two)) return 0; - - /* whichever version still has characters left over wins */ - if (!*one) return -1; else return 1; -} - int simpleStringCmp(const void * a, const void * b) { const char * first = *((const char **) a); const char * second = *((const char **) b); - return rpmvercmp(first, second); + return strverscmp(first, second); } /* look for available memory. note: won't ever report more than the @@ -197,23 +101,23 @@ int totalMemory(void) { char buf[4096]; char * chptr, * start; int total = 0; - + fd = open("/proc/meminfo", O_RDONLY); if (fd < 0) { logMessage(ERROR, "failed to open /proc/meminfo: %m"); return 0; } - + bytesRead = read(fd, buf, sizeof(buf) - 1); if (bytesRead < 0) { logMessage(ERROR, "failed to read from /proc/meminfo: %m"); close(fd); return 0; } - + close(fd); buf[bytesRead] = '\0'; - + chptr = buf; while (*chptr && !total) { if (strncmp(chptr, "MemTotal:", 9)) { @@ -225,7 +129,7 @@ int totalMemory(void) { while (*chptr && *chptr != '\n') chptr++; *chptr = '\0'; - + while (!isdigit(*start) && *start) start++; if (!*start) { logMessage(WARNING, "no number appears after MemTotal tag"); @@ -240,6 +144,6 @@ int totalMemory(void) { } logMessage(INFO, "%d kB are available", total); - + return total; } -- 1.6.0.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list