Bug 1686831 - Still apply fillers when no numbers are printed. r=Gankra

The standard for printf says that for integers, the result of converting
zero with an explicit precision of zero shall be no characters. But
flags and width still need to apply.

Differential Revision: https://phabricator.services.mozilla.com/D102696
This commit is contained in:
Mike Hommey 2021-01-27 01:06:44 +00:00
Родитель 4c520112c0
Коммит c776e2a4de
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -227,7 +227,9 @@ bool mozilla::PrintfTarget::cvt_l(long num, int width, int prec, int radix,
int digits;
// according to the man page this needs to happen
if ((prec == 0) && (num == 0)) return true;
if ((prec == 0) && (num == 0)) {
return fill_n("", 0, width, prec, type, flags);
}
// Converting decimal is a little tricky. In the unsigned case we
// need to stop when we hit 10 digits. In the signed case, we can
@ -254,7 +256,9 @@ bool mozilla::PrintfTarget::cvt_l(long num, int width, int prec, int radix,
bool mozilla::PrintfTarget::cvt_ll(int64_t num, int width, int prec, int radix,
int type, int flags, const char* hexp) {
// According to the man page, this needs to happen.
if (prec == 0 && num == 0) return true;
if (prec == 0 && num == 0) {
return fill_n("", 0, width, prec, type, flags);
}
// Converting decimal is a little tricky. In the unsigned case we
// need to stop when we hit 10 digits. In the signed case, we can