New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in &= (string) and/or m// #8192
Comments
From anno4000@mailbox.tu-berlin.de From: anno4000@mailbox.tu-berlin.de This is a bug report for perl from anno@oliva.zrz.tu-berlin.de, The sequence my $str = 'aa'; dies, showing that the match fails while it obviously shouldn't. It Anno ======================================================================== # prepare a string is( $str, 'a', "Single 'a' after &="); # passes Flags: Site configuration information for perl v5.8.6: Configured by anno at Sun Jul 24 00:22:57 CEST 2005. Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Locally applied patches: @INC for perl v5.8.6: Environment for perl v5.8.6: |
From @ysthOn Sat, Nov 05, 2005 at 05:20:20PM -0800, Anno Siegel wrote:
?? If it dies, the match is succeeding. And it succeeds for me from 5.6.2 I would have expected the &= to leave $str set to the 2 characters: But /^a$/ failing when $str eq "a" is true is obviously a bug. |
The RT System itself - Status changed from 'new' to 'open' |
From @AbigailOn Sun, Nov 06, 2005 at 06:14:20PM -0800, Yitzchak Scott-Thoennes wrote:
It not only makes sense, it's also documented to do it this way: If the operands to a binary bitwise op are strings of From "Bitwise String Operators" in the "perlop" manual page. Abigail |
From anno4000@mailbox.tu-berlin.deOn 07.11.2005, at 03:22, Yitzchak Scott-Thoennes via RT wrote:
It's "match or die", so it dies on failure.
It does, in view of the fact that a bit string is virtually followed
Ah, good that's a clearer example than my /a+$/, which also fails. Anno |
From @ysthOn Mon, Nov 07, 2005 at 09:26:21PM +0100, Anno Siegel wrote:
Sorry, momentary confusion on my part.
Hmm, still can't get that to fail on any version, but /^a$/ and /^a+$/ |
From BQW10602@nifty.comOn Mon, 7 Nov 2005 23:15:14 +0100, Abigail <abigail@abigail.nl> wrote
Does this part of perlop just mention that ("a" | "xyz") is same I don't think "additional zero bits" here mean a NUL character Say, another document, perlguts, mentions as cited below: All SVs that contain strings should be terminated with a NUL Thus I think & operation should add NUL character always. Regards, |
From @rgsSADAHIRO Tomoyuki wrote:
This internal limitation bothers me; but anyway, the simplest fix |
From @nwc10On Tue, Nov 08, 2005 at 01:44:19PM +0100, Rafael Garcia-Suarez wrote:
The limitation that the regexp engine is relying on it definitely bothers me. Nicholas Clark |
From BQW10602@nifty.comOn Tue, 8 Nov 2005 13:44:19 +0100, Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> wrote
Here is a patch proposed, SADAHIRO Tomoyuki Inline Patchdiff -ur perl~patch26045/doop.c perl/doop.c
--- perl~patch26045/doop.c Mon Oct 31 19:55:18 2005
+++ perl/doop.c Wed Nov 09 02:03:13 2005
@@ -1174,7 +1174,7 @@
}
else if (SvOK(sv) || SvTYPE(sv) > SVt_PVMG) {
dc = SvPV_force_nomg_nolen(sv);
- if (SvCUR(sv) < (STRLEN)len) {
+ if (SvLEN(sv) < (STRLEN)(len + 1)) {
dc = SvGROW(sv, (STRLEN)(len + 1));
(void)memzero(dc + SvCUR(sv), len - SvCUR(sv) + 1);
}
@@ -1303,6 +1303,7 @@
case OP_BIT_AND:
while (len--)
*dc++ = *lc++ & *rc++;
+ *dc = '\0';
break;
case OP_BIT_XOR:
while (len--)
diff -ur perl~patch26045/t/op/bop.t perl/t/op/bop.t
--- perl~patch26045/t/op/bop.t Wed Dec 22 06:00:08 2004
+++ perl/t/op/bop.t Wed Nov 09 01:40:34 2005
@@ -15,7 +15,7 @@
# If you find tests are failing, please try adding names to tests to track
# down where the failure is, and supply your new names as a patch.
# (Just-in-time test naming)
-plan tests => 146;
+plan tests => 148;
# numerics
ok ((0xdead & 0xbeef) == 0x9ead);
@@ -328,4 +328,15 @@
SKIP: {
skip "No malloc wrap checks" unless $Config::Config{usemallocwrap};
like( runperl(prog => 'eval q($#a>>=1); print 1'), "^1\n?" );
+}
+
+# [perl #37616] Bug in &= (string) and/or m//
+{
+ $a = "aa";
+ $a &= "a";
+ ok($a =~ /a+$/, 'ASCII "a" is NUL-terminated');
+
+ $b = "bb\x{100}";
+ $b &= "b";
+ ok($b =~ /b+$/, 'Unicode "b" is NUL-terminated');
} |
From @AbigailOn Tue, Nov 08, 2005 at 09:25:35PM +0900, SADAHIRO Tomoyuki wrote:
Yes, I think it does.
But a NUL character is a 8 zero bits. And the next line of the text The granularity for such extension or truncation is one or more bytes.
Yes. But we're talking about two different additions of NUL characters. Abigail |
From BQW10602@nifty.comOn Tue, 8 Nov 2005 21:56:36 +0100, Abigail <abigail@abigail.nl> wrote
Yes. I also think perlop is correct, and I don't intend to change it. NUL character which should be added as I say is SADAHIRO Tomoyuki |
From @rgsSADAHIRO Tomoyuki wrote:
Thanks, applied as change 26136.
|
@rgs - Status changed from 'open' to 'resolved' |
From @ysthOn Sat, Nov 05, 2005 at 05:20:20PM -0800, Anno Siegel wrote:
?? If it dies, the match is succeeding. And it succeeds for me from 5.6.2 I would have expected the &= to leave $str set to the 2 characters: But /^a$/ failing when $str eq "a" is true is obviously a bug. |
Migrated from rt.perl.org#37616 (status was 'resolved')
Searchable as RT37616$
The text was updated successfully, but these errors were encountered: