Change 18815 by [EMAIL PROTECTED] on 2003/03/03 05:43:25
Integrate:
[ 18813]
Use a macro for abs() to avoid the possible truncation to an int;
also make an explicit (double)cast for the arguments to fabs().
Affected files ...
... //depot/maint-5.8/perl/perl.h#19 integrate
... //depot/maint-5.8/perl/pp.c#12 integrate
... //depot/maint-5.8/perl/sv.c#30 integrate
Differences ...
==== //depot/maint-5.8/perl/perl.h#19 (text) ====
Index: perl/perl.h
--- perl/perl.h#18~18804~ Sun Mar 2 08:22:35 2003
+++ perl/perl.h Sun Mar 2 21:43:25 2003
@@ -4318,6 +4318,10 @@
# define PERL_BLOCKSIG_UNBLOCK(set) NOOP
#endif
+/* Use instead of abs() since abs() forces its argument to be an int,
+ * but also beware since evaluates its argument thrice. */
+#define PERL_ABS(x) ((x) < 0 ? -(x) : (x))
+
/* and finally... */
#define PERL_PATCHLEVEL_H_IMPLICIT
#include "patchlevel.h"
==== //depot/maint-5.8/perl/pp.c#12 (text) ====
Index: perl/pp.c
--- perl/pp.c#11~18808~ Sun Mar 2 13:29:38 2003
+++ perl/pp.c Sun Mar 2 21:43:25 2003
@@ -1237,7 +1237,7 @@
}
RETURN;
} /* tried integer divide but it was not an integer result */
- } /* else (abs(result) < 1.0) or (both UVs in range for NV) */
+ } /* else (PERL_ABS(result) < 1.0) or (both UVs in range for NV) */
} /* left wasn't SvIOK */
} /* right wasn't SvIOK */
#endif /* PERL_TRY_UV_DIVIDE */
@@ -2484,9 +2484,7 @@
dPOPTOPiirl;
if (!right)
DIE(aTHX_ "Illegal modulus zero");
- if (right < 0)
- right = -right;
- SETi( left % right );
+ SETi( left % PERL_ABS(right) );
RETURN;
}
#endif
@@ -2523,8 +2521,7 @@
PL_ppaddr[OP_I_MODULO] =
&Perl_pp_i_modulo_1;
/* Make certain we work right this time, too. */
- if (right < 0)
- right = -right;
+ right = PERL_ABS(right);
}
}
#endif
==== //depot/maint-5.8/perl/sv.c#30 (text) ====
Index: perl/sv.c
--- perl/sv.c#29~18804~ Sun Mar 2 08:22:35 2003
+++ perl/sv.c Sun Mar 2 21:43:25 2003
@@ -2274,7 +2274,7 @@
this NV is in the preserved range, therefore: */
if (!(U_V(SvNVX(sv) > 0 ? SvNVX(sv) : -SvNVX(sv))
< (UV)IV_MAX)) {
- Perl_croak(aTHX_ "sv_2iv assumed (U_V(fabs(SvNVX(sv))) <
(UV)IV_MAX) but SvNVX(sv)=%"NVgf" U_V is 0x%"UVxf", IV_MAX is 0x%"UVxf"\n", SvNVX(sv),
U_V(SvNVX(sv)), (UV)IV_MAX);
+ Perl_croak(aTHX_ "sv_2iv assumed
(U_V(fabs((double)SvNVX(sv))) < (UV)IV_MAX) but SvNVX(sv)=%"NVgf" U_V is 0x%"UVxf",
IV_MAX is 0x%"UVxf"\n", SvNVX(sv), U_V(SvNVX(sv)), (UV)IV_MAX);
}
} else {
/* IN_UV NOT_INT
@@ -2561,7 +2561,7 @@
this NV is in the preserved range, therefore: */
if (!(U_V(SvNVX(sv) > 0 ? SvNVX(sv) : -SvNVX(sv))
< (UV)IV_MAX)) {
- Perl_croak(aTHX_ "sv_2uv assumed (U_V(fabs(SvNVX(sv))) <
(UV)IV_MAX) but SvNVX(sv)=%"NVgf" U_V is 0x%"UVxf", IV_MAX is 0x%"UVxf"\n", SvNVX(sv),
U_V(SvNVX(sv)), (UV)IV_MAX);
+ Perl_croak(aTHX_ "sv_2uv assumed
(U_V(fabs((double)SvNVX(sv))) < (UV)IV_MAX) but SvNVX(sv)=%"NVgf" U_V is 0x%"UVxf",
IV_MAX is 0x%"UVxf"\n", SvNVX(sv), U_V(SvNVX(sv)), (UV)IV_MAX);
}
} else
sv_2iuv_non_preserve (sv, numtype);
End of Patch.