diff options
author | otto <> | 2006-09-29 11:00:24 +0000 |
---|---|---|
committer | otto <> | 2006-09-29 11:00:24 +0000 |
commit | b111751208a94882547ae748c16e7978fa7226b6 (patch) | |
tree | 5da3321fe5d4c05cad86a57aa9910780f3e3b577 /src | |
parent | 3e7a96453995beff0dd6bfbefb9db0b02fbb7ef5 (diff) | |
download | openbsd-b111751208a94882547ae748c16e7978fa7226b6.tar.gz openbsd-b111751208a94882547ae748c16e7978fa7226b6.tar.bz2 openbsd-b111751208a94882547ae748c16e7978fa7226b6.zip |
add strtod() underflow test
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libc/Makefile | 4 | ||||
-rw-r--r-- | src/regress/lib/libc/strtod/Makefile | 5 | ||||
-rw-r--r-- | src/regress/lib/libc/strtod/strtodtest.c | 22 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile index a6d3d766b1..04970c7e16 100644 --- a/src/regress/lib/libc/Makefile +++ b/src/regress/lib/libc/Makefile | |||
@@ -1,9 +1,9 @@ | |||
1 | # $OpenBSD: Makefile,v 1.23 2006/03/25 20:28:19 otto Exp $ | 1 | # $OpenBSD: Makefile,v 1.24 2006/09/29 11:00:24 otto Exp $ |
2 | 2 | ||
3 | SUBDIR+= _setjmp alloca atexit db getaddrinfo getcap getopt_long hsearch longjmp | 3 | SUBDIR+= _setjmp alloca atexit db getaddrinfo getcap getopt_long hsearch longjmp |
4 | SUBDIR+= locale malloc | 4 | SUBDIR+= locale malloc |
5 | SUBDIR+= netdb popen regex setjmp setjmp-signal sigreturn sigsetjmp | 5 | SUBDIR+= netdb popen regex setjmp setjmp-signal sigreturn sigsetjmp |
6 | SUBDIR+= sprintf strerror strtonum telldir time vis | 6 | SUBDIR+= sprintf strerror strtod strtonum telldir time vis |
7 | 7 | ||
8 | .if (${MACHINE_ARCH} != "vax") | 8 | .if (${MACHINE_ARCH} != "vax") |
9 | SUBDIR+= ieeefp | 9 | SUBDIR+= ieeefp |
diff --git a/src/regress/lib/libc/strtod/Makefile b/src/regress/lib/libc/strtod/Makefile new file mode 100644 index 0000000000..030c0e7f56 --- /dev/null +++ b/src/regress/lib/libc/strtod/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2006/09/29 11:00:24 otto Exp $ | ||
2 | |||
3 | PROG= strtodtest | ||
4 | |||
5 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/strtod/strtodtest.c b/src/regress/lib/libc/strtod/strtodtest.c new file mode 100644 index 0000000000..0291365a75 --- /dev/null +++ b/src/regress/lib/libc/strtod/strtodtest.c | |||
@@ -0,0 +1,22 @@ | |||
1 | /* $OpenBSD: strtodtest.c,v 1.1 2006/09/29 11:00:24 otto Exp $ */ | ||
2 | /* Public domain, Otto Moerbeek <otto@drijf.net>, 2006. */ | ||
3 | |||
4 | #include <stdio.h> | ||
5 | #include <stdlib.h> | ||
6 | #include <errno.h> | ||
7 | |||
8 | /* | ||
9 | * Checks if strtod() reports underflow. | ||
10 | */ | ||
11 | |||
12 | int | ||
13 | main() | ||
14 | { | ||
15 | char *tmp="0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"; | ||
16 | double d; | ||
17 | |||
18 | d = strtod(tmp, NULL); | ||
19 | if (errno != ERANGE) | ||
20 | errx(1, "errno = %d", errno); | ||
21 | return (0); | ||
22 | } | ||