This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not.
[metaconfig.git] / U / modified / d_strtoul.U
1 ?RCS: $Id: d_strtoul.U,v 3.0.1.1 1997/02/28 15:46:43 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1996, Andy Dougherty
4 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
5 ?RCS: 
6 ?RCS: You may redistribute only under the terms of the Artistic Licence,
7 ?RCS: as specified in the README file that comes with the distribution.
8 ?RCS: You may reuse parts of this distribution only within the terms of
9 ?RCS: that same Artistic Licence; a copy of which may be found at the root
10 ?RCS: of the source tree for dist 3.0.
11 ?RCS:
12 ?RCS: $Log: d_strtoul.U,v $
13 ?RCS: Revision 3.0.1.1  1997/02/28  15:46:43  ram
14 ?RCS: patch61: created
15 ?RCS:
16 ?RCS:
17 ?MAKE:d_strtoul: Inlibc cat longsize Compile run
18 ?MAKE:  -pick add $@ %<
19 ?S:d_strtoul:
20 ?S:     This variable conditionally defines the HAS_STRTOUL symbol, which
21 ?S:     indicates to the C program that the strtoul() routine is available
22 ?S:     to provide conversion of strings to unsigned long.
23 ?S:.
24 ?C:HAS_STRTOUL (STRTOUL):
25 ?C:     This symbol, if defined, indicates that the strtoul routine is
26 ?C:     available to provide conversion of strings to unsigned long.
27 ?C:.
28 ?H:#$d_strtoul HAS_STRTOUL      /**/
29 ?H:.
30 ?LINT:set d_strtoul
31 : see if strtoul exists
32 set strtoul d_strtoul
33 eval $inlibc
34
35 case "$d_strtoul" in
36 "$define")
37         $cat <<EOM
38 Checking whether your strtoul() works okay...
39 EOM
40         $cat >try.c <<'EOCP'
41 #include <errno.h>
42 #include <stdio.h>
43 extern unsigned long int strtoul(char *s, char **, int); 
44 static int bad = 0;
45 void check(char *s, unsigned long eul, int een) {
46         unsigned long gul;
47         errno = 0;
48         gul = strtoul(s, 0, 10);
49         if (!((gul == eul) && (errno == een)))
50                 bad++;
51 }
52 int main() {
53         check(" 1", 1L, 0);
54         check(" 0", 0L, 0);
55 EOCP
56         case "$longsize" in
57         8)
58             $cat >>try.c <<'EOCP'
59         check("18446744073709551615", 18446744073709551615UL, 0);
60         check("18446744073709551616", 18446744073709551615UL, ERANGE);
61 #if 0 /* strtoul() for /^-/ strings is undefined. */
62         check("-1", 18446744073709551615UL, 0);
63         check("-18446744073709551614", 2, 0);
64         check("-18446744073709551615", 1, 0);
65         check("-18446744073709551616", 18446744073709551615UL, ERANGE);
66         check("-18446744073709551617", 18446744073709551615UL, ERANGE);
67 #endif
68 EOCP
69                 ;;
70         4)
71                     $cat >>try.c <<'EOCP'
72         check("4294967295", 4294967295UL, 0);
73         check("4294967296", 4294967295UL, ERANGE);
74 #if 0 /* strtoul() for /^-/ strings is undefined. */
75         check("-1", 4294967295UL, 0);
76         check("-4294967294", 2, 0);
77         check("-4294967295", 1, 0);
78         check("-4294967296", 4294967295UL, ERANGE);
79         check("-4294967297", 4294967295UL, ERANGE);
80 #endif
81 EOCP
82                 ;;
83         *)
84 : Should we write these tests to be more portable by sprintf-ing
85 : ~0 and then manipulating that char string as input for strtol?
86                 ;;
87         esac
88         $cat >>try.c <<'EOCP'
89         if (!bad)
90                 printf("ok\n");
91         return 0;
92 }
93 EOCP
94         set try
95         if eval $compile; then
96                 case "`$run ./try`" in
97                 ok) echo "Your strtoul() seems to be working okay." ;;
98                 *) cat <<EOM >&4
99 Your strtoul() doesn't seem to be working okay.
100 EOM
101                    d_strtoul="$undef"
102                    ;;
103                 esac
104         fi
105         ;;
106 esac
107