about summary refs log tree commit diff
path: root/sysdeps/gnu/errlist-compat.awk
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/gnu/errlist-compat.awk')
-rw-r--r--sysdeps/gnu/errlist-compat.awk40
1 files changed, 23 insertions, 17 deletions
diff --git a/sysdeps/gnu/errlist-compat.awk b/sysdeps/gnu/errlist-compat.awk
index 88b4d4f126..c9a7a9cc44 100644
--- a/sysdeps/gnu/errlist-compat.awk
+++ b/sysdeps/gnu/errlist-compat.awk
@@ -29,19 +29,25 @@
 # necessary compatibility symbols for older, smaller versions of sys_errlist.
 #
 
-BEGIN { highest = 0 }
-
 # These two rules catch the Versions file contents.
 NF == 2 && $2 == "{" { last_version = $1; next }
 $1 == "#errlist-compat" {
-  n = $2 + 0;
-  if (n < 100) {
+  # Don't process any further Versions files
+  ARGC = ARGIND + 1;
+  cnt = $2 + 0;
+  if (cnt < 100) {
     print "*** this line seems bogus:", $0 > "/dev/stderr";
     exit 1;
   }
-  version[n] = last_version;
-  if (n > highest)
-    highest = n;
+  version[pos + 0] = cnt SUBSEP last_version;
+  pos++;
+  if (cnt < highest) {
+    printf "*** %s #errlist-compat counts are not sorted\n", ARGV[ARGIND];
+    exit 1;
+  }
+  if (cnt > highest)
+    highest = cnt;
+  highest_version = last_version;
   next;
 }
 
@@ -50,20 +56,20 @@ END {
 
   if (highest != count) {
     printf "*** errlist.c count %d vs Versions sys_errlist@%s count %d\n", \
-      count, version[highest], highest > "/dev/stderr";
+      count, highest_version, highest > "/dev/stderr";
     exit 1;
   }
 
   lastv = "";
-  for (n = 0; n <= count; ++n)
-    if (n in version) {
-      v = version[n];
-      gsub(/[^A-Z0-9_]/, "_", v);
-      if (lastv != "")
-	compat[lastv] = v;
-      lastv = v;
-      vcount[v] = n;
-    }
+  for (n = 0; n < pos; ++n) {
+    split(version[n], t, SUBSEP)
+    v = t[2];
+    gsub(/[^A-Z0-9_]/, "_", v);
+    if (lastv != "")
+      compat[lastv] = v;
+    lastv = v;
+    vcount[v] = t[1];
+  }
 
   print "/* This file was generated by errlist-compat.awk; DO NOT EDIT!  */\n";
   print "#include <shlib-compat.h>\n";