]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
xmltv: rewrite APPENDIT() macro to xmltv_appedit() fcn
authorJaroslav Kysela <perex@perex.cz>
Fri, 7 Sep 2018 08:06:00 +0000 (10:06 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 7 Sep 2018 08:06:00 +0000 (10:06 +0200)
src/epggrab/module/xmltv.c

index 224ea52325e9b695b8c5180c9ecb5ff4a0bf9d8e..53e0acf545ac039837f05f45c261b99f42aa6be9 100644 (file)
@@ -595,6 +595,25 @@ _xmltv_parse_credits(htsmsg_t **out_credits, htsmsg_t *tags)
   return credits_names;
 }
 
+/*
+ * Convert the string list to a human-readable csv and append
+ * it to the desc with a prefix of name.
+ */
+static void xmltv_appendit(lang_str_t *desc, string_list_t *list, const char *name)
+{
+  if (!list) return;
+  char *str = string_list_2_csv(list, ',', 1);
+  if (str) {
+    lang_str_ele_t *e;
+    RB_FOREACH(e, desc, link) {
+      lang_str_append(desc, "\n\n", e->lang);
+      lang_str_append(desc, tvh_gettext_lang(e->lang, name), e->lang);
+      lang_str_append(desc, str, e->lang);
+    }
+    free(str);
+  }
+}
+
 /**
  * Parse tags inside of a programme
  */
@@ -654,22 +673,6 @@ static int _xmltv_parse_programme_tags
     if (scrape_extra && keyword)
       save |= epg_broadcast_set_keyword(ebc, keyword, &changes);
 
-    /* Convert the string list VAR to a human-readable csv and append
-     * it to the desc with a prefix of NAME.
-     */
-#define APPENDIT(VAR,NAME) \
-    if (VAR) { \
-      char *str = string_list_2_csv((VAR), ',', 1);                            \
-      if (str) {                                                               \
-        lang_str_ele_t *e;                                                     \
-        RB_FOREACH(e, desc, link) {                                            \
-          lang_str_append(desc, "\n\n", e->lang);                              \
-          lang_str_append(desc, tvh_gettext_lang(e->lang, (NAME)), e->lang);   \
-          lang_str_append(desc, str, e->lang);                                 \
-        }                                                                      \
-        free(str);                                                             \
-      }                                                                                \
-    }
 
     /* Append the details on to the description, mainly for legacy
      * clients. This allow you to view the details in the description
@@ -677,9 +680,9 @@ static int _xmltv_parse_programme_tags
      * don't display them.
      */
     if (desc && scrape_onto_desc) {
-      APPENDIT(credits_names, N_("Credits: "));
-      APPENDIT(category, N_("Categories: "));
-      APPENDIT(keyword, N_("Keywords: "));
+      xmltv_appendit(desc, credits_names, N_("Credits: "));
+      xmltv_appendit(desc, category, N_("Categories: "));
+      xmltv_appendit(desc, keyword, N_("Keywords: "));
     }
 
     if (credits)          htsmsg_destroy(credits);