about summary refs log tree commit diff
path: root/scripts/firstversions.awk
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-12-06 02:13:20 +0000
committerUlrich Drepper <drepper@redhat.com>2008-12-06 02:13:20 +0000
commit8680179fdbaa69ba5c3d6056adf32c68d98e171a (patch)
treeb3d4087f34cf4508a1088532d80d5e6c256b3541 /scripts/firstversions.awk
parent71885b7a9149b5e54906204491b64d5ad0a48e9d (diff)
downloadglibc-8680179fdbaa69ba5c3d6056adf32c68d98e171a.tar.gz
glibc-8680179fdbaa69ba5c3d6056adf32c68d98e171a.tar.xz
glibc-8680179fdbaa69ba5c3d6056adf32c68d98e171a.zip
2008-12-05 Joseph Myers <joseph@codesourcery.com>
	    Ulrich Drepper  <drepper@redhat.com>

	* scripts/firstversion.awk: Use custom comparison function to compare
	version numbers.
	* scripts/versions.awk: Use sort invocation which can handle
	multi-digit sub-version numbers.
Diffstat (limited to 'scripts/firstversions.awk')
-rw-r--r--scripts/firstversions.awk31
1 files changed, 27 insertions, 4 deletions
diff --git a/scripts/firstversions.awk b/scripts/firstversions.awk
index 8da92ae485..4a20fc0f9d 100644
--- a/scripts/firstversions.awk
+++ b/scripts/firstversions.awk
@@ -1,6 +1,31 @@
 # Script to preprocess Versions.all lists based on "earliest version"
 # specifications in the shlib-versions file.
 
+# Return -1, 0 or 1 according to whether v1 is less than, equal to or
+# greater than v2 as a version string. Simplified from GNU Autoconf
+# version; this one does not need to handle .0x fraction-style versions.
+function vers_compare (v1, v2)
+{
+  while (length(v1) && length(v2)) {
+    if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
+      for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue;
+      for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue;
+      d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1);
+      d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1);
+      d1 += 0;
+      d2 += 0;
+    } else {
+      d1 = substr(v1, 1, 1); v1 = substr(v1, 2);
+      d2 = substr(v2, 1, 1); v2 = substr(v2, 2);
+    }
+    if (d1 < d2) return -1;
+    if (d1 > d2) return 1;
+  }
+  if (length(v2)) return -1;
+  if (length(v1)) return 1;
+  return 0;
+}
+
 NF > 2 && $2 == ":" {
   for (i = 0; i <= NF - 3; ++i)
     firstversion[$1, i] = $(3 + i);
@@ -25,10 +50,8 @@ $1 == "}" {
 
 {
   if ((thislib, idx[thislib]) in firstversion) {
-    # XXX relative string comparison loses if we ever have multiple digits
-    # between dots in GLIBC_x.y[.z] names.
     f = v = firstversion[thislib, idx[thislib]];
-    while ($1 >= v) {
+    while (vers_compare($1, v) >= 0) {
       delete firstversion[thislib, idx[thislib]];
       idx[thislib]++;
       if ((thislib, idx[thislib]) in firstversion)
@@ -39,7 +62,7 @@ $1 == "}" {
     if ($1 == v || $1 == f)
       # This version was the specified earliest version itself.
       print;
-    else if ($1 < v) {
+    else if (vers_compare($1, v) < 0) {
       # This version is older than the specified earliest version.
       print "  " $1, "=", v;
       # Record that V has been referred to, so we will be sure to emit it