[BZ #3306]
[glibc.git] / scripts / firstversions.awk
blob8da92ae485d6b0a36703552897a0b50d21e0f18e
1 # Script to preprocess Versions.all lists based on "earliest version"
2 # specifications in the shlib-versions file.
4 NF > 2 && $2 == ":" {
5 for (i = 0; i <= NF - 3; ++i)
6 firstversion[$1, i] = $(3 + i);
7 idx[$1] = 0;
8 next;
11 NF == 2 && $2 == "{" { thislib = $1; print; next }
13 $1 == "}" {
14 if ((thislib, idx[thislib]) in firstversion) {
15 # We haven't seen the stated version, but have produced
16 # others pointing to it, so we synthesize it now.
17 printf " %s\n", firstversion[thislib, idx[thislib]];
18 idx[thislib]++;
20 print;
21 next;
24 /GLIBC_PRIVATE/ { print; next }
27 if ((thislib, idx[thislib]) in firstversion) {
28 # XXX relative string comparison loses if we ever have multiple digits
29 # between dots in GLIBC_x.y[.z] names.
30 f = v = firstversion[thislib, idx[thislib]];
31 while ($1 >= v) {
32 delete firstversion[thislib, idx[thislib]];
33 idx[thislib]++;
34 if ((thislib, idx[thislib]) in firstversion)
35 v = firstversion[thislib, idx[thislib]];
36 else
37 break;
39 if ($1 == v || $1 == f)
40 # This version was the specified earliest version itself.
41 print;
42 else if ($1 < v) {
43 # This version is older than the specified earliest version.
44 print " " $1, "=", v;
45 # Record that V has been referred to, so we will be sure to emit it
46 # if we hit a later one without hitting V itself.
47 usedversion[thislib, v] = 1;
49 else {
50 # This version is newer than the specified earliest version.
51 # We haven't seen that version itself or else we wouldn't be here
52 # because we would have removed it from the firstversion array.
53 # If there were any earlier versions that used that one, emit it now.
54 if ((thislib, v) in usedversion) {
55 print " " v;
57 print " " $1;
60 else
61 print;