Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix interaction of space flag and '+' flag, as well as '-' flag and '… #1687

Merged
merged 1 commit into from
May 17, 2020

Conversation

rimathia
Copy link
Contributor

…0' flag

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

@@ -405,7 +405,9 @@ void basic_printf_context<OutputIt, Char>::parse_flags(format_specs& specs,
specs.fill[0] = '0';
break;
case ' ':
specs.sign = sign::space;
if (specs.sign != sign::plus) {
Copy link
Contributor Author

@rimathia rimathia May 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the opengroup description: "This means that if the <space> and + flags both appear, the flag shall be ignored."

specs.align = align::numeric;
else
specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types.
specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
// flag is also present.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opengroup description: "If the 0 and - flags both appear, the 0 flag is ignored."

@rimathia
Copy link
Contributor Author

Hi, since the behaviour changes implemented here seem pretty clearly in line with the opengroup description of the printf familiy I have skipped opening an issue.

@vitaut vitaut merged commit 6b219a5 into fmtlib:master May 17, 2020
@vitaut
Copy link
Contributor

vitaut commented May 17, 2020

This is great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants