summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorSteve Hay <SteveHay@planit.com>2005-06-21 13:49:10 +0000
committerSteve Hay <SteveHay@planit.com>2005-06-21 13:49:10 +0000
commitad3296c668b2eed14533c1cf4b03090043289701 (patch)
tree04b008c28d1626e32499c5468b55d0d3d81ae1b9 /mg.c
parent6a76db8b55b6281740baab9e0ef221938c776ccd (diff)
downloadperl-ad3296c668b2eed14533c1cf4b03090043289701.tar.gz
Trim trailing whitespace from $! and $^E
(Fixes lib/Test/Simple/t/fail-more.t with bcc32 on Win32, and is good for consistency anyway) p4raw-id: //depot/perl@24925
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mg.c b/mg.c
index 383353a9da..bd5acdfe57 100644
--- a/mg.c
+++ b/mg.c
@@ -563,6 +563,13 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg)
return 0;
}
+#define SvRTRIM(sv) STMT_START { \
+ STRLEN len = SvCUR(sv); \
+ while (len > 0 && isSPACE(SvPVX(sv)[len-1])) \
+ --len; \
+ SvCUR_set(sv, len); \
+} STMT_END
+
int
Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
{
@@ -648,6 +655,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
#endif
#endif
#endif
+ SvRTRIM(sv);
SvNOK_on(sv); /* what a wonderful hack! */
}
else if (strEQ(mg->mg_ptr+1, "NCODING"))
@@ -896,6 +904,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
errno = saveerrno;
}
#endif
+ SvRTRIM(sv);
SvNOK_on(sv); /* what a wonderful hack! */
break;
case '<':