2008-05-30 15:03:06 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
from cStringIO import StringIO
|
|
|
|
import glob
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
2008-08-01 16:08:54 +02:00
|
|
|
srcdir = sys.argv[1]
|
|
|
|
|
|
|
|
hlines = file('%s/errors.h' % srcdir,'r').readlines()
|
2008-05-30 15:03:06 +02:00
|
|
|
messages = dict()
|
2009-08-26 17:15:07 +02:00
|
|
|
description = None
|
2008-05-30 15:03:06 +02:00
|
|
|
|
|
|
|
for line in hlines:
|
2009-08-26 17:15:07 +02:00
|
|
|
m = re.match(r'^ \* (.*[^:])$', line)
|
2008-08-05 16:53:29 +02:00
|
|
|
if m:
|
2009-08-26 17:15:07 +02:00
|
|
|
description = m.group(1)
|
|
|
|
m = re.match(r'#define (LASSO_\w+)', line)
|
|
|
|
if m and description:
|
|
|
|
messages[m.group(1)] = description
|
|
|
|
description = None
|
2008-08-05 16:53:29 +02:00
|
|
|
else:
|
|
|
|
m = re.match(r'#define (LASSO_\w+)',line)
|
|
|
|
if m:
|
|
|
|
messages[m.group(1)] = m.group(1)
|
2008-05-30 15:03:06 +02:00
|
|
|
|
2008-08-01 16:08:54 +02:00
|
|
|
clines = file('%s/errors.c.in' % srcdir,'r').readlines()
|
2008-05-30 15:03:06 +02:00
|
|
|
for line in clines:
|
2008-08-05 16:53:29 +02:00
|
|
|
if '@ERROR_CASES@' in line:
|
|
|
|
for k in messages:
|
|
|
|
print """ case %s:
|
2009-08-26 17:15:07 +02:00
|
|
|
return "%s";""" % (k,messages[k].rstrip('\n'))
|
2008-08-05 16:53:29 +02:00
|
|
|
else:
|
|
|
|
print line,
|