Skip to content

Interpret precision as display width #4443

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nikhilreddydev
Copy link

Fixes #4272

It now correctly considers precision as display width precision.
Please let me know, if I need to add any test cases as well.

Thanks!

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Please address inline comments and add a test case to format-test.cc


template <typename Char>
FMT_CONSTEXPR auto handle_precision(
basic_string_view<Char> s, const Char* data, const format_specs& specs,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to separately pass data - you can use s instead.

FMT_ENABLE_IF(std::is_same<Char, char>::value)) -> size_t {
auto code_points = count_code_points_with_display_width_precision(
to_string_view(data), to_unsigned(specs.precision));
return code_point_index(s, to_unsigned(code_points));
Copy link
Contributor

Choose a reason for hiding this comment

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

code_points is already unsigned

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.

Use display width in precision
2 participants