Debian Codegraph @

src/shared/generate-dns_type-gperf.py

raw
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 """Generate %-from-name.gperf from %-list.txt"""
5
6 import sys
7
8 name, prefix, input = sys.argv[1:]
9
10 print(f'''\
11 %{{
12 _Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
13 #if __GNUC__ >= 15
14 _Pragma("GCC diagnostic ignored \\"-Wzero-as-null-pointer-constant\\"")
15 #endif
16 %}}
17 struct {name}_name {{ const char* name; int id; }};
18 %null-strings
19 %%''')
20
21 for line in open(input):
22 line = line.rstrip()
23 s = line.replace('_', '-')
24 print(f'{s}, {prefix}{line}')