"width & precision interplay with utf8 strings, length=$i");
}
-# Used to mangle PL_sv_undef
-fresh_perl_like(
- 'print sprintf "xxx%n\n"; print undef',
- qr/Modification of a read-only value attempted at\b/,
- { switches => [ '-w' ] },
- q(%n should not be able to modify read-only constants),
-);
-
# check overflows
for (int(~0/2+1), ~0, "9999999999999999999") {
is(eval {sprintf "%${_}d", 0}, undef, "no sprintf result expected %${_}d");
is($w_other, 0, "utf8 for invalid format: other warnings");
}
+# it used to upgrade the result to utf8 if the 1st arg happened to be utf8
+
+{
+ my $precis = "9";
+ utf8::upgrade($precis);
+ my $s = sprintf "%.*f\n", $precis, 1.1;
+ ok(!utf8::is_utf8($s), "first arg not special utf8-wise");
+}
+
+# sprintf("%n") used to croak "Modification of a read-only value"
+# as it tried to set &PL_sv_no
+
+{
+ eval { my $s = sprintf("%n"); };
+ like $@, qr/Missing argument for %n in sprintf/, "%n";
+}
+
+# %p of an Inf or Nan address should still print its address, not
+# 'Inf' etc.
+
+like sprintf("%p", 0+'Inf'), qr/^[0-9a-f]+$/, "%p and Inf";
+like sprintf("%p", 0+'NaN'), qr/^[0-9a-f]+$/, "%p and NaN";
+
done_testing();