DEADSOFTWARE

OpenBSD errno to string CASE generator added
authorAlexander Shiryaev <aixp@mail.ru>
Wed, 14 Nov 2012 11:16:32 +0000 (15:16 +0400)
committerAlexander Shiryaev <aixp@mail.ru>
Wed, 14 Nov 2012 11:16:32 +0000 (15:16 +0400)
Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile
Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py [new file with mode: 0755]
Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py [new file with mode: 0755]

index eb2d2450bee2ad43473e6f06c6156784a753c822..38d5ba86388ea69015e4acd6eeb4bcab1864264a 100644 (file)
@@ -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 (executable)
index 0000000..fdefe88
--- /dev/null
@@ -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 <errno.h>
+#include <stdio.h>
+
+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 (executable)
index 0000000..4059ecf
--- /dev/null
@@ -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()