diff options
author | Jim Meyering <jim@meyering.net> | 2003-11-27 07:46:01 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-11-27 07:46:01 +0000 |
commit | ab5dba9e1b6351f0c9a4eb3fdacae5ede216078c (patch) | |
tree | 81d1a35db1c7c8c7f57d110779daf96f562cb321 /lib | |
parent | 5564a80c71d5b039d4da5f981f8743c735822c0d (diff) | |
download | coreutils-ab5dba9e1b6351f0c9a4eb3fdacae5ede216078c.tar.xz |
new files, from Paul Eggert
Diffstat (limited to 'lib')
-rw-r--r-- | lib/c-strtod.c | 34 | ||||
-rw-r--r-- | lib/c-strtod.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/c-strtod.c b/lib/c-strtod.c new file mode 100644 index 000000000..b3fac020a --- /dev/null +++ b/lib/c-strtod.c @@ -0,0 +1,34 @@ +/* Convert string to double, using the C locale. + + Copyright (C) 2003 Free Software Foundation, Inc. + + 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; either version 2, or (at your option) + any later version. + + 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 General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert. */ + +#include "c-strtod.h" + +#include <locale.h> +#include <stdlib.h> + +double +c_strtod (char const *nptr, char **endptr) +{ + double r; + setlocale (LC_NUMERIC, "C"); + r = strtod (nptr, endptr); + setlocale (LC_NUMERIC, ""); + return r; +} diff --git a/lib/c-strtod.h b/lib/c-strtod.h new file mode 100644 index 000000000..f16dbc118 --- /dev/null +++ b/lib/c-strtod.h @@ -0,0 +1 @@ +double c_strtod (char const *, char **); |