One more regex memory leak fixed.
[glibc.git] / scripts / abi-versions.awk
blob06fa14833cf68847165fc4488c4bb9ccb82438f0
1 # Script to generate <abi-versions.h> header file from Versions.all list.
2 # See include/shlib-compat.h comments for explanation.
4 # This script expects the following variables to be defined:
5 # oldest_abi the oldest ABI supported
7 BEGIN {
8 print "/* This file is automatically generated by abi-versions.awk.";
9 print " It defines symbols used by shlib-compat.h, which see. */";
10 print "\n#ifndef _ABI_VERSIONS_H\n#define _ABI_VERSIONS_H";
13 NF == 2 && $2 == "{" {
14 thislib = $1;
15 gsub(/[^A-Za-z0-9_ ]/, "_"); libid = $1;
16 printf "\n/* start %s */\n", thislib;
17 n = 0;
18 start = 0;
19 next;
21 $1 == "}" {
22 printf "/* end %s */\n", thislib;
23 next;
26 $2 == "=" {
27 old = $1; new = $3;
28 gsub(/[^A-Za-z0-9_ ]/, "_");
29 oldid = $1; newid = $3;
31 printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid;
32 printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new;
34 if ("GLIBC_" oldest_abi == old)
35 oldest_abi = "default";
36 next;
40 vers = $1;
41 gsub(/[^A-Za-z0-9_ ]/, "_");
42 versid = $1;
44 printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers;
45 printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers;
46 if ("GLIBC_" oldest_abi == vers)
47 start = 1;
48 if (start == 0 && oldest_abi != "default")
49 --n;
50 next;
53 END {
54 print "\n#endif /* abi-versions.h */";