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

Improve sprintf docs, minor String::Formatter refactors #6758

Merged
merged 4 commits into from
Oct 12, 2018

Conversation

wooster0
Copy link
Contributor

@wooster0 wooster0 commented Sep 20, 2018

This removes redundant spaces in the sprintf documentation. The spaces have just been copied from Ruby's sprintf.c. They are there because Ruby uses the 4-space-code-markdown but in Crystal that's not required because Crystal uses the ```-markdown.

And this also adds the missing c format flag. It's documented but not actually implemented.

src/kernel.cr Outdated
@@ -73,7 +73,7 @@ end
# The syntax for a format specifier is:
#
# ```text
# %[flags][width][.precision]type
# %[flags][width][.precision][type]
Copy link
Member

Choose a reason for hiding this comment

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

What? The type is required. That's why it is not in brackets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I didn't realize the brackets indicate that the argument is optional.

@@ -110,7 +110,7 @@ struct String::Formatter(A)

private def consume_width(flags)
case current_char
when '1'..'9'
when '0'..'9'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is wrong, unless the 0 is after a non-0 digit, 0 is a separate flag:

# 0 (zero) | bdiouxX | Pad with zeros, not spaces.

(I can't fully check the implementation, i'm on my phone)

Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

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

Thank you @r00ster91 👍

@sdogruyol sdogruyol added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:docs labels Oct 12, 2018
@sdogruyol sdogruyol merged commit 7639f20 into crystal-lang:master Oct 12, 2018
@sdogruyol sdogruyol added this to the 0.27.0 milestone Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:docs topic:stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants