I32 items = sp - mark;
STRLEN len;
STRLEN delimlen;
+ const char * const delims = SvPV_const(delim, delimlen);
PERL_ARGS_ASSERT_DO_JOIN;
- (void) SvPV_const(delim, delimlen); /* stringify and get the delimlen */
- /* SvCUR assumes it's SvPOK() and woe betide you if it's not. */
-
mark++;
len = (items > 0 ? (delimlen * (items - 1) ) : 0);
SvUPGRADE(sv, SVt_PV);
}
if (delimlen) {
+ const U32 delimflag = DO_UTF8(delim) ? SV_CATUTF8 : SV_CATBYTES;
for (; items > 0; items--,mark++) {
STRLEN len;
const char *s;
- sv_catsv_nomg(sv,delim);
+ sv_catpvn_flags(sv,delims,delimlen,delimflag);
s = SvPV_const(*mark,len);
sv_catpvn_flags(sv,s,len,
DO_UTF8(*mark) ? SV_CATUTF8 : SV_CATBYTES);
require './test.pl';
}
-plan tests => 26;
+plan tests => 28;
@x = (1, 2, 3);
is( join(':',@x), '1:2:3', 'join an array with character');
is( $ju2, $u );
}
+package o { use overload q|""| => sub { ${$_[0]}++ } }
+{
+ my $o = bless \(my $dummy = "a"), o::;
+ $_ = join $o, 1..10;
+ is $_, "1a2a3a4a5a6a7a8a9a10", 'join, $overloaded, LIST';
+ is $$o, "b", 'overloading was called once on overloaded separator';
+}