Mail Archives: djgpp-workers/2001/03/02/04:45:51
On Thu, 1 Mar 2001, Richard Dawe wrote:
> Eli Zaretskii wrote:
> [snip]
> > There's no rush; whenever you, or someone else have time, please test
> > that.
>
> I patched a copy of DJGPP CVS and ran the tests. The summary info is:
>
> Tested 63223 functions, 410 errors detected
That's what I see, too. I did zip up the CVS version and take it home,
yesterday evening. I first ran the unmodified libc, which showed 410
errors, saved away the 'results' file', and diff'ed it after modifying
strtol, strtoll, strtoul, strtoull and strtod, then deleting mtest.exe and
re-running 'make'. There were no changes at all to mtest.result by these
modifications. The result differs from all the 'standard' versions that
come with the CVS sources, but that's caused by compiler version
differences, I assume.
So here's the patch. I changed the whole strto*l family as described
yesterday. While being at it, I also made a somewhat related change to
strtod.c: it used explicit comparisons to ' ' and '\t' to check for
whitespace, instead of isspace().
--- src/libc/ansi/stdlib/strtol.c.orig Thu Mar 1 16:04:06 2001
+++ src/libc/ansi/stdlib/strtol.c Thu Mar 1 14:32:56 2001
@@ -9,9 +9,9 @@
long
strtol(const char *nptr, char **endptr, int base)
{
- const char *s = nptr;
+ const unsigned char *s = (const unsigned char *) nptr;
unsigned long acc;
- int c;
+ unsigned char c;
unsigned long cutoff;
int neg = 0, any, cutlim;
@@ -22,7 +22,7 @@ strtol(const char *nptr, char **endptr,
*/
do {
c = *s++;
- } while (isspace(c & 0xff));
+ } while (isspace(c));
if (c == '-')
{
neg = 1;
@@ -60,7 +60,7 @@ strtol(const char *nptr, char **endptr,
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
- for (acc = 0, any = 0, c &= 0xff;; c = *s++, c &= 0xff)
+ for (acc = 0, any = 0; ; c = *s++)
{
if (isdigit(c))
c -= '0';
--- src/libc/ansi/stdlib/strtoll.c.orig Thu Mar 1 14:27:46 2001
+++ src/libc/ansi/stdlib/strtoll.c Fri Mar 2 00:32:04 2001
@@ -10,9 +10,9 @@
long long
strtoll(const char *nptr, char **endptr, int base)
{
- const char *s = nptr;
+ const unsigned char *s = (const unsigned char *) nptr;
unsigned long long acc;
- int c;
+ unsigned char c;
unsigned long long cutoff;
int neg = 0, any, cutlim;
@@ -21,7 +21,7 @@ strtoll(const char *nptr, char **endptr,
*/
do {
c = *s++;
- } while (isspace(c & 0xff));
+ } while (isspace(c));
if (c == '-')
{
neg = 1;
@@ -48,7 +48,7 @@ strtoll(const char *nptr, char **endptr,
cutlim = 0;
cutoff++;
}
- for (acc = 0, any = 0, c &= 0xff;; c = *s++, c &= 0xff)
+ for (acc = 0, any = 0; ; c = *s++)
{
if (isdigit(c))
c -= '0';
--- src/libc/ansi/stdlib/strtoul.c.orig Thu Mar 1 14:27:46 2001
+++ src/libc/ansi/stdlib/strtoul.c Fri Mar 2 00:34:24 2001
@@ -15,9 +15,9 @@
unsigned long
strtoul(const char *nptr, char **endptr, int base)
{
- const char *s = nptr;
+ const unsigned char *s = (const unsigned char*) nptr;
unsigned long acc;
- int c;
+ unsigned char c;
unsigned long cutoff;
int neg = 0, any, cutlim;
@@ -26,7 +26,7 @@ strtoul(const char *nptr, char **endptr,
*/
do {
c = *s++;
- } while (isspace(c & 0xff));
+ } while (isspace(c));
if (c == '-')
{
neg = 1;
@@ -45,7 +45,7 @@ strtoul(const char *nptr, char **endptr,
base = c == '0' ? 8 : 10;
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
- for (acc = 0, any = 0, c &= 0xff;; c = *s++, c &= 0xff)
+ for (acc = 0, any = 0; ; c = *s++)
{
if (isdigit(c))
c -= '0';
--- src/libc/ansi/stdlib/strtoull.c.orig Thu Mar 1 14:27:46 2001
+++ src/libc/ansi/stdlib/strtoull.c Fri Mar 2 00:35:20 2001
@@ -16,9 +16,9 @@
unsigned long long
strtoull(const char *nptr, char **endptr, int base)
{
- const char *s = nptr;
+ const unsigned char *s = (const unsigned char*) nptr;
unsigned long long acc;
- int c;
+ unsigned char c;
unsigned long long cutoff;
int neg = 0, any, cutlim;
@@ -27,7 +27,7 @@ strtoull(const char *nptr, char **endptr
*/
do {
c = *s++;
- } while (isspace(c & 0xff));
+ } while (isspace(c));
if (c == '-')
{
neg = 1;
@@ -46,7 +46,7 @@ strtoull(const char *nptr, char **endptr
base = c == '0' ? 8 : 10;
cutoff = (unsigned long long)ULLONG_MAX / base;
cutlim = (unsigned long long)ULLONG_MAX % base;
- for (acc = 0, any = 0, c &= 0xff;; c = *s++, c &= 0xff)
+ for (acc = 0, any = 0; ; c = *s++)
{
if (isdigit(c))
c -= '0';
--- src/libc/ansi/stdlib/strtod.c.orig Mon Jul 12 17:00:24 1999
+++ src/libc/ansi/stdlib/strtod.c Fri Mar 2 00:48:18 2001
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <float.h>
#include <errno.h>
+#include <ctype.h>
#include <libc/unconst.h>
double
@@ -27,7 +28,7 @@ strtod(const char *s, char **sret)
if (sret)
*sret = unconst(s, char *);
- while ((*s == ' ') || (*s == '\t'))
+ while (isspace((unsigned char) *s))
s++;
if (*s == '+')
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -