Index: binaries/data/mods/public/gui/credits/texts/programming.json =================================================================== --- binaries/data/mods/public/gui/credits/texts/programming.json +++ binaries/data/mods/public/gui/credits/texts/programming.json @@ -72,6 +72,7 @@ {"nick": "dvangennip", "name": "Doménique"}, {"nick": "Echelon9", "name": "Rhys Kidd"}, {"nick": "echotangoecho"}, + {"nick": "eecsninja", "name": "Simon Que"}, {"nick": "eihrul", "name": "Lee Salzman"}, {"nick": "elexis", "name": "Alexander Heinsius"}, {"nick": "EmjeR", "name": "Matthijs de Rijk"}, Index: source/tools/atlas/AtlasObject/AtlasObjectXML.cpp =================================================================== --- source/tools/atlas/AtlasObject/AtlasObjectXML.cpp +++ source/tools/atlas/AtlasObject/AtlasObjectXML.cpp @@ -57,18 +57,14 @@ else bytesToWrite = 3, ch = 0xFFFD; // replacement character char buf[4]; - char* target = &buf[bytesToWrite]; - // GCC sometimes warns "array subscript is above array bounds [-Warray-bounds]" - // for the above line, which is a false positive - the C++ standard allows a - // pointer to just after the last element in an array, as long as it's not - // dereferenced (which it isn't here) - switch (bytesToWrite) - { - case 4: *--target = ((ch | 0x80) & 0xBF); ch >>= 6; - case 3: *--target = ((ch | 0x80) & 0xBF); ch >>= 6; - case 2: *--target = ((ch | 0x80) & 0xBF); ch >>= 6; - case 1: *--target = (char)(ch | firstByteMark[bytesToWrite]); + char* target = buf + bytesToWrite - 1; + const char* const endTarget = &buf[0]; + while (target > endTarget) { + char chByte = ch & 0x3F; + ch >>= 6; + *target-- = (chByte | 0x80); } + *target = ((char)ch) | firstByteMark[bytesToWrite]; data += std::string(buf, bytesToWrite); } } @@ -90,16 +86,12 @@ { unsigned long ch = 0; int extraBytesToRead = trailingBytesForUTF8[*source]; - assert(source + extraBytesToRead < sourceEnd); - switch (extraBytesToRead) - { - case 5: ch += *source++; ch <<= 6; - case 4: ch += *source++; ch <<= 6; - case 3: ch += *source++; ch <<= 6; - case 2: ch += *source++; ch <<= 6; - case 1: ch += *source++; ch <<= 6; - case 0: ch += *source++; + + const xmlChar* const readEnd = source + 1 + extraBytesToRead; + while (source < readEnd) { + ch = (ch << 6) + *source++; } + ch -= offsetsFromUTF8[extraBytesToRead]; // Make sure it fits in a 16-bit wchar_t if (ch > 0xFFFF)