diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-08 14:51:22 +0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-08 16:38:47 +0800 |
commit | 2d1d78ebfe3169b4893823764d1b29db84631006 (patch) | |
tree | bb52caeed16dbe971cfce188432eb8b738e6c692 /strtod.c | |
parent | 19b982d3dff0a942bccba9813bc3234e5cceb57f (diff) | |
download | subsurface-2d1d78ebfe3169b4893823764d1b29db84631006.tar.gz |
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 <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'strtod.c')
-rw-r--r-- | strtod.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -29,9 +29,10 @@ #include <ctype.h> #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; |