From 5f808eab5cdff7011a591ae4a1ccc8906c33d4ae Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 24 Aug 2023 10:35:54 +0000 Subject: [PATCH] libgweather: push NWS segfault fix upstream --- pkgs/patched/libgweather/default.nix | 9 +++- .../nws-fix-null-string-comparison.patch | 49 ------------------- 2 files changed, 7 insertions(+), 51 deletions(-) delete mode 100644 pkgs/patched/libgweather/nws-fix-null-string-comparison.patch diff --git a/pkgs/patched/libgweather/default.nix b/pkgs/patched/libgweather/default.nix index e2bcbdd3..08e60c07 100644 --- a/pkgs/patched/libgweather/default.nix +++ b/pkgs/patched/libgweather/default.nix @@ -1,13 +1,18 @@ { lib , libgweather +, fetchpatch , ... }@attrs: (libgweather.override - (removeAttrs attrs [ "libgweather" ]) + (removeAttrs attrs [ "fetchpatch" "libgweather" ]) ).overrideAttrs (upstream: { patches = lib.unique ( (upstream.patches or []) ++ [ - ./nws-fix-null-string-comparison.patch + (fetchpatch { + url = "https://gitlab.gnome.org/GNOME/libgweather/-/merge_requests/282.patch"; + name = "nws: fix null string comparison when reading visibility"; + hash = "sha256-2sfRVvVbUL8jCSuZXlZxs5VYFJlRmFjwL1L6oF0zGo8="; + }) ] ); }) diff --git a/pkgs/patched/libgweather/nws-fix-null-string-comparison.patch b/pkgs/patched/libgweather/nws-fix-null-string-comparison.patch deleted file mode 100644 index 267cb5b0..00000000 --- a/pkgs/patched/libgweather/nws-fix-null-string-comparison.patch +++ /dev/null @@ -1,49 +0,0 @@ -commit 29b80763f81688f789c907f7ecba4c8063745ac2 (HEAD -> sane-dev) -Author: Colin -Date: 2023-08-24 08:03:47 +0000 - - nws: fix null string comparison for visibility forecast - - The API returns a json entry like `"unitCode": "wmoUnit:km"` for the - visibility property. All the other fields are observed to still be - "uom". - -diff --git a/libgweather/weather-nws.c b/libgweather/weather-nws.c -index 2a7238b9..501c3523 100644 ---- a/libgweather/weather-nws.c -+++ b/libgweather/weather-nws.c -@@ -381,6 +381,9 @@ read_interval_values (GSList *forecast_list, - uom = NULL; - if (json_object_has_member (prop, "uom")) { - uom = json_object_get_string_member (prop, "uom"); -+ } else if (json_object_has_member (prop, "unitCode")) { -+ // The "visibility" property in forecasts uses this unique key for the unit -+ uom = json_object_get_string_member (prop, "unitCode"); - } - - read_value = (*select_read_value) (uom); -@@ -776,6 +779,12 @@ read_visibility_m (GWeatherInfo *info, JsonNode *node) - info->visibility = json_node_get_double (node) / VISIBILITY_SM_TO_M (1.); - } - -+static void -+read_visibility_km (GWeatherInfo *info, JsonNode *node) -+{ -+ info->visibility = json_node_get_double (node) / VISIBILITY_SM_TO_KM (1.); -+} -+ - static void - read_visibility_sm (GWeatherInfo *info, JsonNode *node) - { -@@ -785,8 +794,10 @@ read_visibility_sm (GWeatherInfo *info, JsonNode *node) - static ValueReader - select_read_visibility (const gchar *uom) - { -- if (strcmp (uom, "wmoUnit:m") == 0) { -+ if (uom != NULL && strcmp (uom, "wmoUnit:m") == 0) { - return read_visibility_m; -+ } else if (uom != NULL && strcmp (uom, "wmoUnit:km") == 0) { -+ return read_visibility_km; - } - return read_visibility_sm; - }