From f3aef4d98dc962e14d5fa1b4adee73168042a468 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 20 May 2008 19:06:56 +0100 Subject: [PATCH] [Contribs] Fix multi-line POSIX errno definitions. --- contrib/errcode/build_errcodedb.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/contrib/errcode/build_errcodedb.py b/contrib/errcode/build_errcodedb.py index 868c2d3a..1be9d853 100755 --- a/contrib/errcode/build_errcodedb.py +++ b/contrib/errcode/build_errcodedb.py @@ -22,9 +22,9 @@ errfile_files = ('../../src/include/gpxe/errfile.h', '../../src/arch/i386/include/bits/errfile.h') posix_errno_files = ('../../src/include/errno.h', ) -PXENV_STATUS_RE = re.compile(r'^#define\s+(PXENV_STATUS_[^\s]+)\s+(.+)$') -ERRFILE_RE = re.compile(r'^#define\s+(ERRFILE_[^\s]+)\s+(.+)$') -POSIX_ERRNO_RE = re.compile(r'^#define\s+(E[A-Z]+)\s+.*(0x[0-9a-f]+).*$') +PXENV_STATUS_RE = re.compile(r'^#define\s+(PXENV_STATUS_[^\s]+)\s+(.+)$', re.M) +ERRFILE_RE = re.compile(r'^#define\s+(ERRFILE_[^\s]+)\s+(.+)$', re.M) +POSIX_ERRNO_RE = re.compile(r'^#define\s+(E[A-Z0-9]+)\s+(?:\\\n)?.*(0x[0-9a-f]+).*$', re.M) def err(msg): sys.stderr.write('%s: %s\n' % (sys.argv[0], msg)) @@ -41,11 +41,10 @@ def to_posix_errno(errno): def load_header_file(filename, regexp): defines = {} - for line in open(filename, 'r'): - m = regexp.match(line) - if m: - key, val = m.groups() - defines[key] = val + data = open(filename, 'r').read() + for m in regexp.finditer(data): + key, val = m.groups() + defines[key] = val return defines def evaluate(defines, expr):