comparison src/mk-errno-list @ 5494:73a87a677257

[project @ 2005-10-14 07:29:20 by jwe]
author jwe
date Fri, 14 Oct 2005 07:29:20 +0000
parents
children 4270ded9ddc6
comparison
equal deleted inserted replaced
5493:b2e882e8b68b 5494:73a87a677257
1 #! /bin/sh
2
3 if [ $# -ne 2 ]; then
4 echo "usage: get-errno-list [--perl PERL|--python PYTHON]" 1>&2
5 exit 1
6 fi
7
8 if [ $1 = "--perl" ]; then
9 PERL="$2";
10 $PERL -e 'foreach $key (keys(%!)) {
11 $x .= "#if defined ($key)\n { \"$key\", $key, },\n#endif\n";
12 }
13 while (<>) {
14 s/^ *\@SYSDEP_ERRNO_LIST\@/$ x/;
15 print;
16 }'
17
18 elif [ $1 = "--python" ]; then
19 PYTHON="$2";
20 $PYTHON -c '
21 from errno import errorcode
22 from sys import stdin
23
24 t = "#if defined (%s)\n { \"%s\", %s, },\n#endif\n"
25 errstr = ""
26 for k in errorcode.keys():
27 errstr += t % tuple(3*[errorcode[k]])
28
29 for l in stdin:
30 print l.replace("@SYSDEP_ERRNO_LIST@", errstr),
31 '
32 fi
33
34 exit $?