Skip to content

Poco::format() misorders sign and padding specifiers #65

@pprindeville

Description

@pprindeville

If I run in a debugger:

Poco::format("%+03d", -7)

I get "0-7" as the output. This is wrong.

This breaks down as:

stream << setiosflags(ios::showpos) << setfill('0') << setw(3) << -7 << endl;

which not surprisingly, generates the same incorrect response...

I'd recommend processing the sign separately in formatOne() for the specifier '+', i.e.

stream << setiosflags(ios::showpos) << setw(1) << -7

then resetting the ios::showpos flag and shaving 1 off the width, and setting the fill, then passing the value a 2nd time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions