commit 754aa07571271a7f01400d8957477858260ca51a
Author: Stuart Morgan <smorgan@mythtv.org>
Date: Wed Mar 14 21:32:14 2012 +0000
Use the same version of ELFHash as QT does in qlinguist/qrelease, this version involves fewer casts and less chance of losing data in the process.
diff --git a/mythtv/programs/mythfilldatabase/xmltvparser.cpp b/mythtv/programs/mythfilldatabase/xmltvparser.cpp
index 8b5b562..20230d2 100644
a
|
b
|
XMLTVParser::XMLTVParser() : isJapan(false), current_year(0) |
30 | 30 | current_year = QDate::currentDate().toString("yyyy").toUInt(); |
31 | 31 | } |
32 | 32 | |
33 | | static unsigned int ELFHash(const char *s) |
| 33 | static uint ELFHash(const QByteArray &ba) |
34 | 34 | { |
35 | | /* ELF hash uses unsigned chars and unsigned arithmetic for portability */ |
36 | | const unsigned char *name = (const unsigned char *)s; |
37 | | unsigned long h = 0, g; |
| 35 | const uchar *k = (const uchar *)ba.data(); |
| 36 | uint h = 0; |
| 37 | uint g; |
38 | 38 | |
39 | | while (*name) |
| 39 | if (k) |
40 | 40 | { |
41 | | h = (h << 4) + (unsigned long)(*name++); |
42 | | if ((g = (h & 0xF0000000UL))!=0) |
43 | | h ^= (g >> 24); |
44 | | h &= ~g; |
45 | | |
| 41 | while (*k) |
| 42 | { |
| 43 | h = (h << 4) + *k++; |
| 44 | if ((g = (h & 0xf0000000)) != 0) |
| 45 | h ^= g >> 24; |
| 46 | h &= ~g; |
| 47 | } |
46 | 48 | } |
47 | 49 | |
48 | | return (int)h; |
| 50 | return h; |
49 | 51 | } |
50 | 52 | |
51 | 53 | static QString getFirstText(QDomElement element) |
… |
… |
ProgInfo *XMLTVParser::parseProgram( |
533 | 535 | programid.append(uniqueid); |
534 | 536 | else |
535 | 537 | { |
536 | | QString seriesid = QString::number(ELFHash(pginfo->title.toLocal8Bit() |
537 | | .constData())); |
| 538 | QString seriesid = QString::number(ELFHash(pginfo->title.toUtf8())); |
538 | 539 | pginfo->seriesId = seriesid; |
539 | 540 | programid.append(seriesid); |
540 | 541 | |