Skip to content

Commit

Permalink
PR 109125 13 regression SIGBUS in m2pim_ldtoa_ldtoa
Browse files Browse the repository at this point in the history
This patch fixes more bool int parameter mismatches
found in dtoa and ldtoa.

gcc/m2/ChangeLog:

	PR modula2/109125
	* gm2-libs-ch/dtoa.cc (dtoa_strtod): Replace int with bool.
	* gm2-libs-ch/ldtoa.cc (ldtoa_strtold): Replace int with bool.

libgm2/ChangeLog:

	PR modula2/109125
	* libm2pim/dtoa.cc (TRUE): Remove.
	(FALSE): Remove.  Replace int with bool.
	* libm2pim/ldtoa.cc (TRUE): Remove.
	(FALSE): Remove.  Replace int with bool.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
  • Loading branch information
Gaius Mulley committed Mar 15, 2023
1 parent 57052c6 commit 8f1711e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
4 changes: 2 additions & 2 deletions gcc/m2/gm2-libs-ch/dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef enum Mode { maxsignicant, decimaldigits } Mode;
(ndigits may be negative). */

double
dtoa_strtod (const char *s, int *error)
dtoa_strtod (const char *s, bool *error)
{
char *endp;
double d;
Expand All @@ -58,7 +58,7 @@ dtoa_strtod (const char *s, int *error)
if (endp != NULL && (*endp == '\0'))
*error = (errno != 0);
else
*error = TRUE;
*error = true;
return d;
}

Expand Down
4 changes: 2 additions & 2 deletions gcc/m2/gm2-libs-ch/ldtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern int dtoa_calcsign (char *p, int str_size);
(ndigits may be negative). */

long double
ldtoa_strtold (const char *s, int *error)
ldtoa_strtold (const char *s, bool *error)
{
char *endp;
long double d;
Expand All @@ -67,7 +67,7 @@ ldtoa_strtold (const char *s, int *error)
if (endp != NULL && (*endp == '\0'))
*error = (errno != 0);
else
*error = TRUE;
*error = true;
return d;
}

Expand Down
13 changes: 3 additions & 10 deletions libgm2/libm2pim/dtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define NULL (void *)0
#endif

#if !defined(TRUE)
#define TRUE (1 == 1)
#endif
#if !defined(FALSE)
#define FALSE (1 == 0)
#endif

#if defined(HAVE_STDLIB_H)
#if !defined(_ISOC99_SOURCE)
#define _ISOC99_SOURCE
Expand Down Expand Up @@ -110,7 +103,7 @@ typedef enum Mode { maxsignicant, decimaldigits } Mode;
contain ndigits past the decimal point (ndigits may be negative). */

extern "C" double
EXPORT(strtod) (const char *s, int *error)
EXPORT(strtod) (const char *s, bool *error)
{
char *endp;
double d;
Expand All @@ -123,10 +116,10 @@ EXPORT(strtod) (const char *s, int *error)
#if defined(HAVE_ERRNO_H)
*error = (errno != 0);
#else
*error = FALSE;
*error = false;
#endif
else
*error = TRUE;
*error = true;
return d;
}

Expand Down
13 changes: 3 additions & 10 deletions libgm2/libm2pim/ldtoa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define NULL (void *)0
#endif

#if !defined(TRUE)
#define TRUE (1 == 1)
#endif
#if !defined(FALSE)
#define FALSE (1 == 0)
#endif

#define MAX_FP_DIGITS 500

typedef enum Mode { maxsignicant, decimaldigits } Mode;
Expand All @@ -113,7 +106,7 @@ extern "C" int IMPORT(dtoa,calcsign) (char *p, int str_size);
contain ndigits past the decimal point (ndigits may be negative). */

extern "C" long double
EXPORT(strtold) (const char *s, int *error)
EXPORT(strtold) (const char *s, bool *error)
{
char *endp;
long double d;
Expand All @@ -131,10 +124,10 @@ EXPORT(strtold) (const char *s, int *error)
#if defined(HAVE_ERRNO_H)
*error = (errno != 0);
#else
*error = FALSE;
*error = false;
#endif
else
*error = TRUE;
*error = true;
return d;
}

Expand Down

0 comments on commit 8f1711e

Please sign in to comment.