Add {PLUS_NUM} string code which includes leading + for positive values
This commit is contained in:
@@ -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);
|
||||
|
@@ -96,6 +96,7 @@ enum StringControlCode {
|
||||
SCC_DECIMAL,
|
||||
SCC_DECIMAL1,
|
||||
SCC_NUM,
|
||||
SCC_PLUS_NUM,
|
||||
SCC_ZEROFILL_NUM,
|
||||
SCC_HEX,
|
||||
SCC_BYTES,
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user