getaddrinfo: Eliminate another strdup call
[glibc.git] / scripts / versionlist.awk
blobfe872aaeb5e03774f261e409c4672c3992928815
1 # Extract ordered list of version sets from Versions files.
2 # Copyright (C) 2014-2017 Free Software Foundation, Inc.
4 BEGIN { in_lib = ""; in_version = 0 }
6 !in_lib && NF == 2 && $2 == "{" {
7 in_lib = $1;
8 all_libs[in_lib] = 1;
9 next
11 !in_lib { next }
13 NF == 2 && $2 == "{" {
14 in_version = 1;
15 lib_versions[in_lib, $1] = 1;
16 # Partition the version sets into GLIBC_* and others.
17 if ($1 ~ /GLIBC_/) {
18 libs[in_lib] = libs[in_lib] " " $1 "\n";
19 all_versions[$1] = 1;
21 else {
22 others_libs[in_lib] = others_libs[in_lib] " " $1 "\n";
23 others_all_versions[$1] = 1;
25 next
28 in_version && $1 == "}" { in_version = 0; next }
29 in_version { next }
31 $1 == "}" { in_lib = ""; next }
33 END {
34 nlibs = asorti(all_libs, libs_order);
35 for (i = 1; i <= nlibs; ++i) {
36 lib = libs_order[i];
38 for (v in all_versions) {
39 if (!((lib, v) in lib_versions)) {
40 libs[lib] = libs[lib] " " v "\n";
44 for (v in others_all_versions) {
45 if (!((lib, v) in lib_versions)) {
46 others_libs[lib] = others_libs[lib] " " v "\n";
50 print lib, "{";
52 # Sort and print all the GLIBC_* sets first, then all the others.
53 # This is not really generically right, but it suffices
54 # for the cases we have so far. e.g. GCC_3.0 is "later than"
55 # all GLIBC_* sets that matter for purposes of Versions files.
57 sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3";
58 printf "%s", libs[lib] | sort;
59 close(sort);
61 sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3";
62 printf "%s", others_libs[lib] | sort;
63 close(sort);
65 print "}";