summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorSerhat <ss99@tuta.io>2020-10-01 23:06:12 +0300
committerSerhat <ss99@tuta.io>2020-10-02 00:25:42 +0300
commit9f2cdfea8261fae28dbd45a74195b9cff4db6dd5 (patch)
tree05737e01bf643860df6999e730622b271ed955af /core/ustring.cpp
parent25ca77c3796602b52ee9dca98abbb35aa9ede773 (diff)
downloadredot-engine-9f2cdfea8261fae28dbd45a74195b9cff4db6dd5.tar.gz
Fixed padding bug of sprintf function
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index d5afbc2b47..0033c31e20 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -4484,11 +4484,12 @@ String String::sprintf(const Array &values, bool *error) const {
int number_len = str.length();
// Padding.
+ int pad_chars_count = (value < 0 || show_sign) ? min_chars - 1 : min_chars;
String pad_char = pad_with_zeroes ? String("0") : String(" ");
if (left_justified) {
- str = str.rpad(min_chars, pad_char);
+ str = str.rpad(pad_chars_count, pad_char);
} else {
- str = str.lpad(min_chars, pad_char);
+ str = str.lpad(pad_chars_count, pad_char);
}
// Sign.