diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-04-16 21:40:03 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-05-11 12:35:11 -0700 |
commit | 6586ba5579dbe4eb360bc646572e58350d12bffb (patch) | |
tree | 996d1a6fb867f17d52d284b404522cf5d7f2fe40 /core/parse-xml.c | |
parent | ae6f17af0c15ec3d9907a4ba9ca8846dbb0e2721 (diff) | |
download | subsurface-6586ba5579dbe4eb360bc646572e58350d12bffb.tar.gz |
Cleanup: move parse_location() declaration into header file
The parse_location() function was used in three places. In two
of them, the declaration was in the translation unit. Instead,
move the declaration into a header file, to avoid duplication
and the possibility of inconsistencies.
The "units.h" header was chosen as this is where location_t
is defined.
Moreover, make the string argument to parse_location() "const
char *", so that it can be used on non-owned buffers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/parse-xml.c')
-rw-r--r-- | core/parse-xml.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c index d3ee13b57..483614c6e 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -1088,7 +1088,7 @@ static int uddf_dive_match(struct dive *dive, const char *name, char *buf, struc * We don't do exponentials etc, if somebody does * GPS locations in that format, they are insane. */ -static degrees_t parse_degrees(char *buf, char **end) +static degrees_t parse_degrees(const char *buf, const char **end) { int sign = 1, decimals = 6, value = 0; degrees_t ret; @@ -1133,7 +1133,7 @@ static degrees_t parse_degrees(char *buf, char **end) static void gps_lat(char *buffer, struct dive *dive, struct parser_state *state) { - char *end; + const char *end; location_t location = { }; struct dive_site *ds = get_dive_site_for_dive(dive); @@ -1149,7 +1149,7 @@ static void gps_lat(char *buffer, struct dive *dive, struct parser_state *state) static void gps_long(char *buffer, struct dive *dive, struct parser_state *state) { - char *end; + const char *end; location_t location = { }; struct dive_site *ds = get_dive_site_for_dive(dive); @@ -1164,9 +1164,9 @@ static void gps_long(char *buffer, struct dive *dive, struct parser_state *state } /* We allow either spaces or a comma between the decimal degrees */ -void parse_location(char *buffer, location_t *loc) +void parse_location(const char *buffer, location_t *loc) { - char *end; + const char *end; loc->lat = parse_degrees(buffer, &end); if (*end == ',') end++; loc->lon = parse_degrees(end, &end); |