diff --git a/src/strings.cpp b/src/strings.cpp --- a/src/strings.cpp +++ b/src/strings.cpp @@ -185,29 +185,24 @@ void InjectDParam(uint amount) memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint64)); } -static char *FormatNumber(char *buff, int64 number, const char *last, const char *separator) +static char *FormatNumber(char *buff, int64 number, const char *last, const char *separator, int zerofill_from = 19) { uint64 divisor = 10000000000000000000ULL; - uint64 quot; - int i; - uint64 tot; - uint64 num; if (number < 0) { buff += seprintf(buff, last, "-"); number = -number; } - num = number; - - tot = 0; - for (i = 0; i < 20; i++) { - quot = 0; + uint64 num = number; + uint64 tot = 0; + for (int i = 0; i < 20; i++) { + uint64 quot = 0; if (num >= divisor) { quot = num / divisor; num = num % divisor; } - if (tot |= quot || i == 19) { + if (tot |= quot || i >= zerofill_from) { buff += seprintf(buff, last, "%i", (int)quot); if ((i % 3) == 1 && i != 19) buff = strecpy(buff, separator, last); } @@ -232,6 +227,11 @@ static char *FormatNoCommaNumber(char *b return FormatNumber(buff, number, last, ""); } +static char *FormatZerofillNumber(char *buff, int64 number, int64 count, const char *last) +{ + return FormatNumber(buff, number, last, "", 20 - count); +} + static char *FormatHexNumber(char *buff, int64 number, const char *last) { return buff + seprintf(buff, last, "0x%x", (uint32)number); @@ -839,6 +839,11 @@ static char *FormatString(char *buff, co buff = FormatNoCommaNumber(buff, GetInt64(&argv), last); break; + case SCC_ZEROFILL_NUM: { // {ZEROFILL_NUM} + int64 num = GetInt64(&argv); + buff = FormatZerofillNumber(buff, num, GetInt64(&argv), last); + } break; + case SCC_HEX: // {HEX} buff = FormatHexNumber(buff, GetInt64(&argv), last); break;