(W syntax) An underscore (underbar) in a numeric constant did not
separate two digits.
+=item Missing argument for %n in %s
+
+(F) A C<%n> was used in a format string with no corresponding argument for
+perl to write the current string length to.
+
=item Missing argument in %s
(W missing) You called a function with fewer arguments than other
#endif
}
}
- else
+ else {
+ if (arg_missing)
+ Perl_croak_nocontext(
+ "Missing argument for %%n in %s",
+ PL_op ? OP_DESC(PL_op) : "sv_vcatpvfn()");
sv_setuv_mg(argsv, has_utf8 ? (UV)sv_len_utf8(sv) : (UV)i);
+ }
goto donevalidconversion;
}
"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");
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";
+}
done_testing();