File newsboat-2.10.2-json-c-size_t.patch of Package newsboat
From 0a94da8e729c55b61ba87233a789497276bb791e Mon Sep 17 00:00:00 2001
From: Alexander Batischev <eual.jp@gmail.com>
Date: Sun, 7 Jan 2018 18:22:48 +0300
Subject: [PATCH] Make it compile with json-c 0.13
json-c 0.13 changed the return type of array_list_length() from int to
size_t. We're now testing for version macros to figure out the version
we're building against, and adjust the types in our code accordingly.
Closes #98.
---
src/inoreader_api.cpp | 5 +++++
src/oldreader_api.cpp | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/inoreader_api.cpp b/src/inoreader_api.cpp
index d1b09894..a68fe485 100644
--- a/src/inoreader_api.cpp
+++ b/src/inoreader_api.cpp
@@ -136,7 +136,12 @@ std::vector<tagged_feedurl> inoreader_api::get_subscribed_urls() {
json_object_object_get_ex(sub, "categories", &node);
struct array_list * categories = json_object_get_array(node);
+
+#if JSON_C_MAJOR_VERSION == 0 && JSON_C_MINOR_VERSION < 13
for (int i = 0; i < array_list_length(categories); i++) {
+#else
+ for (size_t i = 0; i < array_list_length(categories); i++) {
+#endif
json_object* cat = json_object_array_get_idx(node, i);
json_object* label_node {};
json_object_object_get_ex(cat, "label", &label_node);
diff --git a/src/oldreader_api.cpp b/src/oldreader_api.cpp
index 7cdf0321..39fb3d2e 100644
--- a/src/oldreader_api.cpp
+++ b/src/oldreader_api.cpp
@@ -134,7 +134,11 @@ std::vector<tagged_feedurl> oldreader_api::get_subscribed_urls() {
json_object_object_get_ex(sub, "categories", &node);
struct array_list * categories = json_object_get_array(node);
- for (int i = 0; i < array_list_length(categories); i++) {
+#if JSON_C_MAJOR_VERSION == 0 && JSON_C_MINOR_VERSION < 13
+ for (int i = 0; i < array_list_length(categories); i++) {
+#else
+ for (size_t i = 0; i < array_list_length(categories); i++) {
+#endif
json_object* cat = json_object_array_get_idx(node, i);
json_object* label_node {};
json_object_object_get_ex(cat, "label", &label_node);