summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-12-07 09:00:00 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2012-12-07 09:00:00 +0100
commitbc0b67e6302a114e1efd2701aafa6ecd9282cc69 (patch)
tree3611be87c0eca66ca532fdcb677f3b8405de7dab /tools.c
parenta94f45a1b3d77c9793bee22eee1b352636b0ac16 (diff)
downloadvdr-bc0b67e6302a114e1efd2701aafa6ecd9282cc69.tar.gz
vdr-bc0b67e6302a114e1efd2701aafa6ecd9282cc69.tar.bz2
Only handling decimal point in atod() and dtoa() if it differs from '.'
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/tools.c b/tools.c
index 8c03c868..57f10283 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 2.28 2012/12/06 09:40:02 kls Exp $
+ * $Id: tools.c 2.29 2012/12/07 09:00:00 kls Exp $
*/
#include "tools.h"
@@ -303,21 +303,27 @@ cString AddDirectory(const char *DirName, const char *FileName)
return cString::sprintf("%s/%s", DirName && *DirName ? DirName : ".", FileName);
}
+#define DECIMAL_POINT_C '.'
+
double atod(const char *s)
{
static lconv *loc = localeconv();
- char buf[strlen(s) + 1];
- char *p = buf;
- while (*s) {
- if (*s == '.')
- *p = *loc->decimal_point;
- else
- *p = *s;
- p++;
- s++;
- }
- *p = 0;
- return atof(buf);
+ if (*loc->decimal_point != DECIMAL_POINT_C) {
+ char buf[strlen(s) + 1];
+ char *p = buf;
+ while (*s) {
+ if (*s == DECIMAL_POINT_C)
+ *p = *loc->decimal_point;
+ else
+ *p = *s;
+ p++;
+ s++;
+ }
+ *p = 0;
+ return atof(buf);
+ }
+ else
+ return atof(s);
}
cString dtoa(double d, const char *Format)
@@ -325,7 +331,9 @@ cString dtoa(double d, const char *Format)
static lconv *loc = localeconv();
char buf[16];
snprintf(buf, sizeof(buf), Format, d);
- return strreplace(buf, *loc->decimal_point, '.');
+ if (*loc->decimal_point != DECIMAL_POINT_C)
+ strreplace(buf, *loc->decimal_point, DECIMAL_POINT_C);
+ return buf;
}
cString itoa(int n)