This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix bz#9696: errno value of strtod


Here's a patch to fix strtod, it returned EDOM instead of ERANGE for 
underflow,

Andreas

2011-07-05  Andreas Jaeger  <aj@suse.de>

	[BZ#9696]
	* stdlib/strtod_l.c (round_and_return): Return ERANGE instead of
	EDOM.
	* stdlib/tst-strtod.c: Add testcase.


-- 
 Andreas Jaeger, Program Manager openSUSE
  aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
   SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
    GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
     GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126
diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index 537d1fb..b3380fd 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -1,5 +1,5 @@
 /* Convert string representing a number to float value, using given locale.
-   Copyright (C) 1997,1998,2002,2004,2005,2006,2007,2008,2009,2010
+   Copyright (C) 1997,1998,2002,2004,2005,2006,2007,2008,2009,2010,2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -185,7 +185,7 @@ round_and_return (mp_limb_t *retval, int exponent, int negative,
 
       if (shift > MANT_DIG)
 	{
-	  __set_errno (EDOM);
+	  __set_errno (ERANGE);
 	  return 0.0;
 	}
 
diff --git a/stdlib/tst-strtod.c b/stdlib/tst-strtod.c
index c30eb1e..1cb9a5c 100644
--- a/stdlib/tst-strtod.c
+++ b/stdlib/tst-strtod.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1996-2001,2003,2009 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1996-2001,2003,2009,2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -72,6 +72,7 @@ static const struct ltest tests[] =
     { "+InFiNiTy", HUGE_VAL, '\0', 0 },
 #endif
     { "0x80000Ap-23", 0x80000Ap-23, '\0', 0 },
+    { "1e-324", 0, '\0', ERANGE },
     { NULL, 0, '\0', 0 }
   };
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]