about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/exit.c14
-rw-r--r--stdlib/strtod.c18
-rw-r--r--stdlib/test-canon.c2
3 files changed, 22 insertions, 12 deletions
diff --git a/stdlib/exit.c b/stdlib/exit.c
index b5b85aa26e..1ed1e2521b 100644
--- a/stdlib/exit.c
+++ b/stdlib/exit.c
@@ -33,14 +33,16 @@ DEFINE_HOOK (__libc_atexit, (void))
 void
 exit (int status)
 {
-  const struct exit_function_list *l;
-
-  for (l = __exit_funcs; l != NULL; l = l->next)
+  /* We do it this way to handle recursive calls to exit () made by
+     the functions registered with `atexit' and `on_exit'. We call
+     everyone on the list and use the status value in the last
+     exit (). */
+  for (; __exit_funcs; __exit_funcs = __exit_funcs->next)
     {
-      size_t i = l->idx;
-      while (i-- > 0)
+      while ((__exit_funcs->idx)-- > 0)
 	{
-	  const struct exit_function *const f = &l->fns[i];
+	  const struct exit_function *const f =
+	    &__exit_funcs->fns[__exit_funcs->idx];
 	  switch (f->flavor)
 	    {
 	    case ef_free:
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index d35dc2d5ac..cd78ef0df4 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -712,10 +712,18 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
 		{
 	 	  FLOAT result;
 
-		  /* Overflow or underflow.  */
-		  __set_errno (ERANGE);
-		  result = (exp_negative ? 0.0 :
-			    negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL);
+		  /* We have to take care for special situation: a joker
+		     might have written "0.0e100000" which is in fact
+		     zero.  */
+		  if (lead_zero == -1)
+		    result = negative ? -0.0 : 0.0;
+		  else
+		    {
+		      /* Overflow or underflow.  */
+		      __set_errno (ERANGE);
+		      result = (exp_negative ? 0.0 :
+				negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL);
+		    }
 
 		  /* Accept all following digits as part of the exponent.  */
 		  do
@@ -756,7 +764,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
     *endptr = (STRING_TYPE *) cp;
 
   if (dig_no == 0)
-    return 0.0;
+    return negative ? -0.0 : 0.0;
 
   if (lead_zero)
     {
diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c
index c239d50ae8..d06ec4d581 100644
--- a/stdlib/test-canon.c
+++ b/stdlib/test-canon.c
@@ -136,7 +136,7 @@ main (int argc, char ** argv)
   errno = 0;
   if (realpath ("", buf) != NULL || errno != ENOENT)
     {
-      printf ("%s: expected return value NULL and set errno to ENOENT",
+      printf ("%s: expected return value NULL and set errno to ENOENT"
 	      " for realpath(\"\",...)\n", argv[0]);
       ++errors;
     }