5494
|
1 #! /bin/sh |
7019
|
2 # |
|
3 # Copyright (C) 2005, 2007 John W. Eaton |
|
4 # |
|
5 # This file is part of Octave. |
|
6 # |
|
7 # Octave is free software; you can redistribute it and/or modify it |
|
8 # under the terms of the GNU General Public License as published by the |
|
9 # Free Software Foundation; either version 3 of the License, or (at |
|
10 # your option) any later version. |
|
11 # |
|
12 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 # for more details. |
|
16 # |
|
17 # You should have received a copy of the GNU General Public License |
|
18 # along with Octave; see the file COPYING. If not, see |
|
19 # <http://www.gnu.org/licenses/>. |
5494
|
20 |
|
21 if [ $# -ne 2 ]; then |
|
22 echo "usage: get-errno-list [--perl PERL|--python PYTHON]" 1>&2 |
|
23 exit 1 |
|
24 fi |
|
25 |
|
26 if [ $1 = "--perl" ]; then |
|
27 PERL="$2"; |
|
28 $PERL -e 'foreach $key (keys(%!)) { |
|
29 $x .= "#if defined ($key)\n { \"$key\", $key, },\n#endif\n"; |
|
30 } |
|
31 while (<>) { |
|
32 s/^ *\@SYSDEP_ERRNO_LIST\@/$ x/; |
|
33 print; |
|
34 }' |
|
35 |
|
36 elif [ $1 = "--python" ]; then |
|
37 PYTHON="$2"; |
|
38 $PYTHON -c ' |
|
39 from errno import errorcode |
|
40 from sys import stdin |
|
41 |
|
42 t = "#if defined (%s)\n { \"%s\", %s, },\n#endif\n" |
|
43 errstr = "" |
|
44 for k in errorcode.keys(): |
|
45 errstr += t % tuple(3*[errorcode[k]]) |
|
46 |
|
47 for l in stdin: |
|
48 print l.replace("@SYSDEP_ERRNO_LIST@", errstr), |
|
49 ' |
|
50 fi |
|
51 |
|
52 exit $? |