Package: grcompiler Version: 5.2-2 Severity: normal Tags: patch pending
Dear maintainer, Bastian Germann <bastiangerm...@fishpost.de> has prepared an NMU [1] for grcompiler (versioned as 5.2-2.1) and uploaded it to DELAYED/5. Please feel free to tell me if I should delay it longer. Regards. [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=969910 -- tobi
diff -Nru grcompiler-5.2/debian/changelog grcompiler-5.2/debian/changelog --- grcompiler-5.2/debian/changelog 2020-08-16 11:41:30.000000000 +0200 +++ grcompiler-5.2/debian/changelog 2020-09-08 17:44:40.000000000 +0200 @@ -1,3 +1,12 @@ +grcompiler (5.2-2.1) unstable; urgency=medium + + * Non-maintainer upload. + * Add upstream patches for big endian (Closes: #961445) + * Add upstream patch for font names (Closes: #961438) + * d/copyright: Add missing Upstream-Contact + + -- Bastian Germann <bastiangerm...@fishpost.de> Tue, 08 Sep 2020 17:44:40 +0200 + grcompiler (5.2-2) unstable; urgency=medium * Team upload diff -Nru grcompiler-5.2/debian/copyright grcompiler-5.2/debian/copyright --- grcompiler-5.2/debian/copyright 2020-08-16 11:41:30.000000000 +0200 +++ grcompiler-5.2/debian/copyright 2020-09-08 17:44:22.000000000 +0200 @@ -1,5 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: GrCompiler +Upstream-Contact: silgraphite-de...@lists.sourceforge.net Source: https://github.com/silnrsi/grcompiler License: LGPL-2.1+ or CPL-0.5+ diff -Nru grcompiler-5.2/debian/patches/0001-Build-with-system-s-LZ4.patch grcompiler-5.2/debian/patches/0001-Build-with-system-s-LZ4.patch --- grcompiler-5.2/debian/patches/0001-Build-with-system-s-LZ4.patch 2020-08-16 11:41:30.000000000 +0200 +++ grcompiler-5.2/debian/patches/0001-Build-with-system-s-LZ4.patch 1970-01-01 01:00:00.000000000 +0100 @@ -1,59 +0,0 @@ -From: Bastian Germann <bastiangerm...@fishpost.de> -Date: Thu, 21 May 2020 11:32:59 +0200 -Description: Build with system's LZ4 ---- -diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt -index dcc7f2d..deb50c7 100644 ---- a/compiler/CMakeLists.txt -+++ b/compiler/CMakeLists.txt -@@ -22,9 +22,8 @@ message(STATUS "ICU Libraries: " ${ICU_VERSION}) - - add_subdirectory(Generic) - add_subdirectory(Grammar) --add_subdirectory(LZ4) - --include_directories(Generic Grammar LZ4 ${ICU_INCLUDE_DIR}) -+include_directories(Generic Grammar ${ICU_INCLUDE_DIR}) - - add_library(TtfUtil OBJECT TtfUtil.cpp) - -diff --git a/compiler/Makefile.am b/compiler/Makefile.am -index 2cf0fea..3bd2242 100644 ---- a/compiler/Makefile.am -+++ b/compiler/Makefile.am -@@ -1,7 +1,7 @@ --AM_CPPFLAGS = -I@srcdir@/Generic -I@srcdir@/Grammar -I@srcdir@/LZ4 -+AM_CPPFLAGS = -I@srcdir@/Generic -I@srcdir@/Grammar - --SUBDIRS = Generic Grammar LZ4 --LIBS = @LIBS@ @LIBICONV@ -LGeneric -LGrammar -LLZ4 -lgeneric -lparser -llz4 -+SUBDIRS = Generic Grammar -+LIBS = @LIBS@ @LIBICONV@ -LGeneric -LGrammar -lgeneric -lparser -llz4 - EXTRA_DIST = resource.h GrCompiler.rc GrpParser.g GrpParser_readme.txt GrpParserTokenTypes.txt stddef.gdh - - bin_PROGRAMS = grcompiler -diff --git a/compiler/OutputToFont.cpp b/compiler/OutputToFont.cpp -index 677a04a..a462fed 100644 ---- a/compiler/OutputToFont.cpp -+++ b/compiler/OutputToFont.cpp -@@ -16,7 +16,7 @@ Description: - Include files - ***********************************************************************************************/ - #include "main.h" --#include "LZ4/lz4hc.h" -+#include <lz4hc.h> - - #include <time.h> - #include <memory> -diff --git a/configure.ac b/configure.ac -index f9439c3..22cf145 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -139,7 +139,6 @@ AC_CONFIG_FILES(Makefile \ - compiler/Makefile \ - compiler/Generic/Makefile \ - compiler/Grammar/Makefile \ -- compiler/LZ4/Makefile \ - test/Makefile) - - AC_CONFIG_SUBDIRS([test/GrcRegressionTest]) diff -Nru grcompiler-5.2/debian/patches/0001-Reimplement-BuildFontNames-using-std-lib.patch grcompiler-5.2/debian/patches/0001-Reimplement-BuildFontNames-using-std-lib.patch --- grcompiler-5.2/debian/patches/0001-Reimplement-BuildFontNames-using-std-lib.patch 1970-01-01 01:00:00.000000000 +0100 +++ grcompiler-5.2/debian/patches/0001-Reimplement-BuildFontNames-using-std-lib.patch 2020-09-08 17:40:48.000000000 +0200 @@ -0,0 +1,312 @@ +Origin: https://github.com/silnrsi/grcompiler/commit/a9e6dec71cbc11c5d637fa342e51867330001862 +From: Tim Eves <tim_e...@sil.org> +Date: Mon, 17 Aug 2020 16:20:01 +0700 +Subject: Fix #32 Reimplement BuildFontNames using std lib + +Since C++11 utf version of std::string are available, reimplement +GrcMnager::BuildFontNames() using these instead of lots of memcpy calls +and buffer allocations to perform the require string manipulations. This +also makes the logic of the function more apparent. +--- +diff --git a/compiler/GrcManager.h b/compiler/GrcManager.h +index df40f5f..2e86e03 100644 +--- a/compiler/GrcManager.h ++++ b/compiler/GrcManager.h +@@ -32,12 +32,9 @@ struct PlatEncChange + uint16 encodingID; + uint16 engLangID; + bool fChangeName; +- utf16 * pchwFullName; +- utf16 * pchwUniqueName; +- utf16 * pchwPostscriptName; +- size_t cchwFullName; +- size_t cchwUniqueName; +- size_t cchwPostscriptName; ++ std::u16string stuFullName; ++ std::u16string stuUniqueName; ++ std::u16string stuPostscriptName; + }; + + +diff --git a/compiler/OutputToFont.cpp b/compiler/OutputToFont.cpp +index 677a04a..51300ca 100644 +--- a/compiler/OutputToFont.cpp ++++ b/compiler/OutputToFont.cpp +@@ -18,9 +18,13 @@ Description: + #include "main.h" + #include "LZ4/lz4hc.h" + ++#include <algorithm> ++#include <codecvt> ++#include <locale> + #include <time.h> + #include <memory> + #include <sstream> ++#include <string> + + #pragma hdrstop + #undef THIS_FILE +@@ -650,8 +654,6 @@ bool GrcManager::AddFeatsModFamily(uint16 * pchwFamilyNameNew, + Assert(pchwFamilyNameNew); + + // Generate the new full-font name, the postscript name, and the unique name. +- +- std::wstring stuFullName, stuPostscriptName, stuUniqueName; + ibSubFamilyOffset = (irecSubFamily == -1) ? 0 : read(pRecord[irecSubFamily].offset) + ibStrOffset; + cbSubFamily = (irecSubFamily == -1) ? 0 : read(pRecord[irecSubFamily].length); + ibVendorOffset = (irecVendor == -1) ? 0 : read(pRecord[irecVendor].offset) + ibStrOffset; +@@ -677,17 +679,17 @@ bool GrcManager::AddFeatsModFamily(uint16 * pchwFamilyNameNew, + if (irecFullName > -1) + { + dbStringDiff -= read(pRecord[irecFullName].length); +- dbStringDiff += ppec->cchwFullName * ppec->cbBytesPerChar; ++ dbStringDiff += ppec->stuFullName.length() * ppec->cbBytesPerChar; + } + if (irecUniqueName > -1) + { + dbStringDiff -= read(pRecord[irecUniqueName].length); +- dbStringDiff += ppec->cchwUniqueName * ppec->cbBytesPerChar; ++ dbStringDiff += ppec->stuUniqueName.length() * ppec->cbBytesPerChar; + } + if (irecPSName > -1) + { + dbStringDiff -= read(pRecord[irecPSName].length); +- dbStringDiff += ppec->cchwPostscriptName * ppec->cbBytesPerChar; ++ dbStringDiff += ppec->stuPostscriptName.length() * ppec->cbBytesPerChar; + } + if (irecPrefFamily > -1) + { +@@ -697,7 +699,7 @@ bool GrcManager::AddFeatsModFamily(uint16 * pchwFamilyNameNew, + if (irecCompatibleFull > -1) + { + dbStringDiff -= read(pRecord[irecCompatibleFull].length); +- dbStringDiff += ppec->cchwFullName * ppec->cbBytesPerChar; ++ dbStringDiff += ppec->stuFullName.length() * ppec->cbBytesPerChar; + } + + cbNewStringData += dbStringDiff; +@@ -705,12 +707,9 @@ bool GrcManager::AddFeatsModFamily(uint16 * pchwFamilyNameNew, + else + { + // Font name is not changing, but we do have to output feature strings. +- ppec->pchwFullName = NULL; +- ppec->pchwUniqueName = NULL; +- ppec->pchwPostscriptName = NULL; +- ppec->cchwFullName = 0; +- ppec->cchwUniqueName = 0; +- ppec->cchwPostscriptName = 0; ++ ppec->stuFullName.clear(); ++ ppec->stuUniqueName.clear(); ++ ppec->stuPostscriptName.clear(); + } + } + +@@ -743,13 +742,6 @@ bool GrcManager::AddFeatsModFamily(uint16 * pchwFamilyNameNew, + delete [] *ppNameTbl; // old table + *ppNameTbl = pTblNew; + +- for (size_t ipec = 0; ipec < vpecToChange.size(); ipec++) +- { +- delete vpecToChange[ipec].pchwFullName; +- delete vpecToChange[ipec].pchwUniqueName; +- delete vpecToChange[ipec].pchwPostscriptName; +- } +- + return true; + } + +@@ -849,124 +841,61 @@ bool GrcManager::BuildFontNames(bool f8bitTable, + uint8 * pchVendor, uint16 cbVendor, + PlatEncChange * ppec) + { +- uint16 * pchwFullName, * pchwUniqueName, * pchwPSName; +- uint16 cchwFullName, cchwUniqueName, cchwPSName; +- +- size_t cchwDate = utf16len(stuDate); +- + Assert(pchwFamilyName); ++ std::u16string sub_family, vendor; + + // TODO: properly handle the Macintosh encoding, which is not really ANSI. +- +- // Check for "Regular" or "Standard" subfamily +- utf16 rgchwSubFamily[128]; +- bool fRegular; +- int cchwSubFamily; +- if (cbSubFamily == 0) +- { +- fRegular = true; +- cchwSubFamily = 0; +- } +- else ++ if (f8bitTable) + { +- if (f8bitTable) +- Platform_AnsiToUnicode((char *)pchSubFamily, cbSubFamily, rgchwSubFamily, cbSubFamily); +- else +- { +- utf16ncpy(rgchwSubFamily, (utf16 *)pchSubFamily, cbSubFamily); +- TtfUtil::SwapWString(rgchwSubFamily, cbSubFamily); +- } +- cchwSubFamily = (f8bitTable) ? cbSubFamily : cbSubFamily / sizeof(utf16); +- rgchwSubFamily[cchwSubFamily] = 0; +- fRegular = utf16ncmp(rgchwSubFamily, "Regular", 7) || utf16ncmp(rgchwSubFamily, "Standard", 8); +- } ++ #if _MSC_VER >= 1900 ++ std::wstring_convert<std::codecvt_utf8<int16_t>, int16_t> convert; ++ #else ++ std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> convert; ++ #endif + +- // Get vendor name, if any. +- utf16 * rgchwVendor; +- if (cbVendor == 0) +- { +- rgchwVendor = new utf16[15]; +- utf16ncpy(rgchwVendor, "Unknown Vendor", 14); +- cbVendor = (f8bitTable) ? 14 : 14 * sizeof(utf16); // pretend ++ auto s16 = convert.from_bytes(std::string(reinterpret_cast<char const *>(pchSubFamily), cbSubFamily)); ++ sub_family.assign(reinterpret_cast<char16_t const *>(s16.data()), s16.length()); ++ ++ s16 = convert.from_bytes(std::string(reinterpret_cast<char const *>(pchVendor), cbVendor)); ++ vendor.assign(reinterpret_cast<char16_t const *>(s16.data()), s16.length()); + } + else + { +- rgchwVendor = new utf16[cbVendor + 1]; +- if (f8bitTable) +- Platform_AnsiToUnicode((char *)pchVendor, cbVendor, rgchwVendor, cbVendor); +- else +- { +- utf16ncpy(rgchwVendor, (utf16 *)pchVendor, cbVendor); +- TtfUtil::SwapWString(rgchwVendor, cbVendor); +- } ++ sub_family.assign(reinterpret_cast<char16_t const *>(pchSubFamily), cbSubFamily/sizeof(char16_t)); ++ std::transform(sub_family.begin(), sub_family.end(), sub_family.begin(), read<uint16>); ++ ++ vendor.assign(reinterpret_cast<char16_t const *>(pchVendor), cbVendor/sizeof(char16_t)); ++ std::transform(vendor.begin(), vendor.end(), vendor.begin(), read<uint16>); + } +- int cchwVendor = (f8bitTable) ? cbVendor : cbVendor / sizeof(utf16); +- rgchwVendor[cchwVendor] = 0; ++ ++ // Check for "Regular" or "Standard" subfamily ++ bool const fRegular = sub_family.empty() || sub_family == u"Regular" || sub_family == u"Standard"; ++ std::u16string date = reinterpret_cast<char16_t const *>(stuDate); ++ if (vendor.empty()) ++ vendor = u"Unknown Vendor"; + + // Build the full font name: familyname+subfamily + // or (if subfamily = Regular/Standard) familyname +- if (fRegular) +- { // Regular does not include the subfamily in the full font name. +- pchwFullName = new uint16[cchwFamilyName + 1]; +- utf16cpy(pchwFullName, pchwFamilyName); +- cchwFullName = (uint16)cchwFamilyName; +- } +- else +- { // Other styles do include subfamily in the full font name. +- cchwFullName = (uint16)(cchwFamilyName + cbSubFamily / sizeof(utf16) + 1); // 1 - room for space +- pchwFullName = new uint16[cchwFullName + 1]; +- if (!pchwFullName) +- return false; +- utf16ncpy(pchwFullName, pchwFamilyName, cchwFamilyName); +- pchwFullName[cchwFamilyName] = 0x0020; // space +- utf16ncpy(pchwFullName + cchwFamilyName + 1, rgchwSubFamily, cchwSubFamily); +- pchwFullName[cchwFullName] = 0; +- } ++ // Regular style only includes the family name in the full font name. ++ std::u16string const full_name = std::u16string(reinterpret_cast<char16_t const *>(pchwFamilyName), cchwFamilyName) ++ // Other styles do include subfamily in the full font name. ++ + (fRegular ? u"" : u' ' + sub_family); + + // Build the Postscript name: familyname-subfamily, with certain chars stripped out. +- cchwPSName = (uint16)(cchwFamilyName + cchwSubFamily + 1); // +1 = hyphen +- pchwPSName = new uint16[cchwPSName + 1]; +- if (!pchwPSName) +- return false; +- utf16ncpy(pchwPSName, pchwFamilyName, cchwFamilyName); +- if (cbSubFamily == 0) +- cchwPSName--; // no hyphen +- else +- { +- pchwPSName[cchwFamilyName] = 0x002D; // hyphen +- utf16ncpy(pchwPSName + cchwFamilyName + 1, rgchwSubFamily, cchwSubFamily); +- } +- pchwPSName[cchwPSName] = 0; +- // Allow only chars 33 - 126, minus the following: / % ( ) < > [ ] { } +- int cchMove = 1; +- for (utf16 * pch = pchwPSName + cchwPSName - 1; pch >= pchwPSName; pch--, cchMove++) +- { +- if (*pch < 33 || *pch > 126 || *pch == '/' || *pch == '%' || *pch == '(' +- || *pch == ')' || *pch == '<' || *pch == '>' || *pch == '[' || *pch == ']' +- || *pch == '{' || *pch == '}') +- { +- utf16ncpy(pch, pch + 1, cchMove); +- cchwPSName--; +- } +- } ++ std::u16string ps_name = std::u16string(reinterpret_cast<char16_t const *>(pchwFamilyName), cchwFamilyName) ++ + (sub_family.empty() ? u"" : u'-' + sub_family); ++ ps_name.erase( ++ std::remove_if(ps_name.begin(), ps_name.end(), [](char16_t const c) { ++ return c < 33 || c > 126 || c == '/' || c == '%' || c == '(' || c == ')' ++ || c == '<' || c == '>' || c == '[' || c == ']' || c == '{' || c == '}'; }), ++ ps_name.end()); + + // Build the unique name: vendor: fullname: date +- cchwUniqueName = (uint16)(cchwVendor + cchwFullName + cchwDate + 4); +- pchwUniqueName = new utf16[cchwUniqueName + 1]; +- utf16ncpy(pchwUniqueName, rgchwVendor, cchwVendor); +- utf16ncpy(pchwUniqueName + cchwVendor, ": ", 2); +- utf16ncpy(pchwUniqueName + cchwVendor + 2, pchwFullName, cchwFullName); +- utf16ncpy(pchwUniqueName + cchwVendor + 2 + cchwFullName, ": ", 2); +- utf16ncpy(pchwUniqueName + cchwVendor + 2 + cchwFullName + 2, stuDate, cchwDate); +- pchwUniqueName[cchwUniqueName] = 0; +- delete[] rgchwVendor; ++ std::u16string const unique_name = vendor + u": " + full_name + u": " + date; + +- ppec->pchwFullName = pchwFullName; +- ppec->cchwFullName = cchwFullName; +- ppec->pchwUniqueName = pchwUniqueName; +- ppec->cchwUniqueName = cchwUniqueName; +- ppec->pchwPostscriptName = pchwPSName; +- ppec->cchwPostscriptName = cchwPSName; ++ ppec->stuFullName = full_name; ++ ppec->stuUniqueName = unique_name; ++ ppec->stuPostscriptName = ps_name; + + return true; + } +@@ -1073,7 +1002,7 @@ bool GrcManager::AddFeatsModFamilyAux(uint8 * pTblOld, uint32 /*cbTblOld*/, + uint16 cbStr = 0; + uint8 * pbStr = NULL; + if (ipec < signed(vpec.size()) +- && ppec->pchwFullName // this is a platform+encoding where we need to change the font ++ && !ppec->stuFullName.empty() // this is a platform+encoding where we need to change the font + && ppec->platformID == read(pOldRecord[irec].platform_id) + && ppec->encodingID == read(pOldRecord[irec].platform_specific_id) + && ppec->engLangID == read(pOldRecord[irec].language_id)) +@@ -1088,16 +1017,16 @@ bool GrcManager::AddFeatsModFamilyAux(uint8 * pTblOld, uint32 /*cbTblOld*/, + break; + case n_fullname: + case n_compatiblefull: +- pbStr = (uint8 *)vpec[ipec].pchwFullName; +- cchwStr = vpec[ipec].cchwFullName; ++ pbStr = (uint8 *)vpec[ipec].stuFullName.data(); ++ cchwStr = vpec[ipec].stuFullName.length(); + break; + case n_uniquename: +- pbStr = (uint8 *)vpec[ipec].pchwUniqueName; +- cchwStr = vpec[ipec].cchwUniqueName; ++ pbStr = (uint8 *)vpec[ipec].stuUniqueName.data(); ++ cchwStr = vpec[ipec].stuUniqueName.length(); + break; + case n_postscript: +- pbStr = (uint8 *)vpec[ipec].pchwPostscriptName; +- cchwStr = vpec[ipec].cchwPostscriptName; ++ pbStr = (uint8 *)vpec[ipec].stuPostscriptName.data(); ++ cchwStr = vpec[ipec].stuPostscriptName.length(); + break; + default: + break; diff -Nru grcompiler-5.2/debian/patches/0005-cmake-Not-setting-WORDS_BIGENDIAN.patch grcompiler-5.2/debian/patches/0005-cmake-Not-setting-WORDS_BIGENDIAN.patch --- grcompiler-5.2/debian/patches/0005-cmake-Not-setting-WORDS_BIGENDIAN.patch 1970-01-01 01:00:00.000000000 +0100 +++ grcompiler-5.2/debian/patches/0005-cmake-Not-setting-WORDS_BIGENDIAN.patch 2020-09-08 17:40:48.000000000 +0200 @@ -0,0 +1,60 @@ +Origin: https://github.com/silnrsi/grcompiler/commit/89fa0b3019c4f32b3a50289648fa33c2a2374c60 +From: Tim Eves <tim_e...@sil.org> +Date: Sun, 16 Aug 2020 12:33:54 +0700 +Subject: cmake: Not setting WORDS_BIGENDIAN + +This is a partial fix for Debian bug #961445 +--- +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2fab21c..8649394 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -11,7 +11,7 @@ set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED 11) + include(GNUInstallDirs) + +- ++test_big_endian(BIGENDIAN_SYSTEM) + + if (NOT CMAKE_BUILD_TYPE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release) +diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt +index dcc7f2d..43c6162 100644 +--- a/compiler/CMakeLists.txt ++++ b/compiler/CMakeLists.txt +@@ -27,6 +27,7 @@ add_subdirectory(LZ4) + include_directories(Generic Grammar LZ4 ${ICU_INCLUDE_DIR}) + + add_library(TtfUtil OBJECT TtfUtil.cpp) ++target_compile_definitions(TtfUtil PUBLIC $<${BIGENDIAN_SYSTEM}:WORDS_BIGENDIAN>) + + add_executable(grcompiler + Compiler.cpp +@@ -56,13 +57,12 @@ add_executable(grcompiler + PostParser.cpp + $<TARGET_OBJECTS:TtfUtil> + main.cpp) +- ++target_compile_definitions(grcompiler PRIVATE $<${BIGENDIAN_SYSTEM}:WORDS_BIGENDIAN>) ++target_link_libraries(grcompiler ICU::uc ICU::i18n generic parser lz4) + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_compile_options(grcompiler PRIVATE /Zc:wchar_t- /W3 /EHsc) + endif() + +-target_link_libraries(grcompiler ICU::uc ICU::i18n generic parser lz4) +- + if (icu_POPULATED) + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + file(GLOB_RECURSE _icu_dlls "${icu_SOURCE_DIR}/**${CMAKE_SHARED_LIBRARY_SUFFIX}") +diff --git a/test/GrcRegressionTest/CMakeLists.txt b/test/GrcRegressionTest/CMakeLists.txt +index 4aaf87b..3c54787 100644 +--- a/test/GrcRegressionTest/CMakeLists.txt ++++ b/test/GrcRegressionTest/CMakeLists.txt +@@ -8,6 +8,7 @@ add_executable(GrcRegressionTest + GrcRtFileFont.cpp + GrcRegressionTest.cpp + $<TARGET_OBJECTS:TtfUtil>) ++target_compile_definitions(GrcRegressionTest PRIVATE $<${BIGENDIAN_SYSTEM}:WORDS_BIGENDIAN>) + target_link_libraries(GrcRegressionTest generic) + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") diff -Nru grcompiler-5.2/debian/patches/0006-ResolveToFeatureID-assumed-little-endian.patch grcompiler-5.2/debian/patches/0006-ResolveToFeatureID-assumed-little-endian.patch --- grcompiler-5.2/debian/patches/0006-ResolveToFeatureID-assumed-little-endian.patch 1970-01-01 01:00:00.000000000 +0100 +++ grcompiler-5.2/debian/patches/0006-ResolveToFeatureID-assumed-little-endian.patch 2020-09-08 17:40:48.000000000 +0200 @@ -0,0 +1,36 @@ +Origin: https://github.com/silnrsi/grcompiler/commit/19c55e009386d62468d97948db581cff08962bbb +From: Tim Eves <tim_e...@sil.org> +Date: Sun, 16 Aug 2020 13:05:41 +0700 +Subject: Fixes #31: ResolveToFeatureID assumed little endian + +The code attempted to read a series of up to 4 bytes into a 32 bit value +and left align anything less than 4 bytes. +However it used union type aliasing and assumed little endian host memory +layout. On a bigendian system this reverses the byte order and results +in corrupted Graphtie Feature IDs being written to the TTF. +--- +diff --git a/compiler/GdlExpression.cpp b/compiler/GdlExpression.cpp +index 08fe847..e973c52 100644 +--- a/compiler/GdlExpression.cpp ++++ b/compiler/GdlExpression.cpp +@@ -488,15 +488,13 @@ bool GdlStringExpression::ResolveToFeatureID(unsigned int * pnRet) + if (m_staValue.length() > 4) + return false; + +- union { +- char rgch[4]; +- unsigned int n; +- } featid; + // The way we do the assignments ensures the characters are left-aligned + // in the 4-byte integer (ie, occupying the most significant bytes). +- for (size_t ich = 0; ich < 4; ich++) +- featid.rgch[3-ich] = (ich < m_staValue.length()) ? m_staValue[ich] : 0; +- *pnRet = featid.n; ++ unsigned int id = 0; ++ for(auto c : m_staValue) { id <<= 8; id += c; } ++ id <<= 8*(4-m_staValue.length()); ++ ++ *pnRet = id; + return true; + } + diff -Nru grcompiler-5.2/debian/patches/0007-Build-with-system-s-LZ4.patch grcompiler-5.2/debian/patches/0007-Build-with-system-s-LZ4.patch --- grcompiler-5.2/debian/patches/0007-Build-with-system-s-LZ4.patch 1970-01-01 01:00:00.000000000 +0100 +++ grcompiler-5.2/debian/patches/0007-Build-with-system-s-LZ4.patch 2020-09-08 17:40:48.000000000 +0200 @@ -0,0 +1,59 @@ +From: Bastian Germann <bastiangerm...@fishpost.de> +Date: Thu, 21 May 2020 11:32:59 +0200 +Description: Build with system's LZ4 +--- +diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt +index 43c6162..bb872ce 100644 +--- a/compiler/CMakeLists.txt ++++ b/compiler/CMakeLists.txt +@@ -22,9 +22,8 @@ message(STATUS "ICU Libraries: " ${ICU_VERSION}) + + add_subdirectory(Generic) + add_subdirectory(Grammar) +-add_subdirectory(LZ4) + +-include_directories(Generic Grammar LZ4 ${ICU_INCLUDE_DIR}) ++include_directories(Generic Grammar ${ICU_INCLUDE_DIR}) + + add_library(TtfUtil OBJECT TtfUtil.cpp) + target_compile_definitions(TtfUtil PUBLIC $<${BIGENDIAN_SYSTEM}:WORDS_BIGENDIAN>) +diff --git a/compiler/Makefile.am b/compiler/Makefile.am +index 2cf0fea..3bd2242 100644 +--- a/compiler/Makefile.am ++++ b/compiler/Makefile.am +@@ -1,7 +1,7 @@ +-AM_CPPFLAGS = -I@srcdir@/Generic -I@srcdir@/Grammar -I@srcdir@/LZ4 ++AM_CPPFLAGS = -I@srcdir@/Generic -I@srcdir@/Grammar + +-SUBDIRS = Generic Grammar LZ4 +-LIBS = @LIBS@ @LIBICONV@ -LGeneric -LGrammar -LLZ4 -lgeneric -lparser -llz4 ++SUBDIRS = Generic Grammar ++LIBS = @LIBS@ @LIBICONV@ -LGeneric -LGrammar -lgeneric -lparser -llz4 + EXTRA_DIST = resource.h GrCompiler.rc GrpParser.g GrpParser_readme.txt GrpParserTokenTypes.txt stddef.gdh + + bin_PROGRAMS = grcompiler +diff --git a/compiler/OutputToFont.cpp b/compiler/OutputToFont.cpp +index 677a04a..a462fed 100644 +--- a/compiler/OutputToFont.cpp ++++ b/compiler/OutputToFont.cpp +@@ -16,7 +16,7 @@ Description: + Include files + ***********************************************************************************************/ + #include "main.h" +-#include "LZ4/lz4hc.h" ++#include <lz4hc.h> + + #include <algorithm> + #include <codecvt> +diff --git a/configure.ac b/configure.ac +index f9439c3..22cf145 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -139,7 +139,6 @@ AC_CONFIG_FILES(Makefile \ + compiler/Makefile \ + compiler/Generic/Makefile \ + compiler/Grammar/Makefile \ +- compiler/LZ4/Makefile \ + test/Makefile) + + AC_CONFIG_SUBDIRS([test/GrcRegressionTest]) diff -Nru grcompiler-5.2/debian/patches/series grcompiler-5.2/debian/patches/series --- grcompiler-5.2/debian/patches/series 2020-08-16 11:41:30.000000000 +0200 +++ grcompiler-5.2/debian/patches/series 2020-09-08 17:40:48.000000000 +0200 @@ -1,4 +1,7 @@ -0001-Build-with-system-s-LZ4.patch +0001-Reimplement-BuildFontNames-using-std-lib.patch 0002-set-OK_DATE-FALSE-for-reproducible-build.patch 0003-Fix-man-install-path-for-cmake.patch 0004-Bug#961444.patch +0005-cmake-Not-setting-WORDS_BIGENDIAN.patch +0006-ResolveToFeatureID-assumed-little-endian.patch +0007-Build-with-system-s-LZ4.patch