summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-12-15 04:00:50 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-12-15 04:00:50 +0000
commitc7fc788e7c6f535cd383c26610b58351be9268c4 (patch)
tree3009be95d8fda9e78ba142d9212ba61780ef0526
parent39efa3ccdd2b93b61c2422c3c571d34055e1352b (diff)
downloadperl-c7fc788e7c6f535cd383c26610b58351be9268c4.tar.gz
Fixes for the IV UV patches to compile in Digital UNIX.
p4raw-id: //depot/perl@8123
-rw-r--r--sv.c78
1 files changed, 41 insertions, 37 deletions
diff --git a/sv.c b/sv.c
index ab95cb9b3a..bf52516dc9 100644
--- a/sv.c
+++ b/sv.c
@@ -2064,49 +2064,53 @@ Perl_sv_2uv(pTHX_ register SV *sv)
(void)SvIOK_on(sv);
SvIVX(sv) = Atol(SvPVX(sv));
} else {
-#ifdef HAS_STRTOUL
- UV u;
int save_errno = errno;
- /* Is it an integer that we could convert with strtoul?
- So try it, and if it doesn't set errno then it's pukka.
- This should be faster than going atof and then thinking. */
- if (((numtype & (IS_NUMBER_TO_INT_BY_STRTOL | IS_NUMBER_NOT_INT))
- == IS_NUMBER_TO_INT_BY_STRTOL)
- && ((errno = 0), 1) /* always true */
- && ((u = Strtoul(SvPVX(sv), Null(char**), 10)), 1) /* ditto */
- && (errno == 0)
- /* If known to be negative, check it didn't undeflow IV */
- && ((numtype & IS_NUMBER_NEG) ? ((IV)u <= 0) : 1)) {
- errno = save_errno;
-
- if (SvTYPE(sv) < SVt_PVIV)
- sv_upgrade(sv, SVt_PVIV);
- (void)SvIOK_on(sv);
-
- /* If it's negative must use IV.
- IV-over-UV optimisation */
- if (numtype & IS_NUMBER_NEG || u <= (UV) IV_MAX) {
- /* strtoul is defined to return negated value if the
- number starts with a minus sign. Assuming 2s
- complement, this value will be in range for a negative
- IV if casting the bit pattern to IV doesn't produce
- a positive value. Allow -0 by checking it's <= 0
- hence (numtype & IS_NUMBER_NEG) test above
- */
- SvIVX(sv) = (IV)u;
- } else {
- /* it didn't overflow, and it was positive. */
- SvUVX(sv) = u;
- SvIsUV_on(sv);
+#ifdef HAS_STRTOUL
+ {
+ UV u;
+ /* Is it an integer that we could convert with strtoul?
+ So try it, and if it doesn't set errno then it's pukka.
+ This should be faster than going atof and then thinking. */
+ if (((numtype &
+ (IS_NUMBER_TO_INT_BY_STRTOL | IS_NUMBER_NOT_INT))
+ == IS_NUMBER_TO_INT_BY_STRTOL)
+ && ((errno = 0), 1) /* always true */
+ && ((u = Strtoul(SvPVX(sv), Null(char**), 10)), 1) /* ditto */
+ && (errno == 0)
+ /* If known to be negative, check it didn't undeflow IV */
+ && ((numtype & IS_NUMBER_NEG) ? ((IV)u <= 0) : 1)) {
+ errno = save_errno;
+
+ if (SvTYPE(sv) < SVt_PVIV)
+ sv_upgrade(sv, SVt_PVIV);
+ (void)SvIOK_on(sv);
+
+ /* If it's negative must use IV.
+ IV-over-UV optimisation */
+ if (numtype & IS_NUMBER_NEG || u <= (UV) IV_MAX) {
+ /* strtoul is defined to return negated value if the
+ number starts with a minus sign. Assuming 2s
+ complement, this value will be in range for
+ a negative IV if casting the bit pattern to
+ IV doesn't produce a positive value. Allow -0
+ by checking it's <= 0
+ hence (numtype & IS_NUMBER_NEG) test above
+ */
+ SvIVX(sv) = (IV)u;
+ } else {
+ /* it didn't overflow, and it was positive. */
+ SvUVX(sv) = u;
+ SvIsUV_on(sv);
+ }
}
- } else {
+ }
+#endif
+ {
NV d;
/* Hopefully trace flow will optimise this away where possible
*/
errno = save_errno;
-#else
- NV d;
-#endif
+
/* It wasn't an integer, or it overflowed, or we don't have
strtol. Do things the slow way - check if it's a IV etc. */
d = Atof(SvPVX(sv));