[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r1169 - in /fsf/trunk/libc: ./ nptl/ nptl/sysdeps/unix/sysv/linux/x86_64/ stdlib/



Author: eglibc
Date: Fri Jan 12 00:01:48 2007
New Revision: 1169

Log:
Import glibc-mainline for 2007-01-12

Added:
    fsf/trunk/libc/stdlib/tst-strtod4.c
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/nptl/ChangeLog
    fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
    fsf/trunk/libc/stdlib/Makefile
    fsf/trunk/libc/stdlib/strtod_l.c
    fsf/trunk/libc/stdlib/tst-makecontext.c
    fsf/trunk/libc/stdlib/tst-strtod2.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Fri Jan 12 00:01:48 2007
@@ -1,3 +1,22 @@
+2007-01-05  Steven Munroe  <sjmunroe@xxxxxxxxxx>
+
+	* stdlib/tst-makecontext.c: Include errno.h.  Change main()
+	to do_test().  Define TEST_FUNCTION. Include test-skeleton.c.
+	(do_test): Check errno and exit(0) if ENOSYS.
+
+2007-01-11  Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix handling of multi-byte
+	thousands separators.
+	* stdlib/Makefile: Add rules to build and run tst-strtod4.
+	* stdlib/tst-strtod4.c: New test.
+
+	[BZ #3855]
+	* stdlib/strtod_l.c (____STRTOF_INTERNAL): 0x. not followed by
+	hexadecimal digit should accept just the initial 0.
+	* stdlib/tst-strtod2.c (tests): New variable.
+	(do_test): Run several tests rather than just one.
+
 2007-01-11  Jakub Jelinek  <jakub@xxxxxxxxxx>
 
 	* sysdeps/i386/soft-fp/sfp-machine.h: Remove.

Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Fri Jan 12 00:01:48 2007
@@ -1,3 +1,9 @@
+2007-01-11  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+	(lll_futex_timed_wait): Undo part of last change, don't negate
+	return value.
+
 2007-01-10  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Cleanups.  Define

Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h Fri Jan 12 00:01:48 2007
@@ -172,7 +172,7 @@
 		      : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT),	      \
 		        "d" (_val), "r" (__to)				      \
 		      : "memory", "cc", "r11", "cx");			      \
-    -__status;								      \
+    __status;								      \
   })
 
 

Modified: fsf/trunk/libc/stdlib/Makefile
==============================================================================
--- fsf/trunk/libc/stdlib/Makefile (original)
+++ fsf/trunk/libc/stdlib/Makefile Fri Jan 12 00:01:48 2007
@@ -68,7 +68,7 @@
 		   tst-limits tst-rand48 bug-strtod tst-setcontext	    \
 		   test-a64l tst-qsort tst-system testmb2 bug-strtod2	    \
 		   tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \
-		   tst-makecontext
+		   tst-makecontext tst-strtod4
 
 include ../Makeconfig
 
@@ -114,6 +114,7 @@
 
 tst-strtod-ENV = LOCPATH=$(common-objpfx)localedata
 tst-strtod3-ENV = LOCPATH=$(common-objpfx)localedata
+tst-strtod4-ENV = LOCPATH=$(common-objpfx)localedata
 testmb2-ENV = LOCPATH=$(common-objpfx)localedata
 
 # Run a test on the header files we use.

Modified: fsf/trunk/libc/stdlib/strtod_l.c
==============================================================================
--- fsf/trunk/libc/stdlib/strtod_l.c (original)
+++ fsf/trunk/libc/stdlib/strtod_l.c Fri Jan 12 00:01:48 2007
@@ -1,5 +1,6 @@
 /* Convert string representing a number to float value, using given locale.
-   Copyright (C) 1997,1998,2002,2004,2005,2006 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,2002,2004,2005,2006,2007
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1997.
 
@@ -650,10 +651,11 @@
 	  if (c != '0')
 	    {
 	      for (cnt = 0; thousands[cnt] != '\0'; ++cnt)
-		if (c != thousands[cnt])
+		if (thousands[cnt] != cp[cnt])
 		  break;
 	      if (thousands[cnt] != '\0')
 		break;
+	      cp += cnt - 1;
 	    }
 	  c = *++cp;
 	}
@@ -665,14 +667,23 @@
   if (!((c >= L_('0') && c <= L_('9'))
 	|| (base == 16 && ((CHAR_TYPE) TOLOWER (c) >= L_('a')
 			   && (CHAR_TYPE) TOLOWER (c) <= L_('f')))
+	|| (
 #ifdef USE_WIDE_CHAR
-	|| c == (wint_t) decimal
+	    c == (wint_t) decimal
 #else
-	|| ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt)
-	      if (decimal[cnt] != cp[cnt])
-		break;
-	      decimal[cnt] == '\0'; })
-#endif
+	    ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt)
+		 if (decimal[cnt] != cp[cnt])
+		   break;
+	       decimal[cnt] == '\0'; })
+#endif
+	    /* '0x.' alone is not a valid hexadecimal number.
+	       '.' alone is not valid either, but that has been checked
+	       already earlier.  */
+	    && (base != 16
+		|| cp != start_of_digits
+		|| (cp[decimal_len] >= L_('0') && cp[decimal_len] <= L_('9'))
+		|| ((CHAR_TYPE) TOLOWER (cp[decimal_len]) >= L_('a')
+		    && (CHAR_TYPE) TOLOWER (cp[decimal_len]) <= L_('f'))))
 	|| (base == 16 && (cp != start_of_digits
 			   && (CHAR_TYPE) TOLOWER (c) == L_('p')))
 	|| (base != 16 && (CHAR_TYPE) TOLOWER (c) == L_('e'))))
@@ -715,6 +726,7 @@
 		  break;
 	      if (thousands[cnt] != '\0')
 		break;
+	      cp += cnt - 1;
 	    }
 #endif
 	}

Modified: fsf/trunk/libc/stdlib/tst-makecontext.c
==============================================================================
--- fsf/trunk/libc/stdlib/tst-makecontext.c (original)
+++ fsf/trunk/libc/stdlib/tst-makecontext.c Fri Jan 12 00:01:48 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2007 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
@@ -16,6 +16,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <ucontext.h>
@@ -36,10 +37,16 @@
 }
 
 int
-main (void)
+do_test (void)
 {
   if (getcontext (&ucp) != 0)
     {
+      if (errno == ENOSYS)
+	{
+	  puts ("context handling not supported");
+	  return 0;
+	}
+
       puts ("getcontext failed");
       return 1;
     }
@@ -47,7 +54,7 @@
   ucp.uc_link = NULL;
   ucp.uc_stack.ss_sp = st1;
   ucp.uc_stack.ss_size = sizeof st1;
-  makecontext (&ucp, (void (*) ()) cf, 1, 78);
+  makecontext (&ucp, (void (*) (void)) cf, 1, 78);
   if (setcontext (&ucp) != 0)
     {
       puts ("setcontext failed");
@@ -55,3 +62,6 @@
     }
   return 2;
 }
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Modified: fsf/trunk/libc/stdlib/tst-strtod2.c
==============================================================================
--- fsf/trunk/libc/stdlib/tst-strtod2.c (original)
+++ fsf/trunk/libc/stdlib/tst-strtod2.c Fri Jan 12 00:01:48 2007
@@ -1,22 +1,41 @@
 #include <stdio.h>
 #include <stdlib.h>
+
+struct test
+{
+  const char *str;
+  double result;
+  size_t offset;
+} tests[] =
+{
+  { "0xy", 0.0, 1 },
+  { "0x.y", 0.0, 1 },
+  { "0x0.y", 0.0, 4 },
+  { "0x.0y", 0.0, 4 },
+  { ".y", 0.0, 0 },
+  { "0.y", 0.0, 2 },
+  { ".0y", 0.0, 2 }
+};
 
 static int
 do_test (void)
 {
   int status = 0;
-  const char s[] = "0x";
-  char *ep;
-  double r = strtod (s, &ep);
-  if (r != 0)
+  for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
     {
-      printf ("r = %g, expect 0\n", r);
-      status = 1;
-    }
-  if (ep != s + 1)
-    {
-      printf ("strtod parsed %ju characters, expected 1\n", ep - s);
-      status = 1;
+      char *ep;
+      double r = strtod (tests[i].str, &ep);
+      if (r != tests[i].result)
+	{
+	  printf ("test %zu r = %g, expect %g\n", i, r, tests[i].result);
+	  status = 1;
+	}
+      if (ep != tests[i].str + tests[i].offset)
+	{
+	  printf ("test %zu strtod parsed %ju characters, expected %zu\n",
+		  i, ep - tests[i].str, tests[i].offset);
+	  status = 1;
+	}
     }
   return status;
 }

Added: fsf/trunk/libc/stdlib/tst-strtod4.c
==============================================================================
--- fsf/trunk/libc/stdlib/tst-strtod4.c (added)
+++ fsf/trunk/libc/stdlib/tst-strtod4.c Fri Jan 12 00:01:48 2007
@@ -1,0 +1,56 @@
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define NBSP "\xc2\xa0"
+
+static const struct
+{
+  const char *in;
+  const char *out;
+  double expected;
+} tests[] =
+  {
+    { "000"NBSP"000"NBSP"000", "", 0.0 },
+    { "1"NBSP"000"NBSP"000,5x", "x", 1000000.5 }
+  };
+#define NTESTS (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
+    {
+      puts ("could not set locale");
+      return 1;
+    }
+
+  int status = 0;
+
+  for (int i = 0; i < NTESTS; ++i)
+    {
+      char *ep;
+      double r = __strtod_internal (tests[i].in, &ep, 1);
+
+      if (strcmp (ep, tests[i].out) != 0)
+	{
+	  printf ("%d: got rest string \"%s\", expected \"%s\"\n",
+		  i, ep, tests[i].out);
+	  status = 1;
+	}
+
+      if (r != tests[i].expected)
+	{
+	  printf ("%d: got wrong results %g, expected %g\n",
+		  i, r, tests[i].expected);
+	  status = 1;
+	}
+    }
+
+  return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"