Skip to content

Commit

Permalink
Parse very large numbers as Infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
kgiszczak committed Feb 10, 2024
1 parent 49a5dd3 commit 13c11f0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [0.7.0] - 2024-02-10

- Update tomlc99 to the latest version
- Parse very large numbers as Infinity

## [0.6.0] - 2023-05-05

Expand Down
2 changes: 1 addition & 1 deletion ext/tomlib/toml.c
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ int toml_rtod_ex(toml_raw_t src, double *ret_, char *buf, int buflen) {
}

int toml_rtod(toml_raw_t src, double *ret_) {
char buf[100];
char buf[400];
return toml_rtod_ex(src, ret_, buf, sizeof(buf));
}

Expand Down
2 changes: 1 addition & 1 deletion ext/tomlib/tomlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static VALUE toml_table_key_to_rb_value(const toml_table_t *table, const char *k

datum = toml_double_in(table, key);

if (datum.ok) {
if (datum.ok || datum.u.d == INFINITY || datum.u.d == -INFINITY) {
return DBL2NUM(datum.u.d);
}

Expand Down
4 changes: 4 additions & 0 deletions spec/examples/parser/valid/spec-very-large-floats.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ex1 = 1e1000
ex2 = -1e1000
ex3 = 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999.0
ex4 = -9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999.0
4 changes: 4 additions & 0 deletions spec/examples/parser/valid/spec-very-large-floats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ex1: .inf
ex2: -.inf
ex3: .inf
ex4: -.inf

0 comments on commit 13c11f0

Please sign in to comment.