From d3580c906471273ff6e960f595b7baf43fe69a0b Mon Sep 17 00:00:00 2001 From: satbaby Date: Sat, 9 Oct 2010 13:15:42 +0000 Subject: [PATCH] -add compare bouquetname withoutspace git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@828 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/zapit/src/bouquets.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index fbc35643c..80c3c2682 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -530,16 +530,32 @@ void CBouquetManager::deleteBouquet(const CZapitBouquet* bouquet) } } } + +int str_compare_withoutspace(char const *s1, char const *s2) +{ + int cmp_result = 0; + while(isspace(*s1)) ++s1; + while(isspace(*s2)) ++s2; + + while(!cmp_result && *s1++ && *s2++){ + while(isspace(*s1)) ++s1; + while(isspace(*s2)) ++s2; + cmp_result = tolower(*s1) - tolower(*s2); + } + return cmp_result; +} // -- Find Bouquet-Name, if BQ exists (2002-04-02 rasc) // -- Return: Bouqet-ID (found: 0..n) or -1 (Bouquet does not exist) int CBouquetManager::existsBouquet(char const * const name) { unsigned int i; - for (i = 0; i < Bouquets.size(); i++) { if (Bouquets[i]->Name == name) + { return (int)i; - else if (strcasecmp(Bouquets[i]->Name.c_str(), name)==0){ + } + else if (strcasecmp(Bouquets[i]->Name.c_str(), name)==0) + { int lower1 = 0, lower2 = 0; int upper1 = 0 ,upper2 = 0; std::string str2 = name; @@ -568,6 +584,12 @@ int CBouquetManager::existsBouquet(char const * const name) Bouquets[i]->Name = str2; } return (int)i; + }else if(!(str_compare_withoutspace(Bouquets[i]->Name.c_str(), name)) ) + { + if(strlen(name) > Bouquets[i]->Name.length()){ + Bouquets[i]->Name = name; + } + return (int)i; } } return -1;