Skip to content

Commit 2cb7572

Browse files
committed
metar: fix indent somewhat
1 parent 659c9bc commit 2cb7572

File tree

1 file changed

+88
-88
lines changed

1 file changed

+88
-88
lines changed

libmateweather/weather-metar.c

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ make_time (gint utcDate, gint utcHour, gint utcMin)
5656
* 24 hrs old! */
5757
if ((utcDate > tm.tm_mday) && (tm.tm_mday == 1)) {
5858
tm.tm_mday = 0; /* mktime knows this is the last day of the previous
59-
* month. */
59+
* month. */
6060
} else {
6161
tm.tm_mday = utcDate;
6262
}
@@ -102,15 +102,15 @@ metar_tok_wind (gchar *tokp, WeatherInfo *info)
102102
gustp = strchr (tokp, 'G');
103103
if (gustp) {
104104
memset (sgust, 0, sizeof (sgust));
105-
glen = strspn (gustp + 1, CONST_DIGITS);
105+
glen = strspn (gustp + 1, CONST_DIGITS);
106106
strncpy (sgust, gustp + 1, glen);
107-
tokp = gustp + 1 + glen;
107+
tokp = gustp + 1 + glen;
108108
}
109109

110110
if (!strcmp (tokp, "MPS"))
111-
info->windspeed = WINDSPEED_MS_TO_KNOTS ((WeatherWindSpeed)spd);
111+
info->windspeed = WINDSPEED_MS_TO_KNOTS ((WeatherWindSpeed)spd);
112112
else
113-
info->windspeed = (WeatherWindSpeed)spd;
113+
info->windspeed = (WeatherWindSpeed)spd;
114114

115115
if ((349 <= dir) || (dir <= 11))
116116
info->wind = WIND_N;
@@ -163,33 +163,33 @@ metar_tok_vis (gchar *tokp, WeatherInfo *info)
163163
// US observation: field ends with "SM"
164164
pfrac = strchr (tokp, '/');
165165
if (pfrac) {
166-
if (*tokp == 'M') {
167-
info->visibility = 0.001;
168-
} else {
169-
num = (*(pfrac - 1) - '0');
170-
strncpy (sval, pfrac + 1, pend - pfrac - 1);
171-
den = atoi (sval);
172-
info->visibility =
173-
((WeatherVisibility)num / ((WeatherVisibility)den));
174-
175-
psp = strchr (tokp, ' ');
176-
if (psp) {
177-
*psp = '\0';
178-
val = atoi (tokp);
179-
info->visibility += (WeatherVisibility)val;
180-
}
181-
}
182-
} else {
183-
strncpy (sval, tokp, pend - tokp);
166+
if (*tokp == 'M') {
167+
info->visibility = 0.001;
168+
} else {
169+
num = (*(pfrac - 1) - '0');
170+
strncpy (sval, pfrac + 1, pend - pfrac - 1);
171+
den = atoi (sval);
172+
info->visibility =
173+
((WeatherVisibility)num / ((WeatherVisibility)den));
174+
175+
psp = strchr (tokp, ' ');
176+
if (psp) {
177+
*psp = '\0';
178+
val = atoi (tokp);
179+
info->visibility += (WeatherVisibility)val;
180+
}
181+
}
182+
} else {
183+
strncpy (sval, tokp, pend - tokp);
184184
val = atoi (sval);
185185
info->visibility = (WeatherVisibility)val;
186-
}
186+
}
187187
} else {
188188
// International observation: NNNN(DD NNNNDD)?
189189
// For now: use only the minimum visibility and ignore its direction
190190
strncpy (sval, tokp, strspn (tokp, CONST_DIGITS));
191-
val = atoi (sval);
192-
info->visibility = (WeatherVisibility)val / VISIBILITY_SM_TO_M (1.);
191+
val = atoi (sval);
192+
info->visibility = (WeatherVisibility)val / VISIBILITY_SM_TO_M (1.);
193193
}
194194
}
195195

@@ -261,12 +261,12 @@ metar_tok_temp (gchar *tokp, WeatherInfo *info)
261261
pdew = psep + 1;
262262

263263
info->temp = (*ptemp == 'M') ? TEMP_C_TO_F (-atoi (ptemp + 1))
264-
: TEMP_C_TO_F (atoi (ptemp));
264+
: TEMP_C_TO_F (atoi (ptemp));
265265
if (*pdew) {
266-
info->dew = (*pdew == 'M') ? TEMP_C_TO_F (-atoi (pdew + 1))
267-
: TEMP_C_TO_F (atoi (pdew));
266+
info->dew = (*pdew == 'M') ? TEMP_C_TO_F (-atoi (pdew + 1))
267+
: TEMP_C_TO_F (atoi (pdew));
268268
} else {
269-
info->dew = -1000.0;
269+
info->dew = -1000.0;
270270
}
271271
}
272272

@@ -447,40 +447,40 @@ metar_parse (gchar *metar, WeatherInfo *info)
447447
*/
448448
if (0 != (p = strstr (metar, " RMK "))) {
449449
*p = '\0';
450-
//rmk = p + 5; // uncomment this if RMK data becomes useful
450+
//rmk = p + 5; // uncomment this if RMK data becomes useful
451451
}
452452

453453
p = metar;
454454
i = TIME_RE;
455455
while (*p) {
456456

457457
i2 = RE_NUM;
458-
rm2.rm_so = strlen (p);
459-
rm2.rm_eo = rm2.rm_so;
458+
rm2.rm_so = strlen (p);
459+
rm2.rm_eo = rm2.rm_so;
460460

461461
for (i = 0; i < RE_NUM && rm2.rm_so > 0; i++) {
462-
if (0 == regexec (&metar_re[i], p, 1, &rm, 0)
463-
&& rm.rm_so < rm2.rm_so)
464-
{
465-
i2 = i;
466-
/* Skip leading and trailing space characters, if present.
467-
(the regular expressions include those characters to
468-
only get matches limited to whole words). */
469-
if (p[rm.rm_so] == ' ') rm.rm_so++;
470-
if (p[rm.rm_eo - 1] == ' ') rm.rm_eo--;
471-
rm2.rm_so = rm.rm_so;
472-
rm2.rm_eo = rm.rm_eo;
473-
}
474-
}
475-
476-
if (i2 != RE_NUM) {
477-
tokp = g_strndup (p + rm2.rm_so, rm2.rm_eo - rm2.rm_so);
478-
metar_f[i2] (tokp, info);
479-
g_free (tokp);
480-
}
481-
482-
p += rm2.rm_eo;
483-
p += strspn (p, " ");
462+
if (0 == regexec (&metar_re[i], p, 1, &rm, 0)
463+
&& rm.rm_so < rm2.rm_so)
464+
{
465+
i2 = i;
466+
/* Skip leading and trailing space characters, if present.
467+
(the regular expressions include those characters to
468+
only get matches limited to whole words). */
469+
if (p[rm.rm_so] == ' ') rm.rm_so++;
470+
if (p[rm.rm_eo - 1] == ' ') rm.rm_eo--;
471+
rm2.rm_so = rm.rm_so;
472+
rm2.rm_eo = rm.rm_eo;
473+
}
474+
}
475+
476+
if (i2 != RE_NUM) {
477+
tokp = g_strndup (p + rm2.rm_so, rm2.rm_eo - rm2.rm_so);
478+
metar_f[i2] (tokp, info);
479+
g_free (tokp);
480+
}
481+
482+
p += rm2.rm_eo;
483+
p += strspn (p, " ");
484484
}
485485
return TRUE;
486486
}
@@ -497,15 +497,15 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
497497
g_return_if_fail (info != NULL);
498498

499499
if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
500-
if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code))
501-
info->network_error = TRUE;
502-
else {
503-
/* Translators: %d is an error code, and %s the error string */
504-
g_warning (_("Failed to get METAR data: %d %s.\n"),
505-
msg->status_code, msg->reason_phrase);
506-
}
507-
request_done (info, FALSE);
508-
return;
500+
if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code))
501+
info->network_error = TRUE;
502+
else {
503+
/* Translators: %d is an error code, and %s the error string */
504+
g_warning (_("Failed to get METAR data: %d %s.\n"),
505+
msg->status_code, msg->reason_phrase);
506+
}
507+
request_done (info, FALSE);
508+
return;
509509
}
510510

511511
loc = info->location;
@@ -514,20 +514,20 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
514514
p = strstr (msg->response_body->data, searchkey);
515515
g_free (searchkey);
516516
if (p) {
517-
p += WEATHER_LOCATION_CODE_LEN + 2;
518-
eoln = strchr(p, '\n');
519-
if (eoln)
520-
metar = g_strndup (p, eoln - p);
521-
else
522-
metar = g_strdup (p);
523-
success = metar_parse (metar, info);
524-
g_free (metar);
517+
p += WEATHER_LOCATION_CODE_LEN + 2;
518+
eoln = strchr(p, '\n');
519+
if (eoln)
520+
metar = g_strndup (p, eoln - p);
521+
else
522+
metar = g_strdup (p);
523+
success = metar_parse (metar, info);
524+
g_free (metar);
525525
} else if (!strstr (msg->response_body->data, "aviationweather.gov")) {
526-
/* The response doesn't even seem to have come from NOAA...
527-
* most likely it is a wifi hotspot login page. Call that a
528-
* network error.
529-
*/
530-
info->network_error = TRUE;
526+
/* The response doesn't even seem to have come from NOAA...
527+
* most likely it is a wifi hotspot login page. Call that a
528+
* network error.
529+
*/
530+
info->network_error = TRUE;
531531
}
532532

533533
info->valid = success;
@@ -545,20 +545,20 @@ metar_start_open (WeatherInfo *info)
545545
info->valid = info->network_error = FALSE;
546546
loc = info->location;
547547
if (loc == NULL) {
548-
g_warning (_("WeatherInfo missing location"));
549-
return;
548+
g_warning (_("WeatherInfo missing location"));
549+
return;
550550
}
551551

552552
msg = soup_form_request_new (
553-
"GET", "https://www.aviationweather.gov/adds/dataserver_current/httpparam",
554-
"dataSource", "metars",
555-
"requestType", "retrieve",
556-
"format", "xml",
557-
"hoursBeforeNow", "3",
558-
"mostRecent", "true",
559-
"fields", "raw_text",
560-
"stationString", loc->code,
561-
NULL);
553+
"GET", "https://www.aviationweather.gov/adds/dataserver_current/httpparam",
554+
"dataSource", "metars",
555+
"requestType", "retrieve",
556+
"format", "xml",
557+
"hoursBeforeNow", "3",
558+
"mostRecent", "true",
559+
"fields", "raw_text",
560+
"stationString", loc->code,
561+
NULL);
562562
soup_session_queue_message (info->session, msg, metar_finish, info);
563563

564564
info->requests_pending++;

0 commit comments

Comments
 (0)