aboutsummaryrefslogtreecommitdiff
path: root/scripts/extract-abilist.awk
blob: c9adec435945c461246591a98603e9ffa6953eb0 (plain)
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
# awk script to extract a config-specific .symlist file from a merged file.
# This must be passed run with awk -v config=TUPLE to specify the configuration
# tuple we will match.  The merged file contains stanzas in the form:
#	GLIBC_x.y regexp...
#	| GLIBC_x.y.z regexp...
#	| GLIBC_m.n regexp...
#	 function F
#	 variable D 0x4
# Each regexp is matched against TUPLE, and only matching stanzas go
# into the output, with the regexp list removed.  Multiple version lines
# can match with the same regexp, meaning the stanza is duplicated in
# multiple version sets.  The result matches the original .symlist file
# from abilist.awk that was fed into merge-abilist.awk.

BEGIN {
  inside = 0;
}

/^ / {
  inside = 1;
  if (!ignore) {
    for (version in current) {
      if (version in versions)
	versions[version] = versions[version] "\n" $0;
      else
	versions[version] = $0;
    }
  }
  next;
}

{
  second = ($1 == "|");
  if (second && inside) {
    printf "%s:%d: bad input line inside stanza: %s\n", FILENAME, FNR, $0;
    exit 1;
  }
  inside = 0;

  for (i = second ? 3 : 2; i <= NF; ++i) {
    regex = "^" $i "$";
    if (match(config, regex) != 0) {
      if (!second || ignore)
        # Clear old array.
        split("", current);
      current[second ? $2 : $1] = 1;
      ignore = 0;
      next;
    }
  }

  if (!second)
    ignore = 1;
  next;
}

END {
  nverlist = 0;
  for (version in versions) {
    if (nverslist == 0) {
      verslist = version;
      nverslist = 1;
      continue;
    }
    split(verslist, s, "\n");
    if (version < s[1]) {
      verslist = version;
      for (i = 1; i <= nverslist; ++i) {
	verslist = verslist "\n" s[i];
      }
    }
    else {
      verslist = s[1];
      for (i = 2; i <= nverslist; ++i) {
	if (version < s[i]) break;
	verslist = verslist "\n" s[i];
      }
      verslist = verslist "\n" version;
      for (; i <= nverslist; ++i) {
	verslist = verslist "\n" s[i];
      }
    }
    ++nverslist;
  }

  split(verslist, order, "\n");
  for (i = 1; i <= nverslist; ++i) {
    version = order[i];

    print version;
    outpipe = "sort";
    print versions[version] | outpipe;
    close(outpipe);

    if (version == lastversion)
      break;
  }
}