Skip to content

Commit 19d4e5f

Browse files
committed
Allow integers with up to 18 digits in OPL parser
See #336.
1 parent 7316c65 commit 19d4e5f

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

include/osmium/io/detail/opl_parser_functions.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ namespace osmium {
206206
*data = s;
207207
}
208208

209-
// Arbitrary limit how long integers can get
210209
enum {
211-
max_int_len = 16
210+
max_int_len = std::numeric_limits<int64_t>::digits10 + 1
212211
};
213212

214213
template <typename T>

test/t/io/test_opl_parser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ TEST_CASE("Parse OPL: integer") {
260260
REQUIRE(test_parse_int("-1x") == -1);
261261
REQUIRE(test_parse_int("1234567890123x") == 1234567890123);
262262
REQUIRE(test_parse_int("-1234567890123x") == -1234567890123);
263+
REQUIRE(test_parse_int("999999999999999999x") == 999999999999999999);
264+
REQUIRE(test_parse_int("-999999999999999999x") == -999999999999999999);
263265

264266
REQUIRE_THROWS_WITH(test_parse_int(""),
265267
"OPL error: expected integer");

0 commit comments

Comments
 (0)