This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / d_strerror.U
1 ?RCS: $Id: d_strerror.U 1 2006-08-24 12:32:52Z rmanfredi $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
10 ?RCS:
11 ?RCS: $Log: d_strerror.U,v $
12 ?RCS: Revision 3.0.1.3  1994/05/13  15:20:27  ram
13 ?RCS: patch27: now uses new macro support for cleaner Strerror def
14 ?RCS:
15 ?RCS: Revision 3.0.1.2  1994/05/06  14:58:26  ram
16 ?RCS: patch23: renamed strerror into Strerror to protect name space (ADO)
17 ?RCS:
18 ?RCS: Revision 3.0.1.1  1994/01/24  14:08:56  ram
19 ?RCS: patch16: protected code looking for sys_errnolist[] with @if
20 ?RCS: patch16: added default value for d_sysernlst
21 ?RCS:
22 ?RCS: Revision 3.0  1993/08/18  12:07:35  ram
23 ?RCS: Baseline for dist 3.0 netwide release.
24 ?RCS:
25 ?MAKE:d_strerror d_syserrlst d_sysernlst d_strerrm: contains Csym Findhdr
26 ?MAKE:  -pick add $@ %<
27 ?S:d_strerror:
28 ?S:     This variable conditionally defines HAS_STRERROR if strerror() is
29 ?S:     available to translate error numbers to strings.
30 ?S:.
31 ?S:d_syserrlst:
32 ?S:     This variable conditionally defines HAS_SYS_ERRLIST if sys_errlist[] is
33 ?S:     available to translate error numbers to strings.
34 ?S:.
35 ?S:d_sysernlst:
36 ?S:     This variable conditionally defines HAS_SYS_ERRNOLIST if sys_errnolist[]
37 ?S:     is available to translate error numbers to the symbolic name.
38 ?S:.
39 ?S:d_strerrm:
40 ?S:     This variable holds what Strerrr is defined as to translate an error
41 ?S:     code condition into an error message string. It could be 'strerror'
42 ?S:     or a more complex macro emulating strrror with sys_errlist[], or the
43 ?S:     "unknown" string when both strerror and sys_errlist are missing.
44 ?S:.
45 ?C:HAS_STRERROR (STRERROR):
46 ?C:     This symbol, if defined, indicates that the strerror routine is
47 ?C:     available to translate error numbers to strings. See the writeup
48 ?C:     of Strerror() in this file before you try to define your own.
49 ?C:.
50 ?C:HAS_SYS_ERRLIST (SYSERRLIST):
51 ?C:     This symbol, if defined, indicates that the sys_errlist array is
52 ?C:     available to translate error numbers to strings. The extern int
53 ?C:     sys_nerr gives the size of that table.
54 ?C:.
55 ?C:HAS_SYS_ERRNOLIST (SYSERRNOLIST):
56 ?C:     This symbol, if defined, indicates that the sys_errnolist array is
57 ?C:     available to translate an errno code into its symbolic name (e.g.
58 ?C: ENOENT). The extern int sys_nerrno gives the size of that table.
59 ?C:.
60 ?C:Strerror:
61 ?C:     This preprocessor symbol is defined as a macro if strerror() is
62 ?C:     not available to translate error numbers to strings but sys_errlist[]
63 ?C:     array is there.
64 ?C:.
65 ?H:#$d_strerror HAS_STRERROR            /**/
66 ?H:#$d_syserrlst HAS_SYS_ERRLIST        /**/
67 ?H:#$d_sysernlst HAS_SYS_ERRNOLIST      /**/
68 ?H:#define Strerror(e) $d_strerrm
69 ?H:.
70 ?D:d_sysernlst=''
71 ?T:xxx val
72 : see if strerror and/or sys_errlist[] exist
73 echo " "
74 if set strerror val -f d_strerror; eval $csym; $val; then
75         echo 'strerror() found.' >&4
76         d_strerror="$define"
77         d_strerrm='strerror(e)'
78         if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
79                 echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
80                 d_syserrlst="$define"
81         else
82         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
83                 d_syserrlst="$undef"
84         fi
85 elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
86         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
87         echo 'strerror() found in string header.' >&4
88         d_strerror="$define"
89         d_strerrm='strerror(e)'
90         if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
91                 echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
92                 d_syserrlst="$define"
93         else
94                 echo "(You don't appear to have any sys_errlist[], how can this be?)"
95                 d_syserrlst="$undef"
96         fi
97 elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
98 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
99         d_strerror="$undef"
100         d_syserrlst="$define"
101         d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
102 else
103         echo 'strerror() and sys_errlist[] NOT found.' >&4
104         d_strerror="$undef"
105         d_syserrlst="$undef"
106         d_strerrm='"unknown"'
107 fi
108 @if d_sysernlst || HAS_SYS_ERRNOLIST
109 if set sys_errnolist val -a d_sysernlst; eval $csym; $val; then
110         echo "(Symbolic error codes can be fetched via the sys_errnolist[] array.)"
111         d_sysernlst="$define"
112 else
113         echo "(However, I can't extract the symbolic error code out of errno.)"
114         d_sysernlst="$undef"
115 fi
116 @end
117