Przeglądaj źródła

errno to string CASE generator added

Alexander Shiryaev 12 lat temu
rodzic
commit
1643d7c0e9

+ 8 - 2
BlackBox/_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

+ 32 - 0
BlackBox/_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 <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()

+ 17 - 0
BlackBox/_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()