about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/strtol.c9
-rw-r--r--stdlib/tst-strtol.c8
2 files changed, 7 insertions, 10 deletions
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index 5a097b40a4..396e2ecd74 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -1,5 +1,5 @@
 /* strtol - Convert string representation of a number into an integer value.
-   Copyright (C) 1991, 92, 94, 95, 96 Free Software Foundation, Inc.
+   Copyright (C) 1991, 92, 94, 95, 96, 97 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
@@ -217,13 +217,8 @@ INTERNAL (strtol) (nptr, endptr, base, group)
   /* Check for a sign.  */
   if (*s == L_('-'))
     {
-#if UNSIGNED
-      __set_errno (EINVAL);
-      return 0;
-#else
       negative = 1;
       ++s;
-#endif
     }
   else if (*s == L_('+'))
     {
@@ -317,6 +312,8 @@ INTERNAL (strtol) (nptr, endptr, base, group)
 	      ? -((unsigned LONG int) (LONG_MIN + 1)) + 1
 	      : (unsigned LONG int) LONG_MAX))
     overflow = 1;
+#else
+  overflow |= negative;
 #endif
 
   if (overflow)
diff --git a/stdlib/tst-strtol.c b/stdlib/tst-strtol.c
index 58878f236e..1d398b4558 100644
--- a/stdlib/tst-strtol.c
+++ b/stdlib/tst-strtol.c
@@ -37,8 +37,8 @@ static const struct ltest tests[] =
     { "  0",		0,		0,	0,	0 },
     { "0xffffffffg",	0xffffffff,	0,	'g',	0 },
     { "0xf1f2f3f4f5",	0xffffffff,	0,	0,	ERANGE },
-    { "-0x123456789",	0,		0,	0,	EINVAL },
-    { "-0xfedcba98",	0,		0,	0,	EINVAL },
+    { "-0x123456789",	0xffffffff,	0,	0,	ERANGE },
+    { "-0xfedcba98",	0xffffffff,	0,	0,	ERANGE },
     { NULL,		0,		0,	0,	0 },
 #else
     /* assume 64 bit long... */
@@ -65,8 +65,8 @@ static const struct ltest tests[] =
     { "0xffffffffg",	0xffffffff,	0,	'g',	0 },
     { "0xffffffffffffffffg",	0xffffffffffffffff,	0,	'g',	0 },
     { "0xf1f2f3f4f5f6f7f8f9",	0xffffffffffffffff,	0,	0,	ERANGE },
-    { "-0x123456789abcdef01",	0,			0,	0,	EINVAL },
-    { "-0xfedcba987654321",	0,			0,	0,	EINVAL },
+    { "-0x123456789abcdef01",	0xffffffffffffffff,	0,	0,	ERANGE },
+    { "-0xfedcba987654321",	0xffffffffffffffff,	0,	0,	ERANGE },
     { NULL,		0,		0,	0,	0 },
 #endif
   };