From 1c72b8b0545e6a13ea3db917a1434152c73a3c3b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 8 Jan 2014 14:51:22 +0800 Subject: const'ify our strtod() helper functions The C library doesn't use const char pointers for legacy reasons (and because you *can* modify the string the end pointer points to), but let's do it in our internal implementation just because it's a nice guarantee to have. We actually used to have a non-const end pointer and replace a decimal comma with a decimal dot, but that was because we didn't have the fancy "allow commas" flags. So by using our own strtod_flags() function, we can now keep all the strings we parse read-only rather than modify them as we parse them. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- strtod.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'strtod.c') diff --git a/strtod.c b/strtod.c index 4643cfe9d..fe7319887 100644 --- a/strtod.c +++ b/strtod.c @@ -29,9 +29,10 @@ #include #include "dive.h" -double strtod_flags(char *str, char **ptr, unsigned int flags) +double strtod_flags(const char *str, const char **ptr, unsigned int flags) { - char *p = str, c, *ep; + char c; + const char *p = str, *ep; double val = 0.0; double decimal = 1.0; int sign = 0, esign = 0; -- cgit v1.2.3-70-g09d2