21 lines
389 B
Python
Executable File
21 lines
389 B
Python
Executable File
#!/usr/bin/python
|
|
import re
|
|
import sys
|
|
|
|
for line in open(sys.argv[1]):
|
|
match = re.search('getopt\(argc, argv, "([\w:]*?)"\)', line)
|
|
if match:
|
|
options = match.group(1)
|
|
break
|
|
else:
|
|
raise RuntimeError
|
|
|
|
print '#define GETOPT_OPTIONS "%s"' % options
|
|
|
|
print '#define GETOPT_CASE',
|
|
for c in options:
|
|
if c == ':':
|
|
continue
|
|
print "case '%c':" % c,
|
|
print
|