Skip to content

Fix string formatting of version number#177

Merged
zauguin merged 1 commit into
latex3:devfrom
vlasakm:formatting
Mar 9, 2021
Merged

Fix string formatting of version number#177
zauguin merged 1 commit into
latex3:devfrom
vlasakm:formatting

Conversation

@vlasakm
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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