2018-06-26 21:22:22 +00:00
|
|
|
#!/usr/bin/python3
|
2009-03-24 09:23:30 +00:00
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
for line in open(sys.argv[1]):
|
2018-12-28 15:28:23 +00:00
|
|
|
match = re.search(r'getopt\(argc, argv, "([\w:]*?)"\)', line)
|
2009-03-24 09:23:30 +00:00
|
|
|
if match:
|
|
|
|
options = match.group(1)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise RuntimeError
|
|
|
|
|
2018-06-26 21:22:22 +00:00
|
|
|
print('#define GETOPT_OPTIONS "%s"' % options)
|
2009-03-24 09:23:30 +00:00
|
|
|
|
2018-06-26 21:22:22 +00:00
|
|
|
print('#define GETOPT_CASE', end=' ')
|
2009-03-24 09:23:30 +00:00
|
|
|
for c in options:
|
2013-07-16 06:50:09 +00:00
|
|
|
if c == ':' or c == 'T':
|
2009-03-24 09:23:30 +00:00
|
|
|
continue
|
2018-06-26 21:22:22 +00:00
|
|
|
print("case '%c':" % c, end=' ')
|
|
|
|
print()
|