1 ?RCS: $Id: d_strtoul.U,v 3.0.1.1 1997/02/28 15:46:43 ram Exp $
3 ?RCS: Copyright (c) 1996, Andy Dougherty
4 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
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.
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
17 ?MAKE:d_strtoul: Inlibc cat longsize Compile run
18 ?MAKE: -pick add $@ %<
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.
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.
28 ?H:#$d_strtoul HAS_STRTOUL /**/
31 : see if strtoul exists
38 Checking whether your strtoul() works okay...
43 extern unsigned long int strtoul(char *s, char **, int);
45 void check(char *s, unsigned long eul, int een) {
48 gul = strtoul(s, 0, 10);
49 if (!((gul == eul) && (errno == een)))
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);
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);
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?
95 if eval $compile; then
96 case "`$run ./try`" in
97 ok) echo "Your strtoul() seems to be working okay." ;;
99 Your strtoul() doesn't seem to be working okay.