summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-01-02 20:35:35 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-02 21:17:41 -0800
commitcb53a7867486c89397f1f83eb89d19511ec215ae (patch)
tree39435bd19b8f1147c4a6cb969be609628755d490 /dive.h
parent5511a0e14efdb96c7622adf11185ea741cdb5226 (diff)
downloadsubsurface-cb53a7867486c89397f1f83eb89d19511ec215ae.tar.gz
Make our 'ascii_strtod()' helper more generic
We'll want to do sane parsing of strings, but the C library makes it hard to handle user input sanely and the Qt toDouble() function interface was designed by a retarded chipmunk. So just extend our existing hacky "ascii_strtod()" to allow a more generic interface. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/dive.h b/dive.h
index dab4409da..a0c22935f 100644
--- a/dive.h
+++ b/dive.h
@@ -618,7 +618,6 @@ struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset);
/* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */
extern int match_one_dc(struct divecomputer *a, struct divecomputer *b);
-extern double ascii_strtod(char *, char **);
extern void parse_xml_init(void);
extern void parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, const char **params, char **error);
extern void parse_xml_exit(void);
@@ -783,6 +782,19 @@ extern bool weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2);
extern void remove_cylinder(struct dive *dive, int idx);
extern void remove_weightsystem(struct dive *dive, int idx);
+/*
+ * String handling.
+ */
+#define STRTOD_NO_SIGN 0x01
+#define STRTOD_NO_DOT 0x02
+#define STRTOD_NO_COMMA 0x04
+#define STRTOD_NO_EXPONENT 0x08
+extern double strtod_flags(char *str, char **ptr, unsigned int flags);
+
+#define STRTOD_ASCII (STRTOD_NO_COMMA)
+
+#define ascii_strtod(str,ptr) strtod_flags(str,ptr,STRTOD_ASCII)
+
#ifdef __cplusplus
}
#endif