From 0b686fe0c360dc882c0fd946e7da14f94f0ad2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Sun, 7 Oct 2012 19:35:30 +0300 Subject: Fix prepending and appending to empty EPG fields. --- po/fi_FI.po | 2 +- regexp.c | 45 +++++++++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/po/fi_FI.po b/po/fi_FI.po index 435193a..2e969b3 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: vdr-epgfixer 0.2.0\n" +"Project-Id-Version: vdr-epgfixer 0.2.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-08-14 13:49+0300\n" "PO-Revision-Date: 2012-05-09 23:20+0300\n" diff --git a/regexp.c b/regexp.c index bf446f3..4631cbd 100644 --- a/regexp.c +++ b/regexp.c @@ -252,32 +252,41 @@ bool cRegexp::Apply(cEvent *Event) while (i < 10) { if (pcre_get_named_substring(re, tmpstring, ovector, rc, strBackrefs[i], &string) != PCRE_ERROR_NOSUBSTRING) { switch (i) { - case TITLE: - Event->SetTitle(string); - break; case ATITLE: - Event->SetTitle(*cString::sprintf("%s %s", Event->Title(), string)); - break; case PTITLE: - Event->SetTitle(*cString::sprintf("%s %s", string, Event->Title())); - break; - case SHORTTEXT: - Event->SetShortText(string); + if (Event->Title()) { + if (i == ATITLE) + Event->SetTitle(*cString::sprintf("%s %s", Event->Title(), string)); + else + Event->SetTitle(*cString::sprintf("%s %s", string, Event->Title())); + break; + } + case TITLE: + Event->SetTitle(string); break; case ASHORTTEXT: - Event->SetShortText(*cString::sprintf("%s %s", Event->ShortText(), string)); - break; case PSHORTTEXT: - Event->SetShortText(*cString::sprintf("%s %s", string, Event->ShortText())); - break; - case DESCRIPTION: - Event->SetDescription(string); + if (Event->ShortText()) { + if (i == ASHORTTEXT) + Event->SetShortText(*cString::sprintf("%s %s", Event->ShortText(), string)); + else + Event->SetShortText(*cString::sprintf("%s %s", string, Event->ShortText())); + break; + } + case SHORTTEXT: + Event->SetShortText(string); break; case ADESCRIPTION: - Event->SetDescription(*cString::sprintf("%s %s", Event->Description(), string)); - break; case PDESCRIPTION: - Event->SetDescription(*cString::sprintf("%s %s", string, Event->Description())); + if (Event->Description()) { + if (i == ADESCRIPTION) + Event->SetDescription(*cString::sprintf("%s %s", Event->Description(), string)); + else + Event->SetDescription(*cString::sprintf("%s %s", string, Event->Description())); + break; + } + case DESCRIPTION: + Event->SetDescription(string); break; case RATING: Event->SetParentalRating(atoi(string)); -- cgit v1.2.3