diff --git a/mythtv/programs/mythfilldatabase/xmltvparser.cpp b/mythtv/programs/mythfilldatabase/xmltvparser.cpp index 4807a636d88..20230d2345c 100644 --- a/mythtv/programs/mythfilldatabase/xmltvparser.cpp +++ b/mythtv/programs/mythfilldatabase/xmltvparser.cpp @@ -30,22 +30,24 @@ XMLTVParser::XMLTVParser() : isJapan(false), current_year(0) current_year = QDate::currentDate().toString("yyyy").toUInt(); } -static unsigned int ELFHash(const char *s) +static uint ELFHash(const QByteArray &ba) { - /* ELF hash uses unsigned chars and unsigned arithmetic for portability */ - const unsigned char *name = (const unsigned char *)s; - unsigned long h = 0, g; + const uchar *k = (const uchar *)ba.data(); + uint h = 0; + uint g; - while (*name) + if (k) { - h = (h << 4) + (unsigned long)(*name++); - if ((g = (h & 0xF0000000UL))!=0) - h ^= (g >> 24); - h &= ~g; - + while (*k) + { + h = (h << 4) + *k++; + if ((g = (h & 0xf0000000)) != 0) + h ^= g >> 24; + h &= ~g; + } } - return (int)h; + return h; } static QString getFirstText(QDomElement element) @@ -533,8 +535,7 @@ ProgInfo *XMLTVParser::parseProgram( programid.append(uniqueid); else { - QString seriesid = QString::number(ELFHash(pginfo->title.toUtf8() - .constData())); + QString seriesid = QString::number(ELFHash(pginfo->title.toUtf8())); pginfo->seriesId = seriesid; programid.append(seriesid);