INRIA / INRIA/libpointing

Floating point URI arguments are not parsed correctly

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
54
Forks
14
PR merge metrics
No merged PRs in 30d

Description

The function `atof` used in [URI.cpp](https://github.com/INRIA/libpointing/blob/master/pointing/utils/URI.cpp) returns integer values for floating point numbers if an application uses **locale** where **comma** is used to separate the integer part.

Example:

``` C++
URI uri("osx:?setting=1.5");
double setting = 0.;
URI::getQueryArg(uri.query, "setting", &setting);
// here setting maybe equal to 1 instead of 1.5
```

This can be corrected with

``` C
setlocale(LC_NUMERIC, "C")
```

before using the function, however we need to put the current _locale_ back afterwards.

The easier option could be using `istringstream` to read the numbers, since it uses `US locale` by default.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.