diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-04 16:12:15 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-04 16:12:15 +0200 |
commit | 3bcdd28a6a42d810523d30b30e9ccf880e2b0ca1 (patch) | |
tree | f68e09d120e76df41c08b4e20481024e742b0c0d /libcontacts_parse_contact.c | |
parent | m (diff) | |
download | libcontacts-3bcdd28a6a42d810523d30b30e9ccf880e2b0ca1.tar.gz libcontacts-3bcdd28a6a42d810523d30b30e9ccf880e2b0ca1.tar.bz2 libcontacts-3bcdd28a6a42d810523d30b30e9ccf880e2b0ca1.tar.xz |
Reorder libcontacts_address and fix coord parsing
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libcontacts_parse_contact.c')
-rw-r--r-- | libcontacts_parse_contact.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libcontacts_parse_contact.c b/libcontacts_parse_contact.c index 3cfd54e..8970afd 100644 --- a/libcontacts_parse_contact.c +++ b/libcontacts_parse_contact.c @@ -137,7 +137,7 @@ parse_coord(char *s, double *lat, double *lon) errno = 0; withsign = (s[0] == '-' || s[0] == '+'); - if (s[withsign] != '.' || isdigit(s[withsign])) + if (s[withsign] != '.' && !isdigit(s[withsign])) goto bad; *lat = strtod(s, &s); if (errno) @@ -150,9 +150,10 @@ parse_coord(char *s, double *lat, double *lon) if (s[0] != ' ') goto bad; + s = &s[1]; withsign = (s[0] == '-' || s[0] == '+'); - if (s[withsign] != '.' || isdigit(s[withsign])) + if (s[withsign] != '.' && !isdigit(s[withsign])) goto bad; *lon = strtod(s, &s); if (errno) @@ -347,9 +348,9 @@ libcontacts_parse_contact(char *data, struct libcontacts_contact *contact) if (!(contact->addresses[i]->city = strdup(getstr(p)))) goto fail; } else if (TEST(unindent(p), "COORD") && !contact->addresses[i]->have_coordinates) { - if (parse_coord(getstr(p), - &contact->addresses[i]->latitude, - &contact->addresses[i]->longitude)) { + if (!parse_coord(getstr(p), + &contact->addresses[i]->latitude, + &contact->addresses[i]->longitude)) { contact->addresses[i]->have_coordinates = 1; } else { if (addstr(&contact->addresses[i]->unrecognised_data, unindent(p))) |