Correctly parse translated cardinal directions

We now compare to both the standard English characters ('N', 'E', etc) as
well as to the translated strings (_("N"), _("E")) when parsing GPS
strings.

Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-02-03 15:43:30 +11:00
parent 6fa9e02723
commit 9edde5ff28

12
info.c
View file

@ -401,9 +401,11 @@ static gboolean parse_gps_text(const char *gps_text, double *latitude, double *l
return TRUE; return TRUE;
} }
/* ok, let's parse by hand - first degrees of latitude */ /* ok, let's parse by hand - first degrees of latitude */
if (g_unichar_toupper(g_utf8_get_char(text)) == 'N') if (g_unichar_toupper(g_utf8_get_char(text)) == 'N' ||
!strncmp(text, _("N"), strlen(_("N"))))
text++; text++;
if (g_unichar_toupper(g_utf8_get_char(text)) == 'S') { if (g_unichar_toupper(g_utf8_get_char(text)) == 'S' ||
!strncmp(text, _("S"), strlen(_("S")))) {
text++; text++;
south = TRUE; south = TRUE;
} }
@ -433,9 +435,11 @@ static gboolean parse_gps_text(const char *gps_text, double *latitude, double *l
text = g_utf8_next_char(text); text = g_utf8_next_char(text);
/* next degrees of longitude */ /* next degrees of longitude */
if (g_unichar_toupper(g_utf8_get_char(text)) == 'E') if (g_unichar_toupper(g_utf8_get_char(text)) == 'E' ||
!strncmp(text, _("E"), strlen(_("E"))))
text++; text++;
if (g_unichar_toupper(g_utf8_get_char(text)) == 'W') { if (g_unichar_toupper(g_utf8_get_char(text)) == 'W' ||
!strncmp(text, _("W"), strlen(_("W")))) {
text++; text++;
west = TRUE; west = TRUE;
} }