mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 02:31:25 +01:00
Format: fixes substring ends before the start of the string (#2669)
* Format: fix substring ends before the start of the string Closes #2668 Signed-off-by: Don Yin <Don_Yin@outlook.com> * Doc: moves changelog entry to Unreleased [ci skip] I moved the unreleased fix out of the 2.70.0 section. Signed-off-by: Don Yin <Don_Yin@outlook.com> --------- Signed-off-by: Don Yin <Don_Yin@outlook.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* Improved uptime detection on SunOS via kstat. (#2674, Uptime, SunOS)
|
* Improved uptime detection on SunOS via kstat. (#2674, Uptime, SunOS)
|
||||||
|
* Fixed substring formatting returning the remaining string when a negative end index is before the start of the string. (General)
|
||||||
|
|
||||||
# 2.70.0
|
# 2.70.0
|
||||||
|
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ static bool parseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint3
|
|||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end = (int32_t) tempString.length + end;
|
end = (int32_t) tempString.length + end;
|
||||||
}
|
}
|
||||||
if ((uint32_t) end > tempString.length) {
|
if (end >= 0 && (uint32_t) end > tempString.length) {
|
||||||
end = (int32_t) tempString.length;
|
end = (int32_t) tempString.length;
|
||||||
}
|
}
|
||||||
if (end > start) {
|
if (end > start) {
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ int main(void) {
|
|||||||
VERIFY("output({1~10,10})", "12345 67890", "output()");
|
VERIFY("output({1~10,10})", "12345 67890", "output()");
|
||||||
VERIFY("output({1~10,5})", "12345 67890", "output()");
|
VERIFY("output({1~10,5})", "12345 67890", "output()");
|
||||||
VERIFY("output({1~3,-3})", "12345 67890", "output(45 67)");
|
VERIFY("output({1~3,-3})", "12345 67890", "output(45 67)");
|
||||||
|
VERIFY("output({1~0,-12})", "12345 67890", "output()");
|
||||||
VERIFY("output({1~-5,-3})", "12345 67890", "output(67)");
|
VERIFY("output({1~-5,-3})", "12345 67890", "output(67)");
|
||||||
VERIFY("output({1~-0,10})", "12345 67890", "output(12345 6789)");
|
VERIFY("output({1~-0,10})", "12345 67890", "output(12345 6789)");
|
||||||
VERIFY("output({1~-3,-5})", "12345 67890", "output()");
|
VERIFY("output({1~-3,-5})", "12345 67890", "output()");
|
||||||
|
|||||||
Reference in New Issue
Block a user