This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Metaconfig changes for #8120.
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 15 Dec 2000 02:50:00 +0000 (02:50 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 15 Dec 2000 02:50:00 +0000 (02:50 +0000)
p4raw-id: //depot/metaconfig@8121

U/modified/d_strtoul.U [new file with mode: 0644]
U/perl/d_strtoull.U
U/perl/d_strtouq.U

diff --git a/U/modified/d_strtoul.U b/U/modified/d_strtoul.U
new file mode 100644 (file)
index 0000000..f7e6717
--- /dev/null
@@ -0,0 +1,104 @@
+?RCS: $Id: d_strtoul.U,v 3.0.1.1 1997/02/28 15:46:43 ram Exp $
+?RCS:
+?RCS: Copyright (c) 1996, Andy Dougherty
+?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_strtoul.U,v $
+?RCS: Revision 3.0.1.1  1997/02/28  15:46:43  ram
+?RCS: patch61: created
+?RCS:
+?RCS:
+?MAKE:d_strtoul: Inlibc cat longsize Compile
+?MAKE: -pick add $@ %<
+?S:d_strtoul:
+?S:    This variable conditionally defines the HAS_STRTOUL symbol, which
+?S:    indicates to the C program that the strtoul() routine is available
+?S:    to provide conversion of strings to unsigned long.
+?S:.
+?C:HAS_STRTOUL (STRTOUL):
+?C:    This symbol, if defined, indicates that the strtoul routine is
+?C:    available to provide conversion of strings to unsigned long.
+?C:.
+?H:#$d_strtoul HAS_STRTOUL     /**/
+?H:.
+?F:!try
+?LINT:set d_strtoul
+: see if strtoul exists
+set strtoul d_strtoul
+eval $inlibc
+
+case "$d_strtoul" in
+"$define")
+       $cat <<EOM
+Checking whether your strtoul() works okay...
+EOM
+       $cat >try.c <<'EOCP'
+#include <errno.h>
+#include <stdio.h>
+extern unsigned long int strtoul(char *s, char **, int); 
+static int bad = 0;
+void check(char *s, unsigned long eul, int een) {
+       unsigned long gul;
+       errno = 0;
+       gul = strtoul(s, 0, 10);
+       if (!((gul == eul) && (errno == een)))
+               bad++;
+}
+int main() {
+       check(" 1", 1L, 0);
+       check(" 0", 0L, 0);
+EOCP
+       case "$longsize" in
+       8)
+           $cat >>try.c <<'EOCP'
+       check("18446744073709551615", 18446744073709551615ULL, 0);
+       check("18446744073709551616", 18446744073709551615ULL, ERANGE);
+       check("-1", 18446744073709551615ULL, 0);
+       check("-18446744073709551614", 2, 0);
+       check("-18446744073709551615", 1, 0);
+               check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
+       check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
+EOCP
+               ;;
+       4)
+                   $cat >>try.c <<'EOCP'
+       check("4294967295", 4294967295UL, 0);
+       check("4294967296", 4294967295UL, ERANGE);
+       check("-1", 4294967295UL, 0);
+       check("-4294967294", 2, 0);
+       check("-4294967295", 1, 0);
+               check("-4294967296", 4294967295UL, ERANGE);
+       check("-4294967297", 4294967295UL, ERANGE);
+EOCP
+               ;;
+       *)
+: Should we write these tests to be more portable by sprintf-ing
+: ~0 and then manipulating that char string as input for strtol?
+               ;;
+       esac
+       $cat >>try.c <<'EOCP'
+       if (!bad)
+               printf("ok\n");
+       return 0;
+}
+EOCP
+       set try
+       if eval $compile; then
+               case "`./try`" in
+               ok) echo "Your strtoul() seems to be working okay." ;;
+               *) cat <<EOM >&4
+Your strtoul() doesn't seem to be working okay.
+EOM
+                  d_strtoul="$undef"
+                  ;;
+               esac
+       fi
+       ;;
+esac
+
index 2b5ad64..38b7cc8 100644 (file)
@@ -44,10 +44,15 @@ int check(char *s, long long eull, int een) {
                bad++;
 }
 int main() {
-       check(" 1",                                       1LL, 0);
-       check(" 0",                                       0LL, 0);
-       check("18446744073709551615", 18446744073709551615ULL, 0);
-       check("18446744073709551616", 18446744073709551615ULL, ERANGE);
+       check(" 1",                                        1LL, 0);
+       check(" 0",                                        0LL, 0);
+       check("18446744073709551615",  18446744073709551615ULL, 0);
+       check("18446744073709551616",  18446744073709551615ULL, ERANGE);
+       check("-1",                    18446744073709551615ULL, 0);
+       check("-18446744073709551614",                     2LL, 0);
+       check("-18446744073709551615",                     1LL, 0);
+               check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
+       check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
        if (!bad)
                printf("ok\n");
 }
index 4c251b4..c2dff27 100644 (file)
@@ -5,7 +5,7 @@
 ?RCS: You may distribute under the terms of either the GNU General Public
 ?RCS: License or the Artistic License, as specified in the README file.
 ?RCS:
-?MAKE:d_strtouq: Inlibc
+?MAKE:d_strtouq: Inlibc cat Compile
 ?MAKE: -pick add $@ %<
 ?S:d_strtouq:
 ?S:    This variable conditionally defines the HAS_STRTOUQ symbol, which
 ?C:.
 ?H:#$d_strtouq HAS_STRTOUQ             /**/
 ?H:.
+?F:!try
 ?LINT:set d_strtouq
 : see if strtouq exists
 set strtouq d_strtouq
 eval $inlibc
 
+case "$d_strtouq" in
+"$define")
+       $cat <<EOM
+Checking whether your strtouq() works okay...
+EOM
+       $cat >try.c <<'EOCP'
+#include <errno.h>
+#include <stdio.h>
+extern unsigned long long int strtouq(char *s, char **, int); 
+static int bad = 0;
+void check(char *s, unsigned long long eull, int een) {
+       unsigned long long gull;
+       errno = 0;
+       gull = strtouq(s, 0, 10);
+       if (!((gull == eull) && (errno == een)))
+               bad++;
+}
+int main() {
+       check(" 1",                                        1LL, 0);
+       check(" 0",                                        0LL, 0);
+       check("18446744073709551615",  18446744073709551615ULL, 0);
+       check("18446744073709551616",  18446744073709551615ULL, ERANGE);
+       check("-1",                    18446744073709551615ULL, 0);
+       check("-18446744073709551614",                     2LL, 0);
+       check("-18446744073709551615",                     1LL, 0);
+               check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
+       check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
+       if (!bad)
+               printf("ok\n");
+       return 0;
+}
+EOCP
+       set try
+       if eval $compile; then
+               case "`./try`" in
+               ok) echo "Your strtouq() seems to be working okay." ;;
+               *) cat <<EOM >&4
+Your strtouq() doesn't seem to be working okay.
+EOM
+                  d_strtouq="$undef"
+                  ;;
+               esac
+       fi
+       ;;
+esac
+