Strip trailing space from wttr.in weather descriptions. (0.40.6)
- Fixed trailing space in weather descriptions from wttr.in (e.g. 'Partly Cloudy ' -> 'Partly Cloudy'), which caused a stray space before the closing parenthesis in !forecast full output (e.g. '(Partly Cloudy )' instead of '(Partly Cloudy)'). - Applied the same trailing-space fix to the cond field used by non-full !forecast and !weather. - Updated CHANGELOG.md with 0.40.6 entry.
This commit is contained in:
parent
d4c1b7cfcf
commit
3b863d581d
4 changed files with 13 additions and 3 deletions
|
|
@ -34,7 +34,7 @@ static int parse_forecast_day(const char *p, const char *obj_end,
|
|||
if (hb && hb < obj_end) {
|
||||
hb++;
|
||||
const char *vb = strstr(hb, "\"value\": \"");
|
||||
if (vb && vb < obj_end) { vb += 9; const char *vq = strchr(vb, '"'); if (vq && vb < obj_end) { size_t l = vq - vb; if (l >= cond_sz) l = cond_sz - 1; memcpy(cond_out, vb, l); cond_out[l] = 0; } }
|
||||
if (vb && vb < obj_end) { vb += 9; const char *vq = strchr(vb, '"'); if (vq && vb < obj_end) { size_t l = vq - vb; if (l >= cond_sz) l = cond_sz - 1; memcpy(cond_out, vb, l); cond_out[l] = 0; while (l > 0 && cond_out[l-1] == ' ') cond_out[--l] = 0; } }
|
||||
}
|
||||
}
|
||||
return (date_out[0] != 0) ? 1 : 0;
|
||||
|
|
@ -258,7 +258,7 @@ char *fetch_forecast_full(const char *city_url, const char *city_display) {
|
|||
if (db && db < obj_end) {
|
||||
db++;
|
||||
char *vb = strstr(db, "\"value\": \"");
|
||||
if (vb && vb < obj_end) { vb += 10; char *vq = strchr(vb, '"'); if (vq && vq < obj_end) { size_t l = vq - vb; if (l > sizeof desc - 1) l = sizeof desc - 1; memcpy(desc, vb, l); desc[l] = 0; } }
|
||||
if (vb && vb < obj_end) { vb += 10; char *vq = strchr(vb, '"'); if (vq && vq < obj_end) { size_t l = vq - vb; if (l > sizeof desc - 1) l = sizeof desc - 1; memcpy(desc, vb, l); desc[l] = 0; while (l > 0 && desc[l-1] == ' ') desc[--l] = 0; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue