@@ -123,6 +123,7 @@ std::map<InputId, InputId> FlagAliases = {
123
123
};
124
124
125
125
std::map<Id, std::vector<Id>> Aliases; // original -> list of aliased
126
+ std::set<Id> AliasesAdded;
126
127
127
128
void AddAlias (const Id &original, const Id &aliased) {
128
129
auto &aliases = Aliases[original];
@@ -211,14 +212,16 @@ void append(Id &id, uint32 code) {
211
212
return {};
212
213
}
213
214
for (const auto color : Colors) {
214
- auto sameWithColor = BareIdFromInput (same);
215
- sameWithColor[1 ] = color;
216
- auto differentWithColor = BareIdFromInput (different);
217
- for (auto &entry : differentWithColor) {
215
+ auto copy = same;
216
+ copy[1 ] = color;
217
+ auto sameWithColor = BareIdFromInput (copy);
218
+ copy = different;
219
+ for (auto &entry : copy) {
218
220
if (entry == Colors[0 ] || entry == Colors[1 ]) {
219
221
entry = color;
220
222
}
221
223
}
224
+ auto differentWithColor = BareIdFromInput (copy);
222
225
AddAlias (sameWithColor, differentWithColor);
223
226
}
224
227
} else {
@@ -238,14 +241,16 @@ void append(Id &id, uint32 code) {
238
241
// original: 1
239
242
// add an alias to 'same' in the form of 'original + color'
240
243
for (const auto color : Colors) {
241
- auto originalWithColor = BareIdFromInput (original);
242
- originalWithColor.push_back (color);
243
- auto sameWithColor = BareIdFromInput (same);
244
- for (auto &entry : sameWithColor) {
244
+ auto copy = original;
245
+ copy.push_back (color);
246
+ auto originalWithColor = BareIdFromInput (copy);
247
+ copy = same;
248
+ for (auto &entry : copy) {
245
249
if (entry == ColorMask) {
246
250
entry = color;
247
251
}
248
252
}
253
+ auto sameWithColor = BareIdFromInput (copy);
249
254
AddAlias (originalWithColor, sameWithColor);
250
255
}
251
256
}
@@ -301,6 +306,7 @@ void appendCategory(
301
306
it = result.map .emplace (bareId, index ).first ;
302
307
result.list .push_back (move (emoji));
303
308
if (const auto a = Aliases.find (bareId); a != end (Aliases)) {
309
+ AliasesAdded.emplace (bareId);
304
310
for (const auto &alias : a->second ) {
305
311
const auto ok = result.map .emplace (alias, index ).second ;
306
312
if (!ok) {
@@ -365,6 +371,7 @@ void appendCategory(
365
371
} else if (const auto d = doubleVariatedIds.find (bareId); d != end (doubleVariatedIds)) {
366
372
// result.list[it->second].doubleVariated = true;
367
373
374
+ const auto baseId = bareId;
368
375
const auto &different = d->second ;
369
376
if (different.size () < 4
370
377
|| different[1 ] != Colors[0 ]
@@ -377,18 +384,18 @@ void appendCategory(
377
384
for (auto color2 : Colors) {
378
385
auto colored = Emoji ();
379
386
// colored.colored = true;
380
- // We filled those as aliases were applicable.
381
- // if (color1 == color2) {
382
- // colored.id = baseId ;
383
- // append(colored.id, color1);
384
- // } else {
385
- auto copy = different ;
386
- copy[1 ] = color1 ;
387
- copy[copy. size () - 1 ] = color2;
388
- for ( const auto code : copy) {
389
- append (colored. id , code);
387
+ if (color1 == color2 && baseId. size () == 2 ) {
388
+ colored. id = baseId;
389
+ append ( colored.id , color1) ;
390
+ } else {
391
+ auto copy = different;
392
+ copy[ 1 ] = color1 ;
393
+ copy[copy. size () - 1 ] = color2 ;
394
+ for ( const auto code : copy) {
395
+ append (colored. id , code);
396
+ }
390
397
}
391
- auto bareColoredId = BareIdFromInput (copy );
398
+ auto bareColoredId = colored. id . replace ( QChar ( kPostfix ), QString () );
392
399
if (addOne (bareColoredId, move (colored)) == result.map .end ()) {
393
400
return ;
394
401
}
@@ -711,6 +718,20 @@ Data PrepareData(const QString &dataPath, const std::vector<QString> &oldDataPat
711
718
if (result.list .empty ()) {
712
719
return Data ();
713
720
}
721
+ if (AliasesAdded.size () != Aliases.size ()) {
722
+ for (const auto &[key, list] : Aliases) {
723
+ if (AliasesAdded.find (key) == AliasesAdded.end ()) {
724
+ QStringList expanded;
725
+ for (const auto ch : key) {
726
+ expanded.push_back (QString::number (ch.unicode ()));
727
+ }
728
+ common::logError (kErrorBadData , " input" )
729
+ << " Bad data: Not added aliases list for: "
730
+ << expanded.join (QChar (' ,' )).toStdString ();
731
+ }
732
+ }
733
+ return Data ();
734
+ }
714
735
715
736
fillReplaces (result);
716
737
if (result.list .empty ()) {
0 commit comments