Skip to content

parsing yaml file throw exception while decimal number end with dot . #380

@realysy

Description

@realysy

Description

If a yaml file contains number end with dot ., for example score: 2., fkyaml::node::deserialize() will throw exception:

test: /home/name/fkYAML/include/fkYAML/detail/input/scalar_scanner.hpp:188: static fkyaml::v0_3_10::detail::lexical_token_t fkyaml::v0_3_10::detail::scalar_scanner::scan_after_decimal_point(std::__cxx11::basic_string<char>::const_iterator, std::size_t, bool): Assertion `size > 0' failed.

Reproduction steps

To reproduce, use fkYAML to parse this yaml file:

score: 2.

Also, number in array will cause exception:

data: [1., 2.]

I parse yaml file use the following code:

#include <fstream>
#include "fkYAML/node.hpp"

int main(int argc, char* argv[])
{
    std::ifstream ifs("example.yml");
    fkyaml::node root = fkyaml::node::deserialize(ifs);
    ifs.close();

    return 0;
}

I add fkYAML into my cmake project use add_subdirectory().

Expected vs. actual results

Actual result: parse fail if number end with dot . in yaml file.
Expect: parse as float or double number successfully.

Minimal code example

No response

Error messages

No response

Compiler and operating system

ubuntu 20.04, CXX compiler: c++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0

Library version

v0_3_10

Validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions