mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Compare commits
2 Commits
3b14f8becf
...
3ff2e435e8
Author | SHA1 | Date | |
---|---|---|---|
|
3ff2e435e8 | ||
|
542bef343a |
@ -5882,7 +5882,7 @@ String String::sprintf(const Array &values, bool *error) const {
|
||||
} else {
|
||||
if (c == '0' && min_chars == 0) {
|
||||
if (left_justified) {
|
||||
WARN_PRINT("[%0]: The \"0\" flag is ignored with \"-\" flag in string formatting.");
|
||||
WARN_PRINT("[%%0]: The \"0\" flag is ignored with \"-\" flag in string formatting.");
|
||||
} else {
|
||||
pad_with_zeros = true;
|
||||
}
|
||||
@ -5904,7 +5904,7 @@ String String::sprintf(const Array &values, bool *error) const {
|
||||
|
||||
case '*': { // Dynamic width, based on value.
|
||||
if (value_index >= values.size()) {
|
||||
return vformat("[%*]: Not enough arguments for string formatting (%d provided, but more were expected). Check for extraneous %% placeholders or missing arguments.", value_index);
|
||||
return vformat("[%%*]: Not enough arguments for string formatting (%d provided, but more were expected). Check for extraneous %% placeholders or missing arguments.", value_index);
|
||||
}
|
||||
|
||||
Variant::Type value_type = values[value_index].get_type();
|
||||
@ -5912,7 +5912,7 @@ String String::sprintf(const Array &values, bool *error) const {
|
||||
value_type != Variant::VECTOR2 && value_type != Variant::VECTOR2I &&
|
||||
value_type != Variant::VECTOR3 && value_type != Variant::VECTOR3I &&
|
||||
value_type != Variant::VECTOR4 && value_type != Variant::VECTOR4I) {
|
||||
return vformat("[%*]: A number (int/float) or a vector type (Vector2/3/4/2i/3i/4i) is required, but a %s was provided.", Variant().get_type_name(values[value_index].get_type()));
|
||||
return vformat("[%%*]: A number (int/float) or a vector type (Vector2/3/4/2i/3i/4i) is required, but a %s was provided.", Variant::get_type_name(value_type));
|
||||
}
|
||||
|
||||
int size = values[value_index];
|
||||
|
@ -1229,7 +1229,7 @@ TEST_CASE("[String] sprintf") {
|
||||
args.push_back("sc");
|
||||
output = format.sprintf(args, &error);
|
||||
REQUIRE(error);
|
||||
CHECK(output == "[%c]: Requires a number or a single-character string, but a string of 2 characters was provided.");
|
||||
CHECK(output == "[%c]: A number or a single-character string is required, but a string of 2 characters was provided.");
|
||||
|
||||
// Character bad type.
|
||||
format = "fish %c frog";
|
||||
|
Loading…
Reference in New Issue
Block a user