2009-03-24 09:23:30 +00:00
|
|
|
#!/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:
|
2013-07-16 06:50:09 +00:00
|
|
|
if c == ':' or c == 'T':
|
2009-03-24 09:23:30 +00:00
|
|
|
continue
|
|
|
|
print "case '%c':" % c,
|
|
|
|
print
|