diff --git a/src/strings.cpp b/src/strings.cpp index bfb868da2d..15b7936c18 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1317,6 +1317,15 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg buff = FormatNoCommaNumber(buff, args->GetInt64(SCC_NUM), last); break; + case SCC_PLUS_NUM: { // {PLUS_NUM} + int64 num = args->GetInt64(SCC_PLUS_NUM); + if (num > 0) { + buff += seprintf(buff, last, "+"); + } + buff = FormatNoCommaNumber(buff, num, last); + break; + } + case SCC_ZEROFILL_NUM: { // {ZEROFILL_NUM} int64 num = args->GetInt64(); buff = FormatZerofillNumber(buff, num, args->GetInt64(), last); diff --git a/src/table/control_codes.h b/src/table/control_codes.h index 3d59a6caf5..69838c5bb5 100644 --- a/src/table/control_codes.h +++ b/src/table/control_codes.h @@ -96,6 +96,7 @@ enum StringControlCode { SCC_DECIMAL, SCC_DECIMAL1, SCC_NUM, + SCC_PLUS_NUM, SCC_ZEROFILL_NUM, SCC_HEX, SCC_BYTES, diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h index de3b96c114..f0a0f868bb 100644 --- a/src/table/strgen_tables.h +++ b/src/table/strgen_tables.h @@ -111,6 +111,7 @@ static const CmdStruct _cmd_structs[] = { {"DECIMAL", EmitSingleChar, SCC_DECIMAL, 2, 0, C_NONE}, // Number with comma and fractional part. Second parameter is number of fractional digits, first parameter is number times 10**(second parameter). {"DECIMAL1", EmitSingleChar, SCC_DECIMAL1, 1, 0, C_NONE}, // Decimal with fixed second parameter of 1 {"NUM", EmitSingleChar, SCC_NUM, 1, 0, C_NONE}, // Signed number + {"PLUS_NUM", EmitSingleChar, SCC_PLUS_NUM, 1, 0, C_NONE}, // Signed number, with sign (+ or -) shown for both positive and negative numbers {"ZEROFILL_NUM", EmitSingleChar, SCC_ZEROFILL_NUM, 2, 0, C_NONE}, // Unsigned number with zero fill, e.g. "02". First parameter is number, second minimum length {"BYTES", EmitSingleChar, SCC_BYTES, 1, 0, C_NONE}, // Unsigned number with "bytes", i.e. "1.02 MiB or 123 KiB" {"HEX", EmitSingleChar, SCC_HEX, 1, 0, C_NONE}, // Hexadecimally printed number