Skip to content

Commit

Permalink
Do not accept leftovers when parsing coords
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenc committed Aug 30, 2016
1 parent 62a1e77 commit 9f6bc07
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gp102-poi.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,19 @@ static int parse_one_coord(const char **pos, const char *mod, double *coord)
return 0;
}

static int parse_end(const char **pos)
{
skip_white(pos);
return !!(**pos);
}

static void parse_coords(const char *arg, double *lat, double *lon)
{
const char *pos = arg;

if (parse_one_coord(&pos, "NS", lat) ||
parse_one_coord(&pos, "EW", lon)) {
parse_one_coord(&pos, "EW", lon) ||
parse_end(&pos)) {
int i;

fprintf(stderr, "Error: cannot parse coordinates:\n");
Expand Down

0 comments on commit 9f6bc07

Please sign in to comment.