1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# awk script to merge a config-specific .symlist file with others.
# The input files should be an existing .abilist file, and a .symlist file.
# This must be passed run with awk -v config=REGEXP to specify a regexp
# matching configuration tuples for which the .symlist input defines an ABI.
# The result merges all duplicate occurrences of any symbol in a version set
# into a stanza listing the regexps matching configurations that contain it.
/^[^ ]/ {
if (NF < 2 && config == "") {
print "BAD LINE:", $0 > "/dev/stderr";
exit 2;
}
if (NF < 2) {
current = $1 ":" config;
}
else {
# Filter out the old stanzas from the config we are merging in.
# That way, if a set disappears from the .symlist file for this
# config, the old stanza doesn't stay in the merged output tagged
# for this config. (Disappearing sets might happen during development,
# and between releases could happen on a soname change).
nc = 0;
for (i = 2; i <= NF; ++i)
if ($i != config)
c[nc++] = $i;
if (nc == 0)
current = "";
else {
current = $1 ":" c[0];
for (i = 1; i < nc; ++i)
current = current "," $1 ":" c[i];
}
}
next;
}
{
if (current == "") next;
if ($0 in seen) {
seen[$0] = seen[$0] "\n" current;
}
else {
seen[$0] = current;
}
next;
}
END {
for (line in seen) {
split(seen[line], setlist, "\n");
for (i in setlist) {
split(setlist[i], configs, ",");
for (j in configs) {
split(configs[j], temp, ":");
version = temp[1];
conf = temp[2];
if ((version,conf) in have) continue;
have[version,conf] = 1;
if (version in confs) {
split(confs[version], c, " ");
if (conf < c[1]) {
confs[version] = conf;
for (k = 1; k <= nconfs[version]; ++k) {
confs[version] = confs[version] " " c[k];
}
}
else {
confs[version] = c[1];
for (k = 2; k <= nconfs[version]; ++k) {
if (conf < c[k]) break;
confs[version] = confs[version] " " c[k];
}
confs[version] = confs[version] " " conf;
for (; k <= nconfs[version]; ++k) {
confs[version] = confs[version] " " c[k];
}
}
++nconfs[version];
}
else {
confs[version] = conf;
nconfs[version] = 1;
}
}
}
for (idx in have) delete have[idx];
for (version in confs) {
# Hack: if an element is foo.*/bar and there is also a foo.*,
# then we can omit the foo.*/bar since foo.* matches already.
nc = split(confs[version], c, " ");
for (i = 1; i <= nc; ++i) {
slash = index(c[i], ".*/");
if (slash > 0) {
beforeslash = substr(c[i], 1, slash + 2 - 1);
for (j = 1; j <= nc; ++j)
if (j != i && c[j] == beforeslash) {
c[i] = c[nc--];
break;
}
}
}
idx = version;
for (i = 1; i <= nc; ++i)
idx = idx " " c[i];
if (idx in final) {
final[idx] = final[idx] "\n" line;
}
else {
final[idx] = line;
}
delete confs[version];
delete nconfs[version];
}
}
nstanzas = 0;
for (stanza in final) {
if (nstanzas == 0) {
stanzas = stanza;
nstanzas = 1;
continue;
}
split(stanzas, s, "\n");
if (stanza < s[1]) {
stanzas = stanza;
for (i = 1; i <= nstanzas; ++i) {
stanzas = stanzas "\n" s[i];
}
}
else {
stanzas = s[1];
for (i = 2; i <= nstanzas; ++i) {
if (stanza < s[i]) break;
stanzas = stanzas "\n" s[i];
}
stanzas = stanzas "\n" stanza;
for (; i <= nstanzas; ++i) {
stanzas = stanzas "\n" s[i];
}
}
++nstanzas;
}
split(stanzas, order, "\n");
for (i = 1; i <= nstanzas; ++i) {
stanza = order[i];
print stanza;
outpipe = "sort";
print final[stanza] | outpipe;
close(outpipe);
}
}
|