/*
* FlexiPix library
*
* Copyright 2010-2011 Stefan Schuermans <stefan schuermans info>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <math.h>
#include <intern/strtod_noloc.h>
/**
* \brief own version of strtod ignoring locale
*
* This version of strtod always expects dots in floating point numbers.
* The reason is to be able to use the same config files for all locales.
*
* \param[in] nptr string containing number to parse
* \param[out] endptr filled with pointer to
* \return value read from the string
*/
double flp_strtod_noloc(const char *nptr, char **endptr)
{
double sign = 1.0, value = 0.0, weight = 0.1;
int exp_sign = 1, exp_value = 0;
/* skip whitespace */
while (*nptr == ' ' || *nptr == '\t')
++nptr;
/* read optional sign */
if (*nptr == '+') {
sign = 1.0;
++nptr;
} else if (*nptr == '-') {
sign = -1.0;
++nptr;
}