view src/mk-errno-list @ 5540:cda6a105ae9a before-ov-branch

[project @ 2005-11-17 05:47:13 by jwe]
author jwe
date Thu, 17 Nov 2005 05:47:13 +0000
parents 73a87a677257
children 4270ded9ddc6
line wrap: on
line source

#! /bin/sh

if [ $# -ne 2 ]; then
  echo "usage: get-errno-list [--perl PERL|--python PYTHON]" 1>&2
  exit 1
fi

if [ $1 = "--perl" ]; then
  PERL="$2";
  $PERL -e 'foreach $key (keys(%!)) {
    $x .= "#if defined ($key)\n    { \"$key\", $key, },\n#endif\n";
  }
  while (<>) {
    s/^ *\@SYSDEP_ERRNO_LIST\@/$ x/;
    print;
  }'

elif [ $1 = "--python" ]; then
  PYTHON="$2";
  $PYTHON -c '
from errno import errorcode
from sys import stdin

t = "#if defined (%s)\n    { \"%s\", %s, },\n#endif\n"
errstr = ""
for k in errorcode.keys():
    errstr += t % tuple(3*[errorcode[k]])

for l in stdin:
    print l.replace("@SYSDEP_ERRNO_LIST@", errstr),
'
fi

exit $?