Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kf6-kcodecs for openSUSE:Factory checked in at 2026-09-11 17:59:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kf6-kcodecs (Old) and /work/SRC/openSUSE:Factory/.kf6-kcodecs.new.1265 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kf6-kcodecs" Fri Sep 11 17:59:13 2026 rev:31 rq:1376678 version:6.30.0 Changes: -------- --- /work/SRC/openSUSE:Factory/kf6-kcodecs/kf6-kcodecs.changes 2026-08-17 16:58:48.034624550 +0200 +++ /work/SRC/openSUSE:Factory/.kf6-kcodecs.new.1265/kf6-kcodecs.changes 2026-09-11 18:01:23.710006162 +0200 @@ -1,0 +2,23 @@ +Tue Sep 8 09:21:46 UTC 2026 - Christophe Marin <[email protected]> + +- Update to 6.30.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/frameworks/6/6.30.0 +- Changes since 6.29.0: + * Update dependency version to 6.30.0 + * [KEncodingProber] Fix signedness issues for mBestGuess index + * [KEncodingProber] Return 0.0 confidence if encoding signals wrong syntax + * [KEncodingProber] Clean up float constants and C-style static casts + * [KEncodingProber] Drop charlen tables from state machine models + * [KEncodingProber] Remove need for charlen table from MBCS probers + * [KEncodingProber] Remove some erroneously copied comment + * [KEncodingProber] Remove no longer used method + * [KEncodingProber] SBCS: Replace model pointer with reference + * [KEncodingProber] SBCS: Replace unbounded array pointer with span + * [KEncodingProber] Move sequence counter sum out of loop + * [KEncodingProber] Test for Cyrillic encodings (and Unicode reencodings) + * [KEncodingProber] Test for ASCII only UTF-16 encoded texts + * Update version to 6.30.0 + +------------------------------------------------------------------- Old: ---- kcodecs-6.29.0.tar.xz kcodecs-6.29.0.tar.xz.sig New: ---- kcodecs-6.30.0.tar.xz kcodecs-6.30.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kf6-kcodecs.spec ++++++ --- /var/tmp/diff_new_pack.iw52ci/_old 2026-09-11 18:01:24.365033475 +0200 +++ /var/tmp/diff_new_pack.iw52ci/_new 2026-09-11 18:01:24.366033517 +0200 @@ -19,11 +19,11 @@ %define qt6_version 6.9.0 %define rname kcodecs -# Full KF6 version (e.g. 6.29.0) +# Full KF6 version (e.g. 6.30.0) %{!?_kf6_version: %global _kf6_version %{version}} %bcond_without released Name: kf6-kcodecs -Version: 6.29.0 +Version: 6.30.0 Release: 0 Summary: Method collection to manipulate strings using various encodings License: LGPL-2.1-or-later ++++++ kcodecs-6.29.0.tar.xz -> kcodecs-6.30.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/CMakeLists.txt new/kcodecs-6.30.0/CMakeLists.txt --- old/kcodecs-6.29.0/CMakeLists.txt 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/CMakeLists.txt 2026-09-04 13:37:16.000000000 +0200 @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.29) -set(KF_VERSION "6.29.0") # handled by release scripts +set(KF_VERSION "6.30.0") # handled by release scripts project(KCodecs VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 6.29.0 NO_MODULE) +find_package(ECM 6.30.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/autotests/kencodingprobertest.cpp new/kcodecs-6.30.0/autotests/kencodingprobertest.cpp --- old/kcodecs-6.29.0/autotests/kencodingprobertest.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/autotests/kencodingprobertest.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -124,6 +124,12 @@ QEXPECT_FAIL("Konnichiwa UTF-16BE", "Too low UTF-16BE confidence, too high Win-1252", Abort); QEXPECT_FAIL("EnjoyPlasma Japanese UTF-16LE Universal", "Too low UTF-16LE confidence, too high Win-1252", Abort); QEXPECT_FAIL("EnjoyPlasma Japanese UTF-16BE Universal", "Too low UTF-16BE confidence, too high Win-1252", Abort); + QEXPECT_FAIL("ASCII codepoints UTF-16LE", "UTF-16 low confidence", Abort); + QEXPECT_FAIL("ASCII codepoints UTF-16LE Universal", "UTF-16 with values <= 0x7f not checked", Abort); + QEXPECT_FAIL("ASCII codepoints UTF-16BE", "UTF-16 low confidence", Abort); + QEXPECT_FAIL("ASCII codepoints UTF-16BE Universal", "UTF-16 with values <= 0x7f not checked", Abort); + QEXPECT_FAIL("Plasma Ukrainian UTF-16LE", "UTF-16 low confidence", Abort); + QEXPECT_FAIL("Plasma Ukrainian UTF-16BE", "UTF-16 low confidence", Abort); QCOMPARE(ep.encoding().toLower(), encoding); QEXPECT_FAIL("UTF-16BE Unicode", "UTF-16 no confidence", Abort); @@ -302,6 +308,47 @@ QTest::addRow("EnjoyPlasma ISO-2022-JP") // << plasmaJPTextIso2022 // << KEncodingProber::Universal << QByteArray("iso-2022-jp"); + + constexpr char16_t plasmaENText[] = + u"Explore the Internet with Plasma. Connect with colleagues, " + "friends and family. Manage your files. Enjoy music and videos."; + QTest::addRow("ASCII codepoints UTF-8 Universal") // + << QString(plasmaENText).toUtf8() // + << KEncodingProber::Universal << QByteArray("utf-8"); + QTest::addRow("ASCII codepoints UTF-16LE") // + << QByteArray(asU16LEArray(plasmaENText)) // + << KEncodingProber::Unicode << QByteArray("utf-16le"); + QTest::addRow("ASCII codepoints UTF-16LE Universal") // + << QByteArray(asU16LEArray(plasmaENText)) // + << KEncodingProber::Universal << QByteArray("utf-16le"); + QTest::addRow("ASCII codepoints UTF-16BE") // + << QByteArray(asU16BEArray(plasmaENText)) // + << KEncodingProber::Unicode << QByteArray("utf-16be"); + QTest::addRow("ASCII codepoints UTF-16BE Universal") // + << QByteArray(asU16BEArray(plasmaENText)) // + << KEncodingProber::Universal << QByteArray("utf-16be"); + + constexpr char16_t plasmaUAText[] = + u"Програмне забезпечення KDE працює у NASA, CERN, електромобілях " + "Mercedes, Steam Deck, вашому улюбленому YouTube, а також школах, " + "урядах та офісах по всьому світу."; + QTest::addRow("Plasma Ukrainian UTF-8") // + << QString(plasmaUAText).toUtf8() // + << KEncodingProber::Universal << QByteArray("utf-8"); + QTest::addRow("Plasma Ukrainian UTF-16LE") // + << QByteArray(asU16LEArray(plasmaUAText)) // + << KEncodingProber::Universal << QByteArray("utf-16le"); + QTest::addRow("Plasma Ukrainian UTF-16BE") // + << QByteArray(asU16BEArray(plasmaUAText)) // + << KEncodingProber::Universal << QByteArray("utf-16be"); + QTest::addRow("Plasma Ukrainian Windows-1251") << QByteArray::fromHex( // + "cff0eee3f0e0ecede520e7e0e1e5e7efe5f7e5ededff204b444520eff0e0" + "f6feba20f3204e4153412c204345524e2c20e5ebe5eaf2f0eeeceee1b3eb" + "fff5204d657263656465732c20537465616d204465636b2c20e2e0f8eeec" + "f320f3ebfee1ebe5edeeecf320596f75547562652c20e020f2e0eaeee620" + "f8eaeeebe0f52c20f3f0ffe4e0f520f2e020eef4b3f1e0f520efee20e2f1" + "fceeecf320f1e2b3f2f32e0a") << // + KEncodingProber::Universal << QByteArray("windows-1251"); } void KEncodingProberTest::benchmarkProber() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/poqm/ca/kcodecs6_qt.po new/kcodecs-6.30.0/poqm/ca/kcodecs6_qt.po --- old/kcodecs-6.29.0/poqm/ca/kcodecs6_qt.po 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/poqm/ca/kcodecs6_qt.po 2026-09-04 13:37:16.000000000 +0200 @@ -3,10 +3,10 @@ # This file is distributed under the license LGPL version 2.1 or # version 3 or later versions approved by the membership of KDE e.V. # -# SPDX-FileCopyrightText: 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Sebastià Pla i Sanz <[email protected]> -# SPDX-FileCopyrightText: 2003, 2006, 2011, 2012, 2013 Antoni Bella Pérez <[email protected]> -# SPDX-FileCopyrightText: 2004, 2005, 2007 Albert Astals Cid <[email protected]> -# SPDX-FileCopyrightText: 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2020, 2022, 2024 Josep M. Ferrer <[email protected]> +# SPDX-FileCopyrightText: 1998-2007 Sebastià Pla i Sanz <[email protected]> +# SPDX-FileCopyrightText: 2003, 2006, 2011-2013 Antoni Bella Pérez <[email protected]> +# SPDX-FileCopyrightText: 2004-2005, 2007 Albert Astals Cid <[email protected]> +# SPDX-FileCopyrightText: 2007-2015, 2017, 2020, 2022, 2024 Josep M. Ferrer <[email protected]> # SPDX-FileCopyrightText: 2009 Robert Millan <[email protected]> # SPDX-FileCopyrightText: 2010 Orestes Mas <[email protected]> msgid "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/JpCntx.cpp new/kcodecs-6.30.0/src/probers/JpCntx.cpp --- old/kcodecs-6.29.0/src/probers/JpCntx.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/JpCntx.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -346,15 +346,13 @@ #define MINIMUM_DATA_THRESHOLD 4 -#define DONT_KNOW (float)-1 - float JapaneseContextAnalysis::GetConfidence() { // This is just one way to calculate confidence. It works well for me. if (mTotalRel > MINIMUM_DATA_THRESHOLD) { - return ((float)(mTotalRel - mRelSample[0])) / mTotalRel; + return static_cast<float>(mTotalRel - mRelSample[0]) / mTotalRel; } else { - return (float)DONT_KNOW; + return 0.0f; } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/LangBulgarianModel.cpp new/kcodecs-6.30.0/src/probers/LangBulgarianModel.cpp --- old/kcodecs-6.29.0/src/probers/LangBulgarianModel.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/LangBulgarianModel.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -63,7 +63,7 @@ // first 1024 sequences:3.0618% // rest sequences: 0.2992% // negative sequences: 0.0020% -const char BulgarianLangModel[] = { +constexpr std::array<const uint8_t, 64 * 64> BulgarianLangModel = { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 2, 2, 3, 2, 2, 1, 2, 2, 3, 1, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/LangCyrillicModel.cpp new/kcodecs-6.30.0/src/probers/LangCyrillicModel.cpp --- old/kcodecs-6.29.0/src/probers/LangCyrillicModel.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/LangCyrillicModel.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -115,7 +115,7 @@ // first 1024 sequences: 2.3389% // rest sequences: 0.1237% // negative sequences: 0.0009% -const char RussianLangModel[] = { +constexpr std::array<const uint8_t, 64 * 64> RussianLangModel = { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 1, 3, 3, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 2, 2, 2, 2, 2, 0, 0, 2, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 2, @@ -197,15 +197,15 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; -const SequenceModel Koi8rModel = {KOI8R_CharToOrderMap, RussianLangModel, (float)0.976601, false, "KOI8-R"}; +constexpr SequenceModel Koi8rModel = {KOI8R_CharToOrderMap, RussianLangModel, 0.976601f, false, "KOI8-R"}; -const SequenceModel Win1251Model = {win1251_CharToOrderMap, RussianLangModel, (float)0.976601, false, "windows-1251"}; +constexpr SequenceModel Win1251Model = {win1251_CharToOrderMap, RussianLangModel, 0.976601f, false, "windows-1251"}; -const SequenceModel Latin5Model = {latin5_CharToOrderMap, RussianLangModel, (float)0.976601, false, "ISO-8859-5"}; +constexpr SequenceModel Latin5Model = {latin5_CharToOrderMap, RussianLangModel, 0.976601f, false, "ISO-8859-5"}; -const SequenceModel MacCyrillicModel = {macCyrillic_CharToOrderMap, RussianLangModel, (float)0.976601, false, "x-mac-cyrillic"}; +constexpr SequenceModel MacCyrillicModel = {macCyrillic_CharToOrderMap, RussianLangModel, 0.976601f, false, "x-mac-cyrillic"}; -const SequenceModel Ibm866Model = {IBM866_CharToOrderMap, RussianLangModel, (float)0.976601, false, "IBM866"}; +constexpr SequenceModel Ibm866Model = {IBM866_CharToOrderMap, RussianLangModel, 0.976601f, false, "IBM866"}; -const SequenceModel Ibm855Model = {IBM855_CharToOrderMap, RussianLangModel, (float)0.976601, false, "IBM855"}; +constexpr SequenceModel Ibm855Model = {IBM855_CharToOrderMap, RussianLangModel, 0.976601f, false, "IBM855"}; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/LangGreekModel.cpp new/kcodecs-6.30.0/src/probers/LangGreekModel.cpp --- old/kcodecs-6.29.0/src/probers/LangGreekModel.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/LangGreekModel.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -60,7 +60,7 @@ // first 1024 sequences:1.7001% // rest sequences: 0.0359% // negative sequences: 0.0148% -const char GreekLangModel[] = { +constexpr std::array<const uint8_t, 64 * 64> GreekLangModel = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 0, 2, 2, 3, 3, 0, 3, 0, 3, 2, 0, 3, 3, 3, 0, 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 3, 3, 0, 3, 2, 3, 3, 0, 3, 2, 3, 3, 3, 0, 0, 3, 0, 3, 0, 3, 3, @@ -142,7 +142,7 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const SequenceModel Latin7Model = {Latin7_CharToOrderMap, GreekLangModel, (float)0.982851, false, "ISO-8859-7"}; +constexpr SequenceModel Latin7Model = {Latin7_CharToOrderMap, GreekLangModel, 0.982851f, false, "ISO-8859-7"}; -const SequenceModel Win1253Model = {win1253_CharToOrderMap, GreekLangModel, (float)0.982851, false, "windows-1253"}; +constexpr SequenceModel Win1253Model = {win1253_CharToOrderMap, GreekLangModel, 0.982851f, false, "windows-1253"}; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/LangHebrewModel.cpp new/kcodecs-6.30.0/src/probers/LangHebrewModel.cpp --- old/kcodecs-6.29.0/src/probers/LangHebrewModel.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/LangHebrewModel.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -44,7 +44,7 @@ // first 1024 sequences: 1.5981% // rest sequences: 0.087% // negative sequences: 0.0015% -const char HebrewLangModel[] = { +constexpr std::array<const uint8_t, 64 * 64> HebrewLangModel = { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 1, 2, 0, 1, 0, 0, 3, 0, 3, 1, 0, 0, 1, 3, 2, 0, 1, 1, 2, 0, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 0, 0, 2, 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -126,5 +126,5 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, }; -const SequenceModel Win1255Model = {win1255_CharToOrderMap, HebrewLangModel, (float)0.984004, false, "windows-1255"}; +constexpr SequenceModel Win1255Model = {win1255_CharToOrderMap, HebrewLangModel, 0.984004f, false, "windows-1255"}; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/LangHungarianModel.cpp new/kcodecs-6.30.0/src/probers/LangHungarianModel.cpp --- old/kcodecs-6.29.0/src/probers/LangHungarianModel.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/LangHungarianModel.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -50,7 +50,7 @@ // first 1024 sequences:5.2623% // rest sequences: 0.8894% // negative sequences: 0.0009% -const char HungarianLangModel[] = { +constexpr std::array<const uint8_t, 64 * 64> HungarianLangModel = { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 1, 1, 2, 2, 2, 2, 2, 1, 2, 3, 2, 2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 1, 2, 3, 3, 3, 3, 2, 3, 3, 1, 1, 3, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 2, 1, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 1, 1, 3, 2, @@ -132,7 +132,7 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const SequenceModel Latin2HungarianModel = {Latin2_HungarianCharToOrderMap, HungarianLangModel, (float)0.947368, true, "ISO-8859-2"}; +constexpr SequenceModel Latin2HungarianModel = {Latin2_HungarianCharToOrderMap, HungarianLangModel, 0.947368f, true, "ISO-8859-2"}; -const SequenceModel Win1250HungarianModel = {win1250HungarianCharToOrderMap, HungarianLangModel, (float)0.947368, true, "windows-1250"}; +constexpr SequenceModel Win1250HungarianModel = {win1250HungarianCharToOrderMap, HungarianLangModel, 0.947368f, true, "windows-1250"}; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/LangThaiModel.cpp new/kcodecs-6.30.0/src/probers/LangThaiModel.cpp --- old/kcodecs-6.29.0/src/probers/LangThaiModel.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/LangThaiModel.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -41,7 +41,7 @@ // first 1024 sequences:7.3177% // rest sequences: 1.0230% // negative sequences: 0.0436% -const char ThaiLangModel[] = { +constexpr std::array<const uint8_t, 64 * 64> ThaiLangModel = { 0, 1, 3, 3, 3, 3, 0, 0, 3, 3, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 0, 0, 0, 1, 3, 0, 3, 3, 2, 3, 3, 0, 1, 2, 3, 3, 3, 3, 0, 2, 0, 2, 0, 0, 3, 2, 1, 2, 2, 3, 0, 3, 3, 2, 3, 0, 0, 3, 3, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 2, 3, 0, 2, 2, 2, 3, 0, 2, 3, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1, 1, 3, 2, 2, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 3, 2, 3, @@ -123,5 +123,5 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const SequenceModel TIS620ThaiModel = {TIS620CharToOrderMap, ThaiLangModel, (float)0.926386, false, "TIS-620"}; +constexpr SequenceModel TIS620ThaiModel = {TIS620CharToOrderMap, ThaiLangModel, 0.926386f, false, "TIS-620"}; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/UnicodeGroupProber.cpp new/kcodecs-6.30.0/src/probers/UnicodeGroupProber.cpp --- old/kcodecs-6.29.0/src/probers/UnicodeGroupProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/UnicodeGroupProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -27,9 +27,9 @@ const char *UnicodeGroupProber::GetCharSetName() { - if (mBestGuess == -1) { + if (mBestGuess >= mProbers.size()) { GetConfidence(); - if (mBestGuess == -1) { + if (mBestGuess >= mProbers.size()) { // Default to UTF-8 mBestGuess = 0; } @@ -43,9 +43,9 @@ return mState; } - int activeNum = NUM_OF_UTF_PROBERS; + int activeNum = mProbers.size(); - for (unsigned int i = 0; i < NUM_OF_UTF_PROBERS; ++i) { + for (size_t i = 0; i < mProbers.size(); i++) { if (!mIsActive[i]) { continue; } @@ -76,7 +76,7 @@ case eNotMe: return 0.00f; // sure no default: - for (unsigned int i = 0; i < NUM_OF_UTF_PROBERS; ++i) { + for (size_t i = 0; i < mProbers.size(); i++) { if (!mIsActive[i]) { continue; } @@ -95,7 +95,7 @@ indent += 2; std::string output{" Unicode Group Prober ----"}; GetConfidence(); - for (int i = 0; i < NUM_OF_UTF_PROBERS; i++) { + for (size_t i = 0; i < mProbers.size(); i++) { char state = !mIsActive[i] ? '-' : (i == mBestGuess) ? '*' : ' '; output += '\n' + std::string(indent, ' '); output += std::format("{} #{:02} UTF: ", state, i); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/UnicodeGroupProber.h new/kcodecs-6.30.0/src/probers/UnicodeGroupProber.h --- old/kcodecs-6.29.0/src/probers/UnicodeGroupProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/UnicodeGroupProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -36,7 +36,7 @@ nsProbingState mState = eDetecting; std::array<std::unique_ptr<nsCharSetProber>, NUM_OF_UTF_PROBERS> mProbers = {nullptr}; std::array<bool, NUM_OF_UTF_PROBERS> mIsActive = {false}; - int mBestGuess = -1; + size_t mBestGuess = mProbers.size(); }; } #endif /* UNICODEGROUPPROBER_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsBig5Prober.cpp new/kcodecs-6.30.0/src/probers/nsBig5Prober.cpp --- old/kcodecs-6.29.0/src/probers/nsBig5Prober.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsBig5Prober.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -31,7 +31,7 @@ break; } if (codingState == eStart) { - unsigned int charLen = mCodingSM->GetCurrentCharLen(); + const int64_t charLen = i - mLastStart; if (i == 0) { mLastChar[1] = aBuf[0]; @@ -39,10 +39,12 @@ } else { mDistributionAnalyser.HandleOneChar(aBuf + i - 1, charLen); } + mLastStart = i; } } mLastChar[0] = aBuf[aLen - 1]; + mLastStart -= aLen; if (mState == eDetecting) { if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { @@ -57,6 +59,6 @@ { float distribCf = mDistributionAnalyser.GetConfidence(); - return (float)distribCf; + return distribCf; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsBig5Prober.h new/kcodecs-6.30.0/src/probers/nsBig5Prober.h --- old/kcodecs-6.29.0/src/probers/nsBig5Prober.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsBig5Prober.h 2026-09-04 13:37:16.000000000 +0200 @@ -40,6 +40,7 @@ Big5DistributionAnalysis mDistributionAnalyser; char mLastChar[2] = {0}; + int64_t mLastStart = -1; }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsCharSetProber.h new/kcodecs-6.30.0/src/probers/nsCharSetProber.h --- old/kcodecs-6.29.0/src/probers/nsCharSetProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsCharSetProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -20,7 +20,7 @@ eNotMe = 2, // Negative answer } nsProbingState; -#define SHORTCUT_THRESHOLD (float)0.95 +#define SHORTCUT_THRESHOLD 0.95f class KCODECS_NO_EXPORT nsCharSetProber { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsCodingStateMachine.h new/kcodecs-6.30.0/src/probers/nsCodingStateMachine.h --- old/kcodecs-6.29.0/src/probers/nsCodingStateMachine.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsCodingStateMachine.h 2026-09-04 13:37:16.000000000 +0200 @@ -30,7 +30,6 @@ nsClassTable classTable = {}; unsigned int classFactor = {}; nsStateTable stateTable = {}; - const unsigned int *charLenTable = nullptr; const char *name = nullptr; }; @@ -46,38 +45,17 @@ // for each byte we get its class, if it is first byte, we also get byte length const uint8_t index = static_cast<uint8_t>(c); unsigned int byteCls = mModel.classTable[index]; - if (mCurrentState == eStart) { - mCurrentCharLen = mModel.charLenTable[byteCls]; - } // from byte's class and stateTable, we get its next state mCurrentState = mModel.stateTable[mCurrentState * mModel.classFactor + byteCls]; return mCurrentState; } - unsigned int GetCurrentCharLen(void) - { - return mCurrentCharLen; - } const char *GetCodingStateMachine() { return mModel.name; } - const char *DumpCurrentState() - { - switch (mCurrentState) { - case eStart: - return "eStart"; - case eError: - return "eError"; - case eItsMe: - return "eItsMe"; - default: - return "OK"; - } - } protected: int mCurrentState = eStart; - unsigned int mCurrentCharLen = 0; const SMModel &mModel; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsEUCJPProber.cpp new/kcodecs-6.30.0/src/probers/nsEUCJPProber.cpp --- old/kcodecs-6.29.0/src/probers/nsEUCJPProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsEUCJPProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -36,7 +36,7 @@ break; } if (codingState == eStart) { - unsigned int charLen = mCodingSM->GetCurrentCharLen(); + const int64_t charLen = i - mLastStart; if (i == 0) { mLastChar[1] = aBuf[0]; @@ -46,10 +46,12 @@ mContextAnalyser.HandleOneChar(aBuf + i - 1, charLen); mDistributionAnalyser.HandleOneChar(aBuf + i - 1, charLen); } + mLastStart = i; } } mLastChar[0] = aBuf[aLen - 1]; + mLastStart -= aLen; if (mState == eDetecting) { if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsEUCJPProber.h new/kcodecs-6.30.0/src/probers/nsEUCJPProber.h --- old/kcodecs-6.29.0/src/probers/nsEUCJPProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsEUCJPProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -46,6 +46,7 @@ EUCJPDistributionAnalysis mDistributionAnalyser; char mLastChar[2] = {0}; + int64_t mLastStart = -1; }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsEUCKRProber.cpp new/kcodecs-6.30.0/src/probers/nsEUCKRProber.cpp --- old/kcodecs-6.29.0/src/probers/nsEUCKRProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsEUCKRProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -31,7 +31,7 @@ break; } if (codingState == eStart) { - unsigned int charLen = mCodingSM->GetCurrentCharLen(); + const int64_t charLen = i - mLastStart; if (i == 0) { mLastChar[1] = aBuf[0]; @@ -39,10 +39,12 @@ } else { mDistributionAnalyser.HandleOneChar(aBuf + i - 1, charLen); } + mLastStart = i; } } mLastChar[0] = aBuf[aLen - 1]; + mLastStart -= aLen; if (mState == eDetecting) { if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { @@ -59,6 +61,6 @@ { float distribCf = mDistributionAnalyser.GetConfidence(); - return (float)distribCf; + return distribCf; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsEUCKRProber.h new/kcodecs-6.30.0/src/probers/nsEUCKRProber.h --- old/kcodecs-6.29.0/src/probers/nsEUCKRProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsEUCKRProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -40,6 +40,7 @@ EUCKRDistributionAnalysis mDistributionAnalyser; char mLastChar[2] = {0}; + int64_t mLastStart = -1; }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsEscCharsetProber.h new/kcodecs-6.30.0/src/probers/nsEscCharsetProber.h --- old/kcodecs-6.29.0/src/probers/nsEscCharsetProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsEscCharsetProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -31,7 +31,7 @@ } float GetConfidence(void) override { - return (float)0.99; + return 0.99f; } protected: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsEscSM.h new/kcodecs-6.30.0/src/probers/nsEscSM.h --- old/kcodecs-6.29.0/src/probers/nsEscSM.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsEscSM.h 2026-09-04 13:37:16.000000000 +0200 @@ -61,13 +61,10 @@ // clang-format on }; -static const unsigned int HZCharLenTable[] = {0, 0, 0, 0, 0, 0}; - static constexpr SMModel HZSMModel{ HZ_cls, 6, HZ_st, - HZCharLenTable, "HZ-GB-2312", }; @@ -122,13 +119,10 @@ // clang-format on }; -static const unsigned int ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - static constexpr SMModel ISO2022JPSMModel = { ISO2022JP_cls, 10, ISO2022JP_st, - ISO2022JPCharLenTable, "ISO-2022-JP", }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsGB2312Prober.cpp new/kcodecs-6.30.0/src/probers/nsGB2312Prober.cpp --- old/kcodecs-6.29.0/src/probers/nsGB2312Prober.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsGB2312Prober.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -4,11 +4,6 @@ SPDX-License-Identifier: MIT */ -// for S-JIS encoding, observe characteristic: -// 1, kana character (or hankaku?) often have high frequency of appearance -// 2, kana character often exist in group -// 3, certain combination of kana is never used in japanese language - #include "nsGB2312Prober.h" #include "nsMBCSSM.h" @@ -32,7 +27,7 @@ break; } if (codingState == eStart) { - unsigned int charLen = mCodingSM->GetCurrentCharLen(); + const int64_t charLen = i - mLastStart; if (i == 0) { mLastChar[1] = aBuf[0]; @@ -40,10 +35,12 @@ } else { mDistributionAnalyser.HandleOneChar(aBuf + i - 1, charLen); } + mLastStart = i; } } mLastChar[0] = aBuf[aLen - 1]; + mLastStart -= aLen; if (mState == eDetecting) { if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { @@ -60,6 +57,6 @@ { float distribCf = mDistributionAnalyser.GetConfidence(); - return (float)distribCf; + return distribCf; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsGB2312Prober.h new/kcodecs-6.30.0/src/probers/nsGB2312Prober.h --- old/kcodecs-6.29.0/src/probers/nsGB2312Prober.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsGB2312Prober.h 2026-09-04 13:37:16.000000000 +0200 @@ -41,6 +41,7 @@ GB2312DistributionAnalysis mDistributionAnalyser; char mLastChar[2] = {0}; + int64_t mLastStart = -1; }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsHebrewProber.cpp new/kcodecs-6.30.0/src/probers/nsHebrewProber.cpp --- old/kcodecs-6.29.0/src/probers/nsHebrewProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsHebrewProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -58,8 +58,8 @@ namespace kencodingprober { nsHebrewProber::nsHebrewProber() - : mLogicalProb(new nsSingleByteCharSetProber<false>(&Win1255Model)) - , mVisualProb(new nsSingleByteCharSetProber<true>(&Win1255Model)) + : mLogicalProb(new nsSingleByteCharSetProber<false>(Win1255Model)) + , mVisualProb(new nsSingleByteCharSetProber<true>(Win1255Model)) { } /** HandleData @@ -125,7 +125,7 @@ float nsHebrewProber::GetConfidence() { if (GetState() == eNotMe) { - return 0.01f; + return 0.0f; } int finalsub = mFinalCharLogicalScore - mFinalCharVisualScore; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsLatin1Prober.cpp new/kcodecs-6.30.0/src/probers/nsLatin1Prober.cpp --- old/kcodecs-6.29.0/src/probers/nsLatin1Prober.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsLatin1Prober.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -109,7 +109,7 @@ float nsLatin1Prober::GetConfidence(void) { if (mState == eNotMe) { - return 0.01f; + return 0.0f; } float confidence; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsMBCSGroupProber.cpp new/kcodecs-6.30.0/src/probers/nsMBCSGroupProber.cpp --- old/kcodecs-6.29.0/src/probers/nsMBCSGroupProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsMBCSGroupProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -85,9 +85,9 @@ const char *nsMBCSGroupProber::GetCharSetName() { - if (mBestGuess == -1) { + if (mBestGuess >= mProbers.size()) { GetConfidence(); - if (mBestGuess == -1) { + if (mBestGuess >= mProbers.size()) { mBestGuess = 0; } } @@ -122,7 +122,7 @@ } // The UTF16 probers need unmangled data - for (unsigned int i = NUM_OF_PROBERS - 2; i < NUM_OF_PROBERS; ++i) { + for (size_t i = mProbers.size() - 2; i < mProbers.size(); i++) { if (!mIsActive[i]) { continue; } @@ -132,7 +132,7 @@ } } - for (unsigned int i = 0; i < NUM_OF_PROBERS - 2; ++i) { + for (size_t i = 0; i < mProbers.size() - 2; i++) { if (!mIsActive[i]) { continue; } @@ -164,9 +164,9 @@ case eFoundIt: return 0.99f; case eNotMe: - return 0.01f; + return 0.0f; default: - for (unsigned int i = 0; i < NUM_OF_PROBERS; ++i) { + for (size_t i = 0; i < mProbers.size(); i++) { if (!mIsActive[i]) { continue; } @@ -185,7 +185,7 @@ indent += 2; std::string output{" MBCS Group Prober ----"}; GetConfidence(); - for (int i = 0; i < NUM_OF_PROBERS; i++) { + for (size_t i = 0; i < mProbers.size(); i++) { char state = !mIsSelected[i] ? '.' : !mIsActive[i] ? '-' : (i == mBestGuess) ? '*' : ' '; output += '\n' + std::string(indent, ' '); output += std::format("{} #{:02} MBCS: ", state, i); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsMBCSGroupProber.h new/kcodecs-6.30.0/src/probers/nsMBCSGroupProber.h --- old/kcodecs-6.29.0/src/probers/nsMBCSGroupProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsMBCSGroupProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -50,8 +50,8 @@ std::array<std::unique_ptr<nsCharSetProber>, NUM_OF_PROBERS> mProbers; std::array<bool, NUM_OF_PROBERS> mIsActive = {false}; const std::array<bool, NUM_OF_PROBERS> mIsSelected = {true}; - int mBestGuess = -1; unsigned int mActiveNum = 0; + size_t mBestGuess = mProbers.size(); }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsMBCSSM.h new/kcodecs-6.30.0/src/probers/nsMBCSSM.h --- old/kcodecs-6.29.0/src/probers/nsMBCSSM.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsMBCSSM.h 2026-09-04 13:37:16.000000000 +0200 @@ -66,13 +66,10 @@ // clang-format on }; -static const unsigned int Big5CharLenTable[] = {0, 1, 1, 2, 0}; - static constexpr SMModel Big5SMModel{ BIG5_cls, 5, BIG5_st, - Big5CharLenTable, "Big5", }; @@ -125,13 +122,10 @@ // clang-format on }; -static const unsigned int EUCJPCharLenTable[] = {2, 2, 2, 3, 1, 0}; - static constexpr SMModel EUCJPSMModel{ EUCJP_cls, 6, EUCJP_st, - EUCJPCharLenTable, "EUC-JP", }; @@ -182,13 +176,10 @@ // clang-format on }; -static const unsigned int EUCKRCharLenTable[] = {0, 1, 2, 0}; - static constexpr SMModel EUCKRSMModel{ EUCKR_cls, 4, EUCKR_st, - EUCKRCharLenTable, "EUC-KR", }; @@ -242,18 +233,10 @@ // clang-format on }; -// To be accurate, the length of class 6 can be either 2 or 4. -// But it is not necessary to discriminate between the two since -// it is used for frequency analysis only, and we are validating -// each code range there as well. So it is safe to set it to be -// 2 here. -static const unsigned int GB18030CharLenTable[] = {0, 1, 1, 1, 1, 1, 2}; - static constexpr SMModel GB18030SMModel{ GB18030_cls, 7, GB18030_st, - GB18030CharLenTable, "GB18030", }; @@ -308,13 +291,10 @@ // clang-format on }; -static const unsigned int SJISCharLenTable[] = {0, 1, 1, 2, 0, 0}; - static constexpr SMModel SJISSMModel{ SJIS_cls, 6, SJIS_st, - SJISCharLenTable, "Shift_JIS", }; @@ -375,13 +355,10 @@ // clang-format on }; -static const unsigned int UCS2BECharLenTable[] = {2, 2, 2, 0, 2, 2, 4, 4}; - static constexpr SMModel UCS2BESMModel{ UCS2_cls, 8, UCS2BE_st, - UCS2BECharLenTable, "UTF-16BE", }; @@ -404,13 +381,10 @@ // clang-format on }; -static const unsigned int UCS2LECharLenTable[] = {2, 2, 2, 2, 2, 2, 4, 4}; - static constexpr SMModel UCS2LESMModel{ UCS2_cls, 8, UCS2LE_st, - UCS2LECharLenTable, "UTF-16LE", }; @@ -469,13 +443,10 @@ // clang-format on }; -static const unsigned int UTF8CharLenTable[] = {0, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 4}; - static constexpr SMModel UTF8SMModel{ UTF8_cls, 12, UTF8_st, - UTF8CharLenTable, "UTF-8", }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsSBCSGroupProber.cpp new/kcodecs-6.30.0/src/probers/nsSBCSGroupProber.cpp --- old/kcodecs-6.29.0/src/probers/nsSBCSGroupProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsSBCSGroupProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -16,16 +16,16 @@ { nsSBCSGroupProber::nsSBCSGroupProber() : mProbers{ - std::make_unique<nsSingleByteCharSetProber<false>>(&Win1251Model), - std::make_unique<nsSingleByteCharSetProber<false>>(&Koi8rModel), - std::make_unique<nsSingleByteCharSetProber<false>>(&Latin5Model), - std::make_unique<nsSingleByteCharSetProber<false>>(&MacCyrillicModel), - std::make_unique<nsSingleByteCharSetProber<false>>(&Ibm866Model), - std::make_unique<nsSingleByteCharSetProber<false>>(&Ibm855Model), - std::make_unique<nsSingleByteCharSetProber<false>>(&Latin7Model), - std::make_unique<nsSingleByteCharSetProber<false>>(&Win1253Model), - std::make_unique<nsSingleByteCharSetProber<false>>(&Latin5BulgarianModel), - std::make_unique<nsSingleByteCharSetProber<false>>(&Win1251BulgarianModel), + std::make_unique<nsSingleByteCharSetProber<false>>(Win1251Model), + std::make_unique<nsSingleByteCharSetProber<false>>(Koi8rModel), + std::make_unique<nsSingleByteCharSetProber<false>>(Latin5Model), + std::make_unique<nsSingleByteCharSetProber<false>>(MacCyrillicModel), + std::make_unique<nsSingleByteCharSetProber<false>>(Ibm866Model), + std::make_unique<nsSingleByteCharSetProber<false>>(Ibm855Model), + std::make_unique<nsSingleByteCharSetProber<false>>(Latin7Model), + std::make_unique<nsSingleByteCharSetProber<false>>(Win1253Model), + std::make_unique<nsSingleByteCharSetProber<false>>(Latin5BulgarianModel), + std::make_unique<nsSingleByteCharSetProber<false>>(Win1251BulgarianModel), std::make_unique<nsHebrewProber>(), std::make_unique<nsUtf8Prober>(), std::make_unique<nsUtf16BEProber>(), @@ -47,12 +47,11 @@ const char *nsSBCSGroupProber::GetCharSetName() { // if we have no answer yet - if (mBestGuess == -1) { + if (mBestGuess >= mProbers.size()) { GetConfidence(); // no charset seems positive - if (mBestGuess == -1) - // we will use default. - { + if (mBestGuess >= mProbers.size()) { + // we will use default. mBestGuess = 0; } } @@ -68,10 +67,10 @@ char *newBuf1 = nullptr; unsigned int newLen1 = 0; - int activeNum = NUM_OF_SBCS_PROBERS; + int activeNum = mProbers.size(); // The UTF16 probers need unmangled data - for (unsigned int i = NUM_OF_SBCS_PROBERS - 2; i < NUM_OF_SBCS_PROBERS; ++i) { + for (size_t i = mProbers.size() - 2; i < mProbers.size(); i++) { if (!mIsActive[i]) { activeNum--; continue; @@ -100,7 +99,7 @@ goto done; // Nothing to see here, move on. } - for (unsigned int i = 0; i < NUM_OF_SBCS_PROBERS - 2; ++i) { + for (size_t i = 0; i < mProbers.size() - 2; i++) { if (!mIsActive[i]) { activeNum--; continue; @@ -134,9 +133,9 @@ case eFoundIt: return 0.99f; // sure yes case eNotMe: - return 0.01f; // sure no + return 0.0f; // sure no default: - for (unsigned int i = 0; i < NUM_OF_SBCS_PROBERS; ++i) { + for (size_t i = 0; i < mProbers.size(); i++) { if (!mIsActive[i]) { continue; } @@ -155,7 +154,7 @@ indent += 2; std::string output{" SBCS Group Prober ----"}; GetConfidence(); - for (int i = 0; i < NUM_OF_SBCS_PROBERS; i++) { + for (size_t i = 0; i < mProbers.size(); i++) { char state = !mIsActive[i] ? '-' : (i == mBestGuess) ? '*' : ' '; output += '\n' + std::string(indent, ' '); output += std::format("{} #{:02} SBCS: ", state, i); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsSBCSGroupProber.h new/kcodecs-6.30.0/src/probers/nsSBCSGroupProber.h --- old/kcodecs-6.29.0/src/probers/nsSBCSGroupProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsSBCSGroupProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -39,7 +39,7 @@ nsProbingState mState = eDetecting; std::array<std::unique_ptr<nsCharSetProber>, NUM_OF_SBCS_PROBERS> mProbers = {nullptr}; std::array<bool, NUM_OF_SBCS_PROBERS> mIsActive = {false}; - int mBestGuess = -1; + size_t mBestGuess = mProbers.size(); }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsSBCharSetProber.cpp new/kcodecs-6.30.0/src/probers/nsSBCharSetProber.cpp --- old/kcodecs-6.29.0/src/probers/nsSBCharSetProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsSBCharSetProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -7,6 +7,7 @@ #include "nsSBCharSetProber.h" #include <format> +#include <numeric> namespace kencodingprober { @@ -17,7 +18,7 @@ nsProbingState nsSingleByteCharSetProber<Reversed>::HandleData(const char *aBuf, unsigned int aLen) { for (unsigned int i = 0; i < aLen; i++) { - const unsigned char order = mModel->charToOrderMap[(unsigned char)aBuf[i]]; + const unsigned char order = mModel.charToOrderMap[(unsigned char)aBuf[i]]; if (order < SYMBOL_CAT_ORDER) { mTotalChar++; @@ -26,14 +27,14 @@ mFreqChar++; if (mLastOrder < SAMPLE_SIZE) { - mTotalSeqs++; unsigned int index = Reversed ? mLastOrder + (SAMPLE_SIZE * order) : (mLastOrder * SAMPLE_SIZE) + order; - ++(mSeqCounters[(int)mModel->precedenceMatrix[index]]); + ++(mSeqCounters[mModel.precedenceMatrix[index]]); } } mLastOrder = order; } + mTotalSeqs = std::accumulate(mSeqCounters.begin(), mSeqCounters.end(), 0); if (mState == eDetecting) { if (mTotalSeqs > 1024) { float cf = GetConfidence(); @@ -62,7 +63,7 @@ #else // POSITIVE_APPROACH if (mTotalSeqs > 0) { - float r = 1.0f * mSeqCounters.back() / mTotalSeqs / mModel->mTypicalPositiveRatio; + float r = 1.0f * mSeqCounters.back() / mTotalSeqs / mModel.mTypicalPositiveRatio; r = r * mFreqChar / mTotalChar; if (r >= 0.99f) { r = 0.99f; @@ -76,7 +77,7 @@ template<bool Reversed> const char *nsSingleByteCharSetProber<Reversed>::GetCharSetName() { - return mModel->charsetName; + return mModel.charsetName; } template<bool Reversed> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsSBCharSetProber.h new/kcodecs-6.30.0/src/probers/nsSBCharSetProber.h --- old/kcodecs-6.29.0/src/probers/nsSBCharSetProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsSBCharSetProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -10,6 +10,7 @@ #include "nsCharSetProber.h" #include <array> +#include <span> #define SAMPLE_SIZE 64 #define SYMBOL_CAT_ORDER 250 @@ -18,7 +19,7 @@ { typedef struct { const unsigned char *charToOrderMap; // [256] table use to find a char's order - const char *precedenceMatrix; // [SAMPLE_SIZE][SAMPLE_SIZE]; table to find a 2-char sequence's frequency + const std::span<const uint8_t, 64 * 64> precedenceMatrix; // [SAMPLE_SIZE][SAMPLE_SIZE]; table to find a 2-char sequence's frequency float mTypicalPositiveRatio; // = freqSeqs / totalSeqs bool keepEnglishLetter; // says if this script contains English characters (not implemented) const char *charsetName; @@ -28,7 +29,7 @@ class KCODECS_NO_EXPORT nsSingleByteCharSetProber : public nsCharSetProber { public: - explicit nsSingleByteCharSetProber(const SequenceModel *model) + explicit nsSingleByteCharSetProber(const SequenceModel &model) : mModel(model) { } @@ -45,7 +46,7 @@ protected: nsProbingState mState = eDetecting; - const SequenceModel *mModel = nullptr; + const SequenceModel &mModel; // char order of last character unsigned char mLastOrder = 255; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsSJISProber.cpp new/kcodecs-6.30.0/src/probers/nsSJISProber.cpp --- old/kcodecs-6.29.0/src/probers/nsSJISProber.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsSJISProber.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -36,7 +36,8 @@ break; } if (codingState == eStart) { - unsigned int charLen = mCodingSM->GetCurrentCharLen(); + const int64_t charLen = i - mLastStart; + if (i == 0) { mLastChar[1] = aBuf[0]; mContextAnalyser.HandleOneChar(mLastChar + 2 - charLen, charLen); @@ -45,10 +46,12 @@ mContextAnalyser.HandleOneChar(aBuf + i + 1 - charLen, charLen); mDistributionAnalyser.HandleOneChar(aBuf + i - 1, charLen); } + mLastStart = i; } } mLastChar[0] = aBuf[aLen - 1]; + mLastStart -= aLen; if (mState == eDetecting) { if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsSJISProber.h new/kcodecs-6.30.0/src/probers/nsSJISProber.h --- old/kcodecs-6.29.0/src/probers/nsSJISProber.h 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsSJISProber.h 2026-09-04 13:37:16.000000000 +0200 @@ -48,6 +48,7 @@ SJISDistributionAnalysis mDistributionAnalyser; char mLastChar[2] = {0}; + int64_t mLastStart = -1; }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcodecs-6.29.0/src/probers/nsUniversalDetector.cpp new/kcodecs-6.30.0/src/probers/nsUniversalDetector.cpp --- old/kcodecs-6.29.0/src/probers/nsUniversalDetector.cpp 2026-08-07 22:39:15.000000000 +0200 +++ new/kcodecs-6.30.0/src/probers/nsUniversalDetector.cpp 2026-09-04 13:37:16.000000000 +0200 @@ -17,8 +17,7 @@ namespace kencodingprober { //--------------------------------------------------------------------- -#define SHORTCUT_THRESHOLD (float)0.95 -#define MINIMUM_THRESHOLD (float)0.20 +#define MINIMUM_THRESHOLD 0.20f nsProbingState nsUniversalDetector::HandleData(const char *aBuf, unsigned int aLen) { @@ -99,7 +98,7 @@ } switch (mInputState) { case eHighbyte: { - float maxProberConfidence = (float)0.0; + float maxProberConfidence = 0.0f; int maxProber = 0; for (int i = 0; i < NUM_OF_CHARSET_PROBERS; i++) { @@ -135,7 +134,7 @@ } switch (mInputState) { case eHighbyte: { - float maxProberConfidence = (float)0.0; + float maxProberConfidence = 0.0f; int maxProber = 0; for (int i = 0; i < NUM_OF_CHARSET_PROBERS; i++) {
