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