[libgweather/wip/muktupavels/fix-metar-data] weather-metar: properly extract metar data
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/muktupavels/fix-metar-data] weather-metar: properly extract metar data
- Date: Tue, 24 Apr 2018 16:56:09 +0000 (UTC)
commit 7fe646225fcb98d3a09c712976810edfd747451b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Apr 24 19:38:18 2018 +0300
weather-metar: properly extract metar data
Commit 283afc2d23355def1c1bab70a641f40cea52ba7f switched to new
METAR data provider, but did not fully update code to properly
extract METAR data.
The code still assumes that data are separated by newlines. That
means that now extracted data includes part of opening raw_text
tag, location code and closing raw_text tag.
Fix this by moving pointer to correct position to make sure that
xml tag and location code is not included. Also search for
closing tag to exclude it from data.
Before:
ext>EVRA 241450Z 22011KT 9999 -SHRA SCT034CB OVC039 11/05 Q1005 NOSIG</raw_text>\u000d
After:
241450Z 22011KT 9999 -SHRA SCT034CB OVC039 11/05 Q1005 NOSIG
libgweather/weather-metar.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c
index 31ef815..4bcd079 100644
--- a/libgweather/weather-metar.c
+++ b/libgweather/weather-metar.c
@@ -592,8 +592,8 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
p = strstr (msg->response_body->data, searchkey);
g_free (searchkey);
if (p) {
- p += WEATHER_LOCATION_CODE_LEN + 2;
- eoln = strchr(p, '\n');
+ p += 10 + WEATHER_LOCATION_CODE_LEN + 1;
+ eoln = strstr (p, "</raw_text>");
if (eoln)
metar = g_strndup (p, eoln - p);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]