diff -Naur kopete-0.12.2/kopete/libkopete/private/kopeteemoticons.cpp kopete-changed/kopete/libkopete/private/kopeteemoticons.cpp --- kopete-0.12.2/kopete/libkopete/private/kopeteemoticons.cpp 2006-08-12 02:51:47.000000000 +0200 +++ kopete-changed/kopete/libkopete/private/kopeteemoticons.cpp 2006-09-13 07:20:28.000000000 +0200 @@ -48,6 +48,8 @@ struct Emoticons::Emoticon { Emoticon(){} + /* sort by longest to shortest matchText */ + bool operator< (const Emoticon &e){ return matchText.length() > e.matchText.length(); } QString matchText; QString matchTextEscaped; QString picPath; @@ -424,6 +426,7 @@ node = node.nextSibling(); } mapFile.close(); + sortEmoticons(); } @@ -492,9 +495,24 @@ node = node.nextSibling(); } mapFile.close(); + sortEmoticons(); } +void Emoticons::sortEmoticons() +{ + /* sort strings in order of longest to shortest to provide convenient input for + greedy matching in the tokenizer */ + QValueList keys = d->emoticonMap.keys(); + for ( QValueList::const_iterator it = keys.begin(); it != keys.end(); ++it ) + { + QChar key = (*it); + QValueList keyValues = d->emoticonMap[key]; + qHeapSort(keyValues.begin(), keyValues.end()); + d->emoticonMap[key] = keyValues; + } +} + diff -Naur kopete-0.12.2/kopete/libkopete/private/kopeteemoticons.h kopete-changed/kopete/libkopete/private/kopeteemoticons.h --- kopete-0.12.2/kopete/libkopete/private/kopeteemoticons.h 2006-08-12 02:51:47.000000000 +0200 +++ kopete-changed/kopete/libkopete/private/kopeteemoticons.h 2006-09-13 07:19:17.000000000 +0200 @@ -156,6 +156,12 @@ * @see initEmoticons */ void initEmoticon_JEP0038( const QString & filename); + + /** + * sorts emoticons for convenient parsing, which yields greedy matching on + * matchText + */ + void sortEmoticons(); struct Emoticon;