*++newsp = SvREFCNT_inc(*SP);
FREETMPS;
sv_2mortal(*newsp);
- } else {
+ }
+ else {
+ sv = SvREFCNT_inc(*SP); /* FREETMPS could clobber it */
FREETMPS;
- *++newsp = sv_mortalcopy(*SP);
+ *++newsp = sv_mortalcopy(sv);
+ SvREFCNT_dec(sv);
}
- } else
+ }
+ else
*++newsp = (SvTEMP(*SP)) ? *SP : sv_mortalcopy(*SP);
- } else
+ }
+ else
*++newsp = sv_mortalcopy(*SP);
- } else
+ }
+ else
*++newsp = &PL_sv_undef;
}
else if (gimme == G_ARRAY) {
sv_2mortal(*MARK);
}
else {
+ sv = SvREFCNT_inc(TOPs); /* FREETMPS could clobber it */
FREETMPS;
- *MARK = sv_mortalcopy(TOPs);
+ *MARK = sv_mortalcopy(sv);
+ SvREFCNT_dec(sv);
}
}
else
sv_2mortal(*MARK);
}
else {
+ sv = SvREFCNT_inc(TOPs); /* FREETMPS could clobber it */
FREETMPS;
- *MARK = sv_mortalcopy(TOPs);
+ *MARK = sv_mortalcopy(sv);
+ SvREFCNT_dec(sv);
}
}
else
# test recursive functions.
#
-print "1..23\n";
+print "1..25\n";
sub gcd ($$) {
return gcd($_[0] - $_[1], $_[1]) if ($_[0] > $_[1]);
print 'not ' unless (($t = takeuchi($x, $y, $z)) == $z + 1);
print "ok ", $i++, "\n";
print "# takeuchi($x, $y, $z) = $t\n";
+
+{
+ sub get_first1 {
+ get_list1(@_)->[0];
+ }
+
+ sub get_list1 {
+ return [24] unless $_[0];
+ my $u = get_first1(0);
+ [$u];
+ }
+ my $x = get_first1(1);
+ print "ok $x\n";
+}
+
+{
+ sub get_first2 {
+ return get_list2(@_)->[0];
+ }
+
+ sub get_list2 {
+ return [25] unless $_[0];
+ my $u = get_first2(0);
+ return [$u];
+ }
+ my $x = get_first2(1);
+ print "ok $x\n";
+}
+
+$i = 26;