From d8e7470c83599d7ba31159a7f92a3ca8cabc5d65 Mon Sep 17 00:00:00 2001 From: Alexander Shiryaev Date: Wed, 14 Nov 2012 15:16:32 +0400 Subject: [PATCH] OpenBSD errno to string CASE generator added --- .../_OpenBSD_/Lin/Mod/gen-Libc/Makefile | 10 ++++-- .../Lin/Mod/gen-Libc/mkdumpstrerrno.py | 32 +++++++++++++++++++ .../Lin/Mod/gen-Libc/mkstrerrnocase.py | 17 ++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py create mode 100755 Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile index eb2d245..38d5ba8 100644 --- a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile +++ b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile @@ -8,7 +8,7 @@ PY = python2.7 DEFS = defs-errno defs-signal defs-sc defs-madv defs-siginfo defs-siginfo1 defs-sa defs-mman defs-fcntl defs-sig -all: Libc.txt ${DEFS} +all: Libc.txt ${DEFS} strerrnocase.txt Libc.txt: Libc.txt.templ ${DEFS} sizeofs ${PY} ./untempl.py Libc.txt.templ ${.TARGET} @@ -63,5 +63,11 @@ defs-siginfo1: ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h | grep SEGV_ >> ${.TARGET} ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h | grep BUS_ >> ${.TARGET} +dumpstrerrno.c: defs-errno + grep -v ERESTART ${.ALLSRC} | grep -v EJUSTRETURN | ./mkdumpstrerrno.py > ${.TARGET} + +strerrnocase.txt: dumpstrerrno + ./dumpstrerrno | ./mkstrerrnocase.py > ${.TARGET} + clean: - rm -f sizeofs ${DEFS} Libc.txt + rm -f sizeofs ${DEFS} Libc.txt dumpstrerrno dumpstrerrno.c strerrnocase.txt diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py new file mode 100755 index 0000000..fdefe88 --- /dev/null +++ b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py @@ -0,0 +1,32 @@ +#! /usr/bin/env python2.7 + +import sys + +def main (): + r = [] + while True: + line = sys.stdin.readline() + if line == '': + break + s = line.split()[0][:-1] + r.append("\tD(\"%s\", %s)" % (s, s)) + + print """/* this file was generated automatically */ + +#include +#include + +static void D (const char *s, int e) +{ + printf("%%s, %%s\\n", s, strerror(e)); +} + +int main (int argc, const char *argv[]) +{ +%s; + + return 0; +}""" % (';\n'.join(r),) + +if __name__ == '__main__': + main() diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py new file mode 100755 index 0000000..4059ecf --- /dev/null +++ b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py @@ -0,0 +1,17 @@ +#! /usr/bin/env python2.7 + +import sys, string + +MOD = 'Libc' + +def main (): + while True: + line = sys.stdin.readline() + if line == '': + break + code, s = string.split(line.rstrip(), ', ', maxsplit=1) + s1 = s[0].lower() + s[1:] + print '| %s.%s: s := "%s, %s"' % (MOD, code, code, s1) + +if __name__ == '__main__': + main() -- 2.29.2