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 string formatting of version number #177

Merged
merged 1 commit into from
Mar 9, 2021
Merged

Conversation

vlasakm
Copy link
Contributor

@vlasakm vlasakm commented Mar 6, 2021

According to Lua 5.3 manual %q is for formatting strings and escaping
them so that they can be read again by Lua. This particular number is
however floating point and %q chooses to format it like with %a, that
means hexadecimal. This greatly reduces the the readability. Better
option seems to be using %s, which uses tostring function.

This is the difference in output:

luaotfload | init : Context OpenType loader version 0x1.8e76c8b439581p+1
luaotfload | init : Context OpenType loader version 3.113

There may be other places where this issue may be relevant, but this
line is printed to every log file.

Most of the tests failed on me, but it doesn't seem to be a problem
with this patch.

If you choose to accept this PR consider rebase merging.

@zauguin
Copy link
Member

zauguin commented Mar 8, 2021

Thanks for the PR. I think I would prefer a %.3f here to avoid to rely on unspecified formatting as in tostring.

According to Lua 5.3 manual %q is for formatting strings and escaping
them so that they can be read again by Lua. This particular number is
however floating point and %q chooses to format it like with %a, that
means hexadecimal. This greatly reduces the the readability. Because
ConTeXt's OpenType loader versions are always in the format `x.yyy` we
can use %.3f directly.

This is the difference in output:
```
luaotfload | init : Context OpenType loader version 0x1.8e76c8b439581p+1
luaotfload | init : Context OpenType loader version 3.113
```

There may be other places where this issue may be relevant, but this
line is printed to every log file.
@vlasakm
Copy link
Contributor Author

vlasakm commented Mar 9, 2021

Yeah, you are right, on second thought %.3f better, because it seems that ConTeXt has always used x.yyy. I forced pushed accordingly.

Initally I was going for the more general "human readable" approach of tostring, which at least now uses %g under the hood and takes care of trailing zeros.

@zauguin zauguin merged commit 5b924e5 into latex3:dev Mar 9, 2021
@vlasakm vlasakm deleted the formatting branch May 23, 2021 15:21
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