]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
xmltv: Only parse number from display-name if config allows. (#4615)
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Mon, 25 Sep 2017 00:41:42 +0000 (01:41 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 25 Sep 2017 07:36:29 +0000 (09:36 +0200)
Earlier commit accidentally removed the check for configuration (chnum)
which means leading number would be stripped from xmltv names.

src/epggrab/module/xmltv.c

index 522f9698b1ab78e5800771e679290a0e63d95e2b..a519a54e79eb46a3598ca91168355949fa6ffae6 100644 (file)
@@ -662,38 +662,42 @@ static int _xmltv_parse_channel
     if (!(subtag = htsmsg_field_get_map(f))) continue;
     if (strcmp(f->hmf_name, "display-name") == 0) {
       name = htsmsg_get_str(subtag, "cdata");
-      int major = 0;
-      int minor = 0;
       const char *cur = name;
 
-      /* Some xmltv providers supply a display-name that is the
-       * channel number. So attempt to grab it.
-       */
+      if (chnum && cur) {
+        /* Some xmltv providers supply a display-name that is the
+         * channel number. So attempt to grab it.
+         * But only if chnum (enum meaning to process numbers).
+         */
 
-      /* Check and grab major part of channel number */
-      while (isdigit(*cur))
-        major = (major * 10) + *cur++ - '0';
+        int major = 0;
+        int minor = 0;
 
-      /* If a period then it's an atsc-style number of major.minor.
-       * So skip the period and parse the minor.
-       */
-      if (major && *cur == '.') {
-        ++cur;
+        /* Check and grab major part of channel number */
         while (isdigit(*cur))
-          minor = (minor * 10) + *cur++ - '0';
-      }
+          major = (major * 10) + *cur++ - '0';
+
+        /* If a period then it's an atsc-style number of major.minor.
+         * So skip the period and parse the minor.
+         */
+        if (major && *cur == '.') {
+          ++cur;
+          while (isdigit(*cur))
+            minor = (minor * 10) + *cur++ - '0';
+        }
 
-      /* If we have a channel number and then either end of string
-       * or (if chnum is 'first words') a space, then save the channel.
-       * The space is necessary to avoid channels such as "4Music"
-       * being treated as channel number 4.
-       *
-       * We assume channel number has to be >0.
-       */
-      if (major && (!*cur || (*cur == ' ' && chnum == 1))) {
-        save |= epggrab_channel_set_number(ch, major, minor);
-        /* Skip extra spaces between channel number and actual name */
-        while (*cur == ' ') ++cur;
+        /* If we have a channel number and then either end of string
+         * or (if chnum is 'first words') a space, then save the channel.
+         * The space is necessary to avoid channels such as "4Music"
+         * being treated as channel number 4.
+         *
+         * We assume channel number has to be >0.
+         */
+        if (major && (!*cur || (*cur == ' ' && chnum == 1))) {
+          save |= epggrab_channel_set_number(ch, major, minor);
+          /* Skip extra spaces between channel number and actual name */
+          while (*cur == ' ') ++cur;
+        }
       }
 
       if (cur && *cur)