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

Add support for hexadecimal and octal numbers #102

Merged
merged 1 commit into from
May 19, 2024
Merged

Add support for hexadecimal and octal numbers #102

merged 1 commit into from
May 19, 2024

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented May 19, 2024

I switched from read to our custom parsing because read expects the 0o prefix instead of C-style 0. We only handle integers for now, as read for Double does not support decimal numbers with 0x prefix and I did not want to implement decimals myself.

Additionally, add support for + sign.

Also merge negative.settings test file into dconf.settings since that one aggregates configuration keys from real dconf dumps. Instead create numbers.settings that tests all possible numeric values.

Currently unhandled cases:

zero-trailing=0.
zero-leading=.0
hex-float=0x10.1

GLib’s GVariant parses octal decimals a base 10. This is probably expected, as the docs only mention hex floats.

oct-float=010.1
oct-sci=010e10

GLib’s GVariant parses the following as a double, probably confusing it with scientific notation:

hex-neg-e=-0x1e

I switched from `read` to our custom parsing because `read` expects
the `0o` prefix instead of C-style `0`.
We only handle integers for now, as `read` for `Double` does not support
decimal numbers with `0x` prefix and I did not want to implement decimals myself.

Additionally, add support for + sign.

Also merge `negative.settings` test file into `dconf.settings` since
that one aggregates configuration keys from real dconf dumps.
Instead create `numbers.settings` that tests all possible numeric values.

Currently unhandled cases:

    zero-trailing=0.
    zero-leading=.0
    hex-float=0x10.1

GLib’s GVariant parses octal decimals a base 10.
This is probably expected, as the docs only mention hex floats.

    oct-float=010.1
    oct-sci=010e10

GLib’s GVariant parses the following as a double,
probably confusing it with scientific notation:

    hex-neg-e=-0x1e
@jtojnar jtojnar merged commit fb34a46 into master May 19, 2024
1 check passed
@jtojnar jtojnar deleted the byte branch May 19, 2024 13:14
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.

1 participant