diff --git a/.gitignore b/.gitignore index b3bd1fec..f0c75e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,21 +13,27 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ [Bb]uild/ -Win32/ x64/ x86/ +[Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ +[Aa][Rr][Mm]64[Ee][Cc]/ bld/ [Bb]in/ [Oo]bj/ +[Oo]ut/ [Ll]og/ +[Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ @@ -41,9 +47,10 @@ Generated\ Files/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -# NUNIT +# NUnit *.VisualState.xml TestResult.xml +nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ @@ -58,6 +65,9 @@ project.lock.json project.fragment.lock.json artifacts/ +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + # StyleCop StyleCopReport.xml @@ -124,9 +134,6 @@ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -# JustCode is a .NET coding add-in -.JustCode - # TeamCity is a build add-in _TeamCity* @@ -137,6 +144,11 @@ _TeamCity* .axoCover/* !.axoCover/settings.json +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + # Visual Studio code coverage results *.coverage *.coveragexml @@ -184,6 +196,8 @@ PublishScripts/ # NuGet Packages *.nupkg +# NuGet Symbol Packages +*.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. @@ -208,6 +222,8 @@ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx +*.appxbundle +*.appxupload # Visual Studio cache files # files ending in .cache can be ignored @@ -257,7 +273,9 @@ ServiceFabricBackup/ *.bim.layout *.bim_*.settings *.rptproj.rsuser -*- Backup*.rdl +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ @@ -293,10 +311,6 @@ paket-files/ # FAKE - F# Make .fake/ -# JetBrains Rider -.idea/ -*.sln.iml - # CodeRush personal settings .cr/personal @@ -341,6 +355,15 @@ ASALocalRun/ # BeatPulse healthcheck temp database healthchecksdb +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + # Backup files *.BAK *.bak diff --git a/LICENSE.TXT b/LICENSE.TXT index 6d43e2a5..fdc6311d 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -6,7 +6,7 @@ CorvusSKK The MIT License -Copyright (C) 2011-2020 SASAKI Nobuyuki +Copyright (C) 2011-2024 SASAKI Nobuyuki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -43,11 +43,55 @@ License: ------------------------------------------------------------------------------- +JIS X 0208 (1990) to Unicode +© 2015 Unicode®, Inc. + +JIS X 0212 (1990) to Unicode +© 2015 Unicode®, Inc. + +COPYRIGHT AND PERMISSION NOTICE + +Copyright © 1991-2021 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + + +------------------------------------------------------------------------------- + + Lua The MIT License -Copyright (C) 1994-2018 Lua.org, PUC-Rio. +Copyright (C) 1994-2024 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -75,7 +119,7 @@ zlib The zlib/libpng License -Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -164,89 +208,89 @@ THE SOFTWARE. MICROSOFT SOFTWARE LICENSE TERMS -MICROSOFT VISUAL STUDIO COMMUNITY 2019 +MICROSOFT VISUAL STUDIO COMMUNITY 2022 -3. DISTRIBUTABLE CODE. +4. DISTRIBUTABLE CODE. The software contains code that you may distribute in applications you - develop as described in this Section. For purposes of this Section 3, the - term "distribution" also means deployment of your applications for third - parties to access over the Internet. + develop as described in this Section. For purposes of this Section 4, + the term “distribution” also means deployment of your applications for + third parties to access over the Internet. a. Right to Use and Distribute. - The code and text files listed below are "Distributable Code". - · Distributable List. - You may copy and distribute the object code form of code listed on the - Distributable List located at https://aka.ms/vs/16/redistribution. - · Sample Code, Templates and Styles. - You may copy, modify and distribute the source and object code form of - code marked as "sample", "template", "simple styles" and "sketch styles". - · Third Party Distribution. - You may permit distributors of your applications to copy and distribute - the Distributable Code as part of those applications. + The code and text files listed below are “Distributable Code”. + + i. Distributable List. + You may copy and distribute the object code form of code listed on + the Distributable List located at https://aka.ms/vs/17/redistribution. + + ii. Sample Code, Templates and Styles. + You may copy, modify and distribute the source and object code form of + code marked as “sample”, “template”, “simple styles” and “sketch styles”. + + iii. Third Party Distribution. + You may permit distributors of your applications to copy and distribute + the Distributable Code as part of those applications. b. Distribution Requirements. For any Distributable Code you distribute, you must: + · add significant primary functionality to it in your applications; and + · require distributors and external end users to agree to terms that - protect the Distributable Code at least as much as this agreement. + protect the Distributable Code at least as much as this agreement. + +c. Distribution Restrictions. + You may not: + + · distribute components or runtimes that are marked “Preview”, + “Pre-release” or “Beta”; - c. Distribution Restrictions. - You may not: · use Microsoft’s trademarks in your applications’ names or in a way that - suggests your applications come from or are endorsed by Microsoft; or - · modify or distribute the source code of any Distributable Code so that any - part of it becomes subject to an Excluded License. An "Excluded License" - is one that requires, as a condition of use, modification or distribution - of code, that (i) it be disclosed or distributed in source code form; or - (ii) others have the right to modify it. - - -Distributable Code Files for Visual Studio 2019 - -The following section is the "REDIST list" that is referenced in the -"Distributable Code" section of the Microsoft Software License Terms for Visual -Studio Enterprise 2019, Visual Studio Professional 2019, Visual Studio -Community 2019 ("the software"). If you have a validly licensed copy of such -software, you may copy and distribute with your program the unmodified form of -the files listed below, subject to the License Terms for the software. - -In the lists below... - · [arch] represents the processor architecture identifier, for instance "x86", - "x64", or "arm". - · [locale] represents a specific language, locale, or culture identifier, for - instance "ENU", "en-us", or "1033". - · [version] represents a folder name that uses a version number. - · [VisualStudioFolder] represents the install location for Visual Studio 2019. - - -Visual C++ Runtime Files - -Subject to the License Terms for the software, you may copy and distribute -the following files, unmodified, as a part of the installation package of your -program: - - · [Program Files (x86)]\Common Files\Merge Modules\ - · Microsoft_VC141_CRT_[arch].msm - · Microsoft_VC141_CXXAMP_[arch].msm - · Microsoft_VC141_MFC_[arch].msm - · Microsoft_VC141_MFCLOC_[arch].msm - · Microsoft_VC141_OpenMP_[arch].msm - -Subject to the License Terms for the software, you may copy and distribute with -your program any of the files within the following folder and its subfolders -except as noted below. You may not modify these files. - - · [VisualStudioFolder]\VC\redist - · You may not distribute the contents of the following folders: - · [VisualStudioFolder]VC\Redist\MSVC\[version]\debug_nonredist - · [VisualStudioFolder]VC\Redist\MSVC\[version]\debug_nonredist - · [VisualStudioFolder]\VC\Redist\MSVC\[version]\onecore\debug_nonredist - -Subject to the License Terms for the software, you may copy and distribute -the following files with your program in your program’s application local -folder or by deploying them into the Global Assembly Cache (GAC): - - · [VisualStudioFolder]\VC\Tools\MSVC\[version]\atlmfc\lib\[arch]\mfcmifc80.dll + suggests your applications come from or are endorsed by Microsoft; or + + · modify or distribute the source code of any Distributable Code so that + any part of it becomes subject to an Excluded License. + An “Excluded License” is one that requires, as a condition of use, + modification or distribution of code, + that (i) it be disclosed or distributed in source code form; + or (ii) others have the right to modify it. + + +Distributable Code for Visual Studio 2022 + + In the lists below... + + [arch] represents the processor architecture identifier, + for instance "x86", "x64", or "arm". + [locale] represents a specific language, locale, or culture identifier, + for instance "ENU", "en-us", or "1033". + [version] represents a folder name that uses a version number. + [VisualStudioFolder] represents the install location for Visual Studio 2022. + + Distributable Code Files for Visual Studio 2022 + + The following section is the "REDIST list" that is referenced in the + "Distributable Code" section of the Microsoft Software License Terms for + Visual Studio Enterprise 2022, Visual Studio Professional 2022, + Visual Studio Community 2022 ("the software"). + If you have a validly licensed copy of such software, + you may copy and distribute with your program the unmodified form of + the files listed below, subject to the License Terms for the software. + + Visual C++ Runtime Files + + Subject to the License Terms for the software, you may copy and distribute + with your program any of the files within the following folder and its + subfolders except as noted below. You may not modify these files. + + [VisualStudioFolder]\VC\redist + + You may not distribute the contents of the following folders + (please see List of Utilities and Build Tools for Visual Studio 2022 for + allowed usage for development/testing purposes): + + [VisualStudioFolder]VC\Redist\MSVC\[version]\debug_nonredist + [VisualStudioFolder]\VC\Redist\MSVC\[version]\onecore\debug_nonredist ------------------------------------------------------------------------------- diff --git a/README.md b/README.md index f3ab24ba..69477018 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# CorvusSKK ver. 2.7.12 +# CorvusSKK ver. 3.3.0 -Windowsで動作するSKK風のIMEです。 +![](installer/resource-md/logo.png) Windowsで動作するSKK風のIMEです。 @@ -10,30 +10,17 @@ Windowsで動作するSKK風のIMEです。 ### 対応OS -* Windows Vista (32-bit / 64-bit) - - * Service Pack 2 - * プラットフォーム更新プログラム ( [KB971644](https://support.microsoft.com/en-us/kb/971644) または [KB971512](https://support.microsoft.com/en-us/kb/971512) ) - -* Windows 7 (32-bit / 64-bit) - - * Service Pack 1 - -* Windows 8 (32-bit / 64-bit) - -* Windows 8.1 (32-bit / 64-bit) +* Windows 10 (32-bit / 64-bit / ARM) - * S14 Update ( [KB2919355](https://support.microsoft.com/en-us/kb/2919355) ) + * バージョン 1607 (Anniversary Update) ビルド 14393 以降 -* Windows 10 (32-bit / 64-bit / ARM) +* Windows 11 (64-bit / ARM) ### インストール corvusskk-X.Y.Z.exe を実行してください。 (X, Y, Z はバージョン番号) -Windows 10 on ARM では corvusskk-X.Y.Z-arm.exe を実行してください。 - アップデートの後はOSを再起動しておくと安全です。 インストール先 @@ -50,7 +37,7 @@ Windows 10 on ARM では corvusskk-X.Y.Z-arm.exe を実行してください。 * ARM 版 Windows * %SystemRoot%\System32\IME\IMCRVSKK - * %SystemRoot%\SysArm32\IME\IMCRVSKK + * %SystemRoot%\SysArm32\IME\IMCRVSKK ⦅ Windows 11 ビルド 25905 より前 ⦆ * %SystemRoot%\SysWOW64\IME\IMCRVSKK * 共通 @@ -73,7 +60,7 @@ Windows ストアアプリ、Microsoft Edge 等で使用するには、設定フ Windows 8 以降で動作する設定ダイアログでOKボタンを押して保存をおこなうとアクセス許可の付加が自動的におこなわれます。 -また、Windows 8 以前から Windows 8 以降へ Windows をアップグレードしたときは、CorvusSKK を一旦アンインストールした上でインストールし直してください。 +また、Windows 8 より前から Windows 8 以降へ Windows をアップグレードしたときは、CorvusSKK を一旦アンインストールした上でインストールし直してください。 インストール時に、Windows ストアアプリ、Microsoft Edge 等で使用可能となるようにIMEの登録がおこなわれます。 @@ -86,42 +73,53 @@ Adobe Reader X 以降で使用するには、設定ファイル (config.xml) に -## 設定 +## ファイル +### 設定ファイル -### 設定ダイアログ +設定ファイルは、ディレクトリ %APPDATA%\CorvusSKK に保存されます。 -設定ダイアログは、以下のいずれかの操作で開くことができます。 +| ファイル名 | 説明 | +| --- | --- | +| config.xml | 各種設定 | -* 言語バーを右クリックし、メニューから「設定」を選択する。「テキストサービスと入力言語」ダイアログの「インストールされているサービス」からCorvusSKKを選択し、プロパティボタンを押す。 -* 言語バーの入力モードアイコンを左クリックし、メニューから「設定」を選択する。 -* 言語バーのヘルプボタンを左クリックし、メニューから「CorvusSKK」を選択する。 -* Windows 8 以降の通知領域の入力モードアイコンを右クリックし、メニューから「設定」を選択する。 -* スタートメニューから CorvusSKK\CONFIG を実行する。 -* %SystemRoot%\System32\IME\IMCRVSKK\imcrvcnf.exe または %SystemRoot%\SysWOW64\IME\IMCRVSKK\imcrvcnf.exe を直接実行する - * コマンドライン引数またはドラッグアンドドロップで後述の設定ファイルを渡すことが可能です。 +* 設定サンプル https://github.com/nathancorvussolis/corvusskk/blob/master/installer/config-sample +* デフォルト https://github.com/nathancorvussolis/corvusskk/tree/master/installer/config-share -設定ダイアログで保存した後は、IME OFF → ON で新しい設定が反映されます。 +UTF-8 の XML フォーマットのテキストファイルとなっています。 -IME ON/OFF のキーのみ、IME ON → OFF のときにも反映されます。 +設定ダイアログで OK ボタンまたは適用ボタンを押すと config.xml ファイルが保存されます。 +テキストエディタなどでも編集可能です。変更した後は、IME OFF → ON で新しい設定が反映されます。 -### 設定ファイル、SKK辞書 +下記のディレクトリの優先順位で各ファイルが読み込まれます。 -各種設定及び取込済SKK辞書は、ディレクトリ %AppData%\CorvusSKK の各ファイルに保存されます。 +1. %APPDATA%\CorvusSKK +2. %SystemRoot%\IME\IMCRVSKK (インストーラーによりインストール済み) + +> **開発者向け** +> +> デバッグビルドでは、ディレクトリ %APPDATA%\CorvusSKK_DEBUG に保存されます。 +> +> デバッグビルドでは、下記のディレクトリの優先順位で各ファイルが読み込まれます。 +> +> 1. %APPDATA%\CorvusSKK_DEBUG +> 2. 実行ファイルと同じディレクトリ (ビルドするとディレクトリ installer\config-share から上書きコピーされます) -| ファイル名 | 説明 | -|---|---| -| config.xml | 各種設定 | -| skkdict.txt | 取込済SKK辞書 | -各種設定の config.xml ファイルは、UTF-8 の XML フォーマットのテキストファイルとなっています。 +### SKK辞書ファイル -設定ダイアログで OK ボタンまたは適用ボタンを押すと config.xml ファイルが保存されます。テキストエディタなどでも編集可能です。変更した後は、IME OFF → ON で新しい設定が反映されます。 +後述の[SKK辞書](#skk辞書)の項も合わせて参照してください。 + +取込済SKK辞書は、ディレクトリ %APPDATA%\CorvusSKK に保存されます。 + +| ファイル名 | 説明 | +| --- | --- | +| skkdict.txt | 取込済SKK辞書 | -取込済SKK辞書の skkdict.txt ファイルは、UTF-16 (LE, BOMあり) のSKK辞書フォーマットとなっています。 +UTF-16 (LE, BOMあり) のSKK辞書フォーマットとなっています。 -設定ダイアログのリストにSKK辞書を追加して取込ボタンを押すと取込済SKK辞書に変換されます。後述の[SKK辞書](#skk辞書)の項を参照してください。 +設定ダイアログのリストにSKK辞書を追加して取込ボタンを押すと取込済SKK辞書に変換されます。 ディレクトリ %SystemRoot%\IME\IMCRVSKK に NAIST-jdic をベースとした簡易的なSKK辞書が標準でインストール済みとなっています。取込済SKK辞書が存在しないときはこのSKK辞書が使用されます。 @@ -129,39 +127,53 @@ SKK辞書サーバーを使用するなどでローカルのSKK辞書を使用 下記のディレクトリの優先順位で各ファイルが読み込まれます。 -1. %AppData%\CorvusSKK +1. %APPDATA%\CorvusSKK 2. %SystemRoot%\IME\IMCRVSKK (インストーラーによりインストール済み) > **開発者向け** > -> デバッグビルドでは、ディレクトリ %AppData%\CorvusSKK_DEBUG の各ファイルに保存されます。 +> デバッグビルドでは、ディレクトリ %APPDATA%\CorvusSKK_DEBUG の各ファイルに保存されます。 > > デバッグビルドでは、下記のディレクトリの優先順位で各ファイルが読み込まれます。 > -> 1. %AppData%\CorvusSKK_DEBUG +> 1. %APPDATA%\CorvusSKK_DEBUG > 2. 実行ファイルと同じディレクトリ (ビルドするとディレクトリ installer\config-share から上書きコピーされます) -### ユーザー辞書 +### ユーザー辞書ファイル + +後述の[ユーザー辞書](#ユーザー辞書)の項も合わせて参照してください。 -ユーザー辞書は、ディレクトリ %AppData%\CorvusSKK の各ファイルに保存されます。 +ユーザー辞書は、ディレクトリ %APPDATA%\CorvusSKK の各ファイルに保存されます。 | ファイル名 | 説明 | -|---|---| +| --- | --- | | userdict.txt | ユーザー辞書 | -| userdict.bk1
userdict.bk2
userdict.bk3 | ユーザー辞書バックアップ (3世代まで) | + +ユーザー辞書バックアップは、任意のディレクトリの各ファイルに保存されます。 + +デフォルトは %APPDATA%\CorvusSKK で、設定ダイアログの「辞書2」タブのユーザー辞書バックアップディレクトリで設定可能です。 + +| ファイル名 | 説明 | +| --- | --- | +| userdict.txt.*YYYYMMDDThhmmssZ*.bak | ユーザー辞書バックアップ (最大255世代まで)
*YYYYMMDDThhmmssZ* : バックアップされた日時 ISO8601 (UTC) | UTF-16 (LE, BOMあり) のSKKユーザー辞書フォーマットで書き込まれます。 -ユーザー辞書を直接編集する際は、ログオンユーザー権限で動作している辞書管理プロセス (imcrvmgr.exe) をタスクマネージャなどで終了させた状態でおこなってください。 +ユーザー辞書を直接編集する際は、ログオンユーザー権限で動作している辞書管理プロセス (imcrvmgr.exe) を終了させた状態でおこなってください。 + +* 設定ダイアログの「辞書2」タブの「辞書管理プロセス」で「終了」ボタンを押す。 +* タスクマネージャで 「CorvusSKK Dictionary Manager」 (imcrvmgr.exe) を終了する。 +* コマンドプロンプトなどで「taskkill /im imcrvmgr.exe」などと実行する。 編集後、以下のいずれかの操作をおこなうと辞書管理プロセスが自動的に起動します。 +* 設定ダイアログの「辞書2」タブの「辞書管理プロセス」で「実行」ボタンを押す。 * IME OFF → ON * 仮名漢字変換開始 * 補完開始 -辞書管理プロセスを直接実行することも可能です。 +辞書管理プロセス (imcrvmgr.exe) を直接実行することも可能です。 ユーザー辞書は、辞書管理プロセスの起動時にメモリ上に読み込まれ、候補の確定、登録、削除があったとき、かつ、以下のいずれかのときに上書きされます。 @@ -170,19 +182,112 @@ UTF-16 (LE, BOMあり) のSKKユーザー辞書フォーマットで書き込ま * IME ON 状態で別の IME に切り替えるとき * アプリケーションがフォーカスを失うとき * 辞書管理プロセスが終了するとき -* スリープ、休止状態から復帰するとき +* スリープ、休止状態から復帰したとき +* 設定ダイアログの「辞書2」タブの「ユーザー辞書バックアップ」で手動バックアップを実行したとき ユーザー辞書バックアップは辞書管理プロセスによって以下のいずれかのときに作成されます。 -* シャットダウン、再起動するとき -* ログオフ、スリープ、休止状態から復帰するとき +* ログオフ、シャットダウン、再起動するとき +* スリープ、休止状態から復帰したとき +* 設定ダイアログの「辞書2」タブの「ユーザー辞書バックアップ」で手動バックアップを実行したとき + + + +## 入力モード + + +### 入力モードアイコン + +| ノーマルモード | プライベートモード | 説明 | +| :---: | :---: | --- | +| ![](installer/resource-md/00_input_mode_default.png) | ![](installer/resource-md/00_input_mode_default.png) | IME OFF | +| ![](installer/resource-md/00_input_mode_hiragana.png) | ![](installer/resource-md/00_input_mode_p_hiragana.png) | ひらがなモード | +| ![](installer/resource-md/00_input_mode_katakana.png) | ![](installer/resource-md/00_input_mode_p_katakana.png) | カタカナモード | +| ![](installer/resource-md/00_input_mode_katakana1.png) | ![](installer/resource-md/00_input_mode_p_katakana1.png) | 半角カタカナモード | +| ![](installer/resource-md/00_input_mode_jlatin.png) | ![](installer/resource-md/00_input_mode_p_jlatin.png) | 全角英数字モード | +| ![](installer/resource-md/00_input_mode_ascii.png) | ![](installer/resource-md/00_input_mode_p_ascii.png) | ASCIIモード | + +通知領域の入力モードアイコンを左クリックすると、IME ON/OFF を切り替えます。 + + +### メニュー + +有効な項目にはチェックが入ります。 + +| 言語バーから表示 | 通知領域から表示 | +| :---: | :---: | +| ![](installer/resource-md/01_input_menu_0.png) | ![](installer/resource-md/01_input_menu_1.png) | +| 言語バーの入力モードアイコンを左クリック | 通知領域の入力モードアイコンを右クリック | + +| メニュー項目 | 説明 | +| --- | --- | +| CAPS | Caps Lock をトグルします。 | +| KANA | カナキーロックをトグルします。 | +| Private | プライベートモードをトグルします。 | +| [かな] | ひらがなモードに遷移します。 | +| [カナ] | カタカナモードに遷移します。 | +| [-カナ] | 半角カタカナモードに遷移します。 | +| [全英] | 全角英数字モードに遷移します。 | +| [SKK] | ASCIIモードに遷移します。 | +| [--] | IME OFF | +| 設定 | 設定ダイアログを表示します。 | +| キャンセル | メニューを閉じます。 | + + +### デフォルトキー設定と入力モード遷移図 + +![](installer/resource-md/02_key_and_mode.png) + + +### 半角カタカナモード + +半角カタカナモードでは、ローマ字仮名変換のみ可能です。 + +ひらがな/カタカナへの変換、仮名漢字変換は出来ません。 + + +### プライベートモード + +プライベートモードでは、通常の仮名漢字変換は可能ですが、ユーザー辞書の更新と削除をおこないません。 + +また、辞書登録ウィンドウでの入力による確定も可能ですが、ユーザー辞書に登録されません。 + +後述の[ユーザー辞書](#ユーザー辞書)の項を参照してください。 + + + +## 設定 + + +### 設定ダイアログ + +設定ダイアログは、以下のいずれかの操作で開くことができます。 + +* 言語バーを右クリックし、メニューから「設定」を選択する。「テキストサービスと入力言語」ダイアログの「インストールされているサービス」からCorvusSKKを選択し、プロパティボタンを押す。 +* 言語バーの入力モードアイコンを左クリックし、メニューから「設定」を選択する。 +* 言語バーのヘルプボタンを左クリックし、メニューから「CorvusSKK」を選択する。 +* Windows 8 以降の通知領域の入力モードアイコンを右クリックし、メニューから「設定」を選択する。 +* スタートメニューから CorvusSKK\CONFIG を実行する。 +* %SystemRoot%\System32\IME\IMCRVSKK\imcrvcnf.exe または %SystemRoot%\SysWOW64\IME\IMCRVSKK\imcrvcnf.exe を直接実行する + * コマンドライン引数、または実行ファイルやショートカットへのドラッグアンドドロップで、前述の設定ファイルを渡すことが可能です。 + +設定ダイアログで保存した後は、IME OFF → ON で新しい設定が反映されます。 + +IME ON/OFF のキーのみ、IME ON → OFF のときにも反映されます。 + + +### 仮想キーコード + +仮想キーコードの詳細はこちらを参照してください。 https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes + +設定ダイアログのタブ「[辞書2](#ユーザー辞書)」「[キー0](#キー設定onoff)」「[キー2](#キー設定文字キー設定仮想キー)」のそれぞれ右上にある「仮想キーテスト」エディットボックスにフォーカスがある状態でキー入力すると仮想キーコードを表示します。 ### SKK辞書 -![](installer/resource-md/01_dictionary.png) +![](installer/resource-md/101_dictionary_1.png) -SKK辞書の詳細はこちらを参照ください。 +SKK辞書の詳細はこちらを参照してください。 * https://skk-dev.github.io/dict/ @@ -194,7 +299,9 @@ SKK辞書の詳細はこちらを参照ください。 * http://openlab.ring.gr.jp/skk/skk/dic/ -SKK辞書ファイルの文字コードは、EUC-JIS-2004、UTF-8 (BOMなし/あり)、UTF-16 (LE, BOMあり) に対応しています。 +SKK辞書ファイルの文字コードは、EUC-JIS-2004、EUC-JP、UTF-8 (BOMなし/あり)、UTF-16 (LE, BOMあり) に対応しています。 + +EUC-JP は、ASCII、JIS X 0208、JIS X 0201 片仮名、JIS X 0212 を実装する、いわゆる IANA の EUC-JP となっています。 アーカイブファイルフォーマットは tar、gzip に対応しています。 @@ -223,17 +330,51 @@ SKK辞書のダウンロード機能では HTTP, HTTPS が使用可能です。 同時に1つのみ使用可能です。IPv4、IPv6 に対応しています。 -通信に使用する文字コードは、EUC-JIS-2004、UTF-8 に対応していますが、通常のSKK辞書サーバーではデフォルトの EUC-JIS-2004 を使用してください。 +通信に使用する文字コードは、EUC-JIS-2004 / EUC-JP、UTF-8 に対応しています。 + +通常のSKK辞書サーバーではデフォルトの EUC-JIS-2004 / EUC-JP を使用してください。 サーバーコンプリーション機能は未実装です。 +### ユーザー辞書 + +![](installer/resource-md/102_dictionary_2.png) + +| 機能 | 説明 | +| --- | --- | +| 辞書管理プロセス | 辞書管理プロセスを終了または開始します。 | +| ユーザーディレクトリ | ディレクトリ %APPDATA%\CorvusSKK をシェルで開きます。 | +| システムディレクトリ | ディレクトリ %SystemRoot%\IME\IMCRVSKK をシェルで開きます。 | +| ユーザー辞書バックアップ | ユーザー辞書バックアップのディレクトリと世代数を指定します。
また、そのディレクトリをシェルで開きます。
手動でバックアップを実行します。 | +| プライベートモード | プライベートモードの任意切替のキーと自動切替を指定します。 | + +ユーザー辞書バックアップ + +* ディレクトリの指定には環境変数を使用することが可能です。 +* 存在しないディレクトリを指定した場合すぐにはシェルで開けません。 + すぐに開くには、適用ボタンを押して設定を保存した後、辞書管理プロセスを終了→実行し、手動バックアップを実行してください。 + 辞書管理プロセスがバックアップファイルを作成するときにディレクトリも作成します。 +* ディレクトリをWindowsネットワークの共有フォルダーにした場合、ログオフ/シャットダウン/再起動するときや、スリープ/休止状態から復帰したときに正常に保存されない可能性があります。 +* 手動バックアップを実行できる条件 + * 辞書管理プロセスが実行中。 + * ユーザー辞書バックアップのディレクトリと世代数が未編集、または編集した後に適用して保存済み。 + +プライベートモード + +* 任意切替のデフォルトのキーは、Ctrl + Shift + F10 です。 +* 自動切替をONに設定すると、Edge の InPrivate ウィンドウ, Chrome のシークレットウィンドウ, Firefox のプライベートウィンドウなどで自動的にプライベートモードに切り替えられます。InputScope が IS_PRIVATE に設定されている入力が対象です。 +* 自動切替をOFFに設定すると、InputScope が IS_PRIVATE に設定されている入力でも自動的にプライベートモードになりません。 + +「仮想キーテスト」エディットボックスにフォーカスがある状態でキー入力すると仮想キーコードを表示します。 + + ### 動作 -![](installer/resource-md/02_behavior_1.png) +![](installer/resource-md/103_behavior_1.png) | 機能 | 説明 | -|---|---| +| --- | --- | | 初期入力モード | プログラム起動時の入力モードを指定します。 | | 送り仮名が決定したとき変換を開始する | 送り仮名を入力したとき自動的に変換を開始します。接頭辞も同様です。 | | 送り仮名が一致した候補を優先する | 送り仮名ブロックの送り仮名が一致する候補を優先して出力します。 | @@ -246,10 +387,10 @@ SKK辞書のダウンロード機能では HTTP, HTTPS が使用可能です。 | かな/カナ入力モードをトグルする | キー設定「かな/カナ」「カナ全英変換」のキーでひらがなモードに遷移します。
無効のときは、キー設定「ひらがな」のキーでひらがなモードに遷移してください。 | | キー設定「直接入力」を確定入力で使用する | 確定入力のとき、キー設定の「直接入力」で設定された文字で始まるローマ字を仮名変換しません。
(ひらがな/カタカナ/半角カタカナモードのとき) | -![](installer/resource-md/03_behavior_2.png) +![](installer/resource-md/104_behavior_2.png) | 機能 | 説明 | -|---|---| +| --- | --- | | 複数補完/複数動的補完の表示数 | 複数補完、複数動的補完での1ページあたりの候補数を指定します。 | | 複数補完を使用する | 通常の補完のとき、ユーザー辞書から補完された見出し語を一覧で表示します。
補完対象は「候補一覧の色」の「選択」、補完部分は「候補」の色が使用されます。 | | 動的補完を使用する | 見出し語が入力されたとき、ユーザー辞書から補完された見出し語を表示します。 | @@ -260,34 +401,35 @@ SKK辞書のダウンロード機能では HTTP, HTTPS が使用可能です。 ### 表示 -![](installer/resource-md/04_display1.png) +![](installer/resource-md/105_display_1.png) | 機能 | 説明 | -|---|---| +| --- | --- | | 候補一覧のフォント | 候補一覧に表示するフォントの種類、スタイル、サイズを指定します。 | | 候補一覧の最大幅 | 候補一覧の最大幅のサイズを指定します。 | | 候補一覧の色 | 候補一覧の色を指定します。 | | 候補一覧の描画API | 候補一覧の描画をおこなうAPIを指定します。
Direct2Dと彩色の指定でカラーフォントを表示します。(Windows8.1以降) | | 候補一覧表示に要する変換回数(0は表示無し) | 指定した回数変換すると候補一覧が表示されます。 | +| 候補一覧表示のページ当たり表示数 | 一度に表示される候補の数を指定します。 | | 候補一覧が表示無しのとき候補数を表示する | (<現在の候補の番号>/<候補数>) の形式を追加して表示します。 | | 候補一覧を縦に表示する | 候補一覧で候補を縦に並べて表示します。 | | 注釈を表示する | <候補><セミコロン><注釈> の形式で注釈を表示します。
「候補一覧」の指定で候補一覧に限定されます。 | | ▽▼\*マークを表示する | 大切なものは目に見えないようです。 | | ローマ字を表示する | 仮名文字のローマ字プレフィックスを表示します。
「全英」の指定でいわゆる全角文字で表示されます。 | -![](installer/resource-md/05_display2.png) +![](installer/resource-md/106_display_2.png) | 機能 | 説明 | -|---|---| +| --- | --- | | 入力モードを表示する | キャレットまたは辞書登録ウィンドウ付近に入力モードを表示します。
タイミングは、IME ON/OFF 変更、入力モード変更、IME ON/OFF キー押下、「\*無効\*」キー押下のときです。
表示する秒数として1〜60000ミリ秒を設定してください。デフォルト値は3000ミリ秒です。 | | 入力モードの色 | 入力モード表示の色を指定します。 | ### 表示属性 -![](installer/resource-md/06_display_attribute_1.png) +![](installer/resource-md/107_display_attribute_1.png) -![](installer/resource-md/07_display_attribute_2.png) +![](installer/resource-md/108_display_attribute_2.png) 入力中文字列の表示属性を設定します。 @@ -298,47 +440,65 @@ SKK辞書のダウンロード機能では HTTP, HTTPS が使用可能です。 ### 候補一覧選択キー -![](installer/resource-md/08_select_key.png) +![](installer/resource-md/109_select_key.png) + +候補一覧に表示する文字とキーを設定します。数字、表示、予備1,2 のいずれかの入力で選択された候補が確定されます。 + +「表示」にはUnicodeの基本多言語面と追加面の文字が使用可能です。追加面の文字の場合は、その文字で候補を確定することはできません。 + +「予備1」「予備2」にはUnicodeの基本多言語面の文字のみ使用可能です。 -候補一覧での確定は、デフォルトで 1〜7 と ASDFJKL と asdfjkl を使用します。 +[表示1](#表示)の「候補一覧表示のページ当たり表示数」の設定によって一度に表示される数が決められます。 -コマンドプロンプト等では、デフォルトで 1〜9 と ASDFJKLGH と asdfjklgh を使用します。 +レガシータイプのコマンドプロンプト等の自前で候補を表示するアプリケーションでは、アプリケーション側が要求した数に従います。 候補一覧が表示されているとき、KANAキーロックは無視されます。 | 機能 | 説明 | -|---|---| +| --- | --- | | 数字 | 選択キー (1〜9で固定) | | 表示 | 選択キー (必須、候補一覧の表示にも使用) | -| 予備1,2 | 選択キー (空でもOK) | +| 予備1,2 | 選択キー (空でも可) | + +フォントによっては固定幅を持つ以下の文字が表示としては見易いようです。 + +| 名称 | 範囲 | 文字 | 備考 | +| --- | --- | --- | --- | +| PARENTHESIZED
LATIN SMALL LETTER | U+249C
~U+24B5 | ⒜⒝⒞⒟⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵ | | +| CIRCLED
LATIN CAPITAL LETTER | U+24B6
~U+24CF | ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ | Mは地下鉄の絵文字? | +| CIRCLED
LATIN SMALL LETTER | U+24D0
~U+24E9 | ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ | JIS X 0213
1-12-33~1-12-58 | +| FULLWIDTH
LATIN CAPITAL LETTER | U+FF21
~U+FF3A | ABCDEFGHIJKLMNOPQRSTUVWXYZ | JIS X 0208
3-33~3-58 | +| FULLWIDTH
LATIN SMALL LETTER | U+FF41
~U+FF5A | abcdefghijklmnopqrstuvwxyz | JIS X 0208
3-65~3-90 | +| PARENTHESIZED
LATIN CAPITAL LETTER | U+1F110
~U+1F129 | 🄐🄑🄒🄓🄔🄕🄖🄗🄘🄙🄚🄛🄜🄝🄞🄟🄠🄡🄢🄣🄤🄥🄦🄧🄨🄩 | | +| SQUARED
LATIN CAPITAL LETTER | U+1F130
~U+1F149 | 🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉 | | +| NEGATIVE CIRCLED
LATIN CAPITAL LETTER | U+1F150
~U+1F169 | 🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩 | | +| NEGATIVE SQUARED
LATIN CAPITAL LETTER | U+1F170
~U+1F189 | 🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉 | ABOは血液型の絵文字
Pは駐車場の絵文字 | ### キー設定(ON/OFF) -![](installer/resource-md/09_on_off_key.png) +![](installer/resource-md/110_on_off_key.png) IME ON/OFF のキーをそれぞれ指定します。 仮想キーコード、Alt、Control、Shift の組合せを設定してください。 -「仮想キー表示」エディットボックスにフォーカスがある状態でキー入力すると仮想キーコードを表示します。 - -仮想キーコードの詳細はこちらを参照ください。 https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes - 最大で ON/OFF それぞれ8行ずつです。 +「仮想キーテスト」エディットボックスにフォーカスがある状態でキー入力すると仮想キーコードを表示します。 + ### キー設定(文字)、キー設定(仮想キー) -![](installer/resource-md/10_key1_character.png) +![](installer/resource-md/111_key1_character.png) -![](installer/resource-md/11_key2_virtual_key.png) +![](installer/resource-md/112_key2_virtual_key.png) 各機能に対してキーを正規表現で設定してください。 -Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用しています。 +Visual C++ 2022 の 正規表現で、文法は ECMAScript を使用しています。 -正規表現の詳細はこちらを参照ください。 https://docs.microsoft.com/en-us/cpp/standard-library/regular-expressions-cpp?view=vs-2019 +正規表現の詳細はこちらを参照してください。 https://learn.microsoft.com/en-us/cpp/standard-library/regular-expressions-cpp?view=msvc-170 無効な正規表現で設定するとその機能は無効となります。警告等は表示されません。 @@ -350,101 +510,94 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま 例えば、Shift+Tabであれば「S\x09」、Ctrl+Returnであれば「C\x0D」と記述します。 +「仮想キーテスト」エディットボックスにフォーカスがある状態でキー入力すると仮想キーコードを表示します。 + ### キー設定デフォルト キー設定 ON/OFF -| 機能 | キー | 説明 | -|---|---|---| -| ON / OFF | Alt+\` | 0xC0 + Alt | -| 〃 | 漢字 | 0x19 | -| 〃 | (Alt+半角/全角 Alt+\`) | 0x19 | -| 〃 | 半角/全角(Ctrl+\`) | 0xF3, 0xF4 | +| ON | OFF | キー | 仮想キーコード | +| --- | --- | --- | --- | +| ✓ | ✓ | Alt + \` | 0xC0 + Alt | +| ✓ | ✓ | 漢字
Alt + 半角/全角
Alt + \` | 0x19 | +| ✓ | ✓ | 半角/全角
Ctrl + \` | 0xF3, 0xF4 | +| ✓ | | IME On | 0x16 | +| | ✓ | IME Off | 0x1A | キー設定(文字) | 機能 | キー | 説明 | -|---|---|---| -| かな/カナ | q | ひらがな/カタカナモード、かなカナ変換 | -| カナ全英変換 | Ctrl+q | ひらがな/半角カタカナモード
ひらがなカタカナ→半角カタカナ変換
abbrev→全角英数字変換 | -| 全英 | L | 全英モード | -| ASCII | l | アスキーモード | -| ひらがな | | ひらがなモード | -| abbrev | / | abbrevモード | -| 接辞 | < > | 接頭辞・接尾辞 | -| 次候補 | Space Ctrl+n | 辞書検索開始、次候補 | -| 前候補 | x Ctrl+p | 「後退」のキーも使用可 | -| 辞書削除 | X Ctrl+x | ユーザー辞書から候補を削除 | -| 次補完 | Ctrl+i(Tab) | 補完開始、次見出し語候補 | -| 前補完 | Ctrl+u | 前見出し語候補 | -| 補完と変換 | Ctrl+c | 最初の見出し語候補で辞書検索開始
skk-start-henkan-with-completion-char | -| 絞り込み | | 候補を絞り込む見出し語の入力開始
skk-hint-start-char | -| 変換位置 | | 変換位置指定
2回連続入力で文字自体が確定する
skk-sticky-key | -| 直接入力 | 0〜9 | 見出し語入力でローマ字仮名変換しない | -| 確定 | Ctrl+m(Return) Ctrl+j | | -| 取消 | Ctrl+g Ctrl+[(Escape) | | -| 後退 | Ctrl+h(BS) | | -| 削除 | Ctrl+d DEL(Ctrl+BS) | | -| \*無効\* | | アプリケーション側に非通知
辞書登録/削除の確定無効 | -| 左移動 | Ctrl+b | | -| 先頭移動 | Ctrl+a | | -| 右移動 | Ctrl+f | | -| 末尾移動 | Ctrl+e | | -| 貼付 | Ctrl+y Ctrl+v | クリップボードの文字列を貼り付け | +| --- | --- | --- | +| かな/カナ | q | ひらがな/カタカナモード、かなカナ変換 | +| カナ全英変換 | Ctrl + q | ひらがな/半角カタカナモード
ひらがなカタカナ→半角カタカナ変換
abbrev→全角英数字変換 | +| 全英 | L | 全英モード | +| ASCII | l | アスキーモード | +| ひらがな | | ひらがなモード | +| abbrev | / | abbrevモード | +| 接辞 | < > | 接頭辞・接尾辞 | +| 次候補 | Space
Ctrl + n | 辞書検索開始、次候補 | +| 前候補 | x
Ctrl + p | 「後退」のキーも使用可 | +| 辞書削除 | X
Ctrl + x | ユーザー辞書から候補を削除 | +| 次補完 | Ctrl + i (Tab) | 補完開始、次見出し語候補 | +| 前補完 | Ctrl + u | 前見出し語候補 | +| 補完と変換 | Ctrl + c | 最初の見出し語候補で辞書検索開始
skk-start-henkan-with-completion-char | +| 絞り込み | | 候補を絞り込む見出し語の入力開始
skk-hint-start-char | +| 変換位置 | | 変換位置指定
2回連続入力で文字自体が確定する
skk-sticky-key | +| 直接入力 | 0〜9 | 見出し語入力でローマ字仮名変換しない | +| 確定 | Ctrl + m (Return)
Ctrl + j | | +| 取消 | Ctrl + g
Ctrl + [ (Escape) | | +| 後退 | Ctrl + h (BS) | | +| 削除 | Ctrl + d
DEL (Ctrl + BS) | | +| \*無効\* | | アプリケーション側に非通知
辞書登録/削除の確定無効 | +| 左移動 | Ctrl + b | | +| 先頭移動 | Ctrl + a | | +| 右移動 | Ctrl + f | | +| 末尾移動 | Ctrl + e | | +| 貼付 | Ctrl + y Ctrl + v | クリップボードの文字列を貼り付け | +| 再変換 | | 選択された文字列でユーザー辞書の送りなしエントリを
逆引きしてから通常の辞書検索 | キー設定(仮想キー) | 機能 | キー | 説明 | -|---|---|---| -| かな/カナ | | ひらがな/カタカナモード、かなカナ変換 | -| カナ全英変換 | | ひらがな/半角カタカナモード
ひらがなカタカナ→半角カタカナ変換
abbrev→全角英数字変換 | -| 全英 | | 全英モード | -| ASCII | | アスキーモード | -| ひらがな | Ctrl+0x4A (Ctrl+j) | ひらがなモード | -| abbrev | | abbrevモード | -| 接辞 | | 接頭辞・接尾辞 | -| 次候補 | 0x22 (PgDn) | 辞書検索開始、次候補 | -| 前候補 | 0x21 (PgUp) | 「後退」のキーも使用可 | -| 辞書削除 | | ユーザー辞書から候補を削除 | -| 次補完 | | 補完開始、次見出し語候補 | -| 前補完 | Shift+0x09(Shift+Tab) | 前見出し語候補 | -| 補完と変換 | | 先頭の見出し語候補で辞書検索開始
skk-start-henkan-with-completion-char | -| 絞り込み | | 候補を絞り込む見出し語の入力開始
skk-hint-start-char | -| 変換位置 | | 変換位置指定
skk-sticky-key | -| 直接入力 | | 見出し語入力でローマ字仮名変換しない(不使用) | -| 確定 | | | -| 取消 | | | -| 後退 | | | -| 削除 | 0x2E (Delete) | | -| \*無効\* | Ctrl+0x4A (Ctrl+j) | アプリケーション側に非通知
辞書登録/削除の確定無効 | -| 左移動 | 0x25 (カーソル左) | | -| 先頭移動 | 0x26 (カーソル上) | | -| 右移動 | 0x27 (カーソル右) | | -| 末尾移動 | 0x28 (カーソル下) | | -| 貼付 | | クリップボードの文字列を貼り付け | - - -### キー設定と入力モード遷移図 - -![](installer/resource-md/20_key_and_mode.png) - - -### 半角カタカナモード - -半角カタカナモードでは、ローマ字仮名変換のみ可能です。 - -ひらがな/カタカナへの変換、仮名漢字変換は出来ません。 +| --- | --- | --- | +| かな/カナ | | ひらがな/カタカナモード、かなカナ変換 | +| カナ全英変換 | | ひらがな/半角カタカナモード
ひらがなカタカナ→半角カタカナ変換
abbrev→全角英数字変換 | +| 全英 | | 全英モード | +| ASCII | | アスキーモード | +| ひらがな | Ctrl + 0x4A (Ctrl + j) | ひらがなモード | +| abbrev | | abbrevモード | +| 接辞 | | 接頭辞・接尾辞 | +| 次候補 | 0x22 (PgDn) | 辞書検索開始、次候補 | +| 前候補 | 0x21 (PgUp) | 「後退」のキーも使用可 | +| 辞書削除 | | ユーザー辞書から候補を削除 | +| 次補完 | | 補完開始、次見出し語候補 | +| 前補完 | Shift + 0x09 (Shift + Tab) | 前見出し語候補 | +| 補完と変換 | | 先頭の見出し語候補で辞書検索開始
skk-start-henkan-with-completion-char | +| 絞り込み | | 候補を絞り込む見出し語の入力開始
skk-hint-start-char | +| 変換位置 | | 変換位置指定
skk-sticky-key | +| 直接入力 | | 見出し語入力でローマ字仮名変換しない | +| 確定 | | | +| 取消 | | | +| 後退 | | | +| 削除 | 0x2E (Delete) | | +| \*無効\* | Ctrl + 0x4A (Ctrl + j) | アプリケーション側に非通知
辞書登録/削除の確定無効 | +| 左移動 | 0x25 (カーソル左) | | +| 先頭移動 | 0x26 (カーソル上) | | +| 右移動 | 0x27 (カーソル右) | | +| 末尾移動 | 0x28 (カーソル下) | | +| 貼付 | | クリップボードの文字列を貼り付け | +| 再変換 | | 選択された文字列でユーザー辞書の送りなしエントリを
逆引きしてから通常の辞書検索 | ### 変換位置指定 -![](installer/resource-md/12_conversion_point.png) +![](installer/resource-md/113_conversion_point.png) 変換位置での挙動を指定します。最大で256行です。 | 機能 | 説明 | -|---|---| +| --- | --- | | 開始 | 変換位置開始キー | | 代替 | 変換位置開始キーに代わってローマ字仮名変換に使用する | | 送り | 辞書検索に使用する送りローマ字 | @@ -452,23 +605,23 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま * 例1)AZIK風に以下のように設定したとき「KaQ」と入力すると、表示「▽か\*ん」、辞書検索キー「かn」と入力できます。 | 開始 | 代替 | 送り | - |---|---|---| + | --- | --- | --- | | Q | q | n | | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | - |---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | | q | ん | ン | ン | OFF | OFF | * 例2)以下のように設定したとき、かな入力で送り仮名の最初を「あ」の状態で辞書検索を開始すると、送りローマ字が「a」となります。 | 開始 | 代替 | 送り | - |---|---|---| + | --- | --- | --- | | | あ | a | ### ローマ字・仮名変換表 -![](installer/resource-md/13_kana.png) +![](installer/resource-md/114_kana.png) ローマ字、平仮名、片仮名、所謂半角片仮名、促音/撥音(ん)、待機の組み合せを指定します。 @@ -477,7 +630,7 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま * 例1) 以下のように設定したとき「motto」と入力することで「もっと」と入力することができます。 | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | - |---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | | mo | も | モ | モ | OFF | OFF | | tt | っ | ッ | ッ | **ON** | OFF | | to | と | ト | ト | OFF | OFF | @@ -485,7 +638,7 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま * 例2) 以下のように設定したとき「dango」と入力することで「だんご」と入力することができます。 | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | - |---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | | da | だ | ダ | ダ | OFF | OFF | | ng | ん | ン | ン | **ON** | OFF | | go | ご | ゴ | ゴ | OFF | OFF | @@ -493,17 +646,17 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま * 例3) 以下のように設定したとき「w」の連続入力により草を生やすことができます。 | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | 説明 | - |---|---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | --- | | ww | w | w | w | **ON** | OFF | Latin Small Letter W → Fullwidth Latin Small Letter W | | w | w | w | w | OFF | OFF | Latin Small Letter W → Fullwidth Latin Small Letter W | * 「待機」 * 「待機」がONのとき、入力した文字をローマ字仮名変換した結果 (変換出来ないときは入力した文字そのまま) がローマ字として扱われ、辞書検索開始、確定、補完開始、ローマ字に設定されていない組み合わせ、のいずれかになるまで仮名の最終的な決定が遅延されます。 - * 「待機」機能サンプルを参照してください。[https://github.com/nathancorvussolis/corvusskk/blob/master/installer/config-sample/config - wait-sample.xml](https://github.com/nathancorvussolis/corvusskk/blob/master/installer/config-sample/config%20-%20wait-sample.xml) + * 「待機」機能サンプルを参照してください。[https\://github.com/nathancorvussolis/corvusskk/blob/master/installer/config-sample/config - wait-sample.xml](https://github.com/nathancorvussolis/corvusskk/blob/master/installer/config-sample/config%20-%20wait-sample.xml) * 例1) カナキーロックした状態で「か」と濁点を入力することで「が」と入力することができます。濁点、半濁点のローマ字部分は、現状1文字のみ対応しています。 | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | 説明 | - |---|---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | --- | | カ | か | カ | カ | OFF | **ON** | JIS X 0201 仮名 → JIS X 0208 仮名 | | ゙ | ゛ | ゛ | ゙ | OFF | **ON** | JIS X 0201 濁点 → JIS X 0208 濁点 | | か゛ | が | ガ | ガ | OFF | ON または OFF | 仮名と濁点の合成
待機OFFのとき直ちに確定または辞書検索開始します | @@ -511,7 +664,7 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま * 例2) 以下のように設定したとき「zsssss …」と入力することで「☆」と「★」が繰り返され任意のタイミングで確定することができます。 | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | 説明 | - |---|---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | --- | | zs | ☆ | ☆ | ☆ | OFF | **ON** | | | ☆s | ★ | ★ | ★ | OFF | **ON** | | | ★s | ☆ | ☆ | ☆ | OFF | **ON** | | @@ -519,7 +672,7 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま * 例3) 以下のように設定したとき「w」の連続入力により草を生やすことができます。 | ローマ字 | かな | カナ | カナ | 促/ん | 待機 | 説明 | - |---|---|---|---|---|---|---| + | --- | --- | --- | --- | --- | --- | --- | | w | w | w | w | OFF | **ON** | Latin Small Letter W → Fullwidth Latin Small Letter W | 平仮名/片仮名変換では基本的に1文字ずつ変換されます。 @@ -546,7 +699,7 @@ Visual C++ 2019 の 正規表現で、文法は ECMAScript を使用していま ### ASCII・全英変換表 -![](installer/resource-md/14_full_width_latin.png) +![](installer/resource-md/115_full_width_latin.png) ASCII、全英文字の組み合せを指定します。最大で128行です。 @@ -559,36 +712,36 @@ ASCII、全英文字の組み合せを指定します。最大で128行です。 辞書管理プロセス (imcrvmgr.exe) の各機能の拡張、プログラム実行変換もどき、数値変換をLuaスクリプトで実装しています。 -現在使用しているLuaのバージョンは5.3.5です。 +現在使用しているLuaのバージョンは5.4.7です。 -詳細はこちらを参照ください。https://www.lua.org/manual/5.3/manual.html +詳細はこちらを参照してください。https://www.lua.org/manual/5.4/manual.html Lua内部の文字コードをUTF-8に決め打ちして、Unicode版のWindowsAPIとCランタイム関数を呼ぶようにパッチを当てています。 スクリプトファイルの文字コードはUTF-8のみに対応しています。 -辞書管理プロセスのカレントディレクトリは %AppData%\CorvusSKK になっています。 +辞書管理プロセスのカレントディレクトリは %APPDATA%\CorvusSKK になっています。 コンソールプログラムのlua.exeが %SystemRoot%\System32\IME\IMCRVSKK と %SystemRoot%\SysWOW64\IME\IMCRVSKK にあるので、カスタマイズする際のデバッグ用に使ってください。 辞書管理プロセスの起動時にスクリプトファイル (init.lua) が下記の優先順位で読み込まれます。 -1. %AppData%\CorvusSKK\init.lua +1. %APPDATA%\CorvusSKK\init.lua 2. %SystemRoot%\IME\IMCRVSKK\init.lua (インストーラーによりインストール済み) > **開発者向け** > -> デバッグビルドでは、辞書管理プロセスのカレントディレクトリは %AppData%\CorvusSKK_DEBUG になっています。 +> デバッグビルドでは、辞書管理プロセスのカレントディレクトリは %APPDATA%\CorvusSKK_DEBUG になっています。 > > デバッグビルドでは、下記の優先順位でスクリプトファイルが読み込まれます。 > -> 1. %AppData%\CorvusSKK_DEBUG\init.lua +> 1. %APPDATA%\CorvusSKK_DEBUG\init.lua > 2. 実行ファイルと同じディレクトリのinit.lua (ビルドするとディレクトリ installer\config-lua から上書きコピーされます) ### プログラム実行変換もどき -![](installer/resource-md/21_convert_program.png) +![](installer/resource-md/201_convert_program.png) Emacs Lispのプログラム実行変換に対応していますが、あくまで「もどき」なのでご了承ください。 @@ -597,7 +750,7 @@ Emacs Lisp 辞書ファイル (SKK-JISYO.lisp) などが必要です。 https:// 以下のシンボルに大体対応しています。 | 名称 | 説明 | -|---|---| +| --- | --- | | nil | | | t | | | lambda | | @@ -628,7 +781,7 @@ Emacs Lisp 辞書ファイル (SKK-JISYO.lisp) などが必要です。 https:// | skk-relative-date | | | skk-ignore-dic-word | デフォルト無効 | | skk-omikuji | 独自実装。おみくじを引くことができます。『(skk-omikuji)』 | -| skk-strftime | 独自実装。日時書式出力『(skk-strftime format [unit, diff])』
format : https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?view=vs-2019
unit : 単位 "year", "month", "day", "hour", "min", "sec"
diff : 現在とunitとの差分 | +| skk-strftime | 独自実装。日時書式出力『(skk-strftime format [unit diff])』
format : 以下のstrftime関数のリンク先を参照
unit : 単位 "year", "month", "day", "hour", "min", "sec"
diff : 現在とunitとの差分 | | fill-column | 70で固定 | | comment-start | "/\*" | | comment-end | "\*/" | @@ -639,12 +792,14 @@ skk-omikuji 辞書 https://github.com/nathancorvussolis/corvusskk/blob/master/in skk-strftime 辞書 https://github.com/nathancorvussolis/corvusskk/blob/master/installer/config-sample/skk-strftime.txt +strftime 関数 https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?view=msvc-170 + ### 数値変換 -![](installer/resource-md/22_convert_number.png) +![](installer/resource-md/202_convert_number.png) -タイプ0〜3,5,8,9に対応しています。 +タイプ0,1,2,3,4,5,8,9に対応しています。 タイプ3と5での数値は0〜10^72-1の整数に対応しています。 @@ -653,20 +808,35 @@ skk-strftime 辞書 https://github.com/nathancorvussolis/corvusskk/blob/master/i 見出し語として # (ナンバーサイン)を含み、候補として # と数字を含むエントリが辞書に存在する必要があります。(例:「めいじ#ねん /明治#3年/」) | 候補 | 説明 | 例 | -|---|---|---| +| --- | --- | --- | | #0 | タイプ0 無変換 |「1234567890」→「1234567890」 | | #1 | タイプ1 全角 |「1234567890」→「1234567890」 | | #2 | タイプ2 漢数字 位取りあり |「1234567890」→「一二三四五六七八九〇」 | | #3 | タイプ3 漢数字 位取りなし |「1234567890」→「十二億三千四百五十六万七千八百九十」 | +| #4 | タイプ4 数値再変換 |「123」→見出し語「123」の候補1つ目 | | #5 | タイプ5 大字 |「1234567890」→「拾弐億参千四百五拾六万七千八百九拾」 | | #6 | タイプ6 ローマ数字(独自) |「1234」→「MCCXXXIV」 | | #8 | タイプ8 桁区切り |「1234567890」→「1,234,567,890」 | | #9 | タイプ9 将棋 |「12kin」→「1二金」 | +タイプ4には DDSKK と以下の相違があります。 +辞書に以下のようなエントリがあり「p125」を見出し語として変換したとき、数値エントリの1つ目だけ使用されます。 + + ;; 数値変換タイプ4辞書 + ;; okuri-ari entries. + ;; okuri-nasi entries. + p# /#4/@#4/ + 125 /東京都葛飾区/葛飾区/ + +| \ | 数値変換タイプ4変換結果 | +| --- | --- | +| DDSKK | /東京都葛飾区/葛飾区/@東京都葛飾区/@葛飾区/ | +| 本ソフト | /東京都葛飾区/@東京都葛飾区/ | + ### Unicodeコードポイント変換 -![](installer/resource-md/23_convert_unicode_codepoint.png) +![](installer/resource-md/203_convert_unicode_codepoint.png) 「U+XXXXXX」( コードポイント XXXXXX : 0000-FFFF または 10000-10FFFF ) または「uxxxxxx」( コードポイント xxxxxx : 0000-ffff または 10000-10ffff ) のフォーマットで変換してください。 @@ -676,7 +846,7 @@ skk-strftime 辞書 https://github.com/nathancorvussolis/corvusskk/blob/master/i ### JIS X 0213面区点番号、JIS X 0208区点番号変換 -![](installer/resource-md/24_convert_unicode_jisx0213.png) +![](installer/resource-md/204_convert_unicode_jisx0213.png) JIS X 0213では「X-YY-ZZ」( 面 X : 1-2、 区 YY : 01-94、点 ZZ: 01-94 )、JIS X 0208では「YY-ZZ」( 区 YY : 01-94、点 ZZ: 01-94 ) のフォーマットで変換してください。Unicodeコードポイントが注釈として付加されます。 @@ -686,7 +856,7 @@ JIS X 0213では「X-YY-ZZ」( 面 X : 1-2、 区 YY : 01-94、点 ZZ: 01-94 ) ### 文字コード表記変換 -![](installer/resource-md/25_convert_character_display.png) +![](installer/resource-md/205_convert_character_display.png) 「?X」( X : 任意の1文字以上の文字列 ) のフォーマットで変換してください。 @@ -701,7 +871,7 @@ ASCII, JIS X 0201, JIS X 0213に変換できない文字が含まれていた場 ### 注釈の登録 -![](installer/resource-md/26_register_annotation.png) +![](installer/resource-md/206_register_annotation.png) 辞書登録のとき、登録する候補の入力と同時におこないます。 @@ -719,74 +889,73 @@ ASCII, JIS X 0201, JIS X 0213に変換できない文字が含まれていた場 * 「;;セミコロン」と入力する。 -### Windows 8, 8.1, 10 のタッチキーボード +### 開発環境 -タッチパネルを搭載したマシンでハードウェアキーボードに準拠したレイアウトを使用するには、以下の操作をおこなってください。 +Visual Studio Community 2022 17.10.5 -* Windows 8 の場合 - * 「PC設定」の画面 → 「全般」を選択 → 「タッチキーボード」の項目 → 「ハードウェアキーボードに準拠したレイアウトを使えるようにする」をオン +* Desktop development with C++ -* Windows 8.1 の場合 - * 「PC設定」の画面 → 「PCとデバイス」の画面 → 「入力」を選択 → 「ハードウェアキーボードに準拠したレイアウトをタッチキーボードオプションとして追加する」をオン +* Indivisual components + * Compilers, build tools, and runtimes + * MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) + * MSVC v143 - VS 2022 C++ ARM build tools (Latest) + * MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest) + * SDKs, libraries, and frameworks + * C++ ATL for latest v143 build tools (x86 & x64) + * C++ ATL for latest v143 build tools (ARM) + * C++ ATL for latest v143 build tools (ARM64/ARM64EC) + * Windows 11 SDK (10.0.22621.0) ⦅ バージョン固定 , ARM32 用 ⦆ + * Windows 11 SDK (10.0.26100.0) ⦅ またはそれ以降 , x86/x64/ARM64/ARM64EC 用 ⦆ -* Windows 10 (Ver.1703 まで) の場合 - * 「デバイス」の画面 → 「入力」を選択 → 「ハードウェアキーボードに準拠したレイアウトをタッチキーボードオプションとして追加する」をオン +WiX Toolset v4.0.5 -タッチパネルを搭載していないマシンでハードウェアキーボードに準拠したレイアウトを使用するには、レジストリに以下の値を設定してください。 +* 要 .NET SDK 6 以降 -Windows 10 (Ver.1703 まで) の場合 +* ビルド用バッチファイル内の dotnet build コマンドによって暗黙的に復元 - [HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7] - "EnableCompatibilityKeyboard"=dword:00000001 +pandoc 3.3 -Windows 10 (Ver.1709 から) の場合 - [HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7] - "DisableNewKeyboardExperience"=dword:00000001 +### ビルド手順 +ビルド -### 開発環境 + > installer\_solution_build.cmd -Visual Studio Community 2019 16.5.4 + > installer\_build.cmd -* Desktop development with C++ -* MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.25) -* MSVC v142 - VS 2019 C++ ARM build tools (v14.25) -* MSVC v142 - VS 2019 C++ ARM64 build tools (v14.25) -* C++ ATL for latest v142 build tools (x86 & x64) -* C++ ATL for latest v142 build tools (ARM) -* C++ ATL for latest v142 build tools (ARM64) +ビルド & 署名 & 検証 -WiX Toolset v3.11.2 + > installer\_solution_build.cmd -pandoc 2.9.2.1 + > installer\_sign.cmd + * : SHA-1 thumbprint of certificate + * : RFC-3161 timestamp server -### ビルド手順 + > installer\_verify.cmd -ビルド +デバッグビルド - > installer\_solution_build.cmd - > installer\_build.cmd + > installer\_solution_build_debug.cmd -ビルド & 署名 & 検証 +デバッグビルド IME の登録 (x86, x64) - > installer\_solution_build.cmd - > installer\_sign.cmd + > installer\_debug_reg.cmd - * : SHA-1 hash of certificate for SHA-256 file digest algorithm - * : SHA-256 RFC-3161 timestamp server +デバッグビルド IME の登録解除 (x86, x64) - > installer\_verify.cmd + > installer\_debug_unreg.cmd -クリア +クリーン > installer\_solution_clean.cmd + > installer\_clean.cmd --- -Copyright (C) 2011-2020 SASAKI Nobuyuki +Copyright (C) 2011-2024 SASAKI Nobuyuki nathancorvussolis@gmail.com diff --git a/common/common.cpp b/common/common.cpp index 2902eb1f..f110b077 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -3,18 +3,18 @@ #pragma comment(lib, "bcrypt.lib") -#define CCSUTF16 L", ccs=UTF-16LE" -#define CCSUTF8 L", ccs=UTF-8" -LPCWSTR RccsUTF16 = L"r" CCSUTF16; -LPCWSTR WccsUTF16 = L"w" CCSUTF16; -LPCWSTR RccsUTF8 = L"r" CCSUTF8; -LPCWSTR WccsUTF8 = L"w" CCSUTF8; -LPCWSTR RB = L"rb"; -LPCWSTR WB = L"wb"; +#define CCSUTF16 L",ccs=UTF-16LE" +#define CCSUTF8 L",ccs=UTF-8" +LPCWSTR modeRccsUTF16 = L"rt" CCSUTF16; +LPCWSTR modeWccsUTF16 = L"wt" CCSUTF16; +LPCWSTR modeRccsUTF8 = L"rt" CCSUTF8; +LPCWSTR modeWccsUTF8 = L"wt" CCSUTF8; +LPCWSTR modeRT = L"rt"; +LPCWSTR modeRB = L"rb"; +LPCWSTR modeWB = L"wb"; LPCWSTR fnconfigxml = L"config.xml"; //設定 LPCWSTR fnuserdic = L"userdict.txt"; //ユーザー辞書 -LPCWSTR fnuserbak = L"userdict.bk"; //ユーザー辞書バックアッププレフィックス LPCWSTR fnskkdic = L"skkdict.txt"; //取込SKK辞書 LPCWSTR fninitlua = L"init.lua"; //init.lua @@ -109,95 +109,29 @@ BOOL IsWindowsVersionOrLater(DWORD dwMajorVersion, DWORD dwMinorVersion, DWORD d return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, mask); } -BOOL GetDigest(LPCWSTR pszAlgId, CONST PBYTE data, DWORD datalen, PBYTE digest, DWORD digestlen) -{ - BOOL bRet = FALSE; - - if (digest == nullptr || data == nullptr) - { - return FALSE; - } - - ZeroMemory(digest, digestlen); - - BCRYPT_ALG_HANDLE hAlg; - NTSTATUS status = BCryptOpenAlgorithmProvider(&hAlg, pszAlgId, nullptr, 0); - if (BCRYPT_SUCCESS(status)) - { - DWORD cbHashObject; - ULONG cbResult; - status = BCryptGetProperty(hAlg, BCRYPT_OBJECT_LENGTH, (PBYTE)&cbHashObject, sizeof(DWORD), &cbResult, 0); - if (BCRYPT_SUCCESS(status)) - { - PBYTE pbHashObject = (PBYTE)LocalAlloc(LPTR, cbHashObject); - if (pbHashObject != nullptr) - { - BCRYPT_HASH_HANDLE hHash; - status = BCryptCreateHash(hAlg, &hHash, pbHashObject, cbHashObject, nullptr, 0, 0); - if (BCRYPT_SUCCESS(status)) - { - status = BCryptHashData(hHash, data, datalen, 0); - if (BCRYPT_SUCCESS(status)) - { - status = BCryptFinishHash(hHash, digest, digestlen, 0); - if (BCRYPT_SUCCESS(status)) - { - bRet = TRUE; - } - } - BCryptDestroyHash(hHash); - } - LocalFree(pbHashObject); - } - } - BCryptCloseAlgorithmProvider(hAlg, 0); - } - - return bRet; -} - BOOL IsLittleEndian() { ULONG n = 1; return (*(UCHAR *)&n == 1); } -ULONG htonlc(ULONG h) +ULONG bswap_l(ULONG l) { - if (IsLittleEndian()) - { - h = (h << 24) | ((h & 0x0000FF00) << 8) | - ((h >> 8) & 0x0000FF00) | (h >> 24); - } - return h; + return (IsLittleEndian() ? _byteswap_ulong(l) : l); } -ULONG ntohlc(ULONG n) +USHORT bswap_s(USHORT s) { - return htonlc(n); -} - -USHORT htonsc(USHORT h) -{ - if (IsLittleEndian()) - { - h = (h << 8) | (h >> 8); - } - return h; -} - -USHORT ntohsc(USHORT n) -{ - return htonsc(n); + return (IsLittleEndian() ? _byteswap_ushort(s) : s); } BOOL GetUUID5(REFGUID rguid, CONST PBYTE name, DWORD namelen, LPGUID puuid) { BOOL bRet = FALSE; - CONST LPCWSTR pszAlgId = BCRYPT_SHA1_ALGORITHM; - CONST DWORD dwDigestLen = 20; - CONST USHORT maskVersion = 0x5000; GUID lguid = rguid; + BCRYPT_ALG_HANDLE hAlgorithm = BCRYPT_SHA1_ALG_HANDLE; + CONST DWORD DIGEST_LENGTH = 20; + CONST USHORT MASK_VERSION = 0x5000; if (name == nullptr || namelen == 0 || puuid == nullptr) { @@ -208,25 +142,32 @@ BOOL GetUUID5(REFGUID rguid, CONST PBYTE name, DWORD namelen, LPGUID puuid) if (pMessage != nullptr) { //network byte order - lguid.Data1 = htonlc(lguid.Data1); - lguid.Data2 = htonsc(lguid.Data2); - lguid.Data3 = htonsc(lguid.Data3); + lguid.Data1 = bswap_l(lguid.Data1); + lguid.Data2 = bswap_s(lguid.Data2); + lguid.Data3 = bswap_s(lguid.Data3); memcpy_s(pMessage, sizeof(lguid), &lguid, sizeof(lguid)); memcpy_s(pMessage + sizeof(lguid), namelen, name, namelen); - BYTE digest[dwDigestLen]; - if (GetDigest(pszAlgId, - pMessage, sizeof(lguid) + namelen, digest, dwDigestLen)) + BYTE digest[DIGEST_LENGTH] = {}; + // Windows 10 or later supported + NTSTATUS status = BCryptHash(hAlgorithm, nullptr, 0, + pMessage, (ULONG)LocalSize(pMessage), digest, (ULONG)sizeof(digest)); + if (BCRYPT_SUCCESS(status)) { - GUID dguid = *(GUID *)digest; - //local byte order - dguid.Data1 = ntohlc(dguid.Data1); - dguid.Data2 = ntohsc(dguid.Data2); - dguid.Data3 = ntohsc(dguid.Data3); + GUID dguid = GUID_NULL; + dguid.Data1 = *(ULONG *)&digest[0]; + dguid.Data2 = *(USHORT *)&digest[4]; + dguid.Data3 = *(USHORT *)&digest[6]; + *(ULONGLONG *)dguid.Data4 = *(ULONGLONG *)&digest[8]; + + //host byte order + dguid.Data1 = bswap_l(dguid.Data1); + dguid.Data2 = bswap_s(dguid.Data2); + dguid.Data3 = bswap_s(dguid.Data3); //version dguid.Data3 &= 0x0FFF; - dguid.Data3 |= maskVersion; + dguid.Data3 |= MASK_VERSION; //variant dguid.Data4[0] &= 0x3F; dguid.Data4[0] |= 0x80; @@ -278,13 +219,13 @@ BOOL GetLogonInfo(PBYTE *ppLogonInfo) if (bRet) { - TOKEN_ELEVATION_TYPE tokenElevationType; + TOKEN_ELEVATION_TYPE tokenElevationType = TokenElevationTypeDefault; if (GetTokenInformation(hToken, TokenElevationType, &tokenElevationType, sizeof(tokenElevationType), &dwLength)) { if (tokenElevationType == TokenElevationTypeFull) { - TOKEN_LINKED_TOKEN tokenLinkedToken; + TOKEN_LINKED_TOKEN tokenLinkedToken = {}; if (GetTokenInformation(hToken, TokenLinkedToken, &tokenLinkedToken, sizeof(tokenLinkedToken), &dwLength)) { @@ -294,7 +235,7 @@ BOOL GetLogonInfo(PBYTE *ppLogonInfo) } } - TOKEN_STATISTICS tokenStatistics; + TOKEN_STATISTICS tokenStatistics = {}; if (GetTokenInformation(hToken, TokenStatistics, &tokenStatistics, sizeof(tokenStatistics), &dwLength)) { diff --git a/common/common.h b/common/common.h index 8e7b1d2c..b8f43f5b 100644 --- a/common/common.h +++ b/common/common.h @@ -2,9 +2,10 @@ #include "version.h" -#define MAX_KRNLOBJNAME 256 +#define MAX_SECURITYDESC 256 //string security descriptor +#define MAX_PIPENAME 256 //named pipe name #define PIPEBUFSIZE 0x2000 //named pipe, 16KB with wchar_t -#define READBUFSIZE 0x800 //read skk dictionary, 4KB with wchar_t/char +#define READBUFSIZE 0x200 //read skk dictionary, 512B with wchar_t/char #define RECVBUFSIZE 0x800 //receive from skk server, 2KB with char #define MAX_SKKSERVER_HOST (255 + 1) //SKKサーバー ホスト 読み込みバッファ @@ -18,14 +19,18 @@ #define MAX_SELKEY 7 //候補一覧選択キー数 #define PRESERVEDKEY_NUM 2 //キー設定ON/OFF #define MAX_PRESERVEDKEY 8 //キー設定ON/OFF最大数 +#define PRIVATEMODEKEY_NUM 2 //プライベートモードON/OFF #define MAX_KEYRE 256 //キー1/2 読み込みバッファ #define MAX_CONV_POINT 256 //変換位置指定最大数 +#define DEF_BACKUPGENS 7 //ユーザー辞書バックアップ世代デフォルト +#define MAX_BACKUPGENS 255 //ユーザー辞書バックアップ世代最大 //request #define REQ_SEARCH L'1' //辞書検索 #define REQ_COMPLEMENT L'4' //補完 #define REQ_CONVERTKEY L'5' //見出し語変換 #define REQ_CONVERTCND L'6' //候補変換 +#define REQ_REVERSE L'7' //辞書逆検索 #define REQ_USER_ADD_A L'A' //ユーザー辞書追加(送りあり、補完なし) #define REQ_USER_ADD_N L'B' //ユーザー辞書追加(送りなし、補完あり) #define REQ_USER_DEL_A L'C' //ユーザー辞書削除(送りあり、補完なし) @@ -34,10 +39,14 @@ #define REQ_EXEC_CNF L'P' //設定ダイアログ起動 #define REQ_CAPS_LOCK L'I' //Caps Lock #define REQ_KANA_LOCK L'J' //Kana Lock +#define REQ_BACKUP L'R' //バックアップ +#define REQ_EXIT L'X' //終了 //reply #define REP_OK L'T' //hit #define REP_FALSE L'F' //nothing +#define SYSTEMROOT_IME_DIR L"IME" + #define IMCRVMGREXE L"imcrvmgr.exe" #define IMCRVCNFEXE L"imcrvcnf.exe" #ifndef _DEBUG @@ -51,16 +60,16 @@ #define BOM L'\uFEFF' -extern LPCWSTR RccsUTF16; -extern LPCWSTR WccsUTF16; -extern LPCWSTR RccsUTF8; -extern LPCWSTR WccsUTF8; -extern LPCWSTR RB; -extern LPCWSTR WB; +extern LPCWSTR modeRccsUTF16; +extern LPCWSTR modeWccsUTF16; +extern LPCWSTR modeRccsUTF8; +extern LPCWSTR modeWccsUTF8; +extern LPCWSTR modeRT; +extern LPCWSTR modeRB; +extern LPCWSTR modeWB; extern LPCWSTR fnconfigxml; //設定 extern LPCWSTR fnuserdic; //ユーザー辞書 -extern LPCWSTR fnuserbak; //ユーザー辞書バックアッププレフィックス extern LPCWSTR fnskkdic; //取込SKK辞書 extern LPCWSTR fninitlua; //init.lua @@ -79,31 +88,14 @@ extern const BOOL c_daDisplayAttributeSeries[DISPLAYATTRIBUTE_INFO_NUM]; BOOL IsWindowsVersionOrLater(DWORD dwMajorVersion, DWORD dwMinorVersion, DWORD dwBuildNumber); // Windows 8 +// supports new guidelines #define IsWindowsVersion62OrLater() IsWindowsVersionOrLater(6, 2, 0) // Windows 8.1 +// supports Direct2D color fonts #define IsWindowsVersion63OrLater() IsWindowsVersionOrLater(6, 3, 0) -//// Windows 10 -//#define IsWindowsVersion100OrLater() IsWindowsVersionOrLater(10, 0, 0) -//// Windows 10 ver.1507 Threshold 1 Released in July 2015 -//#define IsWindowsVersion100TH1OrLater() IsWindowsVersionOrLater(10, 0, 10240) -//// Windows 10 ver.1511 Threshold 2 November Update -//#define IsWindowsVersion100TH2OrLater() IsWindowsVersionOrLater(10, 0, 10586) -//// Windows 10 ver.1607 Redstone 1 Anniversary Update -//#define IsWindowsVersion100RS1OrLater() IsWindowsVersionOrLater(10, 0, 14393) // Windows 10 ver.1703 Redstone 2 Creators Update +// supports Per-Monitor DPI Awareness V2 #define IsWindowsVersion100RS2OrLater() IsWindowsVersionOrLater(10, 0, 15063) -//// Windows 10 ver.1709 Redstone 3 Fall Creators Update -//#define IsWindowsVersion100RS3OrLater() IsWindowsVersionOrLater(10, 0, 16299) -//// Windows 10 ver.1803 Redstone 4 April 2018 Update -//#define IsWindowsVersion100RS4OrLater() IsWindowsVersionOrLater(10, 0, 17134) -//// Windows 10 ver.1809 Redstone 5 October 2018 Update -//#define IsWindowsVersion100RS5OrLater() IsWindowsVersionOrLater(10, 0, 17763) -//// Windows 10 ver.1903 19H1 May 2019 Update -//#define IsWindowsVersion10019H1OrLater() IsWindowsVersionOrLater(10, 0, 18362) -//// Windows 10 ver.1909 19H2 November 2019 Update -//#define IsWindowsVersion10019H2OrLater() IsWindowsVersionOrLater(10, 0, 18363) -//// Windows 10 ver.2004 20H1 May 2020 Update -//#define IsWindowsVersion10020H1OrLater() IsWindowsVersionOrLater(10, 0, 19041) #define C_USER_DEFAULT_SCREEN_DPI 96 #define C_FONT_LOGICAL_HEIGHT_PPI 72 diff --git a/common/common.vcxproj b/common/common.vcxproj index b0e9e953..631f6ceb 100644 --- a/common/common.vcxproj +++ b/common/common.vcxproj @@ -1,14 +1,6 @@  - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + {EB999F4D-AD29-4049-BCCB-FABFD01DFC97} @@ -44,114 +36,87 @@ StaticLibrary true - v142 + v143 Unicode StaticLibrary true - v142 - Unicode - - - StaticLibrary - true - v142 + v143 Unicode StaticLibrary true - v142 + v143 Unicode StaticLibrary false - v142 + v143 true Unicode StaticLibrary false - v142 - true - Unicode - - - StaticLibrary - false - v142 + v143 true Unicode StaticLibrary false - v142 + v143 true Unicode - + - - - - + - - - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ @@ -160,9 +125,10 @@ Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -176,25 +142,10 @@ Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true - stdafx.h - true - true - - - Windows - true - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -208,9 +159,10 @@ Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -226,10 +178,11 @@ true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -247,31 +200,11 @@ true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true - stdafx.h - true - true - Guard - - - Windows - true - true - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -289,10 +222,11 @@ true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -307,8 +241,10 @@ + + - + @@ -317,19 +253,22 @@ + + - + Create Create - Create Create Create Create - Create Create + + + diff --git a/common/common.vcxproj.filters b/common/common.vcxproj.filters index fe63f2cb..b4eeb605 100644 --- a/common/common.vcxproj.filters +++ b/common/common.vcxproj.filters @@ -15,7 +15,7 @@ - + Header Files @@ -33,6 +33,12 @@ Header Files + + Header Files + + + Header Files + Header Files @@ -44,7 +50,7 @@ - + Source Files @@ -59,6 +65,12 @@ Source Files + + Source Files + + + Source Files + Source Files @@ -66,4 +78,7 @@ Source Files + + + \ No newline at end of file diff --git a/common/configxml.cpp b/common/configxml.cpp index 36e781bc..d5e1e561 100644 --- a/common/configxml.cpp +++ b/common/configxml.cpp @@ -1,6 +1,7 @@  #include "common.h" #include "configxml.h" +#include "utf8.h" #pragma comment(lib, "shlwapi.lib") #pragma comment(lib, "xmllite.lib") @@ -52,6 +53,20 @@ LPCWSTR ValueServerPort = L"port"; LPCWSTR ValueServerEncoding = L"encoding"; LPCWSTR ValueServerTimeOut = L"timeout"; +//userdict section + +LPCWSTR SectionUserDict = L"userdict"; + +//userdict keys + +LPCWSTR ValueBackupDir = L"backupdir"; +LPCWSTR ValueBackupGen = L"backupgen"; +LPCWSTR ValuePrivateOnVKey = L"privateonvkey"; +LPCWSTR ValuePrivateOnMKey = L"privateonmkey"; +LPCWSTR ValuePrivateOffVKey = L"privateoffvkey"; +LPCWSTR ValuePrivateOffMKey = L"privateoffmkey"; +LPCWSTR ValuePrivateModeAuto = L"privatemodeauto"; + //behavior section LPCWSTR SectionBehavior = L"behavior"; @@ -107,6 +122,7 @@ LPCWSTR ValueColorNO = L"colorno"; LPCWSTR ValueDrawAPI = L"drawapi"; LPCWSTR ValueColorFont = L"colorfont"; LPCWSTR ValueUntilCandList = L"untilcandlist"; +LPCWSTR ValuePageCandNum = L"pagecandnum"; LPCWSTR ValueDispCandNo = L"dispcandno"; LPCWSTR ValueVerticalCand = L"verticalcand"; LPCWSTR ValueAnnotation = L"annotation"; @@ -187,6 +203,7 @@ LPCWSTR ValueKeyMapUp = L"up"; LPCWSTR ValueKeyMapRight = L"right"; LPCWSTR ValueKeyMapDown = L"down"; LPCWSTR ValueKeyMapPaste = L"paste"; +LPCWSTR ValueKeyMapReconvert = L"reconvert"; //convpoint section @@ -592,7 +609,7 @@ HRESULT WriterStartElement(IXmlWriter *pWriter, LPCWSTR element) if (pWriter != nullptr) { - hr = pWriter->WriteStartElement(nullptr, element, nullptr); + hr = pWriter->WriteStartElement(nullptr, TOWELLFORMED(element), nullptr); } return hr; @@ -616,7 +633,7 @@ HRESULT WriterAttribute(IXmlWriter *pWriter, LPCWSTR name, LPCWSTR value) if (pWriter != nullptr) { - hr = pWriter->WriteAttributeString(nullptr, name, nullptr, value); + hr = pWriter->WriteAttributeString(nullptr, TOWELLFORMED(name), nullptr, TOWELLFORMED(value)); } return hr; diff --git a/common/configxml.h b/common/configxml.h index 510ca89d..2ba7140e 100644 --- a/common/configxml.h +++ b/common/configxml.h @@ -47,6 +47,20 @@ extern LPCWSTR ValueServerPort; extern LPCWSTR ValueServerEncoding; extern LPCWSTR ValueServerTimeOut; +//userdict section + +extern LPCWSTR SectionUserDict; + +//userdict keys + +extern LPCWSTR ValueBackupDir; +extern LPCWSTR ValueBackupGen; +extern LPCWSTR ValuePrivateOnVKey; +extern LPCWSTR ValuePrivateOnMKey; +extern LPCWSTR ValuePrivateOffVKey; +extern LPCWSTR ValuePrivateOffMKey; +extern LPCWSTR ValuePrivateModeAuto; + //behavior section extern LPCWSTR SectionBehavior; @@ -102,6 +116,7 @@ extern LPCWSTR ValueColorNO; extern LPCWSTR ValueDrawAPI; extern LPCWSTR ValueColorFont; extern LPCWSTR ValueUntilCandList; +extern LPCWSTR ValuePageCandNum; extern LPCWSTR ValueDispCandNo; extern LPCWSTR ValueVerticalCand; extern LPCWSTR ValueAnnotation; @@ -182,6 +197,7 @@ extern LPCWSTR ValueKeyMapUp; extern LPCWSTR ValueKeyMapRight; extern LPCWSTR ValueKeyMapDown; extern LPCWSTR ValueKeyMapPaste; +extern LPCWSTR ValueKeyMapReconvert; //convpoint section diff --git a/common/cpp.hint b/common/cpp.hint new file mode 100644 index 00000000..8660b6f3 --- /dev/null +++ b/common/cpp.hint @@ -0,0 +1,5 @@ +// common.h +#define FORWARD_ITERATION_I(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ++(iterator)) +#define FORWARD_ITERATION(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ) +#define REVERSE_ITERATION_I(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ++(reverse_iterator)) +#define REVERSE_ITERATION(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ) diff --git a/common/eucjis2004.cpp b/common/eucjis2004.cpp index d9bf5ed6..b0deb1fb 100644 --- a/common/eucjis2004.cpp +++ b/common/eucjis2004.cpp @@ -44,7 +44,7 @@ size_t UcpToWideChar(UCSCHAR ucp, PWCHAR first, PWCHAR second) *second = L'\0'; ret = 1; } - else if (ucp <= SURROGATEPAIR_UCPMAX) //surrogate pair + else if (ucp <= SURROGATEPAIR_UCPMAX) // surrogate pair { *first = (WCHAR)(SURROGATEPAIR_HIGH_MASK | ((ucp - SURROGATEPAIR_UCPMIN) >> SURROGATEPAIR_SEPBIT)); *second = (WCHAR)(SURROGATEPAIR_LOW_MASK | ((ucp - SURROGATEPAIR_UCPMIN) & SURROGATEPAIR_SEPMASK)); @@ -65,7 +65,7 @@ size_t EucJis2004ToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) CONST CHAR ejd = (CHAR)0x80; CONST CHAR ejs = 0x21; CONST CHAR eje = 0x7E; - CHAR ej[2]; + CHAR ej[2] = {}; size_t srcused = 0; if (src == nullptr || srcsize == 0 || ucp1 == nullptr || ucp2 == nullptr) @@ -76,7 +76,7 @@ size_t EucJis2004ToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) *ucp1 = 0; *ucp2 = 0; - if (as <= src[0] && src[0] <= ae) //ASCII + if (as <= src[0] && src[0] <= ae) // ASCII { *ucp1 = src[0]; *ucp2 = 0; @@ -86,7 +86,7 @@ size_t EucJis2004ToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) { switch (src[0]) { - case ss3: // JIS X 0213 Plane 2 + case ss3: // JIS X 0213 第二面 if (srcsize < 3) { break; @@ -117,7 +117,7 @@ size_t EucJis2004ToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) } break; - case ss2: //JIS X 0201 halfwidth katakana + case ss2: // JIS X 0201 片仮名 if (srcsize < 2) { break; @@ -138,7 +138,7 @@ size_t EucJis2004ToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) } break; - default: // JIS X 0213 Plane 1 + default: // JIS X 0213 第一面 if (srcsize < 2) { break; @@ -161,7 +161,7 @@ size_t EucJis2004ToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) { USHORT euc = ((USHORT)ej[0] << 8) | (USHORT)ej[1] | 0x8080; - //結合文字 + // 結合文字 for (int i = 0; i < CMBCHARNUM; i++) { if (euccmb[i].euc == euc) @@ -209,9 +209,9 @@ void AddNullWideChar(size_t *srcsize, size_t si, LPWSTR dst, size_t *dstsize, si BOOL EucJis2004ToWideChar(LPCSTR src, size_t *srcsize, LPWSTR dst, size_t *dstsize) { size_t si = 0, di = 0, ss = -1; - UCSCHAR ucp[2]; - WCHAR utf16[2][2]; - size_t utf16num[2]; + UCSCHAR ucp[2] = {}; + WCHAR utf16[2][2] = {}; + size_t utf16num[2] = {}; if (dstsize == nullptr) { @@ -260,7 +260,7 @@ BOOL EucJis2004ToWideChar(LPCSTR src, size_t *srcsize, LPWSTR dst, size_t *dstsi } } - if (*dstsize <= di + utf16num[0] + utf16num[1]) //limit + if (*dstsize <= di + utf16num[0] + utf16num[1]) // limit { AddNullWideChar(srcsize, si, dst, dstsize, di); return FALSE; @@ -285,7 +285,7 @@ BOOL EucJis2004ToWideChar(LPCSTR src, size_t *srcsize, LPWSTR dst, size_t *dstsi // 終端NULLを付加 -void AddNullEucJis2004(size_t *srcsize, size_t si, LPSTR dst, size_t *dstsize, size_t di) +void AddNullMultiByte(size_t *srcsize, size_t si, LPSTR dst, size_t *dstsize, size_t di) { if (srcsize != nullptr) { @@ -339,11 +339,11 @@ BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsi break; } - if (*(src + si) <= L'\x7F') //ASCII + if (*(src + si) <= L'\x7F') // ASCII { - if (*dstsize <= di + 1) //limit + if (*dstsize <= di + 1) // limit { - AddNullEucJis2004(srcsize, si, dst, dstsize, di); + AddNullMultiByte(srcsize, si, dst, dstsize, di); return FALSE; } if (dst != nullptr) @@ -378,39 +378,75 @@ BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsi ucp = first; } - //結合文字 - for (int i = 0; i < CMBCHARNUM; i++) + // 互換性 + if (!exist) { - if (first == euccmb[i].ucp[0] && second == euccmb[i].ucp[1]) + for (int i = 0; i < CMPEUCNUM; i++) { - if (*dstsize <= di + 2) //limit + if (ucp == euccmp[i].ucp) { - AddNullEucJis2004(srcsize, si, dst, dstsize, di); - return FALSE; + if (*dstsize <= di + 2) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = (CHAR)(euccmp[i].euc >> 8); + *(dst + di + 1) = (CHAR)(euccmp[i].euc & 0xFF); + } + di += 2; + if (ucp != first) // surrogate pair + { + si++; + } + exist = TRUE; + break; } - if (dst != nullptr) + } + } + + // 結合文字 + if (!exist) + { + for (int i = 0; i < CMBCHARNUM; i++) + { + if (first == euccmb[i].ucp[0] && second == euccmb[i].ucp[1]) { - *(dst + di) = euccmb[i].euc >> 8; - *(dst + di + 1) = euccmb[i].euc & 0xFF; + if (*dstsize <= di + 2) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = euccmb[i].euc >> 8; + *(dst + di + 1) = euccmb[i].euc & 0xFF; + } + di += 2; + if (ucp != first) // surrogate pair, unused actually + { + si++; + } + si++; + exist = TRUE; + break; } - di += 2; - si++; - exist = TRUE; - break; } } + // JIS X 0213 第一面 if (!exist) { for (int i = 0; i < ROWNUM; i++) { for (int j = 0; j < CELLNUM; j++) { - if (ucp == euc1[i][j]) // JIS X 0213 Plane 1 + if (ucp == euc1[i][j]) { - if (*dstsize <= di + 2) //limit + if (*dstsize <= di + 2) // limit { - AddNullEucJis2004(srcsize, si, dst, dstsize, di); + AddNullMultiByte(srcsize, si, dst, dstsize, di); return FALSE; } if (dst != nullptr) @@ -419,19 +455,35 @@ BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsi *(dst + di + 1) = (CHAR)((UCHAR)(ejs + j) + (UCHAR)ejd); } di += 2; - if (ucp != first) //surrogate pair + if (ucp != first) // surrogate pair { si++; } exist = TRUE; break; } - else if (euc2i[i] != 0 && euc2i[i] <= ROW2NUM && - ucp == euc2[euc2i[i] - 1][j]) // JIS X 0213 Plane 2 + } + + if (exist) + { + break; + } + } + } + + // JIS X 0213 第二面 + if (!exist) + { + for (int i = 0; i < ROWNUM; i++) + { + for (int j = 0; j < CELLNUM; j++) + { + if (euc2i[i] != 0 && euc2i[i] <= ROW2NUM && + ucp == euc2[euc2i[i] - 1][j]) { - if (*dstsize <= di + 3) //limit + if (*dstsize <= di + 3) // limit { - AddNullEucJis2004(srcsize, si, dst, dstsize, di); + AddNullMultiByte(srcsize, si, dst, dstsize, di); return FALSE; } if (dst != nullptr) @@ -441,7 +493,7 @@ BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsi *(dst + di + 2) = (CHAR)((UCHAR)(ejs + j) + (UCHAR)ejd); } di += 3; - if (ucp != first) //surrogate pair + if (ucp != first) // surrogate pair { si++; } @@ -457,15 +509,16 @@ BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsi } } + // JIS X 0201 片仮名 if (!exist) { for (int i = 0; i < ANKNUM; i++) { - if (ucp == eucK[i]) //JIS X 0201 halfwidth katakana + if (ucp == eucK[i]) { - if (*dstsize <= di + 2) //limit + if (*dstsize <= di + 2) // limit { - AddNullEucJis2004(srcsize, si, dst, dstsize, di); + AddNullMultiByte(srcsize, si, dst, dstsize, di); return FALSE; } if (dst != nullptr) @@ -482,30 +535,32 @@ BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsi if (!exist) { - AddNullEucJis2004(srcsize, si, dst, dstsize, di); + AddNullMultiByte(srcsize, si, dst, dstsize, di); return FALSE; } } } - AddNullEucJis2004(srcsize, si, dst, dstsize, di); + AddNullMultiByte(srcsize, si, dst, dstsize, di); return TRUE; } -std::string wstring_to_eucjis2004_string(const std::wstring &s) +std::wstring eucjis2004_string_to_wstring(const std::string &s) { - std::string ret; + std::wstring ret; size_t len; - BOOL b = WideCharToEucJis2004(s.c_str(), nullptr, nullptr, &len); + BOOL b = EucJis2004ToWideChar(s.c_str(), nullptr, nullptr, &len); if (b && len > 0) { try { - LPSTR euc = new CHAR[len]; - WideCharToEucJis2004(s.c_str(), nullptr, euc, &len); - ret = euc; - delete[] euc; + LPWSTR wcs = new WCHAR[len]; + if (EucJis2004ToWideChar(s.c_str(), nullptr, wcs, &len)) + { + ret = wcs; + } + delete[] wcs; } catch (...) { @@ -515,20 +570,22 @@ std::string wstring_to_eucjis2004_string(const std::wstring &s) return ret; } -std::wstring eucjis2004_string_to_wstring(const std::string &s) +std::string wstring_to_eucjis2004_string(const std::wstring &s) { - std::wstring ret; + std::string ret; size_t len; - BOOL b = EucJis2004ToWideChar(s.c_str(), nullptr, nullptr, &len); + BOOL b = WideCharToEucJis2004(s.c_str(), nullptr, nullptr, &len); if (b && len > 0) { try { - LPWSTR wcs = new WCHAR[len]; - EucJis2004ToWideChar(s.c_str(), nullptr, wcs, &len); - ret = wcs; - delete[] wcs; + LPSTR euc = new CHAR[len]; + if (WideCharToEucJis2004(s.c_str(), nullptr, euc, &len)) + { + ret = euc; + } + delete[] euc; } catch (...) { diff --git a/common/eucjis2004.h b/common/eucjis2004.h index 3b6fa043..29044fde 100644 --- a/common/eucjis2004.h +++ b/common/eucjis2004.h @@ -56,8 +56,8 @@ BOOL EucJis2004ToWideChar(LPCSTR src, size_t *srcsize, LPWSTR dst, size_t *dstsi // nullptrのとき戻り値はFALSEになる BOOL WideCharToEucJis2004(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsize); -std::string wstring_to_eucjis2004_string(const std::wstring &s); -std::wstring eucjis2004_string_to_wstring(const std::string &s); +void AddNullWideChar(size_t *srcsize, size_t si, LPWSTR dst, size_t *dstsize, size_t di); +void AddNullMultiByte(size_t *srcsize, size_t si, LPSTR dst, size_t *dstsize, size_t di); -#define WCTOEUC(w) wstring_to_eucjis2004_string(w).c_str() -#define EUCTOWC(u) eucjis2004_string_to_wstring(u).c_str() +std::wstring eucjis2004_string_to_wstring(const std::string &s); +std::string wstring_to_eucjis2004_string(const std::wstring &s); diff --git a/common/eucjis2004table.cpp b/common/eucjis2004table.cpp index fbf8cf0b..d1533ddf 100644 --- a/common/eucjis2004table.cpp +++ b/common/eucjis2004table.cpp @@ -1,21 +1,21 @@  #include "eucjis2004table.h" -// EUC-JIS-2004 Unicode 変換表 // -// http://x0213.org/codetable/euc-jis-2004-std.txt を元に生成 +// EUC-JIS-2004 / Unicode 変換表 +// +// http://x0213.org/codetable/euc-jis-2004-std.txt を元に生成 +// +// 以下の2つの符号は、iconv 1.17 を参考にして Windows (CP932) mapping とした。 +// +// 0xA1B1 U+203E # OVERLINE Windows: U+FFE3 +// 0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 // -// 以下の2つの符号は、cygwin の iconv 1.14 を参考にして、 -// Windows (CP932) mapping とした。 -// 0xA1B1 U+203E # OVERLINE Windows: U+FFE3 -// 0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 - -#pragma region euc table -#pragma region combining characters +#pragma region Unicode結合文字 const EUCCMB euccmb[CMBCHARNUM] = { - //EUC UCP 1st UCP 2nd + // EUC UCP 1st UCP 2nd {0xA4F7, {0x304B, 0x309A}}, //0xA4F7 U+304B+309A # [2000] {0xA4F8, {0x304D, 0x309A}}, //0xA4F8 U+304D+309A # [2000] {0xA4F9, {0x304F, 0x309A}}, //0xA4F9 U+304F+309A # [2000] @@ -44,9 +44,10 @@ const EUCCMB euccmb[CMBCHARNUM] = }; #pragma endregion -#pragma region EUC 1 +#pragma region JIS_X_0213 第一面 const UCSCHAR euc1[ROWNUM][CELLNUM] = { + //1区 { 0x3000, //0xA1A1 U+3000 # IDEOGRAPHIC SPACE 0x3001, //0xA1A2 U+3001 # IDEOGRAPHIC COMMA @@ -64,8 +65,8 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0xFF40, //0xA1AE U+FF40 # FULLWIDTH GRAVE ACCENT 0x00A8, //0xA1AF U+00A8 # DIAERESIS 0xFF3E, //0xA1B0 U+FF3E # FULLWIDTH CIRCUMFLEX ACCENT -// 0x203E, //0xA1B1 U+203E # OVERLINE Windows: U+FFE3 //// same as iconv on cygwin //// - 0xFFE3, //0xA1B1 U+203E # OVERLINE Windows: U+FFE3 +// 0x203E, //0xA1B1 U+203E # OVERLINE Windows: U+FFE3 + 0xFFE3, //0xA1B1 U+203E # OVERLINE Windows: U+FFE3 //// same as iconv //// 0xFF3F, //0xA1B2 U+FF3F # FULLWIDTH LOW LINE 0x30FD, //0xA1B3 U+30FD # KATAKANA ITERATION MARK 0x30FE, //0xA1B4 U+30FE # KATAKANA VOICED ITERATION MARK @@ -127,8 +128,8 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x2032, //0xA1EC U+2032 # PRIME 0x2033, //0xA1ED U+2033 # DOUBLE PRIME 0x2103, //0xA1EE U+2103 # DEGREE CELSIUS -// 0x00A5, //0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 //// same as iconv on cygwin //// - 0xFFE5, //0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 +// 0x00A5, //0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 + 0xFFE5, //0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 //// same as iconv //// 0xFF04, //0xA1F0 U+FF04 # FULLWIDTH DOLLAR SIGN 0x00A2, //0xA1F1 U+00A2 # CENT SIGN Windows: U+FFE0 0x00A3, //0xA1F2 U+00A3 # POUND SIGN Windows: U+FFE1 @@ -145,6 +146,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x25CE, //0xA1FD U+25CE # BULLSEYE 0x25C7 //0xA1FE U+25C7 # WHITE DIAMOND }, + //2区 { 0x25C6, //0xA2A1 U+25C6 # BLACK DIAMOND 0x25A1, //0xA2A2 U+25A1 # WHITE SQUARE @@ -241,6 +243,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x2669, //0xA2FD U+2669 # QUARTER NOTE [2000] 0x25EF //0xA2FE U+25EF # LARGE CIRCLE [1983] }, + //3区 { 0x25B7, //0xA3A1 U+25B7 # WHITE RIGHT-POINTING TRIANGLE [2000] 0x25B6, //0xA3A2 U+25B6 # BLACK RIGHT-POINTING TRIANGLE [2000] @@ -337,6 +340,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x29FA, //0xA3FD U+29FA # DOUBLE PLUS [2000] [Unicode3.2] 0x29FB //0xA3FE U+29FB # TRIPLE PLUS [2000] [Unicode3.2] }, + //4区 { 0x3041, //0xA4A1 U+3041 # HIRAGANA LETTER SMALL A 0x3042, //0xA4A2 U+3042 # HIRAGANA LETTER A @@ -429,10 +433,11 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x0000, //0xA4F9 U+304F+309A # [2000] ## JIS X 0213 COMBINING CHARACTER 0x0000, //0xA4FA U+3051+309A # [2000] ## JIS X 0213 COMBINING CHARACTER 0x0000, //0xA4FB U+3053+309A # [2000] ## JIS X 0213 COMBINING CHARACTER - 0x0000, // - 0x0000, // - 0x0000 // + 0x0000, //0xA4FC # + 0x0000, //0xA4FD # + 0x0000 //0xA4FE # }, + //5区 { 0x30A1, //0xA5A1 U+30A1 # KATAKANA LETTER SMALL A 0x30A2, //0xA5A2 U+30A2 # KATAKANA LETTER A @@ -529,6 +534,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x0000, //0xA5FD U+30C4+309A # [2000] ## JIS X 0213 COMBINING CHARACTER 0x0000 //0xA5FE U+30C8+309A # [2000] ## JIS X 0213 COMBINING CHARACTER }, + //6区 { 0x0391, //0xA6A1 U+0391 # GREEK CAPITAL LETTER ALPHA 0x0392, //0xA6A2 U+0392 # GREEK CAPITAL LETTER BETA @@ -625,6 +631,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x31FE, //0xA6FD U+31FE # KATAKANA LETTER SMALL RE [2000] [Unicode3.2] 0x31FF //0xA6FE U+31FF # KATAKANA LETTER SMALL RO [2000] [Unicode3.2] }, + //7区 { 0x0410, //0xA7A1 U+0410 # CYRILLIC CAPITAL LETTER A 0x0411, //0xA7A2 U+0411 # CYRILLIC CAPITAL LETTER BE @@ -721,6 +728,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x2423, //0xA7FD U+2423 # OPEN BOX [2000] 0x23CE //0xA7FE U+23CE # RETURN SYMBOL [2000] [Unicode3.2] }, + //8区 { 0x2500, //0xA8A1 U+2500 # BOX DRAWINGS LIGHT HORIZONTAL [1983] 0x2502, //0xA8A2 U+2502 # BOX DRAWINGS LIGHT VERTICAL [1983] @@ -784,14 +792,14 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x32BD, //0xA8DC U+32BD # CIRCLED NUMBER FORTY EIGHT [2000] [Unicode3.2] 0x32BE, //0xA8DD U+32BE # CIRCLED NUMBER FORTY NINE [2000] [Unicode3.2] 0x32BF, //0xA8DE U+32BF # CIRCLED NUMBER FIFTY [2000] [Unicode3.2] - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // + 0x0000, //0xA8DF # + 0x0000, //0xA8E0 # + 0x0000, //0xA8E1 # + 0x0000, //0xA8E2 # + 0x0000, //0xA8E3 # + 0x0000, //0xA8E4 # + 0x0000, //0xA8E5 # + 0x0000, //0xA8E6 # 0x25D0, //0xA8E7 U+25D0 # CIRCLE WITH LEFT HALF BLACK [2000] 0x25D1, //0xA8E8 U+25D1 # CIRCLE WITH RIGHT HALF BLACK [2000] 0x25D2, //0xA8E9 U+25D2 # CIRCLE WITH LOWER HALF BLACK [2000] @@ -814,9 +822,10 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x01D8, //0xA8FA U+01D8 # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE [2000] 0x01DA, //0xA8FB U+01DA # LATIN SMALL LETTER U WITH DIAERESIS AND CARON [2000] 0x01DC, //0xA8FC U+01DC # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE [2000] - 0x0000, // - 0x0000 // + 0x0000, //0xA8FD # + 0x0000 //0xA8FE # }, + //9区 { 0x20AC, //0xA9A1 U+20AC # EURO SIGN [2000] 0x00A0, //0xA9A2 U+00A0 # NO-BREAK SPACE [2000] @@ -913,6 +922,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x0113, //0xA9FD U+0113 # LATIN SMALL LETTER E WITH MACRON [2000] 0x014D //0xA9FE U+014D # LATIN SMALL LETTER O WITH MACRON [2000] }, + //10区 { 0x0104, //0xAAA1 U+0104 # LATIN CAPITAL LETTER A WITH OGONEK [2000] 0x02D8, //0xAAA2 U+02D8 # BREVE [2000] @@ -1009,6 +1019,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x0127, //0xAAFD U+0127 # LATIN SMALL LETTER H WITH STROKE [2000] 0x0295 //0xAAFE U+0295 # LATIN LETTER PHARYNGEAL VOICED FRICATIVE [2000] }, + //11区 { 0x0294, //0xABA1 U+0294 # LATIN LETTER GLOTTAL STOP [2000] 0x0266, //0xABA2 U+0266 # LATIN SMALL LETTER H WITH HOOK [2000] @@ -1105,6 +1116,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x0303, //0xABFD U+0303 # COMBINING TILDE [2000] 0x031A //0xABFE U+031A # COMBINING LEFT ANGLE ABOVE [2000] }, + //12区 { 0x2776, //0xACA1 U+2776 # DINGBAT NEGATIVE CIRCLED DIGIT ONE [2000] 0x2777, //0xACA2 U+2777 # DINGBAT NEGATIVE CIRCLED DIGIT TWO [2000] @@ -1189,18 +1201,19 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x32E5, //0xACF1 U+32E5 # CIRCLED KATAKANA NI [2000] 0x32ED, //0xACF2 U+32ED # CIRCLED KATAKANA HO [2000] 0x32EC, //0xACF3 U+32EC # CIRCLED KATAKANA HE [2000] - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // + 0x0000, //0xACF4 # + 0x0000, //0xACF5 # + 0x0000, //0xACF6 # + 0x0000, //0xACF7 # + 0x0000, //0xACF8 # + 0x0000, //0xACF9 # + 0x0000, //0xACFA # + 0x0000, //0xACFB # + 0x0000, //0xACFC # 0x2051, //0xACFD U+2051 # TWO ASTERISKS ALIGNED VERTICALLY [2000] [Unicode3.2] 0x2042 //0xACFE U+2042 # ASTERISM [2000] }, + //13区 { 0x2460, //0xADA1 U+2460 # CIRCLED DIGIT ONE [2000] 0x2461, //0xADA2 U+2461 # CIRCLED DIGIT TWO [2000] @@ -1257,13 +1270,13 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x33C4, //0xADD5 U+33C4 # SQUARE CC [2000] 0x33A1, //0xADD6 U+33A1 # SQUARE M SQUARED [2000] 0x216B, //0xADD7 U+216B # ROMAN NUMERAL TWELVE [2000] - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // + 0x0000, //0xADD8 # + 0x0000, //0xADD9 # + 0x0000, //0xADDA # + 0x0000, //0xADDB # + 0x0000, //0xADDC # + 0x0000, //0xADDD # + 0x0000, //0xADDE # 0x337B, //0xADDF U+337B # SQUARE ERA NAME HEISEI [2000] 0x301D, //0xADE0 U+301D # REVERSED DOUBLE PRIME QUOTATION MARK [2000] 0x301F, //0xADE1 U+301F # LOW DOUBLE PRIME QUOTATION MARK [2000] @@ -1281,22 +1294,23 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x337E, //0xADED U+337E # SQUARE ERA NAME MEIZI [2000] 0x337D, //0xADEE U+337D # SQUARE ERA NAME TAISYOU [2000] 0x337C, //0xADEF U+337C # SQUARE ERA NAME SYOUWA [2000] - 0x0000, // - 0x0000, // - 0x0000, // + 0x0000, //0xADF0 # Windows: U+2252 + 0x0000, //0xADF1 # Windows: U+2261 + 0x0000, //0xADF2 # Windows: U+222B 0x222E, //0xADF3 U+222E # CONTOUR INTEGRAL [2000] - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // + 0x0000, //0xADF4 # Windows: U+2211 + 0x0000, //0xADF5 # Windows: U+221A + 0x0000, //0xADF6 # Windows: U+22A5 + 0x0000, //0xADF7 # Windows: U+2220 0x221F, //0xADF8 U+221F # RIGHT ANGLE [2000] 0x22BF, //0xADF9 U+22BF # RIGHT TRIANGLE [2000] - 0x0000, // - 0x0000, // - 0x0000, // + 0x0000, //0xADFA # Windows: U+2235 + 0x0000, //0xADFB # Windows: U+2229 + 0x0000, //0xADFC # Windows: U+222A 0x2756, //0xADFD U+2756 # BLACK DIAMOND MINUS WHITE X [2000] 0x261E //0xADFE U+261E # WHITE RIGHT POINTING INDEX [2000] }, + //14区 { 0x4FF1, //0xAEA1 U+4FF1 # [2004] 0x2000B, //0xAEA2 U+2000B # [2000] [Unicode3.1] @@ -1393,6 +1407,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5496, //0xAEFD U+5496 # [2000] 0x54A1 //0xAEFE U+54A1 # [2000] }, + //15区 { 0x54A9, //0xAFA1 U+54A9 # [2000] 0x54C6, //0xAFA2 U+54C6 # [2000] @@ -1489,6 +1504,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5B25, //0xAFFD U+5B25 # [2000] 0x525D //0xAFFE U+525D # [2004] }, + //16区 { 0x4E9C, //0xB0A1 U+4E9C # 0x5516, //0xB0A2 U+5516 # @@ -1585,6 +1601,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x80E4, //0xB0FD U+80E4 # 0x852D //0xB0FE U+852D # }, + //17区 { 0x9662, //0xB1A1 U+9662 # 0x9670, //0xB1A2 U+9670 # @@ -1681,6 +1698,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5F80, //0xB1FD U+5F80 # 0x5FDC //0xB1FE U+5FDC # }, + //18区 { 0x62BC, //0xB2A1 U+62BC # 0x65FA, //0xB2A2 U+65FA # @@ -1777,6 +1795,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x62D0, //0xB2FD U+62D0 # 0x6539 //0xB2FE U+6539 # }, + //19区 { 0x9B41, //0xB3A1 U+9B41 # 0x6666, //0xB3A2 U+6666 # @@ -1873,6 +1892,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8305, //0xB3FD U+8305 # 0x8431 //0xB3FE U+8431 # }, + //20区 { 0x7CA5, //0xB4A1 U+7CA5 # 0x5208, //0xB4A2 U+5208 # @@ -1969,6 +1989,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x68CB, //0xB4FD U+68CB # 0x68C4 //0xB4FE U+68C4 # }, + //21区 { 0x6A5F, //0xB5A1 U+6A5F # 0x5E30, //0xB5A2 U+5E30 # @@ -2065,6 +2086,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x4EAB, //0xB5FD U+4EAB # 0x4EAC //0xB5FE U+4EAC # }, + //22区 { 0x4F9B, //0xB6A1 U+4F9B # 0x4FA0, //0xB6A2 U+4FA0 # @@ -2161,6 +2183,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5C51, //0xB6FD U+5C51 # 0x5C48 //0xB6FE U+5C48 # }, + //23区 { 0x6398, //0xB7A1 U+6398 # 0x7A9F, //0xB7A2 U+7A9F # @@ -2257,6 +2280,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x62F3, //0xB7FD U+62F3 # 0x6372 //0xB7FE U+6372 # }, + //24区 { 0x691C, //0xB8A1 U+691C # 0x6A29, //0xB8A2 U+6A29 # @@ -2353,6 +2377,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x53E3, //0xB8FD U+53E3 # 0x5411 //0xB8FE U+5411 # }, + //25区 { 0x540E, //0xB9A1 U+540E # 0x5589, //0xB9A2 U+5589 # @@ -2449,6 +2474,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x72DB, //0xB9FD U+72DB # 0x8FBC //0xB9FE U+8FBC # }, + //26区 { 0x6B64, //0xBAA1 U+6B64 # 0x9803, //0xBAA2 U+9803 # @@ -2545,6 +2571,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x518A, //0xBAFD U+518A # 0x5237 //0xBAFE U+5237 # }, + //27区 { 0x5BDF, //0xBBA1 U+5BDF # 0x62F6, //0xBBA2 U+62F6 # @@ -2641,6 +2668,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6301, //0xBBFD U+6301 # 0x6642 //0xBBFE U+6642 # }, + //28区 { 0x6B21, //0xBCA1 U+6B21 # 0x6ECB, //0xBCA2 U+6ECB # @@ -2737,6 +2765,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x53CE, //0xBCFD U+53CE # 0x5468 //0xBCFE U+5468 # }, + //29区 { 0x5B97, //0xBDA1 U+5B97 # 0x5C31, //0xBDA2 U+5C31 # @@ -2833,6 +2862,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x50B7, //0xBDFD U+50B7 # 0x511F //0xBDFE U+511F # }, + //30区 { 0x52DD, //0xBEA1 U+52DD # 0x5320, //0xBEA2 U+5320 # @@ -2929,6 +2959,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x57F4, //0xBEFD U+57F4 # 0x98FE //0xBEFE U+98FE # }, + //31区 { 0x62ED, //0xBFA1 U+62ED # 0x690D, //0xBFA2 U+690D # @@ -3025,6 +3056,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x96C0, //0xBFFD U+96C0 # 0x88FE //0xBFFE U+88FE # }, + //32区 { 0x6F84, //0xC0A1 U+6F84 # 0x647A, //0xC0A2 U+647A # @@ -3121,6 +3153,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7BAD, //0xC0FD U+7BAD # 0x7DDA //0xC0FE U+7DDA # }, + //33区 { 0x7E4A, //0xC1A1 U+7E4A # 0x7FA8, //0xC1A2 U+7FA8 # @@ -3217,6 +3250,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5897, //0xC1FD U+5897 # 0x618E //0xC1FE U+618E # }, + //34区 { 0x81D3, //0xC2A1 U+81D3 # 0x8535, //0xC2A2 U+8535 # @@ -3313,6 +3347,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x86F8, //0xC2FD U+86F8 # 0x53EA //0xC2FE U+53EA # }, + //35区 { 0x53E9, //0xC3A1 U+53E9 # 0x4F46, //0xC3A2 U+4F46 # @@ -3409,6 +3444,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x558B, //0xC3FD U+558B # 0x5BF5 //0xC3FE U+5BF5 # }, + //36区 { 0x5E16, //0xC4A1 U+5E16 # 0x5E33, //0xC4A2 U+5E33 # @@ -3505,6 +3541,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8E44, //0xC4FD U+8E44 # 0x9013 //0xC4FE U+9013 # }, + //37区 { 0x90B8, //0xC5A1 U+90B8 # 0x912D, //0xC5A2 U+912D # @@ -3601,6 +3638,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7D71, //0xC5FD U+7D71 # 0x5230 //0xC5FE U+5230 # }, + //38区 { 0x8463, //0xC6A1 U+8463 # 0x8569, //0xC6A2 U+8569 # @@ -3697,6 +3735,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x4E73, //0xC6FD U+4E73 # 0x5165 //0xC6FE U+5165 # }, + //39区 { 0x5982, //0xC7A1 U+5982 # 0x5C3F, //0xC7A2 U+5C3F # @@ -3793,6 +3832,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x99C1, //0xC7FD U+99C1 # 0x9EA6 //0xC7FE U+9EA6 # }, + //40区 { 0x51FD, //0xC8A1 U+51FD # 0x7BB1, //0xC8A2 U+7BB1 # @@ -3889,6 +3929,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7709, //0xC8FD U+7709 # 0x7F8E //0xC8FE U+7F8E # }, + //41区 { 0x9F3B, //0xC9A1 U+9F3B # 0x67CA, //0xC9A2 U+67CA # @@ -3985,6 +4026,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5E45, //0xC9FD U+5E45 # 0x670D //0xC9FE U+670D # }, + //42区 { 0x798F, //0xCAA1 U+798F # 0x8179, //0xCAA2 U+8179 # @@ -4081,6 +4123,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x65B9, //0xCAFD U+65B9 # 0x670B //0xCAFE U+670B # }, + //43区 { 0x6CD5, //0xCBA1 U+6CD5 # 0x6CE1, //0xCBA2 U+6CE1 # @@ -4177,6 +4220,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6162, //0xCBFD U+6162 # 0x6E80 //0xCBFE U+6E80 # }, + //44区 { 0x6F2B, //0xCCA1 U+6F2B # 0x8513, //0xCCA2 U+8513 # @@ -4273,6 +4317,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6CB9, //0xCCFD U+6CB9 # 0x7652 //0xCCFE U+7652 # }, + //45区 { 0x8AED, //0xCDA1 U+8AED # 0x8F38, //0xCDA2 U+8F38 # @@ -4369,6 +4414,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7406, //0xCDFD U+7406 # 0x7483 //0xCDFE U+7483 # }, + //46区 { 0x75E2, //0xCEA1 U+75E2 # 0x88CF, //0xCEA2 U+88CF # @@ -4465,6 +4511,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7DF4, //0xCEFD U+7DF4 # 0x806F //0xCEFE U+806F # }, + //47区 { 0x84EE, //0xCFA1 U+84EE # 0x9023, //0xCFA2 U+9023 # @@ -4561,6 +4608,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5DCB, //0xCFFD U+5DCB # [2000] 0x541E //0xCFFE U+541E # [2004] }, + //48区 { 0x5F0C, //0xD0A1 U+5F0C # 0x4E10, //0xD0A2 U+4E10 # @@ -4657,6 +4705,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x50B4, //0xD0FD U+50B4 # 0x50B2 //0xD0FE U+50B2 # }, + //49区 { 0x50C9, //0xD1A1 U+50C9 # 0x50CA, //0xD1A2 U+50CA # @@ -4753,6 +4802,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5291, //0xD1FD U+5291 # 0x8FA8 //0xD1FE U+8FA8 # }, + //50区 { 0x8FA7, //0xD2A1 U+8FA7 # 0x52AC, //0xD2A2 U+52AC # @@ -4849,6 +4899,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x54C8, //0xD2FD U+54C8 # 0x54A8 //0xD2FE U+54A8 # }, + //51区 { 0x54AB, //0xD3A1 U+54AB # 0x54C2, //0xD3A2 U+54C2 # @@ -4945,6 +4996,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5704, //0xD3FD U+5704 # 0x5709 //0xD3FE U+5709 # }, + //52区 { 0x5708, //0xD4A1 U+5708 # 0x570B, //0xD4A2 U+570B # @@ -5041,6 +5093,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x596C, //0xD4FD U+596C # 0x5969 //0xD4FE U+5969 # }, + //53区 { 0x5978, //0xD5A1 U+5978 # 0x5981, //0xD5A2 U+5981 # @@ -5137,6 +5190,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5C4E, //0xD5FD U+5C4E # 0x5C53 //0xD5FE U+5C53 # }, + //54区 { 0x5C50, //0xD6A1 U+5C50 # 0x5C4F, //0xD6A2 U+5C4F # @@ -5233,6 +5287,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x5ED0, //0xD6FD U+5ED0 # 0x5ECF //0xD6FE U+5ECF # }, + //55区 { 0x5ED6, //0xD7A1 U+5ED6 # 0x5EE3, //0xD7A2 U+5EE3 # @@ -5329,6 +5384,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6083, //0xD7FD U+6083 # 0x609A //0xD7FE U+609A # }, + //56区 { 0x6084, //0xD8A1 U+6084 # 0x609B, //0xD8A2 U+609B # @@ -5425,6 +5481,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6214, //0xD8FD U+6214 # 0x621B //0xD8FE U+621B # }, + //57区 { 0x621E, //0xD9A1 U+621E # 0x6221, //0xD9A2 U+6221 # @@ -5521,6 +5578,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6488, //0xD9FD U+6488 # 0x64BC //0xD9FE U+64BC # }, + //58区 { 0x64DA, //0xDAA1 U+64DA # 0x64D2, //0xDAA2 U+64D2 # @@ -5617,6 +5675,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x66BE, //0xDAFD U+66BE # 0x66BC //0xDAFE U+66BC # }, + //59区 { 0x66C4, //0xDBA1 U+66C4 # 0x66B8, //0xDBA2 U+66B8 # @@ -5713,6 +5772,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x690C, //0xDBFD U+690C # 0x68CD //0xDBFE U+68CD # }, + //60区 { 0x68D4, //0xDCA1 U+68D4 # 0x68E7, //0xDCA2 U+68E7 # @@ -5809,6 +5869,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6AA2, //0xDCFD U+6AA2 # 0x6AA3 //0xDCFE U+6AA3 # }, + //61区 { 0x6A97, //0xDDA1 U+6A97 # 0x8617, //0xDDA2 U+8617 # @@ -5905,6 +5966,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6CB1, //0xDDFD U+6CB1 # 0x6CBE //0xDDFE U+6CBE # }, + //62区 { 0x6CBA, //0xDEA1 U+6CBA # 0x6CDB, //0xDEA2 U+6CDB # @@ -6001,6 +6063,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6F32, //0xDEFD U+6F32 # 0x6ECC //0xDEFE U+6ECC # }, + //63区 { 0x6F3E, //0xDFA1 U+6F3E # 0x6F13, //0xDFA2 U+6F13 # @@ -6097,6 +6160,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x71F5, //0xDFFD U+71F5 # 0x71FC //0xDFFE U+71FC # }, + //64区 { 0x71F9, //0xE0A1 U+71F9 # 0x71FF, //0xE0A2 U+71FF # @@ -6193,6 +6257,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x74D4, //0xE0FD U+74D4 # 0x73F1 //0xE0FE U+73F1 # }, + //65区 { 0x74E0, //0xE1A1 U+74E0 # 0x74E3, //0xE1A2 U+74E3 # @@ -6289,6 +6354,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x766C, //0xE1FD U+766C # 0x7670 //0xE1FE U+7670 # }, + //66区 { 0x7672, //0xE2A1 U+7672 # 0x7676, //0xE2A2 U+7676 # @@ -6385,6 +6451,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x78CA, //0xE2FD U+78CA # 0x78EC //0xE2FE U+78EC # }, + //67区 { 0x78E7, //0xE3A1 U+78E7 # 0x78DA, //0xE3A2 U+78DA # @@ -6481,6 +6548,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7B36, //0xE3FD U+7B36 # 0x7B50 //0xE3FE U+7B50 # }, + //68区 { 0x7B7A, //0xE4A1 U+7B7A # 0x7B04, //0xE4A2 U+7B04 # @@ -6577,6 +6645,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7CFA, //0xE4FD U+7CFA # 0x7D06 //0xE4FE U+7D06 # }, + //69区 { 0x7D02, //0xE5A1 U+7D02 # 0x7D1C, //0xE5A2 U+7D1C # @@ -6673,6 +6742,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7F38, //0xE5FD U+7F38 # 0x7F3A //0xE5FE U+7F3A # }, + //70区 { 0x7F45, //0xE6A1 U+7F45 # 0x7F4C, //0xE6A2 U+7F4C # @@ -6769,6 +6839,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x812F, //0xE6FD U+812F # 0x814B //0xE6FE U+814B # }, + //71区 { 0x968B, //0xE7A1 U+968B # 0x8146, //0xE7A2 U+8146 # @@ -6865,6 +6936,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8309, //0xE7FD U+8309 # 0x82D9 //0xE7FE U+82D9 # }, + //72区 { 0x8335, //0xE8A1 U+8335 # 0x8334, //0xE8A2 U+8334 # @@ -6961,6 +7033,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8558, //0xE8FD U+8558 # 0x8548 //0xE8FE U+8548 # }, + //73区 { 0x8541, //0xE9A1 U+8541 # 0x8602, //0xE9A2 U+8602 # @@ -7057,6 +7130,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x876E, //0xE9FD U+876E # 0x8759 //0xE9FE U+8759 # }, + //74区 { 0x8753, //0xEAA1 U+8753 # 0x8763, //0xEAA2 U+8763 # @@ -7153,6 +7227,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8960, //0xEAFD U+8960 # 0x895E //0xEAFE U+895E # }, + //75区 { 0x8966, //0xEBA1 U+8966 # 0x8964, //0xEBA2 U+8964 # @@ -7249,6 +7324,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8B5A, //0xEBFD U+8B5A # 0x8B6B //0xEBFE U+8B6B # }, + //76区 { 0x8B5F, //0xECA1 U+8B5F # 0x8B6C, //0xECA2 U+8B6C # @@ -7345,6 +7421,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8E34, //0xECFD U+8E34 # 0x8E4A //0xECFE U+8E4A # }, + //77区 { 0x8E47, //0xEDA1 U+8E47 # 0x8E49, //0xEDA2 U+8E49 # @@ -7441,6 +7518,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x9039, //0xEDFD U+9039 # 0x8FF8 //0xEDFE U+8FF8 # }, + //78区 { 0x904F, //0xEEA1 U+904F # 0x9050, //0xEEA2 U+9050 # @@ -7537,6 +7615,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x9344, //0xEEFD U+9344 # 0x932E //0xEEFE U+932E # }, + //79区 { 0x9319, //0xEFA1 U+9319 # 0x9322, //0xEFA2 U+9322 # @@ -7633,6 +7712,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x965C, //0xEFFD U+965C # 0x965E //0xEFFE U+965E # }, + //80区 { 0x965D, //0xF0A1 U+965D # 0x965F, //0xF0A2 U+965F # @@ -7729,6 +7809,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x986F, //0xF0FD U+986F # 0x9870 //0xF0FE U+9870 # }, + //81区 { 0x9871, //0xF1A1 U+9871 # 0x9874, //0xF1A2 U+9874 # @@ -7825,6 +7906,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x9AF1, //0xF1FD U+9AF1 # 0x9AF7 //0xF1FE U+9AF7 # }, + //82区 { 0x9AFB, //0xF2A1 U+9AFB # 0x9B06, //0xF2A2 U+9B06 # @@ -7921,6 +8003,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x9D46, //0xF2FD U+9D46 # 0x9D48 //0xF2FE U+9D48 # }, + //83区 { 0x9D5D, //0xF3A1 U+9D5D # 0x9D5E, //0xF3A2 U+9D5E # @@ -8017,6 +8100,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x9F9C, //0xF3FD U+9F9C # 0x9FA0 //0xF3FE U+9FA0 # }, + //84区 { 0x582F, //0xF4A1 U+582F # [1983] 0x69C7, //0xF4A2 U+69C7 # [1983] @@ -8113,6 +8197,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x64BE, //0xF4FD U+64BE # [2000] 0x64BF //0xF4FE U+64BF # [2000] }, + //85区 { 0x64C4, //0xF5A1 U+64C4 # [2000] 0x64CA, //0xF5A2 U+64CA # [2000] @@ -8209,6 +8294,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x69CF, //0xF5FD U+69CF # [2000] 0x3BB6 //0xF5FE U+3BB6 # [2000] }, + //86区 { 0x3BC3, //0xF6A1 U+3BC3 # [2000] 0x69E2, //0xF6A2 U+69E2 # [2000] @@ -8305,6 +8391,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x6EB1, //0xF6FD U+6EB1 # [2000] 0x6EC1 //0xF6FE U+6EC1 # [2000] }, + //87区 { 0x6EC7, //0xF7A1 U+6EC7 # [2000] 0x6ECE, //0xF7A2 U+6ECE # [2000] @@ -8401,6 +8488,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x73E3, //0xF7FD U+73E3 # [2000] 0x73E9 //0xF7FE U+73E9 # [2000] }, + //88区 { 0x7407, //0xF8A1 U+7407 # [2000] 0x740A, //0xF8A2 U+740A # [2000] @@ -8497,6 +8585,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x782D, //0xF8FD U+782D # [2000] 0x2548E //0xF8FE U+2548E # [2000] [Unicode3.1] }, + //89区 { 0x7843, //0xF9A1 U+7843 # [2000] 0x784E, //0xF9A2 U+784E # [2000] @@ -8593,6 +8682,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x7D23, //0xF9FD U+7D23 # [2000] 0x7D31 //0xF9FE U+7D31 # [2000] }, + //90区 { 0x7D41, //0xFAA1 U+7D41 # [2000] 0x7D48, //0xFAA2 U+7D48 # [2000] @@ -8689,6 +8779,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x83C7, //0xFAFD U+83C7 # [2000] 0x83CF //0xFAFE U+83CF # [2000] }, + //91区 { 0x83D1, //0xFBA1 U+83D1 # [2000] 0x83E1, //0xFBA2 U+83E1 # [2000] @@ -8785,6 +8876,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x8A12, //0xFBFD U+8A12 # [2000] 0x8A15 //0xFBFE U+8A15 # [2000] }, + //92区 { 0x8A22, //0xFCA1 U+8A22 # [2000] 0x8A37, //0xFCA2 U+8A37 # [2000] @@ -8881,6 +8973,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x91FB, //0xFCFD U+91FB # [2000] 0x91E4 //0xFCFE U+91E4 # [2000] }, + //93区 { 0x91E5, //0xFDA1 U+91E5 # [2000] 0x91ED, //0xFDA2 U+91ED # [2000] @@ -8977,6 +9070,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = 0x9853, //0xFDFD U+9853 # [2000] 0x9856 //0xFDFE U+9856 # [2000] }, + //94区 { 0x9857, //0xFEA1 U+9857 # [2000] 0x9859, //0xFEA2 U+9859 # [2000] @@ -9076,7 +9170,7 @@ const UCSCHAR euc1[ROWNUM][CELLNUM] = }; #pragma endregion -#pragma region EUC half width katakana +#pragma region JIS_X_0201 片仮名 const UCSCHAR eucK[ANKNUM] = { 0xFF61, //0x8EA1 U+FF61 # HALFWIDTH IDEOGRAPHIC FULL STOP @@ -9142,54 +9236,56 @@ const UCSCHAR eucK[ANKNUM] = 0xFF9D, //0x8EDD U+FF9D # HALFWIDTH KATAKANA LETTER N 0xFF9E, //0x8EDE U+FF9E # HALFWIDTH KATAKANA VOICED SOUND MARK 0xFF9F, //0x8EDF U+FF9F # HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000, // - 0x0000 // + 0x0000, //0x8EE0 # + 0x0000, //0x8EE1 # + 0x0000, //0x8EE2 # + 0x0000, //0x8EE3 # + 0x0000, //0x8EE4 # + 0x0000, //0x8EE5 # + 0x0000, //0x8EE6 # + 0x0000, //0x8EE7 # + 0x0000, //0x8EE8 # + 0x0000, //0x8EE9 # + 0x0000, //0x8EEA # + 0x0000, //0x8EEB # + 0x0000, //0x8EEC # + 0x0000, //0x8EED # + 0x0000, //0x8EEE # + 0x0000, //0x8EEF # + 0x0000, //0x8EF0 # + 0x0000, //0x8EF1 # + 0x0000, //0x8EF2 # + 0x0000, //0x8EF3 # + 0x0000, //0x8EF4 # + 0x0000, //0x8EF5 # + 0x0000, //0x8EF6 # + 0x0000, //0x8EF7 # + 0x0000, //0x8EF8 # + 0x0000, //0x8EF9 # + 0x0000, //0x8EFA # + 0x0000, //0x8EFB # + 0x0000, //0x8EFC # + 0x0000, //0x8EFD # + 0x0000 //0x8EFE # }; #pragma endregion -#pragma region EUC 2 INDEX -const BYTE euc2i[ROWNUM] = { - 1, 0, 2, 3, 4, 0, 0, 5, 0, 0, 0, 6, 7, 8, 9, - 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,10,11, - 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 +#pragma region JIS_X_0213 第二面インデックス +const BYTE euc2i[ROWNUM] = +{ + 1, 0, 2, 3, 4, 0, 0, 5, 0, 0, 0, 6, 7, 8, 9, //1-15区 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //16-31区 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //32-47区 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //48-63区 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,11, //64-79区 + 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 //80-94区 }; #pragma endregion -#pragma region EUC 2 +#pragma region JIS_X_0213 第二面 const UCSCHAR euc2[ROW2NUM][CELLNUM] = { + //1区 { 0x20089, //0x8FA1A1 U+20089 # [2000] [Unicode3.1] 0x4E02, //0x8FA1A2 U+4E02 # [2000] @@ -9286,6 +9382,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x50E9, //0x8FA1FD U+50E9 # [2000] 0x3492 //0x8FA1FE U+3492 # [2000] }, + //3区 { 0x5108, //0x8FA3A1 U+5108 # [2000] 0x203F9, //0x8FA3A2 U+203F9 # [2000] [Unicode3.1] @@ -9382,6 +9479,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x5501, //0x8FA3FD U+5501 # [2000] 0x5509 //0x8FA3FE U+5509 # [2000] }, + //4区 { 0x553C, //0x8FA4A1 U+553C # [2000] 0x5541, //0x8FA4A2 U+5541 # [2000] @@ -9478,6 +9576,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x5804, //0x8FA4FD U+5804 # [2000] 0x581E //0x8FA4FE U+581E # [2000] }, + //5区 { 0x5820, //0x8FA5A1 U+5820 # [2000] 0x5827, //0x8FA5A2 U+5827 # [2000] @@ -9574,6 +9673,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x5B84, //0x8FA5FD U+5B84 # [2000] 0x219C3 //0x8FA5FE U+219C3 # [2000] [Unicode3.1] }, + //8区 { 0x5B96, //0x8FA8A1 U+5B96 # [2000] 0x5BAC, //0x8FA8A2 U+5BAC # [2000] @@ -9670,6 +9770,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x5E6C, //0x8FA8FD U+5E6C # [2000] 0x5E6D //0x8FA8FE U+5E6D # [2000] }, + //12区 { 0x5E6E, //0x8FACA1 U+5E6E # [2000] 0x2217B, //0x8FACA2 U+2217B # [2000] [Unicode3.1] @@ -9766,6 +9867,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x626D, //0x8FACFD U+626D # [2000] 0x6273 //0x8FACFE U+6273 # [2000] }, + //13区 { 0x6299, //0x8FADA1 U+6299 # [2000] 0x62A6, //0x8FADA2 U+62A6 # [2000] @@ -9862,6 +9964,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x231C3, //0x8FADFD U+231C3 # [2000] [Unicode3.1] 0x6657 //0x8FADFE U+6657 # [2000] }, + //14区 { 0x665B, //0x8FAEA1 U+665B # [2000] 0x6663, //0x8FAEA2 U+6663 # [2000] @@ -9958,6 +10061,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x68CF, //0x8FAEFD U+68CF # [2000] 0x68D6 //0x8FAEFE U+68D6 # [2000] }, + //15区 { 0x68D9, //0x8FAFA1 U+68D9 # [2000] 0x68E4, //0x8FAFA2 U+68E4 # [2000] @@ -10054,6 +10158,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x6B7A, //0x8FAFFD U+6B7A # [2000] 0x6B81 //0x8FAFFE U+6B81 # [2000] }, + //78区 { 0x6B9B, //0x8FEEA1 U+6B9B # [2000] 0x6BAE, //0x8FEEA2 U+6BAE # [2000] @@ -10150,6 +10255,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x6E63, //0x8FEEFD U+6E63 # [2000] 0x3D1E //0x8FEEFE U+3D1E # [2000] }, + //79区 { 0x6E93, //0x8FEFA1 U+6E93 # [2000] 0x6EA7, //0x8FEFA2 U+6EA7 # [2000] @@ -10246,6 +10352,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x71AE, //0x8FEFFD U+71AE # [2000] 0x71AF //0x8FEFFE U+71AF # [2000] }, + //80区 { 0x71B3, //0x8FF0A1 U+71B3 # [2000] 0x243BC, //0x8FF0A2 U+243BC # [2000] [Unicode3.1] @@ -10342,6 +10449,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x7497, //0x8FF0FD U+7497 # [2000] 0x7499 //0x8FF0FE U+7499 # [2000] }, + //81区 { 0x74A0, //0x8FF1A1 U+74A0 # [2000] 0x74A1, //0x8FF1A2 U+74A1 # [2000] @@ -10438,6 +10546,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x772D, //0x8FF1FD U+772D # [2000] 0x7735 //0x8FF1FE U+7735 # [2000] }, + //82区 { 0x251A9, //0x8FF2A1 U+251A9 # [2000] [Unicode3.1] 0x4039, //0x8FF2A2 U+4039 # [2000] @@ -10534,6 +10643,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x4163, //0x8FF2FD U+4163 # [2000] 0x7A2D //0x8FF2FE U+7A2D # [2000] }, + //83区 { 0x7A38, //0x8FF3A1 U+7A38 # [2000] 0x7A47, //0x8FF3A2 U+7A47 # [2000] @@ -10630,6 +10740,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x25EC2, //0x8FF3FD U+25EC2 # [2000] [Unicode3.1] 0x7CC8 //0x8FF3FE U+7CC8 # [2000] }, + //84区 { 0x7CCD, //0x8FF4A1 U+7CCD # [2000] 0x25EE8, //0x8FF4A2 U+25EE8 # [2000] [Unicode3.1] @@ -10726,6 +10837,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x7FE5, //0x8FF4FD U+7FE5 # [2000] 0x7FEF //0x8FF4FE U+7FEF # [2000] }, + //85区 { 0x7FF2, //0x8FF5A1 U+7FF2 # [2000] 0x8002, //0x8FF5A2 U+8002 # [2000] @@ -10822,6 +10934,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x82A7, //0x8FF5FD U+82A7 # [2000] 0x82A8 //0x8FF5FE U+82A8 # [2000] }, + //86区 { 0x82B2, //0x8FF6A1 U+82B2 # [2000] 0x82B4, //0x8FF6A2 U+82B4 # [2000] @@ -10918,6 +11031,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x859F, //0x8FF6FD U+859F # [2000] 0x26FF8 //0x8FF6FE U+26FF8 # [2000] [Unicode3.1] }, + //87区 { 0x26FF6, //0x8FF7A1 U+26FF6 # [2000] [Unicode3.1] 0x26FF7, //0x8FF7A2 U+26FF7 # [2000] [Unicode3.1] @@ -11014,6 +11128,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x8813, //0x8FF7FD U+8813 # [2000] 0x8828 //0x8FF7FE U+8828 # [2000] }, + //88区 { 0x882E, //0x8FF8A1 U+882E # [2000] 0x8832, //0x8FF8A2 U+8832 # [2000] @@ -11110,6 +11225,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x8C4F, //0x8FF8FD U+8C4F # [2000] 0x8C54 //0x8FF8FE U+8C54 # [2000] }, + //89区 { 0x8C57, //0x8FF9A1 U+8C57 # [2000] 0x8C69, //0x8FF9A2 U+8C69 # [2000] @@ -11206,6 +11322,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x905D, //0x8FF9FD U+905D # [2000] 0x285C8 //0x8FF9FE U+285C8 # [2000] [Unicode3.1] }, + //90区 { 0x285C9, //0x8FFAA1 U+285C9 # [2000] [Unicode3.1] 0x9085, //0x8FFAA2 U+9085 # [2000] @@ -11302,6 +11419,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x9311, //0x8FFAFD U+9311 # [2000] 0x28A1E //0x8FFAFE U+28A1E # [2000] [Unicode3.1] }, + //91区 { 0x28A29, //0x8FFBA1 U+28A29 # [2000] [Unicode3.1] 0x92F7, //0x8FFBA2 U+92F7 # [2000] @@ -11398,6 +11516,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x9757, //0x8FFBFD U+9757 # [2000] 0x975B //0x8FFBFE U+975B # [2000] }, + //92区 { 0x976A, //0x8FFCA1 U+976A # [2000] 0x292A0, //0x8FFCA2 U+292A0 # [2000] [Unicode3.1] @@ -11494,6 +11613,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x9A1A, //0x8FFCFD U+9A1A # [2000] 0x9A20 //0x8FFCFE U+9A20 # [2000] }, + //93区 { 0x9A31, //0x8FFDA1 U+9A31 # [2000] 0x9A36, //0x8FFDA2 U+9A36 # [2000] @@ -11590,6 +11710,7 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = 0x9C75, //0x8FFDFD U+9C75 # [2000] 0x9C7A //0x8FFDFE U+9C7A # [2000] }, + //94区 { 0x9CE6, //0x8FFEA1 U+9CE6 # [2000] 0x9CF2, //0x8FFEA2 U+9CF2 # [2000] @@ -11689,4 +11810,15 @@ const UCSCHAR euc2[ROW2NUM][CELLNUM] = }; #pragma endregion +#pragma region Unicode -> EUC-JIS-2004 互換性 +const EUCCMP euccmp[CMPEUCNUM] = +{ + // nkf 2.1.5 + // 0xA1B1 U+203E # OVERLINE Windows: U+FFE3 + {0xA1B1, 0x203E}, + + // nkf 2.1.5 + // 0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 + {0xA1EF, 0x00A5} +}; #pragma endregion diff --git a/common/eucjis2004table.h b/common/eucjis2004table.h index 1a21631e..5b610718 100644 --- a/common/eucjis2004table.h +++ b/common/eucjis2004table.h @@ -1,19 +1,35 @@ #pragma once -#define CMBCHARNUM 25 -#define ANKNUM 94 -#define ROWNUM 94 -#define CELLNUM 94 -#define ROW2NUM 26 +#define CMBCHARNUM 25 // Unicode結合文字 +#define ROWNUM 94 // 区 +#define CELLNUM 94 // 点 +#define ANKNUM 94 // JIS X 0201 片仮名 +#define ROW2NUM 26 // JIS X 0213 第二面 区数 +#define CMPEUCNUM 2 // Unicode -> EUC-JIS-2004 互換性 +// Unicode結合文字 typedef struct { USHORT euc; UCSCHAR ucp[2]; } EUCCMB; -//変換テーブル -extern const EUCCMB euccmb[CMBCHARNUM]; //Unicode結合文字 -extern const UCSCHAR euc1[ROWNUM][CELLNUM]; //JIS X 0213 第一面 -extern const UCSCHAR eucK[ANKNUM]; //JIS X 0201 -extern const BYTE euc2i[ROWNUM]; //JIS X 0213 第二面インデックス -extern const UCSCHAR euc2[ROW2NUM][CELLNUM]; //JIS X 0213 第二面 +// Unicode互換性 +typedef struct { + USHORT euc; + UCSCHAR ucp; +} EUCCMP; + +// 変換テーブル + +// Unicode結合文字 +extern const EUCCMB euccmb[CMBCHARNUM]; +// JIS X 0213 第一面 +extern const UCSCHAR euc1[ROWNUM][CELLNUM]; +// JIS X 0201 片仮名 +extern const UCSCHAR eucK[ANKNUM]; +// JIS X 0213 第二面 +extern const BYTE euc2i[ROWNUM]; +// JIS X 0213 第二面 +extern const UCSCHAR euc2[ROW2NUM][CELLNUM]; +// Unicode -> EUC-JIS-2004 互換性 +extern const EUCCMP euccmp[CMPEUCNUM]; diff --git a/common/eucjp.cpp b/common/eucjp.cpp new file mode 100644 index 00000000..287b3f4e --- /dev/null +++ b/common/eucjp.cpp @@ -0,0 +1,451 @@ + +#include "eucjptable.h" +#include "eucjis2004.h" + +/* EUC-JP + 0x00.. 0x7F ASCII + 0xA1**.. 0xFE** JIS X 0208 + 0x8E**.. 0x8E** JIS X 0201 HALFWIDTH KATAKANA +0x8FA1**..0x8FFE** JIS X 0212 + (** : 0xA1..0xFE) +*/ + +// EUC 1文字分をUnicode Code Pointへ変換 + +size_t EucJPToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2) +{ + CONST CHAR as = 0x00; + CONST CHAR ae = 0x7F; + CONST CHAR ss2 = (CHAR)0x8E; + CONST CHAR ss3 = (CHAR)0x8F; + CONST CHAR ejd = (CHAR)0x80; + CONST CHAR ejs = 0x21; + CONST CHAR eje = 0x7E; + CHAR ej[2] = {}; + size_t srcused = 0; + + if (src == nullptr || srcsize == 0 || ucp1 == nullptr || ucp2 == nullptr) + { + return 0; + } + + *ucp1 = 0; + *ucp2 = 0; + + if (as <= src[0] && src[0] <= ae) // ASCII + { + *ucp1 = src[0]; + *ucp2 = 0; + srcused = 1; + } + else + { + switch (src[0]) + { + case ss3: // JIS X 0212 + if (srcsize < 3) + { + break; + } + + ej[0] = 0; + ej[1] = 0; + + if ((UCHAR)src[1] >= (UCHAR)ejd) + { + ej[0] = (CHAR)((UCHAR)src[1] - (UCHAR)ejd); + } + + if ((UCHAR)src[2] >= (UCHAR)ejd) + { + ej[1] = (CHAR)((UCHAR)src[2] - (UCHAR)ejd); + } + + if ((ej[0] >= ejs && ej[0] <= eje) && (ej[1] >= ejs && ej[1] <= eje)) + { + *ucp1 = 0; + if (euc0212i[ej[0] - ejs] != 0 && euc0212i[ej[0] - ejs] <= ROW0212NUM) + { + *ucp1 = euc0212[euc0212i[ej[0] - ejs] - 1][ej[1] - ejs]; + } + *ucp2 = 0; + srcused = 3; + } + break; + + case ss2: // JIS X 0201 片仮名 + if (srcsize < 2) + { + break; + } + + ej[0] = 0; + + if ((UCHAR)src[1] >= (UCHAR)ejd) + { + ej[0] = (CHAR)((UCHAR)src[1] - (UCHAR)ejd); + } + + if (ej[0] >= ejs && ej[0] <= eje) + { + *ucp1 = eucK[ej[0] - ejs]; + *ucp2 = 0; + srcused = 2; + } + break; + + default: // JIS X 0208 + if (srcsize < 2) + { + break; + } + + ej[0] = 0; + ej[1] = 0; + + if ((UCHAR)src[0] >= (UCHAR)ejd) + { + ej[0] = (CHAR)((UCHAR)src[0] - (UCHAR)ejd); + } + + if ((UCHAR)src[1] >= (UCHAR)ejd) + { + ej[1] = (CHAR)((UCHAR)src[1] - (UCHAR)ejd); + } + + if ((ej[0] >= ejs && ej[0] <= eje) && (ej[1] >= ejs && ej[1] <= eje)) + { + *ucp1 = 0; + CHAR ku = ej[0] - ejs + 1; + CHAR ten = ej[1] - ejs + 1; + if ((jisx0208e[ku - 1][(ten - (ten % 16)) / 16] & (0x0001 << (ten % 16))) != 0) + { + *ucp1 = euc1[ej[0] - ejs][ej[1] - ejs]; + } + *ucp2 = 0; + srcused = 2; + } + break; + } + } + + return srcused; +} + +// EUC-JPをUTF-16へ変換 + +BOOL EucJPToWideChar(LPCSTR src, size_t *srcsize, LPWSTR dst, size_t *dstsize) +{ + size_t si = 0, di = 0, ss = -1; + UCSCHAR ucp[2] = {}; + WCHAR utf16[2][2] = {}; + size_t utf16num[2] = {}; + + if (dstsize == nullptr) + { + return FALSE; + } + + if (dst == nullptr) + { + *dstsize = (size_t)-1; + } + + if (src == nullptr) + { + *dstsize = 0; + return FALSE; + } + + if (srcsize != nullptr) + { + ss = *srcsize; + } + + for (si = 0; ; si++) + { + if ((ss <= si) || (*(src + si) == '\0')) + { + break; + } + + // EUC-JPからUnicode Code Pointへ変換 + size_t used = EucJPToUcp(src + si, ss - si, &ucp[0], &ucp[1]); + if ((ucp[0] == 0) || (used == 0)) + { + AddNullWideChar(srcsize, si, dst, dstsize, di); + return FALSE; + } + si += used - 1; + + // Unicode Code PointからUTF-16へ変換 + for (int i = 0; i < 2; i++) + { + utf16num[i] = 0; + if (ucp[i] != 0) + { + utf16num[i] = UcpToWideChar(ucp[i], &utf16[i][0], &utf16[i][1]); + } + } + + if (*dstsize <= di + utf16num[0] + utf16num[1]) // limit + { + AddNullWideChar(srcsize, si, dst, dstsize, di); + return FALSE; + } + + for (int i = 0; i < 2; i++) + { + if (dst != nullptr) + { + for (int j = 0; j < (int)utf16num[i] && j < 2; j++) + { + *(dst + di + j) = utf16[i][j]; + } + } + di += utf16num[i]; + } + } + + AddNullWideChar(srcsize, si, dst, dstsize, di); + return TRUE; +} + +// UTF-16をEUC-JPへ変換 + +BOOL WideCharToEucJP(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsize) +{ + CONST CHAR ss2 = (CHAR)0x8E; + CONST CHAR ss3 = (CHAR)0x8F; + CONST CHAR ejd = (CHAR)0x80; + CONST CHAR ejs = 0x21; + size_t si = 0, di = 0, ss = -1; + UCSCHAR ucp; + BOOL exist; + + if (dstsize == nullptr) + { + return FALSE; + } + + if (dst == nullptr) + { + *dstsize = (size_t)-1; + } + + if (src == nullptr) + { + *dstsize = 0; + return FALSE; + } + + if (srcsize != nullptr) + { + ss = *srcsize; + } + + for (si = 0; ; si++) + { + if ((ss <= si) || (*(src + si) == L'\0')) + { + break; + } + + if (*(src + si) <= L'\x7F') // ASCII + { + if (*dstsize <= di + 1) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = (CHAR) * (src + si); + } + ++di; + } + else + { + exist = FALSE; + + // surrogate pair なし + ucp = *(src + si); + + // 互換性 + if (!exist) + { + for (int i = 0; i < CMPEUCJPNUM; i++) + { + if (ucp == eucjpcmp[i].ucp) + { + if (*dstsize <= di + 2) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = (CHAR)(eucjpcmp[i].euc >> 8); + *(dst + di + 1) = (CHAR)(eucjpcmp[i].euc & 0xFF); + } + di += 2; + exist = TRUE; + break; + } + } + } + + // JIS X 0218 + if (!exist) + { + for (int i = 0; i < ROWNUM; i++) + { + for (int j = 0; j < CELLNUM; j++) + { + CHAR ku = i + 1; + CHAR ten = j + 1; + if ((jisx0208e[ku - 1][(ten - (ten % 16)) / 16] & (0x0001 << (ten % 16))) != 0 && + ucp == euc1[i][j]) + { + if (*dstsize <= di + 2) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = (CHAR)((UCHAR)(ejs + i) + (UCHAR)ejd); + *(dst + di + 1) = (CHAR)((UCHAR)(ejs + j) + (UCHAR)ejd); + } + di += 2; + exist = TRUE; + break; + } + } + + if (exist) + { + break; + } + } + } + + // JIS X 0212 + if (!exist) + { + for (int i = 0; i < ROWNUM; i++) + { + for (int j = 0; j < CELLNUM; j++) + { + if (euc0212i[i] != 0 && euc0212i[i] <= ROW0212NUM && + ucp == euc0212[euc0212i[i] - 1][j]) + { + if (*dstsize <= di + 3) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = ss3; + *(dst + di + 1) = (CHAR)((UCHAR)(ejs + i) + (UCHAR)ejd); + *(dst + di + 2) = (CHAR)((UCHAR)(ejs + j) + (UCHAR)ejd); + } + di += 3; + exist = TRUE; + break; + } + } + + if (exist) + { + break; + } + } + } + + // JIS X 0201 片仮名 + if (!exist) + { + for (int i = 0; i < ANKNUM; i++) + { + if (ucp == eucK[i]) + { + if (*dstsize <= di + 2) // limit + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + if (dst != nullptr) + { + *(dst + di) = ss2; + *(dst + di + 1) = (CHAR)((UCHAR)(ejs + i) + (UCHAR)ejd); + } + di += 2; + exist = TRUE; + break; + } + } + } + + if (!exist) + { + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return FALSE; + } + } + } + + AddNullMultiByte(srcsize, si, dst, dstsize, di); + return TRUE; +} + +std::wstring eucjp_string_to_wstring(const std::string &s) +{ + std::wstring ret; + size_t len; + + BOOL b = EucJPToWideChar(s.c_str(), nullptr, nullptr, &len); + if (b && len > 0) + { + try + { + LPWSTR wcs = new WCHAR[len]; + if (EucJPToWideChar(s.c_str(), nullptr, wcs, &len)) + { + ret = wcs; + } + delete[] wcs; + } + catch (...) + { + } + } + + return ret; +} + +std::string wstring_to_eucjp_string(const std::wstring &s) +{ + std::string ret; + size_t len; + + BOOL b = WideCharToEucJP(s.c_str(), nullptr, nullptr, &len); + if (b && len > 0) + { + try + { + LPSTR euc = new CHAR[len]; + if (WideCharToEucJP(s.c_str(), nullptr, euc, &len)) + { + ret = euc; + } + delete[] euc; + } + catch (...) + { + } + } + + return ret; +} diff --git a/common/eucjp.h b/common/eucjp.h new file mode 100644 index 00000000..38b5abc6 --- /dev/null +++ b/common/eucjp.h @@ -0,0 +1,48 @@ +#pragma once + +// EUC 1文字分をUnicode Code Pointへ変換 +// 戻り値 +// 変換に使用されたサイズ(char単位) +// 引数 +// src : 変換元のEUC-JP文字列 +// srcsize : 変換元のEUC-JP文字列のサイズ +// ucp1 : Unicode符号位置1つ目 +// ucp2 : Unicode符号位置2つ目(結合文字がある場合、なければ0) +size_t EucJPToUcp(LPCSTR src, size_t srcsize, PUCSCHAR ucp1, PUCSCHAR ucp2); + +// EUC-JPをUTF-16へ変換 +// 戻り値 +// TRUE : 成功 +// FALSE : 失敗 +// 引数 +// src : 変換元のEUC-JP文字列 +// nullptrのとき戻り値はFALSEになる +// srcsize : nullptrのときsrcの終端NULLまで変換する +// nullptr以外のとき指定されたサイズまたはsrcの終端NULLの短いほうまで変換する +// 変換に使用されたサイズ(char単位)が戻る +// dst : 変換先のUTF-16LE文字列バッファ +// nullptrは許容される +// dstsize : dstのサイズ +// 変換結果の終端NULLを含むサイズ(wchar_t単位)が戻る +// nullptrのとき戻り値はFALSEになる +BOOL EucJPToWideChar(LPCSTR src, size_t *srcsize, LPWSTR dst, size_t *dstsize); + +// UTF-16をEUC-JPへ変換 +// 戻り値 +// TRUE : 成功 +// FALSE : 失敗 +// 引数 +// src : 変換元のUTF-16LE文字列 +// nullptrのとき戻り値はFALSEになる +// srcsize : nullptrのときsrcの終端NULLまで変換する +// nullptr以外のとき指定されたサイズまたはsrcの終端NULLの短いほうまで変換する +// 変換に使用されたサイズ(wchar_t単位)が戻る +// dst : 変換先のEUC-JP文字列バッファ +// nullptrは許容される +// dstsize : dstのサイズ +// 変換結果の終端NULLを含むサイズ(char単位)が戻る +// nullptrのとき戻り値はFALSEになる +BOOL WideCharToEucJP(LPCWSTR src, size_t *srcsize, LPSTR dst, size_t *dstsize); + +std::wstring eucjp_string_to_wstring(const std::string &s); +std::string wstring_to_eucjp_string(const std::wstring &s); diff --git a/common/eucjptable.cpp b/common/eucjptable.cpp new file mode 100644 index 00000000..8e76d987 --- /dev/null +++ b/common/eucjptable.cpp @@ -0,0 +1,6790 @@ + +#include "eucjptable.h" + +// +// EUC-JP / Unicode 変換表 +// +// https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0208.TXT +// https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0212.TXT +// を元に生成 +// +// 以下の符号は、iconv 1.17 では Windows (CP932) mapping となっているが、 +// EUC-JIS-2004 と同様に U+2014 とした。 +// +// 0xA1BD U+2014 # EM DASH Windows: U+2015 +// +// JIS X 0208 は、eucjis2004table.cpp の JIS X 0213 第一面 (euc1) のうち +// JIS X 0208 有効区点テーブル (jisx0208e) で有効とされる区点を使用する。 +// +// JIS X 0201 は、eucjis2004table.cpp の JIS X 0201 片仮名 (eucK) を使用する。 +// +// JIS X 0212 は、JIS X 0212 テーブル (euc0212) から +// JIS X 0212 インデックステーブル (euc0212i) で有効とされる区を使用する。 +// + +#pragma region JIS_X_0208 有効区点 +const USHORT jisx0208e[ROWNUM][COLNUM] = +{ + //1-15点, 16-31点, 32-47点, 48-63点, 64-79点, 80-94点 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //1区 + {0x7FFE, 0xFC00, 0xFC03, 0xF001, 0x07FF, 0x43FC}, //2区 + {0x0000, 0x03FF, 0xFFFE, 0x07FF, 0xFFFE, 0x07FF}, //3区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x000F}, //4区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x007F}, //5区 + {0xFFFE, 0x01FF, 0xFFFE, 0x01FF, 0x0000, 0x0000}, //6区 + {0xFFFE, 0xFFFF, 0x0003, 0xFFFE, 0xFFFF, 0x0003}, //7区 + {0xFFFE, 0xFFFF, 0x0001, 0x0000, 0x0000, 0x0000}, //8区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //9区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //10区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //11区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //12区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //13区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //14区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //15区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //16区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //17区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //18区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //19区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //20区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //21区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //22区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //23区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //24区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //25区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //26区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //27区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //28区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //29区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //30区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //31区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //32区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //33区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //34区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //35区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //36区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //37区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //38区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //39区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //40区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //41区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //42区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //43区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //44区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //45区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //46区 + {0xFFFE, 0xFFFF, 0xFFFF, 0x000F, 0x0000, 0x0000}, //47区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //48区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //49区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //50区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //51区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //52区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //53区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //54区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //55区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //56区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //57区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //58区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //59区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //60区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //61区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //62区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //63区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //64区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //65区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //66区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //67区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //68区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //69区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //70区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //71区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //72区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //73区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //74区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //75区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //76区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //77区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //78区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //79区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //80区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //81区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //82区 + {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //83区 + {0x007E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //84区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //85区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //86区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //87区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //88区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //89区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //90区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //91区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //92区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, //93区 + {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000} //94区 +}; +#pragma endregion + +#pragma region JIS_X_0212 インデックス +const BYTE euc0212i[ROWNUM] = +{ + 0, 1, 0, 0, 0, 2, 3, 0, 4, 5, 6, 0, 0, 0, 0, //1-15区 + 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22, //16-31区 + 23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38, //32-47区 + 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54, //48-63区 + 55,56,57,58,59,60,61,62,63,64,65,66,67,68, 0, 0, //64-79区 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 //80-94区 +}; +#pragma endregion + +#pragma region JIS_X_0212 +const UCSCHAR euc0212[ROW0212NUM][CELLNUM] = +{ + //2区 + { + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x02D8, //0x222F 0x02D8 # BREVE + 0x02C7, //0x2230 0x02C7 # CARON (Mandarin Chinese third tone) + 0x00B8, //0x2231 0x00B8 # CEDILLA + 0x02D9, //0x2232 0x02D9 # DOT ABOVE (Mandarin Chinese light tone) + 0x02DD, //0x2233 0x02DD # DOUBLE ACUTE ACCENT + 0x00AF, //0x2234 0x00AF # MACRON + 0x02DB, //0x2235 0x02DB # OGONEK + 0x02DA, //0x2236 0x02DA # RING ABOVE +// 0x007E, //0x2237 0x007E # TILDE + 0xFF5E, //0x2237 0x007E # TILDE //// same as iconv //// + 0x0384, //0x2238 0x0384 # GREEK TONOS + 0x0385, //0x2239 0x0385 # GREEK DIALYTIKA TONOS + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x00A1, //0x2242 0x00A1 # INVERTED EXCLAMATION MARK + 0x00A6, //0x2243 0x00A6 # BROKEN BAR + 0x00BF, //0x2244 0x00BF # INVERTED QUESTION MARK + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x00BA, //0x226B 0x00BA # MASCULINE ORDINAL INDICATOR + 0x00AA, //0x226C 0x00AA # FEMININE ORDINAL INDICATOR + 0x00A9, //0x226D 0x00A9 # COPYRIGHT SIGN + 0x00AE, //0x226E 0x00AE # REGISTERED SIGN + 0x2122, //0x226F 0x2122 # TRADE MARK SIGN + 0x00A4, //0x2270 0x00A4 # CURRENCY SIGN + 0x2116, //0x2271 0x2116 # NUMERO SIGN + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000 // + }, + //6区 + { + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0386, //0x2661 0x0386 # GREEK CAPITAL LETTER ALPHA WITH TONOS + 0x0388, //0x2662 0x0388 # GREEK CAPITAL LETTER EPSILON WITH TONOS + 0x0389, //0x2663 0x0389 # GREEK CAPITAL LETTER ETA WITH TONOS + 0x038A, //0x2664 0x038A # GREEK CAPITAL LETTER IOTA WITH TONOS + 0x03AA, //0x2665 0x03AA # GREEK CAPITAL LETTER IOTA WITH DIALYTIKA + 0x0000, // + 0x038C, //0x2667 0x038C # GREEK CAPITAL LETTER OMICRON WITH TONOS + 0x0000, // + 0x038E, //0x2669 0x038E # GREEK CAPITAL LETTER UPSILON WITH TONOS + 0x03AB, //0x266A 0x03AB # GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA + 0x0000, // + 0x038F, //0x266C 0x038F # GREEK CAPITAL LETTER OMEGA WITH TONOS + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x03AC, //0x2671 0x03AC # GREEK SMALL LETTER ALPHA WITH TONOS + 0x03AD, //0x2672 0x03AD # GREEK SMALL LETTER EPSILON WITH TONOS + 0x03AE, //0x2673 0x03AE # GREEK SMALL LETTER ETA WITH TONOS + 0x03AF, //0x2674 0x03AF # GREEK SMALL LETTER IOTA WITH TONOS + 0x03CA, //0x2675 0x03CA # GREEK SMALL LETTER IOTA WITH DIALYTIKA + 0x0390, //0x2676 0x0390 # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS + 0x03CC, //0x2677 0x03CC # GREEK SMALL LETTER OMICRON WITH TONOS + 0x03C2, //0x2678 0x03C2 # GREEK SMALL LETTER FINAL SIGMA + 0x03CD, //0x2679 0x03CD # GREEK SMALL LETTER UPSILON WITH TONOS + 0x03CB, //0x267A 0x03CB # GREEK SMALL LETTER UPSILON WITH DIALYTIKA + 0x03B0, //0x267B 0x03B0 # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS + 0x03CE, //0x267C 0x03CE # GREEK SMALL LETTER OMEGA WITH TONOS + 0x0000, // + 0x0000 // + }, + //7区 + { + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0402, //0x2742 0x0402 # CYRILLIC CAPITAL LETTER DJE + 0x0403, //0x2743 0x0403 # CYRILLIC CAPITAL LETTER GJE + 0x0404, //0x2744 0x0404 # CYRILLIC CAPITAL LETTER UKRAINIAN IE + 0x0405, //0x2745 0x0405 # CYRILLIC CAPITAL LETTER DZE + 0x0406, //0x2746 0x0406 # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I + 0x0407, //0x2747 0x0407 # CYRILLIC CAPITAL LETTER YI + 0x0408, //0x2748 0x0408 # CYRILLIC CAPITAL LETTER JE + 0x0409, //0x2749 0x0409 # CYRILLIC CAPITAL LETTER LJE + 0x040A, //0x274A 0x040A # CYRILLIC CAPITAL LETTER NJE + 0x040B, //0x274B 0x040B # CYRILLIC CAPITAL LETTER TSHE + 0x040C, //0x274C 0x040C # CYRILLIC CAPITAL LETTER KJE + 0x040E, //0x274D 0x040E # CYRILLIC CAPITAL LETTER SHORT U + 0x040F, //0x274E 0x040F # CYRILLIC CAPITAL LETTER DZHE + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0452, //0x2772 0x0452 # CYRILLIC SMALL LETTER DJE + 0x0453, //0x2773 0x0453 # CYRILLIC SMALL LETTER GJE + 0x0454, //0x2774 0x0454 # CYRILLIC SMALL LETTER UKRAINIAN IE + 0x0455, //0x2775 0x0455 # CYRILLIC SMALL LETTER DZE + 0x0456, //0x2776 0x0456 # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I + 0x0457, //0x2777 0x0457 # CYRILLIC SMALL LETTER YI + 0x0458, //0x2778 0x0458 # CYRILLIC SMALL LETTER JE + 0x0459, //0x2779 0x0459 # CYRILLIC SMALL LETTER LJE + 0x045A, //0x277A 0x045A # CYRILLIC SMALL LETTER NJE + 0x045B, //0x277B 0x045B # CYRILLIC SMALL LETTER TSHE + 0x045C, //0x277C 0x045C # CYRILLIC SMALL LETTER KJE + 0x045E, //0x277D 0x045E # CYRILLIC SMALL LETTER SHORT U + 0x045F //0x277E 0x045F # CYRILLIC SMALL LETTER DZHE + }, + //9区 + { + 0x00C6, //0x2921 0x00C6 # LATIN CAPITAL LIGATURE AE + 0x0110, //0x2922 0x0110 # LATIN CAPITAL LETTER D WITH STROKE + 0x0000, // + 0x0126, //0x2924 0x0126 # LATIN CAPITAL LETTER H WITH STROKE + 0x0000, // + 0x0132, //0x2926 0x0132 # LATIN CAPITAL LIGATURE IJ + 0x0000, // + 0x0141, //0x2928 0x0141 # LATIN CAPITAL LETTER L WITH STROKE + 0x013F, //0x2929 0x013F # LATIN CAPITAL LETTER L WITH MIDDLE DOT + 0x0000, // + 0x014A, //0x292B 0x014A # LATIN CAPITAL LETTER ENG + 0x00D8, //0x292C 0x00D8 # LATIN CAPITAL LETTER O WITH STROKE + 0x0152, //0x292D 0x0152 # LATIN CAPITAL LIGATURE OE + 0x0000, // + 0x0166, //0x292F 0x0166 # LATIN CAPITAL LETTER T WITH STROKE + 0x00DE, //0x2930 0x00DE # LATIN CAPITAL LETTER THORN + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x00E6, //0x2941 0x00E6 # LATIN SMALL LIGATURE AE + 0x0111, //0x2942 0x0111 # LATIN SMALL LETTER D WITH STROKE + 0x00F0, //0x2943 0x00F0 # LATIN SMALL LETTER ETH + 0x0127, //0x2944 0x0127 # LATIN SMALL LETTER H WITH STROKE + 0x0131, //0x2945 0x0131 # LATIN SMALL LETTER DOTLESS I + 0x0133, //0x2946 0x0133 # LATIN SMALL LIGATURE IJ + 0x0138, //0x2947 0x0138 # LATIN SMALL LETTER KRA + 0x0142, //0x2948 0x0142 # LATIN SMALL LETTER L WITH STROKE + 0x0140, //0x2949 0x0140 # LATIN SMALL LETTER L WITH MIDDLE DOT + 0x0149, //0x294A 0x0149 # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE + 0x014B, //0x294B 0x014B # LATIN SMALL LETTER ENG + 0x00F8, //0x294C 0x00F8 # LATIN SMALL LETTER O WITH STROKE + 0x0153, //0x294D 0x0153 # LATIN SMALL LIGATURE OE + 0x00DF, //0x294E 0x00DF # LATIN SMALL LETTER SHARP S + 0x0167, //0x294F 0x0167 # LATIN SMALL LETTER T WITH STROKE + 0x00FE, //0x2950 0x00FE # LATIN SMALL LETTER THORN + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000 // + }, + //10区 + { + 0x00C1, //0x2A21 0x00C1 # LATIN CAPITAL LETTER A WITH ACUTE + 0x00C0, //0x2A22 0x00C0 # LATIN CAPITAL LETTER A WITH GRAVE + 0x00C4, //0x2A23 0x00C4 # LATIN CAPITAL LETTER A WITH DIAERESIS + 0x00C2, //0x2A24 0x00C2 # LATIN CAPITAL LETTER A WITH CIRCUMFLEX + 0x0102, //0x2A25 0x0102 # LATIN CAPITAL LETTER A WITH BREVE + 0x01CD, //0x2A26 0x01CD # LATIN CAPITAL LETTER A WITH CARON + 0x0100, //0x2A27 0x0100 # LATIN CAPITAL LETTER A WITH MACRON + 0x0104, //0x2A28 0x0104 # LATIN CAPITAL LETTER A WITH OGONEK + 0x00C5, //0x2A29 0x00C5 # LATIN CAPITAL LETTER A WITH RING ABOVE + 0x00C3, //0x2A2A 0x00C3 # LATIN CAPITAL LETTER A WITH TILDE + 0x0106, //0x2A2B 0x0106 # LATIN CAPITAL LETTER C WITH ACUTE + 0x0108, //0x2A2C 0x0108 # LATIN CAPITAL LETTER C WITH CIRCUMFLEX + 0x010C, //0x2A2D 0x010C # LATIN CAPITAL LETTER C WITH CARON + 0x00C7, //0x2A2E 0x00C7 # LATIN CAPITAL LETTER C WITH CEDILLA + 0x010A, //0x2A2F 0x010A # LATIN CAPITAL LETTER C WITH DOT ABOVE + 0x010E, //0x2A30 0x010E # LATIN CAPITAL LETTER D WITH CARON + 0x00C9, //0x2A31 0x00C9 # LATIN CAPITAL LETTER E WITH ACUTE + 0x00C8, //0x2A32 0x00C8 # LATIN CAPITAL LETTER E WITH GRAVE + 0x00CB, //0x2A33 0x00CB # LATIN CAPITAL LETTER E WITH DIAERESIS + 0x00CA, //0x2A34 0x00CA # LATIN CAPITAL LETTER E WITH CIRCUMFLEX + 0x011A, //0x2A35 0x011A # LATIN CAPITAL LETTER E WITH CARON + 0x0116, //0x2A36 0x0116 # LATIN CAPITAL LETTER E WITH DOT ABOVE + 0x0112, //0x2A37 0x0112 # LATIN CAPITAL LETTER E WITH MACRON + 0x0118, //0x2A38 0x0118 # LATIN CAPITAL LETTER E WITH OGONEK + 0x0000, // + 0x011C, //0x2A3A 0x011C # LATIN CAPITAL LETTER G WITH CIRCUMFLEX + 0x011E, //0x2A3B 0x011E # LATIN CAPITAL LETTER G WITH BREVE + 0x0122, //0x2A3C 0x0122 # LATIN CAPITAL LETTER G WITH CEDILLA + 0x0120, //0x2A3D 0x0120 # LATIN CAPITAL LETTER G WITH DOT ABOVE + 0x0124, //0x2A3E 0x0124 # LATIN CAPITAL LETTER H WITH CIRCUMFLEX + 0x00CD, //0x2A3F 0x00CD # LATIN CAPITAL LETTER I WITH ACUTE + 0x00CC, //0x2A40 0x00CC # LATIN CAPITAL LETTER I WITH GRAVE + 0x00CF, //0x2A41 0x00CF # LATIN CAPITAL LETTER I WITH DIAERESIS + 0x00CE, //0x2A42 0x00CE # LATIN CAPITAL LETTER I WITH CIRCUMFLEX + 0x01CF, //0x2A43 0x01CF # LATIN CAPITAL LETTER I WITH CARON + 0x0130, //0x2A44 0x0130 # LATIN CAPITAL LETTER I WITH DOT ABOVE + 0x012A, //0x2A45 0x012A # LATIN CAPITAL LETTER I WITH MACRON + 0x012E, //0x2A46 0x012E # LATIN CAPITAL LETTER I WITH OGONEK + 0x0128, //0x2A47 0x0128 # LATIN CAPITAL LETTER I WITH TILDE + 0x0134, //0x2A48 0x0134 # LATIN CAPITAL LETTER J WITH CIRCUMFLEX + 0x0136, //0x2A49 0x0136 # LATIN CAPITAL LETTER K WITH CEDILLA + 0x0139, //0x2A4A 0x0139 # LATIN CAPITAL LETTER L WITH ACUTE + 0x013D, //0x2A4B 0x013D # LATIN CAPITAL LETTER L WITH CARON + 0x013B, //0x2A4C 0x013B # LATIN CAPITAL LETTER L WITH CEDILLA + 0x0143, //0x2A4D 0x0143 # LATIN CAPITAL LETTER N WITH ACUTE + 0x0147, //0x2A4E 0x0147 # LATIN CAPITAL LETTER N WITH CARON + 0x0145, //0x2A4F 0x0145 # LATIN CAPITAL LETTER N WITH CEDILLA + 0x00D1, //0x2A50 0x00D1 # LATIN CAPITAL LETTER N WITH TILDE + 0x00D3, //0x2A51 0x00D3 # LATIN CAPITAL LETTER O WITH ACUTE + 0x00D2, //0x2A52 0x00D2 # LATIN CAPITAL LETTER O WITH GRAVE + 0x00D6, //0x2A53 0x00D6 # LATIN CAPITAL LETTER O WITH DIAERESIS + 0x00D4, //0x2A54 0x00D4 # LATIN CAPITAL LETTER O WITH CIRCUMFLEX + 0x01D1, //0x2A55 0x01D1 # LATIN CAPITAL LETTER O WITH CARON + 0x0150, //0x2A56 0x0150 # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE + 0x014C, //0x2A57 0x014C # LATIN CAPITAL LETTER O WITH MACRON + 0x00D5, //0x2A58 0x00D5 # LATIN CAPITAL LETTER O WITH TILDE + 0x0154, //0x2A59 0x0154 # LATIN CAPITAL LETTER R WITH ACUTE + 0x0158, //0x2A5A 0x0158 # LATIN CAPITAL LETTER R WITH CARON + 0x0156, //0x2A5B 0x0156 # LATIN CAPITAL LETTER R WITH CEDILLA + 0x015A, //0x2A5C 0x015A # LATIN CAPITAL LETTER S WITH ACUTE + 0x015C, //0x2A5D 0x015C # LATIN CAPITAL LETTER S WITH CIRCUMFLEX + 0x0160, //0x2A5E 0x0160 # LATIN CAPITAL LETTER S WITH CARON + 0x015E, //0x2A5F 0x015E # LATIN CAPITAL LETTER S WITH CEDILLA + 0x0164, //0x2A60 0x0164 # LATIN CAPITAL LETTER T WITH CARON + 0x0162, //0x2A61 0x0162 # LATIN CAPITAL LETTER T WITH CEDILLA + 0x00DA, //0x2A62 0x00DA # LATIN CAPITAL LETTER U WITH ACUTE + 0x00D9, //0x2A63 0x00D9 # LATIN CAPITAL LETTER U WITH GRAVE + 0x00DC, //0x2A64 0x00DC # LATIN CAPITAL LETTER U WITH DIAERESIS + 0x00DB, //0x2A65 0x00DB # LATIN CAPITAL LETTER U WITH CIRCUMFLEX + 0x016C, //0x2A66 0x016C # LATIN CAPITAL LETTER U WITH BREVE + 0x01D3, //0x2A67 0x01D3 # LATIN CAPITAL LETTER U WITH CARON + 0x0170, //0x2A68 0x0170 # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE + 0x016A, //0x2A69 0x016A # LATIN CAPITAL LETTER U WITH MACRON + 0x0172, //0x2A6A 0x0172 # LATIN CAPITAL LETTER U WITH OGONEK + 0x016E, //0x2A6B 0x016E # LATIN CAPITAL LETTER U WITH RING ABOVE + 0x0168, //0x2A6C 0x0168 # LATIN CAPITAL LETTER U WITH TILDE + 0x01D7, //0x2A6D 0x01D7 # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE + 0x01DB, //0x2A6E 0x01DB # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE + 0x01D9, //0x2A6F 0x01D9 # LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON + 0x01D5, //0x2A70 0x01D5 # LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON + 0x0174, //0x2A71 0x0174 # LATIN CAPITAL LETTER W WITH CIRCUMFLEX + 0x00DD, //0x2A72 0x00DD # LATIN CAPITAL LETTER Y WITH ACUTE + 0x0178, //0x2A73 0x0178 # LATIN CAPITAL LETTER Y WITH DIAERESIS + 0x0176, //0x2A74 0x0176 # LATIN CAPITAL LETTER Y WITH CIRCUMFLEX + 0x0179, //0x2A75 0x0179 # LATIN CAPITAL LETTER Z WITH ACUTE + 0x017D, //0x2A76 0x017D # LATIN CAPITAL LETTER Z WITH CARON + 0x017B, //0x2A77 0x017B # LATIN CAPITAL LETTER Z WITH DOT ABOVE + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000 // + }, + //11区 + { + 0x00E1, //0x2B21 0x00E1 # LATIN SMALL LETTER A WITH ACUTE + 0x00E0, //0x2B22 0x00E0 # LATIN SMALL LETTER A WITH GRAVE + 0x00E4, //0x2B23 0x00E4 # LATIN SMALL LETTER A WITH DIAERESIS + 0x00E2, //0x2B24 0x00E2 # LATIN SMALL LETTER A WITH CIRCUMFLEX + 0x0103, //0x2B25 0x0103 # LATIN SMALL LETTER A WITH BREVE + 0x01CE, //0x2B26 0x01CE # LATIN SMALL LETTER A WITH CARON + 0x0101, //0x2B27 0x0101 # LATIN SMALL LETTER A WITH MACRON + 0x0105, //0x2B28 0x0105 # LATIN SMALL LETTER A WITH OGONEK + 0x00E5, //0x2B29 0x00E5 # LATIN SMALL LETTER A WITH RING ABOVE + 0x00E3, //0x2B2A 0x00E3 # LATIN SMALL LETTER A WITH TILDE + 0x0107, //0x2B2B 0x0107 # LATIN SMALL LETTER C WITH ACUTE + 0x0109, //0x2B2C 0x0109 # LATIN SMALL LETTER C WITH CIRCUMFLEX + 0x010D, //0x2B2D 0x010D # LATIN SMALL LETTER C WITH CARON + 0x00E7, //0x2B2E 0x00E7 # LATIN SMALL LETTER C WITH CEDILLA + 0x010B, //0x2B2F 0x010B # LATIN SMALL LETTER C WITH DOT ABOVE + 0x010F, //0x2B30 0x010F # LATIN SMALL LETTER D WITH CARON + 0x00E9, //0x2B31 0x00E9 # LATIN SMALL LETTER E WITH ACUTE + 0x00E8, //0x2B32 0x00E8 # LATIN SMALL LETTER E WITH GRAVE + 0x00EB, //0x2B33 0x00EB # LATIN SMALL LETTER E WITH DIAERESIS + 0x00EA, //0x2B34 0x00EA # LATIN SMALL LETTER E WITH CIRCUMFLEX + 0x011B, //0x2B35 0x011B # LATIN SMALL LETTER E WITH CARON + 0x0117, //0x2B36 0x0117 # LATIN SMALL LETTER E WITH DOT ABOVE + 0x0113, //0x2B37 0x0113 # LATIN SMALL LETTER E WITH MACRON + 0x0119, //0x2B38 0x0119 # LATIN SMALL LETTER E WITH OGONEK + 0x01F5, //0x2B39 0x01F5 # LATIN SMALL LETTER G WITH ACUTE + 0x011D, //0x2B3A 0x011D # LATIN SMALL LETTER G WITH CIRCUMFLEX + 0x011F, //0x2B3B 0x011F # LATIN SMALL LETTER G WITH BREVE + 0x0000, // + 0x0121, //0x2B3D 0x0121 # LATIN SMALL LETTER G WITH DOT ABOVE + 0x0125, //0x2B3E 0x0125 # LATIN SMALL LETTER H WITH CIRCUMFLEX + 0x00ED, //0x2B3F 0x00ED # LATIN SMALL LETTER I WITH ACUTE + 0x00EC, //0x2B40 0x00EC # LATIN SMALL LETTER I WITH GRAVE + 0x00EF, //0x2B41 0x00EF # LATIN SMALL LETTER I WITH DIAERESIS + 0x00EE, //0x2B42 0x00EE # LATIN SMALL LETTER I WITH CIRCUMFLEX + 0x01D0, //0x2B43 0x01D0 # LATIN SMALL LETTER I WITH CARON + 0x0000, // + 0x012B, //0x2B45 0x012B # LATIN SMALL LETTER I WITH MACRON + 0x012F, //0x2B46 0x012F # LATIN SMALL LETTER I WITH OGONEK + 0x0129, //0x2B47 0x0129 # LATIN SMALL LETTER I WITH TILDE + 0x0135, //0x2B48 0x0135 # LATIN SMALL LETTER J WITH CIRCUMFLEX + 0x0137, //0x2B49 0x0137 # LATIN SMALL LETTER K WITH CEDILLA + 0x013A, //0x2B4A 0x013A # LATIN SMALL LETTER L WITH ACUTE + 0x013E, //0x2B4B 0x013E # LATIN SMALL LETTER L WITH CARON + 0x013C, //0x2B4C 0x013C # LATIN SMALL LETTER L WITH CEDILLA + 0x0144, //0x2B4D 0x0144 # LATIN SMALL LETTER N WITH ACUTE + 0x0148, //0x2B4E 0x0148 # LATIN SMALL LETTER N WITH CARON + 0x0146, //0x2B4F 0x0146 # LATIN SMALL LETTER N WITH CEDILLA + 0x00F1, //0x2B50 0x00F1 # LATIN SMALL LETTER N WITH TILDE + 0x00F3, //0x2B51 0x00F3 # LATIN SMALL LETTER O WITH ACUTE + 0x00F2, //0x2B52 0x00F2 # LATIN SMALL LETTER O WITH GRAVE + 0x00F6, //0x2B53 0x00F6 # LATIN SMALL LETTER O WITH DIAERESIS + 0x00F4, //0x2B54 0x00F4 # LATIN SMALL LETTER O WITH CIRCUMFLEX + 0x01D2, //0x2B55 0x01D2 # LATIN SMALL LETTER O WITH CARON + 0x0151, //0x2B56 0x0151 # LATIN SMALL LETTER O WITH DOUBLE ACUTE + 0x014D, //0x2B57 0x014D # LATIN SMALL LETTER O WITH MACRON + 0x00F5, //0x2B58 0x00F5 # LATIN SMALL LETTER O WITH TILDE + 0x0155, //0x2B59 0x0155 # LATIN SMALL LETTER R WITH ACUTE + 0x0159, //0x2B5A 0x0159 # LATIN SMALL LETTER R WITH CARON + 0x0157, //0x2B5B 0x0157 # LATIN SMALL LETTER R WITH CEDILLA + 0x015B, //0x2B5C 0x015B # LATIN SMALL LETTER S WITH ACUTE + 0x015D, //0x2B5D 0x015D # LATIN SMALL LETTER S WITH CIRCUMFLEX + 0x0161, //0x2B5E 0x0161 # LATIN SMALL LETTER S WITH CARON + 0x015F, //0x2B5F 0x015F # LATIN SMALL LETTER S WITH CEDILLA + 0x0165, //0x2B60 0x0165 # LATIN SMALL LETTER T WITH CARON + 0x0163, //0x2B61 0x0163 # LATIN SMALL LETTER T WITH CEDILLA + 0x00FA, //0x2B62 0x00FA # LATIN SMALL LETTER U WITH ACUTE + 0x00F9, //0x2B63 0x00F9 # LATIN SMALL LETTER U WITH GRAVE + 0x00FC, //0x2B64 0x00FC # LATIN SMALL LETTER U WITH DIAERESIS + 0x00FB, //0x2B65 0x00FB # LATIN SMALL LETTER U WITH CIRCUMFLEX + 0x016D, //0x2B66 0x016D # LATIN SMALL LETTER U WITH BREVE + 0x01D4, //0x2B67 0x01D4 # LATIN SMALL LETTER U WITH CARON + 0x0171, //0x2B68 0x0171 # LATIN SMALL LETTER U WITH DOUBLE ACUTE + 0x016B, //0x2B69 0x016B # LATIN SMALL LETTER U WITH MACRON + 0x0173, //0x2B6A 0x0173 # LATIN SMALL LETTER U WITH OGONEK + 0x016F, //0x2B6B 0x016F # LATIN SMALL LETTER U WITH RING ABOVE + 0x0169, //0x2B6C 0x0169 # LATIN SMALL LETTER U WITH TILDE + 0x01D8, //0x2B6D 0x01D8 # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE + 0x01DC, //0x2B6E 0x01DC # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE + 0x01DA, //0x2B6F 0x01DA # LATIN SMALL LETTER U WITH DIAERESIS AND CARON + 0x01D6, //0x2B70 0x01D6 # LATIN SMALL LETTER U WITH DIAERESIS AND MACRON + 0x0175, //0x2B71 0x0175 # LATIN SMALL LETTER W WITH CIRCUMFLEX + 0x00FD, //0x2B72 0x00FD # LATIN SMALL LETTER Y WITH ACUTE + 0x00FF, //0x2B73 0x00FF # LATIN SMALL LETTER Y WITH DIAERESIS + 0x0177, //0x2B74 0x0177 # LATIN SMALL LETTER Y WITH CIRCUMFLEX + 0x017A, //0x2B75 0x017A # LATIN SMALL LETTER Z WITH ACUTE + 0x017E, //0x2B76 0x017E # LATIN SMALL LETTER Z WITH CARON + 0x017C, //0x2B77 0x017C # LATIN SMALL LETTER Z WITH DOT ABOVE + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000 // + }, + //16区 + { + 0x4E02, //0x3021 0x4E02 # + 0x4E04, //0x3022 0x4E04 # + 0x4E05, //0x3023 0x4E05 # + 0x4E0C, //0x3024 0x4E0C # + 0x4E12, //0x3025 0x4E12 # + 0x4E1F, //0x3026 0x4E1F # + 0x4E23, //0x3027 0x4E23 # + 0x4E24, //0x3028 0x4E24 # + 0x4E28, //0x3029 0x4E28 # + 0x4E2B, //0x302A 0x4E2B # + 0x4E2E, //0x302B 0x4E2E # + 0x4E2F, //0x302C 0x4E2F # + 0x4E30, //0x302D 0x4E30 # + 0x4E35, //0x302E 0x4E35 # + 0x4E40, //0x302F 0x4E40 # + 0x4E41, //0x3030 0x4E41 # + 0x4E44, //0x3031 0x4E44 # + 0x4E47, //0x3032 0x4E47 # + 0x4E51, //0x3033 0x4E51 # + 0x4E5A, //0x3034 0x4E5A # + 0x4E5C, //0x3035 0x4E5C # + 0x4E63, //0x3036 0x4E63 # + 0x4E68, //0x3037 0x4E68 # + 0x4E69, //0x3038 0x4E69 # + 0x4E74, //0x3039 0x4E74 # + 0x4E75, //0x303A 0x4E75 # + 0x4E79, //0x303B 0x4E79 # + 0x4E7F, //0x303C 0x4E7F # + 0x4E8D, //0x303D 0x4E8D # + 0x4E96, //0x303E 0x4E96 # + 0x4E97, //0x303F 0x4E97 # + 0x4E9D, //0x3040 0x4E9D # + 0x4EAF, //0x3041 0x4EAF # + 0x4EB9, //0x3042 0x4EB9 # + 0x4EC3, //0x3043 0x4EC3 # + 0x4ED0, //0x3044 0x4ED0 # + 0x4EDA, //0x3045 0x4EDA # + 0x4EDB, //0x3046 0x4EDB # + 0x4EE0, //0x3047 0x4EE0 # + 0x4EE1, //0x3048 0x4EE1 # + 0x4EE2, //0x3049 0x4EE2 # + 0x4EE8, //0x304A 0x4EE8 # + 0x4EEF, //0x304B 0x4EEF # + 0x4EF1, //0x304C 0x4EF1 # + 0x4EF3, //0x304D 0x4EF3 # + 0x4EF5, //0x304E 0x4EF5 # + 0x4EFD, //0x304F 0x4EFD # + 0x4EFE, //0x3050 0x4EFE # + 0x4EFF, //0x3051 0x4EFF # + 0x4F00, //0x3052 0x4F00 # + 0x4F02, //0x3053 0x4F02 # + 0x4F03, //0x3054 0x4F03 # + 0x4F08, //0x3055 0x4F08 # + 0x4F0B, //0x3056 0x4F0B # + 0x4F0C, //0x3057 0x4F0C # + 0x4F12, //0x3058 0x4F12 # + 0x4F15, //0x3059 0x4F15 # + 0x4F16, //0x305A 0x4F16 # + 0x4F17, //0x305B 0x4F17 # + 0x4F19, //0x305C 0x4F19 # + 0x4F2E, //0x305D 0x4F2E # + 0x4F31, //0x305E 0x4F31 # + 0x4F60, //0x305F 0x4F60 # + 0x4F33, //0x3060 0x4F33 # + 0x4F35, //0x3061 0x4F35 # + 0x4F37, //0x3062 0x4F37 # + 0x4F39, //0x3063 0x4F39 # + 0x4F3B, //0x3064 0x4F3B # + 0x4F3E, //0x3065 0x4F3E # + 0x4F40, //0x3066 0x4F40 # + 0x4F42, //0x3067 0x4F42 # + 0x4F48, //0x3068 0x4F48 # + 0x4F49, //0x3069 0x4F49 # + 0x4F4B, //0x306A 0x4F4B # + 0x4F4C, //0x306B 0x4F4C # + 0x4F52, //0x306C 0x4F52 # + 0x4F54, //0x306D 0x4F54 # + 0x4F56, //0x306E 0x4F56 # + 0x4F58, //0x306F 0x4F58 # + 0x4F5F, //0x3070 0x4F5F # + 0x4F63, //0x3071 0x4F63 # + 0x4F6A, //0x3072 0x4F6A # + 0x4F6C, //0x3073 0x4F6C # + 0x4F6E, //0x3074 0x4F6E # + 0x4F71, //0x3075 0x4F71 # + 0x4F77, //0x3076 0x4F77 # + 0x4F78, //0x3077 0x4F78 # + 0x4F79, //0x3078 0x4F79 # + 0x4F7A, //0x3079 0x4F7A # + 0x4F7D, //0x307A 0x4F7D # + 0x4F7E, //0x307B 0x4F7E # + 0x4F81, //0x307C 0x4F81 # + 0x4F82, //0x307D 0x4F82 # + 0x4F84 //0x307E 0x4F84 # + }, + //17区 + { + 0x4F85, //0x3121 0x4F85 # + 0x4F89, //0x3122 0x4F89 # + 0x4F8A, //0x3123 0x4F8A # + 0x4F8C, //0x3124 0x4F8C # + 0x4F8E, //0x3125 0x4F8E # + 0x4F90, //0x3126 0x4F90 # + 0x4F92, //0x3127 0x4F92 # + 0x4F93, //0x3128 0x4F93 # + 0x4F94, //0x3129 0x4F94 # + 0x4F97, //0x312A 0x4F97 # + 0x4F99, //0x312B 0x4F99 # + 0x4F9A, //0x312C 0x4F9A # + 0x4F9E, //0x312D 0x4F9E # + 0x4F9F, //0x312E 0x4F9F # + 0x4FB2, //0x312F 0x4FB2 # + 0x4FB7, //0x3130 0x4FB7 # + 0x4FB9, //0x3131 0x4FB9 # + 0x4FBB, //0x3132 0x4FBB # + 0x4FBC, //0x3133 0x4FBC # + 0x4FBD, //0x3134 0x4FBD # + 0x4FBE, //0x3135 0x4FBE # + 0x4FC0, //0x3136 0x4FC0 # + 0x4FC1, //0x3137 0x4FC1 # + 0x4FC5, //0x3138 0x4FC5 # + 0x4FC6, //0x3139 0x4FC6 # + 0x4FC8, //0x313A 0x4FC8 # + 0x4FC9, //0x313B 0x4FC9 # + 0x4FCB, //0x313C 0x4FCB # + 0x4FCC, //0x313D 0x4FCC # + 0x4FCD, //0x313E 0x4FCD # + 0x4FCF, //0x313F 0x4FCF # + 0x4FD2, //0x3140 0x4FD2 # + 0x4FDC, //0x3141 0x4FDC # + 0x4FE0, //0x3142 0x4FE0 # + 0x4FE2, //0x3143 0x4FE2 # + 0x4FF0, //0x3144 0x4FF0 # + 0x4FF2, //0x3145 0x4FF2 # + 0x4FFC, //0x3146 0x4FFC # + 0x4FFD, //0x3147 0x4FFD # + 0x4FFF, //0x3148 0x4FFF # + 0x5000, //0x3149 0x5000 # + 0x5001, //0x314A 0x5001 # + 0x5004, //0x314B 0x5004 # + 0x5007, //0x314C 0x5007 # + 0x500A, //0x314D 0x500A # + 0x500C, //0x314E 0x500C # + 0x500E, //0x314F 0x500E # + 0x5010, //0x3150 0x5010 # + 0x5013, //0x3151 0x5013 # + 0x5017, //0x3152 0x5017 # + 0x5018, //0x3153 0x5018 # + 0x501B, //0x3154 0x501B # + 0x501C, //0x3155 0x501C # + 0x501D, //0x3156 0x501D # + 0x501E, //0x3157 0x501E # + 0x5022, //0x3158 0x5022 # + 0x5027, //0x3159 0x5027 # + 0x502E, //0x315A 0x502E # + 0x5030, //0x315B 0x5030 # + 0x5032, //0x315C 0x5032 # + 0x5033, //0x315D 0x5033 # + 0x5035, //0x315E 0x5035 # + 0x5040, //0x315F 0x5040 # + 0x5041, //0x3160 0x5041 # + 0x5042, //0x3161 0x5042 # + 0x5045, //0x3162 0x5045 # + 0x5046, //0x3163 0x5046 # + 0x504A, //0x3164 0x504A # + 0x504C, //0x3165 0x504C # + 0x504E, //0x3166 0x504E # + 0x5051, //0x3167 0x5051 # + 0x5052, //0x3168 0x5052 # + 0x5053, //0x3169 0x5053 # + 0x5057, //0x316A 0x5057 # + 0x5059, //0x316B 0x5059 # + 0x505F, //0x316C 0x505F # + 0x5060, //0x316D 0x5060 # + 0x5062, //0x316E 0x5062 # + 0x5063, //0x316F 0x5063 # + 0x5066, //0x3170 0x5066 # + 0x5067, //0x3171 0x5067 # + 0x506A, //0x3172 0x506A # + 0x506D, //0x3173 0x506D # + 0x5070, //0x3174 0x5070 # + 0x5071, //0x3175 0x5071 # + 0x503B, //0x3176 0x503B # + 0x5081, //0x3177 0x5081 # + 0x5083, //0x3178 0x5083 # + 0x5084, //0x3179 0x5084 # + 0x5086, //0x317A 0x5086 # + 0x508A, //0x317B 0x508A # + 0x508E, //0x317C 0x508E # + 0x508F, //0x317D 0x508F # + 0x5090 //0x317E 0x5090 # + }, + //18区 + { + 0x5092, //0x3221 0x5092 # + 0x5093, //0x3222 0x5093 # + 0x5094, //0x3223 0x5094 # + 0x5096, //0x3224 0x5096 # + 0x509B, //0x3225 0x509B # + 0x509C, //0x3226 0x509C # + 0x509E, //0x3227 0x509E # + 0x509F, //0x3228 0x509F # + 0x50A0, //0x3229 0x50A0 # + 0x50A1, //0x322A 0x50A1 # + 0x50A2, //0x322B 0x50A2 # + 0x50AA, //0x322C 0x50AA # + 0x50AF, //0x322D 0x50AF # + 0x50B0, //0x322E 0x50B0 # + 0x50B9, //0x322F 0x50B9 # + 0x50BA, //0x3230 0x50BA # + 0x50BD, //0x3231 0x50BD # + 0x50C0, //0x3232 0x50C0 # + 0x50C3, //0x3233 0x50C3 # + 0x50C4, //0x3234 0x50C4 # + 0x50C7, //0x3235 0x50C7 # + 0x50CC, //0x3236 0x50CC # + 0x50CE, //0x3237 0x50CE # + 0x50D0, //0x3238 0x50D0 # + 0x50D3, //0x3239 0x50D3 # + 0x50D4, //0x323A 0x50D4 # + 0x50D8, //0x323B 0x50D8 # + 0x50DC, //0x323C 0x50DC # + 0x50DD, //0x323D 0x50DD # + 0x50DF, //0x323E 0x50DF # + 0x50E2, //0x323F 0x50E2 # + 0x50E4, //0x3240 0x50E4 # + 0x50E6, //0x3241 0x50E6 # + 0x50E8, //0x3242 0x50E8 # + 0x50E9, //0x3243 0x50E9 # + 0x50EF, //0x3244 0x50EF # + 0x50F1, //0x3245 0x50F1 # + 0x50F6, //0x3246 0x50F6 # + 0x50FA, //0x3247 0x50FA # + 0x50FE, //0x3248 0x50FE # + 0x5103, //0x3249 0x5103 # + 0x5106, //0x324A 0x5106 # + 0x5107, //0x324B 0x5107 # + 0x5108, //0x324C 0x5108 # + 0x510B, //0x324D 0x510B # + 0x510C, //0x324E 0x510C # + 0x510D, //0x324F 0x510D # + 0x510E, //0x3250 0x510E # + 0x50F2, //0x3251 0x50F2 # + 0x5110, //0x3252 0x5110 # + 0x5117, //0x3253 0x5117 # + 0x5119, //0x3254 0x5119 # + 0x511B, //0x3255 0x511B # + 0x511C, //0x3256 0x511C # + 0x511D, //0x3257 0x511D # + 0x511E, //0x3258 0x511E # + 0x5123, //0x3259 0x5123 # + 0x5127, //0x325A 0x5127 # + 0x5128, //0x325B 0x5128 # + 0x512C, //0x325C 0x512C # + 0x512D, //0x325D 0x512D # + 0x512F, //0x325E 0x512F # + 0x5131, //0x325F 0x5131 # + 0x5133, //0x3260 0x5133 # + 0x5134, //0x3261 0x5134 # + 0x5135, //0x3262 0x5135 # + 0x5138, //0x3263 0x5138 # + 0x5139, //0x3264 0x5139 # + 0x5142, //0x3265 0x5142 # + 0x514A, //0x3266 0x514A # + 0x514F, //0x3267 0x514F # + 0x5153, //0x3268 0x5153 # + 0x5155, //0x3269 0x5155 # + 0x5157, //0x326A 0x5157 # + 0x5158, //0x326B 0x5158 # + 0x515F, //0x326C 0x515F # + 0x5164, //0x326D 0x5164 # + 0x5166, //0x326E 0x5166 # + 0x517E, //0x326F 0x517E # + 0x5183, //0x3270 0x5183 # + 0x5184, //0x3271 0x5184 # + 0x518B, //0x3272 0x518B # + 0x518E, //0x3273 0x518E # + 0x5198, //0x3274 0x5198 # + 0x519D, //0x3275 0x519D # + 0x51A1, //0x3276 0x51A1 # + 0x51A3, //0x3277 0x51A3 # + 0x51AD, //0x3278 0x51AD # + 0x51B8, //0x3279 0x51B8 # + 0x51BA, //0x327A 0x51BA # + 0x51BC, //0x327B 0x51BC # + 0x51BE, //0x327C 0x51BE # + 0x51BF, //0x327D 0x51BF # + 0x51C2 //0x327E 0x51C2 # + }, + //19区 + { + 0x51C8, //0x3321 0x51C8 # + 0x51CF, //0x3322 0x51CF # + 0x51D1, //0x3323 0x51D1 # + 0x51D2, //0x3324 0x51D2 # + 0x51D3, //0x3325 0x51D3 # + 0x51D5, //0x3326 0x51D5 # + 0x51D8, //0x3327 0x51D8 # + 0x51DE, //0x3328 0x51DE # + 0x51E2, //0x3329 0x51E2 # + 0x51E5, //0x332A 0x51E5 # + 0x51EE, //0x332B 0x51EE # + 0x51F2, //0x332C 0x51F2 # + 0x51F3, //0x332D 0x51F3 # + 0x51F4, //0x332E 0x51F4 # + 0x51F7, //0x332F 0x51F7 # + 0x5201, //0x3330 0x5201 # + 0x5202, //0x3331 0x5202 # + 0x5205, //0x3332 0x5205 # + 0x5212, //0x3333 0x5212 # + 0x5213, //0x3334 0x5213 # + 0x5215, //0x3335 0x5215 # + 0x5216, //0x3336 0x5216 # + 0x5218, //0x3337 0x5218 # + 0x5222, //0x3338 0x5222 # + 0x5228, //0x3339 0x5228 # + 0x5231, //0x333A 0x5231 # + 0x5232, //0x333B 0x5232 # + 0x5235, //0x333C 0x5235 # + 0x523C, //0x333D 0x523C # + 0x5245, //0x333E 0x5245 # + 0x5249, //0x333F 0x5249 # + 0x5255, //0x3340 0x5255 # + 0x5257, //0x3341 0x5257 # + 0x5258, //0x3342 0x5258 # + 0x525A, //0x3343 0x525A # + 0x525C, //0x3344 0x525C # + 0x525F, //0x3345 0x525F # + 0x5260, //0x3346 0x5260 # + 0x5261, //0x3347 0x5261 # + 0x5266, //0x3348 0x5266 # + 0x526E, //0x3349 0x526E # + 0x5277, //0x334A 0x5277 # + 0x5278, //0x334B 0x5278 # + 0x5279, //0x334C 0x5279 # + 0x5280, //0x334D 0x5280 # + 0x5282, //0x334E 0x5282 # + 0x5285, //0x334F 0x5285 # + 0x528A, //0x3350 0x528A # + 0x528C, //0x3351 0x528C # + 0x5293, //0x3352 0x5293 # + 0x5295, //0x3353 0x5295 # + 0x5296, //0x3354 0x5296 # + 0x5297, //0x3355 0x5297 # + 0x5298, //0x3356 0x5298 # + 0x529A, //0x3357 0x529A # + 0x529C, //0x3358 0x529C # + 0x52A4, //0x3359 0x52A4 # + 0x52A5, //0x335A 0x52A5 # + 0x52A6, //0x335B 0x52A6 # + 0x52A7, //0x335C 0x52A7 # + 0x52AF, //0x335D 0x52AF # + 0x52B0, //0x335E 0x52B0 # + 0x52B6, //0x335F 0x52B6 # + 0x52B7, //0x3360 0x52B7 # + 0x52B8, //0x3361 0x52B8 # + 0x52BA, //0x3362 0x52BA # + 0x52BB, //0x3363 0x52BB # + 0x52BD, //0x3364 0x52BD # + 0x52C0, //0x3365 0x52C0 # + 0x52C4, //0x3366 0x52C4 # + 0x52C6, //0x3367 0x52C6 # + 0x52C8, //0x3368 0x52C8 # + 0x52CC, //0x3369 0x52CC # + 0x52CF, //0x336A 0x52CF # + 0x52D1, //0x336B 0x52D1 # + 0x52D4, //0x336C 0x52D4 # + 0x52D6, //0x336D 0x52D6 # + 0x52DB, //0x336E 0x52DB # + 0x52DC, //0x336F 0x52DC # + 0x52E1, //0x3370 0x52E1 # + 0x52E5, //0x3371 0x52E5 # + 0x52E8, //0x3372 0x52E8 # + 0x52E9, //0x3373 0x52E9 # + 0x52EA, //0x3374 0x52EA # + 0x52EC, //0x3375 0x52EC # + 0x52F0, //0x3376 0x52F0 # + 0x52F1, //0x3377 0x52F1 # + 0x52F4, //0x3378 0x52F4 # + 0x52F6, //0x3379 0x52F6 # + 0x52F7, //0x337A 0x52F7 # + 0x5300, //0x337B 0x5300 # + 0x5303, //0x337C 0x5303 # + 0x530A, //0x337D 0x530A # + 0x530B //0x337E 0x530B # + }, + //20区 + { + 0x530C, //0x3421 0x530C # + 0x5311, //0x3422 0x5311 # + 0x5313, //0x3423 0x5313 # + 0x5318, //0x3424 0x5318 # + 0x531B, //0x3425 0x531B # + 0x531C, //0x3426 0x531C # + 0x531E, //0x3427 0x531E # + 0x531F, //0x3428 0x531F # + 0x5325, //0x3429 0x5325 # + 0x5327, //0x342A 0x5327 # + 0x5328, //0x342B 0x5328 # + 0x5329, //0x342C 0x5329 # + 0x532B, //0x342D 0x532B # + 0x532C, //0x342E 0x532C # + 0x532D, //0x342F 0x532D # + 0x5330, //0x3430 0x5330 # + 0x5332, //0x3431 0x5332 # + 0x5335, //0x3432 0x5335 # + 0x533C, //0x3433 0x533C # + 0x533D, //0x3434 0x533D # + 0x533E, //0x3435 0x533E # + 0x5342, //0x3436 0x5342 # + 0x534C, //0x3437 0x534C # + 0x534B, //0x3438 0x534B # + 0x5359, //0x3439 0x5359 # + 0x535B, //0x343A 0x535B # + 0x5361, //0x343B 0x5361 # + 0x5363, //0x343C 0x5363 # + 0x5365, //0x343D 0x5365 # + 0x536C, //0x343E 0x536C # + 0x536D, //0x343F 0x536D # + 0x5372, //0x3440 0x5372 # + 0x5379, //0x3441 0x5379 # + 0x537E, //0x3442 0x537E # + 0x5383, //0x3443 0x5383 # + 0x5387, //0x3444 0x5387 # + 0x5388, //0x3445 0x5388 # + 0x538E, //0x3446 0x538E # + 0x5393, //0x3447 0x5393 # + 0x5394, //0x3448 0x5394 # + 0x5399, //0x3449 0x5399 # + 0x539D, //0x344A 0x539D # + 0x53A1, //0x344B 0x53A1 # + 0x53A4, //0x344C 0x53A4 # + 0x53AA, //0x344D 0x53AA # + 0x53AB, //0x344E 0x53AB # + 0x53AF, //0x344F 0x53AF # + 0x53B2, //0x3450 0x53B2 # + 0x53B4, //0x3451 0x53B4 # + 0x53B5, //0x3452 0x53B5 # + 0x53B7, //0x3453 0x53B7 # + 0x53B8, //0x3454 0x53B8 # + 0x53BA, //0x3455 0x53BA # + 0x53BD, //0x3456 0x53BD # + 0x53C0, //0x3457 0x53C0 # + 0x53C5, //0x3458 0x53C5 # + 0x53CF, //0x3459 0x53CF # + 0x53D2, //0x345A 0x53D2 # + 0x53D3, //0x345B 0x53D3 # + 0x53D5, //0x345C 0x53D5 # + 0x53DA, //0x345D 0x53DA # + 0x53DD, //0x345E 0x53DD # + 0x53DE, //0x345F 0x53DE # + 0x53E0, //0x3460 0x53E0 # + 0x53E6, //0x3461 0x53E6 # + 0x53E7, //0x3462 0x53E7 # + 0x53F5, //0x3463 0x53F5 # + 0x5402, //0x3464 0x5402 # + 0x5413, //0x3465 0x5413 # + 0x541A, //0x3466 0x541A # + 0x5421, //0x3467 0x5421 # + 0x5427, //0x3468 0x5427 # + 0x5428, //0x3469 0x5428 # + 0x542A, //0x346A 0x542A # + 0x542F, //0x346B 0x542F # + 0x5431, //0x346C 0x5431 # + 0x5434, //0x346D 0x5434 # + 0x5435, //0x346E 0x5435 # + 0x5443, //0x346F 0x5443 # + 0x5444, //0x3470 0x5444 # + 0x5447, //0x3471 0x5447 # + 0x544D, //0x3472 0x544D # + 0x544F, //0x3473 0x544F # + 0x545E, //0x3474 0x545E # + 0x5462, //0x3475 0x5462 # + 0x5464, //0x3476 0x5464 # + 0x5466, //0x3477 0x5466 # + 0x5467, //0x3478 0x5467 # + 0x5469, //0x3479 0x5469 # + 0x546B, //0x347A 0x546B # + 0x546D, //0x347B 0x546D # + 0x546E, //0x347C 0x546E # + 0x5474, //0x347D 0x5474 # + 0x547F //0x347E 0x547F # + }, + //21区 + { + 0x5481, //0x3521 0x5481 # + 0x5483, //0x3522 0x5483 # + 0x5485, //0x3523 0x5485 # + 0x5488, //0x3524 0x5488 # + 0x5489, //0x3525 0x5489 # + 0x548D, //0x3526 0x548D # + 0x5491, //0x3527 0x5491 # + 0x5495, //0x3528 0x5495 # + 0x5496, //0x3529 0x5496 # + 0x549C, //0x352A 0x549C # + 0x549F, //0x352B 0x549F # + 0x54A1, //0x352C 0x54A1 # + 0x54A6, //0x352D 0x54A6 # + 0x54A7, //0x352E 0x54A7 # + 0x54A9, //0x352F 0x54A9 # + 0x54AA, //0x3530 0x54AA # + 0x54AD, //0x3531 0x54AD # + 0x54AE, //0x3532 0x54AE # + 0x54B1, //0x3533 0x54B1 # + 0x54B7, //0x3534 0x54B7 # + 0x54B9, //0x3535 0x54B9 # + 0x54BA, //0x3536 0x54BA # + 0x54BB, //0x3537 0x54BB # + 0x54BF, //0x3538 0x54BF # + 0x54C6, //0x3539 0x54C6 # + 0x54CA, //0x353A 0x54CA # + 0x54CD, //0x353B 0x54CD # + 0x54CE, //0x353C 0x54CE # + 0x54E0, //0x353D 0x54E0 # + 0x54EA, //0x353E 0x54EA # + 0x54EC, //0x353F 0x54EC # + 0x54EF, //0x3540 0x54EF # + 0x54F6, //0x3541 0x54F6 # + 0x54FC, //0x3542 0x54FC # + 0x54FE, //0x3543 0x54FE # + 0x54FF, //0x3544 0x54FF # + 0x5500, //0x3545 0x5500 # + 0x5501, //0x3546 0x5501 # + 0x5505, //0x3547 0x5505 # + 0x5508, //0x3548 0x5508 # + 0x5509, //0x3549 0x5509 # + 0x550C, //0x354A 0x550C # + 0x550D, //0x354B 0x550D # + 0x550E, //0x354C 0x550E # + 0x5515, //0x354D 0x5515 # + 0x552A, //0x354E 0x552A # + 0x552B, //0x354F 0x552B # + 0x5532, //0x3550 0x5532 # + 0x5535, //0x3551 0x5535 # + 0x5536, //0x3552 0x5536 # + 0x553B, //0x3553 0x553B # + 0x553C, //0x3554 0x553C # + 0x553D, //0x3555 0x553D # + 0x5541, //0x3556 0x5541 # + 0x5547, //0x3557 0x5547 # + 0x5549, //0x3558 0x5549 # + 0x554A, //0x3559 0x554A # + 0x554D, //0x355A 0x554D # + 0x5550, //0x355B 0x5550 # + 0x5551, //0x355C 0x5551 # + 0x5558, //0x355D 0x5558 # + 0x555A, //0x355E 0x555A # + 0x555B, //0x355F 0x555B # + 0x555E, //0x3560 0x555E # + 0x5560, //0x3561 0x5560 # + 0x5561, //0x3562 0x5561 # + 0x5564, //0x3563 0x5564 # + 0x5566, //0x3564 0x5566 # + 0x557F, //0x3565 0x557F # + 0x5581, //0x3566 0x5581 # + 0x5582, //0x3567 0x5582 # + 0x5586, //0x3568 0x5586 # + 0x5588, //0x3569 0x5588 # + 0x558E, //0x356A 0x558E # + 0x558F, //0x356B 0x558F # + 0x5591, //0x356C 0x5591 # + 0x5592, //0x356D 0x5592 # + 0x5593, //0x356E 0x5593 # + 0x5594, //0x356F 0x5594 # + 0x5597, //0x3570 0x5597 # + 0x55A3, //0x3571 0x55A3 # + 0x55A4, //0x3572 0x55A4 # + 0x55AD, //0x3573 0x55AD # + 0x55B2, //0x3574 0x55B2 # + 0x55BF, //0x3575 0x55BF # + 0x55C1, //0x3576 0x55C1 # + 0x55C3, //0x3577 0x55C3 # + 0x55C6, //0x3578 0x55C6 # + 0x55C9, //0x3579 0x55C9 # + 0x55CB, //0x357A 0x55CB # + 0x55CC, //0x357B 0x55CC # + 0x55CE, //0x357C 0x55CE # + 0x55D1, //0x357D 0x55D1 # + 0x55D2 //0x357E 0x55D2 # + }, + //22区 + { + 0x55D3, //0x3621 0x55D3 # + 0x55D7, //0x3622 0x55D7 # + 0x55D8, //0x3623 0x55D8 # + 0x55DB, //0x3624 0x55DB # + 0x55DE, //0x3625 0x55DE # + 0x55E2, //0x3626 0x55E2 # + 0x55E9, //0x3627 0x55E9 # + 0x55F6, //0x3628 0x55F6 # + 0x55FF, //0x3629 0x55FF # + 0x5605, //0x362A 0x5605 # + 0x5608, //0x362B 0x5608 # + 0x560A, //0x362C 0x560A # + 0x560D, //0x362D 0x560D # + 0x560E, //0x362E 0x560E # + 0x560F, //0x362F 0x560F # + 0x5610, //0x3630 0x5610 # + 0x5611, //0x3631 0x5611 # + 0x5612, //0x3632 0x5612 # + 0x5619, //0x3633 0x5619 # + 0x562C, //0x3634 0x562C # + 0x5630, //0x3635 0x5630 # + 0x5633, //0x3636 0x5633 # + 0x5635, //0x3637 0x5635 # + 0x5637, //0x3638 0x5637 # + 0x5639, //0x3639 0x5639 # + 0x563B, //0x363A 0x563B # + 0x563C, //0x363B 0x563C # + 0x563D, //0x363C 0x563D # + 0x563F, //0x363D 0x563F # + 0x5640, //0x363E 0x5640 # + 0x5641, //0x363F 0x5641 # + 0x5643, //0x3640 0x5643 # + 0x5644, //0x3641 0x5644 # + 0x5646, //0x3642 0x5646 # + 0x5649, //0x3643 0x5649 # + 0x564B, //0x3644 0x564B # + 0x564D, //0x3645 0x564D # + 0x564F, //0x3646 0x564F # + 0x5654, //0x3647 0x5654 # + 0x565E, //0x3648 0x565E # + 0x5660, //0x3649 0x5660 # + 0x5661, //0x364A 0x5661 # + 0x5662, //0x364B 0x5662 # + 0x5663, //0x364C 0x5663 # + 0x5666, //0x364D 0x5666 # + 0x5669, //0x364E 0x5669 # + 0x566D, //0x364F 0x566D # + 0x566F, //0x3650 0x566F # + 0x5671, //0x3651 0x5671 # + 0x5672, //0x3652 0x5672 # + 0x5675, //0x3653 0x5675 # + 0x5684, //0x3654 0x5684 # + 0x5685, //0x3655 0x5685 # + 0x5688, //0x3656 0x5688 # + 0x568B, //0x3657 0x568B # + 0x568C, //0x3658 0x568C # + 0x5695, //0x3659 0x5695 # + 0x5699, //0x365A 0x5699 # + 0x569A, //0x365B 0x569A # + 0x569D, //0x365C 0x569D # + 0x569E, //0x365D 0x569E # + 0x569F, //0x365E 0x569F # + 0x56A6, //0x365F 0x56A6 # + 0x56A7, //0x3660 0x56A7 # + 0x56A8, //0x3661 0x56A8 # + 0x56A9, //0x3662 0x56A9 # + 0x56AB, //0x3663 0x56AB # + 0x56AC, //0x3664 0x56AC # + 0x56AD, //0x3665 0x56AD # + 0x56B1, //0x3666 0x56B1 # + 0x56B3, //0x3667 0x56B3 # + 0x56B7, //0x3668 0x56B7 # + 0x56BE, //0x3669 0x56BE # + 0x56C5, //0x366A 0x56C5 # + 0x56C9, //0x366B 0x56C9 # + 0x56CA, //0x366C 0x56CA # + 0x56CB, //0x366D 0x56CB # + 0x56CF, //0x366E 0x56CF # + 0x56D0, //0x366F 0x56D0 # + 0x56CC, //0x3670 0x56CC # + 0x56CD, //0x3671 0x56CD # + 0x56D9, //0x3672 0x56D9 # + 0x56DC, //0x3673 0x56DC # + 0x56DD, //0x3674 0x56DD # + 0x56DF, //0x3675 0x56DF # + 0x56E1, //0x3676 0x56E1 # + 0x56E4, //0x3677 0x56E4 # + 0x56E5, //0x3678 0x56E5 # + 0x56E6, //0x3679 0x56E6 # + 0x56E7, //0x367A 0x56E7 # + 0x56E8, //0x367B 0x56E8 # + 0x56F1, //0x367C 0x56F1 # + 0x56EB, //0x367D 0x56EB # + 0x56ED //0x367E 0x56ED # + }, + //23区 + { + 0x56F6, //0x3721 0x56F6 # + 0x56F7, //0x3722 0x56F7 # + 0x5701, //0x3723 0x5701 # + 0x5702, //0x3724 0x5702 # + 0x5707, //0x3725 0x5707 # + 0x570A, //0x3726 0x570A # + 0x570C, //0x3727 0x570C # + 0x5711, //0x3728 0x5711 # + 0x5715, //0x3729 0x5715 # + 0x571A, //0x372A 0x571A # + 0x571B, //0x372B 0x571B # + 0x571D, //0x372C 0x571D # + 0x5720, //0x372D 0x5720 # + 0x5722, //0x372E 0x5722 # + 0x5723, //0x372F 0x5723 # + 0x5724, //0x3730 0x5724 # + 0x5725, //0x3731 0x5725 # + 0x5729, //0x3732 0x5729 # + 0x572A, //0x3733 0x572A # + 0x572C, //0x3734 0x572C # + 0x572E, //0x3735 0x572E # + 0x572F, //0x3736 0x572F # + 0x5733, //0x3737 0x5733 # + 0x5734, //0x3738 0x5734 # + 0x573D, //0x3739 0x573D # + 0x573E, //0x373A 0x573E # + 0x573F, //0x373B 0x573F # + 0x5745, //0x373C 0x5745 # + 0x5746, //0x373D 0x5746 # + 0x574C, //0x373E 0x574C # + 0x574D, //0x373F 0x574D # + 0x5752, //0x3740 0x5752 # + 0x5762, //0x3741 0x5762 # + 0x5765, //0x3742 0x5765 # + 0x5767, //0x3743 0x5767 # + 0x5768, //0x3744 0x5768 # + 0x576B, //0x3745 0x576B # + 0x576D, //0x3746 0x576D # + 0x576E, //0x3747 0x576E # + 0x576F, //0x3748 0x576F # + 0x5770, //0x3749 0x5770 # + 0x5771, //0x374A 0x5771 # + 0x5773, //0x374B 0x5773 # + 0x5774, //0x374C 0x5774 # + 0x5775, //0x374D 0x5775 # + 0x5777, //0x374E 0x5777 # + 0x5779, //0x374F 0x5779 # + 0x577A, //0x3750 0x577A # + 0x577B, //0x3751 0x577B # + 0x577C, //0x3752 0x577C # + 0x577E, //0x3753 0x577E # + 0x5781, //0x3754 0x5781 # + 0x5783, //0x3755 0x5783 # + 0x578C, //0x3756 0x578C # + 0x5794, //0x3757 0x5794 # + 0x5797, //0x3758 0x5797 # + 0x5799, //0x3759 0x5799 # + 0x579A, //0x375A 0x579A # + 0x579C, //0x375B 0x579C # + 0x579D, //0x375C 0x579D # + 0x579E, //0x375D 0x579E # + 0x579F, //0x375E 0x579F # + 0x57A1, //0x375F 0x57A1 # + 0x5795, //0x3760 0x5795 # + 0x57A7, //0x3761 0x57A7 # + 0x57A8, //0x3762 0x57A8 # + 0x57A9, //0x3763 0x57A9 # + 0x57AC, //0x3764 0x57AC # + 0x57B8, //0x3765 0x57B8 # + 0x57BD, //0x3766 0x57BD # + 0x57C7, //0x3767 0x57C7 # + 0x57C8, //0x3768 0x57C8 # + 0x57CC, //0x3769 0x57CC # + 0x57CF, //0x376A 0x57CF # + 0x57D5, //0x376B 0x57D5 # + 0x57DD, //0x376C 0x57DD # + 0x57DE, //0x376D 0x57DE # + 0x57E4, //0x376E 0x57E4 # + 0x57E6, //0x376F 0x57E6 # + 0x57E7, //0x3770 0x57E7 # + 0x57E9, //0x3771 0x57E9 # + 0x57ED, //0x3772 0x57ED # + 0x57F0, //0x3773 0x57F0 # + 0x57F5, //0x3774 0x57F5 # + 0x57F6, //0x3775 0x57F6 # + 0x57F8, //0x3776 0x57F8 # + 0x57FD, //0x3777 0x57FD # + 0x57FE, //0x3778 0x57FE # + 0x57FF, //0x3779 0x57FF # + 0x5803, //0x377A 0x5803 # + 0x5804, //0x377B 0x5804 # + 0x5808, //0x377C 0x5808 # + 0x5809, //0x377D 0x5809 # + 0x57E1 //0x377E 0x57E1 # + }, + //24区 + { + 0x580C, //0x3821 0x580C # + 0x580D, //0x3822 0x580D # + 0x581B, //0x3823 0x581B # + 0x581E, //0x3824 0x581E # + 0x581F, //0x3825 0x581F # + 0x5820, //0x3826 0x5820 # + 0x5826, //0x3827 0x5826 # + 0x5827, //0x3828 0x5827 # + 0x582D, //0x3829 0x582D # + 0x5832, //0x382A 0x5832 # + 0x5839, //0x382B 0x5839 # + 0x583F, //0x382C 0x583F # + 0x5849, //0x382D 0x5849 # + 0x584C, //0x382E 0x584C # + 0x584D, //0x382F 0x584D # + 0x584F, //0x3830 0x584F # + 0x5850, //0x3831 0x5850 # + 0x5855, //0x3832 0x5855 # + 0x585F, //0x3833 0x585F # + 0x5861, //0x3834 0x5861 # + 0x5864, //0x3835 0x5864 # + 0x5867, //0x3836 0x5867 # + 0x5868, //0x3837 0x5868 # + 0x5878, //0x3838 0x5878 # + 0x587C, //0x3839 0x587C # + 0x587F, //0x383A 0x587F # + 0x5880, //0x383B 0x5880 # + 0x5881, //0x383C 0x5881 # + 0x5887, //0x383D 0x5887 # + 0x5888, //0x383E 0x5888 # + 0x5889, //0x383F 0x5889 # + 0x588A, //0x3840 0x588A # + 0x588C, //0x3841 0x588C # + 0x588D, //0x3842 0x588D # + 0x588F, //0x3843 0x588F # + 0x5890, //0x3844 0x5890 # + 0x5894, //0x3845 0x5894 # + 0x5896, //0x3846 0x5896 # + 0x589D, //0x3847 0x589D # + 0x58A0, //0x3848 0x58A0 # + 0x58A1, //0x3849 0x58A1 # + 0x58A2, //0x384A 0x58A2 # + 0x58A6, //0x384B 0x58A6 # + 0x58A9, //0x384C 0x58A9 # + 0x58B1, //0x384D 0x58B1 # + 0x58B2, //0x384E 0x58B2 # + 0x58C4, //0x384F 0x58C4 # + 0x58BC, //0x3850 0x58BC # + 0x58C2, //0x3851 0x58C2 # + 0x58C8, //0x3852 0x58C8 # + 0x58CD, //0x3853 0x58CD # + 0x58CE, //0x3854 0x58CE # + 0x58D0, //0x3855 0x58D0 # + 0x58D2, //0x3856 0x58D2 # + 0x58D4, //0x3857 0x58D4 # + 0x58D6, //0x3858 0x58D6 # + 0x58DA, //0x3859 0x58DA # + 0x58DD, //0x385A 0x58DD # + 0x58E1, //0x385B 0x58E1 # + 0x58E2, //0x385C 0x58E2 # + 0x58E9, //0x385D 0x58E9 # + 0x58F3, //0x385E 0x58F3 # + 0x5905, //0x385F 0x5905 # + 0x5906, //0x3860 0x5906 # + 0x590B, //0x3861 0x590B # + 0x590C, //0x3862 0x590C # + 0x5912, //0x3863 0x5912 # + 0x5913, //0x3864 0x5913 # + 0x5914, //0x3865 0x5914 # + 0x8641, //0x3866 0x8641 # + 0x591D, //0x3867 0x591D # + 0x5921, //0x3868 0x5921 # + 0x5923, //0x3869 0x5923 # + 0x5924, //0x386A 0x5924 # + 0x5928, //0x386B 0x5928 # + 0x592F, //0x386C 0x592F # + 0x5930, //0x386D 0x5930 # + 0x5933, //0x386E 0x5933 # + 0x5935, //0x386F 0x5935 # + 0x5936, //0x3870 0x5936 # + 0x593F, //0x3871 0x593F # + 0x5943, //0x3872 0x5943 # + 0x5946, //0x3873 0x5946 # + 0x5952, //0x3874 0x5952 # + 0x5953, //0x3875 0x5953 # + 0x5959, //0x3876 0x5959 # + 0x595B, //0x3877 0x595B # + 0x595D, //0x3878 0x595D # + 0x595E, //0x3879 0x595E # + 0x595F, //0x387A 0x595F # + 0x5961, //0x387B 0x5961 # + 0x5963, //0x387C 0x5963 # + 0x596B, //0x387D 0x596B # + 0x596D //0x387E 0x596D # + }, + //25区 + { + 0x596F, //0x3921 0x596F # + 0x5972, //0x3922 0x5972 # + 0x5975, //0x3923 0x5975 # + 0x5976, //0x3924 0x5976 # + 0x5979, //0x3925 0x5979 # + 0x597B, //0x3926 0x597B # + 0x597C, //0x3927 0x597C # + 0x598B, //0x3928 0x598B # + 0x598C, //0x3929 0x598C # + 0x598E, //0x392A 0x598E # + 0x5992, //0x392B 0x5992 # + 0x5995, //0x392C 0x5995 # + 0x5997, //0x392D 0x5997 # + 0x599F, //0x392E 0x599F # + 0x59A4, //0x392F 0x59A4 # + 0x59A7, //0x3930 0x59A7 # + 0x59AD, //0x3931 0x59AD # + 0x59AE, //0x3932 0x59AE # + 0x59AF, //0x3933 0x59AF # + 0x59B0, //0x3934 0x59B0 # + 0x59B3, //0x3935 0x59B3 # + 0x59B7, //0x3936 0x59B7 # + 0x59BA, //0x3937 0x59BA # + 0x59BC, //0x3938 0x59BC # + 0x59C1, //0x3939 0x59C1 # + 0x59C3, //0x393A 0x59C3 # + 0x59C4, //0x393B 0x59C4 # + 0x59C8, //0x393C 0x59C8 # + 0x59CA, //0x393D 0x59CA # + 0x59CD, //0x393E 0x59CD # + 0x59D2, //0x393F 0x59D2 # + 0x59DD, //0x3940 0x59DD # + 0x59DE, //0x3941 0x59DE # + 0x59DF, //0x3942 0x59DF # + 0x59E3, //0x3943 0x59E3 # + 0x59E4, //0x3944 0x59E4 # + 0x59E7, //0x3945 0x59E7 # + 0x59EE, //0x3946 0x59EE # + 0x59EF, //0x3947 0x59EF # + 0x59F1, //0x3948 0x59F1 # + 0x59F2, //0x3949 0x59F2 # + 0x59F4, //0x394A 0x59F4 # + 0x59F7, //0x394B 0x59F7 # + 0x5A00, //0x394C 0x5A00 # + 0x5A04, //0x394D 0x5A04 # + 0x5A0C, //0x394E 0x5A0C # + 0x5A0D, //0x394F 0x5A0D # + 0x5A0E, //0x3950 0x5A0E # + 0x5A12, //0x3951 0x5A12 # + 0x5A13, //0x3952 0x5A13 # + 0x5A1E, //0x3953 0x5A1E # + 0x5A23, //0x3954 0x5A23 # + 0x5A24, //0x3955 0x5A24 # + 0x5A27, //0x3956 0x5A27 # + 0x5A28, //0x3957 0x5A28 # + 0x5A2A, //0x3958 0x5A2A # + 0x5A2D, //0x3959 0x5A2D # + 0x5A30, //0x395A 0x5A30 # + 0x5A44, //0x395B 0x5A44 # + 0x5A45, //0x395C 0x5A45 # + 0x5A47, //0x395D 0x5A47 # + 0x5A48, //0x395E 0x5A48 # + 0x5A4C, //0x395F 0x5A4C # + 0x5A50, //0x3960 0x5A50 # + 0x5A55, //0x3961 0x5A55 # + 0x5A5E, //0x3962 0x5A5E # + 0x5A63, //0x3963 0x5A63 # + 0x5A65, //0x3964 0x5A65 # + 0x5A67, //0x3965 0x5A67 # + 0x5A6D, //0x3966 0x5A6D # + 0x5A77, //0x3967 0x5A77 # + 0x5A7A, //0x3968 0x5A7A # + 0x5A7B, //0x3969 0x5A7B # + 0x5A7E, //0x396A 0x5A7E # + 0x5A8B, //0x396B 0x5A8B # + 0x5A90, //0x396C 0x5A90 # + 0x5A93, //0x396D 0x5A93 # + 0x5A96, //0x396E 0x5A96 # + 0x5A99, //0x396F 0x5A99 # + 0x5A9C, //0x3970 0x5A9C # + 0x5A9E, //0x3971 0x5A9E # + 0x5A9F, //0x3972 0x5A9F # + 0x5AA0, //0x3973 0x5AA0 # + 0x5AA2, //0x3974 0x5AA2 # + 0x5AA7, //0x3975 0x5AA7 # + 0x5AAC, //0x3976 0x5AAC # + 0x5AB1, //0x3977 0x5AB1 # + 0x5AB2, //0x3978 0x5AB2 # + 0x5AB3, //0x3979 0x5AB3 # + 0x5AB5, //0x397A 0x5AB5 # + 0x5AB8, //0x397B 0x5AB8 # + 0x5ABA, //0x397C 0x5ABA # + 0x5ABB, //0x397D 0x5ABB # + 0x5ABF //0x397E 0x5ABF # + }, + //26区 + { + 0x5AC4, //0x3A21 0x5AC4 # + 0x5AC6, //0x3A22 0x5AC6 # + 0x5AC8, //0x3A23 0x5AC8 # + 0x5ACF, //0x3A24 0x5ACF # + 0x5ADA, //0x3A25 0x5ADA # + 0x5ADC, //0x3A26 0x5ADC # + 0x5AE0, //0x3A27 0x5AE0 # + 0x5AE5, //0x3A28 0x5AE5 # + 0x5AEA, //0x3A29 0x5AEA # + 0x5AEE, //0x3A2A 0x5AEE # + 0x5AF5, //0x3A2B 0x5AF5 # + 0x5AF6, //0x3A2C 0x5AF6 # + 0x5AFD, //0x3A2D 0x5AFD # + 0x5B00, //0x3A2E 0x5B00 # + 0x5B01, //0x3A2F 0x5B01 # + 0x5B08, //0x3A30 0x5B08 # + 0x5B17, //0x3A31 0x5B17 # + 0x5B34, //0x3A32 0x5B34 # + 0x5B19, //0x3A33 0x5B19 # + 0x5B1B, //0x3A34 0x5B1B # + 0x5B1D, //0x3A35 0x5B1D # + 0x5B21, //0x3A36 0x5B21 # + 0x5B25, //0x3A37 0x5B25 # + 0x5B2D, //0x3A38 0x5B2D # + 0x5B38, //0x3A39 0x5B38 # + 0x5B41, //0x3A3A 0x5B41 # + 0x5B4B, //0x3A3B 0x5B4B # + 0x5B4C, //0x3A3C 0x5B4C # + 0x5B52, //0x3A3D 0x5B52 # + 0x5B56, //0x3A3E 0x5B56 # + 0x5B5E, //0x3A3F 0x5B5E # + 0x5B68, //0x3A40 0x5B68 # + 0x5B6E, //0x3A41 0x5B6E # + 0x5B6F, //0x3A42 0x5B6F # + 0x5B7C, //0x3A43 0x5B7C # + 0x5B7D, //0x3A44 0x5B7D # + 0x5B7E, //0x3A45 0x5B7E # + 0x5B7F, //0x3A46 0x5B7F # + 0x5B81, //0x3A47 0x5B81 # + 0x5B84, //0x3A48 0x5B84 # + 0x5B86, //0x3A49 0x5B86 # + 0x5B8A, //0x3A4A 0x5B8A # + 0x5B8E, //0x3A4B 0x5B8E # + 0x5B90, //0x3A4C 0x5B90 # + 0x5B91, //0x3A4D 0x5B91 # + 0x5B93, //0x3A4E 0x5B93 # + 0x5B94, //0x3A4F 0x5B94 # + 0x5B96, //0x3A50 0x5B96 # + 0x5BA8, //0x3A51 0x5BA8 # + 0x5BA9, //0x3A52 0x5BA9 # + 0x5BAC, //0x3A53 0x5BAC # + 0x5BAD, //0x3A54 0x5BAD # + 0x5BAF, //0x3A55 0x5BAF # + 0x5BB1, //0x3A56 0x5BB1 # + 0x5BB2, //0x3A57 0x5BB2 # + 0x5BB7, //0x3A58 0x5BB7 # + 0x5BBA, //0x3A59 0x5BBA # + 0x5BBC, //0x3A5A 0x5BBC # + 0x5BC0, //0x3A5B 0x5BC0 # + 0x5BC1, //0x3A5C 0x5BC1 # + 0x5BCD, //0x3A5D 0x5BCD # + 0x5BCF, //0x3A5E 0x5BCF # + 0x5BD6, //0x3A5F 0x5BD6 # + 0x5BD7, //0x3A60 0x5BD7 # + 0x5BD8, //0x3A61 0x5BD8 # + 0x5BD9, //0x3A62 0x5BD9 # + 0x5BDA, //0x3A63 0x5BDA # + 0x5BE0, //0x3A64 0x5BE0 # + 0x5BEF, //0x3A65 0x5BEF # + 0x5BF1, //0x3A66 0x5BF1 # + 0x5BF4, //0x3A67 0x5BF4 # + 0x5BFD, //0x3A68 0x5BFD # + 0x5C0C, //0x3A69 0x5C0C # + 0x5C17, //0x3A6A 0x5C17 # + 0x5C1E, //0x3A6B 0x5C1E # + 0x5C1F, //0x3A6C 0x5C1F # + 0x5C23, //0x3A6D 0x5C23 # + 0x5C26, //0x3A6E 0x5C26 # + 0x5C29, //0x3A6F 0x5C29 # + 0x5C2B, //0x3A70 0x5C2B # + 0x5C2C, //0x3A71 0x5C2C # + 0x5C2E, //0x3A72 0x5C2E # + 0x5C30, //0x3A73 0x5C30 # + 0x5C32, //0x3A74 0x5C32 # + 0x5C35, //0x3A75 0x5C35 # + 0x5C36, //0x3A76 0x5C36 # + 0x5C59, //0x3A77 0x5C59 # + 0x5C5A, //0x3A78 0x5C5A # + 0x5C5C, //0x3A79 0x5C5C # + 0x5C62, //0x3A7A 0x5C62 # + 0x5C63, //0x3A7B 0x5C63 # + 0x5C67, //0x3A7C 0x5C67 # + 0x5C68, //0x3A7D 0x5C68 # + 0x5C69 //0x3A7E 0x5C69 # + }, + //27区 + { + 0x5C6D, //0x3B21 0x5C6D # + 0x5C70, //0x3B22 0x5C70 # + 0x5C74, //0x3B23 0x5C74 # + 0x5C75, //0x3B24 0x5C75 # + 0x5C7A, //0x3B25 0x5C7A # + 0x5C7B, //0x3B26 0x5C7B # + 0x5C7C, //0x3B27 0x5C7C # + 0x5C7D, //0x3B28 0x5C7D # + 0x5C87, //0x3B29 0x5C87 # + 0x5C88, //0x3B2A 0x5C88 # + 0x5C8A, //0x3B2B 0x5C8A # + 0x5C8F, //0x3B2C 0x5C8F # + 0x5C92, //0x3B2D 0x5C92 # + 0x5C9D, //0x3B2E 0x5C9D # + 0x5C9F, //0x3B2F 0x5C9F # + 0x5CA0, //0x3B30 0x5CA0 # + 0x5CA2, //0x3B31 0x5CA2 # + 0x5CA3, //0x3B32 0x5CA3 # + 0x5CA6, //0x3B33 0x5CA6 # + 0x5CAA, //0x3B34 0x5CAA # + 0x5CB2, //0x3B35 0x5CB2 # + 0x5CB4, //0x3B36 0x5CB4 # + 0x5CB5, //0x3B37 0x5CB5 # + 0x5CBA, //0x3B38 0x5CBA # + 0x5CC9, //0x3B39 0x5CC9 # + 0x5CCB, //0x3B3A 0x5CCB # + 0x5CD2, //0x3B3B 0x5CD2 # + 0x5CDD, //0x3B3C 0x5CDD # + 0x5CD7, //0x3B3D 0x5CD7 # + 0x5CEE, //0x3B3E 0x5CEE # + 0x5CF1, //0x3B3F 0x5CF1 # + 0x5CF2, //0x3B40 0x5CF2 # + 0x5CF4, //0x3B41 0x5CF4 # + 0x5D01, //0x3B42 0x5D01 # + 0x5D06, //0x3B43 0x5D06 # + 0x5D0D, //0x3B44 0x5D0D # + 0x5D12, //0x3B45 0x5D12 # + 0x5D2B, //0x3B46 0x5D2B # + 0x5D23, //0x3B47 0x5D23 # + 0x5D24, //0x3B48 0x5D24 # + 0x5D26, //0x3B49 0x5D26 # + 0x5D27, //0x3B4A 0x5D27 # + 0x5D31, //0x3B4B 0x5D31 # + 0x5D34, //0x3B4C 0x5D34 # + 0x5D39, //0x3B4D 0x5D39 # + 0x5D3D, //0x3B4E 0x5D3D # + 0x5D3F, //0x3B4F 0x5D3F # + 0x5D42, //0x3B50 0x5D42 # + 0x5D43, //0x3B51 0x5D43 # + 0x5D46, //0x3B52 0x5D46 # + 0x5D48, //0x3B53 0x5D48 # + 0x5D55, //0x3B54 0x5D55 # + 0x5D51, //0x3B55 0x5D51 # + 0x5D59, //0x3B56 0x5D59 # + 0x5D4A, //0x3B57 0x5D4A # + 0x5D5F, //0x3B58 0x5D5F # + 0x5D60, //0x3B59 0x5D60 # + 0x5D61, //0x3B5A 0x5D61 # + 0x5D62, //0x3B5B 0x5D62 # + 0x5D64, //0x3B5C 0x5D64 # + 0x5D6A, //0x3B5D 0x5D6A # + 0x5D6D, //0x3B5E 0x5D6D # + 0x5D70, //0x3B5F 0x5D70 # + 0x5D79, //0x3B60 0x5D79 # + 0x5D7A, //0x3B61 0x5D7A # + 0x5D7E, //0x3B62 0x5D7E # + 0x5D7F, //0x3B63 0x5D7F # + 0x5D81, //0x3B64 0x5D81 # + 0x5D83, //0x3B65 0x5D83 # + 0x5D88, //0x3B66 0x5D88 # + 0x5D8A, //0x3B67 0x5D8A # + 0x5D92, //0x3B68 0x5D92 # + 0x5D93, //0x3B69 0x5D93 # + 0x5D94, //0x3B6A 0x5D94 # + 0x5D95, //0x3B6B 0x5D95 # + 0x5D99, //0x3B6C 0x5D99 # + 0x5D9B, //0x3B6D 0x5D9B # + 0x5D9F, //0x3B6E 0x5D9F # + 0x5DA0, //0x3B6F 0x5DA0 # + 0x5DA7, //0x3B70 0x5DA7 # + 0x5DAB, //0x3B71 0x5DAB # + 0x5DB0, //0x3B72 0x5DB0 # + 0x5DB4, //0x3B73 0x5DB4 # + 0x5DB8, //0x3B74 0x5DB8 # + 0x5DB9, //0x3B75 0x5DB9 # + 0x5DC3, //0x3B76 0x5DC3 # + 0x5DC7, //0x3B77 0x5DC7 # + 0x5DCB, //0x3B78 0x5DCB # + 0x5DD0, //0x3B79 0x5DD0 # + 0x5DCE, //0x3B7A 0x5DCE # + 0x5DD8, //0x3B7B 0x5DD8 # + 0x5DD9, //0x3B7C 0x5DD9 # + 0x5DE0, //0x3B7D 0x5DE0 # + 0x5DE4 //0x3B7E 0x5DE4 # + }, + //28区 + { + 0x5DE9, //0x3C21 0x5DE9 # + 0x5DF8, //0x3C22 0x5DF8 # + 0x5DF9, //0x3C23 0x5DF9 # + 0x5E00, //0x3C24 0x5E00 # + 0x5E07, //0x3C25 0x5E07 # + 0x5E0D, //0x3C26 0x5E0D # + 0x5E12, //0x3C27 0x5E12 # + 0x5E14, //0x3C28 0x5E14 # + 0x5E15, //0x3C29 0x5E15 # + 0x5E18, //0x3C2A 0x5E18 # + 0x5E1F, //0x3C2B 0x5E1F # + 0x5E20, //0x3C2C 0x5E20 # + 0x5E2E, //0x3C2D 0x5E2E # + 0x5E28, //0x3C2E 0x5E28 # + 0x5E32, //0x3C2F 0x5E32 # + 0x5E35, //0x3C30 0x5E35 # + 0x5E3E, //0x3C31 0x5E3E # + 0x5E4B, //0x3C32 0x5E4B # + 0x5E50, //0x3C33 0x5E50 # + 0x5E49, //0x3C34 0x5E49 # + 0x5E51, //0x3C35 0x5E51 # + 0x5E56, //0x3C36 0x5E56 # + 0x5E58, //0x3C37 0x5E58 # + 0x5E5B, //0x3C38 0x5E5B # + 0x5E5C, //0x3C39 0x5E5C # + 0x5E5E, //0x3C3A 0x5E5E # + 0x5E68, //0x3C3B 0x5E68 # + 0x5E6A, //0x3C3C 0x5E6A # + 0x5E6B, //0x3C3D 0x5E6B # + 0x5E6C, //0x3C3E 0x5E6C # + 0x5E6D, //0x3C3F 0x5E6D # + 0x5E6E, //0x3C40 0x5E6E # + 0x5E70, //0x3C41 0x5E70 # + 0x5E80, //0x3C42 0x5E80 # + 0x5E8B, //0x3C43 0x5E8B # + 0x5E8E, //0x3C44 0x5E8E # + 0x5EA2, //0x3C45 0x5EA2 # + 0x5EA4, //0x3C46 0x5EA4 # + 0x5EA5, //0x3C47 0x5EA5 # + 0x5EA8, //0x3C48 0x5EA8 # + 0x5EAA, //0x3C49 0x5EAA # + 0x5EAC, //0x3C4A 0x5EAC # + 0x5EB1, //0x3C4B 0x5EB1 # + 0x5EB3, //0x3C4C 0x5EB3 # + 0x5EBD, //0x3C4D 0x5EBD # + 0x5EBE, //0x3C4E 0x5EBE # + 0x5EBF, //0x3C4F 0x5EBF # + 0x5EC6, //0x3C50 0x5EC6 # + 0x5ECC, //0x3C51 0x5ECC # + 0x5ECB, //0x3C52 0x5ECB # + 0x5ECE, //0x3C53 0x5ECE # + 0x5ED1, //0x3C54 0x5ED1 # + 0x5ED2, //0x3C55 0x5ED2 # + 0x5ED4, //0x3C56 0x5ED4 # + 0x5ED5, //0x3C57 0x5ED5 # + 0x5EDC, //0x3C58 0x5EDC # + 0x5EDE, //0x3C59 0x5EDE # + 0x5EE5, //0x3C5A 0x5EE5 # + 0x5EEB, //0x3C5B 0x5EEB # + 0x5F02, //0x3C5C 0x5F02 # + 0x5F06, //0x3C5D 0x5F06 # + 0x5F07, //0x3C5E 0x5F07 # + 0x5F08, //0x3C5F 0x5F08 # + 0x5F0E, //0x3C60 0x5F0E # + 0x5F19, //0x3C61 0x5F19 # + 0x5F1C, //0x3C62 0x5F1C # + 0x5F1D, //0x3C63 0x5F1D # + 0x5F21, //0x3C64 0x5F21 # + 0x5F22, //0x3C65 0x5F22 # + 0x5F23, //0x3C66 0x5F23 # + 0x5F24, //0x3C67 0x5F24 # + 0x5F28, //0x3C68 0x5F28 # + 0x5F2B, //0x3C69 0x5F2B # + 0x5F2C, //0x3C6A 0x5F2C # + 0x5F2E, //0x3C6B 0x5F2E # + 0x5F30, //0x3C6C 0x5F30 # + 0x5F34, //0x3C6D 0x5F34 # + 0x5F36, //0x3C6E 0x5F36 # + 0x5F3B, //0x3C6F 0x5F3B # + 0x5F3D, //0x3C70 0x5F3D # + 0x5F3F, //0x3C71 0x5F3F # + 0x5F40, //0x3C72 0x5F40 # + 0x5F44, //0x3C73 0x5F44 # + 0x5F45, //0x3C74 0x5F45 # + 0x5F47, //0x3C75 0x5F47 # + 0x5F4D, //0x3C76 0x5F4D # + 0x5F50, //0x3C77 0x5F50 # + 0x5F54, //0x3C78 0x5F54 # + 0x5F58, //0x3C79 0x5F58 # + 0x5F5B, //0x3C7A 0x5F5B # + 0x5F60, //0x3C7B 0x5F60 # + 0x5F63, //0x3C7C 0x5F63 # + 0x5F64, //0x3C7D 0x5F64 # + 0x5F67 //0x3C7E 0x5F67 # + }, + //29区 + { + 0x5F6F, //0x3D21 0x5F6F # + 0x5F72, //0x3D22 0x5F72 # + 0x5F74, //0x3D23 0x5F74 # + 0x5F75, //0x3D24 0x5F75 # + 0x5F78, //0x3D25 0x5F78 # + 0x5F7A, //0x3D26 0x5F7A # + 0x5F7D, //0x3D27 0x5F7D # + 0x5F7E, //0x3D28 0x5F7E # + 0x5F89, //0x3D29 0x5F89 # + 0x5F8D, //0x3D2A 0x5F8D # + 0x5F8F, //0x3D2B 0x5F8F # + 0x5F96, //0x3D2C 0x5F96 # + 0x5F9C, //0x3D2D 0x5F9C # + 0x5F9D, //0x3D2E 0x5F9D # + 0x5FA2, //0x3D2F 0x5FA2 # + 0x5FA7, //0x3D30 0x5FA7 # + 0x5FAB, //0x3D31 0x5FAB # + 0x5FA4, //0x3D32 0x5FA4 # + 0x5FAC, //0x3D33 0x5FAC # + 0x5FAF, //0x3D34 0x5FAF # + 0x5FB0, //0x3D35 0x5FB0 # + 0x5FB1, //0x3D36 0x5FB1 # + 0x5FB8, //0x3D37 0x5FB8 # + 0x5FC4, //0x3D38 0x5FC4 # + 0x5FC7, //0x3D39 0x5FC7 # + 0x5FC8, //0x3D3A 0x5FC8 # + 0x5FC9, //0x3D3B 0x5FC9 # + 0x5FCB, //0x3D3C 0x5FCB # + 0x5FD0, //0x3D3D 0x5FD0 # + 0x5FD1, //0x3D3E 0x5FD1 # + 0x5FD2, //0x3D3F 0x5FD2 # + 0x5FD3, //0x3D40 0x5FD3 # + 0x5FD4, //0x3D41 0x5FD4 # + 0x5FDE, //0x3D42 0x5FDE # + 0x5FE1, //0x3D43 0x5FE1 # + 0x5FE2, //0x3D44 0x5FE2 # + 0x5FE8, //0x3D45 0x5FE8 # + 0x5FE9, //0x3D46 0x5FE9 # + 0x5FEA, //0x3D47 0x5FEA # + 0x5FEC, //0x3D48 0x5FEC # + 0x5FED, //0x3D49 0x5FED # + 0x5FEE, //0x3D4A 0x5FEE # + 0x5FEF, //0x3D4B 0x5FEF # + 0x5FF2, //0x3D4C 0x5FF2 # + 0x5FF3, //0x3D4D 0x5FF3 # + 0x5FF6, //0x3D4E 0x5FF6 # + 0x5FFA, //0x3D4F 0x5FFA # + 0x5FFC, //0x3D50 0x5FFC # + 0x6007, //0x3D51 0x6007 # + 0x600A, //0x3D52 0x600A # + 0x600D, //0x3D53 0x600D # + 0x6013, //0x3D54 0x6013 # + 0x6014, //0x3D55 0x6014 # + 0x6017, //0x3D56 0x6017 # + 0x6018, //0x3D57 0x6018 # + 0x601A, //0x3D58 0x601A # + 0x601F, //0x3D59 0x601F # + 0x6024, //0x3D5A 0x6024 # + 0x602D, //0x3D5B 0x602D # + 0x6033, //0x3D5C 0x6033 # + 0x6035, //0x3D5D 0x6035 # + 0x6040, //0x3D5E 0x6040 # + 0x6047, //0x3D5F 0x6047 # + 0x6048, //0x3D60 0x6048 # + 0x6049, //0x3D61 0x6049 # + 0x604C, //0x3D62 0x604C # + 0x6051, //0x3D63 0x6051 # + 0x6054, //0x3D64 0x6054 # + 0x6056, //0x3D65 0x6056 # + 0x6057, //0x3D66 0x6057 # + 0x605D, //0x3D67 0x605D # + 0x6061, //0x3D68 0x6061 # + 0x6067, //0x3D69 0x6067 # + 0x6071, //0x3D6A 0x6071 # + 0x607E, //0x3D6B 0x607E # + 0x607F, //0x3D6C 0x607F # + 0x6082, //0x3D6D 0x6082 # + 0x6086, //0x3D6E 0x6086 # + 0x6088, //0x3D6F 0x6088 # + 0x608A, //0x3D70 0x608A # + 0x608E, //0x3D71 0x608E # + 0x6091, //0x3D72 0x6091 # + 0x6093, //0x3D73 0x6093 # + 0x6095, //0x3D74 0x6095 # + 0x6098, //0x3D75 0x6098 # + 0x609D, //0x3D76 0x609D # + 0x609E, //0x3D77 0x609E # + 0x60A2, //0x3D78 0x60A2 # + 0x60A4, //0x3D79 0x60A4 # + 0x60A5, //0x3D7A 0x60A5 # + 0x60A8, //0x3D7B 0x60A8 # + 0x60B0, //0x3D7C 0x60B0 # + 0x60B1, //0x3D7D 0x60B1 # + 0x60B7 //0x3D7E 0x60B7 # + }, + //30区 + { + 0x60BB, //0x3E21 0x60BB # + 0x60BE, //0x3E22 0x60BE # + 0x60C2, //0x3E23 0x60C2 # + 0x60C4, //0x3E24 0x60C4 # + 0x60C8, //0x3E25 0x60C8 # + 0x60C9, //0x3E26 0x60C9 # + 0x60CA, //0x3E27 0x60CA # + 0x60CB, //0x3E28 0x60CB # + 0x60CE, //0x3E29 0x60CE # + 0x60CF, //0x3E2A 0x60CF # + 0x60D4, //0x3E2B 0x60D4 # + 0x60D5, //0x3E2C 0x60D5 # + 0x60D9, //0x3E2D 0x60D9 # + 0x60DB, //0x3E2E 0x60DB # + 0x60DD, //0x3E2F 0x60DD # + 0x60DE, //0x3E30 0x60DE # + 0x60E2, //0x3E31 0x60E2 # + 0x60E5, //0x3E32 0x60E5 # + 0x60F2, //0x3E33 0x60F2 # + 0x60F5, //0x3E34 0x60F5 # + 0x60F8, //0x3E35 0x60F8 # + 0x60FC, //0x3E36 0x60FC # + 0x60FD, //0x3E37 0x60FD # + 0x6102, //0x3E38 0x6102 # + 0x6107, //0x3E39 0x6107 # + 0x610A, //0x3E3A 0x610A # + 0x610C, //0x3E3B 0x610C # + 0x6110, //0x3E3C 0x6110 # + 0x6111, //0x3E3D 0x6111 # + 0x6112, //0x3E3E 0x6112 # + 0x6113, //0x3E3F 0x6113 # + 0x6114, //0x3E40 0x6114 # + 0x6116, //0x3E41 0x6116 # + 0x6117, //0x3E42 0x6117 # + 0x6119, //0x3E43 0x6119 # + 0x611C, //0x3E44 0x611C # + 0x611E, //0x3E45 0x611E # + 0x6122, //0x3E46 0x6122 # + 0x612A, //0x3E47 0x612A # + 0x612B, //0x3E48 0x612B # + 0x6130, //0x3E49 0x6130 # + 0x6131, //0x3E4A 0x6131 # + 0x6135, //0x3E4B 0x6135 # + 0x6136, //0x3E4C 0x6136 # + 0x6137, //0x3E4D 0x6137 # + 0x6139, //0x3E4E 0x6139 # + 0x6141, //0x3E4F 0x6141 # + 0x6145, //0x3E50 0x6145 # + 0x6146, //0x3E51 0x6146 # + 0x6149, //0x3E52 0x6149 # + 0x615E, //0x3E53 0x615E # + 0x6160, //0x3E54 0x6160 # + 0x616C, //0x3E55 0x616C # + 0x6172, //0x3E56 0x6172 # + 0x6178, //0x3E57 0x6178 # + 0x617B, //0x3E58 0x617B # + 0x617C, //0x3E59 0x617C # + 0x617F, //0x3E5A 0x617F # + 0x6180, //0x3E5B 0x6180 # + 0x6181, //0x3E5C 0x6181 # + 0x6183, //0x3E5D 0x6183 # + 0x6184, //0x3E5E 0x6184 # + 0x618B, //0x3E5F 0x618B # + 0x618D, //0x3E60 0x618D # + 0x6192, //0x3E61 0x6192 # + 0x6193, //0x3E62 0x6193 # + 0x6197, //0x3E63 0x6197 # + 0x6198, //0x3E64 0x6198 # + 0x619C, //0x3E65 0x619C # + 0x619D, //0x3E66 0x619D # + 0x619F, //0x3E67 0x619F # + 0x61A0, //0x3E68 0x61A0 # + 0x61A5, //0x3E69 0x61A5 # + 0x61A8, //0x3E6A 0x61A8 # + 0x61AA, //0x3E6B 0x61AA # + 0x61AD, //0x3E6C 0x61AD # + 0x61B8, //0x3E6D 0x61B8 # + 0x61B9, //0x3E6E 0x61B9 # + 0x61BC, //0x3E6F 0x61BC # + 0x61C0, //0x3E70 0x61C0 # + 0x61C1, //0x3E71 0x61C1 # + 0x61C2, //0x3E72 0x61C2 # + 0x61CE, //0x3E73 0x61CE # + 0x61CF, //0x3E74 0x61CF # + 0x61D5, //0x3E75 0x61D5 # + 0x61DC, //0x3E76 0x61DC # + 0x61DD, //0x3E77 0x61DD # + 0x61DE, //0x3E78 0x61DE # + 0x61DF, //0x3E79 0x61DF # + 0x61E1, //0x3E7A 0x61E1 # + 0x61E2, //0x3E7B 0x61E2 # + 0x61E7, //0x3E7C 0x61E7 # + 0x61E9, //0x3E7D 0x61E9 # + 0x61E5 //0x3E7E 0x61E5 # + }, + //31区 + { + 0x61EC, //0x3F21 0x61EC # + 0x61ED, //0x3F22 0x61ED # + 0x61EF, //0x3F23 0x61EF # + 0x6201, //0x3F24 0x6201 # + 0x6203, //0x3F25 0x6203 # + 0x6204, //0x3F26 0x6204 # + 0x6207, //0x3F27 0x6207 # + 0x6213, //0x3F28 0x6213 # + 0x6215, //0x3F29 0x6215 # + 0x621C, //0x3F2A 0x621C # + 0x6220, //0x3F2B 0x6220 # + 0x6222, //0x3F2C 0x6222 # + 0x6223, //0x3F2D 0x6223 # + 0x6227, //0x3F2E 0x6227 # + 0x6229, //0x3F2F 0x6229 # + 0x622B, //0x3F30 0x622B # + 0x6239, //0x3F31 0x6239 # + 0x623D, //0x3F32 0x623D # + 0x6242, //0x3F33 0x6242 # + 0x6243, //0x3F34 0x6243 # + 0x6244, //0x3F35 0x6244 # + 0x6246, //0x3F36 0x6246 # + 0x624C, //0x3F37 0x624C # + 0x6250, //0x3F38 0x6250 # + 0x6251, //0x3F39 0x6251 # + 0x6252, //0x3F3A 0x6252 # + 0x6254, //0x3F3B 0x6254 # + 0x6256, //0x3F3C 0x6256 # + 0x625A, //0x3F3D 0x625A # + 0x625C, //0x3F3E 0x625C # + 0x6264, //0x3F3F 0x6264 # + 0x626D, //0x3F40 0x626D # + 0x626F, //0x3F41 0x626F # + 0x6273, //0x3F42 0x6273 # + 0x627A, //0x3F43 0x627A # + 0x627D, //0x3F44 0x627D # + 0x628D, //0x3F45 0x628D # + 0x628E, //0x3F46 0x628E # + 0x628F, //0x3F47 0x628F # + 0x6290, //0x3F48 0x6290 # + 0x62A6, //0x3F49 0x62A6 # + 0x62A8, //0x3F4A 0x62A8 # + 0x62B3, //0x3F4B 0x62B3 # + 0x62B6, //0x3F4C 0x62B6 # + 0x62B7, //0x3F4D 0x62B7 # + 0x62BA, //0x3F4E 0x62BA # + 0x62BE, //0x3F4F 0x62BE # + 0x62BF, //0x3F50 0x62BF # + 0x62C4, //0x3F51 0x62C4 # + 0x62CE, //0x3F52 0x62CE # + 0x62D5, //0x3F53 0x62D5 # + 0x62D6, //0x3F54 0x62D6 # + 0x62DA, //0x3F55 0x62DA # + 0x62EA, //0x3F56 0x62EA # + 0x62F2, //0x3F57 0x62F2 # + 0x62F4, //0x3F58 0x62F4 # + 0x62FC, //0x3F59 0x62FC # + 0x62FD, //0x3F5A 0x62FD # + 0x6303, //0x3F5B 0x6303 # + 0x6304, //0x3F5C 0x6304 # + 0x630A, //0x3F5D 0x630A # + 0x630B, //0x3F5E 0x630B # + 0x630D, //0x3F5F 0x630D # + 0x6310, //0x3F60 0x6310 # + 0x6313, //0x3F61 0x6313 # + 0x6316, //0x3F62 0x6316 # + 0x6318, //0x3F63 0x6318 # + 0x6329, //0x3F64 0x6329 # + 0x632A, //0x3F65 0x632A # + 0x632D, //0x3F66 0x632D # + 0x6335, //0x3F67 0x6335 # + 0x6336, //0x3F68 0x6336 # + 0x6339, //0x3F69 0x6339 # + 0x633C, //0x3F6A 0x633C # + 0x6341, //0x3F6B 0x6341 # + 0x6342, //0x3F6C 0x6342 # + 0x6343, //0x3F6D 0x6343 # + 0x6344, //0x3F6E 0x6344 # + 0x6346, //0x3F6F 0x6346 # + 0x634A, //0x3F70 0x634A # + 0x634B, //0x3F71 0x634B # + 0x634E, //0x3F72 0x634E # + 0x6352, //0x3F73 0x6352 # + 0x6353, //0x3F74 0x6353 # + 0x6354, //0x3F75 0x6354 # + 0x6358, //0x3F76 0x6358 # + 0x635B, //0x3F77 0x635B # + 0x6365, //0x3F78 0x6365 # + 0x6366, //0x3F79 0x6366 # + 0x636C, //0x3F7A 0x636C # + 0x636D, //0x3F7B 0x636D # + 0x6371, //0x3F7C 0x6371 # + 0x6374, //0x3F7D 0x6374 # + 0x6375 //0x3F7E 0x6375 # + }, + //32区 + { + 0x6378, //0x4021 0x6378 # + 0x637C, //0x4022 0x637C # + 0x637D, //0x4023 0x637D # + 0x637F, //0x4024 0x637F # + 0x6382, //0x4025 0x6382 # + 0x6384, //0x4026 0x6384 # + 0x6387, //0x4027 0x6387 # + 0x638A, //0x4028 0x638A # + 0x6390, //0x4029 0x6390 # + 0x6394, //0x402A 0x6394 # + 0x6395, //0x402B 0x6395 # + 0x6399, //0x402C 0x6399 # + 0x639A, //0x402D 0x639A # + 0x639E, //0x402E 0x639E # + 0x63A4, //0x402F 0x63A4 # + 0x63A6, //0x4030 0x63A6 # + 0x63AD, //0x4031 0x63AD # + 0x63AE, //0x4032 0x63AE # + 0x63AF, //0x4033 0x63AF # + 0x63BD, //0x4034 0x63BD # + 0x63C1, //0x4035 0x63C1 # + 0x63C5, //0x4036 0x63C5 # + 0x63C8, //0x4037 0x63C8 # + 0x63CE, //0x4038 0x63CE # + 0x63D1, //0x4039 0x63D1 # + 0x63D3, //0x403A 0x63D3 # + 0x63D4, //0x403B 0x63D4 # + 0x63D5, //0x403C 0x63D5 # + 0x63DC, //0x403D 0x63DC # + 0x63E0, //0x403E 0x63E0 # + 0x63E5, //0x403F 0x63E5 # + 0x63EA, //0x4040 0x63EA # + 0x63EC, //0x4041 0x63EC # + 0x63F2, //0x4042 0x63F2 # + 0x63F3, //0x4043 0x63F3 # + 0x63F5, //0x4044 0x63F5 # + 0x63F8, //0x4045 0x63F8 # + 0x63F9, //0x4046 0x63F9 # + 0x6409, //0x4047 0x6409 # + 0x640A, //0x4048 0x640A # + 0x6410, //0x4049 0x6410 # + 0x6412, //0x404A 0x6412 # + 0x6414, //0x404B 0x6414 # + 0x6418, //0x404C 0x6418 # + 0x641E, //0x404D 0x641E # + 0x6420, //0x404E 0x6420 # + 0x6422, //0x404F 0x6422 # + 0x6424, //0x4050 0x6424 # + 0x6425, //0x4051 0x6425 # + 0x6429, //0x4052 0x6429 # + 0x642A, //0x4053 0x642A # + 0x642F, //0x4054 0x642F # + 0x6430, //0x4055 0x6430 # + 0x6435, //0x4056 0x6435 # + 0x643D, //0x4057 0x643D # + 0x643F, //0x4058 0x643F # + 0x644B, //0x4059 0x644B # + 0x644F, //0x405A 0x644F # + 0x6451, //0x405B 0x6451 # + 0x6452, //0x405C 0x6452 # + 0x6453, //0x405D 0x6453 # + 0x6454, //0x405E 0x6454 # + 0x645A, //0x405F 0x645A # + 0x645B, //0x4060 0x645B # + 0x645C, //0x4061 0x645C # + 0x645D, //0x4062 0x645D # + 0x645F, //0x4063 0x645F # + 0x6460, //0x4064 0x6460 # + 0x6461, //0x4065 0x6461 # + 0x6463, //0x4066 0x6463 # + 0x646D, //0x4067 0x646D # + 0x6473, //0x4068 0x6473 # + 0x6474, //0x4069 0x6474 # + 0x647B, //0x406A 0x647B # + 0x647D, //0x406B 0x647D # + 0x6485, //0x406C 0x6485 # + 0x6487, //0x406D 0x6487 # + 0x648F, //0x406E 0x648F # + 0x6490, //0x406F 0x6490 # + 0x6491, //0x4070 0x6491 # + 0x6498, //0x4071 0x6498 # + 0x6499, //0x4072 0x6499 # + 0x649B, //0x4073 0x649B # + 0x649D, //0x4074 0x649D # + 0x649F, //0x4075 0x649F # + 0x64A1, //0x4076 0x64A1 # + 0x64A3, //0x4077 0x64A3 # + 0x64A6, //0x4078 0x64A6 # + 0x64A8, //0x4079 0x64A8 # + 0x64AC, //0x407A 0x64AC # + 0x64B3, //0x407B 0x64B3 # + 0x64BD, //0x407C 0x64BD # + 0x64BE, //0x407D 0x64BE # + 0x64BF //0x407E 0x64BF # + }, + //33区 + { + 0x64C4, //0x4121 0x64C4 # + 0x64C9, //0x4122 0x64C9 # + 0x64CA, //0x4123 0x64CA # + 0x64CB, //0x4124 0x64CB # + 0x64CC, //0x4125 0x64CC # + 0x64CE, //0x4126 0x64CE # + 0x64D0, //0x4127 0x64D0 # + 0x64D1, //0x4128 0x64D1 # + 0x64D5, //0x4129 0x64D5 # + 0x64D7, //0x412A 0x64D7 # + 0x64E4, //0x412B 0x64E4 # + 0x64E5, //0x412C 0x64E5 # + 0x64E9, //0x412D 0x64E9 # + 0x64EA, //0x412E 0x64EA # + 0x64ED, //0x412F 0x64ED # + 0x64F0, //0x4130 0x64F0 # + 0x64F5, //0x4131 0x64F5 # + 0x64F7, //0x4132 0x64F7 # + 0x64FB, //0x4133 0x64FB # + 0x64FF, //0x4134 0x64FF # + 0x6501, //0x4135 0x6501 # + 0x6504, //0x4136 0x6504 # + 0x6508, //0x4137 0x6508 # + 0x6509, //0x4138 0x6509 # + 0x650A, //0x4139 0x650A # + 0x650F, //0x413A 0x650F # + 0x6513, //0x413B 0x6513 # + 0x6514, //0x413C 0x6514 # + 0x6516, //0x413D 0x6516 # + 0x6519, //0x413E 0x6519 # + 0x651B, //0x413F 0x651B # + 0x651E, //0x4140 0x651E # + 0x651F, //0x4141 0x651F # + 0x6522, //0x4142 0x6522 # + 0x6526, //0x4143 0x6526 # + 0x6529, //0x4144 0x6529 # + 0x652E, //0x4145 0x652E # + 0x6531, //0x4146 0x6531 # + 0x653A, //0x4147 0x653A # + 0x653C, //0x4148 0x653C # + 0x653D, //0x4149 0x653D # + 0x6543, //0x414A 0x6543 # + 0x6547, //0x414B 0x6547 # + 0x6549, //0x414C 0x6549 # + 0x6550, //0x414D 0x6550 # + 0x6552, //0x414E 0x6552 # + 0x6554, //0x414F 0x6554 # + 0x655F, //0x4150 0x655F # + 0x6560, //0x4151 0x6560 # + 0x6567, //0x4152 0x6567 # + 0x656B, //0x4153 0x656B # + 0x657A, //0x4154 0x657A # + 0x657D, //0x4155 0x657D # + 0x6581, //0x4156 0x6581 # + 0x6585, //0x4157 0x6585 # + 0x658A, //0x4158 0x658A # + 0x6592, //0x4159 0x6592 # + 0x6595, //0x415A 0x6595 # + 0x6598, //0x415B 0x6598 # + 0x659D, //0x415C 0x659D # + 0x65A0, //0x415D 0x65A0 # + 0x65A3, //0x415E 0x65A3 # + 0x65A6, //0x415F 0x65A6 # + 0x65AE, //0x4160 0x65AE # + 0x65B2, //0x4161 0x65B2 # + 0x65B3, //0x4162 0x65B3 # + 0x65B4, //0x4163 0x65B4 # + 0x65BF, //0x4164 0x65BF # + 0x65C2, //0x4165 0x65C2 # + 0x65C8, //0x4166 0x65C8 # + 0x65C9, //0x4167 0x65C9 # + 0x65CE, //0x4168 0x65CE # + 0x65D0, //0x4169 0x65D0 # + 0x65D4, //0x416A 0x65D4 # + 0x65D6, //0x416B 0x65D6 # + 0x65D8, //0x416C 0x65D8 # + 0x65DF, //0x416D 0x65DF # + 0x65F0, //0x416E 0x65F0 # + 0x65F2, //0x416F 0x65F2 # + 0x65F4, //0x4170 0x65F4 # + 0x65F5, //0x4171 0x65F5 # + 0x65F9, //0x4172 0x65F9 # + 0x65FE, //0x4173 0x65FE # + 0x65FF, //0x4174 0x65FF # + 0x6600, //0x4175 0x6600 # + 0x6604, //0x4176 0x6604 # + 0x6608, //0x4177 0x6608 # + 0x6609, //0x4178 0x6609 # + 0x660D, //0x4179 0x660D # + 0x6611, //0x417A 0x6611 # + 0x6612, //0x417B 0x6612 # + 0x6615, //0x417C 0x6615 # + 0x6616, //0x417D 0x6616 # + 0x661D //0x417E 0x661D # + }, + //34区 + { + 0x661E, //0x4221 0x661E # + 0x6621, //0x4222 0x6621 # + 0x6622, //0x4223 0x6622 # + 0x6623, //0x4224 0x6623 # + 0x6624, //0x4225 0x6624 # + 0x6626, //0x4226 0x6626 # + 0x6629, //0x4227 0x6629 # + 0x662A, //0x4228 0x662A # + 0x662B, //0x4229 0x662B # + 0x662C, //0x422A 0x662C # + 0x662E, //0x422B 0x662E # + 0x6630, //0x422C 0x6630 # + 0x6631, //0x422D 0x6631 # + 0x6633, //0x422E 0x6633 # + 0x6639, //0x422F 0x6639 # + 0x6637, //0x4230 0x6637 # + 0x6640, //0x4231 0x6640 # + 0x6645, //0x4232 0x6645 # + 0x6646, //0x4233 0x6646 # + 0x664A, //0x4234 0x664A # + 0x664C, //0x4235 0x664C # + 0x6651, //0x4236 0x6651 # + 0x664E, //0x4237 0x664E # + 0x6657, //0x4238 0x6657 # + 0x6658, //0x4239 0x6658 # + 0x6659, //0x423A 0x6659 # + 0x665B, //0x423B 0x665B # + 0x665C, //0x423C 0x665C # + 0x6660, //0x423D 0x6660 # + 0x6661, //0x423E 0x6661 # + 0x66FB, //0x423F 0x66FB # + 0x666A, //0x4240 0x666A # + 0x666B, //0x4241 0x666B # + 0x666C, //0x4242 0x666C # + 0x667E, //0x4243 0x667E # + 0x6673, //0x4244 0x6673 # + 0x6675, //0x4245 0x6675 # + 0x667F, //0x4246 0x667F # + 0x6677, //0x4247 0x6677 # + 0x6678, //0x4248 0x6678 # + 0x6679, //0x4249 0x6679 # + 0x667B, //0x424A 0x667B # + 0x6680, //0x424B 0x6680 # + 0x667C, //0x424C 0x667C # + 0x668B, //0x424D 0x668B # + 0x668C, //0x424E 0x668C # + 0x668D, //0x424F 0x668D # + 0x6690, //0x4250 0x6690 # + 0x6692, //0x4251 0x6692 # + 0x6699, //0x4252 0x6699 # + 0x669A, //0x4253 0x669A # + 0x669B, //0x4254 0x669B # + 0x669C, //0x4255 0x669C # + 0x669F, //0x4256 0x669F # + 0x66A0, //0x4257 0x66A0 # + 0x66A4, //0x4258 0x66A4 # + 0x66AD, //0x4259 0x66AD # + 0x66B1, //0x425A 0x66B1 # + 0x66B2, //0x425B 0x66B2 # + 0x66B5, //0x425C 0x66B5 # + 0x66BB, //0x425D 0x66BB # + 0x66BF, //0x425E 0x66BF # + 0x66C0, //0x425F 0x66C0 # + 0x66C2, //0x4260 0x66C2 # + 0x66C3, //0x4261 0x66C3 # + 0x66C8, //0x4262 0x66C8 # + 0x66CC, //0x4263 0x66CC # + 0x66CE, //0x4264 0x66CE # + 0x66CF, //0x4265 0x66CF # + 0x66D4, //0x4266 0x66D4 # + 0x66DB, //0x4267 0x66DB # + 0x66DF, //0x4268 0x66DF # + 0x66E8, //0x4269 0x66E8 # + 0x66EB, //0x426A 0x66EB # + 0x66EC, //0x426B 0x66EC # + 0x66EE, //0x426C 0x66EE # + 0x66FA, //0x426D 0x66FA # + 0x6705, //0x426E 0x6705 # + 0x6707, //0x426F 0x6707 # + 0x670E, //0x4270 0x670E # + 0x6713, //0x4271 0x6713 # + 0x6719, //0x4272 0x6719 # + 0x671C, //0x4273 0x671C # + 0x6720, //0x4274 0x6720 # + 0x6722, //0x4275 0x6722 # + 0x6733, //0x4276 0x6733 # + 0x673E, //0x4277 0x673E # + 0x6745, //0x4278 0x6745 # + 0x6747, //0x4279 0x6747 # + 0x6748, //0x427A 0x6748 # + 0x674C, //0x427B 0x674C # + 0x6754, //0x427C 0x6754 # + 0x6755, //0x427D 0x6755 # + 0x675D //0x427E 0x675D # + }, + //35区 + { + 0x6766, //0x4321 0x6766 # + 0x676C, //0x4322 0x676C # + 0x676E, //0x4323 0x676E # + 0x6774, //0x4324 0x6774 # + 0x6776, //0x4325 0x6776 # + 0x677B, //0x4326 0x677B # + 0x6781, //0x4327 0x6781 # + 0x6784, //0x4328 0x6784 # + 0x678E, //0x4329 0x678E # + 0x678F, //0x432A 0x678F # + 0x6791, //0x432B 0x6791 # + 0x6793, //0x432C 0x6793 # + 0x6796, //0x432D 0x6796 # + 0x6798, //0x432E 0x6798 # + 0x6799, //0x432F 0x6799 # + 0x679B, //0x4330 0x679B # + 0x67B0, //0x4331 0x67B0 # + 0x67B1, //0x4332 0x67B1 # + 0x67B2, //0x4333 0x67B2 # + 0x67B5, //0x4334 0x67B5 # + 0x67BB, //0x4335 0x67BB # + 0x67BC, //0x4336 0x67BC # + 0x67BD, //0x4337 0x67BD # + 0x67F9, //0x4338 0x67F9 # + 0x67C0, //0x4339 0x67C0 # + 0x67C2, //0x433A 0x67C2 # + 0x67C3, //0x433B 0x67C3 # + 0x67C5, //0x433C 0x67C5 # + 0x67C8, //0x433D 0x67C8 # + 0x67C9, //0x433E 0x67C9 # + 0x67D2, //0x433F 0x67D2 # + 0x67D7, //0x4340 0x67D7 # + 0x67D9, //0x4341 0x67D9 # + 0x67DC, //0x4342 0x67DC # + 0x67E1, //0x4343 0x67E1 # + 0x67E6, //0x4344 0x67E6 # + 0x67F0, //0x4345 0x67F0 # + 0x67F2, //0x4346 0x67F2 # + 0x67F6, //0x4347 0x67F6 # + 0x67F7, //0x4348 0x67F7 # + 0x6852, //0x4349 0x6852 # + 0x6814, //0x434A 0x6814 # + 0x6819, //0x434B 0x6819 # + 0x681D, //0x434C 0x681D # + 0x681F, //0x434D 0x681F # + 0x6828, //0x434E 0x6828 # + 0x6827, //0x434F 0x6827 # + 0x682C, //0x4350 0x682C # + 0x682D, //0x4351 0x682D # + 0x682F, //0x4352 0x682F # + 0x6830, //0x4353 0x6830 # + 0x6831, //0x4354 0x6831 # + 0x6833, //0x4355 0x6833 # + 0x683B, //0x4356 0x683B # + 0x683F, //0x4357 0x683F # + 0x6844, //0x4358 0x6844 # + 0x6845, //0x4359 0x6845 # + 0x684A, //0x435A 0x684A # + 0x684C, //0x435B 0x684C # + 0x6855, //0x435C 0x6855 # + 0x6857, //0x435D 0x6857 # + 0x6858, //0x435E 0x6858 # + 0x685B, //0x435F 0x685B # + 0x686B, //0x4360 0x686B # + 0x686E, //0x4361 0x686E # + 0x686F, //0x4362 0x686F # + 0x6870, //0x4363 0x6870 # + 0x6871, //0x4364 0x6871 # + 0x6872, //0x4365 0x6872 # + 0x6875, //0x4366 0x6875 # + 0x6879, //0x4367 0x6879 # + 0x687A, //0x4368 0x687A # + 0x687B, //0x4369 0x687B # + 0x687C, //0x436A 0x687C # + 0x6882, //0x436B 0x6882 # + 0x6884, //0x436C 0x6884 # + 0x6886, //0x436D 0x6886 # + 0x6888, //0x436E 0x6888 # + 0x6896, //0x436F 0x6896 # + 0x6898, //0x4370 0x6898 # + 0x689A, //0x4371 0x689A # + 0x689C, //0x4372 0x689C # + 0x68A1, //0x4373 0x68A1 # + 0x68A3, //0x4374 0x68A3 # + 0x68A5, //0x4375 0x68A5 # + 0x68A9, //0x4376 0x68A9 # + 0x68AA, //0x4377 0x68AA # + 0x68AE, //0x4378 0x68AE # + 0x68B2, //0x4379 0x68B2 # + 0x68BB, //0x437A 0x68BB # + 0x68C5, //0x437B 0x68C5 # + 0x68C8, //0x437C 0x68C8 # + 0x68CC, //0x437D 0x68CC # + 0x68CF //0x437E 0x68CF # + }, + //36区 + { + 0x68D0, //0x4421 0x68D0 # + 0x68D1, //0x4422 0x68D1 # + 0x68D3, //0x4423 0x68D3 # + 0x68D6, //0x4424 0x68D6 # + 0x68D9, //0x4425 0x68D9 # + 0x68DC, //0x4426 0x68DC # + 0x68DD, //0x4427 0x68DD # + 0x68E5, //0x4428 0x68E5 # + 0x68E8, //0x4429 0x68E8 # + 0x68EA, //0x442A 0x68EA # + 0x68EB, //0x442B 0x68EB # + 0x68EC, //0x442C 0x68EC # + 0x68ED, //0x442D 0x68ED # + 0x68F0, //0x442E 0x68F0 # + 0x68F1, //0x442F 0x68F1 # + 0x68F5, //0x4430 0x68F5 # + 0x68F6, //0x4431 0x68F6 # + 0x68FB, //0x4432 0x68FB # + 0x68FC, //0x4433 0x68FC # + 0x68FD, //0x4434 0x68FD # + 0x6906, //0x4435 0x6906 # + 0x6909, //0x4436 0x6909 # + 0x690A, //0x4437 0x690A # + 0x6910, //0x4438 0x6910 # + 0x6911, //0x4439 0x6911 # + 0x6913, //0x443A 0x6913 # + 0x6916, //0x443B 0x6916 # + 0x6917, //0x443C 0x6917 # + 0x6931, //0x443D 0x6931 # + 0x6933, //0x443E 0x6933 # + 0x6935, //0x443F 0x6935 # + 0x6938, //0x4440 0x6938 # + 0x693B, //0x4441 0x693B # + 0x6942, //0x4442 0x6942 # + 0x6945, //0x4443 0x6945 # + 0x6949, //0x4444 0x6949 # + 0x694E, //0x4445 0x694E # + 0x6957, //0x4446 0x6957 # + 0x695B, //0x4447 0x695B # + 0x6963, //0x4448 0x6963 # + 0x6964, //0x4449 0x6964 # + 0x6965, //0x444A 0x6965 # + 0x6966, //0x444B 0x6966 # + 0x6968, //0x444C 0x6968 # + 0x6969, //0x444D 0x6969 # + 0x696C, //0x444E 0x696C # + 0x6970, //0x444F 0x6970 # + 0x6971, //0x4450 0x6971 # + 0x6972, //0x4451 0x6972 # + 0x697A, //0x4452 0x697A # + 0x697B, //0x4453 0x697B # + 0x697F, //0x4454 0x697F # + 0x6980, //0x4455 0x6980 # + 0x698D, //0x4456 0x698D # + 0x6992, //0x4457 0x6992 # + 0x6996, //0x4458 0x6996 # + 0x6998, //0x4459 0x6998 # + 0x69A1, //0x445A 0x69A1 # + 0x69A5, //0x445B 0x69A5 # + 0x69A6, //0x445C 0x69A6 # + 0x69A8, //0x445D 0x69A8 # + 0x69AB, //0x445E 0x69AB # + 0x69AD, //0x445F 0x69AD # + 0x69AF, //0x4460 0x69AF # + 0x69B7, //0x4461 0x69B7 # + 0x69B8, //0x4462 0x69B8 # + 0x69BA, //0x4463 0x69BA # + 0x69BC, //0x4464 0x69BC # + 0x69C5, //0x4465 0x69C5 # + 0x69C8, //0x4466 0x69C8 # + 0x69D1, //0x4467 0x69D1 # + 0x69D6, //0x4468 0x69D6 # + 0x69D7, //0x4469 0x69D7 # + 0x69E2, //0x446A 0x69E2 # + 0x69E5, //0x446B 0x69E5 # + 0x69EE, //0x446C 0x69EE # + 0x69EF, //0x446D 0x69EF # + 0x69F1, //0x446E 0x69F1 # + 0x69F3, //0x446F 0x69F3 # + 0x69F5, //0x4470 0x69F5 # + 0x69FE, //0x4471 0x69FE # + 0x6A00, //0x4472 0x6A00 # + 0x6A01, //0x4473 0x6A01 # + 0x6A03, //0x4474 0x6A03 # + 0x6A0F, //0x4475 0x6A0F # + 0x6A11, //0x4476 0x6A11 # + 0x6A15, //0x4477 0x6A15 # + 0x6A1A, //0x4478 0x6A1A # + 0x6A1D, //0x4479 0x6A1D # + 0x6A20, //0x447A 0x6A20 # + 0x6A24, //0x447B 0x6A24 # + 0x6A28, //0x447C 0x6A28 # + 0x6A30, //0x447D 0x6A30 # + 0x6A32 //0x447E 0x6A32 # + }, + //37区 + { + 0x6A34, //0x4521 0x6A34 # + 0x6A37, //0x4522 0x6A37 # + 0x6A3B, //0x4523 0x6A3B # + 0x6A3E, //0x4524 0x6A3E # + 0x6A3F, //0x4525 0x6A3F # + 0x6A45, //0x4526 0x6A45 # + 0x6A46, //0x4527 0x6A46 # + 0x6A49, //0x4528 0x6A49 # + 0x6A4A, //0x4529 0x6A4A # + 0x6A4E, //0x452A 0x6A4E # + 0x6A50, //0x452B 0x6A50 # + 0x6A51, //0x452C 0x6A51 # + 0x6A52, //0x452D 0x6A52 # + 0x6A55, //0x452E 0x6A55 # + 0x6A56, //0x452F 0x6A56 # + 0x6A5B, //0x4530 0x6A5B # + 0x6A64, //0x4531 0x6A64 # + 0x6A67, //0x4532 0x6A67 # + 0x6A6A, //0x4533 0x6A6A # + 0x6A71, //0x4534 0x6A71 # + 0x6A73, //0x4535 0x6A73 # + 0x6A7E, //0x4536 0x6A7E # + 0x6A81, //0x4537 0x6A81 # + 0x6A83, //0x4538 0x6A83 # + 0x6A86, //0x4539 0x6A86 # + 0x6A87, //0x453A 0x6A87 # + 0x6A89, //0x453B 0x6A89 # + 0x6A8B, //0x453C 0x6A8B # + 0x6A91, //0x453D 0x6A91 # + 0x6A9B, //0x453E 0x6A9B # + 0x6A9D, //0x453F 0x6A9D # + 0x6A9E, //0x4540 0x6A9E # + 0x6A9F, //0x4541 0x6A9F # + 0x6AA5, //0x4542 0x6AA5 # + 0x6AAB, //0x4543 0x6AAB # + 0x6AAF, //0x4544 0x6AAF # + 0x6AB0, //0x4545 0x6AB0 # + 0x6AB1, //0x4546 0x6AB1 # + 0x6AB4, //0x4547 0x6AB4 # + 0x6ABD, //0x4548 0x6ABD # + 0x6ABE, //0x4549 0x6ABE # + 0x6ABF, //0x454A 0x6ABF # + 0x6AC6, //0x454B 0x6AC6 # + 0x6AC9, //0x454C 0x6AC9 # + 0x6AC8, //0x454D 0x6AC8 # + 0x6ACC, //0x454E 0x6ACC # + 0x6AD0, //0x454F 0x6AD0 # + 0x6AD4, //0x4550 0x6AD4 # + 0x6AD5, //0x4551 0x6AD5 # + 0x6AD6, //0x4552 0x6AD6 # + 0x6ADC, //0x4553 0x6ADC # + 0x6ADD, //0x4554 0x6ADD # + 0x6AE4, //0x4555 0x6AE4 # + 0x6AE7, //0x4556 0x6AE7 # + 0x6AEC, //0x4557 0x6AEC # + 0x6AF0, //0x4558 0x6AF0 # + 0x6AF1, //0x4559 0x6AF1 # + 0x6AF2, //0x455A 0x6AF2 # + 0x6AFC, //0x455B 0x6AFC # + 0x6AFD, //0x455C 0x6AFD # + 0x6B02, //0x455D 0x6B02 # + 0x6B03, //0x455E 0x6B03 # + 0x6B06, //0x455F 0x6B06 # + 0x6B07, //0x4560 0x6B07 # + 0x6B09, //0x4561 0x6B09 # + 0x6B0F, //0x4562 0x6B0F # + 0x6B10, //0x4563 0x6B10 # + 0x6B11, //0x4564 0x6B11 # + 0x6B17, //0x4565 0x6B17 # + 0x6B1B, //0x4566 0x6B1B # + 0x6B1E, //0x4567 0x6B1E # + 0x6B24, //0x4568 0x6B24 # + 0x6B28, //0x4569 0x6B28 # + 0x6B2B, //0x456A 0x6B2B # + 0x6B2C, //0x456B 0x6B2C # + 0x6B2F, //0x456C 0x6B2F # + 0x6B35, //0x456D 0x6B35 # + 0x6B36, //0x456E 0x6B36 # + 0x6B3B, //0x456F 0x6B3B # + 0x6B3F, //0x4570 0x6B3F # + 0x6B46, //0x4571 0x6B46 # + 0x6B4A, //0x4572 0x6B4A # + 0x6B4D, //0x4573 0x6B4D # + 0x6B52, //0x4574 0x6B52 # + 0x6B56, //0x4575 0x6B56 # + 0x6B58, //0x4576 0x6B58 # + 0x6B5D, //0x4577 0x6B5D # + 0x6B60, //0x4578 0x6B60 # + 0x6B67, //0x4579 0x6B67 # + 0x6B6B, //0x457A 0x6B6B # + 0x6B6E, //0x457B 0x6B6E # + 0x6B70, //0x457C 0x6B70 # + 0x6B75, //0x457D 0x6B75 # + 0x6B7D //0x457E 0x6B7D # + }, + //38区 + { + 0x6B7E, //0x4621 0x6B7E # + 0x6B82, //0x4622 0x6B82 # + 0x6B85, //0x4623 0x6B85 # + 0x6B97, //0x4624 0x6B97 # + 0x6B9B, //0x4625 0x6B9B # + 0x6B9F, //0x4626 0x6B9F # + 0x6BA0, //0x4627 0x6BA0 # + 0x6BA2, //0x4628 0x6BA2 # + 0x6BA3, //0x4629 0x6BA3 # + 0x6BA8, //0x462A 0x6BA8 # + 0x6BA9, //0x462B 0x6BA9 # + 0x6BAC, //0x462C 0x6BAC # + 0x6BAD, //0x462D 0x6BAD # + 0x6BAE, //0x462E 0x6BAE # + 0x6BB0, //0x462F 0x6BB0 # + 0x6BB8, //0x4630 0x6BB8 # + 0x6BB9, //0x4631 0x6BB9 # + 0x6BBD, //0x4632 0x6BBD # + 0x6BBE, //0x4633 0x6BBE # + 0x6BC3, //0x4634 0x6BC3 # + 0x6BC4, //0x4635 0x6BC4 # + 0x6BC9, //0x4636 0x6BC9 # + 0x6BCC, //0x4637 0x6BCC # + 0x6BD6, //0x4638 0x6BD6 # + 0x6BDA, //0x4639 0x6BDA # + 0x6BE1, //0x463A 0x6BE1 # + 0x6BE3, //0x463B 0x6BE3 # + 0x6BE6, //0x463C 0x6BE6 # + 0x6BE7, //0x463D 0x6BE7 # + 0x6BEE, //0x463E 0x6BEE # + 0x6BF1, //0x463F 0x6BF1 # + 0x6BF7, //0x4640 0x6BF7 # + 0x6BF9, //0x4641 0x6BF9 # + 0x6BFF, //0x4642 0x6BFF # + 0x6C02, //0x4643 0x6C02 # + 0x6C04, //0x4644 0x6C04 # + 0x6C05, //0x4645 0x6C05 # + 0x6C09, //0x4646 0x6C09 # + 0x6C0D, //0x4647 0x6C0D # + 0x6C0E, //0x4648 0x6C0E # + 0x6C10, //0x4649 0x6C10 # + 0x6C12, //0x464A 0x6C12 # + 0x6C19, //0x464B 0x6C19 # + 0x6C1F, //0x464C 0x6C1F # + 0x6C26, //0x464D 0x6C26 # + 0x6C27, //0x464E 0x6C27 # + 0x6C28, //0x464F 0x6C28 # + 0x6C2C, //0x4650 0x6C2C # + 0x6C2E, //0x4651 0x6C2E # + 0x6C33, //0x4652 0x6C33 # + 0x6C35, //0x4653 0x6C35 # + 0x6C36, //0x4654 0x6C36 # + 0x6C3A, //0x4655 0x6C3A # + 0x6C3B, //0x4656 0x6C3B # + 0x6C3F, //0x4657 0x6C3F # + 0x6C4A, //0x4658 0x6C4A # + 0x6C4B, //0x4659 0x6C4B # + 0x6C4D, //0x465A 0x6C4D # + 0x6C4F, //0x465B 0x6C4F # + 0x6C52, //0x465C 0x6C52 # + 0x6C54, //0x465D 0x6C54 # + 0x6C59, //0x465E 0x6C59 # + 0x6C5B, //0x465F 0x6C5B # + 0x6C5C, //0x4660 0x6C5C # + 0x6C6B, //0x4661 0x6C6B # + 0x6C6D, //0x4662 0x6C6D # + 0x6C6F, //0x4663 0x6C6F # + 0x6C74, //0x4664 0x6C74 # + 0x6C76, //0x4665 0x6C76 # + 0x6C78, //0x4666 0x6C78 # + 0x6C79, //0x4667 0x6C79 # + 0x6C7B, //0x4668 0x6C7B # + 0x6C85, //0x4669 0x6C85 # + 0x6C86, //0x466A 0x6C86 # + 0x6C87, //0x466B 0x6C87 # + 0x6C89, //0x466C 0x6C89 # + 0x6C94, //0x466D 0x6C94 # + 0x6C95, //0x466E 0x6C95 # + 0x6C97, //0x466F 0x6C97 # + 0x6C98, //0x4670 0x6C98 # + 0x6C9C, //0x4671 0x6C9C # + 0x6C9F, //0x4672 0x6C9F # + 0x6CB0, //0x4673 0x6CB0 # + 0x6CB2, //0x4674 0x6CB2 # + 0x6CB4, //0x4675 0x6CB4 # + 0x6CC2, //0x4676 0x6CC2 # + 0x6CC6, //0x4677 0x6CC6 # + 0x6CCD, //0x4678 0x6CCD # + 0x6CCF, //0x4679 0x6CCF # + 0x6CD0, //0x467A 0x6CD0 # + 0x6CD1, //0x467B 0x6CD1 # + 0x6CD2, //0x467C 0x6CD2 # + 0x6CD4, //0x467D 0x6CD4 # + 0x6CD6 //0x467E 0x6CD6 # + }, + //39区 + { + 0x6CDA, //0x4721 0x6CDA # + 0x6CDC, //0x4722 0x6CDC # + 0x6CE0, //0x4723 0x6CE0 # + 0x6CE7, //0x4724 0x6CE7 # + 0x6CE9, //0x4725 0x6CE9 # + 0x6CEB, //0x4726 0x6CEB # + 0x6CEC, //0x4727 0x6CEC # + 0x6CEE, //0x4728 0x6CEE # + 0x6CF2, //0x4729 0x6CF2 # + 0x6CF4, //0x472A 0x6CF4 # + 0x6D04, //0x472B 0x6D04 # + 0x6D07, //0x472C 0x6D07 # + 0x6D0A, //0x472D 0x6D0A # + 0x6D0E, //0x472E 0x6D0E # + 0x6D0F, //0x472F 0x6D0F # + 0x6D11, //0x4730 0x6D11 # + 0x6D13, //0x4731 0x6D13 # + 0x6D1A, //0x4732 0x6D1A # + 0x6D26, //0x4733 0x6D26 # + 0x6D27, //0x4734 0x6D27 # + 0x6D28, //0x4735 0x6D28 # + 0x6C67, //0x4736 0x6C67 # + 0x6D2E, //0x4737 0x6D2E # + 0x6D2F, //0x4738 0x6D2F # + 0x6D31, //0x4739 0x6D31 # + 0x6D39, //0x473A 0x6D39 # + 0x6D3C, //0x473B 0x6D3C # + 0x6D3F, //0x473C 0x6D3F # + 0x6D57, //0x473D 0x6D57 # + 0x6D5E, //0x473E 0x6D5E # + 0x6D5F, //0x473F 0x6D5F # + 0x6D61, //0x4740 0x6D61 # + 0x6D65, //0x4741 0x6D65 # + 0x6D67, //0x4742 0x6D67 # + 0x6D6F, //0x4743 0x6D6F # + 0x6D70, //0x4744 0x6D70 # + 0x6D7C, //0x4745 0x6D7C # + 0x6D82, //0x4746 0x6D82 # + 0x6D87, //0x4747 0x6D87 # + 0x6D91, //0x4748 0x6D91 # + 0x6D92, //0x4749 0x6D92 # + 0x6D94, //0x474A 0x6D94 # + 0x6D96, //0x474B 0x6D96 # + 0x6D97, //0x474C 0x6D97 # + 0x6D98, //0x474D 0x6D98 # + 0x6DAA, //0x474E 0x6DAA # + 0x6DAC, //0x474F 0x6DAC # + 0x6DB4, //0x4750 0x6DB4 # + 0x6DB7, //0x4751 0x6DB7 # + 0x6DB9, //0x4752 0x6DB9 # + 0x6DBD, //0x4753 0x6DBD # + 0x6DBF, //0x4754 0x6DBF # + 0x6DC4, //0x4755 0x6DC4 # + 0x6DC8, //0x4756 0x6DC8 # + 0x6DCA, //0x4757 0x6DCA # + 0x6DCE, //0x4758 0x6DCE # + 0x6DCF, //0x4759 0x6DCF # + 0x6DD6, //0x475A 0x6DD6 # + 0x6DDB, //0x475B 0x6DDB # + 0x6DDD, //0x475C 0x6DDD # + 0x6DDF, //0x475D 0x6DDF # + 0x6DE0, //0x475E 0x6DE0 # + 0x6DE2, //0x475F 0x6DE2 # + 0x6DE5, //0x4760 0x6DE5 # + 0x6DE9, //0x4761 0x6DE9 # + 0x6DEF, //0x4762 0x6DEF # + 0x6DF0, //0x4763 0x6DF0 # + 0x6DF4, //0x4764 0x6DF4 # + 0x6DF6, //0x4765 0x6DF6 # + 0x6DFC, //0x4766 0x6DFC # + 0x6E00, //0x4767 0x6E00 # + 0x6E04, //0x4768 0x6E04 # + 0x6E1E, //0x4769 0x6E1E # + 0x6E22, //0x476A 0x6E22 # + 0x6E27, //0x476B 0x6E27 # + 0x6E32, //0x476C 0x6E32 # + 0x6E36, //0x476D 0x6E36 # + 0x6E39, //0x476E 0x6E39 # + 0x6E3B, //0x476F 0x6E3B # + 0x6E3C, //0x4770 0x6E3C # + 0x6E44, //0x4771 0x6E44 # + 0x6E45, //0x4772 0x6E45 # + 0x6E48, //0x4773 0x6E48 # + 0x6E49, //0x4774 0x6E49 # + 0x6E4B, //0x4775 0x6E4B # + 0x6E4F, //0x4776 0x6E4F # + 0x6E51, //0x4777 0x6E51 # + 0x6E52, //0x4778 0x6E52 # + 0x6E53, //0x4779 0x6E53 # + 0x6E54, //0x477A 0x6E54 # + 0x6E57, //0x477B 0x6E57 # + 0x6E5C, //0x477C 0x6E5C # + 0x6E5D, //0x477D 0x6E5D # + 0x6E5E //0x477E 0x6E5E # + }, + //40区 + { + 0x6E62, //0x4821 0x6E62 # + 0x6E63, //0x4822 0x6E63 # + 0x6E68, //0x4823 0x6E68 # + 0x6E73, //0x4824 0x6E73 # + 0x6E7B, //0x4825 0x6E7B # + 0x6E7D, //0x4826 0x6E7D # + 0x6E8D, //0x4827 0x6E8D # + 0x6E93, //0x4828 0x6E93 # + 0x6E99, //0x4829 0x6E99 # + 0x6EA0, //0x482A 0x6EA0 # + 0x6EA7, //0x482B 0x6EA7 # + 0x6EAD, //0x482C 0x6EAD # + 0x6EAE, //0x482D 0x6EAE # + 0x6EB1, //0x482E 0x6EB1 # + 0x6EB3, //0x482F 0x6EB3 # + 0x6EBB, //0x4830 0x6EBB # + 0x6EBF, //0x4831 0x6EBF # + 0x6EC0, //0x4832 0x6EC0 # + 0x6EC1, //0x4833 0x6EC1 # + 0x6EC3, //0x4834 0x6EC3 # + 0x6EC7, //0x4835 0x6EC7 # + 0x6EC8, //0x4836 0x6EC8 # + 0x6ECA, //0x4837 0x6ECA # + 0x6ECD, //0x4838 0x6ECD # + 0x6ECE, //0x4839 0x6ECE # + 0x6ECF, //0x483A 0x6ECF # + 0x6EEB, //0x483B 0x6EEB # + 0x6EED, //0x483C 0x6EED # + 0x6EEE, //0x483D 0x6EEE # + 0x6EF9, //0x483E 0x6EF9 # + 0x6EFB, //0x483F 0x6EFB # + 0x6EFD, //0x4840 0x6EFD # + 0x6F04, //0x4841 0x6F04 # + 0x6F08, //0x4842 0x6F08 # + 0x6F0A, //0x4843 0x6F0A # + 0x6F0C, //0x4844 0x6F0C # + 0x6F0D, //0x4845 0x6F0D # + 0x6F16, //0x4846 0x6F16 # + 0x6F18, //0x4847 0x6F18 # + 0x6F1A, //0x4848 0x6F1A # + 0x6F1B, //0x4849 0x6F1B # + 0x6F26, //0x484A 0x6F26 # + 0x6F29, //0x484B 0x6F29 # + 0x6F2A, //0x484C 0x6F2A # + 0x6F2F, //0x484D 0x6F2F # + 0x6F30, //0x484E 0x6F30 # + 0x6F33, //0x484F 0x6F33 # + 0x6F36, //0x4850 0x6F36 # + 0x6F3B, //0x4851 0x6F3B # + 0x6F3C, //0x4852 0x6F3C # + 0x6F2D, //0x4853 0x6F2D # + 0x6F4F, //0x4854 0x6F4F # + 0x6F51, //0x4855 0x6F51 # + 0x6F52, //0x4856 0x6F52 # + 0x6F53, //0x4857 0x6F53 # + 0x6F57, //0x4858 0x6F57 # + 0x6F59, //0x4859 0x6F59 # + 0x6F5A, //0x485A 0x6F5A # + 0x6F5D, //0x485B 0x6F5D # + 0x6F5E, //0x485C 0x6F5E # + 0x6F61, //0x485D 0x6F61 # + 0x6F62, //0x485E 0x6F62 # + 0x6F68, //0x485F 0x6F68 # + 0x6F6C, //0x4860 0x6F6C # + 0x6F7D, //0x4861 0x6F7D # + 0x6F7E, //0x4862 0x6F7E # + 0x6F83, //0x4863 0x6F83 # + 0x6F87, //0x4864 0x6F87 # + 0x6F88, //0x4865 0x6F88 # + 0x6F8B, //0x4866 0x6F8B # + 0x6F8C, //0x4867 0x6F8C # + 0x6F8D, //0x4868 0x6F8D # + 0x6F90, //0x4869 0x6F90 # + 0x6F92, //0x486A 0x6F92 # + 0x6F93, //0x486B 0x6F93 # + 0x6F94, //0x486C 0x6F94 # + 0x6F96, //0x486D 0x6F96 # + 0x6F9A, //0x486E 0x6F9A # + 0x6F9F, //0x486F 0x6F9F # + 0x6FA0, //0x4870 0x6FA0 # + 0x6FA5, //0x4871 0x6FA5 # + 0x6FA6, //0x4872 0x6FA6 # + 0x6FA7, //0x4873 0x6FA7 # + 0x6FA8, //0x4874 0x6FA8 # + 0x6FAE, //0x4875 0x6FAE # + 0x6FAF, //0x4876 0x6FAF # + 0x6FB0, //0x4877 0x6FB0 # + 0x6FB5, //0x4878 0x6FB5 # + 0x6FB6, //0x4879 0x6FB6 # + 0x6FBC, //0x487A 0x6FBC # + 0x6FC5, //0x487B 0x6FC5 # + 0x6FC7, //0x487C 0x6FC7 # + 0x6FC8, //0x487D 0x6FC8 # + 0x6FCA //0x487E 0x6FCA # + }, + //41区 + { + 0x6FDA, //0x4921 0x6FDA # + 0x6FDE, //0x4922 0x6FDE # + 0x6FE8, //0x4923 0x6FE8 # + 0x6FE9, //0x4924 0x6FE9 # + 0x6FF0, //0x4925 0x6FF0 # + 0x6FF5, //0x4926 0x6FF5 # + 0x6FF9, //0x4927 0x6FF9 # + 0x6FFC, //0x4928 0x6FFC # + 0x6FFD, //0x4929 0x6FFD # + 0x7000, //0x492A 0x7000 # + 0x7005, //0x492B 0x7005 # + 0x7006, //0x492C 0x7006 # + 0x7007, //0x492D 0x7007 # + 0x700D, //0x492E 0x700D # + 0x7017, //0x492F 0x7017 # + 0x7020, //0x4930 0x7020 # + 0x7023, //0x4931 0x7023 # + 0x702F, //0x4932 0x702F # + 0x7034, //0x4933 0x7034 # + 0x7037, //0x4934 0x7037 # + 0x7039, //0x4935 0x7039 # + 0x703C, //0x4936 0x703C # + 0x7043, //0x4937 0x7043 # + 0x7044, //0x4938 0x7044 # + 0x7048, //0x4939 0x7048 # + 0x7049, //0x493A 0x7049 # + 0x704A, //0x493B 0x704A # + 0x704B, //0x493C 0x704B # + 0x7054, //0x493D 0x7054 # + 0x7055, //0x493E 0x7055 # + 0x705D, //0x493F 0x705D # + 0x705E, //0x4940 0x705E # + 0x704E, //0x4941 0x704E # + 0x7064, //0x4942 0x7064 # + 0x7065, //0x4943 0x7065 # + 0x706C, //0x4944 0x706C # + 0x706E, //0x4945 0x706E # + 0x7075, //0x4946 0x7075 # + 0x7076, //0x4947 0x7076 # + 0x707E, //0x4948 0x707E # + 0x7081, //0x4949 0x7081 # + 0x7085, //0x494A 0x7085 # + 0x7086, //0x494B 0x7086 # + 0x7094, //0x494C 0x7094 # + 0x7095, //0x494D 0x7095 # + 0x7096, //0x494E 0x7096 # + 0x7097, //0x494F 0x7097 # + 0x7098, //0x4950 0x7098 # + 0x709B, //0x4951 0x709B # + 0x70A4, //0x4952 0x70A4 # + 0x70AB, //0x4953 0x70AB # + 0x70B0, //0x4954 0x70B0 # + 0x70B1, //0x4955 0x70B1 # + 0x70B4, //0x4956 0x70B4 # + 0x70B7, //0x4957 0x70B7 # + 0x70CA, //0x4958 0x70CA # + 0x70D1, //0x4959 0x70D1 # + 0x70D3, //0x495A 0x70D3 # + 0x70D4, //0x495B 0x70D4 # + 0x70D5, //0x495C 0x70D5 # + 0x70D6, //0x495D 0x70D6 # + 0x70D8, //0x495E 0x70D8 # + 0x70DC, //0x495F 0x70DC # + 0x70E4, //0x4960 0x70E4 # + 0x70FA, //0x4961 0x70FA # + 0x7103, //0x4962 0x7103 # + 0x7104, //0x4963 0x7104 # + 0x7105, //0x4964 0x7105 # + 0x7106, //0x4965 0x7106 # + 0x7107, //0x4966 0x7107 # + 0x710B, //0x4967 0x710B # + 0x710C, //0x4968 0x710C # + 0x710F, //0x4969 0x710F # + 0x711E, //0x496A 0x711E # + 0x7120, //0x496B 0x7120 # + 0x712B, //0x496C 0x712B # + 0x712D, //0x496D 0x712D # + 0x712F, //0x496E 0x712F # + 0x7130, //0x496F 0x7130 # + 0x7131, //0x4970 0x7131 # + 0x7138, //0x4971 0x7138 # + 0x7141, //0x4972 0x7141 # + 0x7145, //0x4973 0x7145 # + 0x7146, //0x4974 0x7146 # + 0x7147, //0x4975 0x7147 # + 0x714A, //0x4976 0x714A # + 0x714B, //0x4977 0x714B # + 0x7150, //0x4978 0x7150 # + 0x7152, //0x4979 0x7152 # + 0x7157, //0x497A 0x7157 # + 0x715A, //0x497B 0x715A # + 0x715C, //0x497C 0x715C # + 0x715E, //0x497D 0x715E # + 0x7160 //0x497E 0x7160 # + }, + //42区 + { + 0x7168, //0x4A21 0x7168 # + 0x7179, //0x4A22 0x7179 # + 0x7180, //0x4A23 0x7180 # + 0x7185, //0x4A24 0x7185 # + 0x7187, //0x4A25 0x7187 # + 0x718C, //0x4A26 0x718C # + 0x7192, //0x4A27 0x7192 # + 0x719A, //0x4A28 0x719A # + 0x719B, //0x4A29 0x719B # + 0x71A0, //0x4A2A 0x71A0 # + 0x71A2, //0x4A2B 0x71A2 # + 0x71AF, //0x4A2C 0x71AF # + 0x71B0, //0x4A2D 0x71B0 # + 0x71B2, //0x4A2E 0x71B2 # + 0x71B3, //0x4A2F 0x71B3 # + 0x71BA, //0x4A30 0x71BA # + 0x71BF, //0x4A31 0x71BF # + 0x71C0, //0x4A32 0x71C0 # + 0x71C1, //0x4A33 0x71C1 # + 0x71C4, //0x4A34 0x71C4 # + 0x71CB, //0x4A35 0x71CB # + 0x71CC, //0x4A36 0x71CC # + 0x71D3, //0x4A37 0x71D3 # + 0x71D6, //0x4A38 0x71D6 # + 0x71D9, //0x4A39 0x71D9 # + 0x71DA, //0x4A3A 0x71DA # + 0x71DC, //0x4A3B 0x71DC # + 0x71F8, //0x4A3C 0x71F8 # + 0x71FE, //0x4A3D 0x71FE # + 0x7200, //0x4A3E 0x7200 # + 0x7207, //0x4A3F 0x7207 # + 0x7208, //0x4A40 0x7208 # + 0x7209, //0x4A41 0x7209 # + 0x7213, //0x4A42 0x7213 # + 0x7217, //0x4A43 0x7217 # + 0x721A, //0x4A44 0x721A # + 0x721D, //0x4A45 0x721D # + 0x721F, //0x4A46 0x721F # + 0x7224, //0x4A47 0x7224 # + 0x722B, //0x4A48 0x722B # + 0x722F, //0x4A49 0x722F # + 0x7234, //0x4A4A 0x7234 # + 0x7238, //0x4A4B 0x7238 # + 0x7239, //0x4A4C 0x7239 # + 0x7241, //0x4A4D 0x7241 # + 0x7242, //0x4A4E 0x7242 # + 0x7243, //0x4A4F 0x7243 # + 0x7245, //0x4A50 0x7245 # + 0x724E, //0x4A51 0x724E # + 0x724F, //0x4A52 0x724F # + 0x7250, //0x4A53 0x7250 # + 0x7253, //0x4A54 0x7253 # + 0x7255, //0x4A55 0x7255 # + 0x7256, //0x4A56 0x7256 # + 0x725A, //0x4A57 0x725A # + 0x725C, //0x4A58 0x725C # + 0x725E, //0x4A59 0x725E # + 0x7260, //0x4A5A 0x7260 # + 0x7263, //0x4A5B 0x7263 # + 0x7268, //0x4A5C 0x7268 # + 0x726B, //0x4A5D 0x726B # + 0x726E, //0x4A5E 0x726E # + 0x726F, //0x4A5F 0x726F # + 0x7271, //0x4A60 0x7271 # + 0x7277, //0x4A61 0x7277 # + 0x7278, //0x4A62 0x7278 # + 0x727B, //0x4A63 0x727B # + 0x727C, //0x4A64 0x727C # + 0x727F, //0x4A65 0x727F # + 0x7284, //0x4A66 0x7284 # + 0x7289, //0x4A67 0x7289 # + 0x728D, //0x4A68 0x728D # + 0x728E, //0x4A69 0x728E # + 0x7293, //0x4A6A 0x7293 # + 0x729B, //0x4A6B 0x729B # + 0x72A8, //0x4A6C 0x72A8 # + 0x72AD, //0x4A6D 0x72AD # + 0x72AE, //0x4A6E 0x72AE # + 0x72B1, //0x4A6F 0x72B1 # + 0x72B4, //0x4A70 0x72B4 # + 0x72BE, //0x4A71 0x72BE # + 0x72C1, //0x4A72 0x72C1 # + 0x72C7, //0x4A73 0x72C7 # + 0x72C9, //0x4A74 0x72C9 # + 0x72CC, //0x4A75 0x72CC # + 0x72D5, //0x4A76 0x72D5 # + 0x72D6, //0x4A77 0x72D6 # + 0x72D8, //0x4A78 0x72D8 # + 0x72DF, //0x4A79 0x72DF # + 0x72E5, //0x4A7A 0x72E5 # + 0x72F3, //0x4A7B 0x72F3 # + 0x72F4, //0x4A7C 0x72F4 # + 0x72FA, //0x4A7D 0x72FA # + 0x72FB //0x4A7E 0x72FB # + }, + //43区 + { + 0x72FE, //0x4B21 0x72FE # + 0x7302, //0x4B22 0x7302 # + 0x7304, //0x4B23 0x7304 # + 0x7305, //0x4B24 0x7305 # + 0x7307, //0x4B25 0x7307 # + 0x730B, //0x4B26 0x730B # + 0x730D, //0x4B27 0x730D # + 0x7312, //0x4B28 0x7312 # + 0x7313, //0x4B29 0x7313 # + 0x7318, //0x4B2A 0x7318 # + 0x7319, //0x4B2B 0x7319 # + 0x731E, //0x4B2C 0x731E # + 0x7322, //0x4B2D 0x7322 # + 0x7324, //0x4B2E 0x7324 # + 0x7327, //0x4B2F 0x7327 # + 0x7328, //0x4B30 0x7328 # + 0x732C, //0x4B31 0x732C # + 0x7331, //0x4B32 0x7331 # + 0x7332, //0x4B33 0x7332 # + 0x7335, //0x4B34 0x7335 # + 0x733A, //0x4B35 0x733A # + 0x733B, //0x4B36 0x733B # + 0x733D, //0x4B37 0x733D # + 0x7343, //0x4B38 0x7343 # + 0x734D, //0x4B39 0x734D # + 0x7350, //0x4B3A 0x7350 # + 0x7352, //0x4B3B 0x7352 # + 0x7356, //0x4B3C 0x7356 # + 0x7358, //0x4B3D 0x7358 # + 0x735D, //0x4B3E 0x735D # + 0x735E, //0x4B3F 0x735E # + 0x735F, //0x4B40 0x735F # + 0x7360, //0x4B41 0x7360 # + 0x7366, //0x4B42 0x7366 # + 0x7367, //0x4B43 0x7367 # + 0x7369, //0x4B44 0x7369 # + 0x736B, //0x4B45 0x736B # + 0x736C, //0x4B46 0x736C # + 0x736E, //0x4B47 0x736E # + 0x736F, //0x4B48 0x736F # + 0x7371, //0x4B49 0x7371 # + 0x7377, //0x4B4A 0x7377 # + 0x7379, //0x4B4B 0x7379 # + 0x737C, //0x4B4C 0x737C # + 0x7380, //0x4B4D 0x7380 # + 0x7381, //0x4B4E 0x7381 # + 0x7383, //0x4B4F 0x7383 # + 0x7385, //0x4B50 0x7385 # + 0x7386, //0x4B51 0x7386 # + 0x738E, //0x4B52 0x738E # + 0x7390, //0x4B53 0x7390 # + 0x7393, //0x4B54 0x7393 # + 0x7395, //0x4B55 0x7395 # + 0x7397, //0x4B56 0x7397 # + 0x7398, //0x4B57 0x7398 # + 0x739C, //0x4B58 0x739C # + 0x739E, //0x4B59 0x739E # + 0x739F, //0x4B5A 0x739F # + 0x73A0, //0x4B5B 0x73A0 # + 0x73A2, //0x4B5C 0x73A2 # + 0x73A5, //0x4B5D 0x73A5 # + 0x73A6, //0x4B5E 0x73A6 # + 0x73AA, //0x4B5F 0x73AA # + 0x73AB, //0x4B60 0x73AB # + 0x73AD, //0x4B61 0x73AD # + 0x73B5, //0x4B62 0x73B5 # + 0x73B7, //0x4B63 0x73B7 # + 0x73B9, //0x4B64 0x73B9 # + 0x73BC, //0x4B65 0x73BC # + 0x73BD, //0x4B66 0x73BD # + 0x73BF, //0x4B67 0x73BF # + 0x73C5, //0x4B68 0x73C5 # + 0x73C6, //0x4B69 0x73C6 # + 0x73C9, //0x4B6A 0x73C9 # + 0x73CB, //0x4B6B 0x73CB # + 0x73CC, //0x4B6C 0x73CC # + 0x73CF, //0x4B6D 0x73CF # + 0x73D2, //0x4B6E 0x73D2 # + 0x73D3, //0x4B6F 0x73D3 # + 0x73D6, //0x4B70 0x73D6 # + 0x73D9, //0x4B71 0x73D9 # + 0x73DD, //0x4B72 0x73DD # + 0x73E1, //0x4B73 0x73E1 # + 0x73E3, //0x4B74 0x73E3 # + 0x73E6, //0x4B75 0x73E6 # + 0x73E7, //0x4B76 0x73E7 # + 0x73E9, //0x4B77 0x73E9 # + 0x73F4, //0x4B78 0x73F4 # + 0x73F5, //0x4B79 0x73F5 # + 0x73F7, //0x4B7A 0x73F7 # + 0x73F9, //0x4B7B 0x73F9 # + 0x73FA, //0x4B7C 0x73FA # + 0x73FB, //0x4B7D 0x73FB # + 0x73FD //0x4B7E 0x73FD # + }, + //44区 + { + 0x73FF, //0x4C21 0x73FF # + 0x7400, //0x4C22 0x7400 # + 0x7401, //0x4C23 0x7401 # + 0x7404, //0x4C24 0x7404 # + 0x7407, //0x4C25 0x7407 # + 0x740A, //0x4C26 0x740A # + 0x7411, //0x4C27 0x7411 # + 0x741A, //0x4C28 0x741A # + 0x741B, //0x4C29 0x741B # + 0x7424, //0x4C2A 0x7424 # + 0x7426, //0x4C2B 0x7426 # + 0x7428, //0x4C2C 0x7428 # + 0x7429, //0x4C2D 0x7429 # + 0x742A, //0x4C2E 0x742A # + 0x742B, //0x4C2F 0x742B # + 0x742C, //0x4C30 0x742C # + 0x742D, //0x4C31 0x742D # + 0x742E, //0x4C32 0x742E # + 0x742F, //0x4C33 0x742F # + 0x7430, //0x4C34 0x7430 # + 0x7431, //0x4C35 0x7431 # + 0x7439, //0x4C36 0x7439 # + 0x7440, //0x4C37 0x7440 # + 0x7443, //0x4C38 0x7443 # + 0x7444, //0x4C39 0x7444 # + 0x7446, //0x4C3A 0x7446 # + 0x7447, //0x4C3B 0x7447 # + 0x744B, //0x4C3C 0x744B # + 0x744D, //0x4C3D 0x744D # + 0x7451, //0x4C3E 0x7451 # + 0x7452, //0x4C3F 0x7452 # + 0x7457, //0x4C40 0x7457 # + 0x745D, //0x4C41 0x745D # + 0x7462, //0x4C42 0x7462 # + 0x7466, //0x4C43 0x7466 # + 0x7467, //0x4C44 0x7467 # + 0x7468, //0x4C45 0x7468 # + 0x746B, //0x4C46 0x746B # + 0x746D, //0x4C47 0x746D # + 0x746E, //0x4C48 0x746E # + 0x7471, //0x4C49 0x7471 # + 0x7472, //0x4C4A 0x7472 # + 0x7480, //0x4C4B 0x7480 # + 0x7481, //0x4C4C 0x7481 # + 0x7485, //0x4C4D 0x7485 # + 0x7486, //0x4C4E 0x7486 # + 0x7487, //0x4C4F 0x7487 # + 0x7489, //0x4C50 0x7489 # + 0x748F, //0x4C51 0x748F # + 0x7490, //0x4C52 0x7490 # + 0x7491, //0x4C53 0x7491 # + 0x7492, //0x4C54 0x7492 # + 0x7498, //0x4C55 0x7498 # + 0x7499, //0x4C56 0x7499 # + 0x749A, //0x4C57 0x749A # + 0x749C, //0x4C58 0x749C # + 0x749F, //0x4C59 0x749F # + 0x74A0, //0x4C5A 0x74A0 # + 0x74A1, //0x4C5B 0x74A1 # + 0x74A3, //0x4C5C 0x74A3 # + 0x74A6, //0x4C5D 0x74A6 # + 0x74A8, //0x4C5E 0x74A8 # + 0x74A9, //0x4C5F 0x74A9 # + 0x74AA, //0x4C60 0x74AA # + 0x74AB, //0x4C61 0x74AB # + 0x74AE, //0x4C62 0x74AE # + 0x74AF, //0x4C63 0x74AF # + 0x74B1, //0x4C64 0x74B1 # + 0x74B2, //0x4C65 0x74B2 # + 0x74B5, //0x4C66 0x74B5 # + 0x74B9, //0x4C67 0x74B9 # + 0x74BB, //0x4C68 0x74BB # + 0x74BF, //0x4C69 0x74BF # + 0x74C8, //0x4C6A 0x74C8 # + 0x74C9, //0x4C6B 0x74C9 # + 0x74CC, //0x4C6C 0x74CC # + 0x74D0, //0x4C6D 0x74D0 # + 0x74D3, //0x4C6E 0x74D3 # + 0x74D8, //0x4C6F 0x74D8 # + 0x74DA, //0x4C70 0x74DA # + 0x74DB, //0x4C71 0x74DB # + 0x74DE, //0x4C72 0x74DE # + 0x74DF, //0x4C73 0x74DF # + 0x74E4, //0x4C74 0x74E4 # + 0x74E8, //0x4C75 0x74E8 # + 0x74EA, //0x4C76 0x74EA # + 0x74EB, //0x4C77 0x74EB # + 0x74EF, //0x4C78 0x74EF # + 0x74F4, //0x4C79 0x74F4 # + 0x74FA, //0x4C7A 0x74FA # + 0x74FB, //0x4C7B 0x74FB # + 0x74FC, //0x4C7C 0x74FC # + 0x74FF, //0x4C7D 0x74FF # + 0x7506 //0x4C7E 0x7506 # + }, + //45区 + { + 0x7512, //0x4D21 0x7512 # + 0x7516, //0x4D22 0x7516 # + 0x7517, //0x4D23 0x7517 # + 0x7520, //0x4D24 0x7520 # + 0x7521, //0x4D25 0x7521 # + 0x7524, //0x4D26 0x7524 # + 0x7527, //0x4D27 0x7527 # + 0x7529, //0x4D28 0x7529 # + 0x752A, //0x4D29 0x752A # + 0x752F, //0x4D2A 0x752F # + 0x7536, //0x4D2B 0x7536 # + 0x7539, //0x4D2C 0x7539 # + 0x753D, //0x4D2D 0x753D # + 0x753E, //0x4D2E 0x753E # + 0x753F, //0x4D2F 0x753F # + 0x7540, //0x4D30 0x7540 # + 0x7543, //0x4D31 0x7543 # + 0x7547, //0x4D32 0x7547 # + 0x7548, //0x4D33 0x7548 # + 0x754E, //0x4D34 0x754E # + 0x7550, //0x4D35 0x7550 # + 0x7552, //0x4D36 0x7552 # + 0x7557, //0x4D37 0x7557 # + 0x755E, //0x4D38 0x755E # + 0x755F, //0x4D39 0x755F # + 0x7561, //0x4D3A 0x7561 # + 0x756F, //0x4D3B 0x756F # + 0x7571, //0x4D3C 0x7571 # + 0x7579, //0x4D3D 0x7579 # + 0x757A, //0x4D3E 0x757A # + 0x757B, //0x4D3F 0x757B # + 0x757C, //0x4D40 0x757C # + 0x757D, //0x4D41 0x757D # + 0x757E, //0x4D42 0x757E # + 0x7581, //0x4D43 0x7581 # + 0x7585, //0x4D44 0x7585 # + 0x7590, //0x4D45 0x7590 # + 0x7592, //0x4D46 0x7592 # + 0x7593, //0x4D47 0x7593 # + 0x7595, //0x4D48 0x7595 # + 0x7599, //0x4D49 0x7599 # + 0x759C, //0x4D4A 0x759C # + 0x75A2, //0x4D4B 0x75A2 # + 0x75A4, //0x4D4C 0x75A4 # + 0x75B4, //0x4D4D 0x75B4 # + 0x75BA, //0x4D4E 0x75BA # + 0x75BF, //0x4D4F 0x75BF # + 0x75C0, //0x4D50 0x75C0 # + 0x75C1, //0x4D51 0x75C1 # + 0x75C4, //0x4D52 0x75C4 # + 0x75C6, //0x4D53 0x75C6 # + 0x75CC, //0x4D54 0x75CC # + 0x75CE, //0x4D55 0x75CE # + 0x75CF, //0x4D56 0x75CF # + 0x75D7, //0x4D57 0x75D7 # + 0x75DC, //0x4D58 0x75DC # + 0x75DF, //0x4D59 0x75DF # + 0x75E0, //0x4D5A 0x75E0 # + 0x75E1, //0x4D5B 0x75E1 # + 0x75E4, //0x4D5C 0x75E4 # + 0x75E7, //0x4D5D 0x75E7 # + 0x75EC, //0x4D5E 0x75EC # + 0x75EE, //0x4D5F 0x75EE # + 0x75EF, //0x4D60 0x75EF # + 0x75F1, //0x4D61 0x75F1 # + 0x75F9, //0x4D62 0x75F9 # + 0x7600, //0x4D63 0x7600 # + 0x7602, //0x4D64 0x7602 # + 0x7603, //0x4D65 0x7603 # + 0x7604, //0x4D66 0x7604 # + 0x7607, //0x4D67 0x7607 # + 0x7608, //0x4D68 0x7608 # + 0x760A, //0x4D69 0x760A # + 0x760C, //0x4D6A 0x760C # + 0x760F, //0x4D6B 0x760F # + 0x7612, //0x4D6C 0x7612 # + 0x7613, //0x4D6D 0x7613 # + 0x7615, //0x4D6E 0x7615 # + 0x7616, //0x4D6F 0x7616 # + 0x7619, //0x4D70 0x7619 # + 0x761B, //0x4D71 0x761B # + 0x761C, //0x4D72 0x761C # + 0x761D, //0x4D73 0x761D # + 0x761E, //0x4D74 0x761E # + 0x7623, //0x4D75 0x7623 # + 0x7625, //0x4D76 0x7625 # + 0x7626, //0x4D77 0x7626 # + 0x7629, //0x4D78 0x7629 # + 0x762D, //0x4D79 0x762D # + 0x7632, //0x4D7A 0x7632 # + 0x7633, //0x4D7B 0x7633 # + 0x7635, //0x4D7C 0x7635 # + 0x7638, //0x4D7D 0x7638 # + 0x7639 //0x4D7E 0x7639 # + }, + //46区 + { + 0x763A, //0x4E21 0x763A # + 0x763C, //0x4E22 0x763C # + 0x764A, //0x4E23 0x764A # + 0x7640, //0x4E24 0x7640 # + 0x7641, //0x4E25 0x7641 # + 0x7643, //0x4E26 0x7643 # + 0x7644, //0x4E27 0x7644 # + 0x7645, //0x4E28 0x7645 # + 0x7649, //0x4E29 0x7649 # + 0x764B, //0x4E2A 0x764B # + 0x7655, //0x4E2B 0x7655 # + 0x7659, //0x4E2C 0x7659 # + 0x765F, //0x4E2D 0x765F # + 0x7664, //0x4E2E 0x7664 # + 0x7665, //0x4E2F 0x7665 # + 0x766D, //0x4E30 0x766D # + 0x766E, //0x4E31 0x766E # + 0x766F, //0x4E32 0x766F # + 0x7671, //0x4E33 0x7671 # + 0x7674, //0x4E34 0x7674 # + 0x7681, //0x4E35 0x7681 # + 0x7685, //0x4E36 0x7685 # + 0x768C, //0x4E37 0x768C # + 0x768D, //0x4E38 0x768D # + 0x7695, //0x4E39 0x7695 # + 0x769B, //0x4E3A 0x769B # + 0x769C, //0x4E3B 0x769C # + 0x769D, //0x4E3C 0x769D # + 0x769F, //0x4E3D 0x769F # + 0x76A0, //0x4E3E 0x76A0 # + 0x76A2, //0x4E3F 0x76A2 # + 0x76A3, //0x4E40 0x76A3 # + 0x76A4, //0x4E41 0x76A4 # + 0x76A5, //0x4E42 0x76A5 # + 0x76A6, //0x4E43 0x76A6 # + 0x76A7, //0x4E44 0x76A7 # + 0x76A8, //0x4E45 0x76A8 # + 0x76AA, //0x4E46 0x76AA # + 0x76AD, //0x4E47 0x76AD # + 0x76BD, //0x4E48 0x76BD # + 0x76C1, //0x4E49 0x76C1 # + 0x76C5, //0x4E4A 0x76C5 # + 0x76C9, //0x4E4B 0x76C9 # + 0x76CB, //0x4E4C 0x76CB # + 0x76CC, //0x4E4D 0x76CC # + 0x76CE, //0x4E4E 0x76CE # + 0x76D4, //0x4E4F 0x76D4 # + 0x76D9, //0x4E50 0x76D9 # + 0x76E0, //0x4E51 0x76E0 # + 0x76E6, //0x4E52 0x76E6 # + 0x76E8, //0x4E53 0x76E8 # + 0x76EC, //0x4E54 0x76EC # + 0x76F0, //0x4E55 0x76F0 # + 0x76F1, //0x4E56 0x76F1 # + 0x76F6, //0x4E57 0x76F6 # + 0x76F9, //0x4E58 0x76F9 # + 0x76FC, //0x4E59 0x76FC # + 0x7700, //0x4E5A 0x7700 # + 0x7706, //0x4E5B 0x7706 # + 0x770A, //0x4E5C 0x770A # + 0x770E, //0x4E5D 0x770E # + 0x7712, //0x4E5E 0x7712 # + 0x7714, //0x4E5F 0x7714 # + 0x7715, //0x4E60 0x7715 # + 0x7717, //0x4E61 0x7717 # + 0x7719, //0x4E62 0x7719 # + 0x771A, //0x4E63 0x771A # + 0x771C, //0x4E64 0x771C # + 0x7722, //0x4E65 0x7722 # + 0x7728, //0x4E66 0x7728 # + 0x772D, //0x4E67 0x772D # + 0x772E, //0x4E68 0x772E # + 0x772F, //0x4E69 0x772F # + 0x7734, //0x4E6A 0x7734 # + 0x7735, //0x4E6B 0x7735 # + 0x7736, //0x4E6C 0x7736 # + 0x7739, //0x4E6D 0x7739 # + 0x773D, //0x4E6E 0x773D # + 0x773E, //0x4E6F 0x773E # + 0x7742, //0x4E70 0x7742 # + 0x7745, //0x4E71 0x7745 # + 0x7746, //0x4E72 0x7746 # + 0x774A, //0x4E73 0x774A # + 0x774D, //0x4E74 0x774D # + 0x774E, //0x4E75 0x774E # + 0x774F, //0x4E76 0x774F # + 0x7752, //0x4E77 0x7752 # + 0x7756, //0x4E78 0x7756 # + 0x7757, //0x4E79 0x7757 # + 0x775C, //0x4E7A 0x775C # + 0x775E, //0x4E7B 0x775E # + 0x775F, //0x4E7C 0x775F # + 0x7760, //0x4E7D 0x7760 # + 0x7762 //0x4E7E 0x7762 # + }, + //47区 + { + 0x7764, //0x4F21 0x7764 # + 0x7767, //0x4F22 0x7767 # + 0x776A, //0x4F23 0x776A # + 0x776C, //0x4F24 0x776C # + 0x7770, //0x4F25 0x7770 # + 0x7772, //0x4F26 0x7772 # + 0x7773, //0x4F27 0x7773 # + 0x7774, //0x4F28 0x7774 # + 0x777A, //0x4F29 0x777A # + 0x777D, //0x4F2A 0x777D # + 0x7780, //0x4F2B 0x7780 # + 0x7784, //0x4F2C 0x7784 # + 0x778C, //0x4F2D 0x778C # + 0x778D, //0x4F2E 0x778D # + 0x7794, //0x4F2F 0x7794 # + 0x7795, //0x4F30 0x7795 # + 0x7796, //0x4F31 0x7796 # + 0x779A, //0x4F32 0x779A # + 0x779F, //0x4F33 0x779F # + 0x77A2, //0x4F34 0x77A2 # + 0x77A7, //0x4F35 0x77A7 # + 0x77AA, //0x4F36 0x77AA # + 0x77AE, //0x4F37 0x77AE # + 0x77AF, //0x4F38 0x77AF # + 0x77B1, //0x4F39 0x77B1 # + 0x77B5, //0x4F3A 0x77B5 # + 0x77BE, //0x4F3B 0x77BE # + 0x77C3, //0x4F3C 0x77C3 # + 0x77C9, //0x4F3D 0x77C9 # + 0x77D1, //0x4F3E 0x77D1 # + 0x77D2, //0x4F3F 0x77D2 # + 0x77D5, //0x4F40 0x77D5 # + 0x77D9, //0x4F41 0x77D9 # + 0x77DE, //0x4F42 0x77DE # + 0x77DF, //0x4F43 0x77DF # + 0x77E0, //0x4F44 0x77E0 # + 0x77E4, //0x4F45 0x77E4 # + 0x77E6, //0x4F46 0x77E6 # + 0x77EA, //0x4F47 0x77EA # + 0x77EC, //0x4F48 0x77EC # + 0x77F0, //0x4F49 0x77F0 # + 0x77F1, //0x4F4A 0x77F1 # + 0x77F4, //0x4F4B 0x77F4 # + 0x77F8, //0x4F4C 0x77F8 # + 0x77FB, //0x4F4D 0x77FB # + 0x7805, //0x4F4E 0x7805 # + 0x7806, //0x4F4F 0x7806 # + 0x7809, //0x4F50 0x7809 # + 0x780D, //0x4F51 0x780D # + 0x780E, //0x4F52 0x780E # + 0x7811, //0x4F53 0x7811 # + 0x781D, //0x4F54 0x781D # + 0x7821, //0x4F55 0x7821 # + 0x7822, //0x4F56 0x7822 # + 0x7823, //0x4F57 0x7823 # + 0x782D, //0x4F58 0x782D # + 0x782E, //0x4F59 0x782E # + 0x7830, //0x4F5A 0x7830 # + 0x7835, //0x4F5B 0x7835 # + 0x7837, //0x4F5C 0x7837 # + 0x7843, //0x4F5D 0x7843 # + 0x7844, //0x4F5E 0x7844 # + 0x7847, //0x4F5F 0x7847 # + 0x7848, //0x4F60 0x7848 # + 0x784C, //0x4F61 0x784C # + 0x784E, //0x4F62 0x784E # + 0x7852, //0x4F63 0x7852 # + 0x785C, //0x4F64 0x785C # + 0x785E, //0x4F65 0x785E # + 0x7860, //0x4F66 0x7860 # + 0x7861, //0x4F67 0x7861 # + 0x7863, //0x4F68 0x7863 # + 0x7864, //0x4F69 0x7864 # + 0x7868, //0x4F6A 0x7868 # + 0x786A, //0x4F6B 0x786A # + 0x786E, //0x4F6C 0x786E # + 0x787A, //0x4F6D 0x787A # + 0x787E, //0x4F6E 0x787E # + 0x788A, //0x4F6F 0x788A # + 0x788F, //0x4F70 0x788F # + 0x7894, //0x4F71 0x7894 # + 0x7898, //0x4F72 0x7898 # + 0x78A1, //0x4F73 0x78A1 # + 0x789D, //0x4F74 0x789D # + 0x789E, //0x4F75 0x789E # + 0x789F, //0x4F76 0x789F # + 0x78A4, //0x4F77 0x78A4 # + 0x78A8, //0x4F78 0x78A8 # + 0x78AC, //0x4F79 0x78AC # + 0x78AD, //0x4F7A 0x78AD # + 0x78B0, //0x4F7B 0x78B0 # + 0x78B1, //0x4F7C 0x78B1 # + 0x78B2, //0x4F7D 0x78B2 # + 0x78B3 //0x4F7E 0x78B3 # + }, + //48区 + { + 0x78BB, //0x5021 0x78BB # + 0x78BD, //0x5022 0x78BD # + 0x78BF, //0x5023 0x78BF # + 0x78C7, //0x5024 0x78C7 # + 0x78C8, //0x5025 0x78C8 # + 0x78C9, //0x5026 0x78C9 # + 0x78CC, //0x5027 0x78CC # + 0x78CE, //0x5028 0x78CE # + 0x78D2, //0x5029 0x78D2 # + 0x78D3, //0x502A 0x78D3 # + 0x78D5, //0x502B 0x78D5 # + 0x78D6, //0x502C 0x78D6 # + 0x78E4, //0x502D 0x78E4 # + 0x78DB, //0x502E 0x78DB # + 0x78DF, //0x502F 0x78DF # + 0x78E0, //0x5030 0x78E0 # + 0x78E1, //0x5031 0x78E1 # + 0x78E6, //0x5032 0x78E6 # + 0x78EA, //0x5033 0x78EA # + 0x78F2, //0x5034 0x78F2 # + 0x78F3, //0x5035 0x78F3 # + 0x7900, //0x5036 0x7900 # + 0x78F6, //0x5037 0x78F6 # + 0x78F7, //0x5038 0x78F7 # + 0x78FA, //0x5039 0x78FA # + 0x78FB, //0x503A 0x78FB # + 0x78FF, //0x503B 0x78FF # + 0x7906, //0x503C 0x7906 # + 0x790C, //0x503D 0x790C # + 0x7910, //0x503E 0x7910 # + 0x791A, //0x503F 0x791A # + 0x791C, //0x5040 0x791C # + 0x791E, //0x5041 0x791E # + 0x791F, //0x5042 0x791F # + 0x7920, //0x5043 0x7920 # + 0x7925, //0x5044 0x7925 # + 0x7927, //0x5045 0x7927 # + 0x7929, //0x5046 0x7929 # + 0x792D, //0x5047 0x792D # + 0x7931, //0x5048 0x7931 # + 0x7934, //0x5049 0x7934 # + 0x7935, //0x504A 0x7935 # + 0x793B, //0x504B 0x793B # + 0x793D, //0x504C 0x793D # + 0x793F, //0x504D 0x793F # + 0x7944, //0x504E 0x7944 # + 0x7945, //0x504F 0x7945 # + 0x7946, //0x5050 0x7946 # + 0x794A, //0x5051 0x794A # + 0x794B, //0x5052 0x794B # + 0x794F, //0x5053 0x794F # + 0x7951, //0x5054 0x7951 # + 0x7954, //0x5055 0x7954 # + 0x7958, //0x5056 0x7958 # + 0x795B, //0x5057 0x795B # + 0x795C, //0x5058 0x795C # + 0x7967, //0x5059 0x7967 # + 0x7969, //0x505A 0x7969 # + 0x796B, //0x505B 0x796B # + 0x7972, //0x505C 0x7972 # + 0x7979, //0x505D 0x7979 # + 0x797B, //0x505E 0x797B # + 0x797C, //0x505F 0x797C # + 0x797E, //0x5060 0x797E # + 0x798B, //0x5061 0x798B # + 0x798C, //0x5062 0x798C # + 0x7991, //0x5063 0x7991 # + 0x7993, //0x5064 0x7993 # + 0x7994, //0x5065 0x7994 # + 0x7995, //0x5066 0x7995 # + 0x7996, //0x5067 0x7996 # + 0x7998, //0x5068 0x7998 # + 0x799B, //0x5069 0x799B # + 0x799C, //0x506A 0x799C # + 0x79A1, //0x506B 0x79A1 # + 0x79A8, //0x506C 0x79A8 # + 0x79A9, //0x506D 0x79A9 # + 0x79AB, //0x506E 0x79AB # + 0x79AF, //0x506F 0x79AF # + 0x79B1, //0x5070 0x79B1 # + 0x79B4, //0x5071 0x79B4 # + 0x79B8, //0x5072 0x79B8 # + 0x79BB, //0x5073 0x79BB # + 0x79C2, //0x5074 0x79C2 # + 0x79C4, //0x5075 0x79C4 # + 0x79C7, //0x5076 0x79C7 # + 0x79C8, //0x5077 0x79C8 # + 0x79CA, //0x5078 0x79CA # + 0x79CF, //0x5079 0x79CF # + 0x79D4, //0x507A 0x79D4 # + 0x79D6, //0x507B 0x79D6 # + 0x79DA, //0x507C 0x79DA # + 0x79DD, //0x507D 0x79DD # + 0x79DE //0x507E 0x79DE # + }, + //49区 + { + 0x79E0, //0x5121 0x79E0 # + 0x79E2, //0x5122 0x79E2 # + 0x79E5, //0x5123 0x79E5 # + 0x79EA, //0x5124 0x79EA # + 0x79EB, //0x5125 0x79EB # + 0x79ED, //0x5126 0x79ED # + 0x79F1, //0x5127 0x79F1 # + 0x79F8, //0x5128 0x79F8 # + 0x79FC, //0x5129 0x79FC # + 0x7A02, //0x512A 0x7A02 # + 0x7A03, //0x512B 0x7A03 # + 0x7A07, //0x512C 0x7A07 # + 0x7A09, //0x512D 0x7A09 # + 0x7A0A, //0x512E 0x7A0A # + 0x7A0C, //0x512F 0x7A0C # + 0x7A11, //0x5130 0x7A11 # + 0x7A15, //0x5131 0x7A15 # + 0x7A1B, //0x5132 0x7A1B # + 0x7A1E, //0x5133 0x7A1E # + 0x7A21, //0x5134 0x7A21 # + 0x7A27, //0x5135 0x7A27 # + 0x7A2B, //0x5136 0x7A2B # + 0x7A2D, //0x5137 0x7A2D # + 0x7A2F, //0x5138 0x7A2F # + 0x7A30, //0x5139 0x7A30 # + 0x7A34, //0x513A 0x7A34 # + 0x7A35, //0x513B 0x7A35 # + 0x7A38, //0x513C 0x7A38 # + 0x7A39, //0x513D 0x7A39 # + 0x7A3A, //0x513E 0x7A3A # + 0x7A44, //0x513F 0x7A44 # + 0x7A45, //0x5140 0x7A45 # + 0x7A47, //0x5141 0x7A47 # + 0x7A48, //0x5142 0x7A48 # + 0x7A4C, //0x5143 0x7A4C # + 0x7A55, //0x5144 0x7A55 # + 0x7A56, //0x5145 0x7A56 # + 0x7A59, //0x5146 0x7A59 # + 0x7A5C, //0x5147 0x7A5C # + 0x7A5D, //0x5148 0x7A5D # + 0x7A5F, //0x5149 0x7A5F # + 0x7A60, //0x514A 0x7A60 # + 0x7A65, //0x514B 0x7A65 # + 0x7A67, //0x514C 0x7A67 # + 0x7A6A, //0x514D 0x7A6A # + 0x7A6D, //0x514E 0x7A6D # + 0x7A75, //0x514F 0x7A75 # + 0x7A78, //0x5150 0x7A78 # + 0x7A7E, //0x5151 0x7A7E # + 0x7A80, //0x5152 0x7A80 # + 0x7A82, //0x5153 0x7A82 # + 0x7A85, //0x5154 0x7A85 # + 0x7A86, //0x5155 0x7A86 # + 0x7A8A, //0x5156 0x7A8A # + 0x7A8B, //0x5157 0x7A8B # + 0x7A90, //0x5158 0x7A90 # + 0x7A91, //0x5159 0x7A91 # + 0x7A94, //0x515A 0x7A94 # + 0x7A9E, //0x515B 0x7A9E # + 0x7AA0, //0x515C 0x7AA0 # + 0x7AA3, //0x515D 0x7AA3 # + 0x7AAC, //0x515E 0x7AAC # + 0x7AB3, //0x515F 0x7AB3 # + 0x7AB5, //0x5160 0x7AB5 # + 0x7AB9, //0x5161 0x7AB9 # + 0x7ABB, //0x5162 0x7ABB # + 0x7ABC, //0x5163 0x7ABC # + 0x7AC6, //0x5164 0x7AC6 # + 0x7AC9, //0x5165 0x7AC9 # + 0x7ACC, //0x5166 0x7ACC # + 0x7ACE, //0x5167 0x7ACE # + 0x7AD1, //0x5168 0x7AD1 # + 0x7ADB, //0x5169 0x7ADB # + 0x7AE8, //0x516A 0x7AE8 # + 0x7AE9, //0x516B 0x7AE9 # + 0x7AEB, //0x516C 0x7AEB # + 0x7AEC, //0x516D 0x7AEC # + 0x7AF1, //0x516E 0x7AF1 # + 0x7AF4, //0x516F 0x7AF4 # + 0x7AFB, //0x5170 0x7AFB # + 0x7AFD, //0x5171 0x7AFD # + 0x7AFE, //0x5172 0x7AFE # + 0x7B07, //0x5173 0x7B07 # + 0x7B14, //0x5174 0x7B14 # + 0x7B1F, //0x5175 0x7B1F # + 0x7B23, //0x5176 0x7B23 # + 0x7B27, //0x5177 0x7B27 # + 0x7B29, //0x5178 0x7B29 # + 0x7B2A, //0x5179 0x7B2A # + 0x7B2B, //0x517A 0x7B2B # + 0x7B2D, //0x517B 0x7B2D # + 0x7B2E, //0x517C 0x7B2E # + 0x7B2F, //0x517D 0x7B2F # + 0x7B30 //0x517E 0x7B30 # + }, + //50区 + { + 0x7B31, //0x5221 0x7B31 # + 0x7B34, //0x5222 0x7B34 # + 0x7B3D, //0x5223 0x7B3D # + 0x7B3F, //0x5224 0x7B3F # + 0x7B40, //0x5225 0x7B40 # + 0x7B41, //0x5226 0x7B41 # + 0x7B47, //0x5227 0x7B47 # + 0x7B4E, //0x5228 0x7B4E # + 0x7B55, //0x5229 0x7B55 # + 0x7B60, //0x522A 0x7B60 # + 0x7B64, //0x522B 0x7B64 # + 0x7B66, //0x522C 0x7B66 # + 0x7B69, //0x522D 0x7B69 # + 0x7B6A, //0x522E 0x7B6A # + 0x7B6D, //0x522F 0x7B6D # + 0x7B6F, //0x5230 0x7B6F # + 0x7B72, //0x5231 0x7B72 # + 0x7B73, //0x5232 0x7B73 # + 0x7B77, //0x5233 0x7B77 # + 0x7B84, //0x5234 0x7B84 # + 0x7B89, //0x5235 0x7B89 # + 0x7B8E, //0x5236 0x7B8E # + 0x7B90, //0x5237 0x7B90 # + 0x7B91, //0x5238 0x7B91 # + 0x7B96, //0x5239 0x7B96 # + 0x7B9B, //0x523A 0x7B9B # + 0x7B9E, //0x523B 0x7B9E # + 0x7BA0, //0x523C 0x7BA0 # + 0x7BA5, //0x523D 0x7BA5 # + 0x7BAC, //0x523E 0x7BAC # + 0x7BAF, //0x523F 0x7BAF # + 0x7BB0, //0x5240 0x7BB0 # + 0x7BB2, //0x5241 0x7BB2 # + 0x7BB5, //0x5242 0x7BB5 # + 0x7BB6, //0x5243 0x7BB6 # + 0x7BBA, //0x5244 0x7BBA # + 0x7BBB, //0x5245 0x7BBB # + 0x7BBC, //0x5246 0x7BBC # + 0x7BBD, //0x5247 0x7BBD # + 0x7BC2, //0x5248 0x7BC2 # + 0x7BC5, //0x5249 0x7BC5 # + 0x7BC8, //0x524A 0x7BC8 # + 0x7BCA, //0x524B 0x7BCA # + 0x7BD4, //0x524C 0x7BD4 # + 0x7BD6, //0x524D 0x7BD6 # + 0x7BD7, //0x524E 0x7BD7 # + 0x7BD9, //0x524F 0x7BD9 # + 0x7BDA, //0x5250 0x7BDA # + 0x7BDB, //0x5251 0x7BDB # + 0x7BE8, //0x5252 0x7BE8 # + 0x7BEA, //0x5253 0x7BEA # + 0x7BF2, //0x5254 0x7BF2 # + 0x7BF4, //0x5255 0x7BF4 # + 0x7BF5, //0x5256 0x7BF5 # + 0x7BF8, //0x5257 0x7BF8 # + 0x7BF9, //0x5258 0x7BF9 # + 0x7BFA, //0x5259 0x7BFA # + 0x7BFC, //0x525A 0x7BFC # + 0x7BFE, //0x525B 0x7BFE # + 0x7C01, //0x525C 0x7C01 # + 0x7C02, //0x525D 0x7C02 # + 0x7C03, //0x525E 0x7C03 # + 0x7C04, //0x525F 0x7C04 # + 0x7C06, //0x5260 0x7C06 # + 0x7C09, //0x5261 0x7C09 # + 0x7C0B, //0x5262 0x7C0B # + 0x7C0C, //0x5263 0x7C0C # + 0x7C0E, //0x5264 0x7C0E # + 0x7C0F, //0x5265 0x7C0F # + 0x7C19, //0x5266 0x7C19 # + 0x7C1B, //0x5267 0x7C1B # + 0x7C20, //0x5268 0x7C20 # + 0x7C25, //0x5269 0x7C25 # + 0x7C26, //0x526A 0x7C26 # + 0x7C28, //0x526B 0x7C28 # + 0x7C2C, //0x526C 0x7C2C # + 0x7C31, //0x526D 0x7C31 # + 0x7C33, //0x526E 0x7C33 # + 0x7C34, //0x526F 0x7C34 # + 0x7C36, //0x5270 0x7C36 # + 0x7C39, //0x5271 0x7C39 # + 0x7C3A, //0x5272 0x7C3A # + 0x7C46, //0x5273 0x7C46 # + 0x7C4A, //0x5274 0x7C4A # + 0x7C55, //0x5275 0x7C55 # + 0x7C51, //0x5276 0x7C51 # + 0x7C52, //0x5277 0x7C52 # + 0x7C53, //0x5278 0x7C53 # + 0x7C59, //0x5279 0x7C59 # + 0x7C5A, //0x527A 0x7C5A # + 0x7C5B, //0x527B 0x7C5B # + 0x7C5C, //0x527C 0x7C5C # + 0x7C5D, //0x527D 0x7C5D # + 0x7C5E //0x527E 0x7C5E # + }, + //51区 + { + 0x7C61, //0x5321 0x7C61 # + 0x7C63, //0x5322 0x7C63 # + 0x7C67, //0x5323 0x7C67 # + 0x7C69, //0x5324 0x7C69 # + 0x7C6D, //0x5325 0x7C6D # + 0x7C6E, //0x5326 0x7C6E # + 0x7C70, //0x5327 0x7C70 # + 0x7C72, //0x5328 0x7C72 # + 0x7C79, //0x5329 0x7C79 # + 0x7C7C, //0x532A 0x7C7C # + 0x7C7D, //0x532B 0x7C7D # + 0x7C86, //0x532C 0x7C86 # + 0x7C87, //0x532D 0x7C87 # + 0x7C8F, //0x532E 0x7C8F # + 0x7C94, //0x532F 0x7C94 # + 0x7C9E, //0x5330 0x7C9E # + 0x7CA0, //0x5331 0x7CA0 # + 0x7CA6, //0x5332 0x7CA6 # + 0x7CB0, //0x5333 0x7CB0 # + 0x7CB6, //0x5334 0x7CB6 # + 0x7CB7, //0x5335 0x7CB7 # + 0x7CBA, //0x5336 0x7CBA # + 0x7CBB, //0x5337 0x7CBB # + 0x7CBC, //0x5338 0x7CBC # + 0x7CBF, //0x5339 0x7CBF # + 0x7CC4, //0x533A 0x7CC4 # + 0x7CC7, //0x533B 0x7CC7 # + 0x7CC8, //0x533C 0x7CC8 # + 0x7CC9, //0x533D 0x7CC9 # + 0x7CCD, //0x533E 0x7CCD # + 0x7CCF, //0x533F 0x7CCF # + 0x7CD3, //0x5340 0x7CD3 # + 0x7CD4, //0x5341 0x7CD4 # + 0x7CD5, //0x5342 0x7CD5 # + 0x7CD7, //0x5343 0x7CD7 # + 0x7CD9, //0x5344 0x7CD9 # + 0x7CDA, //0x5345 0x7CDA # + 0x7CDD, //0x5346 0x7CDD # + 0x7CE6, //0x5347 0x7CE6 # + 0x7CE9, //0x5348 0x7CE9 # + 0x7CEB, //0x5349 0x7CEB # + 0x7CF5, //0x534A 0x7CF5 # + 0x7D03, //0x534B 0x7D03 # + 0x7D07, //0x534C 0x7D07 # + 0x7D08, //0x534D 0x7D08 # + 0x7D09, //0x534E 0x7D09 # + 0x7D0F, //0x534F 0x7D0F # + 0x7D11, //0x5350 0x7D11 # + 0x7D12, //0x5351 0x7D12 # + 0x7D13, //0x5352 0x7D13 # + 0x7D16, //0x5353 0x7D16 # + 0x7D1D, //0x5354 0x7D1D # + 0x7D1E, //0x5355 0x7D1E # + 0x7D23, //0x5356 0x7D23 # + 0x7D26, //0x5357 0x7D26 # + 0x7D2A, //0x5358 0x7D2A # + 0x7D2D, //0x5359 0x7D2D # + 0x7D31, //0x535A 0x7D31 # + 0x7D3C, //0x535B 0x7D3C # + 0x7D3D, //0x535C 0x7D3D # + 0x7D3E, //0x535D 0x7D3E # + 0x7D40, //0x535E 0x7D40 # + 0x7D41, //0x535F 0x7D41 # + 0x7D47, //0x5360 0x7D47 # + 0x7D48, //0x5361 0x7D48 # + 0x7D4D, //0x5362 0x7D4D # + 0x7D51, //0x5363 0x7D51 # + 0x7D53, //0x5364 0x7D53 # + 0x7D57, //0x5365 0x7D57 # + 0x7D59, //0x5366 0x7D59 # + 0x7D5A, //0x5367 0x7D5A # + 0x7D5C, //0x5368 0x7D5C # + 0x7D5D, //0x5369 0x7D5D # + 0x7D65, //0x536A 0x7D65 # + 0x7D67, //0x536B 0x7D67 # + 0x7D6A, //0x536C 0x7D6A # + 0x7D70, //0x536D 0x7D70 # + 0x7D78, //0x536E 0x7D78 # + 0x7D7A, //0x536F 0x7D7A # + 0x7D7B, //0x5370 0x7D7B # + 0x7D7F, //0x5371 0x7D7F # + 0x7D81, //0x5372 0x7D81 # + 0x7D82, //0x5373 0x7D82 # + 0x7D83, //0x5374 0x7D83 # + 0x7D85, //0x5375 0x7D85 # + 0x7D86, //0x5376 0x7D86 # + 0x7D88, //0x5377 0x7D88 # + 0x7D8B, //0x5378 0x7D8B # + 0x7D8C, //0x5379 0x7D8C # + 0x7D8D, //0x537A 0x7D8D # + 0x7D91, //0x537B 0x7D91 # + 0x7D96, //0x537C 0x7D96 # + 0x7D97, //0x537D 0x7D97 # + 0x7D9D //0x537E 0x7D9D # + }, + //52区 + { + 0x7D9E, //0x5421 0x7D9E # + 0x7DA6, //0x5422 0x7DA6 # + 0x7DA7, //0x5423 0x7DA7 # + 0x7DAA, //0x5424 0x7DAA # + 0x7DB3, //0x5425 0x7DB3 # + 0x7DB6, //0x5426 0x7DB6 # + 0x7DB7, //0x5427 0x7DB7 # + 0x7DB9, //0x5428 0x7DB9 # + 0x7DC2, //0x5429 0x7DC2 # + 0x7DC3, //0x542A 0x7DC3 # + 0x7DC4, //0x542B 0x7DC4 # + 0x7DC5, //0x542C 0x7DC5 # + 0x7DC6, //0x542D 0x7DC6 # + 0x7DCC, //0x542E 0x7DCC # + 0x7DCD, //0x542F 0x7DCD # + 0x7DCE, //0x5430 0x7DCE # + 0x7DD7, //0x5431 0x7DD7 # + 0x7DD9, //0x5432 0x7DD9 # + 0x7E00, //0x5433 0x7E00 # + 0x7DE2, //0x5434 0x7DE2 # + 0x7DE5, //0x5435 0x7DE5 # + 0x7DE6, //0x5436 0x7DE6 # + 0x7DEA, //0x5437 0x7DEA # + 0x7DEB, //0x5438 0x7DEB # + 0x7DED, //0x5439 0x7DED # + 0x7DF1, //0x543A 0x7DF1 # + 0x7DF5, //0x543B 0x7DF5 # + 0x7DF6, //0x543C 0x7DF6 # + 0x7DF9, //0x543D 0x7DF9 # + 0x7DFA, //0x543E 0x7DFA # + 0x7E08, //0x543F 0x7E08 # + 0x7E10, //0x5440 0x7E10 # + 0x7E11, //0x5441 0x7E11 # + 0x7E15, //0x5442 0x7E15 # + 0x7E17, //0x5443 0x7E17 # + 0x7E1C, //0x5444 0x7E1C # + 0x7E1D, //0x5445 0x7E1D # + 0x7E20, //0x5446 0x7E20 # + 0x7E27, //0x5447 0x7E27 # + 0x7E28, //0x5448 0x7E28 # + 0x7E2C, //0x5449 0x7E2C # + 0x7E2D, //0x544A 0x7E2D # + 0x7E2F, //0x544B 0x7E2F # + 0x7E33, //0x544C 0x7E33 # + 0x7E36, //0x544D 0x7E36 # + 0x7E3F, //0x544E 0x7E3F # + 0x7E44, //0x544F 0x7E44 # + 0x7E45, //0x5450 0x7E45 # + 0x7E47, //0x5451 0x7E47 # + 0x7E4E, //0x5452 0x7E4E # + 0x7E50, //0x5453 0x7E50 # + 0x7E52, //0x5454 0x7E52 # + 0x7E58, //0x5455 0x7E58 # + 0x7E5F, //0x5456 0x7E5F # + 0x7E61, //0x5457 0x7E61 # + 0x7E62, //0x5458 0x7E62 # + 0x7E65, //0x5459 0x7E65 # + 0x7E6B, //0x545A 0x7E6B # + 0x7E6E, //0x545B 0x7E6E # + 0x7E6F, //0x545C 0x7E6F # + 0x7E73, //0x545D 0x7E73 # + 0x7E78, //0x545E 0x7E78 # + 0x7E7E, //0x545F 0x7E7E # + 0x7E81, //0x5460 0x7E81 # + 0x7E86, //0x5461 0x7E86 # + 0x7E87, //0x5462 0x7E87 # + 0x7E8A, //0x5463 0x7E8A # + 0x7E8D, //0x5464 0x7E8D # + 0x7E91, //0x5465 0x7E91 # + 0x7E95, //0x5466 0x7E95 # + 0x7E98, //0x5467 0x7E98 # + 0x7E9A, //0x5468 0x7E9A # + 0x7E9D, //0x5469 0x7E9D # + 0x7E9E, //0x546A 0x7E9E # + 0x7F3C, //0x546B 0x7F3C # + 0x7F3B, //0x546C 0x7F3B # + 0x7F3D, //0x546D 0x7F3D # + 0x7F3E, //0x546E 0x7F3E # + 0x7F3F, //0x546F 0x7F3F # + 0x7F43, //0x5470 0x7F43 # + 0x7F44, //0x5471 0x7F44 # + 0x7F47, //0x5472 0x7F47 # + 0x7F4F, //0x5473 0x7F4F # + 0x7F52, //0x5474 0x7F52 # + 0x7F53, //0x5475 0x7F53 # + 0x7F5B, //0x5476 0x7F5B # + 0x7F5C, //0x5477 0x7F5C # + 0x7F5D, //0x5478 0x7F5D # + 0x7F61, //0x5479 0x7F61 # + 0x7F63, //0x547A 0x7F63 # + 0x7F64, //0x547B 0x7F64 # + 0x7F65, //0x547C 0x7F65 # + 0x7F66, //0x547D 0x7F66 # + 0x7F6D //0x547E 0x7F6D # + }, + //53区 + { + 0x7F71, //0x5521 0x7F71 # + 0x7F7D, //0x5522 0x7F7D # + 0x7F7E, //0x5523 0x7F7E # + 0x7F7F, //0x5524 0x7F7F # + 0x7F80, //0x5525 0x7F80 # + 0x7F8B, //0x5526 0x7F8B # + 0x7F8D, //0x5527 0x7F8D # + 0x7F8F, //0x5528 0x7F8F # + 0x7F90, //0x5529 0x7F90 # + 0x7F91, //0x552A 0x7F91 # + 0x7F96, //0x552B 0x7F96 # + 0x7F97, //0x552C 0x7F97 # + 0x7F9C, //0x552D 0x7F9C # + 0x7FA1, //0x552E 0x7FA1 # + 0x7FA2, //0x552F 0x7FA2 # + 0x7FA6, //0x5530 0x7FA6 # + 0x7FAA, //0x5531 0x7FAA # + 0x7FAD, //0x5532 0x7FAD # + 0x7FB4, //0x5533 0x7FB4 # + 0x7FBC, //0x5534 0x7FBC # + 0x7FBF, //0x5535 0x7FBF # + 0x7FC0, //0x5536 0x7FC0 # + 0x7FC3, //0x5537 0x7FC3 # + 0x7FC8, //0x5538 0x7FC8 # + 0x7FCE, //0x5539 0x7FCE # + 0x7FCF, //0x553A 0x7FCF # + 0x7FDB, //0x553B 0x7FDB # + 0x7FDF, //0x553C 0x7FDF # + 0x7FE3, //0x553D 0x7FE3 # + 0x7FE5, //0x553E 0x7FE5 # + 0x7FE8, //0x553F 0x7FE8 # + 0x7FEC, //0x5540 0x7FEC # + 0x7FEE, //0x5541 0x7FEE # + 0x7FEF, //0x5542 0x7FEF # + 0x7FF2, //0x5543 0x7FF2 # + 0x7FFA, //0x5544 0x7FFA # + 0x7FFD, //0x5545 0x7FFD # + 0x7FFE, //0x5546 0x7FFE # + 0x7FFF, //0x5547 0x7FFF # + 0x8007, //0x5548 0x8007 # + 0x8008, //0x5549 0x8008 # + 0x800A, //0x554A 0x800A # + 0x800D, //0x554B 0x800D # + 0x800E, //0x554C 0x800E # + 0x800F, //0x554D 0x800F # + 0x8011, //0x554E 0x8011 # + 0x8013, //0x554F 0x8013 # + 0x8014, //0x5550 0x8014 # + 0x8016, //0x5551 0x8016 # + 0x801D, //0x5552 0x801D # + 0x801E, //0x5553 0x801E # + 0x801F, //0x5554 0x801F # + 0x8020, //0x5555 0x8020 # + 0x8024, //0x5556 0x8024 # + 0x8026, //0x5557 0x8026 # + 0x802C, //0x5558 0x802C # + 0x802E, //0x5559 0x802E # + 0x8030, //0x555A 0x8030 # + 0x8034, //0x555B 0x8034 # + 0x8035, //0x555C 0x8035 # + 0x8037, //0x555D 0x8037 # + 0x8039, //0x555E 0x8039 # + 0x803A, //0x555F 0x803A # + 0x803C, //0x5560 0x803C # + 0x803E, //0x5561 0x803E # + 0x8040, //0x5562 0x8040 # + 0x8044, //0x5563 0x8044 # + 0x8060, //0x5564 0x8060 # + 0x8064, //0x5565 0x8064 # + 0x8066, //0x5566 0x8066 # + 0x806D, //0x5567 0x806D # + 0x8071, //0x5568 0x8071 # + 0x8075, //0x5569 0x8075 # + 0x8081, //0x556A 0x8081 # + 0x8088, //0x556B 0x8088 # + 0x808E, //0x556C 0x808E # + 0x809C, //0x556D 0x809C # + 0x809E, //0x556E 0x809E # + 0x80A6, //0x556F 0x80A6 # + 0x80A7, //0x5570 0x80A7 # + 0x80AB, //0x5571 0x80AB # + 0x80B8, //0x5572 0x80B8 # + 0x80B9, //0x5573 0x80B9 # + 0x80C8, //0x5574 0x80C8 # + 0x80CD, //0x5575 0x80CD # + 0x80CF, //0x5576 0x80CF # + 0x80D2, //0x5577 0x80D2 # + 0x80D4, //0x5578 0x80D4 # + 0x80D5, //0x5579 0x80D5 # + 0x80D7, //0x557A 0x80D7 # + 0x80D8, //0x557B 0x80D8 # + 0x80E0, //0x557C 0x80E0 # + 0x80ED, //0x557D 0x80ED # + 0x80EE //0x557E 0x80EE # + }, + //54区 + { + 0x80F0, //0x5621 0x80F0 # + 0x80F2, //0x5622 0x80F2 # + 0x80F3, //0x5623 0x80F3 # + 0x80F6, //0x5624 0x80F6 # + 0x80F9, //0x5625 0x80F9 # + 0x80FA, //0x5626 0x80FA # + 0x80FE, //0x5627 0x80FE # + 0x8103, //0x5628 0x8103 # + 0x810B, //0x5629 0x810B # + 0x8116, //0x562A 0x8116 # + 0x8117, //0x562B 0x8117 # + 0x8118, //0x562C 0x8118 # + 0x811C, //0x562D 0x811C # + 0x811E, //0x562E 0x811E # + 0x8120, //0x562F 0x8120 # + 0x8124, //0x5630 0x8124 # + 0x8127, //0x5631 0x8127 # + 0x812C, //0x5632 0x812C # + 0x8130, //0x5633 0x8130 # + 0x8135, //0x5634 0x8135 # + 0x813A, //0x5635 0x813A # + 0x813C, //0x5636 0x813C # + 0x8145, //0x5637 0x8145 # + 0x8147, //0x5638 0x8147 # + 0x814A, //0x5639 0x814A # + 0x814C, //0x563A 0x814C # + 0x8152, //0x563B 0x8152 # + 0x8157, //0x563C 0x8157 # + 0x8160, //0x563D 0x8160 # + 0x8161, //0x563E 0x8161 # + 0x8167, //0x563F 0x8167 # + 0x8168, //0x5640 0x8168 # + 0x8169, //0x5641 0x8169 # + 0x816D, //0x5642 0x816D # + 0x816F, //0x5643 0x816F # + 0x8177, //0x5644 0x8177 # + 0x8181, //0x5645 0x8181 # + 0x8190, //0x5646 0x8190 # + 0x8184, //0x5647 0x8184 # + 0x8185, //0x5648 0x8185 # + 0x8186, //0x5649 0x8186 # + 0x818B, //0x564A 0x818B # + 0x818E, //0x564B 0x818E # + 0x8196, //0x564C 0x8196 # + 0x8198, //0x564D 0x8198 # + 0x819B, //0x564E 0x819B # + 0x819E, //0x564F 0x819E # + 0x81A2, //0x5650 0x81A2 # + 0x81AE, //0x5651 0x81AE # + 0x81B2, //0x5652 0x81B2 # + 0x81B4, //0x5653 0x81B4 # + 0x81BB, //0x5654 0x81BB # + 0x81CB, //0x5655 0x81CB # + 0x81C3, //0x5656 0x81C3 # + 0x81C5, //0x5657 0x81C5 # + 0x81CA, //0x5658 0x81CA # + 0x81CE, //0x5659 0x81CE # + 0x81CF, //0x565A 0x81CF # + 0x81D5, //0x565B 0x81D5 # + 0x81D7, //0x565C 0x81D7 # + 0x81DB, //0x565D 0x81DB # + 0x81DD, //0x565E 0x81DD # + 0x81DE, //0x565F 0x81DE # + 0x81E1, //0x5660 0x81E1 # + 0x81E4, //0x5661 0x81E4 # + 0x81EB, //0x5662 0x81EB # + 0x81EC, //0x5663 0x81EC # + 0x81F0, //0x5664 0x81F0 # + 0x81F1, //0x5665 0x81F1 # + 0x81F2, //0x5666 0x81F2 # + 0x81F5, //0x5667 0x81F5 # + 0x81F6, //0x5668 0x81F6 # + 0x81F8, //0x5669 0x81F8 # + 0x81F9, //0x566A 0x81F9 # + 0x81FD, //0x566B 0x81FD # + 0x81FF, //0x566C 0x81FF # + 0x8200, //0x566D 0x8200 # + 0x8203, //0x566E 0x8203 # + 0x820F, //0x566F 0x820F # + 0x8213, //0x5670 0x8213 # + 0x8214, //0x5671 0x8214 # + 0x8219, //0x5672 0x8219 # + 0x821A, //0x5673 0x821A # + 0x821D, //0x5674 0x821D # + 0x8221, //0x5675 0x8221 # + 0x8222, //0x5676 0x8222 # + 0x8228, //0x5677 0x8228 # + 0x8232, //0x5678 0x8232 # + 0x8234, //0x5679 0x8234 # + 0x823A, //0x567A 0x823A # + 0x8243, //0x567B 0x8243 # + 0x8244, //0x567C 0x8244 # + 0x8245, //0x567D 0x8245 # + 0x8246 //0x567E 0x8246 # + }, + //55区 + { + 0x824B, //0x5721 0x824B # + 0x824E, //0x5722 0x824E # + 0x824F, //0x5723 0x824F # + 0x8251, //0x5724 0x8251 # + 0x8256, //0x5725 0x8256 # + 0x825C, //0x5726 0x825C # + 0x8260, //0x5727 0x8260 # + 0x8263, //0x5728 0x8263 # + 0x8267, //0x5729 0x8267 # + 0x826D, //0x572A 0x826D # + 0x8274, //0x572B 0x8274 # + 0x827B, //0x572C 0x827B # + 0x827D, //0x572D 0x827D # + 0x827F, //0x572E 0x827F # + 0x8280, //0x572F 0x8280 # + 0x8281, //0x5730 0x8281 # + 0x8283, //0x5731 0x8283 # + 0x8284, //0x5732 0x8284 # + 0x8287, //0x5733 0x8287 # + 0x8289, //0x5734 0x8289 # + 0x828A, //0x5735 0x828A # + 0x828E, //0x5736 0x828E # + 0x8291, //0x5737 0x8291 # + 0x8294, //0x5738 0x8294 # + 0x8296, //0x5739 0x8296 # + 0x8298, //0x573A 0x8298 # + 0x829A, //0x573B 0x829A # + 0x829B, //0x573C 0x829B # + 0x82A0, //0x573D 0x82A0 # + 0x82A1, //0x573E 0x82A1 # + 0x82A3, //0x573F 0x82A3 # + 0x82A4, //0x5740 0x82A4 # + 0x82A7, //0x5741 0x82A7 # + 0x82A8, //0x5742 0x82A8 # + 0x82A9, //0x5743 0x82A9 # + 0x82AA, //0x5744 0x82AA # + 0x82AE, //0x5745 0x82AE # + 0x82B0, //0x5746 0x82B0 # + 0x82B2, //0x5747 0x82B2 # + 0x82B4, //0x5748 0x82B4 # + 0x82B7, //0x5749 0x82B7 # + 0x82BA, //0x574A 0x82BA # + 0x82BC, //0x574B 0x82BC # + 0x82BE, //0x574C 0x82BE # + 0x82BF, //0x574D 0x82BF # + 0x82C6, //0x574E 0x82C6 # + 0x82D0, //0x574F 0x82D0 # + 0x82D5, //0x5750 0x82D5 # + 0x82DA, //0x5751 0x82DA # + 0x82E0, //0x5752 0x82E0 # + 0x82E2, //0x5753 0x82E2 # + 0x82E4, //0x5754 0x82E4 # + 0x82E8, //0x5755 0x82E8 # + 0x82EA, //0x5756 0x82EA # + 0x82ED, //0x5757 0x82ED # + 0x82EF, //0x5758 0x82EF # + 0x82F6, //0x5759 0x82F6 # + 0x82F7, //0x575A 0x82F7 # + 0x82FD, //0x575B 0x82FD # + 0x82FE, //0x575C 0x82FE # + 0x8300, //0x575D 0x8300 # + 0x8301, //0x575E 0x8301 # + 0x8307, //0x575F 0x8307 # + 0x8308, //0x5760 0x8308 # + 0x830A, //0x5761 0x830A # + 0x830B, //0x5762 0x830B # + 0x8354, //0x5763 0x8354 # + 0x831B, //0x5764 0x831B # + 0x831D, //0x5765 0x831D # + 0x831E, //0x5766 0x831E # + 0x831F, //0x5767 0x831F # + 0x8321, //0x5768 0x8321 # + 0x8322, //0x5769 0x8322 # + 0x832C, //0x576A 0x832C # + 0x832D, //0x576B 0x832D # + 0x832E, //0x576C 0x832E # + 0x8330, //0x576D 0x8330 # + 0x8333, //0x576E 0x8333 # + 0x8337, //0x576F 0x8337 # + 0x833A, //0x5770 0x833A # + 0x833C, //0x5771 0x833C # + 0x833D, //0x5772 0x833D # + 0x8342, //0x5773 0x8342 # + 0x8343, //0x5774 0x8343 # + 0x8344, //0x5775 0x8344 # + 0x8347, //0x5776 0x8347 # + 0x834D, //0x5777 0x834D # + 0x834E, //0x5778 0x834E # + 0x8351, //0x5779 0x8351 # + 0x8355, //0x577A 0x8355 # + 0x8356, //0x577B 0x8356 # + 0x8357, //0x577C 0x8357 # + 0x8370, //0x577D 0x8370 # + 0x8378 //0x577E 0x8378 # + }, + //56区 + { + 0x837D, //0x5821 0x837D # + 0x837F, //0x5822 0x837F # + 0x8380, //0x5823 0x8380 # + 0x8382, //0x5824 0x8382 # + 0x8384, //0x5825 0x8384 # + 0x8386, //0x5826 0x8386 # + 0x838D, //0x5827 0x838D # + 0x8392, //0x5828 0x8392 # + 0x8394, //0x5829 0x8394 # + 0x8395, //0x582A 0x8395 # + 0x8398, //0x582B 0x8398 # + 0x8399, //0x582C 0x8399 # + 0x839B, //0x582D 0x839B # + 0x839C, //0x582E 0x839C # + 0x839D, //0x582F 0x839D # + 0x83A6, //0x5830 0x83A6 # + 0x83A7, //0x5831 0x83A7 # + 0x83A9, //0x5832 0x83A9 # + 0x83AC, //0x5833 0x83AC # + 0x83BE, //0x5834 0x83BE # + 0x83BF, //0x5835 0x83BF # + 0x83C0, //0x5836 0x83C0 # + 0x83C7, //0x5837 0x83C7 # + 0x83C9, //0x5838 0x83C9 # + 0x83CF, //0x5839 0x83CF # + 0x83D0, //0x583A 0x83D0 # + 0x83D1, //0x583B 0x83D1 # + 0x83D4, //0x583C 0x83D4 # + 0x83DD, //0x583D 0x83DD # + 0x8353, //0x583E 0x8353 # + 0x83E8, //0x583F 0x83E8 # + 0x83EA, //0x5840 0x83EA # + 0x83F6, //0x5841 0x83F6 # + 0x83F8, //0x5842 0x83F8 # + 0x83F9, //0x5843 0x83F9 # + 0x83FC, //0x5844 0x83FC # + 0x8401, //0x5845 0x8401 # + 0x8406, //0x5846 0x8406 # + 0x840A, //0x5847 0x840A # + 0x840F, //0x5848 0x840F # + 0x8411, //0x5849 0x8411 # + 0x8415, //0x584A 0x8415 # + 0x8419, //0x584B 0x8419 # + 0x83AD, //0x584C 0x83AD # + 0x842F, //0x584D 0x842F # + 0x8439, //0x584E 0x8439 # + 0x8445, //0x584F 0x8445 # + 0x8447, //0x5850 0x8447 # + 0x8448, //0x5851 0x8448 # + 0x844A, //0x5852 0x844A # + 0x844D, //0x5853 0x844D # + 0x844F, //0x5854 0x844F # + 0x8451, //0x5855 0x8451 # + 0x8452, //0x5856 0x8452 # + 0x8456, //0x5857 0x8456 # + 0x8458, //0x5858 0x8458 # + 0x8459, //0x5859 0x8459 # + 0x845A, //0x585A 0x845A # + 0x845C, //0x585B 0x845C # + 0x8460, //0x585C 0x8460 # + 0x8464, //0x585D 0x8464 # + 0x8465, //0x585E 0x8465 # + 0x8467, //0x585F 0x8467 # + 0x846A, //0x5860 0x846A # + 0x8470, //0x5861 0x8470 # + 0x8473, //0x5862 0x8473 # + 0x8474, //0x5863 0x8474 # + 0x8476, //0x5864 0x8476 # + 0x8478, //0x5865 0x8478 # + 0x847C, //0x5866 0x847C # + 0x847D, //0x5867 0x847D # + 0x8481, //0x5868 0x8481 # + 0x8485, //0x5869 0x8485 # + 0x8492, //0x586A 0x8492 # + 0x8493, //0x586B 0x8493 # + 0x8495, //0x586C 0x8495 # + 0x849E, //0x586D 0x849E # + 0x84A6, //0x586E 0x84A6 # + 0x84A8, //0x586F 0x84A8 # + 0x84A9, //0x5870 0x84A9 # + 0x84AA, //0x5871 0x84AA # + 0x84AF, //0x5872 0x84AF # + 0x84B1, //0x5873 0x84B1 # + 0x84B4, //0x5874 0x84B4 # + 0x84BA, //0x5875 0x84BA # + 0x84BD, //0x5876 0x84BD # + 0x84BE, //0x5877 0x84BE # + 0x84C0, //0x5878 0x84C0 # + 0x84C2, //0x5879 0x84C2 # + 0x84C7, //0x587A 0x84C7 # + 0x84C8, //0x587B 0x84C8 # + 0x84CC, //0x587C 0x84CC # + 0x84CF, //0x587D 0x84CF # + 0x84D3 //0x587E 0x84D3 # + }, + //57区 + { + 0x84DC, //0x5921 0x84DC # + 0x84E7, //0x5922 0x84E7 # + 0x84EA, //0x5923 0x84EA # + 0x84EF, //0x5924 0x84EF # + 0x84F0, //0x5925 0x84F0 # + 0x84F1, //0x5926 0x84F1 # + 0x84F2, //0x5927 0x84F2 # + 0x84F7, //0x5928 0x84F7 # + 0x8532, //0x5929 0x8532 # + 0x84FA, //0x592A 0x84FA # + 0x84FB, //0x592B 0x84FB # + 0x84FD, //0x592C 0x84FD # + 0x8502, //0x592D 0x8502 # + 0x8503, //0x592E 0x8503 # + 0x8507, //0x592F 0x8507 # + 0x850C, //0x5930 0x850C # + 0x850E, //0x5931 0x850E # + 0x8510, //0x5932 0x8510 # + 0x851C, //0x5933 0x851C # + 0x851E, //0x5934 0x851E # + 0x8522, //0x5935 0x8522 # + 0x8523, //0x5936 0x8523 # + 0x8524, //0x5937 0x8524 # + 0x8525, //0x5938 0x8525 # + 0x8527, //0x5939 0x8527 # + 0x852A, //0x593A 0x852A # + 0x852B, //0x593B 0x852B # + 0x852F, //0x593C 0x852F # + 0x8533, //0x593D 0x8533 # + 0x8534, //0x593E 0x8534 # + 0x8536, //0x593F 0x8536 # + 0x853F, //0x5940 0x853F # + 0x8546, //0x5941 0x8546 # + 0x854F, //0x5942 0x854F # + 0x8550, //0x5943 0x8550 # + 0x8551, //0x5944 0x8551 # + 0x8552, //0x5945 0x8552 # + 0x8553, //0x5946 0x8553 # + 0x8556, //0x5947 0x8556 # + 0x8559, //0x5948 0x8559 # + 0x855C, //0x5949 0x855C # + 0x855D, //0x594A 0x855D # + 0x855E, //0x594B 0x855E # + 0x855F, //0x594C 0x855F # + 0x8560, //0x594D 0x8560 # + 0x8561, //0x594E 0x8561 # + 0x8562, //0x594F 0x8562 # + 0x8564, //0x5950 0x8564 # + 0x856B, //0x5951 0x856B # + 0x856F, //0x5952 0x856F # + 0x8579, //0x5953 0x8579 # + 0x857A, //0x5954 0x857A # + 0x857B, //0x5955 0x857B # + 0x857D, //0x5956 0x857D # + 0x857F, //0x5957 0x857F # + 0x8581, //0x5958 0x8581 # + 0x8585, //0x5959 0x8585 # + 0x8586, //0x595A 0x8586 # + 0x8589, //0x595B 0x8589 # + 0x858B, //0x595C 0x858B # + 0x858C, //0x595D 0x858C # + 0x858F, //0x595E 0x858F # + 0x8593, //0x595F 0x8593 # + 0x8598, //0x5960 0x8598 # + 0x859D, //0x5961 0x859D # + 0x859F, //0x5962 0x859F # + 0x85A0, //0x5963 0x85A0 # + 0x85A2, //0x5964 0x85A2 # + 0x85A5, //0x5965 0x85A5 # + 0x85A7, //0x5966 0x85A7 # + 0x85B4, //0x5967 0x85B4 # + 0x85B6, //0x5968 0x85B6 # + 0x85B7, //0x5969 0x85B7 # + 0x85B8, //0x596A 0x85B8 # + 0x85BC, //0x596B 0x85BC # + 0x85BD, //0x596C 0x85BD # + 0x85BE, //0x596D 0x85BE # + 0x85BF, //0x596E 0x85BF # + 0x85C2, //0x596F 0x85C2 # + 0x85C7, //0x5970 0x85C7 # + 0x85CA, //0x5971 0x85CA # + 0x85CB, //0x5972 0x85CB # + 0x85CE, //0x5973 0x85CE # + 0x85AD, //0x5974 0x85AD # + 0x85D8, //0x5975 0x85D8 # + 0x85DA, //0x5976 0x85DA # + 0x85DF, //0x5977 0x85DF # + 0x85E0, //0x5978 0x85E0 # + 0x85E6, //0x5979 0x85E6 # + 0x85E8, //0x597A 0x85E8 # + 0x85ED, //0x597B 0x85ED # + 0x85F3, //0x597C 0x85F3 # + 0x85F6, //0x597D 0x85F6 # + 0x85FC //0x597E 0x85FC # + }, + //58区 + { + 0x85FF, //0x5A21 0x85FF # + 0x8600, //0x5A22 0x8600 # + 0x8604, //0x5A23 0x8604 # + 0x8605, //0x5A24 0x8605 # + 0x860D, //0x5A25 0x860D # + 0x860E, //0x5A26 0x860E # + 0x8610, //0x5A27 0x8610 # + 0x8611, //0x5A28 0x8611 # + 0x8612, //0x5A29 0x8612 # + 0x8618, //0x5A2A 0x8618 # + 0x8619, //0x5A2B 0x8619 # + 0x861B, //0x5A2C 0x861B # + 0x861E, //0x5A2D 0x861E # + 0x8621, //0x5A2E 0x8621 # + 0x8627, //0x5A2F 0x8627 # + 0x8629, //0x5A30 0x8629 # + 0x8636, //0x5A31 0x8636 # + 0x8638, //0x5A32 0x8638 # + 0x863A, //0x5A33 0x863A # + 0x863C, //0x5A34 0x863C # + 0x863D, //0x5A35 0x863D # + 0x8640, //0x5A36 0x8640 # + 0x8642, //0x5A37 0x8642 # + 0x8646, //0x5A38 0x8646 # + 0x8652, //0x5A39 0x8652 # + 0x8653, //0x5A3A 0x8653 # + 0x8656, //0x5A3B 0x8656 # + 0x8657, //0x5A3C 0x8657 # + 0x8658, //0x5A3D 0x8658 # + 0x8659, //0x5A3E 0x8659 # + 0x865D, //0x5A3F 0x865D # + 0x8660, //0x5A40 0x8660 # + 0x8661, //0x5A41 0x8661 # + 0x8662, //0x5A42 0x8662 # + 0x8663, //0x5A43 0x8663 # + 0x8664, //0x5A44 0x8664 # + 0x8669, //0x5A45 0x8669 # + 0x866C, //0x5A46 0x866C # + 0x866F, //0x5A47 0x866F # + 0x8675, //0x5A48 0x8675 # + 0x8676, //0x5A49 0x8676 # + 0x8677, //0x5A4A 0x8677 # + 0x867A, //0x5A4B 0x867A # + 0x868D, //0x5A4C 0x868D # + 0x8691, //0x5A4D 0x8691 # + 0x8696, //0x5A4E 0x8696 # + 0x8698, //0x5A4F 0x8698 # + 0x869A, //0x5A50 0x869A # + 0x869C, //0x5A51 0x869C # + 0x86A1, //0x5A52 0x86A1 # + 0x86A6, //0x5A53 0x86A6 # + 0x86A7, //0x5A54 0x86A7 # + 0x86A8, //0x5A55 0x86A8 # + 0x86AD, //0x5A56 0x86AD # + 0x86B1, //0x5A57 0x86B1 # + 0x86B3, //0x5A58 0x86B3 # + 0x86B4, //0x5A59 0x86B4 # + 0x86B5, //0x5A5A 0x86B5 # + 0x86B7, //0x5A5B 0x86B7 # + 0x86B8, //0x5A5C 0x86B8 # + 0x86B9, //0x5A5D 0x86B9 # + 0x86BF, //0x5A5E 0x86BF # + 0x86C0, //0x5A5F 0x86C0 # + 0x86C1, //0x5A60 0x86C1 # + 0x86C3, //0x5A61 0x86C3 # + 0x86C5, //0x5A62 0x86C5 # + 0x86D1, //0x5A63 0x86D1 # + 0x86D2, //0x5A64 0x86D2 # + 0x86D5, //0x5A65 0x86D5 # + 0x86D7, //0x5A66 0x86D7 # + 0x86DA, //0x5A67 0x86DA # + 0x86DC, //0x5A68 0x86DC # + 0x86E0, //0x5A69 0x86E0 # + 0x86E3, //0x5A6A 0x86E3 # + 0x86E5, //0x5A6B 0x86E5 # + 0x86E7, //0x5A6C 0x86E7 # + 0x8688, //0x5A6D 0x8688 # + 0x86FA, //0x5A6E 0x86FA # + 0x86FC, //0x5A6F 0x86FC # + 0x86FD, //0x5A70 0x86FD # + 0x8704, //0x5A71 0x8704 # + 0x8705, //0x5A72 0x8705 # + 0x8707, //0x5A73 0x8707 # + 0x870B, //0x5A74 0x870B # + 0x870E, //0x5A75 0x870E # + 0x870F, //0x5A76 0x870F # + 0x8710, //0x5A77 0x8710 # + 0x8713, //0x5A78 0x8713 # + 0x8714, //0x5A79 0x8714 # + 0x8719, //0x5A7A 0x8719 # + 0x871E, //0x5A7B 0x871E # + 0x871F, //0x5A7C 0x871F # + 0x8721, //0x5A7D 0x8721 # + 0x8723 //0x5A7E 0x8723 # + }, + //59区 + { + 0x8728, //0x5B21 0x8728 # + 0x872E, //0x5B22 0x872E # + 0x872F, //0x5B23 0x872F # + 0x8731, //0x5B24 0x8731 # + 0x8732, //0x5B25 0x8732 # + 0x8739, //0x5B26 0x8739 # + 0x873A, //0x5B27 0x873A # + 0x873C, //0x5B28 0x873C # + 0x873D, //0x5B29 0x873D # + 0x873E, //0x5B2A 0x873E # + 0x8740, //0x5B2B 0x8740 # + 0x8743, //0x5B2C 0x8743 # + 0x8745, //0x5B2D 0x8745 # + 0x874D, //0x5B2E 0x874D # + 0x8758, //0x5B2F 0x8758 # + 0x875D, //0x5B30 0x875D # + 0x8761, //0x5B31 0x8761 # + 0x8764, //0x5B32 0x8764 # + 0x8765, //0x5B33 0x8765 # + 0x876F, //0x5B34 0x876F # + 0x8771, //0x5B35 0x8771 # + 0x8772, //0x5B36 0x8772 # + 0x877B, //0x5B37 0x877B # + 0x8783, //0x5B38 0x8783 # + 0x8784, //0x5B39 0x8784 # + 0x8785, //0x5B3A 0x8785 # + 0x8786, //0x5B3B 0x8786 # + 0x8787, //0x5B3C 0x8787 # + 0x8788, //0x5B3D 0x8788 # + 0x8789, //0x5B3E 0x8789 # + 0x878B, //0x5B3F 0x878B # + 0x878C, //0x5B40 0x878C # + 0x8790, //0x5B41 0x8790 # + 0x8793, //0x5B42 0x8793 # + 0x8795, //0x5B43 0x8795 # + 0x8797, //0x5B44 0x8797 # + 0x8798, //0x5B45 0x8798 # + 0x8799, //0x5B46 0x8799 # + 0x879E, //0x5B47 0x879E # + 0x87A0, //0x5B48 0x87A0 # + 0x87A3, //0x5B49 0x87A3 # + 0x87A7, //0x5B4A 0x87A7 # + 0x87AC, //0x5B4B 0x87AC # + 0x87AD, //0x5B4C 0x87AD # + 0x87AE, //0x5B4D 0x87AE # + 0x87B1, //0x5B4E 0x87B1 # + 0x87B5, //0x5B4F 0x87B5 # + 0x87BE, //0x5B50 0x87BE # + 0x87BF, //0x5B51 0x87BF # + 0x87C1, //0x5B52 0x87C1 # + 0x87C8, //0x5B53 0x87C8 # + 0x87C9, //0x5B54 0x87C9 # + 0x87CA, //0x5B55 0x87CA # + 0x87CE, //0x5B56 0x87CE # + 0x87D5, //0x5B57 0x87D5 # + 0x87D6, //0x5B58 0x87D6 # + 0x87D9, //0x5B59 0x87D9 # + 0x87DA, //0x5B5A 0x87DA # + 0x87DC, //0x5B5B 0x87DC # + 0x87DF, //0x5B5C 0x87DF # + 0x87E2, //0x5B5D 0x87E2 # + 0x87E3, //0x5B5E 0x87E3 # + 0x87E4, //0x5B5F 0x87E4 # + 0x87EA, //0x5B60 0x87EA # + 0x87EB, //0x5B61 0x87EB # + 0x87ED, //0x5B62 0x87ED # + 0x87F1, //0x5B63 0x87F1 # + 0x87F3, //0x5B64 0x87F3 # + 0x87F8, //0x5B65 0x87F8 # + 0x87FA, //0x5B66 0x87FA # + 0x87FF, //0x5B67 0x87FF # + 0x8801, //0x5B68 0x8801 # + 0x8803, //0x5B69 0x8803 # + 0x8806, //0x5B6A 0x8806 # + 0x8809, //0x5B6B 0x8809 # + 0x880A, //0x5B6C 0x880A # + 0x880B, //0x5B6D 0x880B # + 0x8810, //0x5B6E 0x8810 # + 0x8819, //0x5B6F 0x8819 # + 0x8812, //0x5B70 0x8812 # + 0x8813, //0x5B71 0x8813 # + 0x8814, //0x5B72 0x8814 # + 0x8818, //0x5B73 0x8818 # + 0x881A, //0x5B74 0x881A # + 0x881B, //0x5B75 0x881B # + 0x881C, //0x5B76 0x881C # + 0x881E, //0x5B77 0x881E # + 0x881F, //0x5B78 0x881F # + 0x8828, //0x5B79 0x8828 # + 0x882D, //0x5B7A 0x882D # + 0x882E, //0x5B7B 0x882E # + 0x8830, //0x5B7C 0x8830 # + 0x8832, //0x5B7D 0x8832 # + 0x8835 //0x5B7E 0x8835 # + }, + //60区 + { + 0x883A, //0x5C21 0x883A # + 0x883C, //0x5C22 0x883C # + 0x8841, //0x5C23 0x8841 # + 0x8843, //0x5C24 0x8843 # + 0x8845, //0x5C25 0x8845 # + 0x8848, //0x5C26 0x8848 # + 0x8849, //0x5C27 0x8849 # + 0x884A, //0x5C28 0x884A # + 0x884B, //0x5C29 0x884B # + 0x884E, //0x5C2A 0x884E # + 0x8851, //0x5C2B 0x8851 # + 0x8855, //0x5C2C 0x8855 # + 0x8856, //0x5C2D 0x8856 # + 0x8858, //0x5C2E 0x8858 # + 0x885A, //0x5C2F 0x885A # + 0x885C, //0x5C30 0x885C # + 0x885F, //0x5C31 0x885F # + 0x8860, //0x5C32 0x8860 # + 0x8864, //0x5C33 0x8864 # + 0x8869, //0x5C34 0x8869 # + 0x8871, //0x5C35 0x8871 # + 0x8879, //0x5C36 0x8879 # + 0x887B, //0x5C37 0x887B # + 0x8880, //0x5C38 0x8880 # + 0x8898, //0x5C39 0x8898 # + 0x889A, //0x5C3A 0x889A # + 0x889B, //0x5C3B 0x889B # + 0x889C, //0x5C3C 0x889C # + 0x889F, //0x5C3D 0x889F # + 0x88A0, //0x5C3E 0x88A0 # + 0x88A8, //0x5C3F 0x88A8 # + 0x88AA, //0x5C40 0x88AA # + 0x88BA, //0x5C41 0x88BA # + 0x88BD, //0x5C42 0x88BD # + 0x88BE, //0x5C43 0x88BE # + 0x88C0, //0x5C44 0x88C0 # + 0x88CA, //0x5C45 0x88CA # + 0x88CB, //0x5C46 0x88CB # + 0x88CC, //0x5C47 0x88CC # + 0x88CD, //0x5C48 0x88CD # + 0x88CE, //0x5C49 0x88CE # + 0x88D1, //0x5C4A 0x88D1 # + 0x88D2, //0x5C4B 0x88D2 # + 0x88D3, //0x5C4C 0x88D3 # + 0x88DB, //0x5C4D 0x88DB # + 0x88DE, //0x5C4E 0x88DE # + 0x88E7, //0x5C4F 0x88E7 # + 0x88EF, //0x5C50 0x88EF # + 0x88F0, //0x5C51 0x88F0 # + 0x88F1, //0x5C52 0x88F1 # + 0x88F5, //0x5C53 0x88F5 # + 0x88F7, //0x5C54 0x88F7 # + 0x8901, //0x5C55 0x8901 # + 0x8906, //0x5C56 0x8906 # + 0x890D, //0x5C57 0x890D # + 0x890E, //0x5C58 0x890E # + 0x890F, //0x5C59 0x890F # + 0x8915, //0x5C5A 0x8915 # + 0x8916, //0x5C5B 0x8916 # + 0x8918, //0x5C5C 0x8918 # + 0x8919, //0x5C5D 0x8919 # + 0x891A, //0x5C5E 0x891A # + 0x891C, //0x5C5F 0x891C # + 0x8920, //0x5C60 0x8920 # + 0x8926, //0x5C61 0x8926 # + 0x8927, //0x5C62 0x8927 # + 0x8928, //0x5C63 0x8928 # + 0x8930, //0x5C64 0x8930 # + 0x8931, //0x5C65 0x8931 # + 0x8932, //0x5C66 0x8932 # + 0x8935, //0x5C67 0x8935 # + 0x8939, //0x5C68 0x8939 # + 0x893A, //0x5C69 0x893A # + 0x893E, //0x5C6A 0x893E # + 0x8940, //0x5C6B 0x8940 # + 0x8942, //0x5C6C 0x8942 # + 0x8945, //0x5C6D 0x8945 # + 0x8946, //0x5C6E 0x8946 # + 0x8949, //0x5C6F 0x8949 # + 0x894F, //0x5C70 0x894F # + 0x8952, //0x5C71 0x8952 # + 0x8957, //0x5C72 0x8957 # + 0x895A, //0x5C73 0x895A # + 0x895B, //0x5C74 0x895B # + 0x895C, //0x5C75 0x895C # + 0x8961, //0x5C76 0x8961 # + 0x8962, //0x5C77 0x8962 # + 0x8963, //0x5C78 0x8963 # + 0x896B, //0x5C79 0x896B # + 0x896E, //0x5C7A 0x896E # + 0x8970, //0x5C7B 0x8970 # + 0x8973, //0x5C7C 0x8973 # + 0x8975, //0x5C7D 0x8975 # + 0x897A //0x5C7E 0x897A # + }, + //61区 + { + 0x897B, //0x5D21 0x897B # + 0x897C, //0x5D22 0x897C # + 0x897D, //0x5D23 0x897D # + 0x8989, //0x5D24 0x8989 # + 0x898D, //0x5D25 0x898D # + 0x8990, //0x5D26 0x8990 # + 0x8994, //0x5D27 0x8994 # + 0x8995, //0x5D28 0x8995 # + 0x899B, //0x5D29 0x899B # + 0x899C, //0x5D2A 0x899C # + 0x899F, //0x5D2B 0x899F # + 0x89A0, //0x5D2C 0x89A0 # + 0x89A5, //0x5D2D 0x89A5 # + 0x89B0, //0x5D2E 0x89B0 # + 0x89B4, //0x5D2F 0x89B4 # + 0x89B5, //0x5D30 0x89B5 # + 0x89B6, //0x5D31 0x89B6 # + 0x89B7, //0x5D32 0x89B7 # + 0x89BC, //0x5D33 0x89BC # + 0x89D4, //0x5D34 0x89D4 # + 0x89D5, //0x5D35 0x89D5 # + 0x89D6, //0x5D36 0x89D6 # + 0x89D7, //0x5D37 0x89D7 # + 0x89D8, //0x5D38 0x89D8 # + 0x89E5, //0x5D39 0x89E5 # + 0x89E9, //0x5D3A 0x89E9 # + 0x89EB, //0x5D3B 0x89EB # + 0x89ED, //0x5D3C 0x89ED # + 0x89F1, //0x5D3D 0x89F1 # + 0x89F3, //0x5D3E 0x89F3 # + 0x89F6, //0x5D3F 0x89F6 # + 0x89F9, //0x5D40 0x89F9 # + 0x89FD, //0x5D41 0x89FD # + 0x89FF, //0x5D42 0x89FF # + 0x8A04, //0x5D43 0x8A04 # + 0x8A05, //0x5D44 0x8A05 # + 0x8A07, //0x5D45 0x8A07 # + 0x8A0F, //0x5D46 0x8A0F # + 0x8A11, //0x5D47 0x8A11 # + 0x8A12, //0x5D48 0x8A12 # + 0x8A14, //0x5D49 0x8A14 # + 0x8A15, //0x5D4A 0x8A15 # + 0x8A1E, //0x5D4B 0x8A1E # + 0x8A20, //0x5D4C 0x8A20 # + 0x8A22, //0x5D4D 0x8A22 # + 0x8A24, //0x5D4E 0x8A24 # + 0x8A26, //0x5D4F 0x8A26 # + 0x8A2B, //0x5D50 0x8A2B # + 0x8A2C, //0x5D51 0x8A2C # + 0x8A2F, //0x5D52 0x8A2F # + 0x8A35, //0x5D53 0x8A35 # + 0x8A37, //0x5D54 0x8A37 # + 0x8A3D, //0x5D55 0x8A3D # + 0x8A3E, //0x5D56 0x8A3E # + 0x8A40, //0x5D57 0x8A40 # + 0x8A43, //0x5D58 0x8A43 # + 0x8A45, //0x5D59 0x8A45 # + 0x8A47, //0x5D5A 0x8A47 # + 0x8A49, //0x5D5B 0x8A49 # + 0x8A4D, //0x5D5C 0x8A4D # + 0x8A4E, //0x5D5D 0x8A4E # + 0x8A53, //0x5D5E 0x8A53 # + 0x8A56, //0x5D5F 0x8A56 # + 0x8A57, //0x5D60 0x8A57 # + 0x8A58, //0x5D61 0x8A58 # + 0x8A5C, //0x5D62 0x8A5C # + 0x8A5D, //0x5D63 0x8A5D # + 0x8A61, //0x5D64 0x8A61 # + 0x8A65, //0x5D65 0x8A65 # + 0x8A67, //0x5D66 0x8A67 # + 0x8A75, //0x5D67 0x8A75 # + 0x8A76, //0x5D68 0x8A76 # + 0x8A77, //0x5D69 0x8A77 # + 0x8A79, //0x5D6A 0x8A79 # + 0x8A7A, //0x5D6B 0x8A7A # + 0x8A7B, //0x5D6C 0x8A7B # + 0x8A7E, //0x5D6D 0x8A7E # + 0x8A7F, //0x5D6E 0x8A7F # + 0x8A80, //0x5D6F 0x8A80 # + 0x8A83, //0x5D70 0x8A83 # + 0x8A86, //0x5D71 0x8A86 # + 0x8A8B, //0x5D72 0x8A8B # + 0x8A8F, //0x5D73 0x8A8F # + 0x8A90, //0x5D74 0x8A90 # + 0x8A92, //0x5D75 0x8A92 # + 0x8A96, //0x5D76 0x8A96 # + 0x8A97, //0x5D77 0x8A97 # + 0x8A99, //0x5D78 0x8A99 # + 0x8A9F, //0x5D79 0x8A9F # + 0x8AA7, //0x5D7A 0x8AA7 # + 0x8AA9, //0x5D7B 0x8AA9 # + 0x8AAE, //0x5D7C 0x8AAE # + 0x8AAF, //0x5D7D 0x8AAF # + 0x8AB3 //0x5D7E 0x8AB3 # + }, + //62区 + { + 0x8AB6, //0x5E21 0x8AB6 # + 0x8AB7, //0x5E22 0x8AB7 # + 0x8ABB, //0x5E23 0x8ABB # + 0x8ABE, //0x5E24 0x8ABE # + 0x8AC3, //0x5E25 0x8AC3 # + 0x8AC6, //0x5E26 0x8AC6 # + 0x8AC8, //0x5E27 0x8AC8 # + 0x8AC9, //0x5E28 0x8AC9 # + 0x8ACA, //0x5E29 0x8ACA # + 0x8AD1, //0x5E2A 0x8AD1 # + 0x8AD3, //0x5E2B 0x8AD3 # + 0x8AD4, //0x5E2C 0x8AD4 # + 0x8AD5, //0x5E2D 0x8AD5 # + 0x8AD7, //0x5E2E 0x8AD7 # + 0x8ADD, //0x5E2F 0x8ADD # + 0x8ADF, //0x5E30 0x8ADF # + 0x8AEC, //0x5E31 0x8AEC # + 0x8AF0, //0x5E32 0x8AF0 # + 0x8AF4, //0x5E33 0x8AF4 # + 0x8AF5, //0x5E34 0x8AF5 # + 0x8AF6, //0x5E35 0x8AF6 # + 0x8AFC, //0x5E36 0x8AFC # + 0x8AFF, //0x5E37 0x8AFF # + 0x8B05, //0x5E38 0x8B05 # + 0x8B06, //0x5E39 0x8B06 # + 0x8B0B, //0x5E3A 0x8B0B # + 0x8B11, //0x5E3B 0x8B11 # + 0x8B1C, //0x5E3C 0x8B1C # + 0x8B1E, //0x5E3D 0x8B1E # + 0x8B1F, //0x5E3E 0x8B1F # + 0x8B0A, //0x5E3F 0x8B0A # + 0x8B2D, //0x5E40 0x8B2D # + 0x8B30, //0x5E41 0x8B30 # + 0x8B37, //0x5E42 0x8B37 # + 0x8B3C, //0x5E43 0x8B3C # + 0x8B42, //0x5E44 0x8B42 # + 0x8B43, //0x5E45 0x8B43 # + 0x8B44, //0x5E46 0x8B44 # + 0x8B45, //0x5E47 0x8B45 # + 0x8B46, //0x5E48 0x8B46 # + 0x8B48, //0x5E49 0x8B48 # + 0x8B52, //0x5E4A 0x8B52 # + 0x8B53, //0x5E4B 0x8B53 # + 0x8B54, //0x5E4C 0x8B54 # + 0x8B59, //0x5E4D 0x8B59 # + 0x8B4D, //0x5E4E 0x8B4D # + 0x8B5E, //0x5E4F 0x8B5E # + 0x8B63, //0x5E50 0x8B63 # + 0x8B6D, //0x5E51 0x8B6D # + 0x8B76, //0x5E52 0x8B76 # + 0x8B78, //0x5E53 0x8B78 # + 0x8B79, //0x5E54 0x8B79 # + 0x8B7C, //0x5E55 0x8B7C # + 0x8B7E, //0x5E56 0x8B7E # + 0x8B81, //0x5E57 0x8B81 # + 0x8B84, //0x5E58 0x8B84 # + 0x8B85, //0x5E59 0x8B85 # + 0x8B8B, //0x5E5A 0x8B8B # + 0x8B8D, //0x5E5B 0x8B8D # + 0x8B8F, //0x5E5C 0x8B8F # + 0x8B94, //0x5E5D 0x8B94 # + 0x8B95, //0x5E5E 0x8B95 # + 0x8B9C, //0x5E5F 0x8B9C # + 0x8B9E, //0x5E60 0x8B9E # + 0x8B9F, //0x5E61 0x8B9F # + 0x8C38, //0x5E62 0x8C38 # + 0x8C39, //0x5E63 0x8C39 # + 0x8C3D, //0x5E64 0x8C3D # + 0x8C3E, //0x5E65 0x8C3E # + 0x8C45, //0x5E66 0x8C45 # + 0x8C47, //0x5E67 0x8C47 # + 0x8C49, //0x5E68 0x8C49 # + 0x8C4B, //0x5E69 0x8C4B # + 0x8C4F, //0x5E6A 0x8C4F # + 0x8C51, //0x5E6B 0x8C51 # + 0x8C53, //0x5E6C 0x8C53 # + 0x8C54, //0x5E6D 0x8C54 # + 0x8C57, //0x5E6E 0x8C57 # + 0x8C58, //0x5E6F 0x8C58 # + 0x8C5B, //0x5E70 0x8C5B # + 0x8C5D, //0x5E71 0x8C5D # + 0x8C59, //0x5E72 0x8C59 # + 0x8C63, //0x5E73 0x8C63 # + 0x8C64, //0x5E74 0x8C64 # + 0x8C66, //0x5E75 0x8C66 # + 0x8C68, //0x5E76 0x8C68 # + 0x8C69, //0x5E77 0x8C69 # + 0x8C6D, //0x5E78 0x8C6D # + 0x8C73, //0x5E79 0x8C73 # + 0x8C75, //0x5E7A 0x8C75 # + 0x8C76, //0x5E7B 0x8C76 # + 0x8C7B, //0x5E7C 0x8C7B # + 0x8C7E, //0x5E7D 0x8C7E # + 0x8C86 //0x5E7E 0x8C86 # + }, + //63区 + { + 0x8C87, //0x5F21 0x8C87 # + 0x8C8B, //0x5F22 0x8C8B # + 0x8C90, //0x5F23 0x8C90 # + 0x8C92, //0x5F24 0x8C92 # + 0x8C93, //0x5F25 0x8C93 # + 0x8C99, //0x5F26 0x8C99 # + 0x8C9B, //0x5F27 0x8C9B # + 0x8C9C, //0x5F28 0x8C9C # + 0x8CA4, //0x5F29 0x8CA4 # + 0x8CB9, //0x5F2A 0x8CB9 # + 0x8CBA, //0x5F2B 0x8CBA # + 0x8CC5, //0x5F2C 0x8CC5 # + 0x8CC6, //0x5F2D 0x8CC6 # + 0x8CC9, //0x5F2E 0x8CC9 # + 0x8CCB, //0x5F2F 0x8CCB # + 0x8CCF, //0x5F30 0x8CCF # + 0x8CD6, //0x5F31 0x8CD6 # + 0x8CD5, //0x5F32 0x8CD5 # + 0x8CD9, //0x5F33 0x8CD9 # + 0x8CDD, //0x5F34 0x8CDD # + 0x8CE1, //0x5F35 0x8CE1 # + 0x8CE8, //0x5F36 0x8CE8 # + 0x8CEC, //0x5F37 0x8CEC # + 0x8CEF, //0x5F38 0x8CEF # + 0x8CF0, //0x5F39 0x8CF0 # + 0x8CF2, //0x5F3A 0x8CF2 # + 0x8CF5, //0x5F3B 0x8CF5 # + 0x8CF7, //0x5F3C 0x8CF7 # + 0x8CF8, //0x5F3D 0x8CF8 # + 0x8CFE, //0x5F3E 0x8CFE # + 0x8CFF, //0x5F3F 0x8CFF # + 0x8D01, //0x5F40 0x8D01 # + 0x8D03, //0x5F41 0x8D03 # + 0x8D09, //0x5F42 0x8D09 # + 0x8D12, //0x5F43 0x8D12 # + 0x8D17, //0x5F44 0x8D17 # + 0x8D1B, //0x5F45 0x8D1B # + 0x8D65, //0x5F46 0x8D65 # + 0x8D69, //0x5F47 0x8D69 # + 0x8D6C, //0x5F48 0x8D6C # + 0x8D6E, //0x5F49 0x8D6E # + 0x8D7F, //0x5F4A 0x8D7F # + 0x8D82, //0x5F4B 0x8D82 # + 0x8D84, //0x5F4C 0x8D84 # + 0x8D88, //0x5F4D 0x8D88 # + 0x8D8D, //0x5F4E 0x8D8D # + 0x8D90, //0x5F4F 0x8D90 # + 0x8D91, //0x5F50 0x8D91 # + 0x8D95, //0x5F51 0x8D95 # + 0x8D9E, //0x5F52 0x8D9E # + 0x8D9F, //0x5F53 0x8D9F # + 0x8DA0, //0x5F54 0x8DA0 # + 0x8DA6, //0x5F55 0x8DA6 # + 0x8DAB, //0x5F56 0x8DAB # + 0x8DAC, //0x5F57 0x8DAC # + 0x8DAF, //0x5F58 0x8DAF # + 0x8DB2, //0x5F59 0x8DB2 # + 0x8DB5, //0x5F5A 0x8DB5 # + 0x8DB7, //0x5F5B 0x8DB7 # + 0x8DB9, //0x5F5C 0x8DB9 # + 0x8DBB, //0x5F5D 0x8DBB # + 0x8DC0, //0x5F5E 0x8DC0 # + 0x8DC5, //0x5F5F 0x8DC5 # + 0x8DC6, //0x5F60 0x8DC6 # + 0x8DC7, //0x5F61 0x8DC7 # + 0x8DC8, //0x5F62 0x8DC8 # + 0x8DCA, //0x5F63 0x8DCA # + 0x8DCE, //0x5F64 0x8DCE # + 0x8DD1, //0x5F65 0x8DD1 # + 0x8DD4, //0x5F66 0x8DD4 # + 0x8DD5, //0x5F67 0x8DD5 # + 0x8DD7, //0x5F68 0x8DD7 # + 0x8DD9, //0x5F69 0x8DD9 # + 0x8DE4, //0x5F6A 0x8DE4 # + 0x8DE5, //0x5F6B 0x8DE5 # + 0x8DE7, //0x5F6C 0x8DE7 # + 0x8DEC, //0x5F6D 0x8DEC # + 0x8DF0, //0x5F6E 0x8DF0 # + 0x8DBC, //0x5F6F 0x8DBC # + 0x8DF1, //0x5F70 0x8DF1 # + 0x8DF2, //0x5F71 0x8DF2 # + 0x8DF4, //0x5F72 0x8DF4 # + 0x8DFD, //0x5F73 0x8DFD # + 0x8E01, //0x5F74 0x8E01 # + 0x8E04, //0x5F75 0x8E04 # + 0x8E05, //0x5F76 0x8E05 # + 0x8E06, //0x5F77 0x8E06 # + 0x8E0B, //0x5F78 0x8E0B # + 0x8E11, //0x5F79 0x8E11 # + 0x8E14, //0x5F7A 0x8E14 # + 0x8E16, //0x5F7B 0x8E16 # + 0x8E20, //0x5F7C 0x8E20 # + 0x8E21, //0x5F7D 0x8E21 # + 0x8E22 //0x5F7E 0x8E22 # + }, + //64区 + { + 0x8E23, //0x6021 0x8E23 # + 0x8E26, //0x6022 0x8E26 # + 0x8E27, //0x6023 0x8E27 # + 0x8E31, //0x6024 0x8E31 # + 0x8E33, //0x6025 0x8E33 # + 0x8E36, //0x6026 0x8E36 # + 0x8E37, //0x6027 0x8E37 # + 0x8E38, //0x6028 0x8E38 # + 0x8E39, //0x6029 0x8E39 # + 0x8E3D, //0x602A 0x8E3D # + 0x8E40, //0x602B 0x8E40 # + 0x8E41, //0x602C 0x8E41 # + 0x8E4B, //0x602D 0x8E4B # + 0x8E4D, //0x602E 0x8E4D # + 0x8E4E, //0x602F 0x8E4E # + 0x8E4F, //0x6030 0x8E4F # + 0x8E54, //0x6031 0x8E54 # + 0x8E5B, //0x6032 0x8E5B # + 0x8E5C, //0x6033 0x8E5C # + 0x8E5D, //0x6034 0x8E5D # + 0x8E5E, //0x6035 0x8E5E # + 0x8E61, //0x6036 0x8E61 # + 0x8E62, //0x6037 0x8E62 # + 0x8E69, //0x6038 0x8E69 # + 0x8E6C, //0x6039 0x8E6C # + 0x8E6D, //0x603A 0x8E6D # + 0x8E6F, //0x603B 0x8E6F # + 0x8E70, //0x603C 0x8E70 # + 0x8E71, //0x603D 0x8E71 # + 0x8E79, //0x603E 0x8E79 # + 0x8E7A, //0x603F 0x8E7A # + 0x8E7B, //0x6040 0x8E7B # + 0x8E82, //0x6041 0x8E82 # + 0x8E83, //0x6042 0x8E83 # + 0x8E89, //0x6043 0x8E89 # + 0x8E90, //0x6044 0x8E90 # + 0x8E92, //0x6045 0x8E92 # + 0x8E95, //0x6046 0x8E95 # + 0x8E9A, //0x6047 0x8E9A # + 0x8E9B, //0x6048 0x8E9B # + 0x8E9D, //0x6049 0x8E9D # + 0x8E9E, //0x604A 0x8E9E # + 0x8EA2, //0x604B 0x8EA2 # + 0x8EA7, //0x604C 0x8EA7 # + 0x8EA9, //0x604D 0x8EA9 # + 0x8EAD, //0x604E 0x8EAD # + 0x8EAE, //0x604F 0x8EAE # + 0x8EB3, //0x6050 0x8EB3 # + 0x8EB5, //0x6051 0x8EB5 # + 0x8EBA, //0x6052 0x8EBA # + 0x8EBB, //0x6053 0x8EBB # + 0x8EC0, //0x6054 0x8EC0 # + 0x8EC1, //0x6055 0x8EC1 # + 0x8EC3, //0x6056 0x8EC3 # + 0x8EC4, //0x6057 0x8EC4 # + 0x8EC7, //0x6058 0x8EC7 # + 0x8ECF, //0x6059 0x8ECF # + 0x8ED1, //0x605A 0x8ED1 # + 0x8ED4, //0x605B 0x8ED4 # + 0x8EDC, //0x605C 0x8EDC # + 0x8EE8, //0x605D 0x8EE8 # + 0x8EEE, //0x605E 0x8EEE # + 0x8EF0, //0x605F 0x8EF0 # + 0x8EF1, //0x6060 0x8EF1 # + 0x8EF7, //0x6061 0x8EF7 # + 0x8EF9, //0x6062 0x8EF9 # + 0x8EFA, //0x6063 0x8EFA # + 0x8EED, //0x6064 0x8EED # + 0x8F00, //0x6065 0x8F00 # + 0x8F02, //0x6066 0x8F02 # + 0x8F07, //0x6067 0x8F07 # + 0x8F08, //0x6068 0x8F08 # + 0x8F0F, //0x6069 0x8F0F # + 0x8F10, //0x606A 0x8F10 # + 0x8F16, //0x606B 0x8F16 # + 0x8F17, //0x606C 0x8F17 # + 0x8F18, //0x606D 0x8F18 # + 0x8F1E, //0x606E 0x8F1E # + 0x8F20, //0x606F 0x8F20 # + 0x8F21, //0x6070 0x8F21 # + 0x8F23, //0x6071 0x8F23 # + 0x8F25, //0x6072 0x8F25 # + 0x8F27, //0x6073 0x8F27 # + 0x8F28, //0x6074 0x8F28 # + 0x8F2C, //0x6075 0x8F2C # + 0x8F2D, //0x6076 0x8F2D # + 0x8F2E, //0x6077 0x8F2E # + 0x8F34, //0x6078 0x8F34 # + 0x8F35, //0x6079 0x8F35 # + 0x8F36, //0x607A 0x8F36 # + 0x8F37, //0x607B 0x8F37 # + 0x8F3A, //0x607C 0x8F3A # + 0x8F40, //0x607D 0x8F40 # + 0x8F41 //0x607E 0x8F41 # + }, + //65区 + { + 0x8F43, //0x6121 0x8F43 # + 0x8F47, //0x6122 0x8F47 # + 0x8F4F, //0x6123 0x8F4F # + 0x8F51, //0x6124 0x8F51 # + 0x8F52, //0x6125 0x8F52 # + 0x8F53, //0x6126 0x8F53 # + 0x8F54, //0x6127 0x8F54 # + 0x8F55, //0x6128 0x8F55 # + 0x8F58, //0x6129 0x8F58 # + 0x8F5D, //0x612A 0x8F5D # + 0x8F5E, //0x612B 0x8F5E # + 0x8F65, //0x612C 0x8F65 # + 0x8F9D, //0x612D 0x8F9D # + 0x8FA0, //0x612E 0x8FA0 # + 0x8FA1, //0x612F 0x8FA1 # + 0x8FA4, //0x6130 0x8FA4 # + 0x8FA5, //0x6131 0x8FA5 # + 0x8FA6, //0x6132 0x8FA6 # + 0x8FB5, //0x6133 0x8FB5 # + 0x8FB6, //0x6134 0x8FB6 # + 0x8FB8, //0x6135 0x8FB8 # + 0x8FBE, //0x6136 0x8FBE # + 0x8FC0, //0x6137 0x8FC0 # + 0x8FC1, //0x6138 0x8FC1 # + 0x8FC6, //0x6139 0x8FC6 # + 0x8FCA, //0x613A 0x8FCA # + 0x8FCB, //0x613B 0x8FCB # + 0x8FCD, //0x613C 0x8FCD # + 0x8FD0, //0x613D 0x8FD0 # + 0x8FD2, //0x613E 0x8FD2 # + 0x8FD3, //0x613F 0x8FD3 # + 0x8FD5, //0x6140 0x8FD5 # + 0x8FE0, //0x6141 0x8FE0 # + 0x8FE3, //0x6142 0x8FE3 # + 0x8FE4, //0x6143 0x8FE4 # + 0x8FE8, //0x6144 0x8FE8 # + 0x8FEE, //0x6145 0x8FEE # + 0x8FF1, //0x6146 0x8FF1 # + 0x8FF5, //0x6147 0x8FF5 # + 0x8FF6, //0x6148 0x8FF6 # + 0x8FFB, //0x6149 0x8FFB # + 0x8FFE, //0x614A 0x8FFE # + 0x9002, //0x614B 0x9002 # + 0x9004, //0x614C 0x9004 # + 0x9008, //0x614D 0x9008 # + 0x900C, //0x614E 0x900C # + 0x9018, //0x614F 0x9018 # + 0x901B, //0x6150 0x901B # + 0x9028, //0x6151 0x9028 # + 0x9029, //0x6152 0x9029 # + 0x902F, //0x6153 0x902F # + 0x902A, //0x6154 0x902A # + 0x902C, //0x6155 0x902C # + 0x902D, //0x6156 0x902D # + 0x9033, //0x6157 0x9033 # + 0x9034, //0x6158 0x9034 # + 0x9037, //0x6159 0x9037 # + 0x903F, //0x615A 0x903F # + 0x9043, //0x615B 0x9043 # + 0x9044, //0x615C 0x9044 # + 0x904C, //0x615D 0x904C # + 0x905B, //0x615E 0x905B # + 0x905D, //0x615F 0x905D # + 0x9062, //0x6160 0x9062 # + 0x9066, //0x6161 0x9066 # + 0x9067, //0x6162 0x9067 # + 0x906C, //0x6163 0x906C # + 0x9070, //0x6164 0x9070 # + 0x9074, //0x6165 0x9074 # + 0x9079, //0x6166 0x9079 # + 0x9085, //0x6167 0x9085 # + 0x9088, //0x6168 0x9088 # + 0x908B, //0x6169 0x908B # + 0x908C, //0x616A 0x908C # + 0x908E, //0x616B 0x908E # + 0x9090, //0x616C 0x9090 # + 0x9095, //0x616D 0x9095 # + 0x9097, //0x616E 0x9097 # + 0x9098, //0x616F 0x9098 # + 0x9099, //0x6170 0x9099 # + 0x909B, //0x6171 0x909B # + 0x90A0, //0x6172 0x90A0 # + 0x90A1, //0x6173 0x90A1 # + 0x90A2, //0x6174 0x90A2 # + 0x90A5, //0x6175 0x90A5 # + 0x90B0, //0x6176 0x90B0 # + 0x90B2, //0x6177 0x90B2 # + 0x90B3, //0x6178 0x90B3 # + 0x90B4, //0x6179 0x90B4 # + 0x90B6, //0x617A 0x90B6 # + 0x90BD, //0x617B 0x90BD # + 0x90CC, //0x617C 0x90CC # + 0x90BE, //0x617D 0x90BE # + 0x90C3 //0x617E 0x90C3 # + }, + //66区 + { + 0x90C4, //0x6221 0x90C4 # + 0x90C5, //0x6222 0x90C5 # + 0x90C7, //0x6223 0x90C7 # + 0x90C8, //0x6224 0x90C8 # + 0x90D5, //0x6225 0x90D5 # + 0x90D7, //0x6226 0x90D7 # + 0x90D8, //0x6227 0x90D8 # + 0x90D9, //0x6228 0x90D9 # + 0x90DC, //0x6229 0x90DC # + 0x90DD, //0x622A 0x90DD # + 0x90DF, //0x622B 0x90DF # + 0x90E5, //0x622C 0x90E5 # + 0x90D2, //0x622D 0x90D2 # + 0x90F6, //0x622E 0x90F6 # + 0x90EB, //0x622F 0x90EB # + 0x90EF, //0x6230 0x90EF # + 0x90F0, //0x6231 0x90F0 # + 0x90F4, //0x6232 0x90F4 # + 0x90FE, //0x6233 0x90FE # + 0x90FF, //0x6234 0x90FF # + 0x9100, //0x6235 0x9100 # + 0x9104, //0x6236 0x9104 # + 0x9105, //0x6237 0x9105 # + 0x9106, //0x6238 0x9106 # + 0x9108, //0x6239 0x9108 # + 0x910D, //0x623A 0x910D # + 0x9110, //0x623B 0x9110 # + 0x9114, //0x623C 0x9114 # + 0x9116, //0x623D 0x9116 # + 0x9117, //0x623E 0x9117 # + 0x9118, //0x623F 0x9118 # + 0x911A, //0x6240 0x911A # + 0x911C, //0x6241 0x911C # + 0x911E, //0x6242 0x911E # + 0x9120, //0x6243 0x9120 # + 0x9125, //0x6244 0x9125 # + 0x9122, //0x6245 0x9122 # + 0x9123, //0x6246 0x9123 # + 0x9127, //0x6247 0x9127 # + 0x9129, //0x6248 0x9129 # + 0x912E, //0x6249 0x912E # + 0x912F, //0x624A 0x912F # + 0x9131, //0x624B 0x9131 # + 0x9134, //0x624C 0x9134 # + 0x9136, //0x624D 0x9136 # + 0x9137, //0x624E 0x9137 # + 0x9139, //0x624F 0x9139 # + 0x913A, //0x6250 0x913A # + 0x913C, //0x6251 0x913C # + 0x913D, //0x6252 0x913D # + 0x9143, //0x6253 0x9143 # + 0x9147, //0x6254 0x9147 # + 0x9148, //0x6255 0x9148 # + 0x914F, //0x6256 0x914F # + 0x9153, //0x6257 0x9153 # + 0x9157, //0x6258 0x9157 # + 0x9159, //0x6259 0x9159 # + 0x915A, //0x625A 0x915A # + 0x915B, //0x625B 0x915B # + 0x9161, //0x625C 0x9161 # + 0x9164, //0x625D 0x9164 # + 0x9167, //0x625E 0x9167 # + 0x916D, //0x625F 0x916D # + 0x9174, //0x6260 0x9174 # + 0x9179, //0x6261 0x9179 # + 0x917A, //0x6262 0x917A # + 0x917B, //0x6263 0x917B # + 0x9181, //0x6264 0x9181 # + 0x9183, //0x6265 0x9183 # + 0x9185, //0x6266 0x9185 # + 0x9186, //0x6267 0x9186 # + 0x918A, //0x6268 0x918A # + 0x918E, //0x6269 0x918E # + 0x9191, //0x626A 0x9191 # + 0x9193, //0x626B 0x9193 # + 0x9194, //0x626C 0x9194 # + 0x9195, //0x626D 0x9195 # + 0x9198, //0x626E 0x9198 # + 0x919E, //0x626F 0x919E # + 0x91A1, //0x6270 0x91A1 # + 0x91A6, //0x6271 0x91A6 # + 0x91A8, //0x6272 0x91A8 # + 0x91AC, //0x6273 0x91AC # + 0x91AD, //0x6274 0x91AD # + 0x91AE, //0x6275 0x91AE # + 0x91B0, //0x6276 0x91B0 # + 0x91B1, //0x6277 0x91B1 # + 0x91B2, //0x6278 0x91B2 # + 0x91B3, //0x6279 0x91B3 # + 0x91B6, //0x627A 0x91B6 # + 0x91BB, //0x627B 0x91BB # + 0x91BC, //0x627C 0x91BC # + 0x91BD, //0x627D 0x91BD # + 0x91BF //0x627E 0x91BF # + }, + //67区 + { + 0x91C2, //0x6321 0x91C2 # + 0x91C3, //0x6322 0x91C3 # + 0x91C5, //0x6323 0x91C5 # + 0x91D3, //0x6324 0x91D3 # + 0x91D4, //0x6325 0x91D4 # + 0x91D7, //0x6326 0x91D7 # + 0x91D9, //0x6327 0x91D9 # + 0x91DA, //0x6328 0x91DA # + 0x91DE, //0x6329 0x91DE # + 0x91E4, //0x632A 0x91E4 # + 0x91E5, //0x632B 0x91E5 # + 0x91E9, //0x632C 0x91E9 # + 0x91EA, //0x632D 0x91EA # + 0x91EC, //0x632E 0x91EC # + 0x91ED, //0x632F 0x91ED # + 0x91EE, //0x6330 0x91EE # + 0x91EF, //0x6331 0x91EF # + 0x91F0, //0x6332 0x91F0 # + 0x91F1, //0x6333 0x91F1 # + 0x91F7, //0x6334 0x91F7 # + 0x91F9, //0x6335 0x91F9 # + 0x91FB, //0x6336 0x91FB # + 0x91FD, //0x6337 0x91FD # + 0x9200, //0x6338 0x9200 # + 0x9201, //0x6339 0x9201 # + 0x9204, //0x633A 0x9204 # + 0x9205, //0x633B 0x9205 # + 0x9206, //0x633C 0x9206 # + 0x9207, //0x633D 0x9207 # + 0x9209, //0x633E 0x9209 # + 0x920A, //0x633F 0x920A # + 0x920C, //0x6340 0x920C # + 0x9210, //0x6341 0x9210 # + 0x9212, //0x6342 0x9212 # + 0x9213, //0x6343 0x9213 # + 0x9216, //0x6344 0x9216 # + 0x9218, //0x6345 0x9218 # + 0x921C, //0x6346 0x921C # + 0x921D, //0x6347 0x921D # + 0x9223, //0x6348 0x9223 # + 0x9224, //0x6349 0x9224 # + 0x9225, //0x634A 0x9225 # + 0x9226, //0x634B 0x9226 # + 0x9228, //0x634C 0x9228 # + 0x922E, //0x634D 0x922E # + 0x922F, //0x634E 0x922F # + 0x9230, //0x634F 0x9230 # + 0x9233, //0x6350 0x9233 # + 0x9235, //0x6351 0x9235 # + 0x9236, //0x6352 0x9236 # + 0x9238, //0x6353 0x9238 # + 0x9239, //0x6354 0x9239 # + 0x923A, //0x6355 0x923A # + 0x923C, //0x6356 0x923C # + 0x923E, //0x6357 0x923E # + 0x9240, //0x6358 0x9240 # + 0x9242, //0x6359 0x9242 # + 0x9243, //0x635A 0x9243 # + 0x9246, //0x635B 0x9246 # + 0x9247, //0x635C 0x9247 # + 0x924A, //0x635D 0x924A # + 0x924D, //0x635E 0x924D # + 0x924E, //0x635F 0x924E # + 0x924F, //0x6360 0x924F # + 0x9251, //0x6361 0x9251 # + 0x9258, //0x6362 0x9258 # + 0x9259, //0x6363 0x9259 # + 0x925C, //0x6364 0x925C # + 0x925D, //0x6365 0x925D # + 0x9260, //0x6366 0x9260 # + 0x9261, //0x6367 0x9261 # + 0x9265, //0x6368 0x9265 # + 0x9267, //0x6369 0x9267 # + 0x9268, //0x636A 0x9268 # + 0x9269, //0x636B 0x9269 # + 0x926E, //0x636C 0x926E # + 0x926F, //0x636D 0x926F # + 0x9270, //0x636E 0x9270 # + 0x9275, //0x636F 0x9275 # + 0x9276, //0x6370 0x9276 # + 0x9277, //0x6371 0x9277 # + 0x9278, //0x6372 0x9278 # + 0x9279, //0x6373 0x9279 # + 0x927B, //0x6374 0x927B # + 0x927C, //0x6375 0x927C # + 0x927D, //0x6376 0x927D # + 0x927F, //0x6377 0x927F # + 0x9288, //0x6378 0x9288 # + 0x9289, //0x6379 0x9289 # + 0x928A, //0x637A 0x928A # + 0x928D, //0x637B 0x928D # + 0x928E, //0x637C 0x928E # + 0x9292, //0x637D 0x9292 # + 0x9297 //0x637E 0x9297 # + }, + //68区 + { + 0x9299, //0x6421 0x9299 # + 0x929F, //0x6422 0x929F # + 0x92A0, //0x6423 0x92A0 # + 0x92A4, //0x6424 0x92A4 # + 0x92A5, //0x6425 0x92A5 # + 0x92A7, //0x6426 0x92A7 # + 0x92A8, //0x6427 0x92A8 # + 0x92AB, //0x6428 0x92AB # + 0x92AF, //0x6429 0x92AF # + 0x92B2, //0x642A 0x92B2 # + 0x92B6, //0x642B 0x92B6 # + 0x92B8, //0x642C 0x92B8 # + 0x92BA, //0x642D 0x92BA # + 0x92BB, //0x642E 0x92BB # + 0x92BC, //0x642F 0x92BC # + 0x92BD, //0x6430 0x92BD # + 0x92BF, //0x6431 0x92BF # + 0x92C0, //0x6432 0x92C0 # + 0x92C1, //0x6433 0x92C1 # + 0x92C2, //0x6434 0x92C2 # + 0x92C3, //0x6435 0x92C3 # + 0x92C5, //0x6436 0x92C5 # + 0x92C6, //0x6437 0x92C6 # + 0x92C7, //0x6438 0x92C7 # + 0x92C8, //0x6439 0x92C8 # + 0x92CB, //0x643A 0x92CB # + 0x92CC, //0x643B 0x92CC # + 0x92CD, //0x643C 0x92CD # + 0x92CE, //0x643D 0x92CE # + 0x92D0, //0x643E 0x92D0 # + 0x92D3, //0x643F 0x92D3 # + 0x92D5, //0x6440 0x92D5 # + 0x92D7, //0x6441 0x92D7 # + 0x92D8, //0x6442 0x92D8 # + 0x92D9, //0x6443 0x92D9 # + 0x92DC, //0x6444 0x92DC # + 0x92DD, //0x6445 0x92DD # + 0x92DF, //0x6446 0x92DF # + 0x92E0, //0x6447 0x92E0 # + 0x92E1, //0x6448 0x92E1 # + 0x92E3, //0x6449 0x92E3 # + 0x92E5, //0x644A 0x92E5 # + 0x92E7, //0x644B 0x92E7 # + 0x92E8, //0x644C 0x92E8 # + 0x92EC, //0x644D 0x92EC # + 0x92EE, //0x644E 0x92EE # + 0x92F0, //0x644F 0x92F0 # + 0x92F9, //0x6450 0x92F9 # + 0x92FB, //0x6451 0x92FB # + 0x92FF, //0x6452 0x92FF # + 0x9300, //0x6453 0x9300 # + 0x9302, //0x6454 0x9302 # + 0x9308, //0x6455 0x9308 # + 0x930D, //0x6456 0x930D # + 0x9311, //0x6457 0x9311 # + 0x9314, //0x6458 0x9314 # + 0x9315, //0x6459 0x9315 # + 0x931C, //0x645A 0x931C # + 0x931D, //0x645B 0x931D # + 0x931E, //0x645C 0x931E # + 0x931F, //0x645D 0x931F # + 0x9321, //0x645E 0x9321 # + 0x9324, //0x645F 0x9324 # + 0x9325, //0x6460 0x9325 # + 0x9327, //0x6461 0x9327 # + 0x9329, //0x6462 0x9329 # + 0x932A, //0x6463 0x932A # + 0x9333, //0x6464 0x9333 # + 0x9334, //0x6465 0x9334 # + 0x9336, //0x6466 0x9336 # + 0x9337, //0x6467 0x9337 # + 0x9347, //0x6468 0x9347 # + 0x9348, //0x6469 0x9348 # + 0x9349, //0x646A 0x9349 # + 0x9350, //0x646B 0x9350 # + 0x9351, //0x646C 0x9351 # + 0x9352, //0x646D 0x9352 # + 0x9355, //0x646E 0x9355 # + 0x9357, //0x646F 0x9357 # + 0x9358, //0x6470 0x9358 # + 0x935A, //0x6471 0x935A # + 0x935E, //0x6472 0x935E # + 0x9364, //0x6473 0x9364 # + 0x9365, //0x6474 0x9365 # + 0x9367, //0x6475 0x9367 # + 0x9369, //0x6476 0x9369 # + 0x936A, //0x6477 0x936A # + 0x936D, //0x6478 0x936D # + 0x936F, //0x6479 0x936F # + 0x9370, //0x647A 0x9370 # + 0x9371, //0x647B 0x9371 # + 0x9373, //0x647C 0x9373 # + 0x9374, //0x647D 0x9374 # + 0x9376 //0x647E 0x9376 # + }, + //69区 + { + 0x937A, //0x6521 0x937A # + 0x937D, //0x6522 0x937D # + 0x937F, //0x6523 0x937F # + 0x9380, //0x6524 0x9380 # + 0x9381, //0x6525 0x9381 # + 0x9382, //0x6526 0x9382 # + 0x9388, //0x6527 0x9388 # + 0x938A, //0x6528 0x938A # + 0x938B, //0x6529 0x938B # + 0x938D, //0x652A 0x938D # + 0x938F, //0x652B 0x938F # + 0x9392, //0x652C 0x9392 # + 0x9395, //0x652D 0x9395 # + 0x9398, //0x652E 0x9398 # + 0x939B, //0x652F 0x939B # + 0x939E, //0x6530 0x939E # + 0x93A1, //0x6531 0x93A1 # + 0x93A3, //0x6532 0x93A3 # + 0x93A4, //0x6533 0x93A4 # + 0x93A6, //0x6534 0x93A6 # + 0x93A8, //0x6535 0x93A8 # + 0x93AB, //0x6536 0x93AB # + 0x93B4, //0x6537 0x93B4 # + 0x93B5, //0x6538 0x93B5 # + 0x93B6, //0x6539 0x93B6 # + 0x93BA, //0x653A 0x93BA # + 0x93A9, //0x653B 0x93A9 # + 0x93C1, //0x653C 0x93C1 # + 0x93C4, //0x653D 0x93C4 # + 0x93C5, //0x653E 0x93C5 # + 0x93C6, //0x653F 0x93C6 # + 0x93C7, //0x6540 0x93C7 # + 0x93C9, //0x6541 0x93C9 # + 0x93CA, //0x6542 0x93CA # + 0x93CB, //0x6543 0x93CB # + 0x93CC, //0x6544 0x93CC # + 0x93CD, //0x6545 0x93CD # + 0x93D3, //0x6546 0x93D3 # + 0x93D9, //0x6547 0x93D9 # + 0x93DC, //0x6548 0x93DC # + 0x93DE, //0x6549 0x93DE # + 0x93DF, //0x654A 0x93DF # + 0x93E2, //0x654B 0x93E2 # + 0x93E6, //0x654C 0x93E6 # + 0x93E7, //0x654D 0x93E7 # + 0x93F9, //0x654E 0x93F9 # + 0x93F7, //0x654F 0x93F7 # + 0x93F8, //0x6550 0x93F8 # + 0x93FA, //0x6551 0x93FA # + 0x93FB, //0x6552 0x93FB # + 0x93FD, //0x6553 0x93FD # + 0x9401, //0x6554 0x9401 # + 0x9402, //0x6555 0x9402 # + 0x9404, //0x6556 0x9404 # + 0x9408, //0x6557 0x9408 # + 0x9409, //0x6558 0x9409 # + 0x940D, //0x6559 0x940D # + 0x940E, //0x655A 0x940E # + 0x940F, //0x655B 0x940F # + 0x9415, //0x655C 0x9415 # + 0x9416, //0x655D 0x9416 # + 0x9417, //0x655E 0x9417 # + 0x941F, //0x655F 0x941F # + 0x942E, //0x6560 0x942E # + 0x942F, //0x6561 0x942F # + 0x9431, //0x6562 0x9431 # + 0x9432, //0x6563 0x9432 # + 0x9433, //0x6564 0x9433 # + 0x9434, //0x6565 0x9434 # + 0x943B, //0x6566 0x943B # + 0x943F, //0x6567 0x943F # + 0x943D, //0x6568 0x943D # + 0x9443, //0x6569 0x9443 # + 0x9445, //0x656A 0x9445 # + 0x9448, //0x656B 0x9448 # + 0x944A, //0x656C 0x944A # + 0x944C, //0x656D 0x944C # + 0x9455, //0x656E 0x9455 # + 0x9459, //0x656F 0x9459 # + 0x945C, //0x6570 0x945C # + 0x945F, //0x6571 0x945F # + 0x9461, //0x6572 0x9461 # + 0x9463, //0x6573 0x9463 # + 0x9468, //0x6574 0x9468 # + 0x946B, //0x6575 0x946B # + 0x946D, //0x6576 0x946D # + 0x946E, //0x6577 0x946E # + 0x946F, //0x6578 0x946F # + 0x9471, //0x6579 0x9471 # + 0x9472, //0x657A 0x9472 # + 0x9484, //0x657B 0x9484 # + 0x9483, //0x657C 0x9483 # + 0x9578, //0x657D 0x9578 # + 0x9579 //0x657E 0x9579 # + }, + //70区 + { + 0x957E, //0x6621 0x957E # + 0x9584, //0x6622 0x9584 # + 0x9588, //0x6623 0x9588 # + 0x958C, //0x6624 0x958C # + 0x958D, //0x6625 0x958D # + 0x958E, //0x6626 0x958E # + 0x959D, //0x6627 0x959D # + 0x959E, //0x6628 0x959E # + 0x959F, //0x6629 0x959F # + 0x95A1, //0x662A 0x95A1 # + 0x95A6, //0x662B 0x95A6 # + 0x95A9, //0x662C 0x95A9 # + 0x95AB, //0x662D 0x95AB # + 0x95AC, //0x662E 0x95AC # + 0x95B4, //0x662F 0x95B4 # + 0x95B6, //0x6630 0x95B6 # + 0x95BA, //0x6631 0x95BA # + 0x95BD, //0x6632 0x95BD # + 0x95BF, //0x6633 0x95BF # + 0x95C6, //0x6634 0x95C6 # + 0x95C8, //0x6635 0x95C8 # + 0x95C9, //0x6636 0x95C9 # + 0x95CB, //0x6637 0x95CB # + 0x95D0, //0x6638 0x95D0 # + 0x95D1, //0x6639 0x95D1 # + 0x95D2, //0x663A 0x95D2 # + 0x95D3, //0x663B 0x95D3 # + 0x95D9, //0x663C 0x95D9 # + 0x95DA, //0x663D 0x95DA # + 0x95DD, //0x663E 0x95DD # + 0x95DE, //0x663F 0x95DE # + 0x95DF, //0x6640 0x95DF # + 0x95E0, //0x6641 0x95E0 # + 0x95E4, //0x6642 0x95E4 # + 0x95E6, //0x6643 0x95E6 # + 0x961D, //0x6644 0x961D # + 0x961E, //0x6645 0x961E # + 0x9622, //0x6646 0x9622 # + 0x9624, //0x6647 0x9624 # + 0x9625, //0x6648 0x9625 # + 0x9626, //0x6649 0x9626 # + 0x962C, //0x664A 0x962C # + 0x9631, //0x664B 0x9631 # + 0x9633, //0x664C 0x9633 # + 0x9637, //0x664D 0x9637 # + 0x9638, //0x664E 0x9638 # + 0x9639, //0x664F 0x9639 # + 0x963A, //0x6650 0x963A # + 0x963C, //0x6651 0x963C # + 0x963D, //0x6652 0x963D # + 0x9641, //0x6653 0x9641 # + 0x9652, //0x6654 0x9652 # + 0x9654, //0x6655 0x9654 # + 0x9656, //0x6656 0x9656 # + 0x9657, //0x6657 0x9657 # + 0x9658, //0x6658 0x9658 # + 0x9661, //0x6659 0x9661 # + 0x966E, //0x665A 0x966E # + 0x9674, //0x665B 0x9674 # + 0x967B, //0x665C 0x967B # + 0x967C, //0x665D 0x967C # + 0x967E, //0x665E 0x967E # + 0x967F, //0x665F 0x967F # + 0x9681, //0x6660 0x9681 # + 0x9682, //0x6661 0x9682 # + 0x9683, //0x6662 0x9683 # + 0x9684, //0x6663 0x9684 # + 0x9689, //0x6664 0x9689 # + 0x9691, //0x6665 0x9691 # + 0x9696, //0x6666 0x9696 # + 0x969A, //0x6667 0x969A # + 0x969D, //0x6668 0x969D # + 0x969F, //0x6669 0x969F # + 0x96A4, //0x666A 0x96A4 # + 0x96A5, //0x666B 0x96A5 # + 0x96A6, //0x666C 0x96A6 # + 0x96A9, //0x666D 0x96A9 # + 0x96AE, //0x666E 0x96AE # + 0x96AF, //0x666F 0x96AF # + 0x96B3, //0x6670 0x96B3 # + 0x96BA, //0x6671 0x96BA # + 0x96CA, //0x6672 0x96CA # + 0x96D2, //0x6673 0x96D2 # + 0x5DB2, //0x6674 0x5DB2 # + 0x96D8, //0x6675 0x96D8 # + 0x96DA, //0x6676 0x96DA # + 0x96DD, //0x6677 0x96DD # + 0x96DE, //0x6678 0x96DE # + 0x96DF, //0x6679 0x96DF # + 0x96E9, //0x667A 0x96E9 # + 0x96EF, //0x667B 0x96EF # + 0x96F1, //0x667C 0x96F1 # + 0x96FA, //0x667D 0x96FA # + 0x9702 //0x667E 0x9702 # + }, + //71区 + { + 0x9703, //0x6721 0x9703 # + 0x9705, //0x6722 0x9705 # + 0x9709, //0x6723 0x9709 # + 0x971A, //0x6724 0x971A # + 0x971B, //0x6725 0x971B # + 0x971D, //0x6726 0x971D # + 0x9721, //0x6727 0x9721 # + 0x9722, //0x6728 0x9722 # + 0x9723, //0x6729 0x9723 # + 0x9728, //0x672A 0x9728 # + 0x9731, //0x672B 0x9731 # + 0x9733, //0x672C 0x9733 # + 0x9741, //0x672D 0x9741 # + 0x9743, //0x672E 0x9743 # + 0x974A, //0x672F 0x974A # + 0x974E, //0x6730 0x974E # + 0x974F, //0x6731 0x974F # + 0x9755, //0x6732 0x9755 # + 0x9757, //0x6733 0x9757 # + 0x9758, //0x6734 0x9758 # + 0x975A, //0x6735 0x975A # + 0x975B, //0x6736 0x975B # + 0x9763, //0x6737 0x9763 # + 0x9767, //0x6738 0x9767 # + 0x976A, //0x6739 0x976A # + 0x976E, //0x673A 0x976E # + 0x9773, //0x673B 0x9773 # + 0x9776, //0x673C 0x9776 # + 0x9777, //0x673D 0x9777 # + 0x9778, //0x673E 0x9778 # + 0x977B, //0x673F 0x977B # + 0x977D, //0x6740 0x977D # + 0x977F, //0x6741 0x977F # + 0x9780, //0x6742 0x9780 # + 0x9789, //0x6743 0x9789 # + 0x9795, //0x6744 0x9795 # + 0x9796, //0x6745 0x9796 # + 0x9797, //0x6746 0x9797 # + 0x9799, //0x6747 0x9799 # + 0x979A, //0x6748 0x979A # + 0x979E, //0x6749 0x979E # + 0x979F, //0x674A 0x979F # + 0x97A2, //0x674B 0x97A2 # + 0x97AC, //0x674C 0x97AC # + 0x97AE, //0x674D 0x97AE # + 0x97B1, //0x674E 0x97B1 # + 0x97B2, //0x674F 0x97B2 # + 0x97B5, //0x6750 0x97B5 # + 0x97B6, //0x6751 0x97B6 # + 0x97B8, //0x6752 0x97B8 # + 0x97B9, //0x6753 0x97B9 # + 0x97BA, //0x6754 0x97BA # + 0x97BC, //0x6755 0x97BC # + 0x97BE, //0x6756 0x97BE # + 0x97BF, //0x6757 0x97BF # + 0x97C1, //0x6758 0x97C1 # + 0x97C4, //0x6759 0x97C4 # + 0x97C5, //0x675A 0x97C5 # + 0x97C7, //0x675B 0x97C7 # + 0x97C9, //0x675C 0x97C9 # + 0x97CA, //0x675D 0x97CA # + 0x97CC, //0x675E 0x97CC # + 0x97CD, //0x675F 0x97CD # + 0x97CE, //0x6760 0x97CE # + 0x97D0, //0x6761 0x97D0 # + 0x97D1, //0x6762 0x97D1 # + 0x97D4, //0x6763 0x97D4 # + 0x97D7, //0x6764 0x97D7 # + 0x97D8, //0x6765 0x97D8 # + 0x97D9, //0x6766 0x97D9 # + 0x97DD, //0x6767 0x97DD # + 0x97DE, //0x6768 0x97DE # + 0x97E0, //0x6769 0x97E0 # + 0x97DB, //0x676A 0x97DB # + 0x97E1, //0x676B 0x97E1 # + 0x97E4, //0x676C 0x97E4 # + 0x97EF, //0x676D 0x97EF # + 0x97F1, //0x676E 0x97F1 # + 0x97F4, //0x676F 0x97F4 # + 0x97F7, //0x6770 0x97F7 # + 0x97F8, //0x6771 0x97F8 # + 0x97FA, //0x6772 0x97FA # + 0x9807, //0x6773 0x9807 # + 0x980A, //0x6774 0x980A # + 0x9819, //0x6775 0x9819 # + 0x980D, //0x6776 0x980D # + 0x980E, //0x6777 0x980E # + 0x9814, //0x6778 0x9814 # + 0x9816, //0x6779 0x9816 # + 0x981C, //0x677A 0x981C # + 0x981E, //0x677B 0x981E # + 0x9820, //0x677C 0x9820 # + 0x9823, //0x677D 0x9823 # + 0x9826 //0x677E 0x9826 # + }, + //72区 + { + 0x982B, //0x6821 0x982B # + 0x982E, //0x6822 0x982E # + 0x982F, //0x6823 0x982F # + 0x9830, //0x6824 0x9830 # + 0x9832, //0x6825 0x9832 # + 0x9833, //0x6826 0x9833 # + 0x9835, //0x6827 0x9835 # + 0x9825, //0x6828 0x9825 # + 0x983E, //0x6829 0x983E # + 0x9844, //0x682A 0x9844 # + 0x9847, //0x682B 0x9847 # + 0x984A, //0x682C 0x984A # + 0x9851, //0x682D 0x9851 # + 0x9852, //0x682E 0x9852 # + 0x9853, //0x682F 0x9853 # + 0x9856, //0x6830 0x9856 # + 0x9857, //0x6831 0x9857 # + 0x9859, //0x6832 0x9859 # + 0x985A, //0x6833 0x985A # + 0x9862, //0x6834 0x9862 # + 0x9863, //0x6835 0x9863 # + 0x9865, //0x6836 0x9865 # + 0x9866, //0x6837 0x9866 # + 0x986A, //0x6838 0x986A # + 0x986C, //0x6839 0x986C # + 0x98AB, //0x683A 0x98AB # + 0x98AD, //0x683B 0x98AD # + 0x98AE, //0x683C 0x98AE # + 0x98B0, //0x683D 0x98B0 # + 0x98B4, //0x683E 0x98B4 # + 0x98B7, //0x683F 0x98B7 # + 0x98B8, //0x6840 0x98B8 # + 0x98BA, //0x6841 0x98BA # + 0x98BB, //0x6842 0x98BB # + 0x98BF, //0x6843 0x98BF # + 0x98C2, //0x6844 0x98C2 # + 0x98C5, //0x6845 0x98C5 # + 0x98C8, //0x6846 0x98C8 # + 0x98CC, //0x6847 0x98CC # + 0x98E1, //0x6848 0x98E1 # + 0x98E3, //0x6849 0x98E3 # + 0x98E5, //0x684A 0x98E5 # + 0x98E6, //0x684B 0x98E6 # + 0x98E7, //0x684C 0x98E7 # + 0x98EA, //0x684D 0x98EA # + 0x98F3, //0x684E 0x98F3 # + 0x98F6, //0x684F 0x98F6 # + 0x9902, //0x6850 0x9902 # + 0x9907, //0x6851 0x9907 # + 0x9908, //0x6852 0x9908 # + 0x9911, //0x6853 0x9911 # + 0x9915, //0x6854 0x9915 # + 0x9916, //0x6855 0x9916 # + 0x9917, //0x6856 0x9917 # + 0x991A, //0x6857 0x991A # + 0x991B, //0x6858 0x991B # + 0x991C, //0x6859 0x991C # + 0x991F, //0x685A 0x991F # + 0x9922, //0x685B 0x9922 # + 0x9926, //0x685C 0x9926 # + 0x9927, //0x685D 0x9927 # + 0x992B, //0x685E 0x992B # + 0x9931, //0x685F 0x9931 # + 0x9932, //0x6860 0x9932 # + 0x9933, //0x6861 0x9933 # + 0x9934, //0x6862 0x9934 # + 0x9935, //0x6863 0x9935 # + 0x9939, //0x6864 0x9939 # + 0x993A, //0x6865 0x993A # + 0x993B, //0x6866 0x993B # + 0x993C, //0x6867 0x993C # + 0x9940, //0x6868 0x9940 # + 0x9941, //0x6869 0x9941 # + 0x9946, //0x686A 0x9946 # + 0x9947, //0x686B 0x9947 # + 0x9948, //0x686C 0x9948 # + 0x994D, //0x686D 0x994D # + 0x994E, //0x686E 0x994E # + 0x9954, //0x686F 0x9954 # + 0x9958, //0x6870 0x9958 # + 0x9959, //0x6871 0x9959 # + 0x995B, //0x6872 0x995B # + 0x995C, //0x6873 0x995C # + 0x995E, //0x6874 0x995E # + 0x995F, //0x6875 0x995F # + 0x9960, //0x6876 0x9960 # + 0x999B, //0x6877 0x999B # + 0x999D, //0x6878 0x999D # + 0x999F, //0x6879 0x999F # + 0x99A6, //0x687A 0x99A6 # + 0x99B0, //0x687B 0x99B0 # + 0x99B1, //0x687C 0x99B1 # + 0x99B2, //0x687D 0x99B2 # + 0x99B5 //0x687E 0x99B5 # + }, + //73区 + { + 0x99B9, //0x6921 0x99B9 # + 0x99BA, //0x6922 0x99BA # + 0x99BD, //0x6923 0x99BD # + 0x99BF, //0x6924 0x99BF # + 0x99C3, //0x6925 0x99C3 # + 0x99C9, //0x6926 0x99C9 # + 0x99D3, //0x6927 0x99D3 # + 0x99D4, //0x6928 0x99D4 # + 0x99D9, //0x6929 0x99D9 # + 0x99DA, //0x692A 0x99DA # + 0x99DC, //0x692B 0x99DC # + 0x99DE, //0x692C 0x99DE # + 0x99E7, //0x692D 0x99E7 # + 0x99EA, //0x692E 0x99EA # + 0x99EB, //0x692F 0x99EB # + 0x99EC, //0x6930 0x99EC # + 0x99F0, //0x6931 0x99F0 # + 0x99F4, //0x6932 0x99F4 # + 0x99F5, //0x6933 0x99F5 # + 0x99F9, //0x6934 0x99F9 # + 0x99FD, //0x6935 0x99FD # + 0x99FE, //0x6936 0x99FE # + 0x9A02, //0x6937 0x9A02 # + 0x9A03, //0x6938 0x9A03 # + 0x9A04, //0x6939 0x9A04 # + 0x9A0B, //0x693A 0x9A0B # + 0x9A0C, //0x693B 0x9A0C # + 0x9A10, //0x693C 0x9A10 # + 0x9A11, //0x693D 0x9A11 # + 0x9A16, //0x693E 0x9A16 # + 0x9A1E, //0x693F 0x9A1E # + 0x9A20, //0x6940 0x9A20 # + 0x9A22, //0x6941 0x9A22 # + 0x9A23, //0x6942 0x9A23 # + 0x9A24, //0x6943 0x9A24 # + 0x9A27, //0x6944 0x9A27 # + 0x9A2D, //0x6945 0x9A2D # + 0x9A2E, //0x6946 0x9A2E # + 0x9A33, //0x6947 0x9A33 # + 0x9A35, //0x6948 0x9A35 # + 0x9A36, //0x6949 0x9A36 # + 0x9A38, //0x694A 0x9A38 # + 0x9A47, //0x694B 0x9A47 # + 0x9A41, //0x694C 0x9A41 # + 0x9A44, //0x694D 0x9A44 # + 0x9A4A, //0x694E 0x9A4A # + 0x9A4B, //0x694F 0x9A4B # + 0x9A4C, //0x6950 0x9A4C # + 0x9A4E, //0x6951 0x9A4E # + 0x9A51, //0x6952 0x9A51 # + 0x9A54, //0x6953 0x9A54 # + 0x9A56, //0x6954 0x9A56 # + 0x9A5D, //0x6955 0x9A5D # + 0x9AAA, //0x6956 0x9AAA # + 0x9AAC, //0x6957 0x9AAC # + 0x9AAE, //0x6958 0x9AAE # + 0x9AAF, //0x6959 0x9AAF # + 0x9AB2, //0x695A 0x9AB2 # + 0x9AB4, //0x695B 0x9AB4 # + 0x9AB5, //0x695C 0x9AB5 # + 0x9AB6, //0x695D 0x9AB6 # + 0x9AB9, //0x695E 0x9AB9 # + 0x9ABB, //0x695F 0x9ABB # + 0x9ABE, //0x6960 0x9ABE # + 0x9ABF, //0x6961 0x9ABF # + 0x9AC1, //0x6962 0x9AC1 # + 0x9AC3, //0x6963 0x9AC3 # + 0x9AC6, //0x6964 0x9AC6 # + 0x9AC8, //0x6965 0x9AC8 # + 0x9ACE, //0x6966 0x9ACE # + 0x9AD0, //0x6967 0x9AD0 # + 0x9AD2, //0x6968 0x9AD2 # + 0x9AD5, //0x6969 0x9AD5 # + 0x9AD6, //0x696A 0x9AD6 # + 0x9AD7, //0x696B 0x9AD7 # + 0x9ADB, //0x696C 0x9ADB # + 0x9ADC, //0x696D 0x9ADC # + 0x9AE0, //0x696E 0x9AE0 # + 0x9AE4, //0x696F 0x9AE4 # + 0x9AE5, //0x6970 0x9AE5 # + 0x9AE7, //0x6971 0x9AE7 # + 0x9AE9, //0x6972 0x9AE9 # + 0x9AEC, //0x6973 0x9AEC # + 0x9AF2, //0x6974 0x9AF2 # + 0x9AF3, //0x6975 0x9AF3 # + 0x9AF5, //0x6976 0x9AF5 # + 0x9AF9, //0x6977 0x9AF9 # + 0x9AFA, //0x6978 0x9AFA # + 0x9AFD, //0x6979 0x9AFD # + 0x9AFF, //0x697A 0x9AFF # + 0x9B00, //0x697B 0x9B00 # + 0x9B01, //0x697C 0x9B01 # + 0x9B02, //0x697D 0x9B02 # + 0x9B03 //0x697E 0x9B03 # + }, + //74区 + { + 0x9B04, //0x6A21 0x9B04 # + 0x9B05, //0x6A22 0x9B05 # + 0x9B08, //0x6A23 0x9B08 # + 0x9B09, //0x6A24 0x9B09 # + 0x9B0B, //0x6A25 0x9B0B # + 0x9B0C, //0x6A26 0x9B0C # + 0x9B0D, //0x6A27 0x9B0D # + 0x9B0E, //0x6A28 0x9B0E # + 0x9B10, //0x6A29 0x9B10 # + 0x9B12, //0x6A2A 0x9B12 # + 0x9B16, //0x6A2B 0x9B16 # + 0x9B19, //0x6A2C 0x9B19 # + 0x9B1B, //0x6A2D 0x9B1B # + 0x9B1C, //0x6A2E 0x9B1C # + 0x9B20, //0x6A2F 0x9B20 # + 0x9B26, //0x6A30 0x9B26 # + 0x9B2B, //0x6A31 0x9B2B # + 0x9B2D, //0x6A32 0x9B2D # + 0x9B33, //0x6A33 0x9B33 # + 0x9B34, //0x6A34 0x9B34 # + 0x9B35, //0x6A35 0x9B35 # + 0x9B37, //0x6A36 0x9B37 # + 0x9B39, //0x6A37 0x9B39 # + 0x9B3A, //0x6A38 0x9B3A # + 0x9B3D, //0x6A39 0x9B3D # + 0x9B48, //0x6A3A 0x9B48 # + 0x9B4B, //0x6A3B 0x9B4B # + 0x9B4C, //0x6A3C 0x9B4C # + 0x9B55, //0x6A3D 0x9B55 # + 0x9B56, //0x6A3E 0x9B56 # + 0x9B57, //0x6A3F 0x9B57 # + 0x9B5B, //0x6A40 0x9B5B # + 0x9B5E, //0x6A41 0x9B5E # + 0x9B61, //0x6A42 0x9B61 # + 0x9B63, //0x6A43 0x9B63 # + 0x9B65, //0x6A44 0x9B65 # + 0x9B66, //0x6A45 0x9B66 # + 0x9B68, //0x6A46 0x9B68 # + 0x9B6A, //0x6A47 0x9B6A # + 0x9B6B, //0x6A48 0x9B6B # + 0x9B6C, //0x6A49 0x9B6C # + 0x9B6D, //0x6A4A 0x9B6D # + 0x9B6E, //0x6A4B 0x9B6E # + 0x9B73, //0x6A4C 0x9B73 # + 0x9B75, //0x6A4D 0x9B75 # + 0x9B77, //0x6A4E 0x9B77 # + 0x9B78, //0x6A4F 0x9B78 # + 0x9B79, //0x6A50 0x9B79 # + 0x9B7F, //0x6A51 0x9B7F # + 0x9B80, //0x6A52 0x9B80 # + 0x9B84, //0x6A53 0x9B84 # + 0x9B85, //0x6A54 0x9B85 # + 0x9B86, //0x6A55 0x9B86 # + 0x9B87, //0x6A56 0x9B87 # + 0x9B89, //0x6A57 0x9B89 # + 0x9B8A, //0x6A58 0x9B8A # + 0x9B8B, //0x6A59 0x9B8B # + 0x9B8D, //0x6A5A 0x9B8D # + 0x9B8F, //0x6A5B 0x9B8F # + 0x9B90, //0x6A5C 0x9B90 # + 0x9B94, //0x6A5D 0x9B94 # + 0x9B9A, //0x6A5E 0x9B9A # + 0x9B9D, //0x6A5F 0x9B9D # + 0x9B9E, //0x6A60 0x9B9E # + 0x9BA6, //0x6A61 0x9BA6 # + 0x9BA7, //0x6A62 0x9BA7 # + 0x9BA9, //0x6A63 0x9BA9 # + 0x9BAC, //0x6A64 0x9BAC # + 0x9BB0, //0x6A65 0x9BB0 # + 0x9BB1, //0x6A66 0x9BB1 # + 0x9BB2, //0x6A67 0x9BB2 # + 0x9BB7, //0x6A68 0x9BB7 # + 0x9BB8, //0x6A69 0x9BB8 # + 0x9BBB, //0x6A6A 0x9BBB # + 0x9BBC, //0x6A6B 0x9BBC # + 0x9BBE, //0x6A6C 0x9BBE # + 0x9BBF, //0x6A6D 0x9BBF # + 0x9BC1, //0x6A6E 0x9BC1 # + 0x9BC7, //0x6A6F 0x9BC7 # + 0x9BC8, //0x6A70 0x9BC8 # + 0x9BCE, //0x6A71 0x9BCE # + 0x9BD0, //0x6A72 0x9BD0 # + 0x9BD7, //0x6A73 0x9BD7 # + 0x9BD8, //0x6A74 0x9BD8 # + 0x9BDD, //0x6A75 0x9BDD # + 0x9BDF, //0x6A76 0x9BDF # + 0x9BE5, //0x6A77 0x9BE5 # + 0x9BE7, //0x6A78 0x9BE7 # + 0x9BEA, //0x6A79 0x9BEA # + 0x9BEB, //0x6A7A 0x9BEB # + 0x9BEF, //0x6A7B 0x9BEF # + 0x9BF3, //0x6A7C 0x9BF3 # + 0x9BF7, //0x6A7D 0x9BF7 # + 0x9BF8 //0x6A7E 0x9BF8 # + }, + //75区 + { + 0x9BF9, //0x6B21 0x9BF9 # + 0x9BFA, //0x6B22 0x9BFA # + 0x9BFD, //0x6B23 0x9BFD # + 0x9BFF, //0x6B24 0x9BFF # + 0x9C00, //0x6B25 0x9C00 # + 0x9C02, //0x6B26 0x9C02 # + 0x9C0B, //0x6B27 0x9C0B # + 0x9C0F, //0x6B28 0x9C0F # + 0x9C11, //0x6B29 0x9C11 # + 0x9C16, //0x6B2A 0x9C16 # + 0x9C18, //0x6B2B 0x9C18 # + 0x9C19, //0x6B2C 0x9C19 # + 0x9C1A, //0x6B2D 0x9C1A # + 0x9C1C, //0x6B2E 0x9C1C # + 0x9C1E, //0x6B2F 0x9C1E # + 0x9C22, //0x6B30 0x9C22 # + 0x9C23, //0x6B31 0x9C23 # + 0x9C26, //0x6B32 0x9C26 # + 0x9C27, //0x6B33 0x9C27 # + 0x9C28, //0x6B34 0x9C28 # + 0x9C29, //0x6B35 0x9C29 # + 0x9C2A, //0x6B36 0x9C2A # + 0x9C31, //0x6B37 0x9C31 # + 0x9C35, //0x6B38 0x9C35 # + 0x9C36, //0x6B39 0x9C36 # + 0x9C37, //0x6B3A 0x9C37 # + 0x9C3D, //0x6B3B 0x9C3D # + 0x9C41, //0x6B3C 0x9C41 # + 0x9C43, //0x6B3D 0x9C43 # + 0x9C44, //0x6B3E 0x9C44 # + 0x9C45, //0x6B3F 0x9C45 # + 0x9C49, //0x6B40 0x9C49 # + 0x9C4A, //0x6B41 0x9C4A # + 0x9C4E, //0x6B42 0x9C4E # + 0x9C4F, //0x6B43 0x9C4F # + 0x9C50, //0x6B44 0x9C50 # + 0x9C53, //0x6B45 0x9C53 # + 0x9C54, //0x6B46 0x9C54 # + 0x9C56, //0x6B47 0x9C56 # + 0x9C58, //0x6B48 0x9C58 # + 0x9C5B, //0x6B49 0x9C5B # + 0x9C5D, //0x6B4A 0x9C5D # + 0x9C5E, //0x6B4B 0x9C5E # + 0x9C5F, //0x6B4C 0x9C5F # + 0x9C63, //0x6B4D 0x9C63 # + 0x9C69, //0x6B4E 0x9C69 # + 0x9C6A, //0x6B4F 0x9C6A # + 0x9C5C, //0x6B50 0x9C5C # + 0x9C6B, //0x6B51 0x9C6B # + 0x9C68, //0x6B52 0x9C68 # + 0x9C6E, //0x6B53 0x9C6E # + 0x9C70, //0x6B54 0x9C70 # + 0x9C72, //0x6B55 0x9C72 # + 0x9C75, //0x6B56 0x9C75 # + 0x9C77, //0x6B57 0x9C77 # + 0x9C7B, //0x6B58 0x9C7B # + 0x9CE6, //0x6B59 0x9CE6 # + 0x9CF2, //0x6B5A 0x9CF2 # + 0x9CF7, //0x6B5B 0x9CF7 # + 0x9CF9, //0x6B5C 0x9CF9 # + 0x9D0B, //0x6B5D 0x9D0B # + 0x9D02, //0x6B5E 0x9D02 # + 0x9D11, //0x6B5F 0x9D11 # + 0x9D17, //0x6B60 0x9D17 # + 0x9D18, //0x6B61 0x9D18 # + 0x9D1C, //0x6B62 0x9D1C # + 0x9D1D, //0x6B63 0x9D1D # + 0x9D1E, //0x6B64 0x9D1E # + 0x9D2F, //0x6B65 0x9D2F # + 0x9D30, //0x6B66 0x9D30 # + 0x9D32, //0x6B67 0x9D32 # + 0x9D33, //0x6B68 0x9D33 # + 0x9D34, //0x6B69 0x9D34 # + 0x9D3A, //0x6B6A 0x9D3A # + 0x9D3C, //0x6B6B 0x9D3C # + 0x9D45, //0x6B6C 0x9D45 # + 0x9D3D, //0x6B6D 0x9D3D # + 0x9D42, //0x6B6E 0x9D42 # + 0x9D43, //0x6B6F 0x9D43 # + 0x9D47, //0x6B70 0x9D47 # + 0x9D4A, //0x6B71 0x9D4A # + 0x9D53, //0x6B72 0x9D53 # + 0x9D54, //0x6B73 0x9D54 # + 0x9D5F, //0x6B74 0x9D5F # + 0x9D63, //0x6B75 0x9D63 # + 0x9D62, //0x6B76 0x9D62 # + 0x9D65, //0x6B77 0x9D65 # + 0x9D69, //0x6B78 0x9D69 # + 0x9D6A, //0x6B79 0x9D6A # + 0x9D6B, //0x6B7A 0x9D6B # + 0x9D70, //0x6B7B 0x9D70 # + 0x9D76, //0x6B7C 0x9D76 # + 0x9D77, //0x6B7D 0x9D77 # + 0x9D7B //0x6B7E 0x9D7B # + }, + //76区 + { + 0x9D7C, //0x6C21 0x9D7C # + 0x9D7E, //0x6C22 0x9D7E # + 0x9D83, //0x6C23 0x9D83 # + 0x9D84, //0x6C24 0x9D84 # + 0x9D86, //0x6C25 0x9D86 # + 0x9D8A, //0x6C26 0x9D8A # + 0x9D8D, //0x6C27 0x9D8D # + 0x9D8E, //0x6C28 0x9D8E # + 0x9D92, //0x6C29 0x9D92 # + 0x9D93, //0x6C2A 0x9D93 # + 0x9D95, //0x6C2B 0x9D95 # + 0x9D96, //0x6C2C 0x9D96 # + 0x9D97, //0x6C2D 0x9D97 # + 0x9D98, //0x6C2E 0x9D98 # + 0x9DA1, //0x6C2F 0x9DA1 # + 0x9DAA, //0x6C30 0x9DAA # + 0x9DAC, //0x6C31 0x9DAC # + 0x9DAE, //0x6C32 0x9DAE # + 0x9DB1, //0x6C33 0x9DB1 # + 0x9DB5, //0x6C34 0x9DB5 # + 0x9DB9, //0x6C35 0x9DB9 # + 0x9DBC, //0x6C36 0x9DBC # + 0x9DBF, //0x6C37 0x9DBF # + 0x9DC3, //0x6C38 0x9DC3 # + 0x9DC7, //0x6C39 0x9DC7 # + 0x9DC9, //0x6C3A 0x9DC9 # + 0x9DCA, //0x6C3B 0x9DCA # + 0x9DD4, //0x6C3C 0x9DD4 # + 0x9DD5, //0x6C3D 0x9DD5 # + 0x9DD6, //0x6C3E 0x9DD6 # + 0x9DD7, //0x6C3F 0x9DD7 # + 0x9DDA, //0x6C40 0x9DDA # + 0x9DDE, //0x6C41 0x9DDE # + 0x9DDF, //0x6C42 0x9DDF # + 0x9DE0, //0x6C43 0x9DE0 # + 0x9DE5, //0x6C44 0x9DE5 # + 0x9DE7, //0x6C45 0x9DE7 # + 0x9DE9, //0x6C46 0x9DE9 # + 0x9DEB, //0x6C47 0x9DEB # + 0x9DEE, //0x6C48 0x9DEE # + 0x9DF0, //0x6C49 0x9DF0 # + 0x9DF3, //0x6C4A 0x9DF3 # + 0x9DF4, //0x6C4B 0x9DF4 # + 0x9DFE, //0x6C4C 0x9DFE # + 0x9E0A, //0x6C4D 0x9E0A # + 0x9E02, //0x6C4E 0x9E02 # + 0x9E07, //0x6C4F 0x9E07 # + 0x9E0E, //0x6C50 0x9E0E # + 0x9E10, //0x6C51 0x9E10 # + 0x9E11, //0x6C52 0x9E11 # + 0x9E12, //0x6C53 0x9E12 # + 0x9E15, //0x6C54 0x9E15 # + 0x9E16, //0x6C55 0x9E16 # + 0x9E19, //0x6C56 0x9E19 # + 0x9E1C, //0x6C57 0x9E1C # + 0x9E1D, //0x6C58 0x9E1D # + 0x9E7A, //0x6C59 0x9E7A # + 0x9E7B, //0x6C5A 0x9E7B # + 0x9E7C, //0x6C5B 0x9E7C # + 0x9E80, //0x6C5C 0x9E80 # + 0x9E82, //0x6C5D 0x9E82 # + 0x9E83, //0x6C5E 0x9E83 # + 0x9E84, //0x6C5F 0x9E84 # + 0x9E85, //0x6C60 0x9E85 # + 0x9E87, //0x6C61 0x9E87 # + 0x9E8E, //0x6C62 0x9E8E # + 0x9E8F, //0x6C63 0x9E8F # + 0x9E96, //0x6C64 0x9E96 # + 0x9E98, //0x6C65 0x9E98 # + 0x9E9B, //0x6C66 0x9E9B # + 0x9E9E, //0x6C67 0x9E9E # + 0x9EA4, //0x6C68 0x9EA4 # + 0x9EA8, //0x6C69 0x9EA8 # + 0x9EAC, //0x6C6A 0x9EAC # + 0x9EAE, //0x6C6B 0x9EAE # + 0x9EAF, //0x6C6C 0x9EAF # + 0x9EB0, //0x6C6D 0x9EB0 # + 0x9EB3, //0x6C6E 0x9EB3 # + 0x9EB4, //0x6C6F 0x9EB4 # + 0x9EB5, //0x6C70 0x9EB5 # + 0x9EC6, //0x6C71 0x9EC6 # + 0x9EC8, //0x6C72 0x9EC8 # + 0x9ECB, //0x6C73 0x9ECB # + 0x9ED5, //0x6C74 0x9ED5 # + 0x9EDF, //0x6C75 0x9EDF # + 0x9EE4, //0x6C76 0x9EE4 # + 0x9EE7, //0x6C77 0x9EE7 # + 0x9EEC, //0x6C78 0x9EEC # + 0x9EED, //0x6C79 0x9EED # + 0x9EEE, //0x6C7A 0x9EEE # + 0x9EF0, //0x6C7B 0x9EF0 # + 0x9EF1, //0x6C7C 0x9EF1 # + 0x9EF2, //0x6C7D 0x9EF2 # + 0x9EF5 //0x6C7E 0x9EF5 # + }, + //77区 + { + 0x9EF8, //0x6D21 0x9EF8 # + 0x9EFF, //0x6D22 0x9EFF # + 0x9F02, //0x6D23 0x9F02 # + 0x9F03, //0x6D24 0x9F03 # + 0x9F09, //0x6D25 0x9F09 # + 0x9F0F, //0x6D26 0x9F0F # + 0x9F10, //0x6D27 0x9F10 # + 0x9F11, //0x6D28 0x9F11 # + 0x9F12, //0x6D29 0x9F12 # + 0x9F14, //0x6D2A 0x9F14 # + 0x9F16, //0x6D2B 0x9F16 # + 0x9F17, //0x6D2C 0x9F17 # + 0x9F19, //0x6D2D 0x9F19 # + 0x9F1A, //0x6D2E 0x9F1A # + 0x9F1B, //0x6D2F 0x9F1B # + 0x9F1F, //0x6D30 0x9F1F # + 0x9F22, //0x6D31 0x9F22 # + 0x9F26, //0x6D32 0x9F26 # + 0x9F2A, //0x6D33 0x9F2A # + 0x9F2B, //0x6D34 0x9F2B # + 0x9F2F, //0x6D35 0x9F2F # + 0x9F31, //0x6D36 0x9F31 # + 0x9F32, //0x6D37 0x9F32 # + 0x9F34, //0x6D38 0x9F34 # + 0x9F37, //0x6D39 0x9F37 # + 0x9F39, //0x6D3A 0x9F39 # + 0x9F3A, //0x6D3B 0x9F3A # + 0x9F3C, //0x6D3C 0x9F3C # + 0x9F3D, //0x6D3D 0x9F3D # + 0x9F3F, //0x6D3E 0x9F3F # + 0x9F41, //0x6D3F 0x9F41 # + 0x9F43, //0x6D40 0x9F43 # + 0x9F44, //0x6D41 0x9F44 # + 0x9F45, //0x6D42 0x9F45 # + 0x9F46, //0x6D43 0x9F46 # + 0x9F47, //0x6D44 0x9F47 # + 0x9F53, //0x6D45 0x9F53 # + 0x9F55, //0x6D46 0x9F55 # + 0x9F56, //0x6D47 0x9F56 # + 0x9F57, //0x6D48 0x9F57 # + 0x9F58, //0x6D49 0x9F58 # + 0x9F5A, //0x6D4A 0x9F5A # + 0x9F5D, //0x6D4B 0x9F5D # + 0x9F5E, //0x6D4C 0x9F5E # + 0x9F68, //0x6D4D 0x9F68 # + 0x9F69, //0x6D4E 0x9F69 # + 0x9F6D, //0x6D4F 0x9F6D # + 0x9F6E, //0x6D50 0x9F6E # + 0x9F6F, //0x6D51 0x9F6F # + 0x9F70, //0x6D52 0x9F70 # + 0x9F71, //0x6D53 0x9F71 # + 0x9F73, //0x6D54 0x9F73 # + 0x9F75, //0x6D55 0x9F75 # + 0x9F7A, //0x6D56 0x9F7A # + 0x9F7D, //0x6D57 0x9F7D # + 0x9F8F, //0x6D58 0x9F8F # + 0x9F90, //0x6D59 0x9F90 # + 0x9F91, //0x6D5A 0x9F91 # + 0x9F92, //0x6D5B 0x9F92 # + 0x9F94, //0x6D5C 0x9F94 # + 0x9F96, //0x6D5D 0x9F96 # + 0x9F97, //0x6D5E 0x9F97 # + 0x9F9E, //0x6D5F 0x9F9E # + 0x9FA1, //0x6D60 0x9FA1 # + 0x9FA2, //0x6D61 0x9FA2 # + 0x9FA3, //0x6D62 0x9FA3 # + 0x9FA5, //0x6D63 0x9FA5 # + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000, // + 0x0000 // + } +}; +#pragma endregion + +#pragma region Unicode -> EUC-JP 互換性 +const EUCCMP eucjpcmp[CMPEUCJPNUM] = +{ + // nkf 2.1.5 + // 0xA1B1 U+203E # OVERLINE Windows: U+FFE3 + // 0x2131 0xFFE3 # FULLWIDTH MACRON + {0xA1B1, 0x203E}, + + // nkf 2.1.5 + // 0xA1EF U+00A5 # YEN SIGN Windows: U+FFE5 + // 0x216F 0xFFE5 # FULLWIDTH YEN SIGN + {0xA1EF, 0x00A5}, + + // iconv 1.17 + // icu 71.1 + // 0xA1BD U+2014 # EM DASH Windows: U+2015 + // 0x213D 0x2015 # HORIZONTAL BAR + {0xA1BD, 0x2015}, + + // icu 71.1 + // 0xA1C1 U+301C # WAVE DASH Windows: U+FF5E + // 0x2141 0x301C # WAVE DASH + {0xA1C1, 0xFF5E}, + + // icu 71.1 + // 0xA1C2 U+2016 # DOUBLE VERTICAL LINE Windows: U+2225 + // 0x2142 0x2016 # DOUBLE VERTICAL LINE + {0xA1C2, 0x2225}, + + // icu 71.1 + // 0xA1DD U+2212 # MINUS SIGN Windows: U+FF0D + // 0x215D 0x2212 # MINUS SIGN + {0xA1DD, 0xFF0D}, + + // icu 71.1 + // 0xA1F1 U+00A2 # CENT SIGN Windows: U+FFE0 + // 0x2171 0x00A2 # CENT SIGN + {0xA1F1, 0xFFE0}, + + // icu 71.1 + // 0xA1F2 U+00A3 # POUND SIGN Windows: U+FFE1 + // 0x2172 0x00A3 # POUND SIGN + {0xA1F2, 0xFFE1}, + + // icu 71.1 + // 0xA2CC U+00AC # NOT SIGN [1983] Windows: U+FFE2 + // 0x224C 0x00AC # NOT SIGN + {0xA2CC, 0xFFE2} +}; +#pragma endregion diff --git a/common/eucjptable.h b/common/eucjptable.h new file mode 100644 index 00000000..93692522 --- /dev/null +++ b/common/eucjptable.h @@ -0,0 +1,18 @@ +#pragma once + +#include "eucjis2004table.h" + +#define ROW0212NUM 68 // JIS X 0212 区数 +#define COLNUM 6 // JIS X 0208 有効区点要素数 (区数+2)/16 +#define CMPEUCJPNUM 9 // Unicode -> EUC-JP 互換性 + +//変換テーブル + +// JIS X 0208 有効区点 +extern const USHORT jisx0208e[ROWNUM][COLNUM]; +// JIS X 0212 インデックス +extern const BYTE euc0212i[ROWNUM]; +// JIS X 0212 +extern const UCSCHAR euc0212[ROW0212NUM][CELLNUM]; +// Unicode -> EUC-JP 互換性 +extern const EUCCMP eucjpcmp[CMPEUCJPNUM]; diff --git a/common/parseskkdic.cpp b/common/parseskkdic.cpp index 6d7a7002..640de0a4 100644 --- a/common/parseskkdic.cpp +++ b/common/parseskkdic.cpp @@ -1,79 +1,84 @@  #include "common.h" #include "eucjis2004.h" +#include "eucjp.h" #include "parseskkdic.h" LPCWSTR EntriesAri = L";; okuri-ari entries.\n"; LPCWSTR EntriesNasi = L";; okuri-nasi entries.\n"; -int ReadSKKDicLine(FILE *fp, WCHAR bom, int &okuri, std::wstring &key, +int ReadSKKDicLine(FILE *fp, SKKDICENCODING encoding, int &okuri, std::wstring &key, SKKDICCANDIDATES &c, SKKDICOKURIBLOCKS &o) { - CHAR buf[READBUFSIZE * sizeof(WCHAR)]; - std::string sbuf; - WCHAR wbuf[READBUFSIZE]; - std::wstring wsbuf, s, fmt; - size_t is, ie; - void *rp; + CHAR buf[READBUFSIZE]; + WCHAR wbuf[READBUFSIZE / sizeof(WCHAR)]; + std::string strbuf; + std::wstring wstrbuf; c.clear(); o.clear(); - switch (bom) + switch (encoding) { - case BOM: - while ((rp = fgetws(wbuf, _countof(wbuf), fp)) != nullptr) + case enc_utf_8: //UTF-8 + case enc_utf_16: //UTF-16LE + while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) { - wsbuf += wbuf; + wstrbuf += wbuf; - if (!wsbuf.empty() && wsbuf.back() == L'\n') + if (!wstrbuf.empty() && wstrbuf.back() == L'\n') { break; } } break; - default: - while ((rp = fgets(buf, _countof(buf), fp)) != nullptr) + case enc_euc_jis_2004: //EUC-JIS-2004 + case enc_euc_jp: //EUC-JP + while (fgets(buf, _countof(buf), fp) != nullptr) { - sbuf += buf; + strbuf += buf; - if (!sbuf.empty() && sbuf.back() == '\n') + if (!strbuf.empty() && strbuf.back() == '\n') { break; } } break; + default: + return -1; } - if (rp == nullptr) + if (ferror(fp) != 0) { return -1; } - switch (bom) + switch (encoding) { - case BOM: + case enc_utf_8: //UTF-8 + case enc_utf_16: //UTF-16LE + break; + case enc_euc_jis_2004: //EUC-JIS-2004 + wstrbuf = eucjis2004_string_to_wstring(strbuf); + break; + case enc_euc_jp: //EUC-JP + wstrbuf = eucjp_string_to_wstring(strbuf); break; default: - wsbuf = eucjis2004_string_to_wstring(sbuf); - if (wsbuf.empty()) - { - return 1; - } break; } - if (wsbuf.empty()) + if (wstrbuf.empty()) { - return 1; + return -1; } - if (wsbuf.compare(EntriesAri) == 0) + if (wstrbuf.compare(EntriesAri) == 0) { okuri = 1; return 1; } - else if (wsbuf.compare(EntriesNasi) == 0) + else if (wstrbuf.compare(EntriesNasi) == 0) { okuri = 0; return 1; @@ -84,11 +89,10 @@ int ReadSKKDicLine(FILE *fp, WCHAR bom, int &okuri, std::wstring &key, return 1; } - s = wsbuf; + std::wstring s = wstrbuf; static const std::wregex rectrl(L"[\\x00-\\x19]"); - fmt.assign(L""); - s = std::regex_replace(s, rectrl, fmt); + s = std::regex_replace(s, rectrl, L""); if (okuri == 1) { @@ -97,23 +101,22 @@ int ReadSKKDicLine(FILE *fp, WCHAR bom, int &okuri, std::wstring &key, //送りありエントリのブロックを除去 static const std::wregex reblock(L"\\[[^\\[\\]]+?/[^\\[\\]]+?/\\]/"); - fmt.assign(L""); - s = std::regex_replace(s, reblock, fmt); + s = std::regex_replace(s, reblock, L""); } - is = s.find(L"\x20/"); + size_t is = s.find(L"\x20/"); if (is == std::wstring::npos) { return 1; } - ie = s.find_last_not_of(L'\x20', is); + size_t ie = s.find_last_not_of(L'\x20', is); if (ie == std::wstring::npos) { return 1; } - if (s.find_last_of(L'\x20', ie) != std::wstring::npos) + if (s.find_last_of(L'\x20', ie) != std::string::npos) { return 1; } @@ -166,7 +169,7 @@ void ParseSKKDicCandiate(const std::wstring &s, SKKDICCANDIDATES &c) void ParseSKKDicOkuriBlock(const std::wstring &s, SKKDICOKURIBLOCKS &o) { - std::wstring so, okurik, okuric, fmt; + std::wstring so, okurik, okuric; std::wsmatch m; SKKDICCANDIDATES okurics; @@ -178,10 +181,8 @@ void ParseSKKDicOkuriBlock(const std::wstring &s, SKKDICOKURIBLOCKS &o) { okurics.clear(); - fmt.assign(L"$1"); - okurik = std::regex_replace(m.str(), reblock, fmt); - fmt.assign(L"$2"); - okuric = std::regex_replace(m.str(), reblock, fmt); + okurik = std::regex_replace(m.str(), reblock, L"$1"); + okuric = std::regex_replace(m.str(), reblock, L"$2"); ParseSKKDicCandiate(okuric, okurics); @@ -195,18 +196,18 @@ void ParseSKKDicOkuriBlock(const std::wstring &s, SKKDICOKURIBLOCKS &o) std::wstring ParseConcat(const std::wstring &s) { - std::wstring ret, fmt, numstr, numtmpstr; - std::wregex re; - std::wsmatch res; - wchar_t u; - LPCWSTR bsrep = L"\uf05c"; - - ret = s; + std::wstring ret = s; + LPCWSTR bsrep = L"\uF05C"; + // (concat "*") static const std::wregex reconcat(L"^\\(\\s*concat\\s+\"(.+)\"\\s*\\)$"); if (std::regex_search(ret, reconcat)) { + std::wstring fmt, numstr, numtmpstr; + std::wregex re; + std::wsmatch res; + fmt.assign(L"$1"); ret = std::regex_replace(ret, reconcat, fmt); @@ -241,7 +242,7 @@ std::wstring ParseConcat(const std::wstring &s) numstr += res.prefix(); numtmpstr = res.str(); numtmpstr[0] = L'0'; - u = (wchar_t)wcstoul(numtmpstr.c_str(), nullptr, 0); + wchar_t u = (wchar_t)wcstoul(numtmpstr.c_str(), nullptr, 0); if (u >= L'\x20' && u <= L'\x7E') { numstr.append(1, u); @@ -266,25 +267,27 @@ std::wstring ParseConcat(const std::wstring &s) std::wstring MakeConcat(const std::wstring &s) { - std::wstring ret, fmt; - std::wregex re; + std::wstring ret = s; - ret = s; - - // "/" -> \057, ";" -> \073 + // '/' or ';' static const std::wregex respcch(L"[/;]"); if (std::regex_search(ret, respcch)) { - // "\"" -> "\\\"", "\\" -> "\\\\" - re.assign(L"([\\\"\\\\])"); + std::wstring fmt; + std::wregex re; + + // '"' -> "\"", '\' -> "\\" + re.assign(L"([\"\\\\])"); fmt.assign(L"\\$1"); ret = std::regex_replace(ret, re, fmt); + // '/' -> "\057" re.assign(L"/"); fmt.assign(L"\\057"); ret = std::regex_replace(ret, re, fmt); + // ';' -> "\073" re.assign(L";"); fmt.assign(L"\\073"); ret = std::regex_replace(ret, re, fmt); @@ -294,3 +297,60 @@ std::wstring MakeConcat(const std::wstring &s) return ret; } + +std::wstring EscapeGadgetString(const std::wstring &s) +{ + std::wstring ret = s; + LPCWSTR bsrep = L"\uF05C"; + + //実行変換もどきの文字列パラメータをエスケープ + static const std::wregex regadget(L"^\\(.+\\)$"); + + if (std::regex_match(s, regadget)) + { + std::wstring esc, str; + std::wstring tmp = s; + std::wsmatch m; + + std::wstring fmt; + std::wregex re; + + // "\\" -> '\uF05C' + re.assign(L"\\\\\\\\"); + fmt.assign(bsrep); + tmp = std::regex_replace(tmp, re, fmt); + + // "..." ignoring escaped quotation + static const std::wregex restring(L" (\"\"|\".*?[^\\\\]\")"); + + while (std::regex_search(tmp, m, restring)) + { + esc += m.prefix().str(); + str = m.str(); + tmp = m.suffix().str(); + + // '/' -> "\057" + re.assign(L"/"); + fmt.assign(L"\\057"); + str = std::regex_replace(str, re, fmt); + + // ';' -> "\073" + re.assign(L";"); + fmt.assign(L"\\073"); + str = std::regex_replace(str, re, fmt); + + esc += str; + } + + esc += tmp; + + // '\uF05C' -> "\\" + re.assign(bsrep); + fmt.assign(L"\\\\"); + esc = std::regex_replace(esc, re, fmt); + + ret = esc; + } + + return ret; +} diff --git a/common/parseskkdic.h b/common/parseskkdic.h index 8324b0ae..e2254294 100644 --- a/common/parseskkdic.h +++ b/common/parseskkdic.h @@ -12,11 +12,8 @@ typedef std::vector< SKKDICCANDIDATE > SKKDICCANDIDATES; //送りありエントリのブロック typedef std::pair< std::wstring, SKKDICCANDIDATES > SKKDICOKURIBLOCK; //送り仮名、候補 typedef std::vector< SKKDICOKURIBLOCK > SKKDICOKURIBLOCKS; -struct OKURIBLOCKS { //avoid C4503 - SKKDICOKURIBLOCKS o; -}; -typedef std::pair< std::wstring, OKURIBLOCKS > USEROKURIENTRY; //見出し語、送りブロック -typedef std::map< std::wstring, OKURIBLOCKS > USEROKURI; +typedef std::pair< std::wstring, SKKDICOKURIBLOCKS > USEROKURIENTRY; //見出し語、送りブロック +typedef std::map< std::wstring, SKKDICOKURIBLOCKS > USEROKURI; //見出し語順序 typedef std::vector< std::wstring > KEYORDER; @@ -28,9 +25,20 @@ typedef std::map< std::wstring, SKKDICCANDIDATES > SKKDIC; extern LPCWSTR EntriesAri; extern LPCWSTR EntriesNasi; -int ReadSKKDicLine(FILE *fp, WCHAR bom, int &okuri, std::wstring &key, +enum SKKDICENCODING +{ + enc_error = -1, + enc_none = 0, + enc_euc_jis_2004 = 1, + enc_euc_jp = 2, + enc_utf_8 = 8, + enc_utf_16 = 16 +}; + +int ReadSKKDicLine(FILE *fp, SKKDICENCODING encoding, int &okuri, std::wstring &key, SKKDICCANDIDATES &c, SKKDICOKURIBLOCKS &o); void ParseSKKDicCandiate(const std::wstring &s, SKKDICCANDIDATES &c); void ParseSKKDicOkuriBlock(const std::wstring &s, SKKDICOKURIBLOCKS &o); std::wstring ParseConcat(const std::wstring &s); std::wstring MakeConcat(const std::wstring &s); +std::wstring EscapeGadgetString(const std::wstring &s); diff --git a/common/pch.cpp b/common/pch.cpp new file mode 100644 index 00000000..af0744ae --- /dev/null +++ b/common/pch.cpp @@ -0,0 +1 @@ + diff --git a/common/stdafx.h b/common/pch.h similarity index 100% rename from common/stdafx.h rename to common/pch.h diff --git a/common/stdafx.cpp b/common/stdafx.cpp deleted file mode 100644 index 7438ada7..00000000 --- a/common/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -// nothing diff --git a/common/utf8.h b/common/utf8.h index 70311a21..a0aee597 100644 --- a/common/utf8.h +++ b/common/utf8.h @@ -5,3 +5,5 @@ std::wstring utf8_string_to_wstring(const std::string &s); #define WCTOU8(w) wstring_to_utf8_string(w).c_str() #define U8TOWC(u) utf8_string_to_wstring(u).c_str() + +#define TOWELLFORMED(w) U8TOWC(WCTOU8(w)) diff --git a/common/version.h b/common/version.h index 8c6b59bd..89ef6bfd 100644 --- a/common/version.h +++ b/common/version.h @@ -7,10 +7,10 @@ #define TEXTSERVICE_DESC TEXTSERVICE_NAME L"_DEBUG" #endif #define TEXTSERVICE_DIR L"IMCRVSKK" -#define TEXTSERVICE_VER L"2.7.12" +#define TEXTSERVICE_VER L"3.3.0" //for resource #define RC_AUTHOR "nathancorvussolis" #define RC_PRODUCT "CorvusSKK" -#define RC_VERSION "2.7.12" -#define RC_VERSION_D 2,7,12,0 +#define RC_VERSION "3.3.0" +#define RC_VERSION_D 3,3,0,0 diff --git a/imcrvcnf/ConfigCnf.cpp b/imcrvcnf/ConfigCnf.cpp index 9277f5d1..0895f874 100644 --- a/imcrvcnf/ConfigCnf.cpp +++ b/imcrvcnf/ConfigCnf.cpp @@ -1,11 +1,13 @@  #include "configxml.h" +#include "utf8.h" #include "imcrvcnf.h" #include "resource.h" LPCWSTR TextServiceDesc = TEXTSERVICE_DESC; -WCHAR cnfmutexname[MAX_KRNLOBJNAME]; //ミューテックス -WCHAR cnfcanceldiceventname[MAX_KRNLOBJNAME]; //辞書取込キャンセルイベント +WCHAR cnfmutexname[MAX_PATH]; //ミューテックス +WCHAR cnfcanceldiceventname[MAX_PATH]; //辞書取込キャンセルイベント +WCHAR mgrpipename[MAX_PIPENAME]; //名前付きパイプ WCHAR pathconfigxml[MAX_PATH]; //設定 WCHAR pathskkdic[MAX_PATH]; //取込SKK辞書 @@ -37,6 +39,8 @@ void CreateIpcName() ZeroMemory(cnfmutexname, sizeof(cnfmutexname)); ZeroMemory(cnfcanceldiceventname, sizeof(cnfcanceldiceventname)); + ZeroMemory(mgrpipename, sizeof(mgrpipename)); + LPWSTR pszUserUUID = nullptr; if (GetUserUUID(&pszUserUUID)) @@ -44,6 +48,8 @@ void CreateIpcName() _snwprintf_s(cnfmutexname, _TRUNCATE, L"%s%s", IMCRVCNFMUTEX, pszUserUUID); _snwprintf_s(cnfcanceldiceventname, _TRUNCATE, L"%s%s", IMCRVKRNLOBJ L"cnf-cancel-dic-", pszUserUUID); + _snwprintf_s(mgrpipename, _TRUNCATE, L"%s%s", IMCRVMGRPIPE, pszUserUUID); + LocalFree(pszUserUUID); } } @@ -51,9 +57,9 @@ void CreateIpcName() BOOL SetFileDacl(LPWSTR path) { BOOL bRet = FALSE; - WCHAR sddl[MAX_KRNLOBJNAME] = {}; + WCHAR sddl[MAX_SECURITYDESC] = {}; PSECURITY_DESCRIPTOR psd = nullptr; - LPWSTR pszUserSid; + LPWSTR pszUserSid = nullptr; if (GetUserSid(&pszUserSid)) { @@ -88,31 +94,24 @@ BOOL SetFileDacl(LPWSTR path) int GetDpi(HWND hwnd) { HDC hdc = GetDC(hwnd); - int dpi = GetDeviceCaps(hdc, LOGPIXELSX); + int dpi = GetDeviceCaps(hdc, LOGPIXELSY); ReleaseDC(hwnd, hdc); // Windows 10 ver.1703 supports Per-Monitor DPI Awareness V2 if (IsWindowsVersion100RS2OrLater()) { - // try delay load api-ms-win-shcore-scaling-l1-1-1.dll - __try - { - HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); - UINT dpiX, dpiY; - if (SUCCEEDED(GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY))) - { - dpi = (int)dpiX; - } - } - __except (EXCEPTION_EXECUTE_HANDLER) + // Windows 10 ver.1607 or later supported + UINT wdpi = GetDpiForWindow(hwnd); + if (wdpi != 0) { + dpi = (int)wdpi; } } return dpi; } -int GetScaledSizeX(HWND hwnd, int size) +int GetScaledSize(HWND hwnd, int size) { return MulDiv(size, GetDpi(hwnd), C_USER_DEFAULT_SCREEN_DPI); } @@ -147,7 +146,7 @@ void LoadCheckButton(HWND hDlg, int nIDDlgItem, LPCWSTR lpAppName, LPCWSTR lpKey void SaveCheckButton(IXmlWriter *pWriter, HWND hDlg, int nIDDlgItem, LPCWSTR lpKeyName) { - WCHAR num[2]; + WCHAR num[2] = {}; num[0] = L'0' + IsDlgButtonChecked(hDlg, nIDDlgItem); num[1] = L'\0'; @@ -173,7 +172,7 @@ BOOL SaveConfigXml(HWND hPropSheetDlg) { WriterStartSection(pWriter, SectionDictionary); - SaveDictionary(pWriter, PROPSHEET_IDTOHWND(hPropSheetDlg, IDD_DIALOG_DICTIONARY)); + SaveDictionary1(pWriter, PROPSHEET_IDTOHWND(hPropSheetDlg, IDD_DIALOG_DICTIONARY1)); WriterEndSection(pWriter); } @@ -182,7 +181,16 @@ BOOL SaveConfigXml(HWND hPropSheetDlg) { WriterStartSection(pWriter, SectionServer); - SaveServer(pWriter, PROPSHEET_IDTOHWND(hPropSheetDlg, IDD_DIALOG_DICTIONARY)); + SaveDictionary1Server(pWriter, PROPSHEET_IDTOHWND(hPropSheetDlg, IDD_DIALOG_DICTIONARY1)); + + WriterEndSection(pWriter); + } + + //userdict + { + WriterStartSection(pWriter, SectionUserDict); + + SaveDictionary2(pWriter, PROPSHEET_IDTOHWND(hPropSheetDlg, IDD_DIALOG_DICTIONARY2)); WriterEndSection(pWriter); } @@ -316,3 +324,8 @@ BOOL SaveConfigXml(HWND hPropSheetDlg) return TRUE; } + +void ReplaceWellFormed(LPWSTR str, SIZE_T size) +{ + wcsncpy_s(str, size, TOWELLFORMED(str), _TRUNCATE); +} diff --git a/imcrvcnf/DlgDicAddUrl.cpp b/imcrvcnf/DlgDicAddUrl.cpp index fb44c8cd..8ecf4c99 100644 --- a/imcrvcnf/DlgDicAddUrl.cpp +++ b/imcrvcnf/DlgDicAddUrl.cpp @@ -24,8 +24,8 @@ INT_PTR CALLBACK DlgProcSKKDicAddUrl(HWND hDlg, UINT message, WPARAM wParam, LPA GetDlgItemTextW(hDlg, IDC_EDIT_SKK_DIC_URL, urlskkdic, _countof(urlskkdic)); { // trim - std::wstring strurl = std::regex_replace(std::wstring(urlskkdic), - std::wregex(L"^\\s+|\\s+$"), std::wstring(L"")); + static const std::wregex retrim(L"^\\s+|\\s+$"); + std::wstring strurl = std::regex_replace(std::wstring(urlskkdic), retrim, L""); _snwprintf_s(urlskkdic, _TRUNCATE, L"%s", strurl.c_str()); if (urlskkdic[0] == L'\0') diff --git a/imcrvcnf/DlgDicMake.cpp b/imcrvcnf/DlgDicMake.cpp index 519e2140..a09dfc06 100644 --- a/imcrvcnf/DlgDicMake.cpp +++ b/imcrvcnf/DlgDicMake.cpp @@ -1,5 +1,6 @@  #include "eucjis2004.h" +#include "eucjp.h" #include "parseskkdic.h" #include "configxml.h" #include "utf8.h" @@ -24,8 +25,8 @@ BOOL IsMakeSKKDicCanceled(HANDLE hCancelEvent) HRESULT DownloadMakePath(LPCWSTR url, LPWSTR path, size_t len) { - WCHAR dir[MAX_PATH]; - WCHAR fname[MAX_PATH]; + WCHAR dir[MAX_PATH] = {}; + WCHAR fname[MAX_PATH] = {}; DWORD temppathlen = GetTempPathW(_countof(dir), dir); if (temppathlen == 0 || temppathlen > _countof(dir)) @@ -104,9 +105,9 @@ HRESULT DownloadSKKDic(HANDLE hCancelEvent, LPCWSTR url, LPWSTR path, size_t len CHAR rbuf[RECVBUFSIZE]; BOOL retRead; DWORD bytesRead = 0; - FILE *fp; + FILE *fp = nullptr; - _wfopen_s(&fp, path, WB); + _wfopen_s(&fp, path, modeWB); if (fp == nullptr) { InternetCloseHandle(hUrl); @@ -159,58 +160,80 @@ HRESULT DownloadSKKDic(HANDLE hCancelEvent, LPCWSTR url, LPWSTR path, size_t len return S_OK; } -HRESULT CheckMultiByteFile(HANDLE hCancelEvent, LPCWSTR path, int encoding) +HRESULT CheckMultiByteFile(HANDLE hCancelEvent, LPCWSTR path, SKKDICENCODING encoding) { HRESULT hr = S_OK; - FILE *fp; - CHAR buf[READBUFSIZE * sizeof(WCHAR)]; + FILE *fp = nullptr; + CHAR buf[READBUFSIZE]; std::string strbuf; size_t len; - _wfopen_s(&fp, path, RB); + _wfopen_s(&fp, path, modeRB); if (fp == nullptr) { return E_MAKESKKDIC_FILEIO; } - while (fgets(buf, _countof(buf), fp) != nullptr) + while (true) { - if (IsMakeSKKDicCanceled(hCancelEvent)) + strbuf.clear(); + + while (fgets(buf, _countof(buf), fp) != nullptr) { - fclose(fp); - return E_ABORT; + if (IsMakeSKKDicCanceled(hCancelEvent)) + { + fclose(fp); + return E_ABORT; + } + + strbuf += buf; + + if (!strbuf.empty() && strbuf.back() == '\n') + { + break; + } + } + + if (ferror(fp) != 0) + { + hr = E_MAKESKKDIC_FILEIO; + break; } - strbuf += buf; + if (strbuf.empty()) + { + break; + } - if (!strbuf.empty() && strbuf.back() == '\n') + switch (encoding) { - switch (encoding) + case enc_euc_jis_2004: //EUC-JIS-2004 + if (EucJis2004ToWideChar(strbuf.c_str(), nullptr, nullptr, &len) == FALSE) { - case 1: //EUC-JIS-2004 - if (!EucJis2004ToWideChar(strbuf.c_str(), nullptr, nullptr, &len)) - { - hr = S_FALSE; - } - break; - case 8: //UTF-8 - if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, - strbuf.c_str(), -1, nullptr, 0) == 0) - { - hr = S_FALSE; - } - break; - default: hr = S_FALSE; - break; } - - if (hr == S_FALSE) + break; + case enc_euc_jp: //EUC-JP + if (EucJPToWideChar(strbuf.c_str(), nullptr, nullptr, &len) == FALSE) { - break; + hr = S_FALSE; + } + break; + case enc_utf_8: //UTF-8 + if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, + strbuf.c_str(), -1, nullptr, 0) == 0) + { + hr = S_FALSE; } + break; + default: + hr = S_FALSE; + break; + } - strbuf.clear(); + if (hr == S_FALSE) + { + break; } } @@ -222,36 +245,52 @@ HRESULT CheckMultiByteFile(HANDLE hCancelEvent, LPCWSTR path, int encoding) HRESULT CheckWideCharFile(HANDLE hCancelEvent, LPCWSTR path) { HRESULT hr = S_OK; - FILE *fp; - WCHAR wbuf[READBUFSIZE]; + FILE *fp = nullptr; + WCHAR wbuf[READBUFSIZE / sizeof(WCHAR)]; std::wstring wstrbuf; - _wfopen_s(&fp, path, RB); + _wfopen_s(&fp, path, modeRB); if (fp == nullptr) { return E_MAKESKKDIC_FILEIO; } - while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) + while (true) { - if (IsMakeSKKDicCanceled(hCancelEvent)) + wstrbuf.clear(); + + while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) { - fclose(fp); - return E_ABORT; - } + if (IsMakeSKKDicCanceled(hCancelEvent)) + { + fclose(fp); + return E_ABORT; + } - wstrbuf += wbuf; + wstrbuf += wbuf; - if (!wstrbuf.empty() && wstrbuf.back() == L'\n') - { - if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, - wstrbuf.c_str(), -1, nullptr, 0, nullptr, nullptr) == 0) + if (!wstrbuf.empty() && wstrbuf.back() == L'\n') { - hr = S_FALSE; break; } + } - wstrbuf.clear(); + if (ferror(fp) != 0) + { + hr = E_MAKESKKDIC_FILEIO; + break; + } + + if (wstrbuf.empty()) + { + break; + } + + if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, + wstrbuf.c_str(), -1, nullptr, 0, nullptr, nullptr) == 0) + { + hr = S_FALSE; + break; } } @@ -312,20 +351,20 @@ void LoadSKKDicAdd(SKKDIC &skkdic, const std::wstring &key, const std::wstring & HRESULT LoadSKKDicFile(HANDLE hCancelEvent, LPCWSTR path, size_t &count_key, size_t &count_cand, SKKDIC &entries_a, SKKDIC &entries_n) { - FILE *fp; + FILE *fp = nullptr; std::wstring key; SKKDICCANDIDATES sc; SKKDICOKURIBLOCKS so; - int encoding = 0; + SKKDICENCODING encoding = enc_none; - //check BOM - _wfopen_s(&fp, path, RB); + _wfopen_s(&fp, path, modeRB); if (fp == nullptr) { return E_MAKESKKDIC_FILEIO; } + //check BOM WCHAR bom = L'\0'; fread(&bom, 2, 1, fp); fclose(fp); @@ -333,7 +372,7 @@ HRESULT LoadSKKDicFile(HANDLE hCancelEvent, LPCWSTR path, size_t &count_key, siz if (bom == BOM) { //UTF-16LE - encoding = 16; + encoding = enc_utf_16; HRESULT hr = CheckWideCharFile(hCancelEvent, path); switch (hr) @@ -346,19 +385,19 @@ HRESULT LoadSKKDicFile(HANDLE hCancelEvent, LPCWSTR path, size_t &count_key, siz break; default: //Error - encoding = -1; + encoding = enc_error; break; } } //UTF-8 ? - if (encoding == 0) + if (encoding == enc_none) { - HRESULT hr = CheckMultiByteFile(hCancelEvent, path, 8); + HRESULT hr = CheckMultiByteFile(hCancelEvent, path, enc_utf_8); switch (hr) { case S_OK: - encoding = 8; + encoding = enc_utf_8; break; case E_ABORT: case E_MAKESKKDIC_FILEIO: @@ -370,13 +409,31 @@ HRESULT LoadSKKDicFile(HANDLE hCancelEvent, LPCWSTR path, size_t &count_key, siz } //EUC-JIS-2004 ? - if (encoding == 0) + if (encoding == enc_none) { - HRESULT hr = CheckMultiByteFile(hCancelEvent, path, 1); + HRESULT hr = CheckMultiByteFile(hCancelEvent, path, enc_euc_jis_2004); switch (hr) { case S_OK: - encoding = 1; + encoding = enc_euc_jis_2004; + break; + case E_ABORT: + case E_MAKESKKDIC_FILEIO: + return hr; + break; + default: + break; + } + } + + //EUC-JP ? + if (encoding == enc_none) + { + HRESULT hr = CheckMultiByteFile(hCancelEvent, path, enc_euc_jp); + switch (hr) + { + case S_OK: + encoding = enc_euc_jp; break; case E_ABORT: case E_MAKESKKDIC_FILEIO: @@ -389,19 +446,19 @@ HRESULT LoadSKKDicFile(HANDLE hCancelEvent, LPCWSTR path, size_t &count_key, siz switch (encoding) { - case 1: + case enc_euc_jis_2004: //EUC-JIS-2004 - bom = L'\0'; - _wfopen_s(&fp, path, RB); + case enc_euc_jp: + //EUC-JP + _wfopen_s(&fp, path, modeRT); break; - case 8: + case enc_utf_8: //UTF-8 - bom = BOM; - _wfopen_s(&fp, path, RccsUTF8); + _wfopen_s(&fp, path, modeRccsUTF8); break; - case 16: + case enc_utf_16: //UTF-16LE - _wfopen_s(&fp, path, RccsUTF16); + _wfopen_s(&fp, path, modeRccsUTF16); break; default: return E_MAKESKKDIC_ENCODING; @@ -423,7 +480,7 @@ HRESULT LoadSKKDicFile(HANDLE hCancelEvent, LPCWSTR path, size_t &count_key, siz return E_ABORT; } - int rl = ReadSKKDicLine(fp, bom, okuri, key, sc, so); + int rl = ReadSKKDicLine(fp, encoding, okuri, key, sc, so); if (rl == -1) { //EOF @@ -507,7 +564,7 @@ HRESULT UnGzip(LPCWSTR gzpath, LPWSTR path, size_t len) _snwprintf_s(path, len, _TRUNCATE, L"%s\\%s", tempdir, fname); - FILE *fpo; + FILE *fpo = nullptr; _wfopen_s(&fpo, path, L"wb"); if (fpo == nullptr) { @@ -521,20 +578,20 @@ HRESULT UnGzip(LPCWSTR gzpath, LPWSTR path, size_t len) { while (true) { - int len = gzread(gzf, buf, GZBUFSIZE); + int rlen = gzread(gzf, buf, GZBUFSIZE); - if (len == 0) + if (rlen == 0) { ret = S_OK; break; } - else if (len < 0) + else if (rlen < 0) { ret = E_MAKESKKDIC_UNGZIP; break; } - if (fwrite(buf, len, 1, fpo) != 1) + if (fwrite(buf, rlen, 1, fpo) != 1) { ret = E_MAKESKKDIC_UNGZIP; break; @@ -629,7 +686,7 @@ HRESULT UnTar(HANDLE hCancelEvent, LPCWSTR tarpath, size_t &count_key, size_t &c } FILE *fpi = nullptr; - _wfopen_s(&fpi, tarpath, RB); + _wfopen_s(&fpi, tarpath, modeRB); if (fpi == nullptr) { return E_MAKESKKDIC_FILEIO; @@ -734,7 +791,7 @@ HRESULT UnTar(HANDLE hCancelEvent, LPCWSTR tarpath, size_t &count_key, size_t &c if (wcslen(ttfname) == 0) break; } - _wfopen_s(&fpo, path, WB); + _wfopen_s(&fpo, path, modeWB); if (fpo == nullptr) { @@ -795,7 +852,7 @@ HRESULT UnTar(HANDLE hCancelEvent, LPCWSTR tarpath, size_t &count_key, size_t &c HRESULT LoadSKKDic(HANDLE hCancelEvent, HWND hDlg, SKKDIC &entries_a, SKKDIC &entries_n) { - WCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH] = {}; WCHAR text[16] = {}; HWND hWndListView = GetDlgItem(hDlg, IDC_LIST_SKK_DIC); @@ -808,8 +865,8 @@ HRESULT LoadSKKDic(HANDLE hCancelEvent, HWND hDlg, SKKDIC &entries_a, SKKDIC &en } ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); for (int i = 0; i < count; i++) { @@ -929,11 +986,11 @@ void WriteSKKDicEntry(FILE *fp, const std::wstring &key, const SKKDICCANDIDATES HRESULT WriteSKKDic(HANDLE hCancelEvent, const SKKDIC &entries_a, const SKKDIC &entries_n) { - FILE *fp; + FILE *fp = nullptr; WCHAR bom = BOM; LPCWSTR crlf = L"\r\n"; - _wfopen_s(&fp, pathskkdic, WB); + _wfopen_s(&fp, pathskkdic, modeWB); if (fp == nullptr) { return E_MAKESKKDIC_FILEIO; @@ -981,16 +1038,31 @@ HRESULT WriteSKKDic(HANDLE hCancelEvent, const SKKDIC &entries_a, const SKKDIC & return S_OK; } +void SetTaskbarListMarquee(HWND hwnd, TBPFLAG flag) +{ + CComPtr pTaskbarList3; + HRESULT hr = CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pTaskbarList3)); + if (SUCCEEDED(hr) && (pTaskbarList3 != nullptr)) + { + pTaskbarList3->SetProgressState(hwnd, flag); + } +} + void MakeSKKDicThread(void *p) { WCHAR msg[1024]; HRESULT hr = S_OK; HWND child = (HWND)p; - HWND parent = PROPSHEET_IDTOHWND(GetWindow(child, GW_OWNER), IDD_DIALOG_DICTIONARY); + HWND parent = PROPSHEET_IDTOHWND(GetWindow(child, GW_OWNER), IDD_DIALOG_DICTIONARY1); + HWND pdlg = GetParent(child); HANDLE hCancelEvent = OpenEventW(SYNCHRONIZE, FALSE, cnfcanceldiceventname); + HRESULT hrI = CoInitializeEx(nullptr, COINIT_MULTITHREADED); + + SetTaskbarListMarquee(pdlg, TBPF_INDETERMINATE); + LONGLONG t = 0; LARGE_INTEGER qpf = {}; @@ -1036,15 +1108,19 @@ void MakeSKKDicThread(void *p) if (SUCCEEDED(hr)) { + SetTaskbarListMarquee(pdlg, TBPF_NOPROGRESS); + _snwprintf_s(msg, _TRUNCATE, L"完了しました。\r\n\r\n%lld msec", t); - MessageBoxW(parent, msg, TextServiceDesc, MB_OK | MB_ICONINFORMATION); + MessageBoxW(pdlg, msg, TextServiceDesc, MB_OK | MB_ICONINFORMATION); } else if (hr == E_ABORT) { _wremove(pathskkdic); - MessageBoxW(parent, L"中断しました。", TextServiceDesc, MB_OK | MB_ICONWARNING); + SetTaskbarListMarquee(pdlg, TBPF_PAUSED); + + MessageBoxW(pdlg, L"中断しました。", TextServiceDesc, MB_OK | MB_ICONWARNING); } else { @@ -1089,10 +1165,17 @@ void MakeSKKDicThread(void *p) } } + SetTaskbarListMarquee(pdlg, TBPF_ERROR); + _snwprintf_s(msg, _TRUNCATE, L"失敗しました。(%s)\n\n%s", errmsg, path); - MessageBoxW(parent, msg, TextServiceDesc, MB_OK | MB_ICONERROR); + MessageBoxW(pdlg, msg, TextServiceDesc, MB_OK | MB_ICONERROR); } + + SetTaskbarListMarquee(pdlg, TBPF_NOPROGRESS); + + CoUninitialize(); + return; } diff --git a/imcrvcnf/DlgProcBehavior2.cpp b/imcrvcnf/DlgProcBehavior2.cpp index a8654e80..9aed2bb2 100644 --- a/imcrvcnf/DlgProcBehavior2.cpp +++ b/imcrvcnf/DlgProcBehavior2.cpp @@ -6,7 +6,7 @@ INT_PTR CALLBACK DlgProcBehavior2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hwnd; - WCHAR num[2]; + WCHAR num[2] = {}; std::wstring strxmlval; int count; @@ -15,7 +15,7 @@ INT_PTR CALLBACK DlgProcBehavior2(HWND hDlg, UINT message, WPARAM wParam, LPARAM case WM_INITDIALOG: hwnd = GetDlgItem(hDlg, IDC_COMBO_COMPMULTINUM); num[1] = L'\0'; - for (int i = 1; i <= 9; i++) + for (int i = 1; i <= MAX_SELKEY_C; i++) { num[0] = L'0' + (WCHAR)i; SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)num); @@ -74,7 +74,7 @@ INT_PTR CALLBACK DlgProcBehavior2(HWND hDlg, UINT message, WPARAM wParam, LPARAM void SaveBehavior2(IXmlWriter *pWriter, HWND hDlg) { - WCHAR num[2]; + WCHAR num[2] = {}; HWND hwnd = GetDlgItem(hDlg, IDC_COMBO_COMPMULTINUM); int count = 1 + (int)SendMessageW(hwnd, CB_GETCURSEL, 0, 0); diff --git a/imcrvcnf/DlgProcConvPoint.cpp b/imcrvcnf/DlgProcConvPoint.cpp index da833935..e6084693 100644 --- a/imcrvcnf/DlgProcConvPoint.cpp +++ b/imcrvcnf/DlgProcConvPoint.cpp @@ -10,12 +10,12 @@ void LoadConvPoint(HWND hDlg); INT_PTR CALLBACK DlgProcConvPoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWndListView; - LV_COLUMNW lvc; - LVITEMW item; + LV_COLUMNW lvc = {}; + LVITEMW item = {}; int index, count; - WCHAR key[2]; - WCHAR keyBak[2]; - NMLISTVIEW *pListView; + WCHAR key[2] = {}; + WCHAR keyBak[2] = {}; + LPNMLISTVIEW pListView; WCHAR text[16] = {}; switch (message) @@ -28,15 +28,15 @@ INT_PTR CALLBACK DlgProcConvPoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM lvc.pszText = text; lvc.iSubItem = 0; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"開始", _TRUNCATE); ListView_InsertColumn(hWndListView, 0, &lvc); lvc.iSubItem = 1; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"代替", _TRUNCATE); ListView_InsertColumn(hWndListView, 1, &lvc); lvc.iSubItem = 2; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"送り", _TRUNCATE); ListView_InsertColumn(hWndListView, 2, &lvc); @@ -51,9 +51,9 @@ INT_PTR CALLBACK DlgProcConvPoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM case WM_DPICHANGED_AFTERPARENT: hWndListView = GetDlgItem(hDlg, IDC_LIST_CONVPOINT); - ListView_SetColumnWidth(hWndListView, 0, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 0, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 60)); return TRUE; @@ -69,12 +69,17 @@ INT_PTR CALLBACK DlgProcConvPoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM PropSheet_Changed(GetParent(hDlg), hDlg); GetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_ST, key, _countof(key)); + REPLACE_WELLFORMED(key); SetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_ST, key); ListView_SetItemText(hWndListView, index, 0, key); + GetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_AL, key, _countof(key)); + REPLACE_WELLFORMED(key); SetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_AL, key); ListView_SetItemText(hWndListView, index, 1, key); + GetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_OK, key, _countof(key)); + REPLACE_WELLFORMED(key); SetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_OK, key); ListView_SetItemText(hWndListView, index, 2, key); } @@ -83,19 +88,25 @@ INT_PTR CALLBACK DlgProcConvPoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM PropSheet_Changed(GetParent(hDlg), hDlg); item.mask = LVIF_TEXT; + GetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_ST, key, _countof(key)); + REPLACE_WELLFORMED(key); SetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_ST, key); item.pszText = key; item.iItem = count; item.iSubItem = 0; ListView_InsertItem(hWndListView, &item); + GetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_AL, key, _countof(key)); + REPLACE_WELLFORMED(key); SetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_AL, key); item.pszText = key; item.iItem = count; item.iSubItem = 1; ListView_SetItem(hWndListView, &item); + GetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_OK, key, _countof(key)); + REPLACE_WELLFORMED(key); SetDlgItemTextW(hDlg, IDC_EDIT_CONVPOINT_OK, key); item.pszText = key; item.iItem = count; @@ -171,10 +182,11 @@ INT_PTR CALLBACK DlgProcConvPoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM break; case WM_NOTIFY: + if (lParam == NULL) break; switch (((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: - pListView = (NMLISTVIEW*)((LPNMHDR)lParam); + pListView = (LPNMLISTVIEW)((LPNMHDR)lParam); if (pListView->uChanged & LVIF_STATE) { hWndListView = ((LPNMHDR)lParam)->hwndFrom; @@ -260,7 +272,7 @@ void LoadConfigConvPoint() void LoadConvPoint(HWND hDlg) { - LVITEMW item; + LVITEMW item = {}; LoadConfigConvPoint(); @@ -296,7 +308,7 @@ void SaveConvPoint(IXmlWriter *pWriter, HWND hDlg) APPDATAXMLLIST list; APPDATAXMLROW row; APPDATAXMLATTR attr; - WCHAR key[2]; + WCHAR key[2] = {}; HWND hWndListView = GetDlgItem(hDlg, IDC_LIST_CONVPOINT); int count = ListView_GetItemCount(hWndListView); diff --git a/imcrvcnf/DlgProcDictionary.cpp b/imcrvcnf/DlgProcDictionary1.cpp similarity index 85% rename from imcrvcnf/DlgProcDictionary.cpp rename to imcrvcnf/DlgProcDictionary1.cpp index 65ec2580..d1868f15 100644 --- a/imcrvcnf/DlgProcDictionary.cpp +++ b/imcrvcnf/DlgProcDictionary1.cpp @@ -11,15 +11,15 @@ static LPCWSTR defaultTimeOut = L"1000"; void LoadDictionary(HWND hDlg); -INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DlgProcDictionary1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWndListView; - LV_COLUMNW lvc; - LVITEMW item; + LV_COLUMNW lvc = {}; + LVITEMW item = {}; int index, count; OPENFILENAMEW ofn = {}; - WCHAR path[MAX_PATH]; - WCHAR pathBak[MAX_PATH]; + WCHAR path[MAX_PATH] = {}; + WCHAR pathBak[MAX_PATH] = {}; BOOL check; BOOL checkBak; WCHAR text[16] = {}; @@ -80,8 +80,8 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA hWndListView = GetDlgItem(hDlg, IDC_LIST_SKK_DIC); ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); return TRUE; @@ -169,8 +169,8 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA ListView_InsertItem(hWndListView, &item); ListView_SetItemState(hWndListView, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); ListView_SetCheckState(hWndListView, index, TRUE); ListView_EnsureVisible(hWndListView, index, FALSE); } @@ -204,8 +204,8 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA ListView_InsertItem(hWndListView, &item); ListView_SetItemState(hWndListView, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); ListView_SetCheckState(hWndListView, index, TRUE); ListView_EnsureVisible(hWndListView, index, FALSE); } @@ -219,8 +219,8 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA ListView_DeleteItem(hWndListView, index); ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); } return TRUE; @@ -261,6 +261,7 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA break; case WM_NOTIFY: + if (lParam == NULL) break; if (wParam == IDC_LIST_SKK_DIC) { hWndListView = GetDlgItem(hDlg, IDC_LIST_SKK_DIC); @@ -282,8 +283,8 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA ListView_SetItemText(hWndListView, pdi->item.iItem, 0, urlskkdic); urlskkdic[0] = L'\0'; ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); return TRUE; default: @@ -302,7 +303,7 @@ INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARA void LoadDictionary(HWND hDlg) { APPDATAXMLLIST list; - LVITEMW item; + LVITEMW item = {}; HRESULT hr = ReadList(pathconfigxml, SectionDictionary, list); @@ -332,17 +333,17 @@ void LoadDictionary(HWND hDlg) i++; } ListView_SetColumnWidth(hWndListView, 0, LVSCW_AUTOSIZE_USEHEADER); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 80)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 80)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 80)); } } -void SaveDictionary(IXmlWriter *pWriter, HWND hDlg) +void SaveDictionary1(IXmlWriter *pWriter, HWND hDlg) { APPDATAXMLLIST list; APPDATAXMLROW row; APPDATAXMLATTR attr; - WCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH] = {}; HWND hWndListView = GetDlgItem(hDlg, IDC_LIST_SKK_DIC); int count = ListView_GetItemCount(hWndListView); @@ -368,11 +369,11 @@ void SaveDictionary(IXmlWriter *pWriter, HWND hDlg) WriterList(pWriter, list); } -void SaveServer(IXmlWriter *pWriter, HWND hDlg) +void SaveDictionary1Server(IXmlWriter *pWriter, HWND hDlg) { - WCHAR num[16]; - WCHAR host[MAX_SKKSERVER_HOST]; - WCHAR port[MAX_SKKSERVER_PORT]; + WCHAR num[16] = {}; + WCHAR host[MAX_SKKSERVER_HOST] = {}; + WCHAR port[MAX_SKKSERVER_PORT] = {}; SaveCheckButton(pWriter, hDlg, IDC_CHECKBOX_SKKSRV, ValueServerServ); diff --git a/imcrvcnf/DlgProcDictionary2.cpp b/imcrvcnf/DlgProcDictionary2.cpp new file mode 100644 index 00000000..f1d8b32f --- /dev/null +++ b/imcrvcnf/DlgProcDictionary2.cpp @@ -0,0 +1,391 @@ + +#include "configxml.h" +#include "imcrvcnf.h" +#include "resource.h" + +#define MGR_TIMER_ID IDD_DIALOG_DICTIONARY2 + +HANDLE hPipe = INVALID_HANDLE_VALUE; +BOOL bkcnfSaved = FALSE; +BOOL mgrprocRun = FALSE; + +BOOL ConnectDic(); +void DisconnectDic(); +BOOL CommandDic(WCHAR command); + +INT_PTR CALLBACK DlgProcDictionary2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + std::wstring strxmlval; + WCHAR num[16] = {}; + INT n; + UINT u; + + switch (message) + { + case WM_INITDIALOG: + SetTimer(hDlg, MGR_TIMER_ID, 1000, nullptr); + + ReadValue(pathconfigxml, SectionUserDict, ValueBackupGen, strxmlval); + n = strxmlval.empty() ? -1 : _wtoi(strxmlval.c_str()); + if (n < 0) + { + n = DEF_BACKUPGENS; + } + else if (n > MAX_BACKUPGENS) + { + n = MAX_BACKUPGENS; + } + _snwprintf_s(num, _TRUNCATE, L"%d", n); + SetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPGEN, num); + + ReadValue(pathconfigxml, SectionUserDict, ValueBackupDir, strxmlval); + if (strxmlval.empty()) + { + strxmlval = L"%APPDATA%\\" TEXTSERVICE_DESC; + } + FORWARD_ITERATION_I(s_itr, strxmlval) + { + UINT type = PathGetCharTypeW(*s_itr); + if ((type & (GCT_LFNCHAR | GCT_SHORTCHAR | GCT_SEPARATOR)) == 0) + { + *s_itr = L'_'; + } + } + SetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPDIR, strxmlval.c_str()); + + ReadValue(pathconfigxml, SectionUserDict, ValuePrivateOnVKey, strxmlval); + u = (strxmlval.empty() ? + VK_F10 : (BYTE)wcstoul(strxmlval.c_str(), nullptr, 0)); + _snwprintf_s(num, _TRUNCATE, L"0x%02X", u); + SetDlgItemTextW(hDlg, IDC_EDIT_PRIVATEMODE_ON_VKEY, num); + + ReadValue(pathconfigxml, SectionUserDict, ValuePrivateOnMKey, strxmlval); + u = (strxmlval.empty() ? + (TF_MOD_CONTROL | TF_MOD_SHIFT) : wcstoul(strxmlval.c_str(), nullptr, 0)); + CheckDlgButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_ALT, ((u & TF_MOD_ALT) ? BST_CHECKED : BST_UNCHECKED)); + CheckDlgButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_CTRL, ((u & TF_MOD_CONTROL) ? BST_CHECKED : BST_UNCHECKED)); + CheckDlgButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_SHIFT, ((u & TF_MOD_SHIFT) ? BST_CHECKED : BST_UNCHECKED)); + + ReadValue(pathconfigxml, SectionUserDict, ValuePrivateOffVKey, strxmlval); + u = (strxmlval.empty() ? + VK_F10 : (BYTE)wcstoul(strxmlval.c_str(), nullptr, 0)); + _snwprintf_s(num, _TRUNCATE, L"0x%02X", u); + SetDlgItemTextW(hDlg, IDC_EDIT_PRIVATEMODE_OFF_VKEY, num); + + ReadValue(pathconfigxml, SectionUserDict, ValuePrivateOffMKey, strxmlval); + u = (strxmlval.empty() ? + (TF_MOD_CONTROL | TF_MOD_SHIFT) : wcstoul(strxmlval.c_str(), nullptr, 0)); + CheckDlgButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_ALT, ((u & TF_MOD_ALT) ? BST_CHECKED : BST_UNCHECKED)); + CheckDlgButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_CTRL, ((u & TF_MOD_CONTROL) ? BST_CHECKED : BST_UNCHECKED)); + CheckDlgButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_SHIFT, ((u & TF_MOD_SHIFT) ? BST_CHECKED : BST_UNCHECKED)); + + LoadCheckButton(hDlg, IDC_CHECKBOX_PRIVATEMODE_AUTO, SectionUserDict, ValuePrivateModeAuto, L"1"); + + bkcnfSaved = TRUE; + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_RUN_BACKUP), ((bkcnfSaved && mgrprocRun) ? TRUE : FALSE)); + + return TRUE; + + case WM_DPICHANGED_AFTERPARENT: + break; + + case WM_TIMER: + if (wParam == MGR_TIMER_ID) + { + BOOL running = PathFileExistsW(mgrpipename); + + SetDlgItemTextW(hDlg, IDC_MGR_STATUS_TEXT, (running ? L"実行中" : L"終了状態")); + + mgrprocRun = running; + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_RUN_BACKUP), ((bkcnfSaved && mgrprocRun) ? TRUE : FALSE)); + + return TRUE; + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_BUTTON_MGR_KILL: + CommandDic(REQ_EXIT); + return TRUE; + + case IDC_BUTTON_MGR_RUN: + StartProcess(hInst, IMCRVMGREXE); + return TRUE; + + case IDC_BUTTON_OPEN_USERDIR: + { + PWSTR knownfolderpath = nullptr; + + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) + { + WCHAR appdir[MAX_PATH]; + + _snwprintf_s(appdir, _TRUNCATE, L"%s\\%s", knownfolderpath, TextServiceDesc); + + CoTaskMemFree(knownfolderpath); + + ShellExecuteW(nullptr, L"open", appdir, nullptr, nullptr, SW_SHOWNORMAL); + + return TRUE; + } + } + break; + + case IDC_BUTTON_OPEN_SYSTEMDIR: + { + PWSTR knownfolderpath = nullptr; + + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) + { + WCHAR appdir[MAX_PATH]; + + _snwprintf_s(appdir, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, SYSTEMROOT_IME_DIR, TEXTSERVICE_DIR); + + CoTaskMemFree(knownfolderpath); + + ShellExecuteW(nullptr, L"open", appdir, nullptr, nullptr, SW_SHOWNORMAL); + + return TRUE; + } + } + break; + + case IDC_EDIT_USERDICBACKUPGEN: + case IDC_EDIT_USERDICBACKUPDIR: + case IDC_EDIT_PRIVATEMODE_ON_VKEY: + case IDC_EDIT_PRIVATEMODE_OFF_VKEY: + switch (HIWORD(wParam)) + { + case EN_CHANGE: + PropSheet_Changed(GetParent(hDlg), hDlg); + switch (LOWORD(wParam)) + { + case IDC_EDIT_USERDICBACKUPGEN: + case IDC_EDIT_USERDICBACKUPDIR: + bkcnfSaved = FALSE; + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_RUN_BACKUP), ((bkcnfSaved && mgrprocRun) ? TRUE : FALSE)); + break; + default: + break; + } + return TRUE; + default: + break; + } + break; + + case IDC_BUTTON_OPEN_BACKUPDIR: + { + WCHAR prepath[MAX_PATH]; + WCHAR exppath[MAX_PATH]; + + GetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPDIR, prepath, _countof(prepath)); + + ExpandEnvironmentStringsW(prepath, exppath, _countof(exppath)); + + ShellExecuteW(nullptr, L"open", exppath, nullptr, nullptr, SW_SHOWNORMAL); + + return TRUE; + } + break; + + case IDC_BUTTON_RUN_BACKUP: + CommandDic(REQ_BACKUP); + return TRUE; + + case IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_ALT: + case IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_CTRL: + case IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_SHIFT: + case IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_ALT: + case IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_CTRL: + case IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_SHIFT: + case IDC_CHECKBOX_PRIVATEMODE_AUTO: + PropSheet_Changed(GetParent(hDlg), hDlg); + return TRUE; + + default: + break; + } + break; + + case WM_NOTIFY: + if (lParam == NULL) break; + switch (((LPNMHDR)lParam)->code) + { + case PSN_TRANSLATEACCELERATOR: + { + WCHAR vkeytext[8]; + LPMSG lpMsg = (LPMSG)((LPPSHNOTIFY)lParam)->lParam; + if (lpMsg == NULL) break; + switch (lpMsg->message) + { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch (GetDlgCtrlID(lpMsg->hwnd)) + { + case IDC_EDIT_DICTIONARY2_TEST_VKEY: + _snwprintf_s(vkeytext, _TRUNCATE, L"0x%02X", (BYTE)lpMsg->wParam); + SetDlgItemTextW(hDlg, IDC_EDIT_DICTIONARY2_TEST_VKEY, vkeytext); + SendDlgItemMessageW(hDlg, IDC_EDIT_DICTIONARY2_TEST_VKEY, EM_SETSEL, 4, 4); + SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_MESSAGEHANDLED); + return TRUE; + default: + break; + } + break; + default: + break; + } + } + break; + default: + break; + } + break; + + case WM_DESTROY: + KillTimer(hDlg, MGR_TIMER_ID); + PostQuitMessage(0); + return TRUE; + + default: + break; + } + + return FALSE; +} + +void SaveDictionary2(IXmlWriter *pWriter, HWND hDlg) +{ + WCHAR path[MAX_PATH] = {}; + WCHAR num[16] = {}; + INT n; + UINT u; + + GetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPDIR, path, _countof(path)); + for (int i = 0; i < _countof(path) && path[i] != L'\0'; i++) + { + UINT type = PathGetCharTypeW(path[i]); + if ((type & (GCT_LFNCHAR | GCT_SHORTCHAR | GCT_SEPARATOR)) == 0) + { + path[i] = L'_'; + } + } + SetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPDIR, path); + WriterKey(pWriter, ValueBackupDir, path); + + GetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPGEN, num, _countof(num)); + n = _wtoi(num); + if (n < 0) + { + n = DEF_BACKUPGENS; + } + else if (n > MAX_BACKUPGENS) + { + n = MAX_BACKUPGENS; + } + _snwprintf_s(num, _TRUNCATE, L"%d", n); + SetDlgItemTextW(hDlg, IDC_EDIT_USERDICBACKUPGEN, num); + WriterKey(pWriter, ValueBackupGen, num); + + GetDlgItemTextW(hDlg, IDC_EDIT_PRIVATEMODE_ON_VKEY, num, _countof(num)); + _snwprintf_s(num, _TRUNCATE, L"0x%02X", (BYTE)wcstoul(num, nullptr, 0)); + SetDlgItemTextW(hDlg, IDC_EDIT_PRIVATEMODE_ON_VKEY, num); + WriterKey(pWriter, ValuePrivateOnVKey, num); + + u = 0; + if (IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_ALT)) { u |= TF_MOD_ALT; } + if (IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_CTRL)) { u |= TF_MOD_CONTROL; } + if (IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_SHIFT)) { u |= TF_MOD_SHIFT; } + _snwprintf_s(num, _TRUNCATE, L"%X", u); + WriterKey(pWriter, ValuePrivateOnMKey, num); + + GetDlgItemTextW(hDlg, IDC_EDIT_PRIVATEMODE_OFF_VKEY, num, _countof(num)); + _snwprintf_s(num, _TRUNCATE, L"0x%02X", (BYTE)wcstoul(num, nullptr, 0)); + SetDlgItemTextW(hDlg, IDC_EDIT_PRIVATEMODE_OFF_VKEY, num); + WriterKey(pWriter, ValuePrivateOffVKey, num); + + u = 0; + if (IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_ALT)) { u |= TF_MOD_ALT; } + if (IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_CTRL)) { u |= TF_MOD_CONTROL; } + if (IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_SHIFT)) { u |= TF_MOD_SHIFT; } + _snwprintf_s(num, _TRUNCATE, L"%X", u); + WriterKey(pWriter, ValuePrivateOffMKey, num); + + SaveCheckButton(pWriter, hDlg, IDC_CHECKBOX_PRIVATEMODE_AUTO, ValuePrivateModeAuto); + + bkcnfSaved = TRUE; + EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_RUN_BACKUP), ((bkcnfSaved && mgrprocRun) ? TRUE : FALSE)); +} + +BOOL ConnectDic() +{ + DWORD dwMode; + + if (WaitNamedPipeW(mgrpipename, NMPWAIT_USE_DEFAULT_WAIT) == 0) + { + return FALSE; + } + + hPipe = CreateFileW(mgrpipename, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, + nullptr, OPEN_EXISTING, SECURITY_SQOS_PRESENT | SECURITY_EFFECTIVE_ONLY | SECURITY_IDENTIFICATION, nullptr); + if (hPipe == INVALID_HANDLE_VALUE) + { + return FALSE; + } + + dwMode = PIPE_READMODE_MESSAGE | PIPE_WAIT; + if (SetNamedPipeHandleState(hPipe, &dwMode, nullptr, nullptr) == FALSE) + { + DisconnectDic(); + return FALSE; + } + + return TRUE; +} + +void DisconnectDic() +{ + if (hPipe != INVALID_HANDLE_VALUE) + { + CloseHandle(hPipe); + hPipe = INVALID_HANDLE_VALUE; + } +} + +BOOL CommandDic(WCHAR command) +{ + BOOL ret = FALSE; + + WCHAR pipebuf[4] = {}; + DWORD bytesWrite, bytesRead; + + ConnectDic(); + + pipebuf[0] = command; + pipebuf[1] = L'\n'; + pipebuf[2] = L'\0'; + pipebuf[3] = L'\0'; + + bytesWrite = (DWORD)((wcslen(pipebuf) + 1) * sizeof(WCHAR)); + if (WriteFile(hPipe, pipebuf, bytesWrite, &bytesWrite, nullptr) == FALSE) + { + goto exit; + } + + bytesRead = 0; + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) + { + goto exit; + } + + ret = TRUE; + +exit: + + DisconnectDic(); + + return ret; +} diff --git a/imcrvcnf/DlgProcDisplay1.cpp b/imcrvcnf/DlgProcDisplay1.cpp index 892e226a..31f1769e 100644 --- a/imcrvcnf/DlgProcDisplay1.cpp +++ b/imcrvcnf/DlgProcDisplay1.cpp @@ -26,8 +26,8 @@ INT_PTR CALLBACK DlgProcDisplay1(HWND hDlg, UINT message, WPARAM wParam, LPARAM HWND hwnd; HDC hdc; PAINTSTRUCT ps; - WCHAR num[16]; - WCHAR fontname[LF_FACESIZE]; + WCHAR num[16] = {}; + WCHAR fontname[LF_FACESIZE] = {}; INT fontpoint, fontweight, count; BOOL fontitalic; CHOOSEFONTW cf = {}; @@ -36,7 +36,7 @@ INT_PTR CALLBACK DlgProcDisplay1(HWND hDlg, UINT message, WPARAM wParam, LPARAM LONG w; std::wstring strxmlval; CHOOSECOLORW cc = {}; - static COLORREF customColor[16]; + static COLORREF customColor[16] = {}; switch (message) { @@ -124,6 +124,21 @@ INT_PTR CALLBACK DlgProcDisplay1(HWND hDlg, UINT message, WPARAM wParam, LPARAM } SendMessageW(hwnd, CB_SETCURSEL, (WPARAM)count, 0); + hwnd = GetDlgItem(hDlg, IDC_COMBO_PAGECANDNUM); + num[1] = L'\0'; + for (int i = 1; i <= MAX_SELKEY_C; i++) + { + num[0] = L'0' + (WCHAR)i; + SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)num); + } + ReadValue(pathconfigxml, SectionDisplay, ValuePageCandNum, strxmlval); + count = strxmlval.empty() ? MAX_SELKEY : _wtoi(strxmlval.c_str()); + if (count > MAX_SELKEY_C || count < 1) + { + count = MAX_SELKEY; + } + SendMessageW(hwnd, CB_SETCURSEL, (WPARAM)(count - 1), 0); + LoadCheckButton(hDlg, IDC_CHECKBOX_DISPCANDNO, SectionDisplay, ValueDispCandNo); LoadCheckButton(hDlg, IDC_CHECKBOX_VERTICALCAND, SectionDisplay, ValueVerticalCand, L"1"); @@ -233,6 +248,7 @@ INT_PTR CALLBACK DlgProcDisplay1(HWND hDlg, UINT message, WPARAM wParam, LPARAM break; case IDC_COMBO_UNTILCANDLIST: + case IDC_COMBO_PAGECANDNUM: switch (HIWORD(wParam)) { case CBN_SELCHANGE: @@ -299,10 +315,10 @@ INT_PTR CALLBACK DlgProcDisplay1(HWND hDlg, UINT message, WPARAM wParam, LPARAM void SaveFont(IXmlWriter *pWriter, HWND hDlg) { - WCHAR fontname[LF_FACESIZE]; + WCHAR fontname[LF_FACESIZE] = {}; HFONT hFont; LOGFONTW lf = {}; - WCHAR num[16]; + WCHAR num[16] = {}; GetDlgItemTextW(hDlg, IDC_EDIT_FONTNAME, fontname, _countof(fontname)); WriterKey(pWriter, ValueFontName, fontname); @@ -319,7 +335,7 @@ void SaveFont(IXmlWriter *pWriter, HWND hDlg) void SaveDisplay1(IXmlWriter *pWriter, HWND hDlg) { - WCHAR num[16]; + WCHAR num[16] = {}; LONG w; HWND hwnd; int count; @@ -353,6 +369,16 @@ void SaveDisplay1(IXmlWriter *pWriter, HWND hDlg) num[1] = L'\0'; WriterKey(pWriter, ValueUntilCandList, num); + hwnd = GetDlgItem(hDlg, IDC_COMBO_PAGECANDNUM); + count = 1 + (int)SendMessageW(hwnd, CB_GETCURSEL, 0, 0); + if (count > MAX_SELKEY_C || count < 1) + { + count = MAX_SELKEY; + } + num[0] = L'0' + count; + num[1] = L'\0'; + WriterKey(pWriter, ValuePageCandNum, num); + SaveCheckButton(pWriter, hDlg, IDC_CHECKBOX_DISPCANDNO, ValueDispCandNo); SaveCheckButton(pWriter, hDlg, IDC_CHECKBOX_VERTICALCAND, ValueVerticalCand); SaveCheckButton(pWriter, hDlg, IDC_CHECKBOX_ANNOTATION, ValueAnnotation); diff --git a/imcrvcnf/DlgProcDisplay2.cpp b/imcrvcnf/DlgProcDisplay2.cpp index 8d9148cd..baffaf20 100644 --- a/imcrvcnf/DlgProcDisplay2.cpp +++ b/imcrvcnf/DlgProcDisplay2.cpp @@ -23,11 +23,11 @@ INT_PTR CALLBACK DlgProcDisplay2(HWND hDlg, UINT message, WPARAM wParam, LPARAM { HDC hdc; PAINTSTRUCT ps; - WCHAR num[16]; - int count; + WCHAR num[16] = {}; + int n; std::wstring strxmlval; CHOOSECOLORW cc = {}; - static COLORREF customColor[16]; + static COLORREF customColor[16] = {}; switch (message) { @@ -36,20 +36,20 @@ INT_PTR CALLBACK DlgProcDisplay2(HWND hDlg, UINT message, WPARAM wParam, LPARAM ReadValue(pathconfigxml, SectionDisplay, ValueShowModeInlTm, strxmlval); if (!strxmlval.empty()) { - count = _wtoi(strxmlval.c_str()); + n = _wtoi(strxmlval.c_str()); } else { //for compatibility ReadValue(pathconfigxml, SectionDisplay, ValueShowModeSec, strxmlval); - count = strxmlval.empty() ? -1 : _wtoi(strxmlval.c_str()) * 1000; + n = strxmlval.empty() ? -1 : _wtoi(strxmlval.c_str()) * 1000; } - if (count > 60000 || count <= 0) + if (n > 60000 || n <= 0) { - count = SHOWMODEINLTM_DEF; + n = SHOWMODEINLTM_DEF; } - _snwprintf_s(num, _TRUNCATE, L"%d", count); + _snwprintf_s(num, _TRUNCATE, L"%d", n); SetDlgItemTextW(hDlg, IDC_EDIT_SHOWMODEINLTM, num); for (int i = 0; i < _countof(customColor); i++) @@ -159,7 +159,7 @@ INT_PTR CALLBACK DlgProcDisplay2(HWND hDlg, UINT message, WPARAM wParam, LPARAM void SaveDisplay2(IXmlWriter *pWriter, HWND hDlg) { - WCHAR num[16]; + WCHAR num[16] = {}; int count; SaveCheckButton(pWriter, hDlg, IDC_CHECKBOX_SHOWMODEINL, ValueShowModeInl); diff --git a/imcrvcnf/DlgProcDisplayAttr.cpp b/imcrvcnf/DlgProcDisplayAttr.cpp index 2513059f..ddf1d12e 100644 --- a/imcrvcnf/DlgProcDisplayAttr.cpp +++ b/imcrvcnf/DlgProcDisplayAttr.cpp @@ -147,7 +147,7 @@ INT_PTR CALLBACK DlgProcDisplayAttr(HWND hDlg, UINT message, WPARAM wParam, LPAR PAINTSTRUCT ps; HDC hdc; CHOOSECOLORW cc = {}; - static COLORREF customColor[16]; + static COLORREF customColor[16] = {}; switch (message) { @@ -380,7 +380,7 @@ void LoadDisplayAttr(int no) { std::wstring strxmlval; BOOL se; - TF_DISPLAYATTRIBUTE da; + TF_DISPLAYATTRIBUTE da = {}; for (int i = 0; i < _countof(displayAttr[no]) && displayAttr[no][i].key != nullptr; i++) { @@ -400,7 +400,7 @@ void LoadDisplayAttr(int no) void SaveDisplayAttr(IXmlWriter *pWriter, HWND hDlg, int no) { - WCHAR num[64]; + WCHAR num[64] = {}; for (int i = 0; i < _countof(displayAttr[no]); i++) { diff --git a/imcrvcnf/DlgProcJLatin.cpp b/imcrvcnf/DlgProcJLatin.cpp index e50df3ad..657bb59e 100644 --- a/imcrvcnf/DlgProcJLatin.cpp +++ b/imcrvcnf/DlgProcJLatin.cpp @@ -11,12 +11,12 @@ void LoadJLatin(HWND hDlg); INT_PTR CALLBACK DlgProcJLatin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWndListView; - LV_COLUMNW lvc; - LVITEMW item; + LV_COLUMNW lvc = {}; + LVITEMW item = {}; int index, count; - ASCII_JLATIN_CONV ajc; - ASCII_JLATIN_CONV ajcBak; - NMLISTVIEW *pListView; + ASCII_JLATIN_CONV ajc = {}; + ASCII_JLATIN_CONV ajcBak = {}; + LPNMLISTVIEW pListView; WCHAR text[16] = {}; switch (message) @@ -29,11 +29,11 @@ INT_PTR CALLBACK DlgProcJLatin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP lvc.pszText = text; lvc.iSubItem = 0; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"ASCII", _TRUNCATE); ListView_InsertColumn(hWndListView, 0, &lvc); lvc.iSubItem = 1; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"全英", _TRUNCATE); ListView_InsertColumn(hWndListView, 1, &lvc); @@ -47,8 +47,8 @@ INT_PTR CALLBACK DlgProcJLatin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP case WM_DPICHANGED_AFTERPARENT: hWndListView = GetDlgItem(hDlg, IDC_LIST_JLATTBL); - ListView_SetColumnWidth(hWndListView, 0, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 0, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 60)); return TRUE; @@ -65,8 +65,13 @@ INT_PTR CALLBACK DlgProcJLatin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP GetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_A, ajc.ascii, _countof(ajc.ascii)); GetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_J, ajc.jlatin, _countof(ajc.jlatin)); + + REPLACE_WELLFORMED(ajc.ascii); + REPLACE_WELLFORMED(ajc.jlatin); + SetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_A, ajc.ascii); SetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_J, ajc.jlatin); + ListView_SetItemText(hWndListView, index, 0, ajc.ascii); ListView_SetItemText(hWndListView, index, 1, ajc.jlatin); } @@ -76,8 +81,13 @@ INT_PTR CALLBACK DlgProcJLatin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP GetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_A, ajc.ascii, _countof(ajc.ascii)); GetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_J, ajc.jlatin, _countof(ajc.jlatin)); + + REPLACE_WELLFORMED(ajc.ascii); + REPLACE_WELLFORMED(ajc.jlatin); + SetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_A, ajc.ascii); SetDlgItemTextW(hDlg, IDC_EDIT_JLATTBL_J, ajc.jlatin); + item.mask = LVIF_TEXT; item.pszText = ajc.ascii; item.iItem = count; @@ -143,10 +153,11 @@ INT_PTR CALLBACK DlgProcJLatin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP break; case WM_NOTIFY: + if (lParam == NULL) break; switch (((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: - pListView = (NMLISTVIEW*)((LPNMHDR)lParam); + pListView = (LPNMLISTVIEW)((LPNMHDR)lParam); if (pListView->uChanged & LVIF_STATE) { hWndListView = ((LPNMHDR)lParam)->hwndFrom; @@ -227,7 +238,7 @@ void LoadConfigJLatin() void LoadJLatin(HWND hDlg) { - LVITEMW item; + LVITEMW item = {}; LoadConfigJLatin(); @@ -258,7 +269,7 @@ void SaveJLatin(IXmlWriter *pWriter, HWND hDlg) APPDATAXMLLIST list; APPDATAXMLROW row; APPDATAXMLATTR attr; - ASCII_JLATIN_CONV ajc; + ASCII_JLATIN_CONV ajc = {}; HWND hWndListView = GetDlgItem(hDlg, IDC_LIST_JLATTBL); int count = ListView_GetItemCount(hWndListView); diff --git a/imcrvcnf/DlgProcKana.cpp b/imcrvcnf/DlgProcKana.cpp index e8dc039d..ee8e4a79 100644 --- a/imcrvcnf/DlgProcKana.cpp +++ b/imcrvcnf/DlgProcKana.cpp @@ -16,15 +16,15 @@ void SaveKanaTxt(HWND hDlg, LPCWSTR path); INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWndListView; - LV_COLUMNW lvc; - LVITEMW item; + LV_COLUMNW lvc = {}; + LVITEMW item = {}; int index, count; - ROMAN_KANA_CONV rkc; - ROMAN_KANA_CONV rkcBak; - WCHAR soku[2]; - NMLISTVIEW *pListView; + ROMAN_KANA_CONV rkc = {}; + ROMAN_KANA_CONV rkcBak = {}; + WCHAR soku[2] = {}; + LPNMLISTVIEW pListView; OPENFILENAMEW ofn = {}; - WCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH] = {}; WCHAR text[16] = {}; switch (message) @@ -37,23 +37,23 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar lvc.pszText = text; lvc.iSubItem = 0; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"ローマ字", _TRUNCATE); ListView_InsertColumn(hWndListView, 0, &lvc); lvc.iSubItem = 1; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"かな", _TRUNCATE); ListView_InsertColumn(hWndListView, 1, &lvc); lvc.iSubItem = 2; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"カナ", _TRUNCATE); ListView_InsertColumn(hWndListView, 2, &lvc); lvc.iSubItem = 3; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"カナ", _TRUNCATE); ListView_InsertColumn(hWndListView, 3, &lvc); lvc.iSubItem = 4; - lvc.cx = GetScaledSizeX(hDlg, 30); + lvc.cx = GetScaledSize(hDlg, 30); wcsncpy_s(text, L"…", _TRUNCATE); ListView_InsertColumn(hWndListView, 4, &lvc); @@ -71,11 +71,11 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar case WM_DPICHANGED_AFTERPARENT: hWndListView = GetDlgItem(hDlg, IDC_LIST_KANATBL); - ListView_SetColumnWidth(hWndListView, 0, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 3, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 4, GetScaledSizeX(hDlg, 30)); + ListView_SetColumnWidth(hWndListView, 0, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 3, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 4, GetScaledSize(hDlg, 30)); return TRUE; @@ -133,10 +133,17 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar GetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_KA, rkc.katakana_ank, _countof(rkc.katakana_ank)); IsDlgButtonChecked(hDlg, IDC_CHECKBOX_KANATBL_SOKU) == BST_CHECKED ? rkc.soku = TRUE : rkc.soku = FALSE; IsDlgButtonChecked(hDlg, IDC_CHECKBOX_KANATBL_WAIT) == BST_CHECKED ? rkc.wait = TRUE : rkc.wait = FALSE; + + REPLACE_WELLFORMED(rkc.roman); + REPLACE_WELLFORMED(rkc.hiragana); + REPLACE_WELLFORMED(rkc.katakana); + REPLACE_WELLFORMED(rkc.katakana_ank); + SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_R, rkc.roman); SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_H, rkc.hiragana); SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_K, rkc.katakana); SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_KA, rkc.katakana_ank); + ListView_SetItemText(hWndListView, index, 0, rkc.roman); ListView_SetItemText(hWndListView, index, 1, rkc.hiragana); ListView_SetItemText(hWndListView, index, 2, rkc.katakana); @@ -155,10 +162,17 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar GetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_KA, rkc.katakana_ank, _countof(rkc.katakana_ank)); IsDlgButtonChecked(hDlg, IDC_CHECKBOX_KANATBL_SOKU) == BST_CHECKED ? rkc.soku = TRUE : rkc.soku = FALSE; IsDlgButtonChecked(hDlg, IDC_CHECKBOX_KANATBL_WAIT) == BST_CHECKED ? rkc.wait = TRUE : rkc.wait = FALSE; + + REPLACE_WELLFORMED(rkc.roman); + REPLACE_WELLFORMED(rkc.hiragana); + REPLACE_WELLFORMED(rkc.katakana); + REPLACE_WELLFORMED(rkc.katakana_ank); + SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_R, rkc.roman); SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_H, rkc.hiragana); SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_K, rkc.katakana); SetDlgItemTextW(hDlg, IDC_EDIT_KANATBL_KA, rkc.katakana_ank); + item.mask = LVIF_TEXT; item.pszText = rkc.roman; item.iItem = count; @@ -278,10 +292,11 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar break; case WM_NOTIFY: + if (lParam == NULL) break; switch (((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: - pListView = (NMLISTVIEW*)((LPNMHDR)lParam); + pListView = (LPNMLISTVIEW)((LPNMHDR)lParam); if (pListView->uChanged & LVIF_STATE) { hWndListView = ((LPNMHDR)lParam)->hwndFrom; @@ -326,16 +341,16 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar void LoadConfigKanaTxt(LPCWSTR path) { - FILE *fp; + FILE *fp = nullptr; wchar_t b[CONFKANALEN]; const wchar_t seps[] = L"\t\n\0"; size_t sidx, eidx; - WCHAR soku[2]; + WCHAR soku[2] = {}; roman_kana_conv.clear(); roman_kana_conv.shrink_to_fit(); - _wfopen_s(&fp, path, RccsUTF8); + _wfopen_s(&fp, path, modeRccsUTF8); if (fp == nullptr) { return; @@ -412,8 +427,8 @@ void LoadConfigKanaTxt(LPCWSTR path) void LoadKanaTxt(HWND hDlg, LPCWSTR path) { - LVITEMW item; - WCHAR soku[2]; + LVITEMW item = {}; + WCHAR soku[2] = {}; LoadConfigKanaTxt(path); @@ -451,9 +466,9 @@ void LoadKanaTxt(HWND hDlg, LPCWSTR path) void SaveKanaTxt(HWND hDlg, LPCWSTR path) { - ROMAN_KANA_CONV rkc; - WCHAR soku[2]; - FILE *fp; + ROMAN_KANA_CONV rkc = {}; + WCHAR soku[2] = {}; + FILE *fp = nullptr; roman_kana_conv.clear(); roman_kana_conv.shrink_to_fit(); @@ -474,7 +489,7 @@ void SaveKanaTxt(HWND hDlg, LPCWSTR path) roman_kana_conv.push_back(rkc); } - _wfopen_s(&fp, path, WccsUTF8); + _wfopen_s(&fp, path, modeWccsUTF8); if (fp != nullptr) { count = (int)roman_kana_conv.size(); @@ -577,8 +592,8 @@ void LoadConfigKana() void LoadKana(HWND hDlg) { - LVITEMW item; - WCHAR soku[2]; + LVITEMW item = {}; + WCHAR soku[2] = {}; LoadConfigKana(); @@ -618,8 +633,8 @@ void SaveKana(IXmlWriter *pWriter, HWND hDlg) APPDATAXMLLIST list; APPDATAXMLROW row; APPDATAXMLATTR attr; - ROMAN_KANA_CONV rkc; - WCHAR soku[2]; + ROMAN_KANA_CONV rkc = {}; + WCHAR soku[2] = {}; roman_kana_conv.clear(); roman_kana_conv.shrink_to_fit(); diff --git a/imcrvcnf/DlgProcKeyMap.cpp b/imcrvcnf/DlgProcKeyMap.cpp index 85cee5af..99956590 100644 --- a/imcrvcnf/DlgProcKeyMap.cpp +++ b/imcrvcnf/DlgProcKeyMap.cpp @@ -7,7 +7,7 @@ static const struct { int idd; LPCWSTR keyName; LPCWSTR defaultValue; -} KeyMap[2][26] = +} KeyMap[2][27] = { { {IDC_EDIT_KANA, ValueKeyMapKana, L"q"}, @@ -35,7 +35,8 @@ static const struct { {IDC_EDIT_UP, ValueKeyMapUp, L"\\ca"}, {IDC_EDIT_RIGHT, ValueKeyMapRight, L"\\cf"}, {IDC_EDIT_DOWN, ValueKeyMapDown, L"\\ce"}, - {IDC_EDIT_PASTE, ValueKeyMapPaste, L"\\cy|\\cv"} + {IDC_EDIT_PASTE, ValueKeyMapPaste, L"\\cy|\\cv"}, + {IDC_EDIT_RECONVERT, ValueKeyMapReconvert, L""} }, { {IDC_EDIT_KANA, ValueKeyMapKana, L""}, @@ -63,7 +64,8 @@ static const struct { {IDC_EDIT_UP, ValueKeyMapUp, L"\\x26"}, {IDC_EDIT_RIGHT, ValueKeyMapRight, L"\\x27"}, {IDC_EDIT_DOWN, ValueKeyMapDown, L"\\x28"}, - {IDC_EDIT_PASTE, ValueKeyMapPaste, L""} + {IDC_EDIT_PASTE, ValueKeyMapPaste, L""}, + {IDC_EDIT_RECONVERT, ValueKeyMapReconvert, L""} } }; @@ -122,6 +124,7 @@ INT_PTR CALLBACK DlgProcKeyMap(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP case IDC_EDIT_RIGHT: case IDC_EDIT_DOWN: case IDC_EDIT_PASTE: + case IDC_EDIT_RECONVERT: switch (HIWORD(wParam)) { case EN_CHANGE: @@ -136,6 +139,41 @@ INT_PTR CALLBACK DlgProcKeyMap(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP } break; + case WM_NOTIFY: + if (lParam == NULL) break; + switch (((LPNMHDR)lParam)->code) + { + case PSN_TRANSLATEACCELERATOR: + { + WCHAR vkeytext[8]; + LPMSG lpMsg = (LPMSG)((LPPSHNOTIFY)lParam)->lParam; + if (lpMsg == NULL) break; + switch (lpMsg->message) + { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + switch (GetDlgCtrlID(lpMsg->hwnd)) + { + case IDC_EDIT_KEYMAP_TEST_VKEY: + _snwprintf_s(vkeytext, _TRUNCATE, L"\\x%02X", (BYTE)lpMsg->wParam); + SetDlgItemTextW(hDlg, IDC_EDIT_KEYMAP_TEST_VKEY, vkeytext); + SendDlgItemMessageW(hDlg, IDC_EDIT_KEYMAP_TEST_VKEY, EM_SETSEL, 4, 4); + SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_MESSAGEHANDLED); + return TRUE; + default: + break; + } + break; + default: + break; + } + } + break; + default: + break; + } + break; + default: break; } @@ -155,7 +193,7 @@ void LoadKeyMap(HWND hDlg, int nIDDlgItem, LPCWSTR lpAppName, LPCWSTR lpKeyName, void SaveKeyMap(IXmlWriter *pWriter, HWND hDlg, int nIDDlgItem, LPCWSTR lpKeyName) { - WCHAR keyre[MAX_KEYRE]; + WCHAR keyre[MAX_KEYRE] = {}; GetDlgItemTextW(hDlg, nIDDlgItem, keyre, _countof(keyre)); WriterKey(pWriter, lpKeyName, keyre); diff --git a/imcrvcnf/DlgProcPreservedKey.cpp b/imcrvcnf/DlgProcPreservedKey.cpp index 6d55c632..8b80a262 100644 --- a/imcrvcnf/DlgProcPreservedKey.cpp +++ b/imcrvcnf/DlgProcPreservedKey.cpp @@ -19,12 +19,12 @@ void LoadPreservedKey(HWND hDlg); INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWndListView; - LV_COLUMNW lvc; - LVITEMW item; + LV_COLUMNW lvc = {}; + LVITEMW item = {}; int index, count; - WCHAR key[8]; - WCHAR keyBak[8]; - NMLISTVIEW *pListView; + WCHAR key[8] = {}; + WCHAR keyBak[8] = {}; + LPNMLISTVIEW pListView; WCHAR text[16] = {}; switch (message) @@ -39,19 +39,19 @@ INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPA lvc.pszText = text; lvc.iSubItem = 0; - lvc.cx = GetScaledSizeX(hDlg, 90); + lvc.cx = GetScaledSize(hDlg, 90); wcsncpy_s(text, preservedkeyInfo[i].text, _TRUNCATE); ListView_InsertColumn(hWndListView, 0, &lvc); lvc.iSubItem = 1; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"ALT", _TRUNCATE); ListView_InsertColumn(hWndListView, 1, &lvc); lvc.iSubItem = 2; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"CTRL", _TRUNCATE); ListView_InsertColumn(hWndListView, 2, &lvc); lvc.iSubItem = 3; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"SHIFT", _TRUNCATE); ListView_InsertColumn(hWndListView, 3, &lvc); } @@ -71,10 +71,10 @@ INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPA { hWndListView = GetDlgItem(hDlg, preservedkeyInfo[i].id); - ListView_SetColumnWidth(hWndListView, 0, GetScaledSizeX(hDlg, 90)); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 3, GetScaledSizeX(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 0, GetScaledSize(hDlg, 90)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 3, GetScaledSize(hDlg, 60)); } return TRUE; @@ -92,7 +92,7 @@ INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPA PropSheet_Changed(GetParent(hDlg), hDlg); GetDlgItemTextW(hDlg, IDC_EDIT_PRSRVKEY_VKEY, key, _countof(key)); - _snwprintf_s(key, _TRUNCATE, L"0x%02X", wcstoul(key, nullptr, 0)); + _snwprintf_s(key, _TRUNCATE, L"0x%02X", (BYTE)wcstoul(key, nullptr, 0)); SetDlgItemTextW(hDlg, IDC_EDIT_PRSRVKEY_VKEY, key); ListView_SetItemText(hWndListView, index, 0, key); wcsncpy_s(text, IsDlgButtonChecked(hDlg, IDC_CHECKBOX_PRSRVKEY_MKEY_ALT) == BST_CHECKED ? L"1" : L"0", _TRUNCATE); @@ -109,7 +109,7 @@ INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPA item.mask = LVIF_TEXT; GetDlgItemTextW(hDlg, IDC_EDIT_PRSRVKEY_VKEY, key, _countof(key)); - _snwprintf_s(key, _TRUNCATE, L"0x%02X", wcstoul(key, nullptr, 0)); + _snwprintf_s(key, _TRUNCATE, L"0x%02X", (BYTE)wcstoul(key, nullptr, 0)); SetDlgItemTextW(hDlg, IDC_EDIT_PRSRVKEY_VKEY, key); item.pszText = key; item.iItem = count; @@ -215,23 +215,25 @@ INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPA break; case WM_NOTIFY: + if (lParam == NULL) break; hWndListView = ((LPNMHDR)lParam)->hwndFrom; switch (((LPNMHDR)lParam)->code) { case PSN_TRANSLATEACCELERATOR: { + WCHAR vkeytext[8]; LPMSG lpMsg = (LPMSG)((LPPSHNOTIFY)lParam)->lParam; + if (lpMsg == NULL) break; switch (lpMsg->message) { case WM_KEYDOWN: case WM_SYSKEYDOWN: switch (GetDlgCtrlID(lpMsg->hwnd)) { - case IDC_EDIT_DISPVKEY: - WCHAR vkeytext[8]; + case IDC_EDIT_PRSRVKEY_TEST_VKEY: _snwprintf_s(vkeytext, _TRUNCATE, L"0x%02X", (BYTE)lpMsg->wParam); - SetDlgItemTextW(hDlg, IDC_EDIT_DISPVKEY, vkeytext); - SendDlgItemMessageW(hDlg, IDC_EDIT_DISPVKEY, EM_SETSEL, 4, 4); + SetDlgItemTextW(hDlg, IDC_EDIT_PRSRVKEY_TEST_VKEY, vkeytext); + SendDlgItemMessageW(hDlg, IDC_EDIT_PRSRVKEY_TEST_VKEY, EM_SETSEL, 4, 4); SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_MESSAGEHANDLED); return TRUE; default: @@ -275,7 +277,7 @@ INT_PTR CALLBACK DlgProcPreservedKey(HWND hDlg, UINT message, WPARAM wParam, LPA break; case LVN_ITEMCHANGED: - pListView = (NMLISTVIEW*)((LPNMHDR)lParam); + pListView = (LPNMLISTVIEW)((LPNMHDR)lParam); if (pListView->uChanged & LVIF_STATE) { index = ListView_GetNextItem(hWndListView, -1, LVNI_SELECTED); @@ -353,14 +355,28 @@ void SetConfigPreservedKeyONOFF(int onoff, const APPDATAXMLLIST &list) } else { - preservedkey[onoff][0].uVKey = VK_OEM_3/*0xC0*/; + preservedkey[onoff][0].uVKey = VK_OEM_3; // 0xC0 Alt + ` preservedkey[onoff][0].uModifiers = TF_MOD_ALT; - preservedkey[onoff][1].uVKey = VK_KANJI/*0x19*/; + preservedkey[onoff][1].uVKey = VK_KANJI; // 0x19 漢字 / Alt + 半角/全角 / Alt + ` preservedkey[onoff][1].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; - preservedkey[onoff][2].uVKey = VK_OEM_AUTO/*0xF3*/; + preservedkey[onoff][2].uVKey = VK_OEM_AUTO; // 0xF3 半角/全角 / Ctrl + ` preservedkey[onoff][2].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; - preservedkey[onoff][3].uVKey = VK_OEM_ENLW/*0xF4*/; + preservedkey[onoff][3].uVKey = VK_OEM_ENLW; // 0xF4 半角/全角 / Ctrl + ` preservedkey[onoff][3].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; + + switch (onoff) + { + case 0: + preservedkey[onoff][4].uVKey = VK_IME_ON; //0x16 + preservedkey[onoff][4].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; + break; + case 1: + preservedkey[onoff][4].uVKey = VK_IME_OFF; //0x1A + preservedkey[onoff][4].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; + break; + default: + break; + } } } @@ -391,8 +407,8 @@ void LoadConfigPreservedKey() void LoadPreservedKey(HWND hDlg) { - LVITEMW item; - WCHAR num[16]; + LVITEMW item = {}; + WCHAR num[16] = {}; LoadConfigPreservedKey(); @@ -438,7 +454,7 @@ void SavePreservedKey(IXmlWriter *pWriter, HWND hDlg, int no) APPDATAXMLLIST list; APPDATAXMLROW row; APPDATAXMLATTR attr; - WCHAR key[8]; + WCHAR key[8] = {}; list.clear(); diff --git a/imcrvcnf/DlgProcSelKey.cpp b/imcrvcnf/DlgProcSelKey.cpp index 5699d588..5f528488 100644 --- a/imcrvcnf/DlgProcSelKey.cpp +++ b/imcrvcnf/DlgProcSelKey.cpp @@ -9,14 +9,14 @@ static LPCWSTR listSelKey[MAX_SELKEY_C] = INT_PTR CALLBACK DlgProcSelKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hWndListView; - LV_COLUMNW lvc; - LVITEMW item; - NMLISTVIEW *pListView; + LV_COLUMNW lvc = {}; + LVITEMW item = {}; + LPNMLISTVIEW pListView; int index; - WCHAR num[2]; - WCHAR key[4]; + WCHAR num[2 + 1] = {}; + WCHAR key[4 + 1] = {}; std::wstring strxmlval; - WCHAR text[16]; + WCHAR text[16] = {}; switch (message) { @@ -28,19 +28,19 @@ INT_PTR CALLBACK DlgProcSelKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP lvc.pszText = text; lvc.iSubItem = 0; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"数字", _TRUNCATE); ListView_InsertColumn(hWndListView, 0, &lvc); lvc.iSubItem = 1; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"表示", _TRUNCATE); ListView_InsertColumn(hWndListView, 1, &lvc); lvc.iSubItem = 2; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"予備1", _TRUNCATE); ListView_InsertColumn(hWndListView, 2, &lvc); lvc.iSubItem = 3; - lvc.cx = GetScaledSizeX(hDlg, 60); + lvc.cx = GetScaledSize(hDlg, 60); wcsncpy_s(text, L"予備2", _TRUNCATE); ListView_InsertColumn(hWndListView, 3, &lvc); @@ -64,17 +64,23 @@ INT_PTR CALLBACK DlgProcSelKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP if (strxmlval.empty()) strxmlval = listSelKey[index]; wcsncpy_s(key, strxmlval.c_str(), _TRUNCATE); + int sp = IS_SURROGATE_PAIR(key[0], key[1]) ? 1 : 0; + num[0] = key[0]; + num[0 + sp] = key[sp]; + num[1 + sp] = L'\0'; item.pszText = num; item.iItem = index; item.iSubItem = 1; ListView_SetItem(hWndListView, &item); - num[0] = key[1]; + num[0] = key[1 + sp]; + num[1] = L'\0'; item.pszText = num; item.iItem = index; item.iSubItem = 2; ListView_SetItem(hWndListView, &item); - num[0] = key[2]; + num[0] = key[2 + sp]; + num[1] = L'\0'; item.pszText = num; item.iItem = index; item.iSubItem = 3; @@ -85,10 +91,10 @@ INT_PTR CALLBACK DlgProcSelKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP case WM_DPICHANGED_AFTERPARENT: hWndListView = GetDlgItem(hDlg, IDC_LIST_SELKEY); - ListView_SetColumnWidth(hWndListView, 0, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 1, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 2, GetScaledSizeX(hDlg, 60)); - ListView_SetColumnWidth(hWndListView, 3, GetScaledSizeX(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 0, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 1, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 2, GetScaledSize(hDlg, 60)); + ListView_SetColumnWidth(hWndListView, 3, GetScaledSize(hDlg, 60)); return TRUE; @@ -107,12 +113,21 @@ INT_PTR CALLBACK DlgProcSelKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP { break; } + int sp = IS_SURROGATE_PAIR(num[0], num[1]) ? 1 : 0; + num[1 + sp] = L'\0'; + REPLACE_WELLFORMED(num); SetDlgItemTextW(hDlg, IDC_EDIT_SELKEY_DISP, num); ListView_SetItemText(hWndListView, index, 1, num); + GetDlgItemTextW(hDlg, IDC_EDIT_SELKEY_SPARE1, num, _countof(num)); + num[1] = L'\0'; + REPLACE_WELLFORMED(num); SetDlgItemTextW(hDlg, IDC_EDIT_SELKEY_SPARE1, num); ListView_SetItemText(hWndListView, index, 2, num); + GetDlgItemTextW(hDlg, IDC_EDIT_SELKEY_SPARE2, num, _countof(num)); + num[1] = L'\0'; + REPLACE_WELLFORMED(num); SetDlgItemTextW(hDlg, IDC_EDIT_SELKEY_SPARE2, num); ListView_SetItemText(hWndListView, index, 3, num); @@ -125,10 +140,11 @@ INT_PTR CALLBACK DlgProcSelKey(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP break; case WM_NOTIFY: + if (lParam == NULL) break; switch (((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: - pListView = (NMLISTVIEW*)((LPNMHDR)lParam); + pListView = (LPNMLISTVIEW)((LPNMHDR)lParam); if (pListView->uChanged & LVIF_STATE) { hWndListView = ((LPNMHDR)lParam)->hwndFrom; @@ -167,19 +183,22 @@ void SaveSelKey(IXmlWriter *pWriter, HWND hDlg) { HWND hWndListView; int index; - WCHAR num[2]; - WCHAR key[4]; + WCHAR num[2 + 1] = {}; + WCHAR key[4 + 1] = {}; hWndListView = GetDlgItem(hDlg, IDC_LIST_SELKEY); for (index = 0; index < MAX_SELKEY_C; index++) { ListView_GetItemText(hWndListView, index, 1, num, _countof(num)); + int sp = IS_SURROGATE_PAIR(num[0], num[1]) ? 1 : 0; key[0] = num[0]; + key[0 + sp] = num[0 + sp]; ListView_GetItemText(hWndListView, index, 2, num, _countof(num)); - key[1] = num[0]; + key[1 + sp] = num[0]; ListView_GetItemText(hWndListView, index, 3, num, _countof(num)); - key[2] = num[0]; - key[3] = L'\0'; + key[2 + sp] = num[0]; + key[3 + sp] = L'\0'; + _snwprintf_s(num, _TRUNCATE, L"%d", index + 1); WriterKey(pWriter, num, key); } diff --git a/imcrvcnf/cpp.hint b/imcrvcnf/cpp.hint new file mode 100644 index 00000000..8660b6f3 --- /dev/null +++ b/imcrvcnf/cpp.hint @@ -0,0 +1,5 @@ +// common.h +#define FORWARD_ITERATION_I(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ++(iterator)) +#define FORWARD_ITERATION(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ) +#define REVERSE_ITERATION_I(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ++(reverse_iterator)) +#define REVERSE_ITERATION(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ) diff --git a/imcrvcnf/imcrvcnf.cpp b/imcrvcnf/imcrvcnf.cpp index a6b158bc..d1c24527 100644 --- a/imcrvcnf/imcrvcnf.cpp +++ b/imcrvcnf/imcrvcnf.cpp @@ -7,9 +7,9 @@ HINSTANCE hInst; HANDLE hMutex; -int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { - INITCOMMONCONTROLSEX icex; + INITCOMMONCONTROLSEX icex = {}; _wsetlocale(LC_ALL, L"ja-JP"); @@ -28,6 +28,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd return 0; } + HRESULT hrI = CoInitialize(nullptr); + icex.dwSize = sizeof(icex); icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES | ICC_PROGRESS_CLASS; InitCommonControlsEx(&icex); @@ -68,6 +70,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd LocalFree(pArgs); } + CoUninitialize(); + if (hMutex != nullptr) { ReleaseMutex(hMutex); @@ -83,7 +87,8 @@ void CreateProperty() int id; DLGPROC DlgProc; } DlgPages[] = { - {IDD_DIALOG_DICTIONARY, DlgProcDictionary}, + {IDD_DIALOG_DICTIONARY1, DlgProcDictionary1}, + {IDD_DIALOG_DICTIONARY2, DlgProcDictionary2}, {IDD_DIALOG_BEHAVIOR1, DlgProcBehavior1}, {IDD_DIALOG_BEHAVIOR2, DlgProcBehavior2}, {IDD_DIALOG_DISPLAY1, DlgProcDisplay1}, diff --git a/imcrvcnf/imcrvcnf.h b/imcrvcnf/imcrvcnf.h index b7f7f734..5ad82db3 100644 --- a/imcrvcnf/imcrvcnf.h +++ b/imcrvcnf/imcrvcnf.h @@ -9,20 +9,24 @@ int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam); void CreateConfigPath(); void CreateIpcName(); BOOL SetFileDacl(LPWSTR path); -int GetScaledSizeX(HWND hwnd, int size); +int GetScaledSize(HWND hwnd, int size); int GetFontHeight(HWND hwnd, int size); void DrawSelectColor(HWND hDlg, int id, COLORREF col); void LoadCheckButton(HWND hDlg, int nIDDlgItem, LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault = L""); void SaveCheckButton(IXmlWriter *pWriter, HWND hDlg, int nIDDlgItem, LPCWSTR lpKeyName); BOOL SaveConfigXml(HWND hDlg); +void ReplaceWellFormed(LPWSTR str, SIZE_T size); // DlgDicMake void MakeSKKDic(HWND hDlg); // DlgDicAddUrl INT_PTR CALLBACK DlgProcSKKDicAddUrl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); -// DlgProcDictionary -INT_PTR CALLBACK DlgProcDictionary(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); -void SaveDictionary(IXmlWriter *pWriter, HWND hDlg); -void SaveServer(IXmlWriter *pWriter, HWND hDlg); +// DlgProcDictionary1 +INT_PTR CALLBACK DlgProcDictionary1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); +void SaveDictionary1(IXmlWriter *pWriter, HWND hDlg); +void SaveDictionary1Server(IXmlWriter *pWriter, HWND hDlg); +// DlgProcDictionary2 +INT_PTR CALLBACK DlgProcDictionary2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); +void SaveDictionary2(IXmlWriter *pWriter, HWND hDlg); // DlgProcBehavior1 INT_PTR CALLBACK DlgProcBehavior1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); void SaveFont(IXmlWriter *pWriter, HWND hDlg); @@ -65,19 +69,13 @@ void SaveJLatin(IXmlWriter *pWriter, HWND hDlg); extern LPCWSTR TextServiceDesc; extern HINSTANCE hInst; -extern WCHAR cnfmutexname[MAX_KRNLOBJNAME]; //ミューテックス -extern WCHAR cnfcanceldiceventname[MAX_KRNLOBJNAME]; //辞書取込キャンセルイベント -extern WCHAR pathconfigxml[MAX_PATH]; //設定 -extern WCHAR pathskkdic[MAX_PATH]; //取込SKK辞書 -extern WCHAR urlskkdic[INTERNET_MAX_URL_LENGTH]; +extern WCHAR cnfmutexname[MAX_PATH]; //ミューテックス +extern WCHAR cnfcanceldiceventname[MAX_PATH]; //辞書取込キャンセルイベント +extern WCHAR mgrpipename[MAX_PIPENAME]; //名前付きパイプ +extern WCHAR pathconfigxml[MAX_PATH]; //設定 +extern WCHAR pathskkdic[MAX_PATH]; //取込SKK辞書 +extern WCHAR urlskkdic[INTERNET_MAX_URL_LENGTH]; //URL #define PROPSHEET_IDTOHWND(hDlg, id) PropSheet_IndexToHwnd(hDlg, PropSheet_IdToIndex(hDlg, id)) -// Per-Monitor DPI Awareness V2 -#ifndef NTDDI_WIN10_RS2 -#if (WINVER < 0x0605) -#define WM_DPICHANGED_BEFOREPARENT 0x02E2 -#define WM_DPICHANGED_AFTERPARENT 0x02E3 -#define WM_GETDPISCALEDSIZE 0x02E4 -#endif //(WINVER < 0x0605) -#endif //NTDDI_WIN10_RS2 +#define REPLACE_WELLFORMED(str) ReplaceWellFormed(str, _countof(str)) diff --git a/imcrvcnf/imcrvcnf.rc b/imcrvcnf/imcrvcnf.rc index 3e7a225f..fd5bce65 100644 --- a/imcrvcnf/imcrvcnf.rc +++ b/imcrvcnf/imcrvcnf.rc @@ -1,9 +1,14 @@  -#include -#include #include "version.h" #include "resource.h" +#define APSTUDIO_READONLY_SYMBOLS +#define APSTUDIO_HIDDEN_SYMBOLS +#include +#include +#undef APSTUDIO_HIDDEN_SYMBOLS +#undef APSTUDIO_READONLY_SYMBOLS + VS_VERSION_INFO VERSIONINFO FILEVERSION RC_VERSION_D PRODUCTVERSION RC_VERSION_D @@ -39,29 +44,29 @@ FILESUBTYPE VFT2_UNKNOWN IDI_IMCRVCNF ICON "imcrvcnf.ico" -IDD_DIALOG_DICTIONARY DIALOG 0, 0, 268, 244 +IDD_DIALOG_DICTIONARY1 DIALOG 0, 0, 268, 244 STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD -CAPTION "辞書" +CAPTION "辞書1" FONT 10, "MS Gothic" { GROUPBOX "SKK辞書", IDC_STATIC, 4, 4, 258, 236 - CONTROL "", IDC_LIST_SKK_DIC, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT | LVS_EDITLABELS, 14, 20, 238, 118 - PUSHBUTTON "↑", IDC_BUTTON_SKK_DIC_UP, 14, 142, 16, 14, BS_CENTER - PUSHBUTTON "↓", IDC_BUTTON_SKK_DIC_DOWN, 34, 142, 16, 14, BS_CENTER + CONTROL "", IDC_LIST_SKK_DIC, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT | LVS_EDITLABELS, 12, 20, 242, 118 + PUSHBUTTON "↑", IDC_BUTTON_SKK_DIC_UP, 12, 142, 16, 14, BS_CENTER + PUSHBUTTON "↓", IDC_BUTTON_SKK_DIC_DOWN, 32, 142, 16, 14, BS_CENTER PUSHBUTTON "ファイル追加", IDC_BUTTON_SKK_DIC_ADD_FILE, 62, 142, 40, 14, BS_CENTER PUSHBUTTON "URL追加", IDC_BUTTON_SKK_DIC_ADD_URL, 104, 142, 40, 14, BS_CENTER PUSHBUTTON "削除", IDC_BUTTON_SKK_DIC_DEL, 154, 142, 40, 14, BS_CENTER - PUSHBUTTON "取込", IDC_BUTTON_SKK_DIC_MAKE, 212, 142, 40, 14, BS_CENTER - GROUPBOX "SKK辞書サーバー", IDC_STATIC, 14, 166, 238, 64 - AUTOCHECKBOX "SKK辞書サーバーを使用する", IDC_CHECKBOX_SKKSRV, 24, 180, 110, 10 - AUTORADIOBUTTON "EUC-JIS-2004", IDC_RADIO_EUC, 146, 180, 60, 10, WS_GROUP + PUSHBUTTON "取込", IDC_BUTTON_SKK_DIC_MAKE, 214, 142, 40, 14, BS_CENTER + GROUPBOX "SKK辞書サーバー", IDC_STATIC, 12, 166, 242, 64 + AUTOCHECKBOX "使用する", IDC_CHECKBOX_SKKSRV, 24, 180, 48, 10 + AUTORADIOBUTTON "EUC-JIS-2004 / EUC-JP", IDC_RADIO_EUC, 108, 180, 96, 10, WS_GROUP AUTORADIOBUTTON "UTF-8", IDC_RADIO_UTF8, 214, 180, 32, 10 LTEXT "ホスト", IDC_STATIC, 24, 195, 24, 8, SS_LEFT | WS_GROUP EDITTEXT IDC_EDIT_SKKSRV_HOST, 52, 193, 188, 12, ES_AUTOHSCROLL LTEXT "ポート", IDC_STATIC, 24, 210, 24, 8, SS_LEFT - EDITTEXT IDC_EDIT_SKKSRV_PORT, 52, 208, 32, 12, ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_SKKSRV_PORT, 52, 208, 32, 12, ES_AUTOHSCROLL | ES_NUMBER LTEXT "タイムアウト", IDC_STATIC, 115, 210, 50, 8, SS_LEFT - EDITTEXT IDC_EDIT_SKKSRV_TIMEOUT, 170, 208, 32, 12, ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_SKKSRV_TIMEOUT, 170, 208, 32, 12, ES_AUTOHSCROLL | ES_NUMBER LTEXT "msec", IDC_STATIC, 205, 210, 18, 8, SS_LEFT } @@ -85,6 +90,52 @@ FONT 10, "MS Gothic" PUSHBUTTON "中断", IDC_BUTTON_ABORT_DIC_MAKE, 90, 60, 40, 14, 0, WS_EX_LEFT } +IDD_DIALOG_DICTIONARY2 DIALOG 0, 0, 268, 244 +STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD +CAPTION "辞書2" +FONT 10, "MS Gothic" +{ + GROUPBOX "ユーザー辞書", IDC_STATIC, 4, 4, 258, 236 + LTEXT "辞書管理プロセス", IDC_STATIC, 24, 20, 80, 8, SS_LEFT + CONTROL "", IDC_MGR_STATUS_TEXT, WC_STATIC, SS_CENTER, 122, 20, 44, 8 + LTEXT "", IDC_STATIC, 118, 18, 52, 12, SS_BLACKFRAME + PUSHBUTTON "終了", IDC_BUTTON_MGR_KILL, 176, 17, 32, 14, BS_CENTER + PUSHBUTTON "実行", IDC_BUTTON_MGR_RUN, 212, 17, 32, 14, BS_CENTER + LTEXT "ユーザーディレクトリ", IDC_STATIC, 24, 35, 120, 8, SS_LEFT + PUSHBUTTON "開く", IDC_BUTTON_OPEN_USERDIR, 212, 32, 32, 14, BS_CENTER + LTEXT "システムディレクトリ", IDC_STATIC, 24, 50, 120, 8, SS_LEFT + PUSHBUTTON "開く", IDC_BUTTON_OPEN_SYSTEMDIR, 212, 47, 32, 14, BS_CENTER + + GROUPBOX "ユーザー辞書バックアップ", IDC_STATIC, 12, 65, 242, 44 + LTEXT "ディレクトリ", IDC_STATIC, 24, 80, 52, 8, SS_LEFT + EDITTEXT IDC_EDIT_USERDICBACKUPDIR, 78, 78, 128, 12, ES_AUTOHSCROLL + PUSHBUTTON "開く", IDC_BUTTON_OPEN_BACKUPDIR, 212, 77, 32, 14, BS_CENTER + LTEXT "世代数", IDC_STATIC, 24, 95, 52, 8, SS_LEFT + EDITTEXT IDC_EDIT_USERDICBACKUPGEN, 78, 93, 20, 12, ES_AUTOHSCROLL | ES_NUMBER + LTEXT "手動バックアップ", IDC_STATIC, 140, 95, 72, 8, SS_LEFT + PUSHBUTTON "実行", IDC_BUTTON_RUN_BACKUP, 212, 92, 32, 14, BS_CENTER + + GROUPBOX "プライベートモード", IDC_STATIC, 12, 110, 242, 59 + LTEXT "ON", IDC_STATIC, 24, 125, 16, 8, SS_LEFT + LTEXT "仮想キー", IDC_STATIC, 40, 125, 32, 8, SS_LEFT + EDITTEXT IDC_EDIT_PRIVATEMODE_ON_VKEY, 72, 123, 28, 12, ES_CENTER | ES_AUTOHSCROLL + LTEXT "修飾キー", IDC_STATIC, 108, 125, 32, 8, SS_LEFT + AUTOCHECKBOX "ALT", IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_ALT, 140, 125, 32, 10, WS_GROUP + AUTOCHECKBOX "CTRL", IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_CTRL, 175, 125, 32, 10 + AUTOCHECKBOX "SHIFT", IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_SHIFT, 210, 125, 32, 10 + LTEXT "OFF", IDC_STATIC, 24, 140, 16, 8, SS_LEFT + LTEXT "仮想キー", IDC_STATIC, 40, 140, 32, 8, SS_LEFT + EDITTEXT IDC_EDIT_PRIVATEMODE_OFF_VKEY, 72, 138, 28, 12, ES_CENTER | ES_AUTOHSCROLL + LTEXT "修飾キー", IDC_STATIC, 108, 140, 32, 8, SS_LEFT + AUTOCHECKBOX "ALT", IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_ALT, 140, 140, 32, 10, WS_GROUP + AUTOCHECKBOX "CTRL", IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_CTRL, 175, 140, 32, 10 + AUTOCHECKBOX "SHIFT", IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_SHIFT, 210, 140, 32, 10 + AUTOCHECKBOX "自動切替", IDC_CHECKBOX_PRIVATEMODE_AUTO, 24, 155, 48, 10, WS_GROUP + + LTEXT "仮想キーテスト", IDC_STATIC, 186, 5, 42, 8, SS_LEFT + EDITTEXT IDC_EDIT_DICTIONARY2_TEST_VKEY, 226, 3, 28, 12, ES_CENTER | ES_AUTOHSCROLL | ES_READONLY +} + IDD_DIALOG_BEHAVIOR1 DIALOG 0, 0, 268, 244 STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD CAPTION "動作1" @@ -132,7 +183,7 @@ FONT 10, "MS Gothic" EDITTEXT IDC_EDIT_FONTPOINT, 210, 18, 16, 12, ES_AUTOHSCROLL | ES_READONLY PUSHBUTTON "…", IDC_BUTTON_CHOOSEFONT, 230, 17, 16, 14, BS_CENTER LTEXT "候補一覧の最大幅", IDC_STATIC, 24, 35, 80, 8, SS_LEFT - EDITTEXT IDC_EDIT_MAXWIDTH, 128, 33, 32, 12, ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_MAXWIDTH, 128, 33, 32, 12, ES_AUTOHSCROLL | ES_NUMBER LTEXT "候補一覧の色", IDC_STATIC, 24, 50, 50, 8, SS_LEFT LTEXT "背景", IDC_STATIC, 90, 50, 18, 8, SS_LEFT CONTROL "", IDC_COL_BG, WC_STATIC, SS_NOTIFY | SS_BLACKFRAME, 110, 48, 12, 12 @@ -156,15 +207,17 @@ FONT 10, "MS Gothic" AUTOCHECKBOX "彩色", IDC_CHECKBOX_COLOR_FONT, 222, 80, 25, 10, WS_GROUP LTEXT "候補一覧表示に要する変換回数(0は表示無し)", IDC_STATIC, 24, 95, 180, 8, SS_LEFT COMBOBOX IDC_COMBO_UNTILCANDLIST, 218, 93, 28, 12, CBS_DROPDOWNLIST | WS_TABSTOP - AUTOCHECKBOX "候補一覧が表示無しのとき候補数を表示する", IDC_CHECKBOX_DISPCANDNO, 24, 110, 220, 10 - AUTOCHECKBOX "候補一覧を縦に表示する", IDC_CHECKBOX_VERTICALCAND, 24, 125, 220, 10 - AUTOCHECKBOX "注釈を表示する", IDC_CHECKBOX_ANNOTATION, 24, 140, 100, 10 - AUTORADIOBUTTON "全て", IDC_RADIO_ANNOTATALL, 128, 140, 32, 10, WS_GROUP - AUTORADIOBUTTON "候補一覧", IDC_RADIO_ANNOTATLST, 168, 140, 48, 10 - AUTOCHECKBOX "▽▼*マークを表示する", IDC_CHECKBOX_SHOWMODEMARK, 24, 155, 220, 10, WS_GROUP - AUTOCHECKBOX "ローマ字を表示する", IDC_CHECKBOX_SHOWROMAN, 24, 170, 100, 10 - AUTORADIOBUTTON "ASCII", IDC_RADIO_SHOWROMANASCII, 128, 170, 32, 10, WS_GROUP - AUTORADIOBUTTON "全英", IDC_RADIO_SHOWROMANJLATIN, 168, 170, 32, 10 + LTEXT "候補一覧表示のページ当たり候補数", IDC_STATIC, 24, 110, 180, 8, SS_LEFT + COMBOBOX IDC_COMBO_PAGECANDNUM, 218, 108, 28, 12, CBS_DROPDOWNLIST | WS_TABSTOP + AUTOCHECKBOX "候補一覧が表示無しのとき候補数を表示する", IDC_CHECKBOX_DISPCANDNO, 24, 125, 220, 10 + AUTOCHECKBOX "候補一覧を縦に表示する", IDC_CHECKBOX_VERTICALCAND, 24, 140, 220, 10 + AUTOCHECKBOX "注釈を表示する", IDC_CHECKBOX_ANNOTATION, 24, 155, 100, 10 + AUTORADIOBUTTON "全て", IDC_RADIO_ANNOTATALL, 128, 155, 32, 10, WS_GROUP + AUTORADIOBUTTON "候補一覧", IDC_RADIO_ANNOTATLST, 168, 155, 48, 10 + AUTOCHECKBOX "▽▼*マークを表示する", IDC_CHECKBOX_SHOWMODEMARK, 24, 170, 220, 10, WS_GROUP + AUTOCHECKBOX "ローマ字を表示する", IDC_CHECKBOX_SHOWROMAN, 24, 185, 100, 10 + AUTORADIOBUTTON "ASCII", IDC_RADIO_SHOWROMANASCII, 128, 185, 32, 10, WS_GROUP + AUTORADIOBUTTON "全英", IDC_RADIO_SHOWROMANJLATIN, 168, 185, 32, 10 LTEXT "", IDC_STATIC, 0, 0, 0, 0, SS_LEFT | WS_GROUP } @@ -175,7 +228,7 @@ FONT 10, "MS Gothic" { GROUPBOX "表示2", IDC_STATIC, 4, 4, 258, 236 AUTOCHECKBOX "入力モードを表示する", IDC_CHECKBOX_SHOWMODEINL, 24, 20, 100, 10 - EDITTEXT IDC_EDIT_SHOWMODEINLTM, 175, 18, 32, 12, ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_SHOWMODEINLTM, 175, 18, 32, 12, ES_AUTOHSCROLL | ES_NUMBER LTEXT "msec", IDC_STATIC, 210, 20, 18, 8, SS_LEFT LTEXT "入力モードの色", IDC_STATIC, 24, 35, 60, 8, SS_LEFT LTEXT "文字", IDC_STATIC, 90, 35, 18, 8, SS_LEFT @@ -198,7 +251,7 @@ FONT 10, "MS Gothic" IDD_DIALOG_DISPLAYATTR1 DIALOG 0, 0, 268, 244 STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD -CAPTION "▽表示属性" +CAPTION "▽表示" FONT 10, "MS Gothic" { GROUPBOX "▽表示属性", IDC_STATIC, 4, 4, 258, 236 @@ -273,7 +326,7 @@ FONT 10, "MS Gothic" IDD_DIALOG_DISPLAYATTR2 DIALOG 0, 0, 268, 244 STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD -CAPTION "▼表示属性" +CAPTION "▼表示" FONT 10, "MS Gothic" { GROUPBOX "▼表示属性", IDC_STATIC, 4, 4, 258, 236 @@ -362,11 +415,11 @@ FONT 10, "MS Gothic" IDD_DIALOG_SELKEY DIALOG 0, 0, 268, 244 STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD -CAPTION "選択キー" +CAPTION "選択" FONT 10, "MS Gothic" { GROUPBOX "候補一覧選択キー", IDC_STATIC, 4, 4, 258, 236 - CONTROL "", IDC_LIST_SELKEY, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 14, 20, 178, 210 + CONTROL "", IDC_LIST_SELKEY, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 12, 20, 180, 210 LTEXT "表示", IDC_STATIC, 198, 22, 24, 8, SS_LEFT EDITTEXT IDC_EDIT_SELKEY_DISP, 226, 20, 28, 12, ES_CENTER | ES_AUTOHSCROLL LTEXT "予備1", IDC_STATIC, 198, 42, 24, 8, SS_LEFT @@ -382,8 +435,8 @@ CAPTION "キー0" FONT 10, "MS Gothic" { GROUPBOX "キー設定(ON/OFF)", IDC_STATIC, 4, 4, 258, 236 - CONTROL "", IDC_LIST_PRSRVKEY_ON, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 14, 20, 178, 104 - CONTROL "", IDC_LIST_PRSRVKEY_OFF, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 14, 128, 178, 104 + CONTROL "", IDC_LIST_PRSRVKEY_ON, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 12, 20, 180, 104 + CONTROL "", IDC_LIST_PRSRVKEY_OFF, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 12, 128, 180, 104 LTEXT "仮想キー", IDC_STATIC, 198, 22, 24, 8, SS_LEFT EDITTEXT IDC_EDIT_PRSRVKEY_VKEY, 226, 20, 28, 12, ES_CENTER | ES_AUTOHSCROLL LTEXT "修飾キー", IDC_STATIC, 198, 42, 24, 8, SS_LEFT @@ -397,8 +450,9 @@ FONT 10, "MS Gothic" PUSHBUTTON "↓", IDC_BUTTON_PRSRVKEY_DOWN, 234, 136, 16, 14, BS_CENTER PUSHBUTTON "更新", IDC_BUTTON_PRSRVKEY_W, 216, 156, 32, 14, BS_CENTER PUSHBUTTON "削除", IDC_BUTTON_PRSRVKEY_D, 216, 176, 32, 14, BS_CENTER - GROUPBOX "仮想キー表示", IDC_STATIC, 202, 200, 54, 32 - EDITTEXT IDC_EDIT_DISPVKEY, 216, 212, 28, 12, ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + + LTEXT "仮想キーテスト", IDC_STATIC, 186, 5, 42, 8, SS_LEFT + EDITTEXT IDC_EDIT_PRSRVKEY_TEST_VKEY, 226, 3, 28, 12, ES_CENTER | ES_AUTOHSCROLL | ES_READONLY } IDD_DIALOG_KEYMAP1 DIALOG 0, 0, 268, 244 @@ -460,6 +514,8 @@ FONT 10, "MS Gothic" EDITTEXT IDC_EDIT_DOWN, 192, 168, 52, 12, ES_AUTOHSCROLL LTEXT "貼付", IDC_STATIC, 144, 185, 42, 8, SS_LEFT EDITTEXT IDC_EDIT_PASTE, 192, 183, 52, 12, ES_AUTOHSCROLL + LTEXT "再変換", IDC_STATIC, 144, 200, 42, 8, SS_LEFT + EDITTEXT IDC_EDIT_RECONVERT, 192, 198, 52, 12, ES_AUTOHSCROLL } IDD_DIALOG_KEYMAP2 DIALOG 0, 0, 268, 244 @@ -499,8 +555,8 @@ FONT 10, "MS Gothic" LTEXT "変換位置", IDC_STATIC, 144, 20, 42, 8, SS_LEFT EDITTEXT IDC_EDIT_CONV_POINT, 192, 18, 52, 12, ES_AUTOHSCROLL - LTEXT "直接入力", IDC_STATIC, 144, 35, 42, 8, SS_LEFT | WS_DISABLED - EDITTEXT IDC_EDIT_DIRECT, 192, 33, 52, 12, ES_AUTOHSCROLL | WS_DISABLED + LTEXT "直接入力", IDC_STATIC, 144, 35, 42, 8, SS_LEFT + EDITTEXT IDC_EDIT_DIRECT, 192, 33, 52, 12, ES_AUTOHSCROLL LTEXT "確定", IDC_STATIC, 144, 50, 42, 8, SS_LEFT EDITTEXT IDC_EDIT_ENTER, 192, 48, 52, 12, ES_AUTOHSCROLL LTEXT "取消", IDC_STATIC, 144, 65, 42, 8, SS_LEFT @@ -521,15 +577,20 @@ FONT 10, "MS Gothic" EDITTEXT IDC_EDIT_DOWN, 192, 168, 52, 12, ES_AUTOHSCROLL LTEXT "貼付", IDC_STATIC, 144, 185, 42, 8, SS_LEFT EDITTEXT IDC_EDIT_PASTE, 192, 183, 52, 12, ES_AUTOHSCROLL + LTEXT "再変換", IDC_STATIC, 144, 200, 42, 8, SS_LEFT + EDITTEXT IDC_EDIT_RECONVERT, 192, 198, 52, 12, ES_AUTOHSCROLL + + LTEXT "仮想キーテスト", IDC_STATIC, 186, 5, 42, 8, SS_LEFT + EDITTEXT IDC_EDIT_KEYMAP_TEST_VKEY, 226, 3, 28, 12, ES_CENTER | ES_AUTOHSCROLL | ES_READONLY } IDD_DIALOG_CONVPOINT DIALOG 0, 0, 268, 244 STYLE DS_CONTROL | DS_CENTER | DS_SETFONT | WS_VISIBLE | WS_CHILD -CAPTION "変換位置" +CAPTION "位置" FONT 10, "MS Gothic" { GROUPBOX "変換位置指定", IDC_STATIC, 4, 4, 258, 236 - CONTROL "", IDC_LIST_CONVPOINT, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 14, 20, 178, 210 + CONTROL "", IDC_LIST_CONVPOINT, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 12, 20, 180, 210 LTEXT "開始", IDC_STATIC, 198, 22, 24, 8, SS_LEFT EDITTEXT IDC_EDIT_CONVPOINT_ST, 226, 20, 28, 12, ES_CENTER | ES_AUTOHSCROLL LTEXT "代替", IDC_STATIC, 198, 42, 24, 8, SS_LEFT @@ -548,7 +609,7 @@ CAPTION "仮名" FONT 10, "MS Gothic" { GROUPBOX "ローマ字・仮名変換表", IDC_STATIC, 4, 4, 258, 236 - CONTROL "", IDC_LIST_KANATBL, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 14, 20, 178, 210 + CONTROL "", IDC_LIST_KANATBL, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 12, 20, 180, 210 LTEXT "ローマ字", IDC_STATIC, 198, 22, 24, 8, SS_LEFT EDITTEXT IDC_EDIT_KANATBL_R, 226, 20, 28, 12, ES_CENTER | ES_AUTOHSCROLL LTEXT "かな", IDC_STATIC, 198, 42, 24, 8, SS_LEFT @@ -575,7 +636,7 @@ CAPTION "全英" FONT 10, "MS Gothic" { GROUPBOX "ASCII・全英変換表", IDC_STATIC, 4, 4, 258, 236 - CONTROL "", IDC_LIST_JLATTBL, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 14, 20, 178, 210 + CONTROL "", IDC_LIST_JLATTBL, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 12, 20, 180, 210 LTEXT "ASCII", IDC_STATIC, 198, 22, 24, 8, SS_LEFT EDITTEXT IDC_EDIT_JLATTBL_A, 226, 20, 28, 12, ES_CENTER | ES_AUTOHSCROLL LTEXT "全英", IDC_STATIC, 198, 42, 24, 8, SS_LEFT diff --git a/imcrvcnf/imcrvcnf.vcxproj b/imcrvcnf/imcrvcnf.vcxproj index 7a70e3d0..676fb241 100644 --- a/imcrvcnf/imcrvcnf.vcxproj +++ b/imcrvcnf/imcrvcnf.vcxproj @@ -1,14 +1,6 @@  - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + {56319425-6482-41CF-8B63-BC33D6EEBB52} @@ -44,122 +36,93 @@ Application true - v142 + v143 Unicode Application true - v142 - Unicode - - - Application - true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 - true - Unicode - - - Application - false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode - + - - - - + - - - true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - - true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ @@ -168,17 +131,17 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) true true + pch.h Windows true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;%(AdditionalDependencies) + zlib1.lib;common.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -196,45 +159,17 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) true true + pch.h Windows true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;%(AdditionalDependencies) + zlib1.lib;common.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) - - - $(SolutionDir)common;%(AdditionalIncludeDirectories) - 0x0411 - /c 65001 - - - imcrvcnf.manifest %(AdditionalManifestFiles) - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - stdafx.h - $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) - true - true - - - Windows - true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;gdi32.lib;winspool.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -252,17 +187,17 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) true true + pch.h Windows true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;%(AdditionalDependencies) + zlib1.lib;common.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -282,21 +217,22 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) true true Guard + pch.h Windows true true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;%(AdditionalDependencies) + zlib1.lib;common.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) + true $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -316,55 +252,22 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) - true - true - Guard - - - Windows - true - true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - No - UseLinkTimeCodeGeneration - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) - - - $(SolutionDir)common;%(AdditionalIncludeDirectories) - 0x0411 - /c 65001 - - - imcrvcnf.manifest %(AdditionalManifestFiles) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) true true Guard + pch.h Windows true true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;gdi32.lib;winspool.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + zlib1.lib;common.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) + true $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -384,21 +287,21 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)libz;%(AdditionalIncludeDirectories) true true Guard + pch.h Windows true true - common.lib;zlib1.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;delayimp.lib;%(AdditionalDependencies) + zlib1.lib;common.lib;comctl32.lib;comdlg32.lib;wininet.lib;shcore.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration - api-ms-win-shcore-scaling-l1-1-1.dll;%(DelayLoadDLLs) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -413,7 +316,7 @@ - + @@ -423,8 +326,9 @@ + + - @@ -433,14 +337,12 @@ - + Create Create - Create Create Create Create - Create Create @@ -455,6 +357,9 @@ Designer + + + diff --git a/imcrvcnf/imcrvcnf.vcxproj.filters b/imcrvcnf/imcrvcnf.vcxproj.filters index cccd6873..c5a406b3 100644 --- a/imcrvcnf/imcrvcnf.vcxproj.filters +++ b/imcrvcnf/imcrvcnf.vcxproj.filters @@ -15,7 +15,7 @@ - + Header Files @@ -29,7 +29,7 @@ - + Source Files @@ -56,7 +56,16 @@ Source Files - + + Source Files + + + Source Files + + + Source Files + + Source Files @@ -77,12 +86,6 @@ Source Files - - Source Files - - - Source Files - @@ -99,4 +102,7 @@ Resource Files + + + \ No newline at end of file diff --git a/imcrvcnf/pch.cpp b/imcrvcnf/pch.cpp new file mode 100644 index 00000000..af0744ae --- /dev/null +++ b/imcrvcnf/pch.cpp @@ -0,0 +1 @@ + diff --git a/imcrvcnf/stdafx.h b/imcrvcnf/pch.h similarity index 89% rename from imcrvcnf/stdafx.h rename to imcrvcnf/pch.h index 47a59690..9708ec02 100644 --- a/imcrvcnf/stdafx.h +++ b/imcrvcnf/pch.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/imcrvcnf/resource.h b/imcrvcnf/resource.h index 8fcc8d15..131b7d9e 100644 --- a/imcrvcnf/resource.h +++ b/imcrvcnf/resource.h @@ -4,21 +4,28 @@ #define IDC_STATIC (-1) #endif -#define IDD_DIALOG_DICTIONARY 110 -#define IDD_DIALOG_SKK_DIC_ADD_URL 111 -#define IDD_DIALOG_BEHAVIOR1 112 -#define IDD_DIALOG_BEHAVIOR2 113 -#define IDD_DIALOG_DISPLAY1 120 -#define IDD_DIALOG_DISPLAY2 121 -#define IDD_DIALOG_DISPLAYATTR1 122 -#define IDD_DIALOG_DISPLAYATTR2 123 -#define IDD_DIALOG_SELKEY 131 -#define IDD_DIALOG_PRSRVKEY 132 -#define IDD_DIALOG_KEYMAP1 133 -#define IDD_DIALOG_KEYMAP2 134 -#define IDD_DIALOG_CONVPOINT 141 -#define IDD_DIALOG_KANATBL 142 -#define IDD_DIALOG_JLATTBL 143 +#define IDD_DIALOG_DICTIONARY1 110 +#define IDD_DIALOG_SKK_DIC_ADD_URL 111 +#define IDD_DIALOG_DICTIONARY2 112 + +#define IDD_DIALOG_BEHAVIOR1 120 +#define IDD_DIALOG_BEHAVIOR2 121 + +#define IDD_DIALOG_DISPLAY1 130 +#define IDD_DIALOG_DISPLAY2 131 +#define IDD_DIALOG_DISPLAYATTR1 132 +#define IDD_DIALOG_DISPLAYATTR2 133 + +#define IDD_DIALOG_SELKEY 140 +#define IDD_DIALOG_PRSRVKEY 141 +#define IDD_DIALOG_KEYMAP1 142 +#define IDD_DIALOG_KEYMAP2 143 + +#define IDD_DIALOG_CONVPOINT 150 +#define IDD_DIALOG_KANATBL 151 +#define IDD_DIALOG_JLATTBL 152 + + #define IDC_LIST_SKK_DIC 1001 #define IDC_BUTTON_SKK_DIC_ADD_FILE 1002 @@ -37,193 +44,216 @@ #define IDC_EDIT_SKKSRV_PORT 1055 #define IDC_EDIT_SKKSRV_TIMEOUT 1056 -#define IDC_EDIT_SKK_DIC_URL 1101 - -#define IDC_CHECKBOX_DEFAULTMODE 1201 -#define IDC_RADIO_DEFMODEHIRA 1202 -#define IDC_RADIO_DEFMODEASCII 1203 -#define IDC_CHECKBOX_BEGINCVOKURI 1204 -#define IDC_CHECKBOX_PRECEDEOKURI 1205 -#define IDC_CHECKBOX_SHIFTNNOKURI 1206 -#define IDC_CHECKBOX_SRCHALLOKURI 1207 -#define IDC_CHECKBOX_DELCVPOSCNCL 1208 -#define IDC_CHECKBOX_DELOKURICNCL 1209 -#define IDC_CHECKBOX_BACKINCENTER 1210 -#define IDC_CHECKBOX_ADDCANDKTKN 1211 -#define IDC_CHECKBOX_ENTOGGLEKANA 1212 -#define IDC_CHECKBOX_SETBYDIRECT 1213 - -#define IDC_COMBO_COMPMULTINUM 1301 -#define IDC_CHECKBOX_STACOMPMULTI 1302 -#define IDC_CHECKBOX_DYNAMINCOMP 1303 -#define IDC_CHECKBOX_DYNCOMPMULTI 1304 -#define IDC_CHECKBOX_COMPUSERDIC 1305 -#define IDC_CHECKBOX_COMPINCBACK 1306 - -#define IDC_EDIT_FONTNAME 2001 -#define IDC_EDIT_FONTPOINT 2002 -#define IDC_BUTTON_CHOOSEFONT 2003 -#define IDC_EDIT_MAXWIDTH 2004 -#define IDC_COL_BG 2011 -#define IDC_COL_FR 2012 -#define IDC_COL_SE 2013 -#define IDC_COL_CO 2014 -#define IDC_COL_CA 2015 -#define IDC_COL_SC 2016 -#define IDC_COL_AN 2017 -#define IDC_COL_NO 2018 -#define IDC_RADIO_API_GDI 2021 -#define IDC_RADIO_API_D2D 2022 -#define IDC_CHECKBOX_COLOR_FONT 2023 -#define IDC_COMBO_UNTILCANDLIST 2031 -#define IDC_CHECKBOX_DISPCANDNO 2032 -#define IDC_CHECKBOX_VERTICALCAND 2033 -#define IDC_CHECKBOX_ANNOTATION 2034 -#define IDC_RADIO_ANNOTATALL 2035 -#define IDC_RADIO_ANNOTATLST 2036 -#define IDC_CHECKBOX_SHOWMODEMARK 2037 -#define IDC_CHECKBOX_SHOWROMAN 2038 -#define IDC_RADIO_SHOWROMANASCII 2039 -#define IDC_RADIO_SHOWROMANJLATIN 2040 - -#define IDC_CHECKBOX_SHOWMODEINL 2101 -#define IDC_EDIT_SHOWMODEINLTM 2102 -#define IDC_COL_MODE_MC 2103 -#define IDC_COL_MODE_MF 2104 -#define IDC_COL_MODE_HR 2105 -#define IDC_COL_MODE_KT 2106 -#define IDC_COL_MODE_KA 2107 -#define IDC_COL_MODE_JL 2108 -#define IDC_COL_MODE_AC 2109 -#define IDC_COL_MODE_DR 2110 - -#define IDC_CHECKBOX_SERIES_MARK 2201 -#define IDC_CHECKBOX_SERIES_TEXT 2202 -#define IDC_CHECKBOX_SERIES_OKURI 2203 -#define IDC_CHECKBOX_SERIES_ANNOT 2204 -#define IDC_RADIO_FG_STD_MARK 2206 -#define IDC_RADIO_FG_STD_TEXT 2207 -#define IDC_RADIO_FG_STD_OKURI 2208 -#define IDC_RADIO_FG_STD_ANNOT 2209 -#define IDC_RADIO_FG_SEL_MARK 2211 -#define IDC_RADIO_FG_SEL_TEXT 2212 -#define IDC_RADIO_FG_SEL_OKURI 2213 -#define IDC_RADIO_FG_SEL_ANNOT 2214 -#define IDC_COL_FG_MARK 2216 -#define IDC_COL_FG_TEXT 2217 -#define IDC_COL_FG_OKURI 2218 -#define IDC_COL_FG_ANNOT 2219 -#define IDC_RADIO_BG_STD_MARK 2221 -#define IDC_RADIO_BG_STD_TEXT 2222 -#define IDC_RADIO_BG_STD_OKURI 2223 -#define IDC_RADIO_BG_STD_ANNOT 2224 -#define IDC_RADIO_BG_SEL_MARK 2226 -#define IDC_RADIO_BG_SEL_TEXT 2227 -#define IDC_RADIO_BG_SEL_OKURI 2228 -#define IDC_RADIO_BG_SEL_ANNOT 2229 -#define IDC_COL_BG_MARK 2231 -#define IDC_COL_BG_TEXT 2232 -#define IDC_COL_BG_OKURI 2233 -#define IDC_COL_BG_ANNOT 2234 -#define IDC_COMBO_UL_ATTR_MARK 2236 -#define IDC_COMBO_UL_ATTR_TEXT 2237 -#define IDC_COMBO_UL_ATTR_OKURI 2238 -#define IDC_COMBO_UL_ATTR_ANNOT 2239 -#define IDC_CHECKBOX_UL_BOLD_MARK 2241 -#define IDC_CHECKBOX_UL_BOLD_TEXT 2242 -#define IDC_CHECKBOX_UL_BOLD_OKURI 2243 -#define IDC_CHECKBOX_UL_BOLD_ANNOT 2244 -#define IDC_RADIO_UL_STD_MARK 2246 -#define IDC_RADIO_UL_STD_TEXT 2247 -#define IDC_RADIO_UL_STD_OKURI 2248 -#define IDC_RADIO_UL_STD_ANNOT 2249 -#define IDC_RADIO_UL_SEL_MARK 2251 -#define IDC_RADIO_UL_SEL_TEXT 2252 -#define IDC_RADIO_UL_SEL_OKURI 2253 -#define IDC_RADIO_UL_SEL_ANNOT 2254 -#define IDC_COL_UL_MARK 2256 -#define IDC_COL_UL_TEXT 2257 -#define IDC_COL_UL_OKURI 2258 -#define IDC_COL_UL_ANNOT 2259 -#define IDC_COMBO_ATTR_MARK 2261 -#define IDC_COMBO_ATTR_TEXT 2262 -#define IDC_COMBO_ATTR_OKURI 2263 -#define IDC_COMBO_ATTR_ANNOT 2264 - -#define IDC_LIST_SELKEY 3101 -#define IDC_EDIT_SELKEY_DISP 3102 -#define IDC_EDIT_SELKEY_SPARE1 3103 -#define IDC_EDIT_SELKEY_SPARE2 3104 -#define IDC_BUTTON_SELKEY_W 3105 - -#define IDC_LIST_PRSRVKEY_ON 3201 -#define IDC_LIST_PRSRVKEY_OFF 3202 -#define IDC_EDIT_PRSRVKEY_VKEY 3203 -#define IDC_CHECKBOX_PRSRVKEY_MKEY_ALT 3204 -#define IDC_CHECKBOX_PRSRVKEY_MKEY_CTRL 3205 -#define IDC_CHECKBOX_PRSRVKEY_MKEY_SHIFT 3206 -#define IDC_RADIO_PRSRVKEY_ON 3207 -#define IDC_RADIO_PRSRVKEY_OFF 3208 -#define IDC_BUTTON_PRSRVKEY_UP 3209 -#define IDC_BUTTON_PRSRVKEY_DOWN 3210 -#define IDC_BUTTON_PRSRVKEY_W 3211 -#define IDC_BUTTON_PRSRVKEY_D 3212 -#define IDC_EDIT_DISPVKEY 3221 - -#define IDC_EDIT_KANA 3301 -#define IDC_EDIT_CONV_CHAR 3302 -#define IDC_EDIT_JLATIN 3303 -#define IDC_EDIT_ASCII 3304 -#define IDC_EDIT_JMODE 3305 -#define IDC_EDIT_ABBREV 3306 -#define IDC_EDIT_AFFIX 3307 -#define IDC_EDIT_NEXT_CAND 3308 -#define IDC_EDIT_PREV_CAND 3309 -#define IDC_EDIT_PURGE_DIC 3310 -#define IDC_EDIT_NEXT_COMP 3311 -#define IDC_EDIT_PREV_COMP 3312 -#define IDC_EDIT_COMP_CAND 3313 -#define IDC_EDIT_HINT 3314 -#define IDC_EDIT_CONV_POINT 3321 -#define IDC_EDIT_DIRECT 3322 -#define IDC_EDIT_ENTER 3323 -#define IDC_EDIT_CANCEL 3324 -#define IDC_EDIT_BACK 3325 -#define IDC_EDIT_DELETE 3326 -#define IDC_EDIT_VOID 3327 -#define IDC_EDIT_LEFT 3328 -#define IDC_EDIT_UP 3329 -#define IDC_EDIT_RIGHT 3330 -#define IDC_EDIT_DOWN 3331 -#define IDC_EDIT_PASTE 3332 - -#define IDC_LIST_CONVPOINT 4101 -#define IDC_EDIT_CONVPOINT_ST 4102 -#define IDC_EDIT_CONVPOINT_AL 4103 -#define IDC_EDIT_CONVPOINT_OK 4104 -#define IDC_BUTTON_CONVPOINT_UP 4105 -#define IDC_BUTTON_CONVPOINT_DOWN 4106 -#define IDC_BUTTON_CONVPOINT_W 4107 -#define IDC_BUTTON_CONVPOINT_D 4108 - -#define IDC_LIST_KANATBL 4201 -#define IDC_EDIT_KANATBL_R 4202 -#define IDC_EDIT_KANATBL_H 4203 -#define IDC_EDIT_KANATBL_K 4204 -#define IDC_EDIT_KANATBL_KA 4205 -#define IDC_CHECKBOX_KANATBL_SOKU 4206 -#define IDC_CHECKBOX_KANATBL_WAIT 4207 -#define IDC_BUTTON_KANATBL_UP 4208 -#define IDC_BUTTON_KANATBL_DOWN 4209 -#define IDC_BUTTON_KANATBL_W 4210 -#define IDC_BUTTON_KANATBL_D 4211 -#define IDC_BUTTON_LOADKANA 4212 -#define IDC_BUTTON_SAVEKANA 4213 - -#define IDC_LIST_JLATTBL 4301 -#define IDC_EDIT_JLATTBL_A 4302 -#define IDC_EDIT_JLATTBL_J 4303 -#define IDC_BUTTON_JLATTBL_UP 4304 -#define IDC_BUTTON_JLATTBL_DOWN 4305 -#define IDC_BUTTON_JLATTBL_W 4306 -#define IDC_BUTTON_JLATTBL_D 4307 +#define IDC_EDIT_SKK_DIC_URL 1101 + +#define IDC_MGR_STATUS_TEXT 1201 +#define IDC_BUTTON_MGR_KILL 1202 +#define IDC_BUTTON_MGR_RUN 1203 +#define IDC_BUTTON_OPEN_USERDIR 1204 +#define IDC_BUTTON_OPEN_SYSTEMDIR 1205 +#define IDC_EDIT_USERDICBACKUPDIR 1206 +#define IDC_BUTTON_OPEN_BACKUPDIR 1207 +#define IDC_EDIT_USERDICBACKUPGEN 1208 +#define IDC_BUTTON_RUN_BACKUP 1209 +#define IDC_EDIT_PRIVATEMODE_ON_VKEY 1210 +#define IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_ALT 1211 +#define IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_CTRL 1212 +#define IDC_CHECKBOX_PRIVATEMODE_ON_MKEY_SHIFT 1213 +#define IDC_EDIT_PRIVATEMODE_OFF_VKEY 1214 +#define IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_ALT 1215 +#define IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_CTRL 1216 +#define IDC_CHECKBOX_PRIVATEMODE_OFF_MKEY_SHIFT 1217 +#define IDC_CHECKBOX_PRIVATEMODE_AUTO 1218 +#define IDC_EDIT_DICTIONARY2_TEST_VKEY 1299 + +#define IDC_CHECKBOX_DEFAULTMODE 2001 +#define IDC_RADIO_DEFMODEHIRA 2002 +#define IDC_RADIO_DEFMODEASCII 2003 +#define IDC_CHECKBOX_BEGINCVOKURI 2004 +#define IDC_CHECKBOX_PRECEDEOKURI 2005 +#define IDC_CHECKBOX_SHIFTNNOKURI 2006 +#define IDC_CHECKBOX_SRCHALLOKURI 2007 +#define IDC_CHECKBOX_DELCVPOSCNCL 2008 +#define IDC_CHECKBOX_DELOKURICNCL 2009 +#define IDC_CHECKBOX_BACKINCENTER 2010 +#define IDC_CHECKBOX_ADDCANDKTKN 2011 +#define IDC_CHECKBOX_ENTOGGLEKANA 2012 +#define IDC_CHECKBOX_SETBYDIRECT 2013 + +#define IDC_COMBO_COMPMULTINUM 2101 +#define IDC_CHECKBOX_STACOMPMULTI 2102 +#define IDC_CHECKBOX_DYNAMINCOMP 2103 +#define IDC_CHECKBOX_DYNCOMPMULTI 2104 +#define IDC_CHECKBOX_COMPUSERDIC 2105 +#define IDC_CHECKBOX_COMPINCBACK 2106 + +#define IDC_EDIT_FONTNAME 3001 +#define IDC_EDIT_FONTPOINT 3002 +#define IDC_BUTTON_CHOOSEFONT 3003 +#define IDC_EDIT_MAXWIDTH 3004 +#define IDC_COL_BG 3011 +#define IDC_COL_FR 3012 +#define IDC_COL_SE 3013 +#define IDC_COL_CO 3014 +#define IDC_COL_CA 3015 +#define IDC_COL_SC 3016 +#define IDC_COL_AN 3017 +#define IDC_COL_NO 3018 +#define IDC_RADIO_API_GDI 3021 +#define IDC_RADIO_API_D2D 3022 +#define IDC_CHECKBOX_COLOR_FONT 3023 +#define IDC_COMBO_UNTILCANDLIST 3031 +#define IDC_COMBO_PAGECANDNUM 3032 +#define IDC_CHECKBOX_DISPCANDNO 3033 +#define IDC_CHECKBOX_VERTICALCAND 3034 +#define IDC_CHECKBOX_ANNOTATION 3035 +#define IDC_RADIO_ANNOTATALL 3036 +#define IDC_RADIO_ANNOTATLST 3037 +#define IDC_CHECKBOX_SHOWMODEMARK 3038 +#define IDC_CHECKBOX_SHOWROMAN 3039 +#define IDC_RADIO_SHOWROMANASCII 3040 +#define IDC_RADIO_SHOWROMANJLATIN 3041 + +#define IDC_CHECKBOX_SHOWMODEINL 3101 +#define IDC_EDIT_SHOWMODEINLTM 3102 +#define IDC_COL_MODE_MC 3103 +#define IDC_COL_MODE_MF 3104 +#define IDC_COL_MODE_HR 3105 +#define IDC_COL_MODE_KT 3106 +#define IDC_COL_MODE_KA 3107 +#define IDC_COL_MODE_JL 3108 +#define IDC_COL_MODE_AC 3109 +#define IDC_COL_MODE_DR 3110 + +#define IDC_CHECKBOX_SERIES_MARK 3201 +#define IDC_CHECKBOX_SERIES_TEXT 3202 +#define IDC_CHECKBOX_SERIES_OKURI 3203 +#define IDC_CHECKBOX_SERIES_ANNOT 3204 +#define IDC_RADIO_FG_STD_MARK 3206 +#define IDC_RADIO_FG_STD_TEXT 3207 +#define IDC_RADIO_FG_STD_OKURI 3208 +#define IDC_RADIO_FG_STD_ANNOT 3209 +#define IDC_RADIO_FG_SEL_MARK 3211 +#define IDC_RADIO_FG_SEL_TEXT 3212 +#define IDC_RADIO_FG_SEL_OKURI 3213 +#define IDC_RADIO_FG_SEL_ANNOT 3214 +#define IDC_COL_FG_MARK 3216 +#define IDC_COL_FG_TEXT 3217 +#define IDC_COL_FG_OKURI 3218 +#define IDC_COL_FG_ANNOT 3219 +#define IDC_RADIO_BG_STD_MARK 3221 +#define IDC_RADIO_BG_STD_TEXT 3222 +#define IDC_RADIO_BG_STD_OKURI 3223 +#define IDC_RADIO_BG_STD_ANNOT 3224 +#define IDC_RADIO_BG_SEL_MARK 3226 +#define IDC_RADIO_BG_SEL_TEXT 3227 +#define IDC_RADIO_BG_SEL_OKURI 3228 +#define IDC_RADIO_BG_SEL_ANNOT 3229 +#define IDC_COL_BG_MARK 3231 +#define IDC_COL_BG_TEXT 3232 +#define IDC_COL_BG_OKURI 3233 +#define IDC_COL_BG_ANNOT 3234 +#define IDC_COMBO_UL_ATTR_MARK 3236 +#define IDC_COMBO_UL_ATTR_TEXT 3237 +#define IDC_COMBO_UL_ATTR_OKURI 3238 +#define IDC_COMBO_UL_ATTR_ANNOT 3239 +#define IDC_CHECKBOX_UL_BOLD_MARK 3241 +#define IDC_CHECKBOX_UL_BOLD_TEXT 3242 +#define IDC_CHECKBOX_UL_BOLD_OKURI 3243 +#define IDC_CHECKBOX_UL_BOLD_ANNOT 3244 +#define IDC_RADIO_UL_STD_MARK 3246 +#define IDC_RADIO_UL_STD_TEXT 3247 +#define IDC_RADIO_UL_STD_OKURI 3248 +#define IDC_RADIO_UL_STD_ANNOT 3249 +#define IDC_RADIO_UL_SEL_MARK 3251 +#define IDC_RADIO_UL_SEL_TEXT 3252 +#define IDC_RADIO_UL_SEL_OKURI 3253 +#define IDC_RADIO_UL_SEL_ANNOT 3254 +#define IDC_COL_UL_MARK 3256 +#define IDC_COL_UL_TEXT 3257 +#define IDC_COL_UL_OKURI 3258 +#define IDC_COL_UL_ANNOT 3259 +#define IDC_COMBO_ATTR_MARK 3261 +#define IDC_COMBO_ATTR_TEXT 3262 +#define IDC_COMBO_ATTR_OKURI 3263 +#define IDC_COMBO_ATTR_ANNOT 3264 + +#define IDC_LIST_SELKEY 4001 +#define IDC_EDIT_SELKEY_DISP 4002 +#define IDC_EDIT_SELKEY_SPARE1 4003 +#define IDC_EDIT_SELKEY_SPARE2 4004 +#define IDC_BUTTON_SELKEY_W 4005 + +#define IDC_LIST_PRSRVKEY_ON 4101 +#define IDC_LIST_PRSRVKEY_OFF 4102 +#define IDC_EDIT_PRSRVKEY_VKEY 4103 +#define IDC_CHECKBOX_PRSRVKEY_MKEY_ALT 4104 +#define IDC_CHECKBOX_PRSRVKEY_MKEY_CTRL 4105 +#define IDC_CHECKBOX_PRSRVKEY_MKEY_SHIFT 4106 +#define IDC_RADIO_PRSRVKEY_ON 4107 +#define IDC_RADIO_PRSRVKEY_OFF 4108 +#define IDC_BUTTON_PRSRVKEY_UP 4109 +#define IDC_BUTTON_PRSRVKEY_DOWN 4110 +#define IDC_BUTTON_PRSRVKEY_W 4111 +#define IDC_BUTTON_PRSRVKEY_D 4112 +#define IDC_EDIT_PRSRVKEY_TEST_VKEY 4199 + +#define IDC_EDIT_KANA 4201 +#define IDC_EDIT_CONV_CHAR 4202 +#define IDC_EDIT_JLATIN 4203 +#define IDC_EDIT_ASCII 4204 +#define IDC_EDIT_JMODE 4205 +#define IDC_EDIT_ABBREV 4206 +#define IDC_EDIT_AFFIX 4207 +#define IDC_EDIT_NEXT_CAND 4208 +#define IDC_EDIT_PREV_CAND 4209 +#define IDC_EDIT_PURGE_DIC 4210 +#define IDC_EDIT_NEXT_COMP 4211 +#define IDC_EDIT_PREV_COMP 4212 +#define IDC_EDIT_COMP_CAND 4213 +#define IDC_EDIT_HINT 4214 +#define IDC_EDIT_CONV_POINT 4221 +#define IDC_EDIT_DIRECT 4222 +#define IDC_EDIT_ENTER 4223 +#define IDC_EDIT_CANCEL 4224 +#define IDC_EDIT_BACK 4225 +#define IDC_EDIT_DELETE 4226 +#define IDC_EDIT_VOID 4227 +#define IDC_EDIT_LEFT 4228 +#define IDC_EDIT_UP 4229 +#define IDC_EDIT_RIGHT 4230 +#define IDC_EDIT_DOWN 4231 +#define IDC_EDIT_PASTE 4232 +#define IDC_EDIT_RECONVERT 4233 +#define IDC_EDIT_KEYMAP_TEST_VKEY 4299 + +#define IDC_LIST_CONVPOINT 5001 +#define IDC_EDIT_CONVPOINT_ST 5002 +#define IDC_EDIT_CONVPOINT_AL 5003 +#define IDC_EDIT_CONVPOINT_OK 5004 +#define IDC_BUTTON_CONVPOINT_UP 5005 +#define IDC_BUTTON_CONVPOINT_DOWN 5006 +#define IDC_BUTTON_CONVPOINT_W 5007 +#define IDC_BUTTON_CONVPOINT_D 5008 + +#define IDC_LIST_KANATBL 5101 +#define IDC_EDIT_KANATBL_R 5102 +#define IDC_EDIT_KANATBL_H 5103 +#define IDC_EDIT_KANATBL_K 5104 +#define IDC_EDIT_KANATBL_KA 5105 +#define IDC_CHECKBOX_KANATBL_SOKU 5106 +#define IDC_CHECKBOX_KANATBL_WAIT 5107 +#define IDC_BUTTON_KANATBL_UP 5108 +#define IDC_BUTTON_KANATBL_DOWN 5109 +#define IDC_BUTTON_KANATBL_W 5110 +#define IDC_BUTTON_KANATBL_D 5111 +#define IDC_BUTTON_LOADKANA 5112 +#define IDC_BUTTON_SAVEKANA 5113 + +#define IDC_LIST_JLATTBL 5201 +#define IDC_EDIT_JLATTBL_A 5202 +#define IDC_EDIT_JLATTBL_J 5203 +#define IDC_BUTTON_JLATTBL_UP 5204 +#define IDC_BUTTON_JLATTBL_DOWN 5205 +#define IDC_BUTTON_JLATTBL_W 5206 +#define IDC_BUTTON_JLATTBL_D 5207 diff --git a/imcrvcnf/stdafx.cpp b/imcrvcnf/stdafx.cpp deleted file mode 100644 index 7438ada7..00000000 --- a/imcrvcnf/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -// nothing diff --git a/imcrvmgr/ConfigMgr.cpp b/imcrvmgr/ConfigMgr.cpp index 40d0572c..58e2f59d 100644 --- a/imcrvmgr/ConfigMgr.cpp +++ b/imcrvmgr/ConfigMgr.cpp @@ -9,13 +9,20 @@ LPCWSTR DictionaryManagerClass = TEXTSERVICE_NAME L"DictionaryManager"; // ファイルパス WCHAR pathconfigxml[MAX_PATH]; //設定 WCHAR pathuserdic[MAX_PATH]; //ユーザー辞書 -WCHAR pathuserbak[MAX_PATH]; //ユーザー辞書バックアッププレフィックス WCHAR pathskkdic[MAX_PATH]; //取込SKK辞書 WCHAR pathinitlua[MAX_PATH]; //init.lua +WCHAR pathbackup[MAX_PATH]; //ユーザー辞書バックアップレフィックス -WCHAR krnlobjsddl[MAX_KRNLOBJNAME]; //SDDL -WCHAR mgrpipename[MAX_KRNLOBJNAME]; //名前付きパイプ -WCHAR mgrmutexname[MAX_KRNLOBJNAME]; //ミューテックス +WCHAR radconfigxml[MAX_PATH]; //設定 FOLDERID_RoamingAppData +WCHAR sysconfigxml[MAX_PATH]; //設定 FOLDERID_Windows\IME +INT csidlconfigxml; //設定 CSIDL_APPDATA/CSIDL_WINDOWS +WCHAR radskkdic[MAX_PATH]; //取込SKK辞書 FOLDERID_RoamingAppData +WCHAR sysskkdic[MAX_PATH]; //取込SKK辞書 FOLDERID_Windows\IME +INT csidlskkdic; //取込SKK辞書 CSIDL_APPDATA/CSIDL_WINDOWS + +WCHAR krnlobjsddl[MAX_SECURITYDESC]; //SDDL +WCHAR mgrpipename[MAX_PIPENAME]; //名前付きパイプ +WCHAR mgrmutexname[MAX_PATH]; //ミューテックス // 辞書サーバー設定 BOOL serv = FALSE; //SKK辞書サーバーを使用する @@ -24,6 +31,8 @@ WCHAR port[MAX_SKKSERVER_PORT] = {}; //ポート DWORD encoding = 0; //エンコーディング DWORD timeout = 1000; //タイムアウト +INT generation = 0; //ユーザー辞書バックアップ世代数 + BOOL precedeokuri = FALSE; //送り仮名が一致した候補を優先する BOOL compincback = FALSE; //前方一致と後方一致で補完する @@ -38,6 +47,7 @@ const luaL_Reg luaFuncs[] = {u8"search_jisx0208", lua_search_jisx0208}, {u8"search_character_code", lua_search_character_code}, {u8"complement", lua_complement}, + {u8"reverse", lua_reverse}, {u8"add", lua_add}, {u8"delete", lua_delete}, {u8"save", lua_save}, @@ -50,10 +60,17 @@ void CreateConfigPath() ZeroMemory(pathconfigxml, sizeof(pathconfigxml)); ZeroMemory(pathuserdic, sizeof(pathuserdic)); - ZeroMemory(pathuserbak, sizeof(pathuserbak)); ZeroMemory(pathskkdic, sizeof(pathskkdic)); ZeroMemory(pathinitlua, sizeof(pathinitlua)); + ZeroMemory(radconfigxml, sizeof(radconfigxml)); + ZeroMemory(sysconfigxml, sizeof(sysconfigxml)); + ZeroMemory(radskkdic, sizeof(radskkdic)); + ZeroMemory(sysskkdic, sizeof(sysskkdic)); + + csidlconfigxml = CSIDL_APPDATA; + csidlskkdic = CSIDL_APPDATA; + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) { WCHAR appdir[MAX_PATH]; @@ -67,10 +84,10 @@ void CreateConfigPath() _snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s", appdir, fnconfigxml); _snwprintf_s(pathuserdic, _TRUNCATE, L"%s\\%s", appdir, fnuserdic); - _snwprintf_s(pathuserbak, _TRUNCATE, L"%s\\%s", appdir, fnuserbak); _snwprintf_s(pathskkdic, _TRUNCATE, L"%s\\%s", appdir, fnskkdic); _snwprintf_s(pathinitlua, _TRUNCATE, L"%s\\%s", appdir, fninitlua); +#if FALSE //for compatibility if (GetFileAttributesW(pathskkdic) == INVALID_FILE_ATTRIBUTES) { @@ -80,69 +97,86 @@ void CreateConfigPath() _snwprintf_s(skkdict, _TRUNCATE, L"%s\\%s", appdir, L"skkdict.idx"); DeleteFileW(skkdict); } +#endif } -} - -void UpdateConfigPath() -{ - PWSTR knownfolderpath = nullptr; - //%AppData%\\CorvusSKK\\config.xml - //%AppData%\\CorvusSKK\\skkdict.txt + //%APPDATA%\\CorvusSKK\\config.xml + //%APPDATA%\\CorvusSKK\\skkdict.txt if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) { - _snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, TextServiceDesc, fnconfigxml); - _snwprintf_s(pathskkdic, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, TextServiceDesc, fnskkdic); + _snwprintf_s(radconfigxml, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, TextServiceDesc, fnconfigxml); + _snwprintf_s(radskkdic, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, TextServiceDesc, fnskkdic); CoTaskMemFree(knownfolderpath); } - if (GetFileAttributesW(pathconfigxml) == INVALID_FILE_ATTRIBUTES) - { #ifdef _DEBUG - //\\config.xml - if (GetModuleFileNameW(hInst, pathconfigxml, _countof(pathconfigxml)) != 0) + WCHAR modulename[MAX_PATH] = {}; + + //\\config.xml + //\\skkdict.txt + if (GetModuleFileNameW(hInst, modulename, _countof(modulename)) != 0) + { + WCHAR *pdir = wcsrchr(modulename, L'\\'); + if (pdir != nullptr) { - WCHAR *pdir = wcsrchr(pathconfigxml, L'\\'); - if (pdir != nullptr) - { - *(pdir + 1) = L'\0'; - wcsncat_s(pathconfigxml, fnconfigxml, _TRUNCATE); - } + *pdir = L'\0'; + + _snwprintf_s(sysconfigxml, _TRUNCATE, L"%s\\%s", modulename, fnconfigxml); + _snwprintf_s(sysskkdic, _TRUNCATE, L"%s\\%s", modulename, fnskkdic); } + } #else - //%SystemRoot%\\IME\\IMCRVSKK\\config.xml - if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) - { - _snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, L"IME", TEXTSERVICE_DIR, fnconfigxml); + //%SystemRoot%\\IME\\IMCRVSKK\\config.xml + //%SystemRoot%\\IME\\IMCRVSKK\\skkdict.txt + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) + { + _snwprintf_s(sysconfigxml, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, SYSTEMROOT_IME_DIR, TEXTSERVICE_DIR, fnconfigxml); + _snwprintf_s(sysskkdic, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, SYSTEMROOT_IME_DIR, TEXTSERVICE_DIR, fnskkdic); - CoTaskMemFree(knownfolderpath); - } + CoTaskMemFree(knownfolderpath); + } #endif +} + +void UpdateConfigPath() +{ + LPCWSTR p_pathconfigxml = radconfigxml; + LPCWSTR p_pathskkdic = radskkdic; + + INT n_csidlconfigxml = CSIDL_APPDATA; + INT n_csidlskkdic = CSIDL_APPDATA; + + if (GetFileAttributesW(radconfigxml) == INVALID_FILE_ATTRIBUTES) + { + n_csidlconfigxml = CSIDL_WINDOWS; + p_pathconfigxml = sysconfigxml; } - if (GetFileAttributesW(pathskkdic) == INVALID_FILE_ATTRIBUTES) + if (GetFileAttributesW(radskkdic) == INVALID_FILE_ATTRIBUTES) { -#ifdef _DEBUG - //\\skkdict.txt - if (GetModuleFileNameW(hInst, pathskkdic, _countof(pathskkdic)) != 0) - { - WCHAR *pdir = wcsrchr(pathskkdic, L'\\'); - if (pdir != nullptr) - { - *(pdir + 1) = L'\0'; - wcsncat_s(pathskkdic, fnskkdic, _TRUNCATE); - } - } -#else - //%SystemRoot%\\IME\\IMCRVSKK\\skkdict.txt - if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) - { - _snwprintf_s(pathskkdic, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, L"IME", TEXTSERVICE_DIR, fnskkdic); + n_csidlskkdic = CSIDL_WINDOWS; + p_pathskkdic = sysskkdic; + } - CoTaskMemFree(knownfolderpath); - } -#endif + //ファイルが切り替わったら再読み込み + + if (csidlconfigxml != n_csidlconfigxml) + { + csidlconfigxml = n_csidlconfigxml; + wcsncpy_s(pathconfigxml, p_pathconfigxml, _TRUNCATE); + + ftConfig.dwLowDateTime = 0; + ftConfig.dwHighDateTime = 0; + } + + if (csidlskkdic != n_csidlskkdic) + { + csidlskkdic = n_csidlskkdic; + wcsncpy_s(pathskkdic, p_pathskkdic, _TRUNCATE); + + ftSKKDic.dwLowDateTime = 0; + ftSKKDic.dwHighDateTime = 0; } } @@ -177,8 +211,9 @@ void CreateIpcName() } } -void LoadConfig() +void LoadConfig(BOOL sysexit) { + WCHAR path[MAX_PATH]; BOOL servtmp; WCHAR hosttmp[MAX_SKKSERVER_HOST]; //ホスト WCHAR porttmp[MAX_SKKSERVER_PORT]; //ポート @@ -214,22 +249,53 @@ void LoadConfig() } //変更があったら接続し直す - if (servtmp != serv || wcscmp(hosttmp, host) != 0 || wcscmp(porttmp, port) != 0 || - encodingtmp != encoding || timeouttmp != timeout) + if (sysexit == FALSE) { - serv = servtmp; - wcsncpy_s(host, hosttmp, _TRUNCATE); - wcsncpy_s(port, porttmp, _TRUNCATE); - encoding = encodingtmp; - timeout = timeouttmp; + if (servtmp != serv || wcscmp(hosttmp, host) != 0 || wcscmp(porttmp, port) != 0 || + encodingtmp != encoding || timeouttmp != timeout) + { + serv = servtmp; + wcsncpy_s(host, hosttmp, _TRUNCATE); + wcsncpy_s(port, porttmp, _TRUNCATE); + encoding = encodingtmp; + timeout = timeouttmp; - DisconnectSKKServer(); + DisconnectSKKServer(); + + if (serv) + { + StartConnectSKKServer(); + } + } + } - if (serv) + ReadValue(pathconfigxml, SectionUserDict, ValueBackupDir, strxmlval); + if (strxmlval.empty()) + { + strxmlval = L"%APPDATA%\\" TEXTSERVICE_DESC; + } + ExpandEnvironmentStringsW(strxmlval.c_str(), path, _countof(path)); + for (int i = 0; i < _countof(path) && path[i] != L'\0'; i++) + { + UINT type = PathGetCharTypeW(path[i]); + if ((type & (GCT_LFNCHAR | GCT_SHORTCHAR | GCT_SEPARATOR)) == 0) { - StartConnectSKKServer(); + path[i] = L'_'; } } + _snwprintf_s(pathbackup, _TRUNCATE, L"%s\\%s", path, fnuserdic); + + ReadValue(pathconfigxml, SectionUserDict, ValueBackupGen, strxmlval); + INT n = strxmlval.empty() ? -1 : _wtoi(strxmlval.c_str()); + if (n < 0) + { + n = DEF_BACKUPGENS; + } + else if (n > MAX_BACKUPGENS) + { + n = MAX_BACKUPGENS; + } + generation = n; ReadValue(pathconfigxml, SectionBehavior, ValuePrecedeOkuri, strxmlval); precedeokuri = _wtoi(strxmlval.c_str()); @@ -250,18 +316,19 @@ BOOL IsFileModified(LPCWSTR path, FILETIME *ft) { BOOL ret = FALSE; HANDLE hFile; - FILETIME ftn; + FILETIME ftN; if (path != nullptr && ft != nullptr) { hFile = CreateFileW(path, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { - if (GetFileTime(hFile, nullptr, nullptr, &ftn)) + if (GetFileTime(hFile, nullptr, nullptr, &ftN)) { - if (((ULARGE_INTEGER *)ft)->QuadPart != ((ULARGE_INTEGER *)&ftn)->QuadPart) + if ((ft->dwLowDateTime != ftN.dwLowDateTime) || + (ft->dwHighDateTime != ftN.dwHighDateTime)) { - *ft = ftn; + *ft = ftN; ret = TRUE; } } @@ -292,7 +359,7 @@ void InitLua() lua_pushstring(lua, version); lua_setglobal(lua, u8"SKK_VERSION"); - //%AppData%\\CorvusSKK\\init.lua + //%APPDATA%\\CorvusSKK\\init.lua if (luaL_dofile(lua, WCTOU8(pathinitlua)) == LUA_OK) { return; @@ -317,7 +384,7 @@ void InitLua() //%SystemRoot%\\IME\\IMCRVSKK\\init.lua if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) { - _snwprintf_s(pathinitlua, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, L"IME", TEXTSERVICE_DIR, fninitlua); + _snwprintf_s(pathinitlua, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, SYSTEMROOT_IME_DIR, TEXTSERVICE_DIR, fninitlua); CoTaskMemFree(knownfolderpath); } diff --git a/imcrvmgr/SearchCharacter.cpp b/imcrvmgr/SearchCharacter.cpp index 9b246071..577b8f03 100644 --- a/imcrvmgr/SearchCharacter.cpp +++ b/imcrvmgr/SearchCharacter.cpp @@ -1,5 +1,6 @@  #include "eucjis2004.h" +#include "eucjptable.h" #include "imcrvmgr.h" #define SURROGATEPAIR_UCPMAX 0x10FFFF @@ -10,28 +11,27 @@ #define SURROGATEPAIR_SEPBIT 10 #define SURROGATEPAIR_SEPMASK 0x3FF -#define ROWNUM 94 -#define COLNUM 6 - -extern const USHORT jisx0208b[ROWNUM][COLNUM]; - std::wstring SearchUnicode(const std::wstring &searchkey) { std::wstring candidate; //Unicode Code Point UCSCHAR ucp = 0; - WCHAR utf16[3]; + WCHAR utf16[3] = {}; // U+XXXXXX (XXXXXX : 0000-FFFF,10000-10FFFF) - if (std::regex_match(searchkey, std::wregex(L"U\\+([1-9A-F]|10)?[0-9A-F]{4}"))) + static const std::wregex reU(L"U\\+([1-9A-F]|10)?[0-9A-F]{4}"); + + // uxxxxxx (xxxxxx : 0000-ffff,10000-10ffff) + static const std::wregex reL(L"u([1-9a-f]|10)?[0-9a-f]{4}"); + + if (std::regex_match(searchkey, reU)) { if (swscanf_s(searchkey.c_str(), L"U+%X", &ucp) != 1) { return candidate; } } - // uxxxxxx (xxxxxx : 0000-ffff,10000-10ffff) - else if (std::regex_match(searchkey, std::wregex(L"u([1-9a-f]|10)?[0-9a-f]{4}"))) + else if (std::regex_match(searchkey, reL)) { if (swscanf_s(searchkey.c_str(), L"u%x", &ucp) != 1) { @@ -43,7 +43,6 @@ std::wstring SearchUnicode(const std::wstring &searchkey) return candidate; } - ZeroMemory(utf16, sizeof(utf16)); if (UcpToWideChar(ucp, &utf16[0], &utf16[1]) != 0) { candidate = L"/"; @@ -62,12 +61,14 @@ std::wstring SearchJISX0213(const std::wstring &searchkey) CONST CHAR base = 0x20; int men, ku, ten; size_t size; - WCHAR utf16[8]; - CHAR euc[4]; - UCSCHAR ucp[2]; - WCHAR sucp[32]; + WCHAR utf16[8] = {}; + CHAR euc[4] = {}; + UCSCHAR ucp[2] = {}; + WCHAR sucp[32] = {}; - if (!std::regex_match(searchkey, std::wregex(L"[12]-(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])"))) + static const std::wregex re(L"[12]-(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])"); + + if (!std::regex_match(searchkey, re)) { return candidate; } @@ -126,7 +127,9 @@ std::wstring SearchJISX0208(const std::wstring &searchkey) //JIS X 0208 区点番号 int ku, ten; - if (!std::regex_match(searchkey, std::wregex(L"(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])"))) + static const std::wregex re(L"(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])"); + + if (!std::regex_match(searchkey, re)) { return candidate; } @@ -136,9 +139,12 @@ std::wstring SearchJISX0208(const std::wstring &searchkey) return candidate; } - if ((jisx0208b[ku - 1][(ten - (ten % 16)) / 16] & (0x0001 << (ten % 16))) != 0) + if (ku >= 1 && ku <= ROWNUM && ten >= 1 && ten <= CELLNUM) { - candidate = SearchJISX0213(L"1-" + searchkey); + if ((jisx0208e[ku - 1][(ten - (ten % 16)) / 16] & (0x0001 << (ten % 16))) != 0) + { + candidate = SearchJISX0213(L"1-" + searchkey); + } } return candidate; @@ -156,7 +162,7 @@ std::wstring SearchCharacterCode(const std::wstring &searchkey) CONST CHAR ejs = 0x21; CONST CHAR eje = 0x7E; CONST CHAR base = 0x20; - CHAR ej[2]; + CHAR ej[2] = {}; std::wstring e, u; WCHAR b[16] = {}; size_t len; @@ -165,7 +171,7 @@ std::wstring SearchCharacterCode(const std::wstring &searchkey) //ASCII, JIS X 0201 (片仮名, 8bit), JIS X 0213 面区点番号 if (WideCharToEucJis2004(searchkey.c_str(), nullptr, nullptr, &len)) { - std::string euc = WCTOEUC(searchkey); + std::string euc = wstring_to_eucjis2004_string(searchkey); for (size_t i = 0; i < euc.size(); i++) { @@ -274,103 +280,3 @@ void SendKeyboardInput(WCHAR command) SendInput(2, input2, sizeof(INPUT)); } - -//JIS X 0208 有効区点テーブル -const USHORT jisx0208b[ROWNUM][COLNUM] = -{ - //1-15点, 16-31点, 32-47点, 48-63点, 64-79点, 80-94点 - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, //1区 - {0x7FFE, 0xFC00, 0xFC03, 0xF001, 0x07FF, 0x43FC}, //2区 - {0x0000, 0x03FF, 0xFFFE, 0x07FF, 0xFFFE, 0x07FF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x000F}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x007F}, - {0xFFFE, 0x01FF, 0xFFFE, 0x01FF, 0x0000, 0x0000}, - {0xFFFE, 0xFFFF, 0x0003, 0xFFFE, 0xFFFF, 0x0003}, - {0xFFFE, 0xFFFF, 0x0001, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0x000F, 0x0000, 0x0000}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7FFF}, - {0x007E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000} //94区 -}; diff --git a/imcrvmgr/SearchDictionary.cpp b/imcrvmgr/SearchDictionary.cpp index 429d6cbe..5cee8a12 100644 --- a/imcrvmgr/SearchDictionary.cpp +++ b/imcrvmgr/SearchDictionary.cpp @@ -10,8 +10,6 @@ POS skkdicpos_n; //送りなしエントリ void SearchDictionary(const std::wstring &searchkey, const std::wstring &okuri, SKKDICCANDIDATES &sc) { std::wstring candidate; - std::wregex re; - std::wstring fmt; if (lua != nullptr) { @@ -30,11 +28,22 @@ void SearchDictionary(const std::wstring &searchkey, const std::wstring &okuri, } else { + std::wstring okurik = okuri; + + //skk-search-sagyo-henkaku (anything) + //「送りあり変換で送りなし候補も検索する」 → 送り仮名あり、送りローマ字なし + static const std::wregex reroman(L"^.+[a-z]$"); + if (!okurik.empty() && !std::regex_match(searchkey, reroman)) + { + //送り仮名クリア + okurik.clear(); + } + //ユーザー辞書 - candidate += SearchUserDic(searchkey, okuri); + candidate += SearchUserDic(searchkey, okurik); //SKK辞書 - candidate += SearchSKKDic(searchkey, okuri); + candidate += SearchSKKDic(searchkey, okurik); //SKK辞書サーバー candidate += SearchSKKServer(searchkey); @@ -54,14 +63,12 @@ void SearchDictionary(const std::wstring &searchkey, const std::wstring &okuri, candidate += SearchCharacterCode(searchkey.substr(1)); } - re.assign(L"/\n/"); - fmt.assign(L"/"); - candidate = std::regex_replace(candidate, re, fmt); + static const std::wregex resepdic(L"/\n/"); + candidate = std::regex_replace(candidate, resepdic, L"/"); } - re.assign(L"[\\x00-\\x19]"); - fmt.assign(L""); - candidate = std::regex_replace(candidate, re, fmt); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + candidate = std::regex_replace(candidate, rectrl, L""); ParseSKKDicCandiate(candidate, sc); @@ -87,14 +94,12 @@ void SearchDictionary(const std::wstring &searchkey, const std::wstring &okuri, std::wstring SearchSKKDic(const std::wstring &searchkey, const std::wstring &okuri) { - FILE *fp; - std::wstring candidate, wsbuf, kbuf, cbuf; - WCHAR wbuf[READBUFSIZE]; - PWCHAR pwb; + FILE *fp = nullptr; + std::wstring candidate, wstrbuf, kbuf, cbuf; + WCHAR wbuf[READBUFSIZE / sizeof(WCHAR)]; long pos, left, mid, right; - size_t is, ie; - _wfopen_s(&fp, pathskkdic, RB); + _wfopen_s(&fp, pathskkdic, modeRB); if (fp == nullptr) { return candidate; @@ -123,42 +128,45 @@ std::wstring SearchSKKDic(const std::wstring &searchkey, const std::wstring &oku } fseek(fp, pos, SEEK_SET); - wsbuf.clear(); + wstrbuf.clear(); kbuf.clear(); cbuf.clear(); - while ((pwb = fgetws(wbuf, _countof(wbuf), fp)) != nullptr) + while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) { - wsbuf += wbuf; + wstrbuf += wbuf; - if (!wsbuf.empty() && wsbuf.back() == L'\n') + if (!wstrbuf.empty() && wstrbuf.back() == L'\n') { + // CR+LF -> LF + if (wstrbuf.size() >= 2 && wstrbuf[wstrbuf.size() - 2] == L'\r') + { + wstrbuf.erase(wstrbuf.size() - 2); + wstrbuf.push_back(L'\n'); + } break; } } - if (pwb == nullptr) + if (ferror(fp) != 0) { break; } - // CR+LF -> LF - is = wsbuf.find_last_of(L'/'); - if (is != std::wstring::npos) + if (wstrbuf.empty()) { - wsbuf.erase(is + 1); - wsbuf.push_back(L'\n'); + break; } - is = wsbuf.find(L"\x20/"); + size_t is = wstrbuf.find(L"\x20/"); if (is != std::wstring::npos) { - ie = wsbuf.find_last_not_of(L'\x20', is); - if (is != std::wstring::npos) + size_t ie = wstrbuf.find_last_not_of(L'\x20', is); + if (ie != std::wstring::npos) { - kbuf = wsbuf.substr(0, ie + 1); + kbuf = wstrbuf.substr(0, ie + 1); } - cbuf = wsbuf.substr(is + 1); + cbuf = wstrbuf.substr(is + 1); } int cmpkey = searchkey.compare(kbuf); @@ -184,9 +192,9 @@ std::wstring SearchSKKDic(const std::wstring &searchkey, const std::wstring &oku void MakeSKKDicPos() { - FILE *fp; - WCHAR wbuf[READBUFSIZE]; - PWCHAR pwb, pwn; + FILE *fp = nullptr; + WCHAR wbuf[READBUFSIZE / sizeof(WCHAR)]; + std::wstring wstrbuf; long pos; int okuri = -1; @@ -195,40 +203,58 @@ void MakeSKKDicPos() skkdicpos_n.clear(); skkdicpos_n.shrink_to_fit(); - _wfopen_s(&fp, pathskkdic, RB); + _wfopen_s(&fp, pathskkdic, modeRB); if (fp == nullptr) { return; } - fseek(fp, 2, SEEK_SET); //skip BOM + //check BOM + WCHAR bom = L'\0'; + fread(&bom, 2, 1, fp); + if (bom != BOM) + { + fclose(fp); + return; + } + pos = ftell(fp); while (true) { - while ((pwb = fgetws(wbuf, _countof(wbuf), fp)) != nullptr) + wstrbuf.clear(); + + while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) { - if ((pwn = wcschr(wbuf, L'\n')) != nullptr) + wstrbuf += wbuf; + + if (!wstrbuf.empty() && wstrbuf.back() == L'\n') { - if ((pwn != wbuf) && (*(pwn - 1) == L'\r')) + // CR+LF -> LF + if (wstrbuf.size() >= 2 && wstrbuf[wstrbuf.size() - 2] == L'\r') { - *(pwn - 1) = L'\n'; - *pwn = L'\0'; + wstrbuf.erase(wstrbuf.size() - 2); + wstrbuf.push_back(L'\n'); } break; } } - if (pwb == nullptr) + if (ferror(fp) != 0) + { + break; + } + + if (wstrbuf.empty()) { break; } - if (wcscmp(EntriesAri, wbuf) == 0) + if (wstrbuf.compare(EntriesAri) == 0) { okuri = 1; } - else if (wcscmp(EntriesNasi, wbuf) == 0) + else if (wstrbuf.compare(EntriesNasi) == 0) { okuri = 0; } @@ -283,10 +309,12 @@ std::wstring ConvertKey(const std::wstring &searchkey, const std::wstring &okuri } //数値変換 - ret = std::regex_replace(searchkey, std::wregex(L"[0-9]+"), std::wstring(L"#")); + static const std::wregex renum(L"[0-9]+"); + ret = std::regex_replace(searchkey, renum, L"#"); } - ret = std::regex_replace(ret, std::wregex(L"[\\x00-\\x19]"), std::wstring(L"")); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + ret = std::regex_replace(ret, rectrl, L""); return ret; } @@ -317,205 +345,8 @@ std::wstring ConvertCandidate(const std::wstring &searchkey, const std::wstring ret = ParseConcat(candidate); } - ret = std::regex_replace(ret, std::wregex(L"[\\x00-\\x19]"), std::wstring(L"")); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + ret = std::regex_replace(ret, rectrl, L""); return ret; } - -int lua_search_skk_dictionary(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1) && - lua_isstring(lua, 2)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - std::wstring okurikey = U8TOWC(lua_tostring(lua, 2)); - - candidate = SearchSKKDic(searchkey, okurikey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_search_user_dictionary(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1) && - lua_isstring(lua, 2)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - std::wstring okurikey = U8TOWC(lua_tostring(lua, 2)); - - candidate = SearchUserDic(searchkey, okurikey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_search_skk_server(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - - candidate = SearchSKKServer(searchkey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_search_skk_server_info(lua_State *lua) -{ - std::wstring server_ver = GetSKKServerInfo(SKK_VER); - std::wstring server_hst = GetSKKServerInfo(SKK_HST); - - lua_pushstring(lua, WCTOU8(server_ver)); - lua_pushstring(lua, WCTOU8(server_hst)); - - return 2; -} - -int lua_search_unicode(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - - candidate = SearchUnicode(searchkey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_search_jisx0213(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - - candidate = SearchJISX0213(searchkey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_search_jisx0208(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - - candidate = SearchJISX0208(searchkey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_search_character_code(lua_State *lua) -{ - std::wstring candidate; - - if (lua_isstring(lua, 1)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - - candidate = SearchCharacterCode(searchkey); - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_complement(lua_State *lua) -{ - std::wstring candidate; - SKKDICCANDIDATES sc; - - if (lua_isstring(lua, 1)) - { - std::wstring searchkey = U8TOWC(lua_tostring(lua, 1)); - - SearchComplement(searchkey, sc); - - FORWARD_ITERATION_I(sc_itr, sc) - { - candidate += L"/" + MakeConcat(sc_itr->first); - } - if (!candidate.empty()) - { - candidate += L"/\n"; - } - } - - lua_pushstring(lua, WCTOU8(candidate)); - - return 1; -} - -int lua_add(lua_State *lua) -{ - if (lua_isboolean(lua, 1) && - lua_isstring(lua, 2) && - lua_isstring(lua, 3) && - lua_isstring(lua, 4) && - lua_isstring(lua, 5)) - { - int okuriari = lua_toboolean(lua, 1); - WCHAR command = (okuriari ? REQ_USER_ADD_A : REQ_USER_ADD_N); - std::wstring searchkey = U8TOWC(lua_tostring(lua, 2)); - std::wstring candidate = U8TOWC(lua_tostring(lua, 3)); - std::wstring annotation = U8TOWC(lua_tostring(lua, 4)); - std::wstring okuri = U8TOWC(lua_tostring(lua, 5)); - - AddUserDic(command, searchkey, candidate, annotation, okuri); - } - - return 0; -} - -int lua_delete(lua_State *lua) -{ - if (lua_isboolean(lua, 1) && - lua_isstring(lua, 2) && - lua_isstring(lua, 3)) - { - int okuriari = lua_toboolean(lua, 1); - WCHAR command = (okuriari ? REQ_USER_DEL_A : REQ_USER_DEL_N); - std::wstring searchkey = U8TOWC(lua_tostring(lua, 2)); - std::wstring candidate = U8TOWC(lua_tostring(lua, 3)); - - DelUserDic(command, searchkey, candidate); - } - - return 0; -} - -int lua_save(lua_State *lua) -{ - StartSaveUserDic(TRUE); - - return 0; -} diff --git a/imcrvmgr/SearchSKKServer.cpp b/imcrvmgr/SearchSKKServer.cpp index 506b1f2e..8730210b 100644 --- a/imcrvmgr/SearchSKKServer.cpp +++ b/imcrvmgr/SearchSKKServer.cpp @@ -1,5 +1,6 @@  #include "eucjis2004.h" +#include "eucjp.h" #include "utf8.h" #include "imcrvmgr.h" @@ -7,11 +8,10 @@ SOCKET skksocket = INVALID_SOCKET; std::wstring SearchSKKServer(const std::wstring &searchkey) { - std::wstring candidate; std::string key; - std::string buf; + std::wstring candidate; CHAR rbuf[RECVBUFSIZE]; - int n; + std::string buf; if (serv) { @@ -28,24 +28,33 @@ std::wstring SearchSKKServer(const std::wstring &searchkey) } key.push_back(SKK_REQ); + std::string skey; switch (encoding) { case 0: - buf = wstring_to_eucjis2004_string(searchkey); - if (!buf.empty()) + skey = wstring_to_eucjis2004_string(searchkey); + if (!skey.empty()) { - key += buf; + key += skey; } else { - return candidate; + skey = wstring_to_eucjp_string(searchkey); + if (!skey.empty()) + { + key += skey; + } + else + { + return candidate; + } } break; case 1: - buf = wstring_to_utf8_string(searchkey); - if (!buf.empty()) + skey = wstring_to_utf8_string(searchkey); + if (!skey.empty()) { - key += buf; + key += skey; } else { @@ -64,12 +73,10 @@ std::wstring SearchSKKServer(const std::wstring &searchkey) goto end; } - buf.clear(); - while (true) { ZeroMemory(rbuf, sizeof(rbuf)); - n = recv(skksocket, rbuf, sizeof(rbuf) - 1, 0); + int n = recv(skksocket, rbuf, sizeof(rbuf) - 1, 0); if (n == SOCKET_ERROR || n <= 0) { StartConnectSKKServer(); @@ -89,16 +96,21 @@ std::wstring SearchSKKServer(const std::wstring &searchkey) { std::string s; std::smatch m; - std::regex r; + static const std::regex r("/[^/]+"); + std::wstring c; s = buf.substr(1); - r.assign("/[^/]+"); while (std::regex_search(s, m, r)) { switch (encoding) { case 0: - candidate += eucjis2004_string_to_wstring(m.str()); + c = eucjis2004_string_to_wstring(m.str()); + if (c.empty()) + { + c = eucjp_string_to_wstring(m.str()); + } + candidate += c; break; case 1: candidate += utf8_string_to_wstring(m.str()); @@ -120,8 +132,8 @@ void ConnectSKKServer() ADDRINFOW *paiwResult; ADDRINFOW *paiw; u_long mode; - timeval tv; - fd_set fdw, fde; + timeval tv = {}; + fd_set fdw = {}, fde = {}; ADDRINFOW aiwHints = {}; aiwHints.ai_family = AF_UNSPEC; @@ -251,10 +263,6 @@ void CleanUpSKKServer() std::wstring GetSKKServerInfo(CHAR req) { std::wstring ret; - std::string sbuf; - std::string buf; - CHAR rbuf[RECVBUFSIZE]; - int n; if (serv) { @@ -276,17 +284,20 @@ std::wstring GetSKKServerInfo(CHAR req) } else { + CHAR rbuf[RECVBUFSIZE]; + std::string buf; + while (true) { ZeroMemory(rbuf, sizeof(rbuf)); - n = recv(skksocket, rbuf, sizeof(rbuf) - 1, 0); + int n = recv(skksocket, rbuf, sizeof(rbuf) - 1, 0); if (n == SOCKET_ERROR || n <= 0) { StartConnectSKKServer(); break; } - sbuf += rbuf; + buf += rbuf; if (rbuf[n - 1] == '\x20'/*SP*/) { @@ -297,10 +308,14 @@ std::wstring GetSKKServerInfo(CHAR req) switch (encoding) { case 0: - ret = eucjis2004_string_to_wstring(sbuf); + ret = eucjis2004_string_to_wstring(buf); + if (ret.empty()) + { + ret = eucjp_string_to_wstring(buf); + } break; case 1: - ret = utf8_string_to_wstring(sbuf); + ret = utf8_string_to_wstring(buf); break; default: break; diff --git a/imcrvmgr/SearchUserDictionary.cpp b/imcrvmgr/SearchUserDictionary.cpp index b1e6142a..4085e31f 100644 --- a/imcrvmgr/SearchUserDictionary.cpp +++ b/imcrvmgr/SearchUserDictionary.cpp @@ -6,13 +6,22 @@ //ユーザー辞書 SKKDIC userdic; +//ユーザー辞書送りブロック USEROKURI userokuri; //送りなし、補完あり KEYORDER keyorder_n; //送りあり、補完なし KEYORDER keyorder_a; -std::wstring SearchUserDic(const std::wstring &searchkey, const std::wstring &okuri) +//ユーザー辞書保存データ +typedef struct { + SKKDIC userdic; + USEROKURI userokuri; + KEYORDER keyorder_n; + KEYORDER keyorder_a; +} USERDATA; + +std::wstring SearchUserDic(const std::wstring &searchkey, const std::wstring &okuri) { std::wstring candidate; SKKDICCANDIDATES sc; @@ -33,7 +42,7 @@ std::wstring SearchUserDic(const std::wstring &searchkey, const std::wstring &o auto userokuri_itr = userokuri.find(searchkey); if (userokuri_itr != userokuri.end()) { - REVERSE_ITERATION_I(so_ritr, userokuri_itr->second.o) + REVERSE_ITERATION_I(so_ritr, userokuri_itr->second) { if (so_ritr->first == okuri) { @@ -115,8 +124,6 @@ void SearchComplement(const std::wstring &searchkey, SKKDICCANDIDATES &sc) void SearchComplementSearchCandidate(SKKDICCANDIDATES &sc, int max) { std::wstring candidate, conv; - std::wregex re(L"[\\x00-\\x19]"); - std::wstring fmt(L""); SKKDICCANDIDATES scc; if (max >= 9 || max <= 0) @@ -128,20 +135,23 @@ void SearchComplementSearchCandidate(SKKDICCANDIDATES &sc, int max) { candidate = SearchUserDic(sc_itr->first, L""); - candidate = std::regex_replace(candidate, re, fmt); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + candidate = std::regex_replace(candidate, rectrl, L""); scc.clear(); ParseSKKDicCandiate(candidate, scc); - int i = 0; + int cnt = 0; FORWARD_ITERATION_I(scc_itr, scc) { - if (max <= i++) + if (max <= cnt) { break; } + ++cnt; + conv = ConvertCandidate(sc_itr->first, scc_itr->first, L""); if (conv.empty()) { @@ -154,7 +164,7 @@ void SearchComplementSearchCandidate(SKKDICCANDIDATES &sc, int max) { sc_itr->second += L"/"; - if (i < (int)scc.size()) + if (cnt < (int)scc.size()) { sc_itr->second += L"…"; } @@ -162,6 +172,36 @@ void SearchComplementSearchCandidate(SKKDICCANDIDATES &sc, int max) } } +void SearchReverse(const std::wstring &candidate, std::wstring &key) +{ + EnterCriticalSection(&csUserData); // ! + + key.clear(); + + if (!keyorder_n.empty()) + { + REVERSE_ITERATION_I(keyorder_ritr, keyorder_n) + { + auto userdic_itr = userdic.find(*keyorder_ritr); + if (userdic_itr != userdic.end()) + { + REVERSE_ITERATION_I(candidate_ritr, userdic_itr->second) + { + if (candidate == candidate_ritr->first) + { + key = *keyorder_ritr; + break; + } + } + } + + if (!key.empty()) break; + } + } + + LeaveCriticalSection(&csUserData); // ! +} + void DelKeyOrder(const std::wstring &searchkey, KEYORDER &keyorder) { EnterCriticalSection(&csUserData); // ! @@ -195,7 +235,6 @@ void AddKeyOrder(const std::wstring &searchkey, KEYORDER &keyorder) void AddUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring &candidate, const std::wstring &annotation, const std::wstring &okuri) { SKKDICENTRY userdicentry; - std::wregex re; std::wstring candidate_esc; std::wstring annotation_esc; USEROKURIENTRY userokurientry; @@ -206,7 +245,8 @@ void AddUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring return; } - candidate_esc = MakeConcat(candidate); + candidate_esc = MakeConcat(EscapeGadgetString(candidate)); + annotation_esc = MakeConcat(annotation); EnterCriticalSection(&csUserData); // ! @@ -246,21 +286,21 @@ void AddUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring } //ユーザー辞書送りブロック - re.assign(L"[\\[\\]]"); //角括弧を含む候補を除外 - if (command == REQ_USER_ADD_A && !okuri.empty() && !std::regex_search(candidate_esc, re)) + static const std::wregex reblock(L"[\\[\\]]"); //角括弧を含む候補を除外 + if (command == REQ_USER_ADD_A && !okuri.empty() && !std::regex_search(candidate_esc, reblock)) { auto userokuri_itr = userokuri.find(searchkey); if (userokuri_itr == userokuri.end()) { okurics.push_back(std::make_pair(candidate_esc, std::wstring(L""))); userokurientry.first = searchkey; - userokurientry.second.o.push_back(std::make_pair(okuri, okurics)); + userokurientry.second.push_back(std::make_pair(okuri, okurics)); userokuri.insert(userokurientry); } else { bool hit_okuri = false; - FORWARD_ITERATION_I(so_itr, userokuri_itr->second.o) + FORWARD_ITERATION_I(so_itr, userokuri_itr->second) { if (so_itr->first == okuri) { @@ -282,9 +322,9 @@ void AddUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring } okurics = so_itr->second; - userokuri_itr->second.o.erase(so_itr); - userokuri_itr->second.o.push_back(std::make_pair(okuri, okurics)); - so_itr = userokuri_itr->second.o.begin(); + userokuri_itr->second.erase(so_itr); + userokuri_itr->second.push_back(std::make_pair(okuri, okurics)); + so_itr = userokuri_itr->second.begin(); hit_okuri = true; break; } @@ -292,7 +332,7 @@ void AddUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring if (!hit_okuri) { okurics.push_back(std::make_pair(candidate_esc, std::wstring(L""))); - userokuri_itr->second.o.push_back(std::make_pair(okuri, okurics)); + userokuri_itr->second.push_back(std::make_pair(okuri, okurics)); } } } @@ -344,7 +384,7 @@ void DelUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring auto userokuri_itr = userokuri.find(searchkey); if (userokuri_itr != userokuri.end()) { - FORWARD_ITERATION(so_itr, userokuri_itr->second.o) + FORWARD_ITERATION(so_itr, userokuri_itr->second) { FORWARD_ITERATION(sc_itr, so_itr->second) { @@ -359,14 +399,14 @@ void DelUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring } if (so_itr->second.empty()) { - so_itr = userokuri_itr->second.o.erase(so_itr); + so_itr = userokuri_itr->second.erase(so_itr); } else { ++so_itr; } } - if (userokuri_itr->second.o.empty()) + if (userokuri_itr->second.empty()) { userokuri.erase(userokuri_itr); } @@ -378,7 +418,7 @@ void DelUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring BOOL LoadUserDic() { BOOL ret = FALSE; - FILE *fp; + FILE *fp = nullptr; std::wstring key, empty; int okuri = -1; //-1:header / 1:okuri-ari entries. / 0:okuri-nasi entries. SKKDICCANDIDATES sc; @@ -394,7 +434,7 @@ BOOL LoadUserDic() EnterCriticalSection(&csUserDict); // ! - _wfopen_s(&fp, pathuserdic, RccsUTF8); //UTF-8 or UTF-16LE(with BOM) + _wfopen_s(&fp, pathuserdic, modeRccsUTF8); //UTF-8 or UTF-16LE(with BOM) if (fp == nullptr) { goto exit; @@ -402,7 +442,7 @@ BOOL LoadUserDic() while (true) { - int rl = ReadSKKDicLine(fp, BOM, okuri, key, sc, so); + int rl = ReadSKKDicLine(fp, enc_utf_8, okuri, key, sc, so); if (rl == -1) { //EOF @@ -532,7 +572,7 @@ BOOL LoadUserDic() if (!so.empty()) { userokurientry.first = key; - userokurientry.second.o = so; + userokurientry.second = so; userokuri.insert(userokurientry); } } @@ -585,7 +625,7 @@ void WriteUserDicEntry(FILE *fp, const std::wstring &key, const SKKDICCANDIDATES void SaveUserDic(USERDATA *userdata) { - FILE *fp; + FILE *fp = nullptr; SKKDICOKURIBLOCKS so; if (userdata == nullptr) @@ -595,7 +635,7 @@ void SaveUserDic(USERDATA *userdata) EnterCriticalSection(&csUserDict); // ! - _wfopen_s(&fp, pathuserdic, WccsUTF16); + _wfopen_s(&fp, pathuserdic, modeWccsUTF16); if (fp == nullptr) { goto exit; @@ -613,7 +653,7 @@ void SaveUserDic(USERDATA *userdata) auto userokuri_itr = userdata->userokuri.find(*keyorder_ritr); if (userokuri_itr != userdata->userokuri.end()) { - so = userokuri_itr->second.o; + so = userokuri_itr->second; } WriteUserDicEntry(fp, userdic_itr->first, userdic_itr->second, so); } @@ -641,7 +681,7 @@ void SaveUserDic(USERDATA *userdata) unsigned __stdcall SaveUserDicThread(void *p) { - USERDATA *userdata = (USERDATA *)p; + USERDATA *userdata = reinterpret_cast(p); if (userdata != nullptr) { @@ -719,22 +759,63 @@ void StartSaveUserDic(BOOL bThread) void BackUpUserDic() { - WCHAR oldpath[MAX_PATH]; - WCHAR newpath[MAX_PATH]; + WCHAR path[MAX_PATH] = {}; + LPCWSTR ext = L"bak"; EnterCriticalSection(&csUserDict); // ! - for (int i = BACKUP_GENS; i > 1; i--) + // バックアップディレクトリ作成 + + WCHAR drive[_MAX_DRIVE] = {}; + WCHAR dir[_MAX_DIR] = {}; + _wsplitpath_s(pathbackup, drive, _countof(drive), dir, _countof(dir), nullptr, 0, nullptr, 0); + _wmakepath_s(path, drive, dir, nullptr, nullptr); + SHCreateDirectoryExW(nullptr, path, nullptr); + + // バックアップ + + SYSTEMTIME st = {}; + GetSystemTime(&st); + + _snwprintf_s(path, _TRUNCATE, L"%s.%04d%02d%02dT%02d%02d%02dZ.%s", + pathbackup, + st.wYear, st.wMonth, st.wDay, + st.wHour, st.wMinute, st.wSecond, + ext); + + CopyFileW(pathuserdic, path, FALSE); + + // バックアップファイル検索 + + std::vector filenames; + WIN32_FIND_DATAW fd; + + _snwprintf_s(path, _TRUNCATE, L"%s.*.%s", pathbackup, ext); + + HANDLE hFind = FindFirstFileW(path, &fd); + if (hFind != INVALID_HANDLE_VALUE) { - _snwprintf_s(oldpath, _TRUNCATE, L"%s%d", pathuserbak, i - 1); - _snwprintf_s(newpath, _TRUNCATE, L"%s%d", pathuserbak, i); + filenames.push_back(fd.cFileName); - MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING); + while (FindNextFileW(hFind, &fd)) + { + filenames.push_back(fd.cFileName); + } + + FindClose(hFind); } - _snwprintf_s(newpath, _TRUNCATE, L"%s%d", pathuserbak, 1); + // 昇順ソート + std::sort(filenames.begin(), filenames.end()); + + // 古いバックアップファイルを削除 + int len = (int)filenames.size() - generation; + for (int i = 0; i < len; i++) + { + _wmakepath_s(path, drive, dir, filenames[i].c_str(), nullptr); - CopyFileW(pathuserdic, newpath, FALSE); + DeleteFileW(path); + } LeaveCriticalSection(&csUserDict); // ! } diff --git a/imcrvmgr/Server.cpp b/imcrvmgr/Server.cpp index 169e5cba..9dcfe15b 100644 --- a/imcrvmgr/Server.cpp +++ b/imcrvmgr/Server.cpp @@ -4,67 +4,26 @@ void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result) { - /* - request and reply commands - - search candidate - request "1\n\t\t\n" - reply "T\n\t\t\t\n...\n":hit - "F\n":nothing - search key for complement - request "4\n\t\t\n" - reply "T\n\t\t\t\n...\n":hit - "F\n":nothing - convert key - request "5\n\t\t\n" - reply "T\n\n...\n":hit - "F\n":nothing - convert candidate - request "6\n\t\t\n" - reply "T\n\n":hit - "F\n":nothing - add candidate (complement off) - request "A\n\t\t\t\n" - reply "T\n" - add candidate (complement on) - request "B\n\t\t\t\n" - reply "T\n" - delete candidate (complement off) - request "C\n\t\n" - reply "T\n" - delete candidate (complement on) - request "D\n\t\n" - reply "T\n" - save user dictionary - request "S\n" - reply "T\n" - create configuration dialog process - request "P\n" - reply "T\n" - caps lock - request "I\n" - reply "T\n" - kana lock - request "J\n" - reply "T\n" - */ - SKKDICCANDIDATES sc; - std::wstring fmt, key, keyorg, okuri, candidate, annotation, conv; - std::wregex re; + std::wstring key, keyorg, okuri, candidate, annotation, conv; + + // search, complement, convert key, convert candidate, reverse + static const std::wregex research(L"(.*)\t(.*)\t(.*)\n"); + // add candidate + static const std::wregex readd(L"(.*)\t(.*)\t(.*)\t(.*)\n"); + // delete candidate + static const std::wregex redel(L"(.*)\t(.*)\n"); result.clear(); switch (command) { case REQ_SEARCH: - re.assign(L"(.*)\t(.*)\t(.*)\n"); - fmt.assign(L"$1"); - key = std::regex_replace(argument, re, fmt); - fmt.assign(L"$2"); - keyorg = std::regex_replace(argument, re, fmt); - fmt.assign(L"$3"); - okuri = std::regex_replace(argument, re, fmt); + if (!std::regex_match(argument, research)) break; + + key = std::regex_replace(argument, research, L"$1"); + keyorg = std::regex_replace(argument, research, L"$2"); + okuri = std::regex_replace(argument, research, L"$3"); SearchDictionary(key, okuri, sc); @@ -88,11 +47,10 @@ void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result) break; case REQ_COMPLEMENT: - re.assign(L"(.*)\t(.*)\t(.*)\n"); - fmt.assign(L"$1"); - key = std::regex_replace(argument, re, fmt); - fmt.assign(L"$2"); - keyorg = std::regex_replace(argument, re, fmt); + if (!std::regex_match(argument, research)) break; + + key = std::regex_replace(argument, research, L"$1"); + keyorg = std::regex_replace(argument, research, L"$2"); if (lua != nullptr) { @@ -138,13 +96,11 @@ void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result) case REQ_CONVERTKEY: case REQ_CONVERTCND: - re.assign(L"(.*)\t(.*)\t(.*)\n"); - fmt.assign(L"$1"); - key = std::regex_replace(argument, re, fmt); - fmt.assign(L"$2"); - candidate = std::regex_replace(argument, re, fmt); - fmt.assign(L"$3"); - okuri = std::regex_replace(argument, re, fmt); + if (!std::regex_match(argument, research)) break; + + key = std::regex_replace(argument, research, L"$1"); + candidate = std::regex_replace(argument, research, L"$2"); + okuri = std::regex_replace(argument, research, L"$3"); switch (command) { @@ -171,17 +127,53 @@ void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result) } break; + case REQ_REVERSE: + if (!std::regex_match(argument, research)) break; + + candidate = std::regex_replace(argument, research, L"$1"); + + result = REP_OK; + + if (lua != nullptr) + { + lua_getglobal(lua, u8"lua_skk_reverse"); + lua_pushstring(lua, WCTOU8(candidate)); + + if (lua_pcall(lua, 1, 1, 0) == LUA_OK) + { + if (lua_isstring(lua, -1)) + { + key = U8TOWC(lua_tostring(lua, -1)); + } + lua_pop(lua, 1); + } + } + else + { + SearchReverse(candidate, key); + } + + if (!key.empty()) + { + result = REP_OK; + result += L"\n"; + result += L"\t" + key + L"\t\t\n"; + } + else + { + result = REP_FALSE; + result += L"\n"; + } + break; + case REQ_USER_ADD_A: case REQ_USER_ADD_N: - re.assign(L"(.*)\t(.*)\t(.*)\t(.*)\n"); - fmt.assign(L"$1"); - key = std::regex_replace(argument, re, fmt); - fmt.assign(L"$2"); - candidate = std::regex_replace(argument, re, fmt); - fmt.assign(L"$3"); - annotation = std::regex_replace(argument, re, fmt); - fmt.assign(L"$4"); - okuri = std::regex_replace(argument, re, fmt); + if (!std::regex_match(argument, readd)) break; + + key = std::regex_replace(argument, readd, L"$1"); + candidate = std::regex_replace(argument, readd, L"$2"); + annotation = std::regex_replace(argument, readd, L"$3"); + okuri = std::regex_replace(argument, readd, L"$4"); result = REP_OK; @@ -209,11 +201,10 @@ void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result) case REQ_USER_DEL_A: case REQ_USER_DEL_N: - re.assign(L"(.*)\t(.*)\n"); - fmt.assign(L"$1"); - key = std::regex_replace(argument, re, fmt); - fmt.assign(L"$2"); - candidate = std::regex_replace(argument, re, fmt); + if (!std::regex_match(argument, redel)) break; + + key = std::regex_replace(argument, redel, L"$1"); + candidate = std::regex_replace(argument, redel, L"$2"); result = REP_OK; @@ -272,6 +263,21 @@ void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result) result += L"\n"; break; + case REQ_BACKUP: + StartSaveUserDic(FALSE); + BackUpUserDic(); + + result = REP_OK; + result += L"\n"; + break; + + case REQ_EXIT: + SendMessageW(hWndMgr, WM_CLOSE, 0, 0); + + result = REP_OK; + result += L"\n"; + break; + default: result = REP_FALSE; result += L"\n"; @@ -284,7 +290,7 @@ unsigned __stdcall SrvThread(void *p) HANDLE hPipe = (HANDLE)p; DWORD bytesRead, bytesWrite; BOOL bRet; - WCHAR command; + WCHAR command = L'\0'; std::wstring argument; std::wstring wspipebuf; @@ -329,13 +335,36 @@ unsigned __stdcall SrvThread(void *p) ZeroMemory(pipebuf, sizeof(WCHAR) * PIPEBUFSIZE); bytesRead = 0; - bRet = ReadFile(hPipe, pipebuf, sizeof(WCHAR) * PIPEBUFSIZE, &bytesRead, nullptr); + bRet = ReadFile(hPipe, pipebuf, sizeof(WCHAR) * (PIPEBUFSIZE - 1), &bytesRead, nullptr); if (bRet == FALSE || bytesRead == 0) { DisconnectNamedPipe(hPipe); continue; } +#ifdef _DEBUG + EnterCriticalSection(&csEdit); // ! + + if (dedit.size() > SHRT_MAX) dedit.clear(); + + switch (command) + { + case REQ_USER_SAVE: + dedit.clear(); + break; + default: + break; + } + + LeaveCriticalSection(&csEdit); // ! +#endif + + command = pipebuf[0]; + if (pipebuf[1] != L'\n') command = L'\0'; + argument.assign(&pipebuf[2]); + + wspipebuf.clear(); + #ifdef _DEBUG tedit.assign(pipebuf); re.assign(L"\n"); @@ -345,13 +374,14 @@ unsigned __stdcall SrvThread(void *p) fmt.assign(L"»\u00A0"); tedit = std::regex_replace(tedit, re, fmt); + EnterCriticalSection(&csEdit); // ! + dedit.append(tedit); - SetWindowTextW(hWndEdit, dedit.c_str()); -#endif - command = pipebuf[0]; - argument.assign(&pipebuf[2]); - wspipebuf.clear(); + LeaveCriticalSection(&csEdit); // ! + + PostMessageW(hWndMgr, WM_USER_SETTEXT, (WPARAM)hWndEdit, (LPARAM)dedit.c_str()); +#endif SrvProc(command, argument, wspipebuf); @@ -366,18 +396,13 @@ unsigned __stdcall SrvThread(void *p) fmt.assign(L"»\u00A0"); tedit = std::regex_replace(tedit, re, fmt); + EnterCriticalSection(&csEdit); // ! + dedit.append(tedit); - SetWindowTextW(hWndEdit, dedit.c_str()); - SendMessageW(hWndEdit, WM_VSCROLL, SB_BOTTOM, 0); - switch (command) - { - case REQ_USER_SAVE: - dedit.clear(); - break; - default: - break; - } + LeaveCriticalSection(&csEdit); // ! + + PostMessageW(hWndMgr, WM_USER_SETTEXT, (WPARAM)hWndEdit, (LPARAM)dedit.c_str()); #endif bytesWrite = (DWORD)((wcslen(pipebuf) + 1) * sizeof(WCHAR)); @@ -399,8 +424,8 @@ unsigned __stdcall SrvThread(void *p) HANDLE SrvStart() { - PSECURITY_DESCRIPTOR psd; - SECURITY_ATTRIBUTES sa; + PSECURITY_DESCRIPTOR psd = nullptr; + SECURITY_ATTRIBUTES sa = {}; HANDLE hPipe = INVALID_HANDLE_VALUE; HANDLE hThread = nullptr; @@ -429,3 +454,102 @@ HANDLE SrvStart() return hThread; } + +/* + request and reply commands + + search candidate + request + "1\n\t\t\n" + reply + "T\n\t\t\t\n...\n":hit + "F\n":nothing + + search key for complement + request + "4\n\t\t\n" + reply + "T\n\t\t\t\n...\n" : hit + "F\n" : nothing + + convert key + request + "5\n\t\t\n" + reply + "T\n\n...\n" : hit + "F\n" : nothing + + convert candidate + request + "6\n\t\t\n" + reply + "T\n\n" : hit + "F\n" : nothing + + reverse + request + "7\n\t\t\n" + reply + "T\n\t\t\t\n" : hit + "F\n" : nothing + + add candidate (complement off) + request + "A\n\t\t\t\n" + reply + "T\n" + + add candidate (complement on) + request + "B\n\t\t\t\n" + reply + "T\n" + + delete candidate (complement off) + request + "C\n\t\n" + reply + "T\n" + + delete candidate (complement on) + request + "D\n\t\n" + reply + "T\n" + + save user dictionary + request + "S\n" + reply + "T\n" + + create configuration dialog process + request + "P\n" + reply + "T\n" + + caps lock + request + "I\n" + reply + "T\n" + + kana lock + request + "J\n" + reply + "T\n" + + backup + request + "R\n" + reply + "T\n" + + exit + request + "X\n" + reply + "T\n" +*/ diff --git a/imcrvmgr/cpp.hint b/imcrvmgr/cpp.hint new file mode 100644 index 00000000..8660b6f3 --- /dev/null +++ b/imcrvmgr/cpp.hint @@ -0,0 +1,5 @@ +// common.h +#define FORWARD_ITERATION_I(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ++(iterator)) +#define FORWARD_ITERATION(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ) +#define REVERSE_ITERATION_I(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ++(reverse_iterator)) +#define REVERSE_ITERATION(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ) diff --git a/imcrvmgr/imcrvmgr.cpp b/imcrvmgr/imcrvmgr.cpp index ca2387e9..69cc1c96 100644 --- a/imcrvmgr/imcrvmgr.cpp +++ b/imcrvmgr/imcrvmgr.cpp @@ -10,7 +10,9 @@ CRITICAL_SECTION csSKKSocket; BOOL bUserDicChg; FILETIME ftConfig = {}; FILETIME ftSKKDic = {}; +HWND hWndMgr; #ifdef _DEBUG +CRITICAL_SECTION csEdit; HWND hWndEdit; HFONT hFont; #endif @@ -20,7 +22,7 @@ HANDLE hThreadSrv; BOOL bSrvThreadExit; lua_State *lua; -int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) +int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { MSG msg; HWND hWnd; @@ -46,7 +48,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.hInstance = hInst; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.hCursor = LoadCursorW(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = DictionaryManagerClass; RegisterClassExW(&wc); @@ -66,6 +68,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd return 0; } + hWndMgr = hWnd; + #ifdef _DEBUG ShowWindow(hWnd, SW_MINIMIZE); #else @@ -75,11 +79,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd while (GetMessageW(&msg, nullptr, 0, 0)) { - if (!TranslateAcceleratorW(msg.hwnd, nullptr, &msg)) - { - TranslateMessage(&msg); - DispatchMessageW(&msg); - } + TranslateMessage(&msg); + DispatchMessageW(&msg); } ReleaseMutex(hMutex); @@ -92,6 +93,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HANDLE hPipe; WSADATA wsaData; + int wsa = -1; #ifdef _DEBUG RECT r = {}; HDC hDC; @@ -113,7 +115,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) SendMessageW(hWndEdit, WM_SETFONT, (WPARAM)hFont, 0); ReleaseDC(nullptr, hDC); #endif - WSAStartup(WINSOCK_VERSION, &wsaData); + wsa = WSAStartup(WINSOCK_VERSION, &wsaData); + switch (wsa) + { + case 0: + //success + break; + case WSASYSNOTREADY: + case WSAVERNOTSUPPORTED: + case WSAEINPROGRESS: + case WSAEPROCLIM: + case WSAEFAULT: + default: + //error + break; + } CreateConfigPath(); UpdateConfigPath(); @@ -122,6 +138,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) InitializeCriticalSection(&csUserData); // ! InitializeCriticalSection(&csSaveUserDic); // ! InitializeCriticalSection(&csSKKSocket); // ! +#ifdef _DEBUG + InitializeCriticalSection(&csEdit); // ! +#endif if (IsFileModified(pathconfigxml, &ftConfig)) { @@ -151,6 +170,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) GetClientRect(hWnd, &r); MoveWindow(hWndEdit, 0, 0, r.right, r.bottom, TRUE); break; + + case WM_USER_SETTEXT: + EnterCriticalSection(&csEdit); // ! + SetWindowTextW((HWND)wParam, (LPCWSTR)lParam); + LeaveCriticalSection(&csEdit); // ! + SendMessageW((HWND)wParam, WM_VSCROLL, SB_BOTTOM, 0); + break; #endif case WM_POWERBROADCAST: @@ -158,6 +184,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { StartSaveUserDic(FALSE); + if (IsFileModified(pathconfigxml, &ftConfig)) + { + LoadConfig(TRUE); + } + BackUpUserDic(); } break; @@ -193,6 +224,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (message == WM_ENDSESSION) { + if (IsFileModified(pathconfigxml, &ftConfig)) + { + LoadConfig(TRUE); + } + BackUpUserDic(); } diff --git a/imcrvmgr/imcrvmgr.h b/imcrvmgr/imcrvmgr.h index 6f5bba37..a3738bd6 100644 --- a/imcrvmgr/imcrvmgr.h +++ b/imcrvmgr/imcrvmgr.h @@ -4,22 +4,30 @@ #include "parseskkdic.h" #include "lua.hpp" -typedef struct { - SKKDIC userdic; - USEROKURI userokuri; - KEYORDER keyorder_n; - KEYORDER keyorder_a; -} USERDATA; - // ConfigMgr void CreateConfigPath(); void UpdateConfigPath(); void CreateIpcName(); -void LoadConfig(); +void LoadConfig(BOOL sysexit = FALSE); BOOL IsFileModified(LPCWSTR path, FILETIME *ft); void InitLua(); void UninitLua(); +// lcrvmgr +int lua_search_skk_dictionary(lua_State *L); +int lua_search_user_dictionary(lua_State *L); +int lua_search_skk_server(lua_State *L); +int lua_search_skk_server_info(lua_State *L); +int lua_search_unicode(lua_State *L); +int lua_search_jisx0213(lua_State *L); +int lua_search_jisx0208(lua_State *L); +int lua_search_character_code(lua_State *L); +int lua_complement(lua_State *L); +int lua_reverse(lua_State *L); +int lua_add(lua_State *L); +int lua_delete(lua_State *L); +int lua_save(lua_State *L); + // SearchCharacter std::wstring SearchUnicode(const std::wstring &searchkey); std::wstring SearchJISX0213(const std::wstring &searchkey); @@ -33,23 +41,12 @@ std::wstring SearchSKKDic(const std::wstring &searchkey, const std::wstring &oku void MakeSKKDicPos(); std::wstring ConvertKey(const std::wstring &searchkey, const std::wstring &okuri); std::wstring ConvertCandidate(const std::wstring &searchkey, const std::wstring &candidate, const std::wstring &okuri); -int lua_search_skk_dictionary(lua_State *lua); -int lua_search_user_dictionary(lua_State *lua); -int lua_search_skk_server(lua_State *lua); -int lua_search_skk_server_info(lua_State *lua); -int lua_search_unicode(lua_State *lua); -int lua_search_jisx0213(lua_State *lua); -int lua_search_jisx0208(lua_State *lua); -int lua_search_character_code(lua_State *lua); -int lua_complement(lua_State *lua); -int lua_add(lua_State *lua); -int lua_delete(lua_State *lua); -int lua_save(lua_State *lua); // SearchUserDictionary std::wstring SearchUserDic(const std::wstring &searchkey, const std::wstring &okuri); void SearchComplement(const std::wstring &searchkey, SKKDICCANDIDATES &sc); void SearchComplementSearchCandidate(SKKDICCANDIDATES &sc, int max); +void SearchReverse(const std::wstring &candidate, std::wstring &key); void AddUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring &candidate, const std::wstring &annotation, const std::wstring &okuri); void DelUserDic(WCHAR command, const std::wstring &searchkey, const std::wstring &candidate); BOOL LoadUserDic(); @@ -73,8 +70,6 @@ HANDLE SrvStart(); //server #define SKK_HIT '1' -#define BACKUP_GENS 3 - extern CRITICAL_SECTION csUserDict; extern CRITICAL_SECTION csUserData; extern CRITICAL_SECTION csSaveUserDic; @@ -82,7 +77,10 @@ extern CRITICAL_SECTION csSKKSocket; extern BOOL bUserDicChg; extern FILETIME ftConfig; extern FILETIME ftSKKDic; +extern HWND hWndMgr; #ifdef _DEBUG +#define WM_USER_SETTEXT (WM_USER + 1) +extern CRITICAL_SECTION csEdit; extern HWND hWndEdit; extern HFONT hFont; #endif @@ -98,13 +96,20 @@ extern LPCWSTR DictionaryManagerClass; // ファイルパス extern WCHAR pathconfigxml[MAX_PATH]; //設定 extern WCHAR pathuserdic[MAX_PATH]; //ユーザー辞書 -extern WCHAR pathuserbak[MAX_PATH]; //ユーザー辞書バックアッププレフィックス extern WCHAR pathskkdic[MAX_PATH]; //取込SKK辞書 extern WCHAR pathinitlua[MAX_PATH]; //init.lua +extern WCHAR pathbackup[MAX_PATH]; //ユーザー辞書バックアップレフィックス -extern WCHAR krnlobjsddl[MAX_KRNLOBJNAME]; //SDDL -extern WCHAR mgrpipename[MAX_KRNLOBJNAME]; //名前付きパイプ -extern WCHAR mgrmutexname[MAX_KRNLOBJNAME]; //ミューテックス +extern WCHAR radconfigxml[MAX_PATH]; //設定 FOLDERID_RoamingAppData +extern WCHAR sysconfigxml[MAX_PATH]; //設定 FOLDERID_Windows\IME +extern INT csidlconfigxml; //設定 CSIDL_APPDATA/CSIDL_WINDOWS +extern WCHAR radskkdic[MAX_PATH]; //取込SKK辞書 FOLDERID_RoamingAppData +extern WCHAR sysskkdic[MAX_PATH]; //取込SKK辞書 FOLDERID_Windows\IME +extern INT csidlskkdic; //取込SKK辞書 CSIDL_APPDATA/CSIDL_WINDOWS + +extern WCHAR krnlobjsddl[MAX_SECURITYDESC]; //SDDL +extern WCHAR mgrpipename[MAX_PIPENAME]; //名前付きパイプ +extern WCHAR mgrmutexname[MAX_PATH]; //ミューテックス // 辞書サーバー設定 extern BOOL serv; //SKK辞書サーバーを使用する @@ -113,5 +118,7 @@ extern WCHAR port[MAX_SKKSERVER_PORT]; //ポート extern DWORD encoding; //エンコーディング extern DWORD timeout; //タイムアウト +extern INT generation; //ユーザー辞書バックアップ世代数 + extern BOOL precedeokuri; //送り仮名が一致した候補を優先する extern BOOL compincback; //前方一致と後方一致で補完する diff --git a/imcrvmgr/imcrvmgr.vcxproj b/imcrvmgr/imcrvmgr.vcxproj index fcfaf461..5da4fe6c 100644 --- a/imcrvmgr/imcrvmgr.vcxproj +++ b/imcrvmgr/imcrvmgr.vcxproj @@ -1,14 +1,6 @@  - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + {289FD85F-FCDB-413D-BBF3-997583DF0FEE} @@ -44,122 +36,93 @@ Application true - v142 + v143 Unicode Application true - v142 - Unicode - - - Application - true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 - true - Unicode - - - Application - false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode - + - - - - + - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ @@ -168,15 +131,16 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) true true + pch.h Windows true - lua53.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) + lua54.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) @@ -195,42 +159,16 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) true true + pch.h Windows true - lua53.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - - - $(SolutionDir)common;%(AdditionalIncludeDirectories) - 0x0411 - /c 65001 - - - imcrvmgr.manifest %(AdditionalManifestFiles) - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - stdafx.h - $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) - true - true - - - Windows - true - lua53.lib;common.lib;ws2_32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + lua54.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) @@ -249,15 +187,16 @@ Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) true true + pch.h Windows true - lua53.lib;common.lib;ws2_32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + lua54.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) @@ -278,20 +217,22 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) true true Guard + pch.h Windows true true - lua53.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) + lua54.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration + true $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -311,53 +252,22 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) true true Guard + pch.h Windows true true - lua53.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - No - UseLinkTimeCodeGeneration - - - $(SolutionDir)common;%(AdditionalIncludeDirectories) - 0x0411 - /c 65001 - - - imcrvmgr.manifest %(AdditionalManifestFiles) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - stdafx.h - $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) - true - true - Guard - - - Windows - true - true - lua53.lib;common.lib;ws2_32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + lua54.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration + true $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -377,17 +287,18 @@ true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) $(SolutionDir)common;$(SolutionDir)liblua;%(AdditionalIncludeDirectories) true true Guard + pch.h Windows true true - lua53.lib;common.lib;ws2_32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + lua54.lib;common.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration @@ -403,24 +314,23 @@ - + + + - - + Create Create - Create Create Create Create - Create Create @@ -430,6 +340,9 @@ + + + diff --git a/imcrvmgr/imcrvmgr.vcxproj.filters b/imcrvmgr/imcrvmgr.vcxproj.filters index e018f5ed..496c3bf7 100644 --- a/imcrvmgr/imcrvmgr.vcxproj.filters +++ b/imcrvmgr/imcrvmgr.vcxproj.filters @@ -15,7 +15,7 @@ - + Header Files @@ -23,12 +23,15 @@ - + Source Files Source Files + + Source Files + Source Files @@ -58,4 +61,7 @@ Resource Files + + + \ No newline at end of file diff --git a/imcrvmgr/lcrvmgr.cpp b/imcrvmgr/lcrvmgr.cpp new file mode 100644 index 00000000..9a36ffc4 --- /dev/null +++ b/imcrvmgr/lcrvmgr.cpp @@ -0,0 +1,218 @@ + +#include "utf8.h" +#include "imcrvmgr.h" + +int lua_search_skk_dictionary(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1) && + lua_isstring(L, 2)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + std::wstring okurikey = U8TOWC(lua_tostring(L, 2)); + + candidate = SearchSKKDic(searchkey, okurikey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_search_user_dictionary(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1) && + lua_isstring(L, 2)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + std::wstring okurikey = U8TOWC(lua_tostring(L, 2)); + + candidate = SearchUserDic(searchkey, okurikey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_search_skk_server(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + + candidate = SearchSKKServer(searchkey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_search_skk_server_info(lua_State *L) +{ + std::wstring server_ver = GetSKKServerInfo(SKK_VER); + std::wstring server_hst = GetSKKServerInfo(SKK_HST); + + lua_pushstring(L, WCTOU8(server_ver)); + lua_pushstring(L, WCTOU8(server_hst)); + + return 2; +} + +int lua_search_unicode(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + + candidate = SearchUnicode(searchkey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_search_jisx0213(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + + candidate = SearchJISX0213(searchkey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_search_jisx0208(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + + candidate = SearchJISX0208(searchkey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_search_character_code(lua_State *L) +{ + std::wstring candidate; + + if (lua_isstring(L, 1)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + + candidate = SearchCharacterCode(searchkey); + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_complement(lua_State *L) +{ + std::wstring candidate; + SKKDICCANDIDATES sc; + + if (lua_isstring(L, 1)) + { + std::wstring searchkey = U8TOWC(lua_tostring(L, 1)); + + SearchComplement(searchkey, sc); + + FORWARD_ITERATION_I(sc_itr, sc) + { + candidate += L"/" + MakeConcat(sc_itr->first); + } + + if (!candidate.empty()) + { + candidate += L"/\n"; + } + } + + lua_pushstring(L, WCTOU8(candidate)); + + return 1; +} + +int lua_reverse(lua_State *L) +{ + std::wstring key; + + if (lua_isstring(L, 1)) + { + std::wstring candidate = U8TOWC(lua_tostring(L, 1)); + + SearchReverse(candidate, key); + } + + lua_pushstring(L, WCTOU8(key)); + + return 1; +} + +int lua_add(lua_State *L) +{ + if (lua_isboolean(L, 1) && + lua_isstring(L, 2) && + lua_isstring(L, 3) && + lua_isstring(L, 4) && + lua_isstring(L, 5)) + { + int okuriari = lua_toboolean(L, 1); + WCHAR command = (okuriari ? REQ_USER_ADD_A : REQ_USER_ADD_N); + std::wstring searchkey = U8TOWC(lua_tostring(L, 2)); + std::wstring candidate = U8TOWC(lua_tostring(L, 3)); + std::wstring annotation = U8TOWC(lua_tostring(L, 4)); + std::wstring okuri = U8TOWC(lua_tostring(L, 5)); + + AddUserDic(command, searchkey, candidate, annotation, okuri); + } + + return 0; +} + +int lua_delete(lua_State *L) +{ + if (lua_isboolean(L, 1) && + lua_isstring(L, 2) && + lua_isstring(L, 3)) + { + int okuriari = lua_toboolean(L, 1); + WCHAR command = (okuriari ? REQ_USER_DEL_A : REQ_USER_DEL_N); + std::wstring searchkey = U8TOWC(lua_tostring(L, 2)); + std::wstring candidate = U8TOWC(lua_tostring(L, 3)); + + DelUserDic(command, searchkey, candidate); + } + + return 0; +} + +int lua_save(lua_State *L) +{ + StartSaveUserDic(TRUE); + + return 0; +} diff --git a/imcrvmgr/pch.cpp b/imcrvmgr/pch.cpp new file mode 100644 index 00000000..af0744ae --- /dev/null +++ b/imcrvmgr/pch.cpp @@ -0,0 +1 @@ + diff --git a/imcrvmgr/stdafx.h b/imcrvmgr/pch.h similarity index 89% rename from imcrvmgr/stdafx.h rename to imcrvmgr/pch.h index c9bd3694..03dcd4d6 100644 --- a/imcrvmgr/stdafx.h +++ b/imcrvmgr/pch.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/imcrvmgr/stdafx.cpp b/imcrvmgr/stdafx.cpp deleted file mode 100644 index 7438ada7..00000000 --- a/imcrvmgr/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -// nothing diff --git a/imcrvskk.sln b/imcrvskk.sln index 62a3fce7..27af2f65 100644 --- a/imcrvskk.sln +++ b/imcrvskk.sln @@ -1,10 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29025.244 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34003.232 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\installer.vcxproj", "{C65505E2-5456-473C-91B1-C6D91B294DC3}" ProjectSection(ProjectDependencies) = postProject + {1E93D511-25BF-4CCF-93E5-DA44F66016AB} = {1E93D511-25BF-4CCF-93E5-DA44F66016AB} {56319425-6482-41CF-8B63-BC33D6EEBB52} = {56319425-6482-41CF-8B63-BC33D6EEBB52} {AB342A30-9A85-497B-8C03-7A95AB3DC9AA} = {AB342A30-9A85-497B-8C03-7A95AB3DC9AA} {EB999F4D-AD29-4049-BCCB-FABFD01DFC97} = {EB999F4D-AD29-4049-BCCB-FABFD01DFC97} @@ -15,6 +16,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\inst EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imcrvtip", "imcrvtip\imcrvtip.vcxproj", "{740F50A9-EA25-4FFB-890D-57D53FD6F026}" + ProjectSection(ProjectDependencies) = postProject + {1E93D511-25BF-4CCF-93E5-DA44F66016AB} = {1E93D511-25BF-4CCF-93E5-DA44F66016AB} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imcrvmgr", "imcrvmgr\imcrvmgr.vcxproj", "{289FD85F-FCDB-413D-BBF3-997583DF0FEE}" ProjectSection(ProjectDependencies) = postProject @@ -46,14 +50,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imcrvmgr_test", "test\imcrv {EB999F4D-AD29-4049-BCCB-FABFD01DFC97} = {EB999F4D-AD29-4049-BCCB-FABFD01DFC97} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libinput", "libinput\libinput.vcxproj", "{1E93D511-25BF-4CCF-93E5-DA44F66016AB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM Debug|ARM64 = Debug|ARM64 + Debug|ARM64EC = Debug|ARM64EC Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|ARM = Release|ARM Release|ARM64 = Release|ARM64 + Release|ARM64EC = Release|ARM64EC Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection @@ -62,6 +70,8 @@ Global {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|ARM.Build.0 = Debug|ARM {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|ARM64.ActiveCfg = Debug|ARM64 {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|ARM64.Build.0 = Debug|ARM64 + {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC + {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|ARM64EC.Build.0 = Debug|ARM64EC {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|x64.ActiveCfg = Debug|x64 {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|x64.Build.0 = Debug|x64 {C65505E2-5456-473C-91B1-C6D91B294DC3}.Debug|x86.ActiveCfg = Debug|Win32 @@ -70,6 +80,8 @@ Global {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|ARM.Build.0 = Release|ARM {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|ARM64.ActiveCfg = Release|ARM64 {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|ARM64.Build.0 = Release|ARM64 + {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|ARM64EC.ActiveCfg = Release|ARM64EC + {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|ARM64EC.Build.0 = Release|ARM64EC {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|x64.ActiveCfg = Release|x64 {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|x64.Build.0 = Release|x64 {C65505E2-5456-473C-91B1-C6D91B294DC3}.Release|x86.ActiveCfg = Release|Win32 @@ -77,7 +89,8 @@ Global {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|ARM.ActiveCfg = Debug|ARM {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|ARM.Build.0 = Debug|ARM {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|ARM64.Build.0 = Debug|ARM64 + {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC + {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|ARM64EC.Build.0 = Debug|ARM64EC {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|x64.ActiveCfg = Debug|x64 {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|x64.Build.0 = Debug|x64 {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Debug|x86.ActiveCfg = Debug|Win32 @@ -85,103 +98,136 @@ Global {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|ARM.ActiveCfg = Release|ARM {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|ARM.Build.0 = Release|ARM {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|ARM64.ActiveCfg = Release|ARM64 - {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|ARM64.Build.0 = Release|ARM64 + {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|ARM64EC.ActiveCfg = Release|ARM64EC + {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|ARM64EC.Build.0 = Release|ARM64EC {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|x64.ActiveCfg = Release|x64 {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|x64.Build.0 = Release|x64 {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|x86.ActiveCfg = Release|Win32 {740F50A9-EA25-4FFB-890D-57D53FD6F026}.Release|x86.Build.0 = Release|Win32 - {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|ARM.ActiveCfg = Debug|ARM + {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|ARM.ActiveCfg = Debug|ARM64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|ARM64.ActiveCfg = Debug|ARM64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|ARM64.Build.0 = Debug|ARM64 + {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|x64.ActiveCfg = Debug|x64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|x64.Build.0 = Debug|x64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|x86.ActiveCfg = Debug|Win32 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Debug|x86.Build.0 = Debug|Win32 - {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|ARM.ActiveCfg = Release|ARM + {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|ARM.ActiveCfg = Release|ARM64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|ARM64.ActiveCfg = Release|ARM64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|ARM64.Build.0 = Release|ARM64 + {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|ARM64EC.ActiveCfg = Release|ARM64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|x64.ActiveCfg = Release|x64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|x64.Build.0 = Release|x64 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|x86.ActiveCfg = Release|Win32 {289FD85F-FCDB-413D-BBF3-997583DF0FEE}.Release|x86.Build.0 = Release|Win32 - {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|ARM.ActiveCfg = Debug|ARM + {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|ARM.ActiveCfg = Debug|ARM64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|ARM64.ActiveCfg = Debug|ARM64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|ARM64.Build.0 = Debug|ARM64 + {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|x64.ActiveCfg = Debug|x64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|x64.Build.0 = Debug|x64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|x86.ActiveCfg = Debug|Win32 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Debug|x86.Build.0 = Debug|Win32 - {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|ARM.ActiveCfg = Release|ARM + {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|ARM.ActiveCfg = Release|ARM64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|ARM64.ActiveCfg = Release|ARM64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|ARM64.Build.0 = Release|ARM64 + {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|ARM64EC.ActiveCfg = Release|ARM64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|x64.ActiveCfg = Release|x64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|x64.Build.0 = Release|x64 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|x86.ActiveCfg = Release|Win32 {56319425-6482-41CF-8B63-BC33D6EEBB52}.Release|x86.Build.0 = Release|Win32 - {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|ARM.ActiveCfg = Debug|ARM + {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|ARM.ActiveCfg = Debug|ARM64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|ARM64.ActiveCfg = Debug|ARM64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|ARM64.Build.0 = Debug|ARM64 + {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|x64.ActiveCfg = Debug|x64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|x64.Build.0 = Debug|x64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|x86.ActiveCfg = Debug|Win32 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Debug|x86.Build.0 = Debug|Win32 - {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|ARM.ActiveCfg = Release|ARM + {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|ARM.ActiveCfg = Release|ARM64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|ARM64.ActiveCfg = Release|ARM64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|ARM64.Build.0 = Release|ARM64 + {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|ARM64EC.ActiveCfg = Release|ARM64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|x64.ActiveCfg = Release|x64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|x64.Build.0 = Release|x64 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|x86.ActiveCfg = Release|Win32 {EB999F4D-AD29-4049-BCCB-FABFD01DFC97}.Release|x86.Build.0 = Release|Win32 - {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|ARM.ActiveCfg = Debug|ARM + {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|ARM.ActiveCfg = Debug|ARM64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|ARM64.ActiveCfg = Debug|ARM64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|ARM64.Build.0 = Debug|ARM64 + {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|x64.ActiveCfg = Debug|x64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|x64.Build.0 = Debug|x64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|x86.ActiveCfg = Debug|Win32 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Debug|x86.Build.0 = Debug|Win32 - {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|ARM.ActiveCfg = Release|ARM + {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|ARM.ActiveCfg = Release|ARM64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|ARM64.ActiveCfg = Release|ARM64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|ARM64.Build.0 = Release|ARM64 + {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|ARM64EC.ActiveCfg = Release|ARM64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|x64.ActiveCfg = Release|x64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|x64.Build.0 = Release|x64 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|x86.ActiveCfg = Release|Win32 {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51}.Release|x86.Build.0 = Release|Win32 - {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|ARM.ActiveCfg = Debug|ARM + {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|ARM.ActiveCfg = Debug|ARM64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|ARM64.ActiveCfg = Debug|ARM64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|ARM64.Build.0 = Debug|ARM64 + {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|x64.ActiveCfg = Debug|x64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|x64.Build.0 = Debug|x64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|x86.ActiveCfg = Debug|Win32 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Debug|x86.Build.0 = Debug|Win32 - {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|ARM.ActiveCfg = Release|ARM + {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|ARM.ActiveCfg = Release|ARM64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|ARM64.ActiveCfg = Release|ARM64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|ARM64.Build.0 = Release|ARM64 + {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|ARM64EC.ActiveCfg = Release|ARM64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|x64.ActiveCfg = Release|x64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|x64.Build.0 = Release|x64 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|x86.ActiveCfg = Release|Win32 {34405AB3-7404-4118-870E-EE572DB3F7B1}.Release|x86.Build.0 = Release|Win32 - {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|ARM.ActiveCfg = Debug|ARM + {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|ARM.ActiveCfg = Debug|ARM64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|ARM64.ActiveCfg = Debug|ARM64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|ARM64.Build.0 = Debug|ARM64 + {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|x64.ActiveCfg = Debug|x64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|x64.Build.0 = Debug|x64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|x86.ActiveCfg = Debug|Win32 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Debug|x86.Build.0 = Debug|Win32 - {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|ARM.ActiveCfg = Release|ARM + {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|ARM.ActiveCfg = Release|ARM64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|ARM64.ActiveCfg = Release|ARM64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|ARM64.Build.0 = Release|ARM64 + {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|ARM64EC.ActiveCfg = Release|ARM64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|x64.ActiveCfg = Release|x64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|x64.Build.0 = Release|x64 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|x86.ActiveCfg = Release|Win32 {AB342A30-9A85-497B-8C03-7A95AB3DC9AA}.Release|x86.Build.0 = Release|Win32 - {059AAA09-58FE-4578-B99E-7D706D7DC810}.Debug|ARM.ActiveCfg = Debug|ARM + {059AAA09-58FE-4578-B99E-7D706D7DC810}.Debug|ARM.ActiveCfg = Debug|ARM64 {059AAA09-58FE-4578-B99E-7D706D7DC810}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {059AAA09-58FE-4578-B99E-7D706D7DC810}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 {059AAA09-58FE-4578-B99E-7D706D7DC810}.Debug|x64.ActiveCfg = Debug|x64 {059AAA09-58FE-4578-B99E-7D706D7DC810}.Debug|x86.ActiveCfg = Debug|Win32 - {059AAA09-58FE-4578-B99E-7D706D7DC810}.Release|ARM.ActiveCfg = Release|ARM + {059AAA09-58FE-4578-B99E-7D706D7DC810}.Release|ARM.ActiveCfg = Release|ARM64 {059AAA09-58FE-4578-B99E-7D706D7DC810}.Release|ARM64.ActiveCfg = Release|ARM64 + {059AAA09-58FE-4578-B99E-7D706D7DC810}.Release|ARM64EC.ActiveCfg = Release|ARM64 {059AAA09-58FE-4578-B99E-7D706D7DC810}.Release|x64.ActiveCfg = Release|x64 {059AAA09-58FE-4578-B99E-7D706D7DC810}.Release|x86.ActiveCfg = Release|Win32 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|ARM.ActiveCfg = Debug|ARM + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|ARM.Build.0 = Debug|ARM + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|ARM64EC.Build.0 = Debug|ARM64EC + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|x64.ActiveCfg = Debug|x64 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|x64.Build.0 = Debug|x64 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|x86.ActiveCfg = Debug|Win32 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Debug|x86.Build.0 = Debug|Win32 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|ARM.ActiveCfg = Release|ARM + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|ARM.Build.0 = Release|ARM + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|ARM64.ActiveCfg = Release|ARM64 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|ARM64EC.ActiveCfg = Release|ARM64EC + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|ARM64EC.Build.0 = Release|ARM64EC + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|x64.ActiveCfg = Release|x64 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|x64.Build.0 = Release|x64 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|x86.ActiveCfg = Release|Win32 + {1E93D511-25BF-4CCF-93E5-DA44F66016AB}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/imcrvtip/CandidateKeyHandler.cpp b/imcrvtip/CandidateKeyHandler.cpp index d29588f3..4e924c75 100644 --- a/imcrvtip/CandidateKeyHandler.cpp +++ b/imcrvtip/CandidateKeyHandler.cpp @@ -5,7 +5,7 @@ #include "CandidateWindow.h" #include "InputModeWindow.h" -HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey) +HRESULT CCandidateWindow::_OnKeyDown(WPARAM wParam) { UINT i, page, index; WCHAR ch; @@ -13,17 +13,17 @@ HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey) if (_pCandidateWindow != nullptr && !_preEnd) { - return _pCandidateWindow->_OnKeyDown(uVKey); + return _pCandidateWindow->_OnKeyDown(wParam); } //辞書登録モード if (_regmode) { - _OnKeyDownRegword(uVKey); + _OnKeyDownRegword(wParam); return S_OK; } - _GetChSf(uVKey, ch, sf); + _GetChSf(wParam, ch, sf); //辞書削除 if (_mode == wm_delete) @@ -40,7 +40,7 @@ HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey) break; } - if (_pTextService->_IsKeyVoid(ch, (BYTE)uVKey)) + if (_pTextService->_IsKeyVoid(ch, (BYTE)wParam)) { if (sf == SKK_ENTER) { @@ -95,17 +95,17 @@ HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey) } else { - _NextComp(); + _NextCompPage(); } break; case SKK_PREV_COMP: if (candidx != (size_t)-1) { - _PrevComp(); + _PrevCompPage(); } break; default: - _InvokeKeyHandler(uVKey); + _InvokeKeyHandler(wParam); break; } @@ -145,22 +145,25 @@ HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey) case SKK_BACK: case SKK_PREV_CAND: - _PrevPage(); + _PrevConvPage(); break; case SKK_NEXT_CAND: - _NextPage(); + _NextConvPage(); break; default: - _GetChSf(uVKey, ch, sf, VK_KANA); + _GetChSf(wParam, ch, sf, VK_KANA); for (i = 0; i < MAX_SELKEY_C; i++) { + WCHAR dsph = _pTextService->selkey[i].disp[0]; + WCHAR dspl = _pTextService->selkey[i].disp[1]; + WCHAR sp1 = _pTextService->selkey[i].spare1; + WCHAR sp2 = _pTextService->selkey[i].spare2; + if (ch == (L'1' + i) || - (ch == _pTextService->selkey[i][0][0] && _pTextService->selkey[i][0][0] != L'\0') || - (ch == _pTextService->selkey[i][1][0] && _pTextService->selkey[i][1][0] != L'\0') || - (ch == _pTextService->selkey[i][2][0] && _pTextService->selkey[i][2][0] != L'\0')) + (ch != L'\0' && ((ch == dsph && dspl == L'\0') || ch == sp1 || ch == sp2))) { GetCurrentPage(&page); if (i < _CandCount[page]) @@ -204,18 +207,18 @@ HRESULT CCandidateWindow::_OnKeyDown(UINT uVKey) return S_OK; } -void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) +void CCandidateWindow::_OnKeyDownRegword(WPARAM wParam) { WCHAR ch; BYTE sf; - _GetChSf(uVKey, ch, sf); + _GetChSf(wParam, ch, sf); //確定していないとき if (!_regfixed) { _pTextService->showcandlist = FALSE; //候補一覧表示をループさせる - _HandleKey((WPARAM)uVKey, SKK_NULL); + _HandleKey(wParam, SKK_NULL); _Update(); if (_pInputModeWindow != nullptr) @@ -225,7 +228,7 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) return; } - if (_pTextService->_IsKeyVoid(ch, (BYTE)uVKey)) + if (_pTextService->_IsKeyVoid(ch, (BYTE)wParam)) { _pTextService->_UpdateLanguageBar(); @@ -252,9 +255,12 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) _regmode = FALSE; //スペースのみのとき空として扱う - if (std::regex_match(_regtext, std::wregex(L"^\\s+$"))) { - _regtext.clear(); + static const std::wregex resp(L"^\\s+$"); + if (std::regex_match(_regtext, resp)) + { + _regtext.clear(); + } } if (_regtext.empty()) //空のときはキャンセル扱い @@ -304,14 +310,15 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) } else { - std::wstring conv; + std::wstring convcand; std::wstring candidate; std::wstring annotation; std::wsmatch result; std::wstring okurikey; //候補と注釈を、行頭以外の最後のセミコロンで分割 - if (std::regex_search(_regtext, result, std::wregex(L".+;"))) + static const std::wregex resepsc(L".+;"); + if (std::regex_search(_regtext, result, resepsc)) { candidate = result.str().substr(0, result.str().size() - 1); annotation = result.suffix(); @@ -337,22 +344,24 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) } //候補変換 - _pTextService->_ConvertWord(REQ_CONVERTCND, _pTextService->searchkeyorg, candidate, okurikey, conv); + _pTextService->_ConvertWord(REQ_CONVERTCND, _pTextService->searchkeyorg, candidate, okurikey); + + convcand = _pTextService->convword; - if (_pTextService->searchkey.empty() || conv.empty()) + if (_pTextService->searchkey.empty() || convcand.empty()) { //変換見出し語が空文字列または //変換済み候補が空文字列であれば未変換見出し語を見出し語とする _pTextService->searchkey = _pTextService->searchkeyorg; } - if (conv.empty()) + if (convcand.empty()) { - conv = candidate; + convcand = candidate; } _pTextService->candidates.push_back(std::make_pair( - std::make_pair(conv, annotation), + std::make_pair(convcand, annotation), std::make_pair(candidate, annotation))); _pTextService->candidx = _pTextService->candidates.size() - 1; _pTextService->candorgcnt = 0; @@ -525,8 +534,8 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) LPWSTR pwCB = (LPWSTR)GlobalLock(hCB); if (pwCB != nullptr) { - std::wstring scb = std::regex_replace(std::wstring(pwCB), - std::wregex(L"[\\x00-\\x19]"), std::wstring(L"")); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + std::wstring scb = std::regex_replace(std::wstring(pwCB), rectrl, L""); _regtext.insert(_regtextpos, scb); _regtextpos += scb.size(); _Update(); @@ -540,7 +549,7 @@ void CCandidateWindow::_OnKeyDownRegword(UINT uVKey) break; default: - _HandleKey((WPARAM)uVKey, SKK_NULL); + _HandleKey(wParam, SKK_NULL); if (_pInputModeWindow != nullptr) { @@ -558,27 +567,35 @@ void CCandidateWindow::_InvokeSfHandler(BYTE sf) } } -void CCandidateWindow::_InvokeKeyHandler(UINT uVKey) +void CCandidateWindow::_InvokeKeyHandler(WPARAM wParam) { if (_pCandidateList != nullptr) { - _pCandidateList->_InvokeKeyHandler(uVKey); + _pCandidateList->_InvokeKeyHandler(wParam); } } void CCandidateWindow::_HandleKey(WPARAM wParam, BYTE bSf) { + BYTE sf = bSf; + WCHAR ch = WCHAR_MAX; + if (_pTextService != nullptr) { - _pTextService->_HandleKey(0, nullptr, wParam, bSf); + if (bSf == SKK_NULL) + { + _GetChSf(wParam, ch, sf); + } + + _pTextService->_HandleKey(0, nullptr, wParam, sf, ch); } } -void CCandidateWindow::_GetChSf(UINT uVKey, WCHAR &ch, BYTE &sf, BYTE vkoff) +void CCandidateWindow::_GetChSf(WPARAM wParam, WCHAR &ch, BYTE &sf, BYTE vkoff) { if (_pTextService != nullptr) { - ch = _pTextService->_GetCh(uVKey, vkoff); - sf = _pTextService->_GetSf(uVKey, ch); + ch = _pTextService->_GetCh((BYTE)wParam, vkoff); + sf = _pTextService->_GetSf((BYTE)wParam, ch); } } diff --git a/imcrvtip/CandidateList.cpp b/imcrvtip/CandidateList.cpp index 4156871b..416b425c 100644 --- a/imcrvtip/CandidateList.cpp +++ b/imcrvtip/CandidateList.cpp @@ -122,12 +122,15 @@ STDAPI CCandidateList::OnKeyDown(WPARAM wParam, LPARAM lParam, BOOL *pfEaten) } *pfEaten = TRUE; + + _pTextService->_GetKeyboardState(); + #ifdef _DEBUG - _pCandidateWindow->_OnKeyDown((UINT)wParam); + _pCandidateWindow->_OnKeyDown(wParam); #else __try { - _pCandidateWindow->_OnKeyDown((UINT)wParam); + _pCandidateWindow->_OnKeyDown(wParam); } __except (EXCEPTION_EXECUTE_HANDLER) { @@ -235,14 +238,20 @@ class CCandidateWindowEditSession : public CEditSessionBase // ITfEditSession STDMETHODIMP DoEditSession(TfEditCookie ec) { + HRESULT hr; + CComPtr pContextView; if (SUCCEEDED(_pContext->GetActiveView(&pContextView)) && (pContextView != nullptr)) { - RECT rc = {}; - BOOL fClipped; - if (SUCCEEDED(pContextView->GetTextExt(ec, _pRangeComposition, &rc, &fClipped))) + try + { + CComPtr pEditSession; + pEditSession.Attach( + new CCandidateListGetTextExtEditSession(_pTextService, _pContext, pContextView, _pRangeComposition, _pCandidateWindow)); + _pContext->RequestEditSession(_pTextService->_GetClientId(), pEditSession, TF_ES_SYNC | TF_ES_READ, &hr); + } + catch (...) { - _pCandidateWindow->_Move(&rc, ec, _pContext); } } @@ -325,11 +334,9 @@ HRESULT CCandidateList::_StartCandidateList(TfClientId tfClientId, ITfDocumentMg CComPtr pEditSession; pEditSession.Attach( new CCandidateWindowEditSession(_pTextService, _pContextDocument, _pRangeComposition, _pCandidateWindow)); - // Asynchronous, read-only - hr = pContext->RequestEditSession(ec, pEditSession, TF_ES_ASYNC | TF_ES_READ, &hrSession); + hr = pContext->RequestEditSession(tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READ, &hrSession); - // It is possible that asynchronous requests are treated as synchronous requests. - if (FAILED(hr) || (hrSession != TF_S_ASYNC && FAILED(hrSession))) + if (FAILED(hr) || FAILED(hrSession)) { goto exit; } @@ -349,11 +356,11 @@ HRESULT CCandidateList::_StartCandidateList(TfClientId tfClientId, ITfDocumentMg return hrRet; } -void CCandidateList::_InvokeKeyHandler(WPARAM key) +void CCandidateList::_InvokeKeyHandler(WPARAM wParam) { if (_pTextService != nullptr && _pContextDocument != nullptr) { - _pTextService->_InvokeKeyHandler(_pContextDocument, (WPARAM)key, (LPARAM)0, 0); + _pTextService->_InvokeKeyHandler(_pContextDocument, wParam, 0, SKK_NULL); } } @@ -361,7 +368,7 @@ void CCandidateList::_InvokeSfHandler(BYTE sf) { if (_pTextService != nullptr && _pContextDocument != nullptr) { - _pTextService->_InvokeKeyHandler(_pContextDocument, (WPARAM)0, (LPARAM)0, sf); + _pTextService->_InvokeKeyHandler(_pContextDocument, 0, 0, sf); } } @@ -466,6 +473,14 @@ void CCandidateList::_Show(BOOL bShow) } } +void CCandidateList::_Redraw() +{ + if (_pCandidateWindow != nullptr) + { + _pCandidateWindow->_Redraw(); + } +} + void CCandidateList::_SetText(const std::wstring &text, BOOL fixed, int mode) { if (_pCandidateWindow != nullptr) diff --git a/imcrvtip/CandidateList.h b/imcrvtip/CandidateList.h index 257bf3ec..da9bafc1 100644 --- a/imcrvtip/CandidateList.h +++ b/imcrvtip/CandidateList.h @@ -34,6 +34,7 @@ class CCandidateList : void _InvokeKeyHandler(WPARAM key); void _InvokeSfHandler(BYTE sf); void _Show(BOOL bShow); + void _Redraw(); void _SetText(const std::wstring &text, BOOL fixed, int mode); void _Move(LPRECT lpr, TfEditCookie ec = TF_INVALID_EDIT_COOKIE, ITfContext *pContext = nullptr); void _UpdateComp(); diff --git a/imcrvtip/CandidatePaint.cpp b/imcrvtip/CandidatePaint.cpp index b7bda925..dce181b1 100644 --- a/imcrvtip/CandidatePaint.cpp +++ b/imcrvtip/CandidatePaint.cpp @@ -369,6 +369,9 @@ std::wstring CCandidateWindow::_MakeCandidateString(UINT page, UINT count, UINT std::wstring ca = candidates[count + _uShowedCount + idx].first.first; std::wstring an = candidates[count + _uShowedCount + idx].first.second; + static const std::wregex resp(markSP); + static const std::wstring snbsp(markNBSP); + int color_cycle = cycle; if ((_mode == wm_complement) && (ca.compare(0, searchkey.size(), searchkey) != 0)) { @@ -388,7 +391,7 @@ std::wstring CCandidateWindow::_MakeCandidateString(UINT page, UINT count, UINT case CL_COLOR_SE: if (_mode == wm_candidate) { - s.append(_pTextService->selkey[(idx % MAX_SELKEY_C)][0]); + s.append(_pTextService->selkey[(idx % MAX_SELKEY_C)].disp); } else { @@ -406,8 +409,7 @@ std::wstring CCandidateWindow::_MakeCandidateString(UINT page, UINT count, UINT case CL_COLOR_CA: if (_mode == wm_candidate) { - s.append(std::regex_replace(ca, - std::wregex(markSP), std::wstring(markNBSP))); + s.append(std::regex_replace(ca, resp, snbsp)); } else { @@ -416,14 +418,12 @@ std::wstring CCandidateWindow::_MakeCandidateString(UINT page, UINT count, UINT if (ca.compare(0, searchkey.size(), searchkey) == 0) { //前方一致 - s.append(std::regex_replace(ca.substr(searchkey.size()), - std::wregex(markSP), std::wstring(markNBSP))); + s.append(std::regex_replace(ca.substr(searchkey.size()), resp, snbsp)); } else { //後方一致 - s.append(std::regex_replace(ca.substr(0, ca.size() - searchkey.size()), - std::wregex(markSP), std::wstring(markNBSP))); + s.append(std::regex_replace(ca.substr(0, ca.size() - searchkey.size()), resp, snbsp)); } } } @@ -451,16 +451,14 @@ std::wstring CCandidateWindow::_MakeCandidateString(UINT page, UINT count, UINT { if (_pTextService->cx_annotation && !an.empty()) { - s.append(std::regex_replace(an, - std::wregex(markSP), std::wstring(markNBSP))); + s.append(std::regex_replace(an, resp, snbsp)); } } else { if (!an.empty()) { - s.append(std::regex_replace(an, - std::wregex(markSP), std::wstring(markNBSP))); + s.append(std::regex_replace(an, resp, snbsp)); } } break; diff --git a/imcrvtip/CandidateUIElement.cpp b/imcrvtip/CandidateUIElement.cpp index 720ac1be..609a0a75 100644 --- a/imcrvtip/CandidateUIElement.cpp +++ b/imcrvtip/CandidateUIElement.cpp @@ -453,7 +453,7 @@ STDAPI CCandidateWindow::SetPageIndex(UINT *pIndex, UINT uPageCnt) if (_mode == wm_candidate) { - _CandStr.push_back(_pTextService->selkey[(i % MAX_SELKEY_C)][0]); + _CandStr.push_back(_pTextService->selkey[(i % MAX_SELKEY_C)].disp); _CandStr[k].append(markNo); } else diff --git a/imcrvtip/CandidateWindow.cpp b/imcrvtip/CandidateWindow.cpp index 46d3d4b6..c2b4c342 100644 --- a/imcrvtip/CandidateWindow.cpp +++ b/imcrvtip/CandidateWindow.cpp @@ -119,15 +119,19 @@ void CCandidateWindow::_UninitClass() LRESULT CALLBACK CCandidateWindow::_WindowPreProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CCandidateWindow *pCandidateWindow = nullptr; + LPCREATESTRUCTW pCreate; + LONG_PTR ptr; switch (uMsg) { case WM_NCCREATE: - pCandidateWindow = (CCandidateWindow *)((LPCREATESTRUCTW)lParam)->lpCreateParams; + pCreate = reinterpret_cast(lParam); + pCandidateWindow = reinterpret_cast(pCreate->lpCreateParams); SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pCandidateWindow); break; default: - pCandidateWindow = (CCandidateWindow *)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + ptr = GetWindowLongPtrW(hWnd, GWLP_USERDATA); + pCandidateWindow = reinterpret_cast(ptr); break; } @@ -208,7 +212,7 @@ void CCandidateWindow::_Move(LPCRECT lpr, TfEditCookie ec, ITfContext *pContext) if (ec != TF_INVALID_EDIT_COOKIE && pContext != nullptr) { - _vertical = _pTextService->_GetVertical(ec, pContext); + _vertical = _pTextService->_IsVertical(ec, pContext); } if (_vertical) @@ -444,14 +448,18 @@ void CCandidateWindow::_InitList() if (_mode == wm_candidate) { - _uPageCandNum = MAX_SELKEY; + _uPageCandNum = _pTextService->cx_pagecandnum; + if (_uPageCandNum > MAX_SELKEY_C || _uPageCandNum < 1) + { + _uPageCandNum = MAX_SELKEY; + } } else { _uPageCandNum = _pTextService->cx_compmultinum; if (_uPageCandNum > MAX_SELKEY_C || _uPageCandNum < 1) { - _uPageCandNum = MAX_SELKEY; + _uPageCandNum = COMPMULTIDISP_DEF; } } @@ -470,7 +478,7 @@ void CCandidateWindow::_InitList() { if (_mode == wm_candidate) { - _CandStr.push_back(_pTextService->selkey[(i % _uPageCandNum)][0]); + _CandStr.push_back(_pTextService->selkey[(i % _uPageCandNum)].disp); _CandStr[i].append(markNo); } else @@ -495,7 +503,7 @@ void CCandidateWindow::_InitList() } } - _uPageCnt = ((_uCount - (_uCount % _uPageCandNum)) / _uPageCandNum) + ((_uCount % _uPageCandNum) == 0 ? 0 : 1); + _uPageCnt = ((_uCount - (_uCount % _uPageCandNum)) / _uPageCandNum) + (((_uCount % _uPageCandNum) == 0) ? 0 : 1); _PageIndex.clear(); _CandCount.clear(); @@ -524,7 +532,7 @@ void CCandidateWindow::_UpdateUIElement() } } -void CCandidateWindow::_NextPage() +void CCandidateWindow::_NextConvPage() { UINT uOldPage, uNewPage; @@ -571,7 +579,7 @@ void CCandidateWindow::_NextPage() _UpdateUIElement(); } -void CCandidateWindow::_PrevPage() +void CCandidateWindow::_PrevConvPage() { UINT uOldPage, uNewPage; @@ -654,7 +662,7 @@ void CCandidateWindow::_PrevPage() _UpdateUIElement(); } -void CCandidateWindow::_NextComp() +void CCandidateWindow::_NextCompPage() { UINT uOldPage, uNewPage; @@ -682,7 +690,7 @@ void CCandidateWindow::_NextComp() _UpdateUIElement(); } -void CCandidateWindow::_PrevComp() +void CCandidateWindow::_PrevCompPage() { UINT uOldPage, uNewPage; @@ -765,6 +773,8 @@ void CCandidateWindow::_BackUpStatus() candidates_bak = _pTextService->candidates; candidx_bak = _pTextService->candidx; candorgcnt_bak = _pTextService->candorgcnt; + reconversion_bak = _pTextService->reconversion; + reconvtext_bak = _pTextService->reconvtext; } void CCandidateWindow::_ClearStatus() @@ -779,6 +789,9 @@ void CCandidateWindow::_ClearStatus() _pTextService->candidates.clear(); _pTextService->candidx = 0; _pTextService->candorgcnt = 0; + _pTextService->reconversion = FALSE; + _pTextService->reconvtext.clear(); + _pTextService->showcandlist = FALSE; _pTextService->showentry = FALSE; _pTextService->inputkey = FALSE; @@ -797,6 +810,9 @@ void CCandidateWindow::_RestoreStatusReg() _pTextService->candidates = candidates_bak; _pTextService->candidx = candidx_bak; _pTextService->candorgcnt = candorgcnt_bak; + _pTextService->reconversion = reconversion_bak; + _pTextService->reconvtext = reconvtext_bak; + _pTextService->showcandlist = TRUE; _pTextService->showentry = TRUE; _pTextService->inputkey = TRUE; @@ -814,6 +830,8 @@ void CCandidateWindow::_ClearStatusReg() candidates_bak.clear(); candidx_bak = 0; candorgcnt_bak = 0; + reconversion_bak = FALSE; + reconvtext_bak.clear(); } void CCandidateWindow::_PreEndReq() diff --git a/imcrvtip/CandidateWindow.h b/imcrvtip/CandidateWindow.h index 44b4c5f0..b50d081f 100644 --- a/imcrvtip/CandidateWindow.h +++ b/imcrvtip/CandidateWindow.h @@ -53,17 +53,17 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior void _UpdateComp(); //KeyHandler - HRESULT _OnKeyDown(UINT uVKey); + HRESULT _OnKeyDown(WPARAM wParam); private: LONG _cRef; void _InitList(); void _UpdateUIElement(); - void _NextPage(); - void _PrevPage(); - void _NextComp(); - void _PrevComp(); + void _NextConvPage(); + void _PrevConvPage(); + void _NextCompPage(); + void _PrevCompPage(); void _Update(); void _BackUpStatus(); void _ClearStatus(); @@ -74,11 +74,11 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior void _CreateNext(int mode); //KeyHandler - void _OnKeyDownRegword(UINT uVKey); + void _OnKeyDownRegword(WPARAM wParam); void _InvokeSfHandler(BYTE sf); - void _InvokeKeyHandler(UINT uVKey); + void _InvokeKeyHandler(WPARAM wParam); void _HandleKey(WPARAM wParam, BYTE bSf); - void _GetChSf(UINT uVKey, WCHAR &ch, BYTE &sf, BYTE vkoff = 0); + void _GetChSf(WPARAM wParam, WCHAR &ch, BYTE &sf, BYTE vkoff = 0); //Paint void _WindowProcPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -157,4 +157,6 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior CANDIDATES candidates_bak; size_t candidx_bak; size_t candorgcnt_bak; + BOOL reconversion_bak; + std::wstring reconvtext_bak; }; diff --git a/imcrvtip/Compartment.cpp b/imcrvtip/Compartment.cpp index ff6542ef..b3c1f8fb 100644 --- a/imcrvtip/Compartment.cpp +++ b/imcrvtip/Compartment.cpp @@ -73,7 +73,7 @@ BOOL CTextService::_IsKeyboardDisabled() { if (V_VT(&var) == VT_I4) { - fDisabled = (V_I4(&var) == 0 ? FALSE : TRUE); + fDisabled = ((V_I4(&var) == 0) ? FALSE : TRUE); } } } @@ -87,7 +87,7 @@ BOOL CTextService::_IsKeyboardDisabled() { if (V_VT(&var) == VT_I4) { - fDisabled = (V_I4(&var) == 0 ? FALSE : TRUE); + fDisabled = ((V_I4(&var) == 0) ? FALSE : TRUE); } } } @@ -122,7 +122,7 @@ BOOL CTextService::_IsKeyboardOpen() { if (V_VT(&var) == VT_I4) { - fOpen = (V_I4(&var) == 0 ? FALSE : TRUE); + fOpen = ((V_I4(&var) == 0) ? FALSE : TRUE); } } } diff --git a/imcrvtip/FnConfig.cpp b/imcrvtip/ConfigTip.cpp similarity index 81% rename from imcrvtip/FnConfig.cpp rename to imcrvtip/ConfigTip.cpp index 5de91c59..f40c845c 100644 --- a/imcrvtip/FnConfig.cpp +++ b/imcrvtip/ConfigTip.cpp @@ -35,17 +35,30 @@ static const struct { {SKK_RIGHT, ValueKeyMapRight}, {SKK_DOWN, ValueKeyMapDown}, {SKK_PASTE, ValueKeyMapPaste}, + {SKK_RECONVERT, ValueKeyMapReconvert}, {SKK_NULL, L""} }; -static const TF_PRESERVEDKEY configpreservedkey[] = +static const TF_PRESERVEDKEY configpreservedkey[PRESERVEDKEY_NUM][MAX_PRESERVEDKEY] = { - {VK_OEM_3 /*0xC0*/, TF_MOD_ALT}, - {VK_KANJI /*0x19*/, TF_MOD_IGNORE_ALL_MODIFIER}, - {VK_OEM_AUTO /*0xF3*/, TF_MOD_IGNORE_ALL_MODIFIER}, - {VK_OEM_ENLW /*0xF4*/, TF_MOD_IGNORE_ALL_MODIFIER} + { + {VK_OEM_3 /*0xC0*/, TF_MOD_ALT}, + {VK_KANJI /*0x19*/, TF_MOD_IGNORE_ALL_MODIFIER}, + {VK_OEM_AUTO /*0xF3*/, TF_MOD_IGNORE_ALL_MODIFIER}, + {VK_OEM_ENLW /*0xF4*/, TF_MOD_IGNORE_ALL_MODIFIER}, + {VK_IME_ON /*0x16*/, TF_MOD_IGNORE_ALL_MODIFIER} + }, + { + {VK_OEM_3 /*0xC0*/, TF_MOD_ALT}, + {VK_KANJI /*0x19*/, TF_MOD_IGNORE_ALL_MODIFIER}, + {VK_OEM_AUTO /*0xF3*/, TF_MOD_IGNORE_ALL_MODIFIER}, + {VK_OEM_ENLW /*0xF4*/, TF_MOD_IGNORE_ALL_MODIFIER}, + {VK_IME_OFF /*0x1A*/, TF_MOD_IGNORE_ALL_MODIFIER} + } }; +static const TF_PRESERVEDKEY configprivatemodekey = {VK_F10, TF_MOD_CONTROL | TF_MOD_SHIFT}; + static const struct { LPCWSTR value; COLORREF color; @@ -78,13 +91,19 @@ static const struct { LPCWSTR sectionpreservedkeyonoff[PRESERVEDKEY_NUM] = {SectionPreservedKeyON, SectionPreservedKeyOFF}; +LPCWSTR keyprivatemodekeyonoff[PRIVATEMODEKEY_NUM][2] = +{ + {ValuePrivateOnVKey, ValuePrivateOnMKey}, + {ValuePrivateOffVKey, ValuePrivateOffMKey} +}; + void CTextService::_CreateConfigPath() { PWSTR knownfolderpath = nullptr; ZeroMemory(pathconfigxml, sizeof(pathconfigxml)); - //%AppData%\\CorvusSKK\\config.xml + //%APPDATA%\\CorvusSKK\\config.xml if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) { _snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s", knownfolderpath, TextServiceDesc, fnconfigxml); @@ -109,7 +128,7 @@ void CTextService::_CreateConfigPath() //%SystemRoot%\\IME\\IMCRVSKK\\config.xml if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, KF_FLAG_DONT_VERIFY, nullptr, &knownfolderpath))) { - _snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, L"IME", TEXTSERVICE_DIR, fnconfigxml); + _snwprintf_s(pathconfigxml, _TRUNCATE, L"%s\\%s\\%s\\%s", knownfolderpath, SYSTEMROOT_IME_DIR, TEXTSERVICE_DIR, fnconfigxml); CoTaskMemFree(knownfolderpath); } @@ -147,6 +166,31 @@ void CTextService::_ReadBoolValue(LPCWSTR section, LPCWSTR key, BOOL &value, BOO } } +void CTextService::_LoadUserDict() +{ + std::wstring strxmlval; + + //UserDict + + for (int i = 0; i < PRIVATEMODEKEY_NUM; i++) + { + ReadValue(pathconfigxml, SectionUserDict, keyprivatemodekeyonoff[i][0], strxmlval); + privatemodekey[i].uVKey = + (strxmlval.empty() ? configprivatemodekey.uVKey : (BYTE)wcstoul(strxmlval.c_str(), nullptr, 0)); + + ReadValue(pathconfigxml, SectionUserDict, keyprivatemodekeyonoff[i][1], strxmlval); + privatemodekey[i].uModifiers = + (strxmlval.empty() ? configprivatemodekey.uModifiers : + (wcstoul(strxmlval.c_str(), nullptr, 0) & (TF_MOD_ALT | TF_MOD_CONTROL | TF_MOD_SHIFT))); + if ((privatemodekey[i].uModifiers & (TF_MOD_ALT | TF_MOD_CONTROL | TF_MOD_SHIFT)) == 0) + { + privatemodekey[i].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; + } + } + + _ReadBoolValue(SectionUserDict, ValuePrivateModeAuto, cx_privatemodeauto, TRUE); +} + void CTextService::_LoadBehavior() { std::wstring strxmlval; @@ -174,6 +218,11 @@ void CTextService::_LoadBehavior() _ReadBoolValue(SectionBehavior, ValueDynamicComp, cx_dynamiccomp, FALSE); _ReadBoolValue(SectionBehavior, ValueDynCompMulti, cx_dyncompmulti, FALSE); _ReadBoolValue(SectionBehavior, ValueCompUserDic, cx_compuserdic, FALSE); +} + +void CTextService::_LoadDisplay() +{ + std::wstring strxmlval; //Font @@ -240,6 +289,13 @@ void CTextService::_LoadBehavior() cx_untilcandlist = UNTILCANDLIST_DEF; } + ReadValue(pathconfigxml, SectionDisplay, ValuePageCandNum, strxmlval); + cx_pagecandnum = strxmlval.empty() ? -1 : _wtoi(strxmlval.c_str()); + if (cx_pagecandnum > MAX_SELKEY_C || cx_pagecandnum < 1) + { + cx_pagecandnum = MAX_SELKEY; + } + _ReadBoolValue(SectionDisplay, ValueDispCandNo, cx_dispcandnum, FALSE); _ReadBoolValue(SectionDisplay, ValueVerticalCand, cx_verticalcand, TRUE); _ReadBoolValue(SectionDisplay, ValueAnnotation, cx_annotation, TRUE); @@ -282,7 +338,9 @@ void CTextService::_LoadDisplayAttr() { std::wstring strxmlval; BOOL se; - TF_DISPLAYATTRIBUTE da; + TF_DISPLAYATTRIBUTE da = {}; + + //DisplayAttr for (int i = 0; i < DISPLAYATTRIBUTE_INFO_NUM; i++) { @@ -305,8 +363,8 @@ void CTextService::_LoadDisplayAttr() void CTextService::_LoadSelKey() { - WCHAR num[2]; - WCHAR key[4]; + WCHAR num[2 + 1] = {}; + WCHAR key[4 + 1] = {}; std::wstring strxmlval; ZeroMemory(selkey, sizeof(selkey)); @@ -316,10 +374,15 @@ void CTextService::_LoadSelKey() num[0] = L'0' + i + 1; num[1] = L'\0'; ReadValue(pathconfigxml, SectionSelKey, num, strxmlval); + ZeroMemory(key, sizeof(key)); wcsncpy_s(key, strxmlval.c_str(), _TRUNCATE); - selkey[i][0][0] = key[0]; - selkey[i][1][0] = key[1]; - selkey[i][2][0] = key[2]; + + int sp = IS_SURROGATE_PAIR(key[0], key[1]) ? 1 : 0; + + selkey[i].disp[0] = key[0]; + selkey[i].disp[0 + sp] = key[0 + sp]; + selkey[i].spare1 = key[1 + sp]; + selkey[i].spare2 = key[2 + sp]; } } @@ -346,12 +409,12 @@ void CTextService::_SetPreservedKeyONOFF(int onoff, const APPDATAXMLLIST &list) { if (r_itr->first == AttributeVKey) { - preservedkey[onoff][i].uVKey = wcstoul(r_itr->second.c_str(), nullptr, 0); + preservedkey[onoff][i].uVKey = (BYTE)wcstoul(r_itr->second.c_str(), nullptr, 0); } else if (r_itr->first == AttributeMKey) { preservedkey[onoff][i].uModifiers = - wcstoul(r_itr->second.c_str(), nullptr, 0) & (TF_MOD_ALT | TF_MOD_CONTROL | TF_MOD_SHIFT); + (wcstoul(r_itr->second.c_str(), nullptr, 0) & (TF_MOD_ALT | TF_MOD_CONTROL | TF_MOD_SHIFT)); if ((preservedkey[onoff][i].uModifiers & (TF_MOD_ALT | TF_MOD_CONTROL | TF_MOD_SHIFT)) == 0) { preservedkey[onoff][i].uModifiers = TF_MOD_IGNORE_ALL_MODIFIER; @@ -364,9 +427,9 @@ void CTextService::_SetPreservedKeyONOFF(int onoff, const APPDATAXMLLIST &list) } else { - for (int i = 0; i < _countof(configpreservedkey); i++) + for (int i = 0; i < MAX_PRESERVEDKEY; i++) { - preservedkey[onoff][i] = configpreservedkey[i]; + preservedkey[onoff][i] = configpreservedkey[onoff][i]; } } } @@ -398,8 +461,8 @@ void CTextService::_LoadPreservedKey() void CTextService::_LoadCKeyMap() { - WCHAR key[2]; - WCHAR keyre[MAX_KEYRE]; + WCHAR key[2] = {}; + WCHAR keyre[MAX_KEYRE] = {}; std::wstring s; std::wregex re; std::wstring strxmlval; @@ -434,6 +497,7 @@ void CTextService::_LoadCKeyMap() case SKK_RIGHT: case SKK_DOWN: case SKK_PASTE: + case SKK_RECONVERT: for (WCHAR ch = 0x01; ch < CKEYMAPNUM; ch++) { key[0] = ch; @@ -519,8 +583,8 @@ void CTextService::_LoadCKeyMap() void CTextService::_LoadVKeyMap() { - WCHAR key[3]; - WCHAR keyre[MAX_KEYRE]; + WCHAR key[3] = {}; + WCHAR keyre[MAX_KEYRE] = {}; std::wstring s; std::wregex re; std::wstring strxmlval; @@ -557,6 +621,7 @@ void CTextService::_LoadVKeyMap() case SKK_RIGHT: case SKK_DOWN: case SKK_PASTE: + case SKK_RECONVERT: for (int j = 0; j < _countof(pkeymaps); j++) { for (WCHAR ch = 0x01; ch < VKEYMAPNUM; ch++) @@ -727,30 +792,30 @@ void CTextService::_LoadConvPoint() { if (r_itr->first == AttributeCPStart) { - cp.ch[0] = r_itr->second.c_str()[0]; + cp.st = r_itr->second.c_str()[0]; } else if (r_itr->first == AttributeCPAlter) { - cp.ch[1] = r_itr->second.c_str()[0]; + cp.al = r_itr->second.c_str()[0]; } else if (r_itr->first == AttributeCPOkuri) { - cp.ch[2] = r_itr->second.c_str()[0]; + cp.ok = r_itr->second.c_str()[0]; } } auto vs_itr = std::lower_bound(conv_point_s.begin(), conv_point_s.end(), - cp.ch[0], [] (CONV_POINT m, WCHAR v) { return (m.ch[0] < v); }); + cp.st, [] (const CONV_POINT &m, const WCHAR &v) { return (m.st < v); }); - if (vs_itr == conv_point_s.end() || cp.ch[0] != vs_itr->ch[0]) + if (vs_itr == conv_point_s.end() || cp.st != vs_itr->st) { conv_point_s.insert(vs_itr, cp); } auto va_itr = std::lower_bound(conv_point_a.begin(), conv_point_a.end(), - cp.ch[1], [] (CONV_POINT m, WCHAR v) { return (m.ch[1] < v); }); + cp.al, [] (const CONV_POINT &m, const WCHAR &v) { return (m.al < v); }); - if (va_itr == conv_point_a.end() || cp.ch[1] != va_itr->ch[1]) + if (va_itr == conv_point_a.end() || cp.al != va_itr->al) { conv_point_a.insert(va_itr, cp); } @@ -764,9 +829,6 @@ void CTextService::_LoadKana() { APPDATAXMLLIST list; - std::wregex re(L"[\\x00-\\x19]"); - std::wstring fmt(L""); - roman_kana_tree = ROMAN_KANA_NODE{}; HRESULT hr = ReadList(pathconfigxml, SectionKana, list); @@ -816,7 +878,8 @@ void CTextService::_LoadKana() if (pszb != nullptr) { - wcsncpy_s(pszb, blen, std::regex_replace(r_itr->second, re, fmt).c_str(), _TRUNCATE); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + wcsncpy_s(pszb, blen, std::regex_replace(r_itr->second, rectrl, L"").c_str(), _TRUNCATE); } } @@ -867,7 +930,7 @@ BOOL CTextService::_AddKanaTree(ROMAN_KANA_NODE &tree, ROMAN_KANA_CONV rkc, int } auto v_itr = std::lower_bound(tree.nodes.begin(), tree.nodes.end(), - rkc.roman[depth], [] (ROMAN_KANA_NODE m, WCHAR v) { return (m.ch < v); }); + rkc.roman[depth], [] (const ROMAN_KANA_NODE &m, const WCHAR &v) { return (m.ch < v); }); if (v_itr != tree.nodes.end() && v_itr->ch == rkc.roman[depth]) { @@ -909,7 +972,7 @@ void CTextService::_AddKanaTreeItem(ROMAN_KANA_NODE &tree, ROMAN_KANA_CONV rkc, rkn.ch = rkc.roman[depth]; auto v_itr = std::lower_bound(tree.nodes.begin(), tree.nodes.end(), - rkn.ch, [] (ROMAN_KANA_NODE m, WCHAR v) { return (m.ch < v); }); + rkn.ch, [] (const ROMAN_KANA_NODE &m, const WCHAR &v) { return (m.ch < v); }); if (rkc.roman[depth + 1] == L'\0') { @@ -930,9 +993,6 @@ void CTextService::_LoadJLatin() { APPDATAXMLLIST list; - std::wregex re(L"[\\x00-\\x19]"); - std::wstring fmt(L""); - ascii_jlatin_conv.clear(); ascii_jlatin_conv.shrink_to_fit(); @@ -968,12 +1028,13 @@ void CTextService::_LoadJLatin() if (pszb != nullptr) { - wcsncpy_s(pszb, blen, std::regex_replace(r_itr->second, re, fmt).c_str(), _TRUNCATE); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + wcsncpy_s(pszb, blen, std::regex_replace(r_itr->second, rectrl, L"").c_str(), _TRUNCATE); } } auto v_itr = std::lower_bound(ascii_jlatin_conv.begin(), ascii_jlatin_conv.end(), - ajc.ascii[0], [] (ASCII_JLATIN_CONV m, WCHAR v) { return (m.ascii[0] < v); }); + ajc.ascii[0], [] (const ASCII_JLATIN_CONV &m, const WCHAR &v) { return (m.ascii[0] < v); }); if (v_itr == ascii_jlatin_conv.end() || ajc.ascii[0] != v_itr->ascii[0]) { diff --git a/imcrvtip/DllMain.cpp b/imcrvtip/DllMain.cpp index a63dd250..c3a8a23c 100644 --- a/imcrvtip/DllMain.cpp +++ b/imcrvtip/DllMain.cpp @@ -9,16 +9,26 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { case DLL_PROCESS_ATTACH: g_hInst = hinstDLL; + + CCandidateWindow::_UninitClass(); if (!CCandidateWindow::_InitClass()) { return FALSE; } + + CInputModeWindow::_UninitClass(); if (!CInputModeWindow::_InitClass()) { return FALSE; } break; + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: CCandidateWindow::_UninitClass(); CInputModeWindow::_UninitClass(); diff --git a/imcrvtip/EnumDisplayAttributeInfo.h b/imcrvtip/EnumDisplayAttributeInfo.h index 76939644..a5c493d6 100644 --- a/imcrvtip/EnumDisplayAttributeInfo.h +++ b/imcrvtip/EnumDisplayAttributeInfo.h @@ -99,6 +99,16 @@ class CEnumDisplayAttributeInfo : public IEnumTfDisplayAttributeInfo return S_OK; } + for (ULONG i = 0; i < ulCount; i++) + { + *(rgInfo + i) = nullptr; + } + + if (pcFetched != nullptr) + { + *pcFetched = 0; + } + while(cFetched < ulCount) { if(_nIndex >= DISPLAYATTRIBUTE_INFO_NUM) @@ -115,7 +125,12 @@ class CEnumDisplayAttributeInfo : public IEnumTfDisplayAttributeInfo { for(ULONG i = 0; i < cFetched; i++) { - delete *(rgInfo + i); + ITfDisplayAttributeInfo *pdai = *(rgInfo + i); + if (pdai != nullptr) + { + pdai->Release(); + *(rgInfo + i) = nullptr; + } } return E_OUTOFMEMORY; } diff --git a/imcrvtip/FnEnumCandidates.h b/imcrvtip/FnEnumCandidates.h index ca38d417..c8cd8dc0 100644 --- a/imcrvtip/FnEnumCandidates.h +++ b/imcrvtip/FnEnumCandidates.h @@ -102,6 +102,16 @@ class CFnEnumCandidates : public IEnumTfCandidates return S_OK; } + for (ULONG i = 0; i < ulCount; i++) + { + *(ppCand + i) = nullptr; + } + + if (pcFetched != nullptr) + { + *pcFetched = 0; + } + while(cFetched < ulCount) { if(_nIndex >= (ULONG)_candidates.size()) @@ -117,7 +127,12 @@ class CFnEnumCandidates : public IEnumTfCandidates { for(ULONG i = 0; i < cFetched; i++) { - delete *(ppCand + i); + ITfCandidateString *pcs = *(ppCand + i); + if (pcs != nullptr) + { + pcs->Release(); + *(ppCand + i) = nullptr; + } } return E_OUTOFMEMORY; } diff --git a/imcrvtip/FunctionProvider.cpp b/imcrvtip/FunctionProvider.cpp index b257ae89..c7541622 100644 --- a/imcrvtip/FunctionProvider.cpp +++ b/imcrvtip/FunctionProvider.cpp @@ -160,32 +160,43 @@ STDAPI CTextService::GetReconversion(ITfRange *pRange, ITfCandidateList **ppCand HRESULT hr = E_FAIL; std::wstring text; - if (SUCCEEDED((_GetRangeText(pRange, text))) && !text.empty()) + hr = _GetRangeText(pRange, text); + + static const std::wregex rectrl(L"[\\x00-\\x19]"); + text = std::regex_replace(text, rectrl, L""); + + if (FAILED(hr) || text.empty()) { - std::wstring key; - _ConvKanaToKana(text, im_katakana, key, im_hiragana); + return E_FAIL; + } + try + { CComPtr pTextService; + pTextService.Attach(new CTextService()); - try + _ConvKanaToKana(text, im_katakana, pTextService->kana, im_hiragana); + + pTextService->searchkey = pTextService->kana; + pTextService->_SearchDic(REQ_REVERSE); + + if (!pTextService->candidates.empty()) { - pTextService.Attach(new CTextService()); + pTextService->kana = pTextService->candidates.front().second.first; + pTextService->candidates.clear(); + } - pTextService->_ResetStatus(); - pTextService->_CreateConfigPath(); - pTextService->inputmode = im_hiragana; - pTextService->kana = key; + pTextService->inputmode = im_hiragana; - pTextService->_StartSubConv(REQ_SEARCH); + pTextService->_StartSubConv(REQ_SEARCH); - *ppCandList = new CFnCandidateList(this, key, pTextService->candidates); + *ppCandList = new CFnCandidateList(this, pTextService->kana, pTextService->candidates); - hr = S_OK; - } - catch (...) - { - return E_OUTOFMEMORY; - } + hr = S_OK; + } + catch (...) + { + return E_OUTOFMEMORY; } return hr; @@ -206,29 +217,50 @@ STDAPI CTextService::Reconvert(ITfRange *pRange) HRESULT hr = E_FAIL; std::wstring text; - if (SUCCEEDED(_GetRangeText(pRange, text)) && !text.empty()) + hr = _GetRangeText(pRange, text); + + static const std::wregex rectrl(L"[\\x00-\\x19]"); + text = std::regex_replace(text, rectrl, L""); + + if (FAILED(hr) || text.empty()) + { + return E_FAIL; + } + + CComPtr pDocumentMgr; + if (SUCCEEDED(_pThreadMgr->GetFocus(&pDocumentMgr)) && (pDocumentMgr != nullptr)) { - CComPtr pDocumentMgr; - if (SUCCEEDED(_pThreadMgr->GetFocus(&pDocumentMgr)) && (pDocumentMgr != nullptr)) + CComPtr pContext; + if (SUCCEEDED(pDocumentMgr->GetTop(&pContext)) && (pContext != nullptr)) { - CComPtr pContext; - if (SUCCEEDED(pDocumentMgr->GetTop(&pContext)) && (pContext != nullptr)) + if (!_IsKeyboardOpen()) { - reconversion = TRUE; - reconvsrc = text; + inputmode = im_disable; + _SetKeyboardOpen(TRUE); + } - if (!_IsKeyboardOpen()) - { - inputmode = im_disable; - _SetKeyboardOpen(TRUE); - } + _ResetStatus(); + + _ConvKanaToKana(text, im_katakana, kana, im_hiragana); - inputmode = im_hiragana; - inputkey = TRUE; - _ConvKanaToKana(text, im_katakana, kana, im_hiragana); + searchkey = kana; + _SearchDic(REQ_REVERSE); - hr = _InvokeKeyHandler(pContext, 0, 0, SKK_NEXT_CAND); + if (!candidates.empty()) + { + kana = candidates.front().second.first; + candidates.clear(); } + + reconversion = TRUE; + reconvtext = text; + + inputkey = TRUE; + inputmode = im_hiragana; + + _UpdateLanguageBar(FALSE); + + hr = _InvokeKeyHandler(pContext, 0, 0, SKK_NEXT_CAND); } } @@ -265,29 +297,35 @@ class CGetRangeTextEditSession : public CEditSessionBase // ITfEditSession STDMETHODIMP DoEditSession(TfEditCookie ec) { - HRESULT hr; - WCHAR buf[16]; + HRESULT hr = S_OK; + WCHAR buf[16] = {}; ULONG cch = _countof(buf) - 1; _Text.clear(); - while (cch == _countof(buf) - 1) + while (SUCCEEDED(hr)) { ZeroMemory(buf, sizeof(buf)); cch = _countof(buf) - 1; + hr = _pRange->GetText(ec, TF_TF_MOVESTART, buf, cch, &cch); + if (SUCCEEDED(hr)) { _Text.append(buf); + + if (cch < _countof(buf) - 1) + { + break; + } } else { _Text.clear(); - return hr; } } - return S_OK; + return hr; } std::wstring _GetText() @@ -334,10 +372,6 @@ class CSetResultEditSession : public CEditSessionBase { } - ~CSetResultEditSession() - { - } - // ITfEditSession STDMETHODIMP DoEditSession(TfEditCookie ec) { @@ -376,7 +410,7 @@ HRESULT CTextService::_SetResult(const std::wstring &fnsearchkey, const CANDIDAT CComPtr pEditSession; pEditSession.Attach( new CSetResultEditSession(this, pContext)); - pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_SYNC | TF_ES_READWRITE, &hr); + pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); } catch (...) { diff --git a/imcrvtip/Globals.cpp b/imcrvtip/Globals.cpp index a61e581a..8914091d 100644 --- a/imcrvtip/Globals.cpp +++ b/imcrvtip/Globals.cpp @@ -1,6 +1,4 @@  -#include - #include "configxml.h" #include "imcrvtip.h" @@ -29,6 +27,14 @@ const GUID c_guidPreservedKeyOn = const GUID c_guidPreservedKeyOff = {0xba178f26, 0x486b, 0x4824, {0x8d, 0xa9, 0x50, 0x60, 0xa1, 0x1d, 0xc3, 0x5b}}; +// {88231634-A6BE-483E-8028-5E6CC8592B8F} +const GUID c_guidPrivateModeKeyOn = +{0x88231634, 0xa6be, 0x483e, {0x80, 0x28, 0x5e, 0x6c, 0xc8, 0x59, 0x2b, 0x8f}}; + +// {63100F6A-237E-43C3-83D4-52F224770BAC} +const GUID c_guidPrivateModeKeyOff = +{0x63100f6a, 0x237e, 0x43c3, { 0x83, 0xd4, 0x52, 0xf2, 0x24, 0x77, 0xb, 0xac }}; + // {3E45E83F-C786-485f-8B66-B7EAD509F960} const GUID c_guidLangBarItemButton = {0x3e45e83f, 0xc786, 0x485f, {0x8b, 0x66, 0xb7, 0xea, 0xd5, 0x09, 0xf9, 0x60}}; @@ -83,6 +89,14 @@ const GUID c_guidPreservedKeyOn = const GUID c_guidPreservedKeyOff = {0x6b6743b3, 0x2d6f, 0x4bb9, {0x9d, 0x74, 0x70, 0x07, 0x92, 0x8c, 0x1e, 0x94}}; +// {DC9E1E45-6818-4108-AC41-3A72EB7068F4} +const GUID c_guidPrivateModeKeyOn = +{0xdc9e1e45, 0x6818, 0x4108, {0xac, 0x41, 0x3a, 0x72, 0xeb, 0x70, 0x68, 0xf4}}; + +// {42D1356F-A252-488A-80F5-29244E830216} +const GUID c_guidPrivateModeKeyOff = +{0x42d1356f, 0xa252, 0x488a, { 0x80, 0xf5, 0x29, 0x24, 0x4e, 0x83, 0x2, 0x16 }}; + // {F4BF0D3C-D4CE-456f-837E-FE6712C6A8C3} const GUID c_guidLangBarItemButton = {0xf4bf0d3c, 0xd4ce, 0x456f, {0x83, 0x7e, 0xfe, 0x67, 0x12, 0xc6, 0xa8, 0xc3}}; @@ -164,20 +178,3 @@ const DISPLAYATTRIBUTE_INFO c_gdDisplayAttributeInfo[DISPLAYATTRIBUTE_INFO_NUM] c_daDisplayAttributeSeries[6], c_daDisplayAttributeConvAnnot } }; - -// added in Windows 8 SDK -#ifndef _WIN32_WINNT_WIN8 - -const GUID GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT = -{0x13A016DF, 0x560B, 0x46CD, {0x94, 0x7A, 0x4C, 0x3A, 0xF1, 0xE0, 0xE3, 0x5D}}; - -const GUID GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT = -{0x25504FB4, 0x7BAB, 0x4BC1, {0x9C, 0x69, 0xCF, 0x81, 0x89, 0x0F, 0x0E, 0xF5}}; - -const GUID GUID_LBI_INPUTMODE = -{0x2C77A81E, 0x41CC, 0x4178, {0xA3, 0xA7, 0x5F, 0x8A, 0x98, 0x75, 0x68, 0xE6}}; - -const IID IID_ITfFnGetPreferredTouchKeyboardLayout = -{0x5F309A41, 0x590A, 0x4ACC, {0xA9, 0x7F, 0xD8, 0xEF, 0xFF, 0x13, 0xFD, 0xFC}}; - -#endif //_WIN32_WINNT_WIN8 diff --git a/imcrvtip/Icon/pxAscii.ico b/imcrvtip/Icon/pxAscii.ico new file mode 100644 index 00000000..30a4f9ad Binary files /dev/null and b/imcrvtip/Icon/pxAscii.ico differ diff --git a/imcrvtip/Icon/pxHiragana.ico b/imcrvtip/Icon/pxHiragana.ico new file mode 100644 index 00000000..ace9c236 Binary files /dev/null and b/imcrvtip/Icon/pxHiragana.ico differ diff --git a/imcrvtip/Icon/pxJLatin.ico b/imcrvtip/Icon/pxJLatin.ico new file mode 100644 index 00000000..926ab177 Binary files /dev/null and b/imcrvtip/Icon/pxJLatin.ico differ diff --git a/imcrvtip/Icon/pxKatakana.ico b/imcrvtip/Icon/pxKatakana.ico new file mode 100644 index 00000000..a7ebe5a7 Binary files /dev/null and b/imcrvtip/Icon/pxKatakana.ico differ diff --git a/imcrvtip/Icon/pxKatakana1.ico b/imcrvtip/Icon/pxKatakana1.ico new file mode 100644 index 00000000..9c544f3c Binary files /dev/null and b/imcrvtip/Icon/pxKatakana1.ico differ diff --git a/imcrvtip/Icon/pzAscii.ico b/imcrvtip/Icon/pzAscii.ico new file mode 100644 index 00000000..fb60faa2 Binary files /dev/null and b/imcrvtip/Icon/pzAscii.ico differ diff --git a/imcrvtip/Icon/pzHiragana.ico b/imcrvtip/Icon/pzHiragana.ico new file mode 100644 index 00000000..fec544ec Binary files /dev/null and b/imcrvtip/Icon/pzHiragana.ico differ diff --git a/imcrvtip/Icon/pzJLatin.ico b/imcrvtip/Icon/pzJLatin.ico new file mode 100644 index 00000000..d794171a Binary files /dev/null and b/imcrvtip/Icon/pzJLatin.ico differ diff --git a/imcrvtip/Icon/pzKatakana.ico b/imcrvtip/Icon/pzKatakana.ico new file mode 100644 index 00000000..f81caa0f Binary files /dev/null and b/imcrvtip/Icon/pzKatakana.ico differ diff --git a/imcrvtip/Icon/pzKatakana1.ico b/imcrvtip/Icon/pzKatakana1.ico new file mode 100644 index 00000000..0f298da1 Binary files /dev/null and b/imcrvtip/Icon/pzKatakana1.ico differ diff --git a/imcrvtip/InputModeWindow.cpp b/imcrvtip/InputModeWindow.cpp index 6b59164c..3d0958d1 100644 --- a/imcrvtip/InputModeWindow.cpp +++ b/imcrvtip/InputModeWindow.cpp @@ -330,15 +330,19 @@ void CInputModeWindow::_UninitClass() LRESULT CALLBACK CInputModeWindow::_WindowPreProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CInputModeWindow *pInputModeWindow = nullptr; + LPCREATESTRUCTW pCreate; + LONG_PTR ptr; switch (uMsg) { case WM_NCCREATE: - pInputModeWindow = (CInputModeWindow *)((LPCREATESTRUCTW)lParam)->lpCreateParams; + pCreate = reinterpret_cast(lParam); + pInputModeWindow = reinterpret_cast(pCreate->lpCreateParams); SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pInputModeWindow); break; default: - pInputModeWindow = (CInputModeWindow *)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + ptr = GetWindowLongPtrW(hWnd, GWLP_USERDATA); + pInputModeWindow = reinterpret_cast(ptr); break; } @@ -617,11 +621,9 @@ void CTextService::_StartInputModeWindow() CComPtr pEditSession; pEditSession.Attach( new CInputModeWindowEditSession(this, pContext, _pInputModeWindow)); - // Asynchronous, read-only - hr = pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_ASYNC | TF_ES_READ, &hrSession); + hr = pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READ, &hrSession); - // It is possible that asynchronous requests are treated as synchronous requests. - if (FAILED(hr) || (hrSession != TF_S_ASYNC && FAILED(hrSession))) + if (FAILED(hr) || FAILED(hrSession)) { _EndInputModeWindow(); } diff --git a/imcrvtip/KeyEventSink.cpp b/imcrvtip/KeyEventSink.cpp index 5cd09113..c176bd86 100644 --- a/imcrvtip/KeyEventSink.cpp +++ b/imcrvtip/KeyEventSink.cpp @@ -6,6 +6,9 @@ static LPCWSTR c_PreservedKeyDesc[PRESERVEDKEY_NUM] = {L"ON", L"OFF"}; static const GUID c_guidPreservedKeyOnOff[PRESERVEDKEY_NUM] = {c_guidPreservedKeyOn, c_guidPreservedKeyOff}; +static LPCWSTR c_PrivateModeKeyDesc[PRIVATEMODEKEY_NUM] = {L"Private ON", L"Private OFF"}; +static const GUID c_guidPrivateModeKeyOnOff[PRIVATEMODEKEY_NUM] = {c_guidPrivateModeKeyOn, c_guidPrivateModeKeyOff}; + BOOL CTextService::_IsKeyEaten(ITfContext *pContext, WPARAM wParam) { if (_IsKeyboardDisabled()) @@ -31,8 +34,8 @@ BOOL CTextService::_IsKeyEaten(ITfContext *pContext, WPARAM wParam) } } - SHORT vk_ctrl = GetKeyState(VK_CONTROL) & 0x8000; - SHORT vk_kana = GetKeyState(VK_KANA) & 0x0001; + BYTE vk_ctrl = keystate[VK_CONTROL] & 0x80; + BYTE vk_kana = keystate[VK_KANA] & 0x01; WCHAR ch = _GetCh((BYTE)wParam); BYTE sf = _GetSf((BYTE)wParam, ch); @@ -45,6 +48,7 @@ BOOL CTextService::_IsKeyEaten(ITfContext *pContext, WPARAM wParam) switch (sf) { case SKK_JMODE: + case SKK_RECONVERT: return TRUE; break; default: @@ -61,6 +65,7 @@ BOOL CTextService::_IsKeyEaten(ITfContext *pContext, WPARAM wParam) case SKK_JLATIN: case SKK_ASCII: case SKK_ABBREV: + case SKK_RECONVERT: return TRUE; break; case SKK_DIRECT: @@ -80,6 +85,7 @@ BOOL CTextService::_IsKeyEaten(ITfContext *pContext, WPARAM wParam) case SKK_CONV_CHAR: case SKK_JLATIN: case SKK_ASCII: + case SKK_RECONVERT: return TRUE; break; case SKK_DIRECT: @@ -134,6 +140,8 @@ STDAPI CTextService::OnTestKeyDown(ITfContext *pic, WPARAM wParam, LPARAM lParam return E_INVALIDARG; } + _GetKeyboardState(); + *pfEaten = _IsKeyEaten(pic, wParam); _EndInputModeWindow(); @@ -158,6 +166,8 @@ STDAPI CTextService::OnKeyDown(ITfContext *pic, WPARAM wParam, LPARAM lParam, BO return E_INVALIDARG; } + _GetKeyboardState(); + *pfEaten = _IsKeyEaten(pic, wParam); if (*pfEaten) @@ -175,6 +185,8 @@ STDAPI CTextService::OnTestKeyUp(ITfContext *pic, WPARAM wParam, LPARAM lParam, return E_INVALIDARG; } + _GetKeyboardState(); + *pfEaten = _IsKeyEaten(pic, wParam); return S_OK; @@ -187,6 +199,8 @@ STDAPI CTextService::OnKeyUp(ITfContext *pic, WPARAM wParam, LPARAM lParam, BOOL return E_INVALIDARG; } + _GetKeyboardState(); + *pfEaten = _IsKeyEaten(pic, wParam); return S_OK; @@ -199,6 +213,8 @@ STDAPI CTextService::OnPreservedKey(ITfContext *pic, REFGUID rguid, BOOL *pfEate return E_INVALIDARG; } + _GetKeyboardState(); + BOOL fOpen = _IsKeyboardOpen(); if (IsEqualGUID(rguid, c_guidPreservedKeyOn)) @@ -231,6 +247,54 @@ STDAPI CTextService::OnPreservedKey(ITfContext *pic, REFGUID rguid, BOOL *pfEate *pfEaten = TRUE; } + else if (IsEqualGUID(rguid, c_guidPrivateModeKeyOn)) + { + if (!_IsPrivateMode()) + { + _TogglePrivateMode(); + } + + { + _UninitPrivateModeKey(0); //ON + _UninitPrivateModeKey(1); //OFF + + _InitPrivateModeKey(1); //OFF + _InitPrivateModeKey(0); //ON 未使用だがキーは拾う 重複するキーは上書きされない + } + + if (_pCandidateList != nullptr) + { + _pCandidateList->_Redraw(); + } + + _UpdateLanguageBar(); + + *pfEaten = TRUE; + } + else if (IsEqualGUID(rguid, c_guidPrivateModeKeyOff)) + { + if (_IsPrivateMode()) + { + _TogglePrivateMode(); + } + + { + _UninitPrivateModeKey(0); //ON + _UninitPrivateModeKey(1); //OFF + + _InitPrivateModeKey(0); //ON + _InitPrivateModeKey(1); //OFF 未使用だがキーは拾う 重複するキーは上書きされない + } + + if (_pCandidateList != nullptr) + { + _pCandidateList->_Redraw(); + } + + _UpdateLanguageBar(); + + *pfEaten = TRUE; + } else { *pfEaten = FALSE; @@ -321,3 +385,38 @@ void CTextService::_UninitPreservedKey(int onoff) } } } + +BOOL CTextService::_InitPrivateModeKey(int onoff) +{ + HRESULT hr = E_FAIL; + + if (onoff != 0 && onoff != 1) + { + return FALSE; + } + + CComPtr pKeystrokeMgr; + if (SUCCEEDED(_pThreadMgr->QueryInterface(IID_PPV_ARGS(&pKeystrokeMgr))) && (pKeystrokeMgr != nullptr)) + { + hr = pKeystrokeMgr->PreserveKey(_ClientId, c_guidPrivateModeKeyOnOff[onoff], + &privatemodekey[onoff], c_PrivateModeKeyDesc[onoff], (ULONG)wcslen(c_PrivateModeKeyDesc[onoff])); + } + + return SUCCEEDED(hr); +} + +void CTextService::_UninitPrivateModeKey(int onoff) +{ + HRESULT hr = E_FAIL; + + if (onoff != 0 && onoff != 1) + { + return; + } + + CComPtr pKeystrokeMgr; + if (SUCCEEDED(_pThreadMgr->QueryInterface(IID_PPV_ARGS(&pKeystrokeMgr))) && (pKeystrokeMgr != nullptr)) + { + hr = pKeystrokeMgr->UnpreserveKey(c_guidPrivateModeKeyOnOff[onoff], &privatemodekey[onoff]); + } +} diff --git a/imcrvtip/KeyHandler.cpp b/imcrvtip/KeyHandler.cpp index 9e416bbd..8b6426f9 100644 --- a/imcrvtip/KeyHandler.cpp +++ b/imcrvtip/KeyHandler.cpp @@ -7,21 +7,22 @@ class CKeyHandlerEditSession : public CEditSessionBase { public: - CKeyHandlerEditSession(CTextService *pTextService, ITfContext *pContext, WPARAM wParam, BYTE bSf) : CEditSessionBase(pTextService, pContext) + CKeyHandlerEditSession(CTextService *pTextService, ITfContext *pContext, WPARAM wParam, BYTE bSf, WCHAR wCh) : CEditSessionBase(pTextService, pContext) { _wParam = wParam; _bSf = bSf; + _wCh = wCh; } // ITfEditSession STDMETHODIMP DoEditSession(TfEditCookie ec) { #ifdef _DEBUG - _pTextService->_HandleKey(ec, _pContext, _wParam, _bSf); + _pTextService->_HandleKey(ec, _pContext, _wParam, _bSf, _wCh); #else __try { - _pTextService->_HandleKey(ec, _pContext, _wParam, _bSf); + _pTextService->_HandleKey(ec, _pContext, _wParam, _bSf, _wCh); } __except (EXCEPTION_EXECUTE_HANDLER) { @@ -35,18 +36,27 @@ class CKeyHandlerEditSession : public CEditSessionBase private: WPARAM _wParam; BYTE _bSf; + WCHAR _wCh; }; HRESULT CTextService::_InvokeKeyHandler(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BYTE bSf) { HRESULT hr = E_FAIL; + BYTE sf = bSf; + WCHAR ch = WCHAR_MAX; + + if (bSf == SKK_NULL) + { + ch = _GetCh((BYTE)wParam); + sf = _GetSf((BYTE)wParam, ch); + } try { CComPtr pEditSession; pEditSession.Attach( - new CKeyHandlerEditSession(this, pContext, wParam, bSf)); - pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_SYNC | TF_ES_READWRITE, &hr); + new CKeyHandlerEditSession(this, pContext, wParam, sf, ch)); + pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); } catch (...) { @@ -55,22 +65,11 @@ HRESULT CTextService::_InvokeKeyHandler(ITfContext *pContext, WPARAM wParam, LPA return hr; } -HRESULT CTextService::_HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM wParam, BYTE bSf) +HRESULT CTextService::_HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM wParam, BYTE bSf, WCHAR wCh) { - BYTE sf; - WCHAR ch, chO = L'\0'; HRESULT hrc = E_ABORT; - - if (bSf == SKK_NULL) - { - ch = _GetCh((BYTE)wParam); - sf = _GetSf((BYTE)wParam, ch); - } - else - { - ch = WCHAR_MAX; - sf = bSf; - } + BYTE sf = bSf; + WCHAR ch = wCh, chO = L'\0'; if (ch == L'\0' && sf == SKK_NULL) { @@ -224,11 +223,11 @@ HRESULT CTextService::_HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM w } auto vs_itr = std::lower_bound(conv_point_s.begin(), conv_point_s.end(), - ch, [] (CONV_POINT m, WCHAR v) { return (m.ch[0] < v); }); + ch, [] (const CONV_POINT &m, const WCHAR &v) { return (m.st < v); }); - if (vs_itr != conv_point_s.end() && ch == vs_itr->ch[0]) + if (vs_itr != conv_point_s.end() && ch == vs_itr->st) { - ch = vs_itr->ch[1]; + ch = vs_itr->al; ROMAN_KANA_CONV rkc = {}; wcsncpy_s(rkc.roman, roman.c_str(), _TRUNCATE); @@ -249,7 +248,7 @@ HRESULT CTextService::_HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM w if (!inputkey || !kana.empty()) { - chO = vs_itr->ch[2]; + chO = vs_itr->ok; if (SUCCEEDED(_HandleControl(ec, pContext, SKK_CONV_POINT, ch))) { return S_OK; @@ -259,11 +258,11 @@ HRESULT CTextService::_HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM w else { auto va_itr = std::lower_bound(conv_point_a.begin(), conv_point_a.end(), - ch, [] (CONV_POINT m, WCHAR v) { return (m.ch[1] < v); }); + ch, [] (const CONV_POINT &m, const WCHAR &v) { return (m.al < v); }); - if (va_itr != conv_point_a.end() && ch == va_itr->ch[1]) + if (va_itr != conv_point_a.end() && ch == va_itr->al) { - chO = va_itr->ch[2]; + chO = va_itr->ok; } } } @@ -282,11 +281,11 @@ HRESULT CTextService::_HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM w if (!roman.empty() && chO != L'\0') { auto va_itr = std::lower_bound(conv_point_a.begin(), conv_point_a.end(), - roman[0], [] (CONV_POINT m, WCHAR v) { return (m.ch[1] < v); }); + roman[0], [] (const CONV_POINT &m, const WCHAR &v) { return (m.al < v); }); - if (va_itr != conv_point_a.end() && roman[0] == va_itr->ch[1]) + if (va_itr != conv_point_a.end() && roman[0] == va_itr->al) { - chO = va_itr->ch[2]; + chO = va_itr->ok; } } @@ -354,15 +353,33 @@ void CTextService::_KeyboardOpenCloseChanged(BOOL showinputmode) _CreateConfigPath(); - _LoadDisplayAttr(); + { + _UninitPrivateModeKey(0); //ON + _UninitPrivateModeKey(1); //OFF + + _LoadUserDict(); + + _GetAppPrivateMode(); + + BOOL p = _IsPrivateMode(); + _InitPrivateModeKey(p ? 1 : 0); //OFF or ON + _InitPrivateModeKey(p ? 0 : 1); //ON or OFF 未使用だがキーは拾う 重複するキーは上書きされない + } + _LoadBehavior(); + _LoadDisplay(); + _LoadDisplayAttr(); _LoadSelKey(); - _UninitPreservedKey(0); //ON - _UninitPreservedKey(1); //OFF - _LoadPreservedKey(); - _InitPreservedKey(1); //OFF - _InitPreservedKey(0); //ON 未使用だがキーは拾う 重複するキーは上書きされない + { + _UninitPreservedKey(0); //ON + _UninitPreservedKey(1); //OFF + + _LoadPreservedKey(); + + _InitPreservedKey(1); //OFF + _InitPreservedKey(0); //ON 未使用だがキーは拾う 重複するキーは上書きされない + } _LoadCKeyMap(); _LoadVKeyMap(); @@ -401,11 +418,15 @@ void CTextService::_KeyboardOpenCloseChanged(BOOL showinputmode) _CreateConfigPath(); - _UninitPreservedKey(1); //OFF - _UninitPreservedKey(0); //ON - _LoadPreservedKey(); - _InitPreservedKey(0); //ON - _InitPreservedKey(1); //OFF 未使用だがキーは拾う 重複するキーは上書きされない + { + _UninitPreservedKey(1); //OFF + _UninitPreservedKey(0); //ON + + _LoadPreservedKey(); + + _InitPreservedKey(0); //ON + _InitPreservedKey(1); //OFF 未使用だがキーは拾う 重複するキーは上書きされない + } } _UpdateLanguageBar(showinputmode); @@ -503,9 +524,10 @@ BOOL CTextService::_IsKeyVoid(WCHAR ch, BYTE vk) { if (vk < VKEYMAPNUM) { - SHORT vk_shift = GetKeyState(VK_SHIFT) & 0x8000; - SHORT vk_ctrl = GetKeyState(VK_CONTROL) & 0x8000; BYTE k = SKK_NULL; + BYTE vk_shift = keystate[VK_SHIFT] & 0x80; + BYTE vk_ctrl = keystate[VK_CONTROL] & 0x80; + if (vk_shift) { k = vkeymap_shift.keyvoid[vk]; @@ -518,6 +540,7 @@ BOOL CTextService::_IsKeyVoid(WCHAR ch, BYTE vk) { k = vkeymap.keyvoid[vk]; } + if (k == SKK_VOID) { return TRUE; @@ -549,7 +572,7 @@ void CTextService::_ResetStatus() roman.clear(); kana.clear(); okuriidx = 0; - reconvsrc.clear(); + reconvtext.clear(); searchkey.clear(); searchkeyorg.clear(); @@ -558,6 +581,7 @@ void CTextService::_ResetStatus() candidates.shrink_to_fit(); candidx = 0; candorgcnt = 0; + convword.clear(); cursoridx = 0; } @@ -585,5 +609,8 @@ void CTextService::_GetActiveFlags() _UILessMode = TRUE; } - _ShowInputMode = cx_showmodeinl && !_UILessMode; + if (cx_showmodeinl && !_UILessMode) + { + _ShowInputMode = TRUE; + } } diff --git a/imcrvtip/KeyHandlerChar.cpp b/imcrvtip/KeyHandlerCharacter.cpp similarity index 94% rename from imcrvtip/KeyHandlerChar.cpp rename to imcrvtip/KeyHandlerCharacter.cpp index b94137f7..4767004c 100644 --- a/imcrvtip/KeyHandlerChar.cpp +++ b/imcrvtip/KeyHandlerCharacter.cpp @@ -72,7 +72,7 @@ HRESULT CTextService::_HandleChar(TfEditCookie ec, ITfContext *pContext, WPARAM break; } - ROMAN_KANA_CONV rkcn; + ROMAN_KANA_CONV rkcn = {}; wcsncpy_s(rkcn.roman, roman_conv.c_str(), _TRUNCATE); ret = _ConvRomanKana(&rkcn); switch (ret) diff --git a/imcrvtip/KeyHandlerComposition.cpp b/imcrvtip/KeyHandlerComposition.cpp index 65ce69f8..d9d6e531 100644 --- a/imcrvtip/KeyHandlerComposition.cpp +++ b/imcrvtip/KeyHandlerComposition.cpp @@ -606,33 +606,3 @@ void CTextService::_EndCompletionList(TfEditCookie ec, ITfContext *pContext) _EndCandidateList(); } } - -BOOL CTextService::_GetVertical(TfEditCookie ec, ITfContext *pContext) -{ - BOOL ret = FALSE; - - if (pContext != nullptr) - { - if (_IsComposing()) - { - CComPtr pRange; - if (SUCCEEDED(_pComposition->GetRange(&pRange)) && (pRange != nullptr)) - { - CComPtr pReadOnlyProperty; - if (SUCCEEDED(pContext->GetAppProperty(TSATTRID_Text_VerticalWriting, &pReadOnlyProperty)) && (pReadOnlyProperty != nullptr)) - { - CComVariant var; - if (SUCCEEDED(pReadOnlyProperty->GetValue(ec, pRange, &var))) - { - if (V_VT(&var) == VT_BOOL) - { - ret = V_BOOL(&var); - } - } - } - } - } - } - - return ret; -} diff --git a/imcrvtip/KeyHandlerControl.cpp b/imcrvtip/KeyHandlerControl.cpp index e6c031ef..1b85119a 100644 --- a/imcrvtip/KeyHandlerControl.cpp +++ b/imcrvtip/KeyHandlerControl.cpp @@ -28,7 +28,7 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE } //ひらがな/カタカナに変換 - _ConvKanaToKana(kana, inputmode, kana, (inputmode == im_hiragana ? im_katakana : im_hiragana)); + _ConvKanaToKana(kana, inputmode, kana, ((inputmode == im_hiragana) ? im_katakana : im_hiragana)); _HandleCharReturn(ec, pContext); } else @@ -39,10 +39,10 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE _HandleCharReturn(ec, pContext); } - if (cx_entogglekana || inputmode == im_hiragana) + if (cx_entogglekana || (inputmode == im_hiragana)) { //ひらがな/カタカナモードへ - inputmode = (inputmode == im_hiragana ? im_katakana : im_hiragana); + inputmode = ((inputmode == im_hiragana) ? im_katakana : im_hiragana); } _UpdateLanguageBar(); } @@ -161,7 +161,7 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE } //アスキー/全英モードへ - inputmode = (sf == SKK_ASCII ? im_ascii : im_jlatin); + inputmode = ((sf == SKK_ASCII) ? im_ascii : im_jlatin); _UpdateLanguageBar(); return S_OK; break; @@ -332,7 +332,7 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE if (purgedicmode) { purgedicmode = FALSE; - _DelUserDic((okuriidx == 0 ? REQ_USER_DEL_N : REQ_USER_DEL_A), + _DelUserDic(((okuriidx == 0) ? REQ_USER_DEL_N : REQ_USER_DEL_A), ((candorgcnt <= candidx) ? searchkey : searchkeyorg), candidates[candidx].second.first); showentry = FALSE; @@ -471,7 +471,7 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE { if (complement) { - return _HandleKey(ec, pContext, 0, SKK_NEXT_CAND); + return _HandleKey(ec, pContext, 0, SKK_NEXT_CAND, WCHAR_MAX); } return S_OK; } @@ -601,7 +601,7 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE if (inputkey || !kana.empty() || !roman.empty()) { _ConvRoman(); - _HandleCharReturn(ec, pContext, (_GetSf(0, ch) == SKK_BACK ? TRUE : FALSE)); + _HandleCharReturn(ec, pContext, ((_GetSf(0, ch) == SKK_BACK) ? TRUE : FALSE)); } return S_OK; break; @@ -658,7 +658,7 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE if (reconversion) { - kana = reconvsrc; + kana = reconvtext; } else { @@ -1007,8 +1007,8 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE PWCHAR pwCB = (PWCHAR)GlobalLock(hCB); if (pwCB != nullptr) { - std::wstring scb = std::regex_replace(std::wstring(pwCB), - std::wregex(L"[\\x00-\\x19]"), std::wstring(L"")); + static const std::wregex rectrl(L"[\\x00-\\x19]"); + std::wstring scb = std::regex_replace(std::wstring(pwCB), rectrl, L""); kana.insert(cursoridx, scb); if (okuriidx != 0 && cursoridx <= okuriidx) { @@ -1029,6 +1029,15 @@ HRESULT CTextService::_HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE CloseClipboard(); } } + return S_OK; + break; + + case SKK_RECONVERT: + if (!inputkey && !showentry) + { + _Reconv(ec, pContext); + return S_OK; + } break; default: diff --git a/imcrvtip/KeyHandlerConv.cpp b/imcrvtip/KeyHandlerConversion.cpp similarity index 80% rename from imcrvtip/KeyHandlerConv.cpp rename to imcrvtip/KeyHandlerConversion.cpp index 205a78ef..1e325a24 100644 --- a/imcrvtip/KeyHandlerConv.cpp +++ b/imcrvtip/KeyHandlerConversion.cpp @@ -3,14 +3,24 @@ #include "TextService.h" #include "CandidateList.h" +BOOL CTextService::_GetKeyboardState() +{ + ZeroMemory(keystate, sizeof(keystate)); + + if (GetKeyboardState(keystate) == FALSE) + { + ZeroMemory(keystate, sizeof(keystate)); + + return FALSE; + } + + return TRUE; +} + WCHAR CTextService::_GetCh(BYTE vk, BYTE vkoff) { - BYTE keystate[256]; - WCHAR ubuff; WCHAR u = L'\0'; - GetKeyboardState(keystate); - switch (inputmode) { case im_hiragana: @@ -34,10 +44,10 @@ WCHAR CTextService::_GetCh(BYTE vk, BYTE vkoff) break; } - int retu = ToUnicode(vk, 0, keystate, &ubuff, 1, 0); - if (retu == 1) + int retu = ToUnicode(vk, 0, keystate, &u, 1, 0); + if (retu != 1) { - u = ubuff; + u = L'\0'; } return u; @@ -46,8 +56,8 @@ WCHAR CTextService::_GetCh(BYTE vk, BYTE vkoff) BYTE CTextService::_GetSf(BYTE vk, WCHAR ch) { BYTE k = SKK_NULL; - SHORT vk_shift = GetKeyState(VK_SHIFT) & 0x8000; - SHORT vk_ctrl = GetKeyState(VK_CONTROL) & 0x8000; + BYTE vk_shift = keystate[VK_SHIFT] & 0x80; + BYTE vk_ctrl = keystate[VK_CONTROL] & 0x80; if (vk < VKEYMAPNUM) { @@ -167,7 +177,7 @@ HRESULT CTextService::_SearchRomanKanaNode(const ROMAN_KANA_NODE &tree, ROMAN_KA } auto v_itr = std::lower_bound(tree.nodes.begin(), tree.nodes.end(), - pconv->roman[depth], [] (ROMAN_KANA_NODE m, WCHAR v) { return (m.ch < v); }); + pconv->roman[depth], [] (const ROMAN_KANA_NODE &m, const WCHAR &v) { return (m.ch < v); }); if (v_itr != tree.nodes.end() && v_itr->ch == pconv->roman[depth]) { @@ -208,7 +218,7 @@ HRESULT CTextService::_ConvAsciiJLatin(ASCII_JLATIN_CONV *pconv) } auto v_itr = std::lower_bound(ascii_jlatin_conv.begin(), ascii_jlatin_conv.end(), - pconv->ascii[0], [] (ASCII_JLATIN_CONV m, WCHAR v) { return (m.ascii[0] < v); }); + pconv->ascii[0], [] (const ASCII_JLATIN_CONV &m, const WCHAR &v) { return (m.ascii[0] < v); }); if (v_itr != ascii_jlatin_conv.end() && v_itr->ascii[0] == pconv->ascii[0]) { @@ -323,8 +333,6 @@ void CTextService::_StartSubConv(WCHAR command) _ConvKanaToKana(kana, inputmode, searchkey, im_hiragana); } - candidates.clear(); - candidates.shrink_to_fit(); candorgcnt = 0; searchkeyorg = searchkey; @@ -335,8 +343,6 @@ void CTextService::_StartSubConv(WCHAR command) if (cx_srchallokuri && okuriidx != 0) { candidates_bak = candidates; - candidates.clear(); - candidates.shrink_to_fit(); searchkey.pop_back(); @@ -410,8 +416,6 @@ void CTextService::_StartSubConv(WCHAR command) candorgcnt = candidates.size(); candidates_bak = candidates; - candidates.clear(); - candidates.shrink_to_fit(); searchkeyorg = searchkey; //オリジナルバックアップ @@ -430,15 +434,18 @@ void CTextService::_StartSubConv(WCHAR command) } //見出し語変換 - _ConvertWord(REQ_CONVERTKEY, searchkeyorg, std::wstring(L""), okurikey, searchkey); + _ConvertWord(REQ_CONVERTKEY, searchkeyorg, L"", okurikey); + + searchkey = convword; if (!searchkey.empty() && searchkey != searchkeyorg) { //変換済み見出し語検索 _SearchDic(command); + + candidates_num = candidates; } - candidates_num = candidates; candidates.clear(); candidates.shrink_to_fit(); @@ -446,6 +453,7 @@ void CTextService::_StartSubConv(WCHAR command) { candidates.insert(candidates.end(), candidates_bak.begin(), candidates_bak.end()); } + if (!candidates_num.empty()) { candidates.insert(candidates.end(), candidates_num.begin(), candidates_num.end()); @@ -515,9 +523,6 @@ void CTextService::_NextComp() _ConvKanaToKana(kana, inputmode, searchkey, im_hiragana); } - candidates.clear(); - candidates.shrink_to_fit(); - //候補の表示数は「候補一覧表示に要する変換回数」-1 個まで WCHAR c = L'0'; if (cx_untilcandlist >= 1 && cx_untilcandlist <= 9) @@ -759,11 +764,11 @@ BOOL CTextService::_ConvShift(WCHAR ch) // ローマ字に格納されている仮名をキーに、変換位置指定の「代替」を検索する。 // ヒットしたエントリの「送り」を送りローマ字とする。 auto va_itr = std::lower_bound(conv_point_a.begin(), conv_point_a.end(), - chN, [] (CONV_POINT m, WCHAR v) { return (m.ch[1] < v); }); + chN, [] (const CONV_POINT &m, const WCHAR &v) { return (m.al < v); }); - if (va_itr != conv_point_a.end() && chN == va_itr->ch[1]) + if (va_itr != conv_point_a.end() && chN == va_itr->al) { - chO = va_itr->ch[2]; + chO = va_itr->ok; } if (chO == L'\0') @@ -937,9 +942,8 @@ BOOL CTextService::_ConvN() void CTextService::_ConvKanaToKana(const std::wstring &src, int srcmode, std::wstring &dst, int dstmode) { - BOOL exist; - WCHAR *convkana = nullptr; - WCHAR srckana[3]; + BOOL exist = FALSE; + WCHAR srckana[3] = {}; std::wstring dsttmp; switch (srcmode) @@ -1062,11 +1066,11 @@ void CTextService::_ConvOkuriRoman() // 送り仮名の先頭をキーに、変換位置指定の「代替」を検索する。 // ヒットしたエントリの「送り」を送りローマ字とする。 auto va_itr = std::lower_bound(conv_point_a.begin(), conv_point_a.end(), - chN, [](CONV_POINT m, WCHAR v) { return (m.ch[1] < v); }); + chN, [](const CONV_POINT &m, const WCHAR &v) { return (m.al < v); }); - if (va_itr != conv_point_a.end() && chN == va_itr->ch[1]) + if (va_itr != conv_point_a.end() && chN == va_itr->al) { - chO = va_itr->ch[2]; + chO = va_itr->ok; } if (chO == L'\0') @@ -1085,3 +1089,105 @@ void CTextService::_ConvOkuriRoman() } } } + +void CTextService::_Reconv(TfEditCookie ec, ITfContext *pContext) +{ + if (pContext == nullptr) + { + return; + } + + TF_SELECTION tfSelection = {}; + ULONG cFetched = 0; + if (FAILED(pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched))) + { + return; + } + + CComPtr pRangeSelection; + pRangeSelection.Attach(tfSelection.range); + + if (cFetched != 1) + { + return; + } + + CComPtr pRange; + BOOL fConvertable = FALSE; + if (FAILED(QueryRange(pRangeSelection, &pRange, &fConvertable)) || !fConvertable) + { + return; + } + + HWND hwnd = nullptr; + BOOL fEmpty = FALSE; + if (SUCCEEDED(pRange->IsEmpty(ec, &fEmpty)) && fEmpty) + { + CComPtr pContextView; + if (SUCCEEDED(pContext->GetActiveView(&pContextView)) && (pContextView != nullptr)) + { + pContextView->GetWnd(&hwnd); + } + } + + if (hwnd != nullptr) + { + DWORD size = (DWORD)SendMessageW(hwnd, WM_IME_REQUEST, IMR_RECONVERTSTRING, 0); + + if (size > sizeof(RECONVERTSTRING)) + { + CComHeapPtr rsbuf; + rsbuf.Allocate(size); + + PRECONVERTSTRING rs = reinterpret_cast((PBYTE)rsbuf); + rs->dwSize = size; + rs->dwVersion = 0; + + size = (DWORD)SendMessageW(hwnd, WM_IME_REQUEST, IMR_RECONVERTSTRING, reinterpret_cast(rs)); + + if (size > sizeof(RECONVERTSTRING)) + { + DWORD ofs = rs->dwStrOffset + rs->dwCompStrOffset; + DWORD len = rs->dwCompStrLen; + + if ((ofs + len) <= size) + { + CComBSTR text; + + if (IsWindowUnicode(hwnd)) + { + text = CComBSTR(len, reinterpret_cast(&rsbuf[ofs])); + } + else + { + int wlen = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, + reinterpret_cast(&rsbuf[ofs]), len, nullptr, 0); + + if (wlen > 0) + { + CComHeapPtr wbuf; + wbuf.Allocate(wlen); + + if (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, + reinterpret_cast(&rsbuf[ofs]), len, wbuf, wlen) > 0) + { + text = CComBSTR(wlen, wbuf); + } + } + } + + if (text.Length() > 0) + { + pRange->SetText(ec, 0, text, text.Length()); + } + } + } + } + } + + fEmpty = TRUE; + if (SUCCEEDED(pRange->IsEmpty(ec, &fEmpty)) && !fEmpty) + { + Reconvert(pRange); + } +} diff --git a/imcrvtip/KeyHandlerDictionary.cpp b/imcrvtip/KeyHandlerDictionary.cpp index d49f94f2..133ddf4c 100644 --- a/imcrvtip/KeyHandlerDictionary.cpp +++ b/imcrvtip/KeyHandlerDictionary.cpp @@ -38,10 +38,12 @@ void CTextService::_DisconnectDic() void CTextService::_SearchDic(WCHAR command) { DWORD bytesWrite, bytesRead; - std::wstring s, se, fmt, scd, scr, sad, sar, okurikey; - std::wregex r; + std::wstring s, se, scd, scr, sad, sar, okurikey; std::wsmatch m; + candidates.clear(); + candidates.shrink_to_fit(); + _StartManager(); _ConnectDic(); @@ -74,32 +76,29 @@ void CTextService::_SearchDic(WCHAR command) ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } - if (pipebuf[0] != REP_OK) + if ((pipebuf[0] != REP_OK) || (pipebuf[1] != L'\n')) { goto exit; } - s.assign(pipebuf); - r.assign(L"(.*)\t(.*)\t(.*)\t(.*)\n"); + s.assign(&pipebuf[2]); + + static const std::wregex re(L"(.*)\t(.*)\t(.*)\t(.*)\n"); - while (std::regex_search(s, m, r)) + while (std::regex_search(s, m, re)) { se = m.str(); s = m.suffix().str(); - fmt.assign(L"$1"); - scd = std::regex_replace(se, r, fmt); - fmt.assign(L"$2"); - scr = std::regex_replace(se, r, fmt); - fmt.assign(L"$3"); - sad = std::regex_replace(se, r, fmt); - fmt.assign(L"$4"); - sar = std::regex_replace(se, r, fmt); + scd = std::regex_replace(se, re, L"$1"); + scr = std::regex_replace(se, re, L"$2"); + sad = std::regex_replace(se, re, L"$3"); + sar = std::regex_replace(se, re, L"$4"); if (scd.empty()) { @@ -120,9 +119,12 @@ void CTextService::_SearchDic(WCHAR command) _DisconnectDic(); } -void CTextService::_ConvertWord(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &okuri, std::wstring &conv) +void CTextService::_ConvertWord(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &okuri) { DWORD bytesWrite, bytesRead; + PWCHAR pn; + + convword.clear(); _StartManager(); @@ -142,19 +144,22 @@ void CTextService::_ConvertWord(WCHAR command, const std::wstring &key, const st ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } - if (pipebuf[0] != REP_OK) + if ((pipebuf[0] != REP_OK) || (pipebuf[1] != L'\n')) { - conv.clear(); goto exit; } - pipebuf[wcslen(pipebuf) - 1] = L'\0'; - conv.assign(&pipebuf[2]); + pn = &pipebuf[wcslen(pipebuf) - 1]; + if (*pn == L'\n') + { + *pn = L'\0'; + convword.assign(&pipebuf[2]); + } exit: ZeroMemory(pipebuf, sizeof(pipebuf)); @@ -164,6 +169,9 @@ void CTextService::_ConvertWord(WCHAR command, const std::wstring &key, const st void CTextService::_AddUserDic(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &annotation) { + //Private Mode + if (_IsPrivateMode()) return; + DWORD bytesWrite, bytesRead; std::wstring okurikey; @@ -197,7 +205,7 @@ void CTextService::_AddUserDic(WCHAR command, const std::wstring &key, const std ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } @@ -210,6 +218,9 @@ void CTextService::_AddUserDic(WCHAR command, const std::wstring &key, const std void CTextService::_DelUserDic(WCHAR command, const std::wstring &key, const std::wstring &candidate) { + //Private Mode + if (_IsPrivateMode()) return; + DWORD bytesWrite, bytesRead; _ConnectDic(); @@ -228,7 +239,7 @@ void CTextService::_DelUserDic(WCHAR command, const std::wstring &key, const std ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } @@ -261,7 +272,7 @@ void CTextService::_CommandDic(WCHAR command) } bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } diff --git a/imcrvtip/LanguageBar.cpp b/imcrvtip/LanguageBar.cpp index 941b4e5a..0073983d 100644 --- a/imcrvtip/LanguageBar.cpp +++ b/imcrvtip/LanguageBar.cpp @@ -20,6 +20,8 @@ static const struct { {im_disable, IDM_CAPSLOCK, 0, L"CAPS"}, {im_disable, IDM_KANALOCK, 0, L"KANA"}, {im_disable, IDM_NONE, TF_LBMENUF_SEPARATOR, L""}, + {im_disable, IDM_PRIVATE, 0, L"Private"}, + {im_disable, IDM_NONE, TF_LBMENUF_SEPARATOR, L""}, {im_hiragana, IDM_HIRAGANA, 0, L"[かな]"}, {im_katakana, IDM_KATAKANA, 0, L"[カナ]"}, {im_katakana_ank, IDM_KATAKANA_ANK, 0, L"[-カナ]"}, @@ -43,6 +45,17 @@ static const WORD iconIDZ[] = IDI_Z_DEFAULT, IDI_Z_HIRAGANA, IDI_Z_KATAKANA, IDI_Z_KATAKANA1, IDI_Z_JLATIN, IDI_Z_ASCII }; +// 16 colors (black only) icons (Private) +static const WORD iconIDPX[] = +{ + IDI_X_DEFAULT, IDI_PX_HIRAGANA, IDI_PX_KATAKANA, IDI_PX_KATAKANA1, IDI_PX_JLATIN, IDI_PX_ASCII +}; +// png icons (Private) +static const WORD iconIDPZ[] = +{ + IDI_Z_DEFAULT, IDI_PZ_HIRAGANA, IDI_PZ_KATAKANA, IDI_PZ_KATAKANA1, IDI_PZ_JLATIN, IDI_PZ_ASCII +}; + CLangBarItemButton::CLangBarItemButton(CTextService *pTextService, REFGUID guid) { DllAddRef(); @@ -200,15 +213,22 @@ STDAPI CLangBarItemButton::OnClick(TfLBIClick click, POINT pt, const RECT *prcAr break; } } + CheckMenuRadioItem(hMenu, IDM_HIRAGANA, IDM_DIRECT, check, MF_BYCOMMAND); + CheckMenuItem(hMenu, IDM_CAPSLOCK, - MF_BYCOMMAND | ((GetKeyState(VK_CAPITAL) & 1) == 1 ? MF_CHECKED : MF_UNCHECKED)); + MF_BYCOMMAND | (((GetKeyState(VK_CAPITAL) & 1) == 1) ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(hMenu, IDM_KANALOCK, - MF_BYCOMMAND | ((GetKeyState(VK_KANA) & 1) == 1 ? MF_CHECKED : MF_UNCHECKED)); + MF_BYCOMMAND | (((GetKeyState(VK_KANA) & 1) == 1) ? MF_CHECKED : MF_UNCHECKED)); + + CheckMenuItem(hMenu, IDM_PRIVATE, + MF_BYCOMMAND | + (_pTextService->_IsPrivateMode() ? MF_CHECKED : MF_UNCHECKED)); + HMENU hSubMenu = GetSubMenu(hMenu, 0); if (hSubMenu) { - TPMPARAMS tpm; + TPMPARAMS tpm = {}; TPMPARAMS *ptpm = nullptr; if (prcArea != nullptr) { @@ -261,14 +281,19 @@ STDAPI CLangBarItemButton::InitMenu(ITfMenu *pMenu) switch (menuItems[i].id) { case IDM_CAPSLOCK: - pMenu->AddMenuItem(menuItems[i].id, menuItems[i].flag | - ((GetKeyState(VK_CAPITAL) & 1) == 1 ? TF_LBMENUF_CHECKED : 0), - nullptr, nullptr, menuItems[i].text, (ULONG)wcslen(menuItems[i].text), nullptr); + _AddMenuItem(pMenu, menuItems[i].id, + menuItems[i].flag | (((GetKeyState(VK_CAPITAL) & 1) == 1) ? TF_LBMENUF_CHECKED : 0), + menuItems[i].text, (ULONG)wcslen(menuItems[i].text)); break; case IDM_KANALOCK: - pMenu->AddMenuItem(menuItems[i].id, menuItems[i].flag | - ((GetKeyState(VK_KANA) & 1) == 1 ? TF_LBMENUF_CHECKED : 0), - nullptr, nullptr, menuItems[i].text, (ULONG)wcslen(menuItems[i].text), nullptr); + _AddMenuItem(pMenu, menuItems[i].id, + menuItems[i].flag | (((GetKeyState(VK_KANA) & 1) == 1) ? TF_LBMENUF_CHECKED : 0), + menuItems[i].text, (ULONG)wcslen(menuItems[i].text)); + break; + case IDM_PRIVATE: + _AddMenuItem(pMenu, menuItems[i].id, + menuItems[i].flag | (_pTextService->_IsPrivateMode() ? TF_LBMENUF_CHECKED : 0), + menuItems[i].text, (ULONG)wcslen(menuItems[i].text)); break; case IDM_HIRAGANA: case IDM_KATAKANA: @@ -277,9 +302,9 @@ STDAPI CLangBarItemButton::InitMenu(ITfMenu *pMenu) case IDM_ASCII: case IDM_DIRECT: default: - pMenu->AddMenuItem(menuItems[i].id, menuItems[i].flag | - (_pTextService->inputmode == menuItems[i].inputmode ? TF_LBMENUF_RADIOCHECKED : 0), - nullptr, nullptr, menuItems[i].text, (ULONG)wcslen(menuItems[i].text), nullptr); + _AddMenuItem(pMenu, menuItems[i].id, + menuItems[i].flag | ((_pTextService->inputmode == menuItems[i].inputmode) ? TF_LBMENUF_RADIOCHECKED : 0), + menuItems[i].text, (ULONG)wcslen(menuItems[i].text)); break; } } @@ -305,6 +330,10 @@ STDAPI CLangBarItemButton::OnMenuSelect(UINT wID) break; } break; + case IDM_PRIVATE: + _pTextService->_TogglePrivateMode(); + _pTextService->_UpdateLanguageBar(); + break; case IDM_CONFIG: _pTextService->_StartConfigure(); break; @@ -513,18 +542,38 @@ HRESULT CLangBarItemButton::_GetIcon(HICON *phIcon, INT size, BOOL bNT62) } } - if (bNT62) + if (_pTextService->_IsPrivateMode()) { - if (iconindex < _countof(iconIDZ)) + if (bNT62) { - iconid = iconIDZ[iconindex]; + if (iconindex < _countof(iconIDPZ)) + { + iconid = iconIDPZ[iconindex]; + } + } + else + { + if (iconindex < _countof(iconIDPX)) + { + iconid = iconIDPX[iconindex]; + } } } else { - if (iconindex < _countof(iconIDX)) + if (bNT62) + { + if (iconindex < _countof(iconIDZ)) + { + iconid = iconIDZ[iconindex]; + } + } + else { - iconid = iconIDX[iconindex]; + if (iconindex < _countof(iconIDX)) + { + iconid = iconIDX[iconindex]; + } } } @@ -533,6 +582,18 @@ HRESULT CLangBarItemButton::_GetIcon(HICON *phIcon, INT size, BOOL bNT62) return (*phIcon != nullptr) ? S_OK : E_FAIL; } +HRESULT CLangBarItemButton::_AddMenuItem(ITfMenu *pMenu, UINT uId, DWORD dwFlags, LPCWSTR pch, ULONG cch) +{ + if (pMenu == nullptr) + { + return E_FAIL; + } +#pragma warning(push) +#pragma warning(disable:6387) + return pMenu->AddMenuItem(uId, dwFlags, nullptr, nullptr, pch, cch, nullptr); +#pragma warning(pop) +} + BOOL CTextService::_InitLanguageBar() { BOOL fRet = FALSE; @@ -584,7 +645,7 @@ BOOL CTextService::_InitLanguageBar() } } - return (fRet && fRetI); + return ((fRet && fRetI) ? TRUE : FALSE); } void CTextService::_UninitLanguageBar() diff --git a/imcrvtip/LanguageBar.h b/imcrvtip/LanguageBar.h index 7f9d8480..a02ae165 100644 --- a/imcrvtip/LanguageBar.h +++ b/imcrvtip/LanguageBar.h @@ -32,6 +32,7 @@ class CLangBarItemButton : HRESULT _Update(); HRESULT _GetIcon(HICON *phIcon, INT size, BOOL bNT62); + HRESULT _AddMenuItem(ITfMenu *pMenu, UINT uId, DWORD dwFlags, LPCWSTR pch, ULONG cch); private: LONG _cRef; diff --git a/imcrvtip/Property.cpp b/imcrvtip/Property.cpp new file mode 100644 index 00000000..e99159e1 --- /dev/null +++ b/imcrvtip/Property.cpp @@ -0,0 +1,205 @@ + +#include +#include +#include + +#include "imcrvtip.h" +#include "TextService.h" +#include "EditSession.h" + +BOOL CTextService::_IsVertical(TfEditCookie ec, ITfContext *pContext) +{ + BOOL ret = FALSE; + + if (pContext == nullptr) + { + return FALSE; + } + + if (_IsComposing()) + { + CComPtr pReadOnlyProperty; + if (SUCCEEDED(pContext->GetAppProperty(TSATTRID_Text_VerticalWriting, &pReadOnlyProperty)) && (pReadOnlyProperty != nullptr)) + { + CComPtr pRange; + if (SUCCEEDED(_pComposition->GetRange(&pRange)) && (pRange != nullptr)) + { + CComVariant var; + if (SUCCEEDED(pReadOnlyProperty->GetValue(ec, pRange, &var))) + { + if (V_VT(&var) == VT_BOOL) + { + ret = V_BOOL(&var); + } + } + } + } + } + + return ret; +} + +BOOL CTextService::_IsAppPrivateScope(TfEditCookie ec, ITfContext *pContext) +{ + BOOL ret = FALSE; + + if (pContext == nullptr) + { + return FALSE; + } + + TF_SELECTION tfSelection = {}; + ULONG cFetched = 0; + if (FAILED(pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched))) + { + return FALSE; + } + + CComPtr pRangeSelection; + pRangeSelection.Attach(tfSelection.range); + + if (cFetched != 1) + { + return FALSE; + } + + CComPtr pReadOnlyProperty; + if (SUCCEEDED(pContext->GetAppProperty(GUID_PROP_INPUTSCOPE, &pReadOnlyProperty)) && (pReadOnlyProperty != nullptr)) + { + CComVariant var; + if (SUCCEEDED(pReadOnlyProperty->GetValue(ec, pRangeSelection, &var)) && (var.punkVal != nullptr)) + { + CComPtr pInputScope; + if (SUCCEEDED(var.punkVal->QueryInterface(IID_PPV_ARGS(&pInputScope))) && (pInputScope != nullptr)) + { + InputScope *pInputScopes = nullptr; + UINT cCount = 0; + if (SUCCEEDED(pInputScope->GetInputScopes(&pInputScopes, &cCount)) && (pInputScopes != nullptr)) + { + for (UINT i = 0; i < cCount; i++) + { + if (pInputScopes[i] == InputScope::IS_PRIVATE) + { + ret = TRUE; + break; + } + } + CoTaskMemFree(pInputScopes); + } + } + } + } + + return ret; +} + +class CGetAppPrivateModeEditSession : public CEditSessionBase +{ +public: + CGetAppPrivateModeEditSession(CTextService *pTextService, ITfContext *pContext, BOOL *pIsPrivate) : CEditSessionBase(pTextService, pContext) + { + _pIsPrivate = pIsPrivate; + } + + // ITfEditSession + STDMETHODIMP DoEditSession(TfEditCookie ec) + { + if (_pIsPrivate != nullptr) + { + *_pIsPrivate = _pTextService->_IsAppPrivateScope(ec, _pContext); + } + return S_OK; + } + +private: + BOOL *_pIsPrivate; +}; + +void CTextService::_GetAppPrivateMode() +{ + BOOL isPrivate = FALSE; + + CComPtr pDocumentMgr; + if (SUCCEEDED(_pThreadMgr->GetFocus(&pDocumentMgr)) && (pDocumentMgr != nullptr)) + { + CComPtr pContext; + if (SUCCEEDED(pDocumentMgr->GetTop(&pContext)) && (pContext != nullptr)) + { + try + { + HRESULT hr = E_FAIL; + + CComPtr pEditSession; + pEditSession.Attach( + new CGetAppPrivateModeEditSession(this, pContext, &isPrivate)); + pContext->RequestEditSession(_ClientId, pEditSession, TF_ES_SYNC | TF_ES_READ, &hr); + } + catch (...) + { + } + } + } + + _AppPrivateMode = isPrivate; +} + +BOOL CTextService::_IsPrivateMode() +{ + switch (_UserPrivateMode) + { + case S_OK: + //ON + return TRUE; + case E_FAIL: + //未定義 自動切替とIS_PRIVATEに従ってON/OFF + if (cx_privatemodeauto && _AppPrivateMode) + { + return TRUE; + } + break; + case S_FALSE: + //OFF + break; + default: + break; + } + return FALSE; +} + +void CTextService::_TogglePrivateMode() +{ + if (cx_privatemodeauto && _AppPrivateMode) + { + switch (_UserPrivateMode) + { + case S_OK: + case E_FAIL: + //OFF + _UserPrivateMode = S_FALSE; + break; + case S_FALSE: + //未定義 自動切替とIS_PRIVATEに従ってON + _UserPrivateMode = E_FAIL; + break; + default: + break; + } + } + else + { + switch (_UserPrivateMode) + { + case S_OK: + //未定義 自動切替とIS_PRIVATEに従ってOFF + _UserPrivateMode = E_FAIL; + break; + case E_FAIL: + case S_FALSE: + //ON + _UserPrivateMode = S_OK; + break; + default: + break; + } + } +} diff --git a/imcrvtip/Register.cpp b/imcrvtip/Register.cpp index 597d916b..d511db63 100644 --- a/imcrvtip/Register.cpp +++ b/imcrvtip/Register.cpp @@ -30,13 +30,12 @@ static const GUID c_guidCategory8[] = BOOL RegisterProfiles() { HRESULT hr = E_FAIL; - WCHAR fileName[MAX_PATH]; + WCHAR fileName[MAX_PATH] = {}; CComPtr pInputProcessorProfileMgr; hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pInputProcessorProfileMgr)); if (SUCCEEDED(hr) && (pInputProcessorProfileMgr != nullptr)) { - ZeroMemory(fileName, sizeof(fileName)); GetModuleFileNameW(g_hInst, fileName, _countof(fileName)); hr = pInputProcessorProfileMgr->RegisterProfile(c_clsidTextService, TEXTSERVICE_LANGID, c_guidProfile, @@ -126,11 +125,11 @@ void UnregisterCategories() BOOL RegisterServer() { - WCHAR szInfoKey[_countof(c_szInfoKeyPrefix) + CLSID_STRLEN]; - HKEY hKey; - HKEY hSubKey; + WCHAR szInfoKey[_countof(c_szInfoKeyPrefix) + CLSID_STRLEN] = {}; + HKEY hKey = nullptr; + HKEY hSubKey = nullptr; BOOL fRet = FALSE; - WCHAR fileName[MAX_PATH]; + WCHAR fileName[MAX_PATH] = {}; if (StringFromGUID2(c_clsidTextService, szInfoKey + _countof(c_szInfoKeyPrefix) - 1, CLSID_STRLEN + 1) == 0) { @@ -144,7 +143,7 @@ BOOL RegisterServer() return FALSE; } - if (RegSetValueExW(hKey, nullptr, 0, REG_SZ, (BYTE *)TextServiceDesc, (DWORD)(wcslen(TextServiceDesc) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS) + if (RegSetValueExW(hKey, nullptr, 0, REG_SZ, (CONST LPBYTE)TextServiceDesc, (DWORD)(wcslen(TextServiceDesc) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS) { goto exit; } @@ -154,15 +153,14 @@ BOOL RegisterServer() goto exit; } - ZeroMemory(fileName, sizeof(fileName)); GetModuleFileNameW(g_hInst, fileName, _countof(fileName)); - if (RegSetValueExW(hSubKey, nullptr, 0, REG_SZ, (BYTE *)fileName, (DWORD)(wcslen(fileName) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS) + if (RegSetValueExW(hSubKey, nullptr, 0, REG_SZ, (CONST LPBYTE)fileName, (DWORD)(wcslen(fileName) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS) { goto exit_sub; } - if (RegSetValueExW(hSubKey, c_szModelName, 0, REG_SZ, (BYTE *)TEXTSERVICE_MODEL, (DWORD)(wcslen(TEXTSERVICE_MODEL) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS) + if (RegSetValueExW(hSubKey, c_szModelName, 0, REG_SZ, (CONST LPBYTE)TEXTSERVICE_MODEL, (DWORD)(wcslen(TEXTSERVICE_MODEL) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS) { goto exit_sub; } @@ -180,7 +178,7 @@ BOOL RegisterServer() void UnregisterServer() { - WCHAR szInfoKey[_countof(c_szInfoKeyPrefix) + CLSID_STRLEN]; + WCHAR szInfoKey[_countof(c_szInfoKeyPrefix) + CLSID_STRLEN] = {}; if (StringFromGUID2(c_clsidTextService, szInfoKey + _countof(c_szInfoKeyPrefix) - 1, CLSID_STRLEN + 1) == 0) { @@ -194,9 +192,9 @@ void UnregisterServer() BOOL InstallLayoutOrTipProfileList(DWORD dwFlags) { - WCHAR clsid[CLSID_STRLEN + 1]; - WCHAR guidprofile[CLSID_STRLEN + 1]; - WCHAR profilelist[7 + CLSID_STRLEN * 2 + 1]; + WCHAR clsid[CLSID_STRLEN + 1] = {}; + WCHAR guidprofile[CLSID_STRLEN + 1] = {}; + WCHAR profilelist[7 + CLSID_STRLEN * 2 + 1] = {}; if (StringFromGUID2(c_clsidTextService, clsid, _countof(clsid)) == 0) { diff --git a/imcrvtip/Server.cpp b/imcrvtip/Server.cpp index 7bb72d23..19ed99ef 100644 --- a/imcrvtip/Server.cpp +++ b/imcrvtip/Server.cpp @@ -106,12 +106,14 @@ STDAPI CClassFactory::LockServer(BOOL fLock) return S_OK; } +__control_entrypoint(DllExport) STDAPI DllCanUnloadNow(void) { return g_cRefDll <= 0 ? S_OK : S_FALSE; } -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvObj) +_Check_return_ +STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID FAR *ppvObj) { static CClassFactory factory; diff --git a/imcrvtip/TextService.cpp b/imcrvtip/TextService.cpp index 291510b8..28b01d28 100644 --- a/imcrvtip/TextService.cpp +++ b/imcrvtip/TextService.cpp @@ -3,6 +3,7 @@ #include "TextService.h" #include "LanguageBar.h" #include "CandidateList.h" +#include "CandidateWindow.h" #include "InputModeWindow.h" CTextService::CTextService() @@ -46,11 +47,16 @@ CTextService::CTextService() _ImmersiveMode = FALSE; _UILessMode = FALSE; _ShowInputMode = FALSE; + _AppPrivateMode = FALSE; + _UserPrivateMode = E_FAIL; hPipe = INVALID_HANDLE_VALUE; inputmode = im_direct; + ZeroMemory(preservedkey, sizeof(preservedkey)); + ZeroMemory(&privatemodekey, sizeof(privatemodekey)); + _ResetStatus(); _CreateConfigPath(); @@ -203,7 +209,8 @@ STDAPI CTextService::ActivateEx(ITfThreadMgr *ptim, TfClientId tid, DWORD dwFlag if (!_InitDisplayAttributeGuidAtom()) { - goto exit; + // some applications do not support ITfCategoryMgr interface. + //goto exit; } if (!_InitFunctionProvider()) @@ -237,6 +244,8 @@ STDAPI CTextService::Deactivate() _UninitPreservedKey(0); _UninitPreservedKey(1); + _UninitPrivateModeKey(0); + _UninitPrivateModeKey(1); _UninitKeyEventSink(); diff --git a/imcrvtip/TextService.h b/imcrvtip/TextService.h index c855074e..3493e607 100644 --- a/imcrvtip/TextService.h +++ b/imcrvtip/TextService.h @@ -132,9 +132,16 @@ class CTextService : void _ClearCompositionDisplayAttributes(TfEditCookie ec, ITfContext *pContext); BOOL _SetCompositionDisplayAttributes(TfEditCookie ec, ITfContext *pContext, ITfRange *pRange, TfGuidAtom gaDisplayAttribute); + // Property + BOOL _IsVertical(TfEditCookie ec, ITfContext *pContext); + BOOL _IsAppPrivateScope(TfEditCookie ec, ITfContext *pContext); + void _GetAppPrivateMode(); + BOOL _IsPrivateMode(); + void _TogglePrivateMode(); + // KeyHandler HRESULT _InvokeKeyHandler(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BYTE bSf); - HRESULT _HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM wParam, BYTE bSf); + HRESULT _HandleKey(TfEditCookie ec, ITfContext *pContext, WPARAM wParam, BYTE bSf, WCHAR wCh); void _KeyboardOpenCloseChanged(BOOL showinputmode = TRUE); void _KeyboardInputConversionChanged(); BOOL _KeyboardSetDefaultMode(); @@ -144,7 +151,7 @@ class CTextService : void _InitD2D(); void _UninitD2D(); - // KeyHandlerChar + // KeyHandlerCharacter HRESULT _HandleChar(TfEditCookie ec, ITfContext *pContext, WPARAM wParam, WCHAR ch, WCHAR chO); HRESULT _HandleCharReturn(TfEditCookie ec, ITfContext *pContext, BOOL back = FALSE); HRESULT _HandleCharShift(TfEditCookie ec, ITfContext *pContext); @@ -155,12 +162,12 @@ class CTextService : HRESULT _ShowCandidateList(TfEditCookie ec, ITfContext *pContext, int mode); void _EndCandidateList(); void _EndCompletionList(TfEditCookie ec, ITfContext *pContext); - BOOL _GetVertical(TfEditCookie ec, ITfContext *pContext); // KeyHandlerControl HRESULT _HandleControl(TfEditCookie ec, ITfContext *pContext, BYTE sf, WCHAR ch); - // KeyHandlerConv + // KeyHandlerConversion + BOOL _GetKeyboardState(); WCHAR _GetCh(BYTE vk, BYTE vkoff = 0); BYTE _GetSf(BYTE vk, WCHAR ch); HRESULT _ConvRomanKana(ROMAN_KANA_CONV *pconv); @@ -180,12 +187,13 @@ class CTextService : void _ConvKanaToKana(const std::wstring &src, int srcmode, std::wstring &dst, int dstmode); BOOL _SearchKanaByKana(const ROMAN_KANA_NODE &tree, const WCHAR *src, int srcmode, std::wstring &dst, int dstmode); void _ConvOkuriRoman(); + void _Reconv(TfEditCookie ec, ITfContext *pContext); // KeyHandlerDictionary void _ConnectDic(); void _DisconnectDic(); void _SearchDic(WCHAR command); - void _ConvertWord(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &okuri, std::wstring &conv); + void _ConvertWord(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &okuri); void _AddUserDic(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &annotation); void _DelUserDic(WCHAR command, const std::wstring &key, const std::wstring &candidate); void _SaveUserDic(); @@ -193,11 +201,13 @@ class CTextService : void _StartManager(); void _StartConfigure(); - // FnConfig + // ConfigTip void _CreateConfigPath(); void _CreateIpcName(); void _ReadBoolValue(LPCWSTR section, LPCWSTR key, BOOL &value, BOOL defval); + void _LoadUserDict(); void _LoadBehavior(); + void _LoadDisplay(); void _LoadDisplayAttr(); void _LoadSelKey(); void _SetPreservedKeyONOFF(int onoff, const APPDATAXMLLIST &list); @@ -238,6 +248,9 @@ class CTextService : BOOL _InitPreservedKey(int onoff); void _UninitPreservedKey(int onoff); + BOOL _InitPrivateModeKey(int onoff); + void _UninitPrivateModeKey(int onoff); + BOOL _InitLanguageBar(); void _UninitLanguageBar(); @@ -282,12 +295,15 @@ class CTextService : FILETIME ftconfigxml; //更新時刻 //imcrvmgr.exe との名前付きパイプ - WCHAR mgrpipename[MAX_KRNLOBJNAME]; + WCHAR mgrpipename[MAX_PIPENAME]; HANDLE hPipe; WCHAR pipebuf[PIPEBUFSIZE]; //ミューテックス - WCHAR mgrmutexname[MAX_KRNLOBJNAME]; - WCHAR cnfmutexname[MAX_KRNLOBJNAME]; + WCHAR mgrmutexname[MAX_PATH]; + WCHAR cnfmutexname[MAX_PATH]; + + //GetKeyboardState引数 + BYTE keystate[256]; //キーマップ CKEYMAP ckeymap; //文字 @@ -295,7 +311,7 @@ class CTextService : VKEYMAP vkeymap_shift; //仮想キー(+Shift) VKEYMAP vkeymap_ctrl; //仮想キー(+Ctrl) - //変換位置指定(0:開始,1:代替,2:送り) + //変換位置指定 std::vector conv_point_s; //開始で昇順ソート std::vector conv_point_a; //代替で昇順ソート @@ -316,6 +332,9 @@ class CTextService : BOOL _ImmersiveMode; //Immersive Mode BOOL _UILessMode; //UILess Mode BOOL _ShowInputMode; //InputModeWindow + BOOL _AppPrivateMode; //Private Mode by application + //Private Mode by user, E_FAIL:undefined / S_OK:enabled / S_FALSE:desabled + HRESULT _UserPrivateMode; //状態 INT inputmode; //入力モード (無し/ひらがな/カタカナ/半角カタカナ/全英/アスキー) @@ -339,6 +358,7 @@ class CTextService : UINT cx_drawapi; //候補一覧の描画API(0:GDI/1:Direct2D) BOOL cx_colorfont; //候補一覧の描画API 彩色(Direct2Dのときカラーフォントにする) UINT cx_untilcandlist; //候補一覧表示に要する変換回数(0:表示なし/1:1回目...) + UINT cx_pagecandnum; //候補一覧表示に表示する候補数 BOOL cx_verticalcand; //候補一覧を縦に表示する BOOL cx_dispcandnum; //候補一覧表示なしのとき候補数を表示する BOOL cx_annotation; //注釈を表示する @@ -351,6 +371,8 @@ class CTextService : UINT cx_showmodeinltm; //入力モードの表示ミリ秒数 COLORREF cx_mode_colors[DISPLAY_MODE_COLOR_NUM]; //入力モードの色 + BOOL cx_privatemodeauto; //プライベートモード自動切替 + BOOL cx_begincvokuri; //送り仮名が決定したとき変換を開始する BOOL cx_shiftnnokuri; //送り仮名で撥音を送り出す BOOL cx_srchallokuri; //送りあり変換で送りなし候補も検索する @@ -371,7 +393,7 @@ class CTextService : std::wstring roman; //ローマ字 std::wstring kana; //仮名 size_t okuriidx; //送り仮名インデックス - std::wstring reconvsrc; //再変換元 + std::wstring reconvtext; //再変換元 //検索用見出し語 std::wstring searchkey; //数値変換で数値→# @@ -381,15 +403,19 @@ class CTextService : CANDIDATES candidates; //候補 size_t candidx; //候補インデックス size_t candorgcnt; //オリジナル見出し語の候補数 + std::wstring convword; //見出し語/候補変換 size_t cursoridx; //カーソルインデックス //候補一覧選択キー - WCHAR selkey[MAX_SELKEY_C][3][2]; + SELKEY selkey[MAX_SELKEY_C]; //preserved key TF_PRESERVEDKEY preservedkey[PRESERVEDKEY_NUM][MAX_PRESERVEDKEY]; + //private mode key + TF_PRESERVEDKEY privatemodekey[PRIVATEMODEKEY_NUM]; + //表示属性 別のインスタンスからGetDisplayAttributeInfo()が呼ばれるのでstaticで static BOOL display_attribute_series[DISPLAYATTRIBUTE_INFO_NUM]; static TF_DISPLAYATTRIBUTE display_attribute_info[DISPLAYATTRIBUTE_INFO_NUM]; diff --git a/imcrvtip/ThreadMgrEventSink.cpp b/imcrvtip/ThreadMgrEventSink.cpp index 9053d69a..93b1b31f 100644 --- a/imcrvtip/ThreadMgrEventSink.cpp +++ b/imcrvtip/ThreadMgrEventSink.cpp @@ -1,6 +1,7 @@  #include "imcrvtip.h" #include "TextService.h" +#include "CandidateList.h" STDAPI CTextService::OnInitDocumentMgr(ITfDocumentMgr *pdim) { @@ -16,6 +17,22 @@ STDAPI CTextService::OnSetFocus(ITfDocumentMgr *pdim, ITfDocumentMgr *pdimPrevFo { _InitTextEditSink(pdim); + { + _UninitPrivateModeKey(0); //ON + _UninitPrivateModeKey(1); //OFF + + _GetAppPrivateMode(); + + BOOL p = _IsPrivateMode(); + _InitPrivateModeKey(p ? 1 : 0); //OFF or ON + _InitPrivateModeKey(p ? 0 : 1); //ON or OFF 未使用だがキーは拾う 重複するキーは上書きされない + } + + if (_pCandidateList != nullptr) + { + _pCandidateList->_Redraw(); + } + _UpdateLanguageBar(FALSE); return S_OK; @@ -53,7 +70,7 @@ BOOL CTextService::_InitThreadMgrEventSink() void CTextService::_UninitThreadMgrEventSink() { - HRESULT hr; + HRESULT hr = E_FAIL; if (_dwThreadMgrEventSinkCookie != TF_INVALID_COOKIE) { diff --git a/imcrvtip/cpp.hint b/imcrvtip/cpp.hint new file mode 100644 index 00000000..8660b6f3 --- /dev/null +++ b/imcrvtip/cpp.hint @@ -0,0 +1,5 @@ +// common.h +#define FORWARD_ITERATION_I(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ++(iterator)) +#define FORWARD_ITERATION(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ) +#define REVERSE_ITERATION_I(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ++(reverse_iterator)) +#define REVERSE_ITERATION(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ) diff --git a/imcrvtip/imcrvtip.h b/imcrvtip/imcrvtip.h index fafec181..b5e997ef 100644 --- a/imcrvtip/imcrvtip.h +++ b/imcrvtip/imcrvtip.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "common.h" #include "convtype.h" @@ -50,6 +48,7 @@ enum InputMode #define SKK_RIGHT 0x06 // 右移動 c-f VK_RIGHT #define SKK_DOWN 0x05 // 末尾移動 c-e VK_DOWN #define SKK_PASTE 0x19 // 貼付 c-y (c-v) +#define SKK_RECONVERT 0x1C // 再変換 VK_CONVERT typedef struct { //キー設定(文字) BYTE keylatin[CKEYMAPNUM]; //全英/アスキー @@ -63,10 +62,18 @@ typedef struct { //キー設定(仮想キー) BYTE keyvoid[VKEYMAPNUM]; //無効 } VKEYMAP; -typedef struct { //変換位置指定(0:開始,1:代替,2:送り) - WCHAR ch[3]; +typedef struct { //変換位置指定 + WCHAR st; //開始 + WCHAR al; //代替 + WCHAR ok; //送り } CONV_POINT; +typedef struct { //選択キー + WCHAR disp[2 + 1]; //表示 + WCHAR spare1; //予備1 + WCHAR spare2; //予備2 +} SELKEY; + //ローマ字仮名ノード typedef struct ROMAN_KANA_NODE { //探索対象、ローマ字1文字分、ルートノードはL'\0' @@ -130,6 +137,8 @@ extern const CLSID c_clsidTextService; extern const GUID c_guidProfile; extern const GUID c_guidPreservedKeyOn; extern const GUID c_guidPreservedKeyOff; +extern const GUID c_guidPrivateModeKeyOn; +extern const GUID c_guidPrivateModeKeyOff; extern const GUID c_guidLangBarItemButton; extern const GUID c_guidCandidateListUIElement; @@ -169,52 +178,3 @@ LONG DllRelease(); #define IID_IUNK_ARGS(pType) __uuidof(*(pType)), reinterpret_cast(pType) #define IID_PUNK_ARGS(ppType) __uuidof(**(ppType)), reinterpret_cast(ppType) - -// added in Windows 8 SDK -#ifndef _WIN32_WINNT_WIN8 - -#define EVENT_OBJECT_IME_SHOW 0x8027 -#define EVENT_OBJECT_IME_HIDE 0x8028 -#define EVENT_OBJECT_IME_CHANGE 0x8029 - -#define TF_TMF_IMMERSIVEMODE 0x40000000 - -#define TF_IPP_CAPS_IMMERSIVESUPPORT 0x00010000 -#define TF_IPP_CAPS_SYSTRAYSUPPORT 0x00020000 - -extern const GUID GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT; -extern const GUID GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT; -extern const GUID GUID_LBI_INPUTMODE; - -typedef DECLSPEC_UUID("E9967127-FB3C-4978-9008-FB3060D92730") -enum __MIDL_ITfFnGetPreferredTouchKeyboardLayout_0001 -{ - TKBLT_UNDEFINED = 0, - TKBLT_CLASSIC = 1, - TKBLT_OPTIMIZED = 2 -} TKBLayoutType; - -MIDL_INTERFACE("5F309A41-590A-4ACC-A97F-D8EFFF13FDFC") -ITfFnGetPreferredTouchKeyboardLayout : public ITfFunction -{ -public: - virtual HRESULT STDMETHODCALLTYPE GetLayout( - TKBLayoutType *pTKBLayoutType, - WORD *pwPreferredLayoutId) = 0; -}; - -#define TKBL_UNDEFINED 0 -#define TKBL_OPT_JAPANESE_ABC 0x0411 - -extern const IID IID_ITfFnGetPreferredTouchKeyboardLayout; - -#endif //_WIN32_WINNT_WIN8 - -// added in Windows 8.1 SDK -#ifndef _WIN32_WINNT_WINBLUE - -#define WM_DPICHANGED 0x02E0 - -#define D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT (static_cast(0x00000004)) - -#endif //_WIN32_WINNT_WINBLUE diff --git a/imcrvtip/imcrvtip.rc b/imcrvtip/imcrvtip.rc index 1f949276..142d6033 100644 --- a/imcrvtip/imcrvtip.rc +++ b/imcrvtip/imcrvtip.rc @@ -41,12 +41,14 @@ IDI_0_IME ICON "Icon\\imcrvskk.ico" #else IDI_0_IME ICON "Icon\\imdebug.ico" #endif + IDI_X_DEFAULT ICON "Icon\\xDefault.ico" IDI_X_HIRAGANA ICON "Icon\\xHiragana.ico" IDI_X_KATAKANA ICON "Icon\\xKatakana.ico" IDI_X_KATAKANA1 ICON "Icon\\xKatakana1.ico" IDI_X_JLATIN ICON "Icon\\xJLatin.ico" IDI_X_ASCII ICON "Icon\\xAscii.ico" + IDI_Z_DEFAULT ICON "Icon\\zDefault.ico" IDI_Z_HIRAGANA ICON "Icon\\zHiragana.ico" IDI_Z_KATAKANA ICON "Icon\\zKatakana.ico" @@ -54,6 +56,18 @@ IDI_Z_KATAKANA1 ICON "Icon\\zKatakana1.ico" IDI_Z_JLATIN ICON "Icon\\zJLatin.ico" IDI_Z_ASCII ICON "Icon\\zAscii.ico" +IDI_PX_HIRAGANA ICON "Icon\\pxHiragana.ico" +IDI_PX_KATAKANA ICON "Icon\\pxKatakana.ico" +IDI_PX_KATAKANA1 ICON "Icon\\pxKatakana1.ico" +IDI_PX_JLATIN ICON "Icon\\pxJLatin.ico" +IDI_PX_ASCII ICON "Icon\\pxAscii.ico" + +IDI_PZ_HIRAGANA ICON "Icon\\pzHiragana.ico" +IDI_PZ_KATAKANA ICON "Icon\\pzKatakana.ico" +IDI_PZ_KATAKANA1 ICON "Icon\\pzKatakana1.ico" +IDI_PZ_JLATIN ICON "Icon\\pzJLatin.ico" +IDI_PZ_ASCII ICON "Icon\\pzAscii.ico" + IDR_SYSTRAY_MENU MENU { POPUP "" @@ -61,6 +75,8 @@ IDR_SYSTRAY_MENU MENU MENUITEM "CAPS", IDM_CAPSLOCK MENUITEM "KANA", IDM_KANALOCK MENUITEM SEPARATOR + MENUITEM "Private", IDM_PRIVATE + MENUITEM SEPARATOR MENUITEM "[かな]", IDM_HIRAGANA MENUITEM "[カナ]", IDM_KATAKANA MENUITEM "[-カナ]", IDM_KATAKANA_ANK diff --git a/imcrvtip/imcrvtip.vcxproj b/imcrvtip/imcrvtip.vcxproj index e5ad4bfb..1cdb481a 100644 --- a/imcrvtip/imcrvtip.vcxproj +++ b/imcrvtip/imcrvtip.vcxproj @@ -1,6 +1,14 @@  + + Debug + Win32 + + + Debug + x64 + Debug ARM @@ -9,12 +17,16 @@ Debug ARM64 - + Debug + ARM64EC + + + Release Win32 - - Debug + + Release x64 @@ -25,13 +37,9 @@ Release ARM64 - - Release - Win32 - - + Release - x64 + ARM64EC @@ -44,59 +52,72 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 + Unicode + + + DynamicLibrary + true + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 + true + Unicode + + + DynamicLibrary + false + v143 true Unicode - + @@ -108,7 +129,10 @@ - + + + + @@ -120,46 +144,61 @@ + + + true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + true false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + true @@ -168,19 +207,21 @@ Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreadedDebug + pch.h Windows true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;%(AdditionalDependencies) + ucrtd.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) + libucrtd.lib;%(IgnoreSpecificDefaultLibraries) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -189,8 +230,7 @@ _DEBUG;%(PreprocessorDefinitions) - icacls "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" /grant *S-1-15-2-1:RX > nul -ver > nul + icacls "$(TargetPath)" /grant *S-1-15-2-1:RX > nul @@ -200,19 +240,21 @@ ver > nul Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreadedDebug + pch.h Windows true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;%(AdditionalDependencies) + ucrtd.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) + libucrtd.lib;%(IgnoreSpecificDefaultLibraries) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -221,8 +263,7 @@ ver > nul _DEBUG;%(PreprocessorDefinitions) - icacls "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" /grant *S-1-15-2-1:RX > nul -ver > nul + icacls "$(TargetPath)" /grant *S-1-15-2-1:RX > nul @@ -232,19 +273,21 @@ ver > nul Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreadedDebug + pch.h Windows true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ucrtd.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) + libucrtd.lib;%(IgnoreSpecificDefaultLibraries) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -253,8 +296,7 @@ ver > nul _DEBUG;%(PreprocessorDefinitions) - icacls "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" /grant *S-1-15-2-1:RX > nul -ver > nul + icacls "$(TargetPath)" /grant *S-1-15-2-1:RX > nul @@ -264,19 +306,51 @@ ver > nul Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) + true + true + MultiThreadedDebug + pch.h + + + Windows + true + ucrtd.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) + imcrvtip.def + $(OutDir);%(AdditionalLibraryDirectories) + input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) + libucrtd.lib;%(IgnoreSpecificDefaultLibraries) + + $(SolutionDir)common;%(AdditionalIncludeDirectories) + 0x0411 + /c 65001 + _DEBUG;%(PreprocessorDefinitions) + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreadedDebug + pch.h Windows true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ucrtd.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) + libucrtd.lib;%(IgnoreSpecificDefaultLibraries) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -285,8 +359,7 @@ ver > nul _DEBUG;%(PreprocessorDefinitions) - icacls "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetFileName)" /grant *S-1-15-2-1:RX > nul -ver > nul + icacls "$(TargetPath)" /grant *S-1-15-2-1:RX > nul @@ -298,23 +371,26 @@ ver > nul true WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreaded Guard + pch.h Windows true true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;%(AdditionalDependencies) + ucrt.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) No UseLinkTimeCodeGeneration + libucrt.lib;%(IgnoreSpecificDefaultLibraries) + true $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -331,23 +407,26 @@ ver > nul true WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreaded Guard + pch.h Windows true true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;%(AdditionalDependencies) + ucrt.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) No UseLinkTimeCodeGeneration + libucrt.lib;%(IgnoreSpecificDefaultLibraries) + true $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -364,23 +443,25 @@ ver > nul true WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true MultiThreaded true Guard + pch.h Windows true true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ucrt.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) No UseLinkTimeCodeGeneration + libucrt.lib;%(IgnoreSpecificDefaultLibraries) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -397,23 +478,60 @@ ver > nul true WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) true true MultiThreaded Guard + pch.h + + + Windows + true + true + ucrt.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) + imcrvtip.def + $(OutDir);%(AdditionalLibraryDirectories) + input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) + No + UseLinkTimeCodeGeneration + libucrt.lib;%(IgnoreSpecificDefaultLibraries) + + + $(SolutionDir)common;%(AdditionalIncludeDirectories) + 0x0411 + /c 65001 + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h;%(ForcedIncludeFiles) + $(SolutionDir)common;$(SolutionDir)libinput;%(AdditionalIncludeDirectories) + true + MultiThreaded + true + Guard + pch.h Windows true true - input.lib;d2d1.lib;dwrite.lib;delayimp.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + ucrt.lib;delayimp.lib;input.lib;d2d1.lib;dwrite.lib;%(AdditionalDependencies) imcrvtip.def $(OutDir);%(AdditionalLibraryDirectories) input.dll;d2d1.dll;dwrite.dll;%(DelayLoadDLLs) No UseLinkTimeCodeGeneration + libucrt.lib;%(IgnoreSpecificDefaultLibraries) $(SolutionDir)common;%(AdditionalIncludeDirectories) @@ -431,16 +549,16 @@ ver > nul - - + + @@ -449,73 +567,34 @@ ver > nul + - - - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - $(ProjectDir)$(IntDir)input.obj;$(OutDir)input.lib;$(OutDir)input.exp;%(Outputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - input.h;input.def;%(AdditionalInputs) - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - cl /nologo /LD input.cpp /Fo"$(ProjectDir)$(IntDir)input.obj" /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /link /NODEFAULTLIB /NOENTRY /DEF:input.def /IMPLIB:"$(OutDir)input.lib" /OUT:"$(OutDir)input.dll" -if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" - false - false - false - false - false - false - false - false - - + - + + - + Create Create Create Create + Create Create Create Create Create + Create @@ -523,8 +602,8 @@ if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + - @@ -532,6 +611,16 @@ if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + + + + + + diff --git a/imcrvtip/imcrvtip.vcxproj.filters b/imcrvtip/imcrvtip.vcxproj.filters index 43cfba8d..8d530bfa 100644 --- a/imcrvtip/imcrvtip.vcxproj.filters +++ b/imcrvtip/imcrvtip.vcxproj.filters @@ -13,12 +13,9 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - {075a55c1-9aa9-42c2-8435-89de2d13eef7} - - + Header Files @@ -60,12 +57,9 @@ Header Files - - Dummy DLL Files - - + Source Files @@ -92,13 +86,13 @@ Source Files - + Source Files - + Source Files - + Source Files @@ -116,7 +110,7 @@ Source Files - + Source Files @@ -125,7 +119,7 @@ Source Files - + Source Files @@ -134,6 +128,9 @@ Source Files + + Source Files + Source Files @@ -158,14 +155,13 @@ Source Files + + Source Files + - - Resource Files - - - Dummy DLL Files - + + @@ -215,10 +211,35 @@ Resource Files - - - - Dummy DLL Files - + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + \ No newline at end of file diff --git a/imcrvtip/pch.cpp b/imcrvtip/pch.cpp new file mode 100644 index 00000000..af0744ae --- /dev/null +++ b/imcrvtip/pch.cpp @@ -0,0 +1 @@ + diff --git a/imcrvtip/stdafx.h b/imcrvtip/pch.h similarity index 100% rename from imcrvtip/stdafx.h rename to imcrvtip/pch.h diff --git a/imcrvtip/resource.h b/imcrvtip/resource.h index 0ccf0bb0..ce1f22c5 100644 --- a/imcrvtip/resource.h +++ b/imcrvtip/resource.h @@ -16,6 +16,18 @@ #define IDI_Z_JLATIN 305 #define IDI_Z_ASCII 306 +#define IDI_PX_HIRAGANA 402 +#define IDI_PX_KATAKANA 403 +#define IDI_PX_KATAKANA1 404 +#define IDI_PX_JLATIN 405 +#define IDI_PX_ASCII 406 + +#define IDI_PZ_HIRAGANA 502 +#define IDI_PZ_KATAKANA 503 +#define IDI_PZ_KATAKANA1 504 +#define IDI_PZ_JLATIN 505 +#define IDI_PZ_ASCII 506 + #define IDR_SYSTRAY_MENU 1000 #define IDM_NONE 1001 #define IDM_HIRAGANA 1011 @@ -25,5 +37,6 @@ #define IDM_ASCII 1015 #define IDM_DIRECT 1020 #define IDM_CONFIG 1021 -#define IDM_CAPSLOCK 1022 -#define IDM_KANALOCK 1023 +#define IDM_CAPSLOCK 1022 +#define IDM_KANALOCK 1023 +#define IDM_PRIVATE 1024 diff --git a/imcrvtip/stdafx.cpp b/imcrvtip/stdafx.cpp deleted file mode 100644 index 7438ada7..00000000 --- a/imcrvtip/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -// nothing diff --git a/installer/_build.cmd b/installer/_build.cmd index efdbfb81..65c4fb74 100644 --- a/installer/_build.cmd +++ b/installer/_build.cmd @@ -1,14 +1,14 @@ @echo off setlocal - pushd "%~dp0" call _clean.cmd +set SignOutput=false + call _build_msi.cmd call _build_bundle.cmd popd - endlocal diff --git a/installer/_build_bundle.cmd b/installer/_build_bundle.cmd index 1972a33d..c5895f40 100644 --- a/installer/_build_bundle.cmd +++ b/installer/_build_bundle.cmd @@ -1,32 +1,17 @@ @echo off setlocal - pushd "%~dp0" call _vsdev.cmd -call _version.cmd - -rem x86/x64 - -"%WIX%bin\candle.exe" installer-bundle.wxs ^ --nologo -out "%TARGETDIR%\corvusskk-%VERSION%.wixobj" ^ --ext WixBalExtension -ext WixUtilExtension +call _env.cmd -"%WIX%bin\light.exe" "%TARGETDIR%\corvusskk-%VERSION%.wixobj" ^ --nologo -out "%TARGETDIR%\corvusskk-%VERSION%.exe" ^ --ext WixBalExtension -ext WixUtilExtension +if not defined SIGNCOMMAND set SignOutput=false -rem ARM +set BUILDCOMMAND=dotnet build installer-bundle.wixproj -nologo -verbosity:normal -target:Build -"%WIX%bin\candle.exe" installer-bundle-arm.wxs ^ --nologo -out "%TARGETDIR%\corvusskk-%VERSION%-arm.wixobj" ^ --ext WixBalExtension -ext WixUtilExtension - -"%WIX%bin\light.exe" "%TARGETDIR%\corvusskk-%VERSION%-arm.wixobj" ^ --nologo -out "%TARGETDIR%\corvusskk-%VERSION%-arm.exe" ^ --ext WixBalExtension -ext WixUtilExtension +echo build bundle +%BUILDCOMMAND% -property:BaseIntermediateOutputPath=%OutDir%\bundle\ popd - endlocal diff --git a/installer/_build_doc.cmd b/installer/_build_doc.cmd new file mode 100644 index 00000000..f6eda084 --- /dev/null +++ b/installer/_build_doc.cmd @@ -0,0 +1,47 @@ +@echo off +setlocal +pushd "%~dp0" + +call _env.cmd + +if not exist "%OutDir%" mkdir "%OutDir%" + +pushd .. + +set PATH=%PATH%;%LocalAppData%\Pandoc;%ProgramFiles%\Pandoc + +set DESCRIPTION=CorvusSKK + +pandoc.exe ^ +-s ^ +-f gfm-ascii_identifiers ^ +-t html5 ^ +-V lang:"ja" ^ +-V title-prefix:"%DESCRIPTION%" ^ +-V pagetitle:"Manual" ^ +-V title:"%DESCRIPTION% Manual" ^ +--embed-resources ^ +--standalone ^ +-c "installer\resource-md\markdown.css" ^ +--toc ^ +-o "installer\%OutDir%\README.html" ^ +README.md + +popd + +copy /y /b "..\LICENSE.TXT" "%OutDir%\LICENSE.txt" > nul +copy /y /b "config-lua\init.lua" "%OutDir%\init.lua" > nul +copy /y /b "config-share\config.xml" "%OutDir%\config.xml" > nul +copy /y /b "config-share\skkdict.txt" "%OutDir%\skkdict.txt" > nul + +pushd "%OutDir%" + +copy /b LICENSE.txt + > nul +copy /b init.lua + > nul +copy /b config.xml + > nul +copy /b skkdict.txt + > nul + +popd + +popd +endlocal diff --git a/installer/_build_msi.cmd b/installer/_build_msi.cmd index a24e8bbf..0e7d5b23 100644 --- a/installer/_build_msi.cmd +++ b/installer/_build_msi.cmd @@ -1,40 +1,28 @@ @echo off setlocal - pushd "%~dp0" call _vsdev.cmd -call _version.cmd - -call _build_sub.cmd - -rem x86 +call _env.cmd -"%WIX%bin\candle.exe" installer-x86.wxs ^ --nologo -out "%TARGETDIR%\x86.wixobj" +call _build_doc.cmd -"%WIX%bin\light.exe" "%TARGETDIR%\x86.wixobj" ^ --nologo -out "%TARGETDIR%\x86.msi" -ext WixUIExtension -sw1076 +if not defined SIGNCOMMAND set SignOutput=false -rem x64 +set BUILDCOMMAND=dotnet build installer-msi.wixproj -nologo -verbosity:normal -target:Build -"%WIX%bin\candle.exe" installer-x64.wxs ^ --nologo -out "%TARGETDIR%\x64.wixobj" +echo build x86.msi +%BUILDCOMMAND% -property:PackagePlatform=x86 -property:InstallerPlatform=x86 -property:BaseIntermediateOutputPath=%OutDir%\x86\ -"%WIX%bin\light.exe" "%TARGETDIR%\x64.wixobj" ^ --nologo -out "%TARGETDIR%\x64.msi" -ext WixUIExtension -sw1076 +echo build x64.msi +%BUILDCOMMAND% -property:PackagePlatform=x64 -property:InstallerPlatform=x64 -property:BaseIntermediateOutputPath=%OutDir%\x64\ -rem ARM +echo build arm32.msi +%BUILDCOMMAND% -property:PackagePlatform=arm32 -property:InstallerPlatform=arm64 -property:BaseIntermediateOutputPath=%OutDir%\arm32\ -"%WIX%bin\candle.exe" installer-arm.wxs ^ --nologo -out "%TARGETDIR%\arm.wixobj" - -"%WIX%bin\light.exe" "%TARGETDIR%\arm.wixobj" ^ --nologo -out "%TARGETDIR%\arm.msi" -ext WixUIExtension -sw1076 - -msiinfo "%TARGETDIR%\arm.msi" /p Arm64;1033 /nologo +echo build arm64.msi +%BUILDCOMMAND% -property:PackagePlatform=arm64 -property:InstallerPlatform=arm64 -property:BaseIntermediateOutputPath=%OutDir%\arm64\ popd - endlocal diff --git a/installer/_build_sub.cmd b/installer/_build_sub.cmd deleted file mode 100644 index 43fab202..00000000 --- a/installer/_build_sub.cmd +++ /dev/null @@ -1,48 +0,0 @@ -@echo off -setlocal - -pushd "%~dp0" - -call _version.cmd - -if not exist "%TARGETDIR%" mkdir "%TARGETDIR%" - -pushd .. - -set PATH=%PATH%;%LocalAppData%\Pandoc;%ProgramFiles%\Pandoc;%ProgramFiles(x86)%\Pandoc - -set DESCRIPTION=CorvusSKK - -pandoc.exe ^ --s ^ --f gfm-ascii_identifiers ^ --t html5 ^ --V lang:"ja" ^ --V title-prefix:"%DESCRIPTION%" ^ --V pagetitle:"Manual" ^ --V title:"%DESCRIPTION% Manual" ^ ---self-contained ^ --c "installer\resource-md\markdown.css" ^ ---toc ^ --o "installer\%TARGETDIR%\README.html" ^ -README.md - -popd - -copy /y /b "..\LICENSE.TXT" "%TARGETDIR%\LICENSE.txt" > nul -copy /y /b "config-lua\init.lua" "%TARGETDIR%\init.lua" > nul -copy /y /b "config-share\config.xml" "%TARGETDIR%\config.xml" > nul -copy /y /b "config-share\skkdict.txt" "%TARGETDIR%\skkdict.txt" > nul - -pushd "%TARGETDIR%" - -copy /b LICENSE.txt + > nul -copy /b init.lua + > nul -copy /b config.xml + > nul -copy /b skkdict.txt + > nul - -popd - -popd - -endlocal diff --git a/installer/_clean.cmd b/installer/_clean.cmd index 10d95bf9..88234e45 100644 --- a/installer/_clean.cmd +++ b/installer/_clean.cmd @@ -1,21 +1,10 @@ @echo off setlocal - pushd "%~dp0" -call _version.cmd - -if exist "%TARGETDIR%\README.html" del "%TARGETDIR%\README.html" -if exist "%TARGETDIR%\LICENSE.txt" del "%TARGETDIR%\LICENSE.txt" -if exist "%TARGETDIR%\config.xml" del "%TARGETDIR%\config.xml" -if exist "%TARGETDIR%\init.lua" del "%TARGETDIR%\init.lua" -if exist "%TARGETDIR%\skkdict.txt" del "%TARGETDIR%\skkdict.txt" +call _env.cmd -if exist "%TARGETDIR%\*.exe" del "%TARGETDIR%\*.exe" -if exist "%TARGETDIR%\*.msi" del "%TARGETDIR%\*.msi" -if exist "%TARGETDIR%\*.wixobj" del "%TARGETDIR%\*.wixobj" -if exist "%TARGETDIR%\*.wixpdb" del "%TARGETDIR%\*.wixpdb" +if exist "%OutDir%" rd /s /q "%OutDir%" popd - endlocal diff --git a/installer/_debug_reg.cmd b/installer/_debug_reg.cmd index 9234d14e..9c8743ce 100644 --- a/installer/_debug_reg.cmd +++ b/installer/_debug_reg.cmd @@ -1,4 +1,14 @@ +@echo off +setlocal pushd "%~dp0" -regsvr32 /s ..\Win32\Debug\imcrvtip.dll -regsvr32 /s ..\x64\Debug\imcrvtip.dll + +openfiles > nul 2>&1 +if %errorlevel% equ 1 ( + powershell start-process "%~nx0" -verb runas +) else ( + regsvr32 /s "..\build\Win32\Debug\imcrvtip.dll" + regsvr32 /s "..\build\x64\Debug\imcrvtip.dll" +) + popd +endlocal diff --git a/installer/_debug_unreg.cmd b/installer/_debug_unreg.cmd index 81a4300f..b408e784 100644 --- a/installer/_debug_unreg.cmd +++ b/installer/_debug_unreg.cmd @@ -1,4 +1,14 @@ +@echo off +setlocal pushd "%~dp0" -regsvr32 /s /u ..\Win32\Debug\imcrvtip.dll -regsvr32 /s /u ..\x64\Debug\imcrvtip.dll + +openfiles > nul 2>&1 +if %errorlevel% equ 1 ( + powershell start-process "%~nx0" -verb runas +) else ( + regsvr32 /s /u "..\build\Win32\Debug\imcrvtip.dll" + regsvr32 /s /u "..\build\x64\Debug\imcrvtip.dll" +) + popd +endlocal diff --git a/installer/_env.cmd b/installer/_env.cmd new file mode 100644 index 00000000..71f3d1db --- /dev/null +++ b/installer/_env.cmd @@ -0,0 +1,6 @@ + +set VERSION=3.3.0 + +set WIXTOOLSET_VERSION=4.0.5 + +set OutDir=build diff --git a/installer/_sign.cmd b/installer/_sign.cmd index 12ba9306..1a68a16c 100644 --- a/installer/_sign.cmd +++ b/installer/_sign.cmd @@ -1,79 +1,50 @@ @echo off setlocal - pushd "%~dp0" call _vsdev.cmd -call _version.cmd +call _env.cmd -rem > _sign.cmd -rem * : SHA-1 hash of certificate for SHA-256 file digest algorithm -rem * : SHA-256 RFC-3161 timestamp server +rem > _sign.cmd +rem * : SHA-1 thumbprint of certificate +rem * : RFC-3161 timestamp server set DESCRIPTION="CorvusSKK" set SHA1HASH=%1 set TIMESTAMPSERVER=%2 +set SIGNCOMMAND=signtool sign /v /d %DESCRIPTION% /sha1 %SHA1HASH% /fd sha256 /tr %TIMESTAMPSERVER% /td sha256 + +set BINFILES= rem x86 -set BINFILES="..\Win32\Release\*.dll" "..\Win32\Release\*.exe" +set BINFILES=%BINFILES% "..\build\Win32\Release\*.dll" "..\build\Win32\Release\*.exe" rem x64 -set BINFILES=%BINFILES% "..\x64\Release\*.dll" "..\x64\Release\*.exe" +set BINFILES=%BINFILES% "..\build\x64\Release\*.dll" "..\build\x64\Release\*.exe" rem ARM32 TIP only -set BINFILES=%BINFILES% "..\ARM\Release\*.dll" +set BINFILES=%BINFILES% "..\build\ARM\Release\*.dll" rem ARM64 -set BINFILES=%BINFILES% "..\ARM64\Release\*.dll" "..\ARM64\Release\*.exe" - -rem x86 -set MSIFILES="%TARGETDIR%\x86.msi" -rem x64 -set MSIFILES=%MSIFILES% "%TARGETDIR%\x64.msi" -rem ARM -set MSIFILES=%MSIFILES% "%TARGETDIR%\arm.msi" - -rem x86/x64 -set BEFILE="%TARGETDIR%\engine.exe" -set BSFILE="%TARGETDIR%\corvusskk-%VERSION%.exe" - -rem ARM -set ARMBEFILE="%TARGETDIR%\engine-arm.exe" -set ARMBSFILE="%TARGETDIR%\corvusskk-%VERSION%-arm.exe" - -set SIGNCOMMAND=signtool sign /v /d %DESCRIPTION% /sha1 %SHA1HASH% /fd sha256 /tr %TIMESTAMPSERVER% /td sha256 +set BINFILES=%BINFILES% "..\build\ARM64\Release\*.dll" "..\build\ARM64\Release\*.exe" +rem ARM64EC TIP only +set BINFILES=%BINFILES% "..\build\ARM64EC\Release\*.dll" call _clean.cmd +echo sign binary files %SIGNCOMMAND% %BINFILES% -call _build_msi.cmd +set SignOutput=true -%SIGNCOMMAND% %MSIFILES% +call _build_msi.cmd call _build_bundle.cmd -rem x86/x64 -"%WIX%\bin\insignia.exe" -nologo -ib %BSFILE% -o %BEFILE% - -rem ARM -"%WIX%\bin\insignia.exe" -nologo -ib %ARMBSFILE% -o %ARMBEFILE% - -%SIGNCOMMAND% %BEFILE% %ARMBEFILE% - -rem x86/x64 -"%WIX%\bin\insignia.exe" -nologo -ab %BEFILE% %BSFILE% -o %BSFILE% - -rem ARM -"%WIX%\bin\insignia.exe" -nologo -ab %ARMBEFILE% %ARMBSFILE% -o %ARMBSFILE% - -%SIGNCOMMAND% %BSFILE% %ARMBSFILE% - popd - endlocal diff --git a/installer/_solution_build.cmd b/installer/_solution_build.cmd index 185b4985..64b328a6 100644 --- a/installer/_solution_build.cmd +++ b/installer/_solution_build.cmd @@ -1,36 +1,28 @@ @echo off setlocal - pushd "%~dp0" call _vsdev.cmd -call _version.cmd +call _env.cmd -rem x86 +set BUILDCOMMAND=msbuild "..\imcrvskk.sln" -nologo -maxcpucount -verbosity:normal +set BUILDCOMMAND=%BUILDCOMMAND% -target:Build -property:Configuration=Release -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Release,Platform=x86 +rem x86 +%BUILDCOMMAND% -property:Platform=x86 rem x64 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Release,Platform=x64 +%BUILDCOMMAND% -property:Platform=x64 rem ARM32 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Release,Platform=ARM +%BUILDCOMMAND% -property:Platform=ARM -property:WindowsTargetPlatformVersion=10.0.22621.0 rem ARM64 +%BUILDCOMMAND% -property:Platform=ARM64 -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Release,Platform=ARM64 +rem ARM64EC +%BUILDCOMMAND% -property:Platform=ARM64EC popd - endlocal diff --git a/installer/_solution_build_debug.cmd b/installer/_solution_build_debug.cmd index e11c6a5c..1c6eccf0 100644 --- a/installer/_solution_build_debug.cmd +++ b/installer/_solution_build_debug.cmd @@ -1,36 +1,28 @@ @echo off setlocal - pushd "%~dp0" call _vsdev.cmd -call _version.cmd +call _env.cmd -rem x86 +set BUILDCOMMAND=msbuild "..\imcrvskk.sln" -nologo -maxcpucount -verbosity:normal +set BUILDCOMMAND=%BUILDCOMMAND% -target:Build -property:Configuration=Debug -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Debug,Platform=x86 +rem x86 +%BUILDCOMMAND% -property:Platform=x86 rem x64 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Debug,Platform=x64 +%BUILDCOMMAND% -property:Platform=x64 rem ARM32 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Debug,Platform=ARM +%BUILDCOMMAND% -property:Platform=ARM -property:WindowsTargetPlatformVersion=10.0.22621.0 rem ARM64 +%BUILDCOMMAND% -property:Platform=ARM64 -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Build ^ -/property:Configuration=Debug,Platform=ARM64 +rem ARM64EC +%BUILDCOMMAND% -property:Platform=ARM64EC popd - endlocal diff --git a/installer/_solution_clean.cmd b/installer/_solution_clean.cmd index 98333fda..e0937bb4 100644 --- a/installer/_solution_clean.cmd +++ b/installer/_solution_clean.cmd @@ -1,36 +1,8 @@ @echo off setlocal - pushd "%~dp0" -call _vsdev.cmd - -call _version.cmd - -rem x86 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Release,Platform=x86 - -rem x64 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Release,Platform=x64 - -rem ARM32 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Release,Platform=ARM - -rem ARM64 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Release,Platform=ARM64 +if exist "..\build" rd /s /q "..\build" popd - endlocal diff --git a/installer/_solution_clean_debug.cmd b/installer/_solution_clean_debug.cmd deleted file mode 100644 index 6e932d2b..00000000 --- a/installer/_solution_clean_debug.cmd +++ /dev/null @@ -1,36 +0,0 @@ -@echo off -setlocal - -pushd "%~dp0" - -call _vsdev.cmd - -call _version.cmd - -rem x86 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Debug,Platform=x86 - -rem x64 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Debug,Platform=x64 - -rem ARM32 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Debug,Platform=ARM - -rem ARM64 - -msbuild "..\imcrvskk.sln" ^ -/nologo /maxcpucount /verbosity:normal /target:Clean ^ -/property:Configuration=Debug,Platform=ARM64 - -popd - -endlocal diff --git a/installer/_verify.cmd b/installer/_verify.cmd index c91fb23b..ae92ca1c 100644 --- a/installer/_verify.cmd +++ b/installer/_verify.cmd @@ -1,44 +1,45 @@ @echo off setlocal - pushd "%~dp0" call _vsdev.cmd -call _version.cmd +call _env.cmd +set BINFILES= rem x86 -set BINFILES="..\Win32\Release\*.dll" "..\Win32\Release\*.exe" +set BINFILES=%BINFILES% "..\build\Win32\Release\*.dll" "..\build\Win32\Release\*.exe" rem x64 -set BINFILES=%BINFILES% "..\x64\Release\*.dll" "..\x64\Release\*.exe" +set BINFILES=%BINFILES% "..\build\x64\Release\*.dll" "..\build\x64\Release\*.exe" rem ARM32 TIP only -set BINFILES=%BINFILES% "..\ARM\Release\*.dll" +set BINFILES=%BINFILES% "..\build\ARM\Release\*.dll" rem ARM64 -set BINFILES=%BINFILES% "..\ARM64\Release\*.dll" "..\ARM64\Release\*.exe" +set BINFILES=%BINFILES% "..\build\ARM64\Release\*.dll" "..\build\ARM64\Release\*.exe" +rem ARM64EC TIP only +set BINFILES=%BINFILES% "..\build\ARM64EC\Release\*.dll" +set MSIFILES= rem x86 -set MSIFILES="%TARGETDIR%\x86.msi" +set MSIFILES=%MSIFILES% "%OutDir%\x86.msi" rem x64 -set MSIFILES=%MSIFILES% "%TARGETDIR%\x64.msi" -rem ARM -set MSIFILES=%MSIFILES% "%TARGETDIR%\arm.msi" - -rem x86/x64 -set BEFILE="%TARGETDIR%\engine.exe" -set BSFILE="%TARGETDIR%\corvusskk-%VERSION%.exe" +set MSIFILES=%MSIFILES% "%OutDir%\x64.msi" +rem ARM32 +set MSIFILES=%MSIFILES% "%OutDir%\arm32.msi" +rem ARM64 +set MSIFILES=%MSIFILES% "%OutDir%\arm64.msi" -rem ARM -set ARMBEFILE="%TARGETDIR%\engine-arm.exe" -set ARMBSFILE="%TARGETDIR%\corvusskk-%VERSION%-arm.exe" +rem bundle +set BEFILE="%OutDir%\corvusskk-%VERSION%-engine.exe" +set BSFILE="%OutDir%\corvusskk-%VERSION%.exe" -signtool verify /all /v /d /pa /tw %BINFILES% %MSIFILES% %BEFILE% %BSFILE% %ARMBEFILE% %ARMBSFILE% +signtool verify /all /v /d /pa /tw %BINFILES% %MSIFILES% %BEFILE% %BSFILE% set SIGNCOUNT=0 -for %%i in (%BINFILES% %MSIFILES% %BEFILE% %BSFILE% %ARMBEFILE% %ARMBSFILE%) do set /a "SIGNCOUNT = SIGNCOUNT + 1" +for %%i in (%BINFILES% %MSIFILES% %BEFILE% %BSFILE%) do set /a "SIGNCOUNT = SIGNCOUNT + 1" echo; echo %SIGNCOUNT% signatures in all. @@ -46,5 +47,4 @@ echo %SIGNCOUNT% signatures in all. popd - endlocal diff --git a/installer/_version.cmd b/installer/_version.cmd deleted file mode 100644 index ee8e4001..00000000 --- a/installer/_version.cmd +++ /dev/null @@ -1,4 +0,0 @@ - -set VERSION=2.7.12 - -set TARGETDIR=build diff --git a/installer/_vsdev.cmd b/installer/_vsdev.cmd index 127a9ce8..0780b09c 100644 --- a/installer/_vsdev.cmd +++ b/installer/_vsdev.cmd @@ -1,14 +1,16 @@ @echo off -set VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -set VSWHEREOPT=-version ^^^[16.0^^^,17.0^^^) -requires Microsoft.Component.MSBuild -property installationPath +set VSWHEREEXE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" +set VSWHEREOPT=-version [17^^,18^^) -requires Microsoft.Component.MSBuild -property installationPath -for /f "usebackq tokens=*" %%i in (`%VSWHERE% %VSWHEREOPT%`) do ( - if exist "%%i" ( - set VS2019InstallDir=%%i - ) +for /f "usebackq tokens=*" %%i in (`%VSWHEREEXE% %VSWHEREOPT%`) do ( + set VSDEVCMDBAT=%%i\Common7\Tools\VsDevCmd.bat ) -if not exist "%VS2019InstallDir%\Common7\Tools\VsDevCmd.bat" exit /B 1 +if exist "%VSDEVCMDBAT%" ( + call "%VSDEVCMDBAT%" %* > nul +) -call "%VS2019InstallDir%\Common7\Tools\VsDevCmd.bat" > nul +set VSWHEREEXE= +set VSWHEREOPT= +set VSDEVCMDBAT= diff --git a/installer/config-lua/init.lua b/installer/config-lua/init.lua index 9c2cf71f..5229e5dc 100644 --- a/installer/config-lua/init.lua +++ b/installer/config-lua/init.lua @@ -24,6 +24,10 @@ candidate : 候補 string okuri : 送り仮名 string 戻り値 : 変換済み文字列 string + 逆検索 + lua_skk_reverse(candidate) + candidate : 候補 string + 戻り値 : 見出し語 string 辞書追加 lua_skk_add(okuriari, key, candidate, annotation, okuri) okuriari : boolean (送りあり:true/送りなし:false) @@ -83,6 +87,10 @@ crvmgr.complement(key) key : 見出し語 string 戻り値 : "///...//\n" or "" string + 逆検索 + crvmgr.reverse(candidate) + candidate : 候補 string + 戻り値 : 見出し語 string 辞書追加 crvmgr.add(okuriari, key, candidate, annotation, okuri) okuriari : boolean (送りあり:true/送りなし:false) @@ -182,7 +190,7 @@ local skk_gadget_dayofweek_table = { local skk_gadget_unit_table_org = { {"mile", {{"yard", 1760.0}, {"feet", 5280.0}, {"m", 1609.344}, {"km", 1.609344}}}, {"yard", {{"feet", 3.0}, {"inch", 36.0}, {"m", 0.9144}, {"cm", 91.44}, {"mm", 914.4}}}, - {"feet", {{"inch", 12.0}, {"yard", (1.0 / 3.0)}, {"m", 0.3048}, {"cm", 30.48}, {"mm", 304.8}}}, + {"feet", {{"inch", 12.0}, {"yard", (1.0 / 3.0)}, {"m", 0.3048}, {"cm", 30.48}, {"mm", 304.8}}}, {"inch", {{"feet", (1.0 / 12.0)}, {"yard", (1.0 / 36.0)}, {"m", 0.0254}, {"cm", 2.54}, {"mm", 25.4}}}, {"pound", {{"g", 453.59237}, {"ounce", 16.0}, {"grain", 7000.0}}}, {"ounce", {{"g", 28.349523125}, {"pound", (1.0 / 16.0)}, {"grain", (7000.0 / 16.0)}}}, @@ -300,6 +308,28 @@ local function skk_num_type_3(num, len) return ret end +-- 数値変換タイプ4 (数値再変換) +local function skk_num_type_4(num, len) + local ret = "" + + -- ユーザー辞書検索 + ret = ret .. crvmgr.search_user_dictionary(num, "") + + -- SKK辞書検索 + ret = ret .. crvmgr.search_skk_dictionary(num, "") + + -- SKK辞書サーバー検索 + ret = ret .. crvmgr.search_skk_server(num) + + -- 余計な"/\n"を削除 + ret = string.gsub(ret, "/\n/", "/") + + -- 先頭の候補のみ + ret = string.match(ret, "^/([^;/]+)") + + return ret +end + -- 数値変換タイプ5 (漢数字、大字) local function skk_num_type_5(num, len) local ret = "" @@ -363,7 +393,7 @@ local skk_num_type_func_table = { skk_num_type_1, skk_num_type_2, skk_num_type_3, - skk_num_type_n, + skk_num_type_4, skk_num_type_5, skk_num_type_6, skk_num_type_n, @@ -891,7 +921,9 @@ function convert_s_to_table(s) if (q == 0) then if (c == "(") then if (ret ~= "") then - ret = ret .. "," + if (r ~= "{") then + ret = ret .. "," + end end ret = ret .. "{" elseif (c == ")" or c == "\x20") then @@ -1027,7 +1059,7 @@ local function skk_convert_gadget(key, candidate) -- 乱数 math.randomseed(skk_gadget_time) - local f = load("return " .. convert_s_to_table(candidate)) + local f = load("return " .. convert_s_to_table(candidate)) if (not f) then return candidate end @@ -1140,14 +1172,18 @@ end function lua_skk_search(key, okuri) -- skk-search-sagyo-henkaku (t:true/anything:false) - if (enable_skk_search_sagyo_only) then - if (okuri ~= "" and string.find("さしすせサシスセ", okuri) == nil and - string.match(string.sub(key, -1), "[a-z]") == nil) then - return "" + -- 「送りあり変換で送りなし候補も検索する」 → 送り仮名あり、送りローマ字なし + if (okuri ~= "" and string.match(string.sub(key, -1), "[a-z]") == nil) then + if (enable_skk_search_sagyo_only) then + if (string.find("さしすせ", okuri) ~= nil) then + okuri = "" + end + else + okuri = "" end end - local ret = skk_search(key, okuri) + local ret = skk_search(key, okuri) -- skk-ignore-dic-word if (enable_skk_ignore_dic_word) then @@ -1172,6 +1208,11 @@ function lua_skk_convert_candidate(key, candidate, okuri) return skk_convert_candidate(key, candidate, okuri) end +-- 逆検索 +function lua_skk_reverse(candidate) + return crvmgr.reverse(candidate) +end + -- 辞書追加 function lua_skk_add(okuriari, key, candidate, annotation, okuri) diff --git a/installer/config-lua/test_c.lua b/installer/config-lua/test_c.lua index e833aac6..49547985 100644 --- a/installer/config-lua/test_c.lua +++ b/installer/config-lua/test_c.lua @@ -4,7 +4,16 @@ SKK_VERSION="CorvusSKK X.Y.Z" local _M = {} function _M.search_user_dictionary(key, okuri) - return "" + local ret = "" + + if (key == "p#") then + ret = "/#4/\n" + elseif (key == "125") then + ret = "/東京都葛飾区;サンプル/\n" + else + end + + return ret end function _M.search_skk_dictionary(key, okuri) @@ -16,6 +25,13 @@ function _M.search_skk_dictionary(key, okuri) ret = "/切;紙を-/着;服を-/斬;人を-/伐;木を-/剪;盆栽を-/截;布地を-/(skk-ignore-dic-word \"斬\")/\n" elseif (key == "き") then ret = "/気/機/器/木/\n" + + elseif (key == "p#") then + ret = "/#4/\n" + elseif (key == "125") then + ret = "/東京都葛飾区(テスト);サンプル/\n" + + else end return ret @@ -49,6 +65,10 @@ function _M.complement(key) return "/きあい/きけん/きき/きかい/\n" end +function _M.reverse(candidate) + return "" +end + function _M.add(okuriari, key, candidate, annotation, okuri) return end diff --git a/installer/config-lua/test_num.lua b/installer/config-lua/test_num.lua index 9c916cc3..cade27ca 100644 --- a/installer/config-lua/test_num.lua +++ b/installer/config-lua/test_num.lua @@ -231,6 +231,7 @@ el_test_num_table = { {"1888", "#6", "MDCCCLXXXVIII"}, {"2444", "#6", "MMCDXLIV"}, {"3999", "#6", "MMMCMXCIX"}, +{"p125", "#4", "東京都葛飾区"}, } diff --git a/installer/config-lua/test_time.lua b/installer/config-lua/test_time.lua index 1cbc4da0..8eef5692 100644 --- a/installer/config-lua/test_time.lua +++ b/installer/config-lua/test_time.lua @@ -101,15 +101,26 @@ el_test_time_table = { {"さらいねん", "(skk-relative-date (lambda (date-information format gengo and-time) (skk-default-current-date date-information \"%s年\" 0 nil 0 0 0)) nil nil :yy 2)"}, {"あした!", "(skk-relative-date nil nil nil :dd 1)"}, +{"きのう!", "(skk-relative-date nil nil nil :dd -1)"}, + +{"きょう", "(format-time-string \"%Y年%#m月%#d日(%a)\")"}, +{"きょう", "(format-time-string \"%Y年%#m月%#d日(%a)\" (current-time))"}, +{"あした", "(format-time-string \"%Y年%#m月%#d日(%a)\" (+ (current-time) 86400))"}, +{"きのう", "(format-time-string \"%Y年%#m月%#d日(%a)\" (- (current-time) 86400))"}, {"あした", "(skk-strftime \"%Y年%#m月%#d日(%a)\" \"day\" 1)"}, +{"きのう", "(skk-strftime \"%Y年%#m月%#d日(%a)\" \"day\" -1)"}, {"にちじ", "(skk-strftime \"%x %X\")"}, +{"にちじ", "(skk-strftime \"%#x %#X\")"}, +{"にちじ", "(skk-strftime \"%c\")"}, {"にちじ", "(skk-strftime \"%#c\")"}, -{"こんげつ", "(skk-strftime \"%B\")"}, -{"ようび", "(skk-strftime \"%A\")"}, -{"いま", "(format-time-string \"%H時%M分\" (current-time))"}, -{"いま", "(format-time-string \"%p%I時%M分\" (current-time))"}, +{"Basic UTC", "(skk-strftime \"!%Y%m%dT%H%M%SZ\")"}, +{"Basic Loc", "(skk-strftime \"%Y%m%dT%H%M%S%z\")"}, + +{"Extended UTC", "(skk-strftime \"!%FT%TZ\")"}, +{"Extended Loc", "(concat (skk-strftime \"%FT%T\") (substring (skk-strftime \"%z\") 0 3) \":\" (substring (skk-strftime \"%z\") 3 5))"}, + } diff --git a/installer/config-sample/config - act.xml b/installer/config-sample/config - act.xml index e5575924..ef67d188 100644 --- a/installer/config-sample/config - act.xml +++ b/installer/config-sample/config - act.xml @@ -2,12 +2,12 @@
- +
@@ -17,6 +17,15 @@
+
+ + + + + + + +
@@ -56,6 +65,7 @@ + @@ -100,6 +110,7 @@ +
@@ -108,6 +119,7 @@ +
@@ -139,6 +151,7 @@ +
@@ -167,6 +180,7 @@ +
diff --git a/installer/config-sample/config - azik-jpkbd.xml b/installer/config-sample/config - azik-jpkbd.xml index dde88fa1..11e6e023 100644 --- a/installer/config-sample/config - azik-jpkbd.xml +++ b/installer/config-sample/config - azik-jpkbd.xml @@ -2,12 +2,12 @@
- +
@@ -17,6 +17,15 @@
+
+ + + + + + + +
@@ -56,6 +65,7 @@ + @@ -100,6 +110,7 @@ +
@@ -108,6 +119,7 @@ +
@@ -141,6 +153,7 @@ +
@@ -169,6 +182,7 @@ +
diff --git a/installer/config-sample/config - azik-uskbd.xml b/installer/config-sample/config - azik-uskbd.xml index 0a8468ab..12ddd74b 100644 --- a/installer/config-sample/config - azik-uskbd.xml +++ b/installer/config-sample/config - azik-uskbd.xml @@ -2,12 +2,12 @@
- +
@@ -17,6 +17,15 @@
+
+ + + + + + + +
@@ -56,6 +65,7 @@ + @@ -100,6 +110,7 @@ +
@@ -108,6 +119,7 @@ +
@@ -141,6 +153,7 @@ +
@@ -169,6 +182,7 @@ +
diff --git a/installer/config-sample/config - gact10.xml b/installer/config-sample/config - gact10.xml index 5f27f723..1bfabafe 100644 --- a/installer/config-sample/config - gact10.xml +++ b/installer/config-sample/config - gact10.xml @@ -2,7 +2,7 @@
- +
@@ -52,6 +52,15 @@
+
+ + + + + + + +
@@ -91,6 +100,7 @@ + @@ -135,6 +145,7 @@ +
@@ -143,6 +154,7 @@ +
@@ -172,6 +184,7 @@ +
@@ -200,6 +213,7 @@ +
diff --git a/installer/config-sample/config - kana.xml b/installer/config-sample/config - kana.xml index a166d17e..07f1be3a 100644 --- a/installer/config-sample/config - kana.xml +++ b/installer/config-sample/config - kana.xml @@ -20,7 +20,7 @@ -->
- +
@@ -30,6 +30,15 @@
+
+ + + + + + + +
@@ -69,6 +78,7 @@ + @@ -113,6 +123,7 @@ +
@@ -121,6 +132,7 @@ +
@@ -150,6 +162,7 @@ +
@@ -178,6 +191,7 @@ +
diff --git a/installer/config-sample/config - roman.xml b/installer/config-sample/config - roman.xml index 8630fed9..c7182382 100644 --- a/installer/config-sample/config - roman.xml +++ b/installer/config-sample/config - roman.xml @@ -7,7 +7,7 @@ -->
- +
@@ -17,6 +17,15 @@
+
+ + + + + + + +
@@ -56,6 +65,7 @@ + @@ -100,6 +110,7 @@ +
@@ -108,6 +119,7 @@ +
@@ -137,6 +149,7 @@ +
@@ -165,6 +178,7 @@ +
diff --git a/installer/config-sample/config - tsuki-2-263-jpkbd.xml b/installer/config-sample/config - tsuki-2-263-jpkbd.xml index 269f7cc9..874ce9ba 100644 --- a/installer/config-sample/config - tsuki-2-263-jpkbd.xml +++ b/installer/config-sample/config - tsuki-2-263-jpkbd.xml @@ -23,7 +23,7 @@ -->
- +
@@ -33,6 +33,15 @@
+
+ + + + + + + +
@@ -72,6 +81,7 @@ + @@ -116,6 +126,7 @@ +
@@ -124,6 +135,7 @@ +
@@ -156,6 +168,7 @@ +
@@ -184,6 +197,7 @@ +
diff --git a/installer/config-sample/config - tsuki-2-263-uskbd.xml b/installer/config-sample/config - tsuki-2-263-uskbd.xml index dc163d13..a7bfcab9 100644 --- a/installer/config-sample/config - tsuki-2-263-uskbd.xml +++ b/installer/config-sample/config - tsuki-2-263-uskbd.xml @@ -23,7 +23,7 @@ -->
- +
@@ -33,6 +33,15 @@
+
+ + + + + + + +
@@ -72,6 +81,7 @@ + @@ -116,6 +126,7 @@ +
@@ -124,6 +135,7 @@ +
@@ -156,6 +168,7 @@ +
@@ -184,6 +197,7 @@ +
diff --git a/installer/config-sample/config - wait-sample.xml b/installer/config-sample/config - wait-sample.xml index 3e4f4717..91fe6100 100644 --- a/installer/config-sample/config - wait-sample.xml +++ b/installer/config-sample/config - wait-sample.xml @@ -7,7 +7,7 @@ -->
- +
@@ -17,6 +17,15 @@
+
+ + + + + + + +
@@ -56,6 +65,7 @@ + @@ -100,6 +110,7 @@ +
@@ -108,6 +119,7 @@ +
@@ -137,6 +149,7 @@ +
@@ -165,6 +178,7 @@ +
diff --git a/installer/config-sample/skk-strftime.txt b/installer/config-sample/skk-strftime.txt index 48c91662..e97bb232 100644 --- a/installer/config-sample/skk-strftime.txt +++ b/installer/config-sample/skk-strftime.txt @@ -3,6 +3,7 @@ ;; ;; okuri-ari entries. ;; okuri-nasi entries. +datetime /(skk-strftime "!%Y%m%dT%H%M%SZ")/(skk-strftime "%Y%m%dT%H%M%S%z")/(skk-strftime "!%FT%TZ")/(concat (skk-strftime "%FT%T") (substring (skk-strftime "%z") 0 3) ":" (substring (skk-strftime "%z") 3 5))/ いま /(skk-strftime "%Y年%#m月%#d日(%a) %#H時%#M分%#S秒")/ #びょうご /(skk-strftime "%Y年%#m月%#d日(%a) %#H時%#M分%#S秒" "sec" #0)/ #びょうまえ /(skk-strftime "%Y年%#m月%#d日(%a) %#H時%#M分%#S秒" "sec" -#0)/ diff --git a/installer/config-share/config.xml b/installer/config-share/config.xml index 98436f77..132db1b7 100644 --- a/installer/config-share/config.xml +++ b/installer/config-share/config.xml @@ -10,6 +10,15 @@
+
+ + + + + + + +
@@ -49,6 +58,7 @@ + @@ -93,6 +103,7 @@ +
@@ -101,6 +112,7 @@ +
@@ -130,6 +142,7 @@ +
@@ -158,6 +171,7 @@ +
diff --git a/installer/installer-arm.wxs b/installer/installer-arm.wxs deleted file mode 100644 index 45e09716..00000000 --- a/installer/installer-arm.wxs +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Installed - NOT REMOVE - - - - = 603]]> - - - - - diff --git a/installer/installer-arm32.wxs b/installer/installer-arm32.wxs new file mode 100644 index 00000000..ffdca6f8 --- /dev/null +++ b/installer/installer-arm32.wxs @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/installer/installer-arm64.wxs b/installer/installer-arm64.wxs new file mode 100644 index 00000000..72151059 --- /dev/null +++ b/installer/installer-arm64.wxs @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/installer/installer-bundle-arm.wxs b/installer/installer-bundle-arm.wxs deleted file mode 100644 index fd96bd64..00000000 --- a/installer/installer-bundle-arm.wxs +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installer/installer-bundle-ucrt.wxi b/installer/installer-bundle-ucrt.wxi deleted file mode 100644 index 1361e3c5..00000000 --- a/installer/installer-bundle-ucrt.wxi +++ /dev/null @@ -1,277 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/installer/installer-bundle.wixproj b/installer/installer-bundle.wixproj new file mode 100644 index 00000000..df356e16 --- /dev/null +++ b/installer/installer-bundle.wixproj @@ -0,0 +1,39 @@ + + + Bundle + x86 + none + Release + true + false + corvusskk-$(VERSION) + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/installer/installer-bundle.wxs b/installer/installer-bundle.wxs index a9a930c5..3142c869 100644 --- a/installer/installer-bundle.wxs +++ b/installer/installer-bundle.wxs @@ -1,108 +1,75 @@ - - - - + + Condition="(VersionNT = v10.0 AND WindowsBuildNumber >= 14393) OR (VersionNT > v10.0)"> + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Theme="rtfLargeLicense" + LocalizationFile="theme-bundle\thm.wxl" + SuppressOptionsUI="yes" + ShowVersion="yes" /> + + + + - - - - - + InstallCondition="VersionNT" /> + + + + + + diff --git a/installer/installer-msi.wixproj b/installer/installer-msi.wixproj new file mode 100644 index 00000000..6a70b90c --- /dev/null +++ b/installer/installer-msi.wixproj @@ -0,0 +1,46 @@ + + + Package + none + Release + true + false + + + + x86 + + + x64 + + + arm32 + + + arm64 + + + + + + + + + + + + + + + + + + + + + diff --git a/installer/installer-version.wxi b/installer/installer-version.wxi deleted file mode 100644 index f1ccf862..00000000 --- a/installer/installer-version.wxi +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/installer/installer-x64.wxs b/installer/installer-x64.wxs index 8533eda1..bca2668e 100644 --- a/installer/installer-x64.wxs +++ b/installer/installer-x64.wxs @@ -1,88 +1,86 @@ - - + - - - - + - - - - - - - - + + + - + + + + - - + + - + - - + + - - + + - - + + - - + + - - + + - + + Source="$(env.VCToolsRedistDir)x64\Microsoft.VC143.CRT\msvcp140.dll" KeyPath="yes" /> - + + Source="$(env.VCToolsRedistDir)x64\Microsoft.VC143.CRT\vcruntime140.dll" KeyPath="yes" /> - + + Source="$(env.VCToolsRedistDir)x64\Microsoft.VC143.CRT\vcruntime140_1.dll" KeyPath="yes" /> - - - + + + + + @@ -97,7 +95,7 @@ - + @@ -111,10 +109,6 @@ - - = 600]]> - - - + diff --git a/installer/installer-x86.wxs b/installer/installer-x86.wxs index e22f053d..6368e8f2 100644 --- a/installer/installer-x86.wxs +++ b/installer/installer-x86.wxs @@ -1,116 +1,130 @@ - - + - - - - + - - - - - - - - - - + + + + + + + + - - + + + + - + + + + - - + + - + - + - + - + - + + Source="$(env.VCToolsRedistDir)x86\Microsoft.VC143.CRT\msvcp140.dll" KeyPath="yes" /> + Source="$(env.VCToolsRedistDir)x86\Microsoft.VC143.CRT\vcruntime140.dll" KeyPath="yes" /> - + - + - + - - + + - - + + - - - - - + + + + + + @@ -129,7 +143,7 @@ - + @@ -143,10 +157,6 @@ - - = 600]]> - - - + diff --git a/installer/installer.vcxproj b/installer/installer.vcxproj index ed8f1b83..9977448a 100644 --- a/installer/installer.vcxproj +++ b/installer/installer.vcxproj @@ -1,6 +1,14 @@  + + Debug + Win32 + + + Debug + x64 + Debug ARM @@ -9,12 +17,16 @@ Debug ARM64 - + Debug + ARM64EC + + + Release Win32 - - Debug + + Release x64 @@ -25,13 +37,9 @@ Release ARM64 - + Release - Win32 - - - Release - x64 + ARM64EC @@ -42,29 +50,29 @@ - - + + + - - + + + - + - - @@ -87,27 +95,42 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -121,47 +144,57 @@ Makefile true - v142 + v143 Makefile true - v142 + v143 Makefile true - v142 + v143 Makefile true - v142 + v143 + + + Makefile + true + v143 Makefile false - v142 + v143 Makefile false - v142 + v143 Makefile false - v142 + v143 Makefile false - v142 + v143 + + + Makefile + false + v143 - + @@ -173,7 +206,10 @@ - + + + + @@ -185,110 +221,134 @@ + + + - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - if exist "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" > nul + if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" > nul - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - WIN32;_DEBUG;$(NMakePreprocessorDefinitions) - build\ - obj\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - if exist "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" > nul + if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" > nul - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - WIN32;_DEBUG;$(NMakePreprocessorDefinitions) - build\ - obj\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - obj\$(Platform)\$(Configuration)\ - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - if exist "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" > nul + if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" > nul - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - WIN32;_DEBUG;$(NMakePreprocessorDefinitions) + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - obj\$(Platform)\$(Configuration)\ - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - if exist "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)$(Platform)\$(Configuration)\init.lua" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" > nul -if exist "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)$(Platform)\$(Configuration)\skkdict.txt" > nul + if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" > nul - copy /y "config-lua\init.lua" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -copy /y "config-share\config.xml" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul -icacls "$(SolutionDir)$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul -copy /y "config-share\skkdict.txt" "$(SolutionDir)$(Platform)\$(Configuration)\" > nul + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul - WIN32;_DEBUG;$(NMakePreprocessorDefinitions) + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul + + if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\skkdict.txt" > nul +if exist "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" del /f "$(SolutionDir)build\$(Platform)\$(Configuration)\init.lua" > nul + + copy /y "config-share\config.xml" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +icacls "$(SolutionDir)build\$(Platform)\$(Configuration)\config.xml" /grant *S-1-15-2-1:R > nul +copy /y "config-share\skkdict.txt" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul +copy /y "config-lua\init.lua" "$(SolutionDir)build\$(Platform)\$(Configuration)\" > nul + + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - WIN32;NDEBUG;$(NMakePreprocessorDefinitions) echo build > nul - echo rebuild > nul echo clean > nul - build\ - obj\$(Platform)\$(Configuration)\ + echo rebuild > nul + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - WIN32;NDEBUG;$(NMakePreprocessorDefinitions) echo build > nul - echo rebuild > nul echo clean > nul - build\ - obj\$(Platform)\$(Configuration)\ + echo rebuild > nul + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - obj\$(Platform)\$(Configuration)\ - WIN32;NDEBUG;$(NMakePreprocessorDefinitions) echo build > nul - echo rebuild > nul echo clean > nul + echo rebuild > nul + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - obj\$(Platform)\$(Configuration)\ - WIN32;NDEBUG;$(NMakePreprocessorDefinitions) echo build > nul + echo clean > nul echo rebuild > nul + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + echo build > nul echo clean > nul + echo rebuild > nul + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ diff --git a/installer/installer.vcxproj.filters b/installer/installer.vcxproj.filters index e0248197..e630035a 100644 --- a/installer/installer.vcxproj.filters +++ b/installer/installer.vcxproj.filters @@ -21,96 +21,96 @@ - - Installer Files + + config-lua - - Installer Files + + config-lua - - Installer Files + + config-lua - - Installer Files + + config-lua - - Installer Files + + config-lua - - Installer Files + + config-lua - - Installer Files + + resource-md - + Installer Files - + Installer Files - + Installer Files - + Installer Files - + Installer Files - - Installer Files + + + theme-bundle - - Installer Files + + theme-bundle - + Installer Files - - config-lua + + Installer Files - - config-lua + + Installer Files - - config-lua + + Installer Files - - config-lua + + Installer Files - - config-lua + + Installer Files - - config-lua + + Installer Files - - resource-md + + Installer Files - + Installer Files - + Installer Files - + Installer Files - + Installer Files - + Installer Files - + Installer Files - + Installer Files - - - theme-bundle + + Installer Files @@ -161,77 +161,122 @@ - + + theme-bundle + + + theme-bundle + + + theme-bundle + + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - + resource-md - - theme-bundle + + resource-md - - theme-bundle + + resource-md - - theme-bundle + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md + + + resource-md \ No newline at end of file diff --git a/installer/resource-md/00_input_mode_ascii.png b/installer/resource-md/00_input_mode_ascii.png new file mode 100644 index 00000000..afa7eb9c Binary files /dev/null and b/installer/resource-md/00_input_mode_ascii.png differ diff --git a/installer/resource-md/00_input_mode_default.png b/installer/resource-md/00_input_mode_default.png new file mode 100644 index 00000000..4d1302c3 Binary files /dev/null and b/installer/resource-md/00_input_mode_default.png differ diff --git a/installer/resource-md/00_input_mode_hiragana.png b/installer/resource-md/00_input_mode_hiragana.png new file mode 100644 index 00000000..e50a3def Binary files /dev/null and b/installer/resource-md/00_input_mode_hiragana.png differ diff --git a/installer/resource-md/00_input_mode_jlatin.png b/installer/resource-md/00_input_mode_jlatin.png new file mode 100644 index 00000000..32391550 Binary files /dev/null and b/installer/resource-md/00_input_mode_jlatin.png differ diff --git a/installer/resource-md/00_input_mode_katakana.png b/installer/resource-md/00_input_mode_katakana.png new file mode 100644 index 00000000..78cc7a59 Binary files /dev/null and b/installer/resource-md/00_input_mode_katakana.png differ diff --git a/installer/resource-md/00_input_mode_katakana1.png b/installer/resource-md/00_input_mode_katakana1.png new file mode 100644 index 00000000..f27beefa Binary files /dev/null and b/installer/resource-md/00_input_mode_katakana1.png differ diff --git a/installer/resource-md/00_input_mode_p_ascii.png b/installer/resource-md/00_input_mode_p_ascii.png new file mode 100644 index 00000000..5eb3e88b Binary files /dev/null and b/installer/resource-md/00_input_mode_p_ascii.png differ diff --git a/installer/resource-md/00_input_mode_p_hiragana.png b/installer/resource-md/00_input_mode_p_hiragana.png new file mode 100644 index 00000000..75df484f Binary files /dev/null and b/installer/resource-md/00_input_mode_p_hiragana.png differ diff --git a/installer/resource-md/00_input_mode_p_jlatin.png b/installer/resource-md/00_input_mode_p_jlatin.png new file mode 100644 index 00000000..f469bca3 Binary files /dev/null and b/installer/resource-md/00_input_mode_p_jlatin.png differ diff --git a/installer/resource-md/00_input_mode_p_katakana.png b/installer/resource-md/00_input_mode_p_katakana.png new file mode 100644 index 00000000..337526b3 Binary files /dev/null and b/installer/resource-md/00_input_mode_p_katakana.png differ diff --git a/installer/resource-md/00_input_mode_p_katakana1.png b/installer/resource-md/00_input_mode_p_katakana1.png new file mode 100644 index 00000000..24eb740f Binary files /dev/null and b/installer/resource-md/00_input_mode_p_katakana1.png differ diff --git a/installer/resource-md/01_dictionary.png b/installer/resource-md/01_dictionary.png deleted file mode 100644 index 93760bfc..00000000 Binary files a/installer/resource-md/01_dictionary.png and /dev/null differ diff --git a/installer/resource-md/01_input_menu_0.png b/installer/resource-md/01_input_menu_0.png new file mode 100644 index 00000000..92cf2676 Binary files /dev/null and b/installer/resource-md/01_input_menu_0.png differ diff --git a/installer/resource-md/01_input_menu_1.png b/installer/resource-md/01_input_menu_1.png new file mode 100644 index 00000000..35541414 Binary files /dev/null and b/installer/resource-md/01_input_menu_1.png differ diff --git a/installer/resource-md/02_behavior_1.png b/installer/resource-md/02_behavior_1.png deleted file mode 100644 index d074b883..00000000 Binary files a/installer/resource-md/02_behavior_1.png and /dev/null differ diff --git a/installer/resource-md/20_key_and_mode.png b/installer/resource-md/02_key_and_mode.png similarity index 100% rename from installer/resource-md/20_key_and_mode.png rename to installer/resource-md/02_key_and_mode.png diff --git a/installer/resource-md/03_behavior_2.png b/installer/resource-md/03_behavior_2.png deleted file mode 100644 index 343dbc2a..00000000 Binary files a/installer/resource-md/03_behavior_2.png and /dev/null differ diff --git a/installer/resource-md/04_display1.png b/installer/resource-md/04_display1.png deleted file mode 100644 index 7740e520..00000000 Binary files a/installer/resource-md/04_display1.png and /dev/null differ diff --git a/installer/resource-md/05_display2.png b/installer/resource-md/05_display2.png deleted file mode 100644 index 7dc8f94e..00000000 Binary files a/installer/resource-md/05_display2.png and /dev/null differ diff --git a/installer/resource-md/06_display_attribute_1.png b/installer/resource-md/06_display_attribute_1.png deleted file mode 100644 index d4a812d3..00000000 Binary files a/installer/resource-md/06_display_attribute_1.png and /dev/null differ diff --git a/installer/resource-md/07_display_attribute_2.png b/installer/resource-md/07_display_attribute_2.png deleted file mode 100644 index cc8c015c..00000000 Binary files a/installer/resource-md/07_display_attribute_2.png and /dev/null differ diff --git a/installer/resource-md/08_select_key.png b/installer/resource-md/08_select_key.png deleted file mode 100644 index 449c90ad..00000000 Binary files a/installer/resource-md/08_select_key.png and /dev/null differ diff --git a/installer/resource-md/09_on_off_key.png b/installer/resource-md/09_on_off_key.png deleted file mode 100644 index c76afecb..00000000 Binary files a/installer/resource-md/09_on_off_key.png and /dev/null differ diff --git a/installer/resource-md/101_dictionary_1.png b/installer/resource-md/101_dictionary_1.png new file mode 100644 index 00000000..f17a1ff4 Binary files /dev/null and b/installer/resource-md/101_dictionary_1.png differ diff --git a/installer/resource-md/102_dictionary_2.png b/installer/resource-md/102_dictionary_2.png new file mode 100644 index 00000000..88128308 Binary files /dev/null and b/installer/resource-md/102_dictionary_2.png differ diff --git a/installer/resource-md/103_behavior_1.png b/installer/resource-md/103_behavior_1.png new file mode 100644 index 00000000..c6c88427 Binary files /dev/null and b/installer/resource-md/103_behavior_1.png differ diff --git a/installer/resource-md/104_behavior_2.png b/installer/resource-md/104_behavior_2.png new file mode 100644 index 00000000..3f2b3db3 Binary files /dev/null and b/installer/resource-md/104_behavior_2.png differ diff --git a/installer/resource-md/105_display_1.png b/installer/resource-md/105_display_1.png new file mode 100644 index 00000000..12501f6d Binary files /dev/null and b/installer/resource-md/105_display_1.png differ diff --git a/installer/resource-md/106_display_2.png b/installer/resource-md/106_display_2.png new file mode 100644 index 00000000..9e1aeaec Binary files /dev/null and b/installer/resource-md/106_display_2.png differ diff --git a/installer/resource-md/107_display_attribute_1.png b/installer/resource-md/107_display_attribute_1.png new file mode 100644 index 00000000..00364754 Binary files /dev/null and b/installer/resource-md/107_display_attribute_1.png differ diff --git a/installer/resource-md/108_display_attribute_2.png b/installer/resource-md/108_display_attribute_2.png new file mode 100644 index 00000000..fbc6a6e7 Binary files /dev/null and b/installer/resource-md/108_display_attribute_2.png differ diff --git a/installer/resource-md/109_select_key.png b/installer/resource-md/109_select_key.png new file mode 100644 index 00000000..aad7f8d5 Binary files /dev/null and b/installer/resource-md/109_select_key.png differ diff --git a/installer/resource-md/10_key1_character.png b/installer/resource-md/10_key1_character.png deleted file mode 100644 index 0f55a08f..00000000 Binary files a/installer/resource-md/10_key1_character.png and /dev/null differ diff --git a/installer/resource-md/110_on_off_key.png b/installer/resource-md/110_on_off_key.png new file mode 100644 index 00000000..0221e689 Binary files /dev/null and b/installer/resource-md/110_on_off_key.png differ diff --git a/installer/resource-md/111_key1_character.png b/installer/resource-md/111_key1_character.png new file mode 100644 index 00000000..25591699 Binary files /dev/null and b/installer/resource-md/111_key1_character.png differ diff --git a/installer/resource-md/112_key2_virtual_key.png b/installer/resource-md/112_key2_virtual_key.png new file mode 100644 index 00000000..ffa526d7 Binary files /dev/null and b/installer/resource-md/112_key2_virtual_key.png differ diff --git a/installer/resource-md/113_conversion_point.png b/installer/resource-md/113_conversion_point.png new file mode 100644 index 00000000..8ddd3a5d Binary files /dev/null and b/installer/resource-md/113_conversion_point.png differ diff --git a/installer/resource-md/114_kana.png b/installer/resource-md/114_kana.png new file mode 100644 index 00000000..753d94c0 Binary files /dev/null and b/installer/resource-md/114_kana.png differ diff --git a/installer/resource-md/115_full_width_latin.png b/installer/resource-md/115_full_width_latin.png new file mode 100644 index 00000000..bada329e Binary files /dev/null and b/installer/resource-md/115_full_width_latin.png differ diff --git a/installer/resource-md/11_key2_virtual_key.png b/installer/resource-md/11_key2_virtual_key.png deleted file mode 100644 index ec8f6874..00000000 Binary files a/installer/resource-md/11_key2_virtual_key.png and /dev/null differ diff --git a/installer/resource-md/12_conversion_point.png b/installer/resource-md/12_conversion_point.png deleted file mode 100644 index 17e19e89..00000000 Binary files a/installer/resource-md/12_conversion_point.png and /dev/null differ diff --git a/installer/resource-md/13_kana.png b/installer/resource-md/13_kana.png deleted file mode 100644 index 7faaac49..00000000 Binary files a/installer/resource-md/13_kana.png and /dev/null differ diff --git a/installer/resource-md/14_full_width_latin.png b/installer/resource-md/14_full_width_latin.png deleted file mode 100644 index 251c6a1c..00000000 Binary files a/installer/resource-md/14_full_width_latin.png and /dev/null differ diff --git a/installer/resource-md/201_convert_program.png b/installer/resource-md/201_convert_program.png new file mode 100644 index 00000000..7ae2a9e5 Binary files /dev/null and b/installer/resource-md/201_convert_program.png differ diff --git a/installer/resource-md/22_convert_number.png b/installer/resource-md/202_convert_number.png similarity index 100% rename from installer/resource-md/22_convert_number.png rename to installer/resource-md/202_convert_number.png diff --git a/installer/resource-md/23_convert_unicode_codepoint.png b/installer/resource-md/203_convert_unicode_codepoint.png similarity index 100% rename from installer/resource-md/23_convert_unicode_codepoint.png rename to installer/resource-md/203_convert_unicode_codepoint.png diff --git a/installer/resource-md/24_convert_unicode_jisx0213.png b/installer/resource-md/204_convert_unicode_jisx0213.png similarity index 100% rename from installer/resource-md/24_convert_unicode_jisx0213.png rename to installer/resource-md/204_convert_unicode_jisx0213.png diff --git a/installer/resource-md/25_convert_character_display.png b/installer/resource-md/205_convert_character_display.png similarity index 100% rename from installer/resource-md/25_convert_character_display.png rename to installer/resource-md/205_convert_character_display.png diff --git a/installer/resource-md/26_register_annotation.png b/installer/resource-md/206_register_annotation.png similarity index 100% rename from installer/resource-md/26_register_annotation.png rename to installer/resource-md/206_register_annotation.png diff --git a/installer/resource-md/21_convert_program.png b/installer/resource-md/21_convert_program.png deleted file mode 100644 index 8a2508fc..00000000 Binary files a/installer/resource-md/21_convert_program.png and /dev/null differ diff --git a/installer/resource-md/logo.png b/installer/resource-md/logo.png new file mode 100644 index 00000000..16433628 Binary files /dev/null and b/installer/resource-md/logo.png differ diff --git a/installer/theme-bundle/license.rtf b/installer/theme-bundle/license.rtf index 18d5f4bc..41faa27d 100644 --- a/installer/theme-bundle/license.rtf +++ b/installer/theme-bundle/license.rtf @@ -1,12 +1,12 @@ {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Verdana;}} {\colortbl ;\red0\green0\blue255;} -{\*\generator Riched20 10.0.18362}\viewkind4\uc1 +{\*\generator Riched20 10.0.19041}\viewkind4\uc1 \pard\sl240\slmult1\f0\fs16\par CorvusSKK\par \par The MIT License\par \par -Copyright (C) 2011-2020 SASAKI Nobuyuki\par +Copyright (C) 2011-2024 SASAKI Nobuyuki\par \par Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\par \par @@ -31,11 +31,35 @@ License:\par ----------------------------------------------------\par \par \par +JIS X 0208 (1990) to Unicode\par +\'a9 2015 Unicode\'ae, Inc.\par +\par +JIS X 0212 (1990) to Unicode\par +\'a9 2015 Unicode\'ae, Inc.\par +\par +COPYRIGHT AND PERMISSION NOTICE\par +\par +Copyright \'a9 1991-2021 Unicode, Inc. All rights reserved.\par +Distributed under the Terms of Use in {{\field{\*\fldinst{HYPERLINK https://www.unicode.org/copyright.html }}{\fldrslt{https://www.unicode.org/copyright.html\ul0\cf0}}}}\f0\fs16 .\par +\par +Permission is hereby granted, free of charge, to any person obtaining a copy of the Unicode data files and any associated documentation (the "Data Files") or Unicode software and any associated documentation (the "Software") to deal in the Data Files or Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Data Files or Software, and to permit persons to whom the Data Files or Software are furnished to do so, provided that either\par +(a) this copyright and permission notice appear with all copies of the Data Files or Software, or\par +(b) this copyright and permission notice appear in associated Documentation.\par +\par +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.\par +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.\par +\par +Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder.\par +\par +\par +----------------------------------------------------\par +\par +\par Lua\par \par The MIT License\par \par -Copyright (C) 1994-2018 Lua.org, PUC-Rio.\par +Copyright (C) 1994-2024 Lua.org, PUC-Rio.\par \par Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\par \par @@ -51,7 +75,7 @@ zlib\par \par The zlib/libpng License\par \par -Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler\par +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler\par \par This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\par \par @@ -102,83 +126,90 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI \par \par MICROSOFT SOFTWARE LICENSE TERMS\par -MICROSOFT VISUAL STUDIO COMMUNITY 2019\par +MICROSOFT VISUAL STUDIO COMMUNITY 2022\par \par -3. DISTRIBUTABLE CODE.\par +4. DISTRIBUTABLE CODE.\par -\pard\li142\sl240\slmult1 The software contains code that you may distribute in applications you develop as described in this Section. For purposes of this Section 3, the term \lang1041 "\lang1033 distribution\lang1041 "\lang1033 also means deployment of your applications for third parties to access over the Internet.\par +\pard\li142\sl240\slmult1 The software contains code that you may distribute in applications you develop as described in this Section. For purposes of this Section 4, the term \ldblquote distribution\rdblquote also means deployment of your applications for third parties to access over the Internet.\par \pard\sl240\slmult1\par \pard\li142\sl240\slmult1 a. Right to Use and Distribute.\par -\pard\fi-142\li426\sl240\slmult1 The code and text files listed below are \lang1041 "\lang1033 Distributable Code\lang1041 "\lang1033 .\par -\'b7 Distributable List. You may copy and distribute the object code form of code listed on the Distributable List located at {{\field{\*\fldinst{HYPERLINK https://aka.ms/vs/16/redistribution }}{\fldrslt{https://aka.ms/vs/16/redistribution\ul0\cf0}}}}\f0\fs16 .\par -\'b7 Sample Code, Templates and Styles. You may copy, modify and distribute the source and object code form of code marked as "sample", "template", "simple styles" and \ldblquote sketch styles".\par -\'b7 Third Party Distribution. You may permit distributors of your applications to copy and distribute the Distributable Code as part of those applications.\par +\pard\li284\sl240\slmult1 The code and text files listed below are \ldblquote Distributable Code\rdblquote .\par +i. Distributable List.\par + +\pard\li426\sl240\slmult1 You may copy and distribute the object code form of code listed on the Distributable List located at {{\field{\*\fldinst{HYPERLINK https://aka.ms/vs/17/redistribution }}{\fldrslt{https://aka.ms/vs/17/redistribution\ul0\cf0}}}}\f0\fs16 .\par + +\pard\li284\sl240\slmult1 ii. Sample Code, Templates and Styles.\par + +\pard\li426\sl240\slmult1 You may copy, modify and distribute the source and object code form of code marked as \ldblquote sample\rdblquote , \ldblquote template\rdblquote , \ldblquote simple styles\rdblquote and \ldblquote sketch styles\rdblquote .\par + +\pard\li284\sl240\slmult1 iii. Third Party Distribution.\par + +\pard\li426\sl240\slmult1 You may permit distributors of your applications to copy and distribute the Distributable Code as part of those applications.\par \pard\sl240\slmult1\par \pard\li142\sl240\slmult1 b. Distribution Requirements.\par -\pard\fi-142\li426\sl240\slmult1 For any Distributable Code you distribute, you must:\par -\'b7 add significant primary functionality to it in your applications; and\par +\pard\li284\sl240\slmult1 For any Distributable Code you distribute, you must:\par + +\pard\fi-142\li426\sl240\slmult1\'b7 add significant primary functionality to it in your applications; and\par \'b7 require distributors and external end users to agree to terms that protect the Distributable Code at least as much as this agreement.\par \pard\sl240\slmult1\par \pard\li142\sl240\slmult1 c. Distribution Restrictions.\par -\pard\fi-142\li426\sl240\slmult1 You may not:\par +\pard\li284\sl240\slmult1 You may not:\par + +\pard\fi-142\li426\sl240\slmult1\'b7 distribute components or runtimes that are marked \ldblquote Preview\rdblquote , \ldblquote Pre-release\rdblquote or \ldblquote Beta\rdblquote ;\par \'b7 use Microsoft\rquote s trademarks in your applications\rquote names or in a way that suggests your applications come from or are endorsed by Microsoft; or\par -\'b7 modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An "Excluded License" is one that requires, as a condition of use, modification or distribution of code, that (i) it be disclosed or distributed in source code form; or (ii) others have the right to modify it.\par +\'b7 modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An \ldblquote Excluded License\rdblquote is one that requires, as a condition of use, modification or distribution of code, that (i) it be disclosed or distributed in source code form; or (ii) others have the right to modify it.\par \pard\sl240\slmult1\par \par -Distributable Code Files for Visual Studio 2019\par -\par -The following section is the "REDIST list" that is referenced in the "Distributable Code" section of the Microsoft Software License Terms for Visual Studio Enterprise 2019, Visual Studio Professional 2019, Visual Studio Community 2019 ("the software"). If you have a validly licensed copy of such software, you may copy and distribute with your program the unmodified form of the files listed below, subject to the License Terms for the software.\par +Distributable Code for Visual Studio 2022\par \par -In the lists below...\par -\pard\fi-142\li284\sl240\slmult1\'b7 [arch] represents the processor architecture identifier, for instance "x86", "x64", or "arm".\par -\'b7 [locale] represents a specific language, locale, or culture identifier, for instance "ENU", "en-us", or "1033".\par -\'b7 [version] represents a folder name that uses a version number.\par -\'b7 [VisualStudioFolder] represents the install location for Visual Studio 2019.\par +\pard\li142\sl240\slmult1 In the lists below...\par \pard\sl240\slmult1\par -\par -Visual C++ Runtime Files\par -\par -Subject to the License Terms for the software, you may copy and distribute the following files, unmodified, as a part of the installation package of your program:\par -\par -\pard\fi-142\li284\sl240\slmult1\'b7 [Program Files (x86)]\\Common Files\\Merge Modules\\\par +\pard\fi-142\li426\sl240\slmult1 [arch] represents the processor architecture identifier, for instance "x86", "x64", or "arm".\par +[locale] represents a specific language, locale, or culture identifier, for instance "ENU", "en-us", or "1033".\par +[version] represents a folder name that uses a version number.\par +[VisualStudioFolder] represents the install location for Visual Studio 2022.\par + +\pard\sl240\slmult1\par -\pard\fi-142\li426\sl240\slmult1\'b7 Microsoft_VC141_CRT_[arch].msm\par -\'b7 Microsoft_VC141_CXXAMP_[arch].msm\par -\'b7 Microsoft_VC141_MFC_[arch].msm\par -\'b7 Microsoft_VC141_MFCLOC_[arch].msm\par -\'b7 Microsoft_VC141_OpenMP_[arch].msm\par +\pard\li142\sl240\slmult1 Distributable Code Files for Visual Studio 2022\par \pard\sl240\slmult1\par -Subject to the License Terms for the software, you may copy and distribute with\par -your program any of the files within the following folder and its subfolders\par -except as noted below. You may not modify these files.\par -\par -\pard\fi-142\li284\sl240\slmult1\'b7 [VisualStudioFolder]\\VC\\redist\par -\'b7 You may not distribute the contents of the following folders:\par +\pard\li284\sl240\slmult1 The following section is the "REDIST list" that is referenced in the "Distributable Code" section of the Microsoft Software License Terms for Visual Studio Enterprise 2022, Visual Studio Professional 2022, Visual Studio Community 2022 ("the software"). If you have a validly licensed copy of such software, you may copy and distribute with your program the unmodified form of the files listed below, subject to the License Terms for the software.\par + +\pard\sl240\slmult1\par -\pard\fi-142\li426\sl240\slmult1\'b7 [VisualStudioFolder]VC\\Redist\\MSVC\\[version]\\debug_nonredist\par -\'b7 [VisualStudioFolder]VC\\Redist\\MSVC\\[version]\\debug_nonredist\par -\'b7 [VisualStudioFolder]\\VC\\Redist\\MSVC\\[version]\\onecore\\debug_nonredist\par +\pard\li284\sl240\slmult1 Visual C++ Runtime Files\par + +\pard\sl240\slmult1\par + +\pard\li426\sl240\slmult1 Subject to the License Terms for the software, you may copy and distribute with your program any of the files within the following folder and its subfolders except as noted below. You may not modify these files.\par + +\pard\sl240\slmult1\par + +\pard\li568\sl240\slmult1 [VisualStudioFolder]\\VC\\redist\par + +\pard\sl240\slmult1\par + +\pard\li426\sl240\slmult1 You may not distribute the contents of the following folders (please see List of Utilities and Build Tools for Visual Studio 2022 for allowed usage for development/testing purposes):\par \pard\sl240\slmult1\par -Subject to the License Terms for the software, you may copy and distribute the following files with your program in your program\rquote s application local folder or by deploying them into the Global Assembly Cache (GAC):\par -\par -\pard\fi-142\li284\sl240\slmult1\'b7 [VisualStudioFolder]\\VC\\Tools\\MSVC\\[version]\\atlmfc\\lib\\[arch]\\mfcmifc80.dll\par +\pard\li568\sl240\slmult1 [VisualStudioFolder]VC\\Redist\\MSVC\\[version]\\debug_nonredist\par +[VisualStudioFolder]\\VC\\Redist\\MSVC\\[version]\\onecore\\debug_nonredist\par \pard\sl240\slmult1\par \par diff --git a/installer/theme-bundle/logo.png b/installer/theme-bundle/logo.png index 6681a74b..16433628 100644 Binary files a/installer/theme-bundle/logo.png and b/installer/theme-bundle/logo.png differ diff --git a/installer/theme-bundle/thm.wxl b/installer/theme-bundle/thm.wxl new file mode 100644 index 00000000..74860993 --- /dev/null +++ b/installer/theme-bundle/thm.wxl @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/imcrvtip/input.cpp b/libinput/input.cpp similarity index 91% rename from imcrvtip/input.cpp rename to libinput/input.cpp index dbe6c561..5362d2e2 100644 --- a/imcrvtip/input.cpp +++ b/libinput/input.cpp @@ -10,6 +10,7 @@ UINT WINAPI EnumEnabledLayoutOrTip( _Out_ LAYOUTORTIPPROFILE *pLayoutOrTipProfile, _In_ UINT uBufLength ) { + pLayoutOrTipProfile = nullptr; return 0; } @@ -19,6 +20,7 @@ UINT WINAPI EnumLayoutOrTipForSetup( _In_ UINT uBufLength, _In_ DWORD dwFlags ) { + pLayoutOrTip = nullptr; return 0; } diff --git a/imcrvtip/input.def b/libinput/input.def similarity index 100% rename from imcrvtip/input.def rename to libinput/input.def diff --git a/imcrvtip/input.h b/libinput/input.h similarity index 95% rename from imcrvtip/input.h rename to libinput/input.h index 4bf910eb..baa9ea58 100644 --- a/imcrvtip/input.h +++ b/libinput/input.h @@ -2,8 +2,9 @@ #include -EXTERN_C -{ +// input.dll dummy functions + +EXTERN_C_START typedef struct tagLAYOUTORTIPPROFILE { DWORD dwProfileType; // InputProcessor or HKL @@ -106,4 +107,4 @@ BOOL WINAPI SetDefaultLayoutOrTipUserReg( _In_ DWORD dwFlags ); -} +EXTERN_C_END diff --git a/libinput/libinput.vcxproj b/libinput/libinput.vcxproj new file mode 100644 index 00000000..ec605f20 --- /dev/null +++ b/libinput/libinput.vcxproj @@ -0,0 +1,448 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Debug + ARM + + + Debug + ARM64 + + + Debug + ARM64EC + + + Release + Win32 + + + Release + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + ARM64EC + + + + {1e93d511-25bf-4ccf-93e5-da44f66016ab} + Win32Proj + libinput + 10.0 + libinput + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + true + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + input + true + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + + + Windows + true + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + + + Windows + true + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + + + Windows + true + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + + + Windows + true + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + + + Windows + true + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Guard + MultiThreaded + true + + + Windows + true + true + false + false + input.def + UseLinkTimeCodeGeneration + true + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Guard + MultiThreaded + true + + + Windows + true + true + false + false + input.def + UseLinkTimeCodeGeneration + true + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Guard + MultiThreaded + true + + + Windows + true + true + false + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Guard + MultiThreaded + true + + + Windows + true + true + false + false + input.def + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Guard + MultiThreaded + true + + + Windows + true + true + false + false + input.def + UseLinkTimeCodeGeneration + + + if exist "$(OutDir)input.dll" del "$(OutDir)input.dll" + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libinput/libinput.vcxproj.filters b/libinput/libinput.vcxproj.filters new file mode 100644 index 00000000..7e52eed7 --- /dev/null +++ b/libinput/libinput.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + + + Header Files + + + + + Source Files + + + + + + \ No newline at end of file diff --git a/liblua/lapi.c b/liblua/lapi.c index df7317f3..332e97d1 100644 --- a/liblua/lapi.c +++ b/liblua/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.259.1.2 2017/12/06 18:35:12 roberto Exp $ +** $Id: lapi.c $ ** Lua API ** See Copyright Notice in lua.h */ @@ -10,6 +10,7 @@ #include "lprefix.h" +#include #include #include @@ -36,11 +37,14 @@ const char lua_ident[] = "$LuaAuthors: " LUA_AUTHORS " $"; -/* value at a non-valid index */ -#define NONVALIDVALUE cast(TValue *, luaO_nilobject) -/* corresponding test */ -#define isvalid(o) ((o) != luaO_nilobject) +/* +** Test for a valid index (one that is not the 'nilvalue'). +** '!ttisnil(o)' implies 'o != &G(L)->nilvalue', so it is not needed. +** However, it covers the most common cases in a faster way. +*/ +#define isvalid(L, o) (!ttisnil(o) || o != &G(L)->nilvalue) + /* test for pseudo index */ #define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) @@ -48,68 +52,74 @@ const char lua_ident[] = /* test for upvalue */ #define isupvalue(i) ((i) < LUA_REGISTRYINDEX) -/* test for valid but not pseudo index */ -#define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) - -#define api_checkvalidindex(l,o) api_check(l, isvalid(o), "invalid index") - -#define api_checkstackindex(l, i, o) \ - api_check(l, isstackindex(i, o), "index not in the stack") - -static TValue *index2addr (lua_State *L, int idx) { +/* +** Convert an acceptable index to a pointer to its respective value. +** Non-valid indices return the special nil value 'G(L)->nilvalue'. +*/ +static TValue *index2value (lua_State *L, int idx) { CallInfo *ci = L->ci; if (idx > 0) { - TValue *o = ci->func + idx; - api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index"); - if (o >= L->top) return NONVALIDVALUE; - else return o; + StkId o = ci->func.p + idx; + api_check(L, idx <= ci->top.p - (ci->func.p + 1), "unacceptable index"); + if (o >= L->top.p) return &G(L)->nilvalue; + else return s2v(o); } else if (!ispseudo(idx)) { /* negative index */ - api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); - return L->top + idx; + api_check(L, idx != 0 && -idx <= L->top.p - (ci->func.p + 1), + "invalid index"); + return s2v(L->top.p + idx); } else if (idx == LUA_REGISTRYINDEX) return &G(L)->l_registry; else { /* upvalues */ idx = LUA_REGISTRYINDEX - idx; api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); - if (ttislcf(ci->func)) /* light C function? */ - return NONVALIDVALUE; /* it has no upvalues */ - else { - CClosure *func = clCvalue(ci->func); - return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE; + if (ttisCclosure(s2v(ci->func.p))) { /* C closure? */ + CClosure *func = clCvalue(s2v(ci->func.p)); + return (idx <= func->nupvalues) ? &func->upvalue[idx-1] + : &G(L)->nilvalue; + } + else { /* light C function or Lua function (through a hook)?) */ + api_check(L, ttislcf(s2v(ci->func.p)), "caller not a C function"); + return &G(L)->nilvalue; /* no upvalues */ } } } + /* -** to be called by 'lua_checkstack' in protected mode, to grow stack -** capturing memory errors +** Convert a valid actual index (not a pseudo-index) to its address. */ -static void growstack (lua_State *L, void *ud) { - int size = *(int *)ud; - luaD_growstack(L, size); +l_sinline StkId index2stack (lua_State *L, int idx) { + CallInfo *ci = L->ci; + if (idx > 0) { + StkId o = ci->func.p + idx; + api_check(L, o < L->top.p, "invalid index"); + return o; + } + else { /* non-positive index */ + api_check(L, idx != 0 && -idx <= L->top.p - (ci->func.p + 1), + "invalid index"); + api_check(L, !ispseudo(idx), "invalid index"); + return L->top.p + idx; + } } LUA_API int lua_checkstack (lua_State *L, int n) { int res; - CallInfo *ci = L->ci; + CallInfo *ci; lua_lock(L); + ci = L->ci; api_check(L, n >= 0, "negative 'n'"); - if (L->stack_last - L->top > n) /* stack large enough? */ + if (L->stack_last.p - L->top.p > n) /* stack large enough? */ res = 1; /* yes; check is OK */ - else { /* no; need to grow stack */ - int inuse = cast_int(L->top - L->stack) + EXTRA_STACK; - if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */ - res = 0; /* no */ - else /* try to grow stack */ - res = (luaD_rawrunprotected(L, &growstack, &n) == LUA_OK); - } - if (res && ci->top < L->top + n) - ci->top = L->top + n; /* adjust frame top */ + else /* need to grow stack */ + res = luaD_growstack(L, n, 0); + if (res && ci->top.p < L->top.p + n) + ci->top.p = L->top.p + n; /* adjust frame top */ lua_unlock(L); return res; } @@ -121,11 +131,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { lua_lock(to); api_checknelems(from, n); api_check(from, G(from) == G(to), "moving among independent states"); - api_check(from, to->ci->top - to->top >= n, "stack overflow"); - from->top -= n; + api_check(from, to->ci->top.p - to->top.p >= n, "stack overflow"); + from->top.p -= n; for (i = 0; i < n; i++) { - setobj2s(to, to->top, from->top + i); - to->top++; /* stack already checked by previous 'api_check' */ + setobjs2s(to, to->top.p, from->top.p + i); + to->top.p++; /* stack already checked by previous 'api_check' */ } lua_unlock(to); } @@ -141,10 +151,9 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { } -LUA_API const lua_Number *lua_version (lua_State *L) { - static const lua_Number version = LUA_VERSION_NUM; - if (L == NULL) return &version; - else return G(L)->version; +LUA_API lua_Number lua_version (lua_State *L) { + UNUSED(L); + return LUA_VERSION_NUM; } @@ -160,28 +169,51 @@ LUA_API const lua_Number *lua_version (lua_State *L) { LUA_API int lua_absindex (lua_State *L, int idx) { return (idx > 0 || ispseudo(idx)) ? idx - : cast_int(L->top - L->ci->func) + idx; + : cast_int(L->top.p - L->ci->func.p) + idx; } LUA_API int lua_gettop (lua_State *L) { - return cast_int(L->top - (L->ci->func + 1)); + return cast_int(L->top.p - (L->ci->func.p + 1)); } LUA_API void lua_settop (lua_State *L, int idx) { - StkId func = L->ci->func; + CallInfo *ci; + StkId func, newtop; + ptrdiff_t diff; /* difference for new top */ lua_lock(L); + ci = L->ci; + func = ci->func.p; if (idx >= 0) { - api_check(L, idx <= L->stack_last - (func + 1), "new top too large"); - while (L->top < (func + 1) + idx) - setnilvalue(L->top++); - L->top = (func + 1) + idx; + api_check(L, idx <= ci->top.p - (func + 1), "new top too large"); + diff = ((func + 1) + idx) - L->top.p; + for (; diff > 0; diff--) + setnilvalue(s2v(L->top.p++)); /* clear new slots */ } else { - api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); - L->top += idx+1; /* 'subtract' index (index is negative) */ + api_check(L, -(idx+1) <= (L->top.p - (func + 1)), "invalid new top"); + diff = idx + 1; /* will "subtract" index (as it is negative) */ + } + api_check(L, L->tbclist.p < L->top.p, "previous pop of an unclosed slot"); + newtop = L->top.p + diff; + if (diff < 0 && L->tbclist.p >= newtop) { + lua_assert(hastocloseCfunc(ci->nresults)); + newtop = luaF_close(L, newtop, CLOSEKTOP, 0); } + L->top.p = newtop; /* correct top only after closing any upvalue */ + lua_unlock(L); +} + + +LUA_API void lua_closeslot (lua_State *L, int idx) { + StkId level; + lua_lock(L); + level = index2stack(L, idx); + api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist.p == level, + "no variable to close at given level"); + level = luaF_close(L, level, CLOSEKTOP, 0); + setnilvalue(s2v(level)); lua_unlock(L); } @@ -189,11 +221,13 @@ LUA_API void lua_settop (lua_State *L, int idx) { /* ** Reverse the stack segment from 'from' to 'to' ** (auxiliary to 'lua_rotate') +** Note that we move(copy) only the value inside the stack. +** (We do not move additional fields that may exist.) */ -static void reverse (lua_State *L, StkId from, StkId to) { +l_sinline void reverse (lua_State *L, StkId from, StkId to) { for (; from < to; from++, to--) { TValue temp; - setobj(L, &temp, from); + setobj(L, &temp, s2v(from)); setobjs2s(L, from, to); setobj2s(L, to, &temp); } @@ -207,9 +241,8 @@ static void reverse (lua_State *L, StkId from, StkId to) { LUA_API void lua_rotate (lua_State *L, int idx, int n) { StkId p, t, m; lua_lock(L); - t = L->top - 1; /* end of stack segment being rotated */ - p = index2addr(L, idx); /* start of segment */ - api_checkstackindex(L, idx, p); + t = L->top.p - 1; /* end of stack segment being rotated */ + p = index2stack(L, idx); /* start of segment */ api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ reverse(L, p, m); /* reverse the prefix with length 'n' */ @@ -222,12 +255,12 @@ LUA_API void lua_rotate (lua_State *L, int idx, int n) { LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { TValue *fr, *to; lua_lock(L); - fr = index2addr(L, fromidx); - to = index2addr(L, toidx); - api_checkvalidindex(L, to); + fr = index2value(L, fromidx); + to = index2value(L, toidx); + api_check(L, isvalid(L, to), "invalid index"); setobj(L, to, fr); if (isupvalue(toidx)) /* function upvalue? */ - luaC_barrier(L, clCvalue(L->ci->func), fr); + luaC_barrier(L, clCvalue(s2v(L->ci->func.p)), fr); /* LUA_REGISTRYINDEX does not need gc barrier (collector revisits it before finishing collection) */ lua_unlock(L); @@ -236,7 +269,7 @@ LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { LUA_API void lua_pushvalue (lua_State *L, int idx) { lua_lock(L); - setobj2s(L, L->top, index2addr(L, idx)); + setobj2s(L, L->top.p, index2value(L, idx)); api_incr_top(L); lua_unlock(L); } @@ -249,53 +282,53 @@ LUA_API void lua_pushvalue (lua_State *L, int idx) { LUA_API int lua_type (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - return (isvalid(o) ? ttnov(o) : LUA_TNONE); + const TValue *o = index2value(L, idx); + return (isvalid(L, o) ? ttype(o) : LUA_TNONE); } LUA_API const char *lua_typename (lua_State *L, int t) { UNUSED(L); - api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); + api_check(L, LUA_TNONE <= t && t < LUA_NUMTYPES, "invalid type"); return ttypename(t); } LUA_API int lua_iscfunction (lua_State *L, int idx) { - StkId o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return (ttislcf(o) || (ttisCclosure(o))); } LUA_API int lua_isinteger (lua_State *L, int idx) { - StkId o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return ttisinteger(o); } LUA_API int lua_isnumber (lua_State *L, int idx) { lua_Number n; - const TValue *o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return tonumber(o, &n); } LUA_API int lua_isstring (lua_State *L, int idx) { - const TValue *o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return (ttisstring(o) || cvt2str(o)); } LUA_API int lua_isuserdata (lua_State *L, int idx) { - const TValue *o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return (ttisfulluserdata(o) || ttislightuserdata(o)); } LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { - StkId o1 = index2addr(L, index1); - StkId o2 = index2addr(L, index2); - return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0; + const TValue *o1 = index2value(L, index1); + const TValue *o2 = index2value(L, index2); + return (isvalid(L, o1) && isvalid(L, o2)) ? luaV_rawequalobj(o1, o2) : 0; } @@ -305,23 +338,24 @@ LUA_API void lua_arith (lua_State *L, int op) { api_checknelems(L, 2); /* all other operations expect two operands */ else { /* for unary operations, add fake 2nd operand */ api_checknelems(L, 1); - setobjs2s(L, L->top, L->top - 1); + setobjs2s(L, L->top.p, L->top.p - 1); api_incr_top(L); } /* first operand at top - 2, second at top - 1; result go to top - 2 */ - luaO_arith(L, op, L->top - 2, L->top - 1, L->top - 2); - L->top--; /* remove second operand */ + luaO_arith(L, op, s2v(L->top.p - 2), s2v(L->top.p - 1), L->top.p - 2); + L->top.p--; /* remove second operand */ lua_unlock(L); } LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { - StkId o1, o2; + const TValue *o1; + const TValue *o2; int i = 0; lua_lock(L); /* may call tag method */ - o1 = index2addr(L, index1); - o2 = index2addr(L, index2); - if (isvalid(o1) && isvalid(o2)) { + o1 = index2value(L, index1); + o2 = index2value(L, index2); + if (isvalid(L, o1) && isvalid(L, o2)) { switch (op) { case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; @@ -335,7 +369,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) { - size_t sz = luaO_str2num(s, L->top); + size_t sz = luaO_str2num(s, s2v(L->top.p)); if (sz != 0) api_incr_top(L); return sz; @@ -343,66 +377,66 @@ LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) { LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) { - lua_Number n; - const TValue *o = index2addr(L, idx); + lua_Number n = 0; + const TValue *o = index2value(L, idx); int isnum = tonumber(o, &n); - if (!isnum) - n = 0; /* call to 'tonumber' may change 'n' even if it fails */ - if (pisnum) *pisnum = isnum; + if (pisnum) + *pisnum = isnum; return n; } LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) { - lua_Integer res; - const TValue *o = index2addr(L, idx); + lua_Integer res = 0; + const TValue *o = index2value(L, idx); int isnum = tointeger(o, &res); - if (!isnum) - res = 0; /* call to 'tointeger' may change 'n' even if it fails */ - if (pisnum) *pisnum = isnum; + if (pisnum) + *pisnum = isnum; return res; } LUA_API int lua_toboolean (lua_State *L, int idx) { - const TValue *o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return !l_isfalse(o); } LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { - StkId o = index2addr(L, idx); + TValue *o; + lua_lock(L); + o = index2value(L, idx); if (!ttisstring(o)) { if (!cvt2str(o)) { /* not convertible? */ if (len != NULL) *len = 0; + lua_unlock(L); return NULL; } - lua_lock(L); /* 'luaO_tostring' may create a new string */ luaO_tostring(L, o); luaC_checkGC(L); - o = index2addr(L, idx); /* previous call may reallocate the stack */ - lua_unlock(L); + o = index2value(L, idx); /* previous call may reallocate the stack */ } if (len != NULL) - *len = vslen(o); - return svalue(o); + *len = tsslen(tsvalue(o)); + lua_unlock(L); + return getstr(tsvalue(o)); } -LUA_API size_t lua_rawlen (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - switch (ttype(o)) { - case LUA_TSHRSTR: return tsvalue(o)->shrlen; - case LUA_TLNGSTR: return tsvalue(o)->u.lnglen; - case LUA_TUSERDATA: return uvalue(o)->len; - case LUA_TTABLE: return (size_t)luaH_getn(hvalue(o)); +LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { + const TValue *o = index2value(L, idx); + switch (ttypetag(o)) { + case LUA_VSHRSTR: return tsvalue(o)->shrlen; + case LUA_VLNGSTR: return tsvalue(o)->u.lnglen; + case LUA_VUSERDATA: return uvalue(o)->len; + case LUA_VTABLE: return luaH_getn(hvalue(o)); default: return 0; } } LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { - StkId o = index2addr(L, idx); + const TValue *o = index2value(L, idx); if (ttislcf(o)) return fvalue(o); else if (ttisCclosure(o)) return clCvalue(o)->f; @@ -410,9 +444,8 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { } -LUA_API void *lua_touserdata (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - switch (ttnov(o)) { +l_sinline void *touserdata (const TValue *o) { + switch (ttype(o)) { case LUA_TUSERDATA: return getudatamem(uvalue(o)); case LUA_TLIGHTUSERDATA: return pvalue(o); default: return NULL; @@ -420,23 +453,37 @@ LUA_API void *lua_touserdata (lua_State *L, int idx) { } +LUA_API void *lua_touserdata (lua_State *L, int idx) { + const TValue *o = index2value(L, idx); + return touserdata(o); +} + + LUA_API lua_State *lua_tothread (lua_State *L, int idx) { - StkId o = index2addr(L, idx); + const TValue *o = index2value(L, idx); return (!ttisthread(o)) ? NULL : thvalue(o); } +/* +** Returns a pointer to the internal representation of an object. +** Note that ANSI C does not allow the conversion of a pointer to +** function to a 'void*', so the conversion here goes through +** a 'size_t'. (As the returned pointer is only informative, this +** conversion should not be a problem.) +*/ LUA_API const void *lua_topointer (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - switch (ttype(o)) { - case LUA_TTABLE: return hvalue(o); - case LUA_TLCL: return clLvalue(o); - case LUA_TCCL: return clCvalue(o); - case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o))); - case LUA_TTHREAD: return thvalue(o); - case LUA_TUSERDATA: return getudatamem(uvalue(o)); - case LUA_TLIGHTUSERDATA: return pvalue(o); - default: return NULL; + const TValue *o = index2value(L, idx); + switch (ttypetag(o)) { + case LUA_VLCF: return cast_voidp(cast_sizet(fvalue(o))); + case LUA_VUSERDATA: case LUA_VLIGHTUSERDATA: + return touserdata(o); + default: { + if (iscollectable(o)) + return gcvalue(o); + else + return NULL; + } } } @@ -449,7 +496,7 @@ LUA_API const void *lua_topointer (lua_State *L, int idx) { LUA_API void lua_pushnil (lua_State *L) { lua_lock(L); - setnilvalue(L->top); + setnilvalue(s2v(L->top.p)); api_incr_top(L); lua_unlock(L); } @@ -457,7 +504,7 @@ LUA_API void lua_pushnil (lua_State *L) { LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { lua_lock(L); - setfltvalue(L->top, n); + setfltvalue(s2v(L->top.p), n); api_incr_top(L); lua_unlock(L); } @@ -465,7 +512,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { lua_lock(L); - setivalue(L->top, n); + setivalue(s2v(L->top.p), n); api_incr_top(L); lua_unlock(L); } @@ -480,7 +527,7 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { TString *ts; lua_lock(L); ts = (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len); - setsvalue2s(L, L->top, ts); + setsvalue2s(L, L->top.p, ts); api_incr_top(L); luaC_checkGC(L); lua_unlock(L); @@ -491,11 +538,11 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { LUA_API const char *lua_pushstring (lua_State *L, const char *s) { lua_lock(L); if (s == NULL) - setnilvalue(L->top); + setnilvalue(s2v(L->top.p)); else { TString *ts; ts = luaS_new(L, s); - setsvalue2s(L, L->top, ts); + setsvalue2s(L, L->top.p, ts); s = getstr(ts); /* internal copy's address */ } api_incr_top(L); @@ -532,7 +579,7 @@ LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { lua_lock(L); if (n == 0) { - setfvalue(L->top, fn); + setfvalue(s2v(L->top.p), fn); api_incr_top(L); } else { @@ -541,12 +588,13 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { api_check(L, n <= MAXUPVAL, "upvalue index too large"); cl = luaF_newCclosure(L, n); cl->f = fn; - L->top -= n; + L->top.p -= n; while (n--) { - setobj2n(L, &cl->upvalue[n], L->top + n); + setobj2n(L, &cl->upvalue[n], s2v(L->top.p + n)); /* does not need barrier because closure is white */ + lua_assert(iswhite(cl)); } - setclCvalue(L, L->top, cl); + setclCvalue(L, s2v(L->top.p), cl); api_incr_top(L); luaC_checkGC(L); } @@ -556,7 +604,10 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { LUA_API void lua_pushboolean (lua_State *L, int b) { lua_lock(L); - setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + if (b) + setbtvalue(s2v(L->top.p)); + else + setbfvalue(s2v(L->top.p)); api_incr_top(L); lua_unlock(L); } @@ -564,7 +615,7 @@ LUA_API void lua_pushboolean (lua_State *L, int b) { LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { lua_lock(L); - setpvalue(L->top, p); + setpvalue(s2v(L->top.p), p); api_incr_top(L); lua_unlock(L); } @@ -572,7 +623,7 @@ LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { LUA_API int lua_pushthread (lua_State *L) { lua_lock(L); - setthvalue(L, L->top, L); + setthvalue(L, s2v(L->top.p), L); api_incr_top(L); lua_unlock(L); return (G(L)->mainthread == L); @@ -585,99 +636,126 @@ LUA_API int lua_pushthread (lua_State *L) { */ -static int auxgetstr (lua_State *L, const TValue *t, const char *k) { +l_sinline int auxgetstr (lua_State *L, const TValue *t, const char *k) { const TValue *slot; TString *str = luaS_new(L, k); if (luaV_fastget(L, t, str, slot, luaH_getstr)) { - setobj2s(L, L->top, slot); + setobj2s(L, L->top.p, slot); api_incr_top(L); } else { - setsvalue2s(L, L->top, str); + setsvalue2s(L, L->top.p, str); api_incr_top(L); - luaV_finishget(L, t, L->top - 1, L->top - 1, slot); + luaV_finishget(L, t, s2v(L->top.p - 1), L->top.p - 1, slot); } lua_unlock(L); - return ttnov(L->top - 1); + return ttype(s2v(L->top.p - 1)); } +/* +** Get the global table in the registry. Since all predefined +** indices in the registry were inserted right when the registry +** was created and never removed, they must always be in the array +** part of the registry. +*/ +#define getGtable(L) \ + (&hvalue(&G(L)->l_registry)->array[LUA_RIDX_GLOBALS - 1]) + + LUA_API int lua_getglobal (lua_State *L, const char *name) { - Table *reg = hvalue(&G(L)->l_registry); + const TValue *G; lua_lock(L); - return auxgetstr(L, luaH_getint(reg, LUA_RIDX_GLOBALS), name); + G = getGtable(L); + return auxgetstr(L, G, name); } LUA_API int lua_gettable (lua_State *L, int idx) { - StkId t; + const TValue *slot; + TValue *t; lua_lock(L); - t = index2addr(L, idx); - luaV_gettable(L, t, L->top - 1, L->top - 1); + t = index2value(L, idx); + if (luaV_fastget(L, t, s2v(L->top.p - 1), slot, luaH_get)) { + setobj2s(L, L->top.p - 1, slot); + } + else + luaV_finishget(L, t, s2v(L->top.p - 1), L->top.p - 1, slot); lua_unlock(L); - return ttnov(L->top - 1); + return ttype(s2v(L->top.p - 1)); } LUA_API int lua_getfield (lua_State *L, int idx, const char *k) { lua_lock(L); - return auxgetstr(L, index2addr(L, idx), k); + return auxgetstr(L, index2value(L, idx), k); } LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { - StkId t; + TValue *t; const TValue *slot; lua_lock(L); - t = index2addr(L, idx); - if (luaV_fastget(L, t, n, slot, luaH_getint)) { - setobj2s(L, L->top, slot); - api_incr_top(L); + t = index2value(L, idx); + if (luaV_fastgeti(L, t, n, slot)) { + setobj2s(L, L->top.p, slot); } else { - setivalue(L->top, n); - api_incr_top(L); - luaV_finishget(L, t, L->top - 1, L->top - 1, slot); + TValue aux; + setivalue(&aux, n); + luaV_finishget(L, t, &aux, L->top.p, slot); } + api_incr_top(L); + lua_unlock(L); + return ttype(s2v(L->top.p - 1)); +} + + +l_sinline int finishrawget (lua_State *L, const TValue *val) { + if (isempty(val)) /* avoid copying empty items to the stack */ + setnilvalue(s2v(L->top.p)); + else + setobj2s(L, L->top.p, val); + api_incr_top(L); lua_unlock(L); - return ttnov(L->top - 1); + return ttype(s2v(L->top.p - 1)); +} + + +static Table *gettable (lua_State *L, int idx) { + TValue *t = index2value(L, idx); + api_check(L, ttistable(t), "table expected"); + return hvalue(t); } LUA_API int lua_rawget (lua_State *L, int idx) { - StkId t; + Table *t; + const TValue *val; lua_lock(L); - t = index2addr(L, idx); - api_check(L, ttistable(t), "table expected"); - setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); - lua_unlock(L); - return ttnov(L->top - 1); + api_checknelems(L, 1); + t = gettable(L, idx); + val = luaH_get(t, s2v(L->top.p - 1)); + L->top.p--; /* remove key */ + return finishrawget(L, val); } LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) { - StkId t; + Table *t; lua_lock(L); - t = index2addr(L, idx); - api_check(L, ttistable(t), "table expected"); - setobj2s(L, L->top, luaH_getint(hvalue(t), n)); - api_incr_top(L); - lua_unlock(L); - return ttnov(L->top - 1); + t = gettable(L, idx); + return finishrawget(L, luaH_getint(t, n)); } LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) { - StkId t; + Table *t; TValue k; lua_lock(L); - t = index2addr(L, idx); - api_check(L, ttistable(t), "table expected"); - setpvalue(&k, cast(void *, p)); - setobj2s(L, L->top, luaH_get(hvalue(t), &k)); - api_incr_top(L); - lua_unlock(L); - return ttnov(L->top - 1); + t = gettable(L, idx); + setpvalue(&k, cast_voidp(p)); + return finishrawget(L, luaH_get(t, &k)); } @@ -685,7 +763,7 @@ LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { Table *t; lua_lock(L); t = luaH_new(L); - sethvalue(L, L->top, t); + sethvalue2s(L, L->top.p, t); api_incr_top(L); if (narray > 0 || nrec > 0) luaH_resize(L, t, narray, nrec); @@ -699,8 +777,8 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { Table *mt; int res = 0; lua_lock(L); - obj = index2addr(L, objindex); - switch (ttnov(obj)) { + obj = index2value(L, objindex); + switch (ttype(obj)) { case LUA_TTABLE: mt = hvalue(obj)->metatable; break; @@ -708,11 +786,11 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { mt = uvalue(obj)->metatable; break; default: - mt = G(L)->mt[ttnov(obj)]; + mt = G(L)->mt[ttype(obj)]; break; } if (mt != NULL) { - sethvalue(L, L->top, mt); + sethvalue2s(L, L->top.p, mt); api_incr_top(L); res = 1; } @@ -721,15 +799,23 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) { } -LUA_API int lua_getuservalue (lua_State *L, int idx) { - StkId o; +LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) { + TValue *o; + int t; lua_lock(L); - o = index2addr(L, idx); + o = index2value(L, idx); api_check(L, ttisfulluserdata(o), "full userdata expected"); - getuservalue(L, uvalue(o), L->top); + if (n <= 0 || n > uvalue(o)->nuvalue) { + setnilvalue(s2v(L->top.p)); + t = LUA_TNONE; + } + else { + setobj2s(L, L->top.p, &uvalue(o)->uv[n - 1].uv); + t = ttype(s2v(L->top.p)); + } api_incr_top(L); lua_unlock(L); - return ttnov(L->top - 1); + return t; } @@ -744,101 +830,102 @@ static void auxsetstr (lua_State *L, const TValue *t, const char *k) { const TValue *slot; TString *str = luaS_new(L, k); api_checknelems(L, 1); - if (luaV_fastset(L, t, str, slot, luaH_getstr, L->top - 1)) - L->top--; /* pop value */ + if (luaV_fastget(L, t, str, slot, luaH_getstr)) { + luaV_finishfastset(L, t, slot, s2v(L->top.p - 1)); + L->top.p--; /* pop value */ + } else { - setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */ + setsvalue2s(L, L->top.p, str); /* push 'str' (to make it a TValue) */ api_incr_top(L); - luaV_finishset(L, t, L->top - 1, L->top - 2, slot); - L->top -= 2; /* pop value and key */ + luaV_finishset(L, t, s2v(L->top.p - 1), s2v(L->top.p - 2), slot); + L->top.p -= 2; /* pop value and key */ } lua_unlock(L); /* lock done by caller */ } LUA_API void lua_setglobal (lua_State *L, const char *name) { - Table *reg = hvalue(&G(L)->l_registry); + const TValue *G; lua_lock(L); /* unlock done in 'auxsetstr' */ - auxsetstr(L, luaH_getint(reg, LUA_RIDX_GLOBALS), name); + G = getGtable(L); + auxsetstr(L, G, name); } LUA_API void lua_settable (lua_State *L, int idx) { - StkId t; + TValue *t; + const TValue *slot; lua_lock(L); api_checknelems(L, 2); - t = index2addr(L, idx); - luaV_settable(L, t, L->top - 2, L->top - 1); - L->top -= 2; /* pop index and value */ + t = index2value(L, idx); + if (luaV_fastget(L, t, s2v(L->top.p - 2), slot, luaH_get)) { + luaV_finishfastset(L, t, slot, s2v(L->top.p - 1)); + } + else + luaV_finishset(L, t, s2v(L->top.p - 2), s2v(L->top.p - 1), slot); + L->top.p -= 2; /* pop index and value */ lua_unlock(L); } LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { lua_lock(L); /* unlock done in 'auxsetstr' */ - auxsetstr(L, index2addr(L, idx), k); + auxsetstr(L, index2value(L, idx), k); } LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) { - StkId t; + TValue *t; const TValue *slot; lua_lock(L); api_checknelems(L, 1); - t = index2addr(L, idx); - if (luaV_fastset(L, t, n, slot, luaH_getint, L->top - 1)) - L->top--; /* pop value */ + t = index2value(L, idx); + if (luaV_fastgeti(L, t, n, slot)) { + luaV_finishfastset(L, t, slot, s2v(L->top.p - 1)); + } else { - setivalue(L->top, n); - api_incr_top(L); - luaV_finishset(L, t, L->top - 1, L->top - 2, slot); - L->top -= 2; /* pop value and key */ + TValue aux; + setivalue(&aux, n); + luaV_finishset(L, t, &aux, s2v(L->top.p - 1), slot); } + L->top.p--; /* pop value */ lua_unlock(L); } -LUA_API void lua_rawset (lua_State *L, int idx) { - StkId o; - TValue *slot; +static void aux_rawset (lua_State *L, int idx, TValue *key, int n) { + Table *t; lua_lock(L); - api_checknelems(L, 2); - o = index2addr(L, idx); - api_check(L, ttistable(o), "table expected"); - slot = luaH_set(L, hvalue(o), L->top - 2); - setobj2t(L, slot, L->top - 1); - invalidateTMcache(hvalue(o)); - luaC_barrierback(L, hvalue(o), L->top-1); - L->top -= 2; + api_checknelems(L, n); + t = gettable(L, idx); + luaH_set(L, t, key, s2v(L->top.p - 1)); + invalidateTMcache(t); + luaC_barrierback(L, obj2gco(t), s2v(L->top.p - 1)); + L->top.p -= n; lua_unlock(L); } -LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { - StkId o; - lua_lock(L); - api_checknelems(L, 1); - o = index2addr(L, idx); - api_check(L, ttistable(o), "table expected"); - luaH_setint(L, hvalue(o), n, L->top - 1); - luaC_barrierback(L, hvalue(o), L->top-1); - L->top--; - lua_unlock(L); +LUA_API void lua_rawset (lua_State *L, int idx) { + aux_rawset(L, idx, s2v(L->top.p - 2), 2); } LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { - StkId o; - TValue k, *slot; + TValue k; + setpvalue(&k, cast_voidp(p)); + aux_rawset(L, idx, &k, 1); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { + Table *t; lua_lock(L); api_checknelems(L, 1); - o = index2addr(L, idx); - api_check(L, ttistable(o), "table expected"); - setpvalue(&k, cast(void *, p)); - slot = luaH_set(L, hvalue(o), &k); - setobj2t(L, slot, L->top - 1); - luaC_barrierback(L, hvalue(o), L->top - 1); - L->top--; + t = gettable(L, idx); + luaH_setint(L, t, n, s2v(L->top.p - 1)); + luaC_barrierback(L, obj2gco(t), s2v(L->top.p - 1)); + L->top.p--; lua_unlock(L); } @@ -848,14 +935,14 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { Table *mt; lua_lock(L); api_checknelems(L, 1); - obj = index2addr(L, objindex); - if (ttisnil(L->top - 1)) + obj = index2value(L, objindex); + if (ttisnil(s2v(L->top.p - 1))) mt = NULL; else { - api_check(L, ttistable(L->top - 1), "table expected"); - mt = hvalue(L->top - 1); + api_check(L, ttistable(s2v(L->top.p - 1)), "table expected"); + mt = hvalue(s2v(L->top.p - 1)); } - switch (ttnov(obj)) { + switch (ttype(obj)) { case LUA_TTABLE: { hvalue(obj)->metatable = mt; if (mt) { @@ -873,26 +960,33 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { break; } default: { - G(L)->mt[ttnov(obj)] = mt; + G(L)->mt[ttype(obj)] = mt; break; } } - L->top--; + L->top.p--; lua_unlock(L); return 1; } -LUA_API void lua_setuservalue (lua_State *L, int idx) { - StkId o; +LUA_API int lua_setiuservalue (lua_State *L, int idx, int n) { + TValue *o; + int res; lua_lock(L); api_checknelems(L, 1); - o = index2addr(L, idx); + o = index2value(L, idx); api_check(L, ttisfulluserdata(o), "full userdata expected"); - setuservalue(L, uvalue(o), L->top - 1); - luaC_barrier(L, gcvalue(o), L->top - 1); - L->top--; + if (!(cast_uint(n) - 1u < cast_uint(uvalue(o)->nuvalue))) + res = 0; /* 'n' not in [1, uvalue(o)->nuvalue] */ + else { + setobj(L, &uvalue(o)->uv[n - 1].uv, s2v(L->top.p - 1)); + luaC_barrierback(L, gcvalue(o), s2v(L->top.p - 1)); + res = 1; + } + L->top.p--; lua_unlock(L); + return res; } @@ -902,7 +996,8 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) { #define checkresults(L,na,nr) \ - api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ + api_check(L, (nr) == LUA_MULTRET \ + || (L->ci->top.p - L->top.p >= (nr) - (na)), \ "results from function overflow current stack size") @@ -915,8 +1010,8 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults, api_checknelems(L, nargs+1); api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); checkresults(L, nargs, nresults); - func = L->top - (nargs+1); - if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ + func = L->top.p - (nargs+1); + if (k != NULL && yieldable(L)) { /* need to prepare continuation? */ L->ci->u.c.k = k; /* save continuation */ L->ci->u.c.ctx = ctx; /* save context */ luaD_call(L, func, nresults); /* do the call */ @@ -959,12 +1054,12 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, if (errfunc == 0) func = 0; else { - StkId o = index2addr(L, errfunc); - api_checkstackindex(L, errfunc, o); + StkId o = index2stack(L, errfunc); + api_check(L, ttisfunction(s2v(o)), "error handler must be a function"); func = savestack(L, o); } - c.func = L->top - (nargs+1); /* function to be called */ - if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */ + c.func = L->top.p - (nargs+1); /* function to be called */ + if (k == NULL || !yieldable(L)) { /* no continuation or no yieldable? */ c.nresults = nresults; /* do a 'conventional' protected call */ status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); } @@ -973,7 +1068,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, ci->u.c.k = k; /* save continuation */ ci->u.c.ctx = ctx; /* save context */ /* save information for error recovery */ - ci->extra = savestack(L, c.func); + ci->u2.funcidx = cast_int(savestack(L, c.func)); ci->u.c.old_errfunc = L->errfunc; L->errfunc = func; setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */ @@ -998,14 +1093,13 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, luaZ_init(L, &z, reader, data); status = luaD_protectedparser(L, &z, chunkname, mode); if (status == LUA_OK) { /* no errors? */ - LClosure *f = clLvalue(L->top - 1); /* get newly created function */ + LClosure *f = clLvalue(s2v(L->top.p - 1)); /* get new function */ if (f->nupvalues >= 1) { /* does it have an upvalue? */ /* get global table from registry */ - Table *reg = hvalue(&G(L)->l_registry); - const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + const TValue *gt = getGtable(L); /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ - setobj(L, f->upvals[0]->v, gt); - luaC_upvalbarrier(L, f->upvals[0]); + setobj(L, f->upvals[0]->v.p, gt); + luaC_barrier(L, f->upvals[0], gt); } } lua_unlock(L); @@ -1018,7 +1112,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) { TValue *o; lua_lock(L); api_checknelems(L, 1); - o = L->top - 1; + o = s2v(L->top.p - 1); if (isLfunction(o)) status = luaU_dump(L, getproto(o), writer, data, strip); else @@ -1036,20 +1130,22 @@ LUA_API int lua_status (lua_State *L) { /* ** Garbage-collection function */ - -LUA_API int lua_gc (lua_State *L, int what, int data) { +LUA_API int lua_gc (lua_State *L, int what, ...) { + va_list argp; int res = 0; - global_State *g; + global_State *g = G(L); + if (g->gcstp & GCSTPGC) /* internal stop? */ + return -1; /* all options are invalid when stopped */ lua_lock(L); - g = G(L); + va_start(argp, what); switch (what) { case LUA_GCSTOP: { - g->gcrunning = 0; + g->gcstp = GCSTPUSR; /* stopped by the user */ break; } case LUA_GCRESTART: { luaE_setdebt(g, 0); - g->gcrunning = 1; + g->gcstp = 0; /* (GCSTPGC must be already zero here) */ break; } case LUA_GCCOLLECT: { @@ -1066,11 +1162,12 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { break; } case LUA_GCSTEP: { + int data = va_arg(argp, int); l_mem debt = 1; /* =1 to signal that it did an actual step */ - lu_byte oldrunning = g->gcrunning; - g->gcrunning = 1; /* allow GC to run */ + lu_byte oldstp = g->gcstp; + g->gcstp = 0; /* allow GC to run (GCSTPGC must be zero here) */ if (data == 0) { - luaE_setdebt(g, -GCSTEPSIZE); /* to do a "small" step */ + luaE_setdebt(g, 0); /* do a basic step */ luaC_step(L); } else { /* add 'data' to total debt */ @@ -1078,28 +1175,55 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { luaE_setdebt(g, debt); luaC_checkGC(L); } - g->gcrunning = oldrunning; /* restore previous state */ + g->gcstp = oldstp; /* restore previous state */ if (debt > 0 && g->gcstate == GCSpause) /* end of cycle? */ res = 1; /* signal it */ break; } case LUA_GCSETPAUSE: { - res = g->gcpause; - g->gcpause = data; + int data = va_arg(argp, int); + res = getgcparam(g->gcpause); + setgcparam(g->gcpause, data); break; } case LUA_GCSETSTEPMUL: { - res = g->gcstepmul; - if (data < 40) data = 40; /* avoid ridiculous low values (and 0) */ - g->gcstepmul = data; + int data = va_arg(argp, int); + res = getgcparam(g->gcstepmul); + setgcparam(g->gcstepmul, data); break; } case LUA_GCISRUNNING: { - res = g->gcrunning; + res = gcrunning(g); + break; + } + case LUA_GCGEN: { + int minormul = va_arg(argp, int); + int majormul = va_arg(argp, int); + res = isdecGCmodegen(g) ? LUA_GCGEN : LUA_GCINC; + if (minormul != 0) + g->genminormul = minormul; + if (majormul != 0) + setgcparam(g->genmajormul, majormul); + luaC_changemode(L, KGC_GEN); + break; + } + case LUA_GCINC: { + int pause = va_arg(argp, int); + int stepmul = va_arg(argp, int); + int stepsize = va_arg(argp, int); + res = isdecGCmodegen(g) ? LUA_GCGEN : LUA_GCINC; + if (pause != 0) + setgcparam(g->gcpause, pause); + if (stepmul != 0) + setgcparam(g->gcstepmul, stepmul); + if (stepsize != 0) + g->gcstepsize = stepsize; + luaC_changemode(L, KGC_INC); break; } default: res = -1; /* invalid option */ } + va_end(argp); lua_unlock(L); return res; } @@ -1112,52 +1236,71 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { LUA_API int lua_error (lua_State *L) { + TValue *errobj; lua_lock(L); + errobj = s2v(L->top.p - 1); api_checknelems(L, 1); - luaG_errormsg(L); + /* error object is the memory error message? */ + if (ttisshrstring(errobj) && eqshrstr(tsvalue(errobj), G(L)->memerrmsg)) + luaM_error(L); /* raise a memory error */ + else + luaG_errormsg(L); /* raise a regular error */ /* code unreachable; will unlock when control actually leaves the kernel */ return 0; /* to avoid warnings */ } LUA_API int lua_next (lua_State *L, int idx) { - StkId t; + Table *t; int more; lua_lock(L); - t = index2addr(L, idx); - api_check(L, ttistable(t), "table expected"); - more = luaH_next(L, hvalue(t), L->top - 1); + api_checknelems(L, 1); + t = gettable(L, idx); + more = luaH_next(L, t, L->top.p - 1); if (more) { api_incr_top(L); } else /* no more elements */ - L->top -= 1; /* remove key */ + L->top.p -= 1; /* remove key */ lua_unlock(L); return more; } +LUA_API void lua_toclose (lua_State *L, int idx) { + int nresults; + StkId o; + lua_lock(L); + o = index2stack(L, idx); + nresults = L->ci->nresults; + api_check(L, L->tbclist.p < o, "given index below or equal a marked one"); + luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ + if (!hastocloseCfunc(nresults)) /* function not marked yet? */ + L->ci->nresults = codeNresults(nresults); /* mark it */ + lua_assert(hastocloseCfunc(L->ci->nresults)); + lua_unlock(L); +} + + LUA_API void lua_concat (lua_State *L, int n) { lua_lock(L); api_checknelems(L, n); - if (n >= 2) { + if (n > 0) luaV_concat(L, n); - } - else if (n == 0) { /* push empty string */ - setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + else { /* nothing to concatenate */ + setsvalue2s(L, L->top.p, luaS_newlstr(L, "", 0)); /* push empty string */ api_incr_top(L); } - /* else n == 1; nothing to do */ luaC_checkGC(L); lua_unlock(L); } LUA_API void lua_len (lua_State *L, int idx) { - StkId t; + TValue *t; lua_lock(L); - t = index2addr(L, idx); - luaV_objlen(L, L->top, t); + t = index2value(L, idx); + luaV_objlen(L, L->top.p, t); api_incr_top(L); lua_unlock(L); } @@ -1181,11 +1324,28 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { } -LUA_API void *lua_newuserdata (lua_State *L, size_t size) { +void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud) { + lua_lock(L); + G(L)->ud_warn = ud; + G(L)->warnf = f; + lua_unlock(L); +} + + +void lua_warning (lua_State *L, const char *msg, int tocont) { + lua_lock(L); + luaE_warning(L, msg, tocont); + lua_unlock(L); +} + + + +LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) { Udata *u; lua_lock(L); - u = luaS_newudata(L, size); - setuvalue(L, L->top, u); + api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX, "invalid value"); + u = luaS_newudata(L, size, nuvalue); + setuvalue(L, s2v(L->top.p), u); api_incr_top(L); luaC_checkGC(L); lua_unlock(L); @@ -1194,25 +1354,27 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size) { -static const char *aux_upvalue (StkId fi, int n, TValue **val, - CClosure **owner, UpVal **uv) { - switch (ttype(fi)) { - case LUA_TCCL: { /* C closure */ +static const char *aux_upvalue (TValue *fi, int n, TValue **val, + GCObject **owner) { + switch (ttypetag(fi)) { + case LUA_VCCL: { /* C closure */ CClosure *f = clCvalue(fi); - if (!(1 <= n && n <= f->nupvalues)) return NULL; + if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues))) + return NULL; /* 'n' not in [1, f->nupvalues] */ *val = &f->upvalue[n-1]; - if (owner) *owner = f; + if (owner) *owner = obj2gco(f); return ""; } - case LUA_TLCL: { /* Lua closure */ + case LUA_VLCL: { /* Lua closure */ LClosure *f = clLvalue(fi); TString *name; Proto *p = f->p; - if (!(1 <= n && n <= p->sizeupvalues)) return NULL; - *val = f->upvals[n-1]->v; - if (uv) *uv = f->upvals[n - 1]; + if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues))) + return NULL; /* 'n' not in [1, p->sizeupvalues] */ + *val = f->upvals[n-1]->v.p; + if (owner) *owner = obj2gco(f->upvals[n - 1]); name = p->upvalues[n-1].name; - return (name == NULL) ? "(*no name)" : getstr(name); + return (name == NULL) ? "(no name)" : getstr(name); } default: return NULL; /* not a closure */ } @@ -1223,9 +1385,9 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { const char *name; TValue *val = NULL; /* to avoid warnings */ lua_lock(L); - name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL, NULL); + name = aux_upvalue(index2value(L, funcindex), n, &val, NULL); if (name) { - setobj2s(L, L->top, val); + setobj2s(L, L->top.p, val); api_incr_top(L); } lua_unlock(L); @@ -1236,18 +1398,16 @@ LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { const char *name; TValue *val = NULL; /* to avoid warnings */ - CClosure *owner = NULL; - UpVal *uv = NULL; - StkId fi; + GCObject *owner = NULL; /* to avoid warnings */ + TValue *fi; lua_lock(L); - fi = index2addr(L, funcindex); + fi = index2value(L, funcindex); api_checknelems(L, 1); - name = aux_upvalue(fi, n, &val, &owner, &uv); + name = aux_upvalue(fi, n, &val, &owner); if (name) { - L->top--; - setobj(L, val, L->top); - if (owner) { luaC_barrier(L, owner, L->top); } - else if (uv) { luaC_upvalbarrier(L, uv); } + L->top.p--; + setobj(L, val, s2v(L->top.p)); + luaC_barrier(L, owner, val); } lua_unlock(L); return name; @@ -1255,29 +1415,35 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { + static const UpVal *const nullup = NULL; LClosure *f; - StkId fi = index2addr(L, fidx); + TValue *fi = index2value(L, fidx); api_check(L, ttisLclosure(fi), "Lua function expected"); f = clLvalue(fi); - api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); if (pf) *pf = f; - return &f->upvals[n - 1]; /* get its upvalue pointer */ + if (1 <= n && n <= f->p->sizeupvalues) + return &f->upvals[n - 1]; /* get its upvalue pointer */ + else + return (UpVal**)&nullup; } LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { - StkId fi = index2addr(L, fidx); - switch (ttype(fi)) { - case LUA_TLCL: { /* lua closure */ + TValue *fi = index2value(L, fidx); + switch (ttypetag(fi)) { + case LUA_VLCL: { /* lua closure */ return *getupvalref(L, fidx, n, NULL); } - case LUA_TCCL: { /* C closure */ + case LUA_VCCL: { /* C closure */ CClosure *f = clCvalue(fi); - api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index"); - return &f->upvalue[n - 1]; - } + if (1 <= n && n <= f->nupvalues) + return &f->upvalue[n - 1]; + /* else */ + } /* FALLTHROUGH */ + case LUA_VLCF: + return NULL; /* light C functions have no upvalues */ default: { - api_check(L, 0, "closure expected"); + api_check(L, 0, "function expected"); return NULL; } } @@ -1289,11 +1455,9 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, LClosure *f1; UpVal **up1 = getupvalref(L, fidx1, n1, &f1); UpVal **up2 = getupvalref(L, fidx2, n2, NULL); - luaC_upvdeccount(L, *up1); + api_check(L, *up1 != NULL && *up2 != NULL, "invalid upvalue index"); *up1 = *up2; - (*up1)->refcount++; - if (upisopen(*up1)) (*up1)->u.open.touched = 1; - luaC_upvalbarrier(L, *up1); + luaC_objbarrier(L, f1, *up1); } diff --git a/liblua/lapi.h b/liblua/lapi.h index 8e16ad53..a742427c 100644 --- a/liblua/lapi.h +++ b/liblua/lapi.h @@ -1,5 +1,5 @@ /* -** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lapi.h $ ** Auxiliary functions from Lua API ** See Copyright Notice in lua.h */ @@ -11,14 +11,42 @@ #include "llimits.h" #include "lstate.h" -#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ - "stack overflow");} +/* Increments 'L->top.p', checking for stack overflows */ +#define api_incr_top(L) {L->top.p++; \ + api_check(L, L->top.p <= L->ci->top.p, \ + "stack overflow");} + + +/* +** If a call returns too many multiple returns, the callee may not have +** stack space to accommodate all results. In this case, this macro +** increases its stack space ('L->ci->top.p'). +*/ #define adjustresults(L,nres) \ - { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + { if ((nres) <= LUA_MULTRET && L->ci->top.p < L->top.p) \ + L->ci->top.p = L->top.p; } + + +/* Ensure the stack has at least 'n' elements */ +#define api_checknelems(L,n) \ + api_check(L, (n) < (L->top.p - L->ci->func.p), \ + "not enough elements in the stack") + + +/* +** To reduce the overhead of returning from C functions, the presence of +** to-be-closed variables in these functions is coded in the CallInfo's +** field 'nresults', in a way that functions with no to-be-closed variables +** with zero, one, or "all" wanted results have no overhead. Functions +** with other number of wanted results, as well as functions with +** variables to be closed, have an extra check. +*/ -#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ - "not enough elements in the stack") +#define hastocloseCfunc(n) ((n) < LUA_MULTRET) +/* Map [-1, inf) (range of 'nresults') into (-inf, -2] */ +#define codeNresults(n) (-(n) - 3) +#define decodeNresults(n) (-(n) - 3) #endif diff --git a/liblua/lauxlib.c b/liblua/lauxlib.c index 8bdada50..923105ed 100644 --- a/liblua/lauxlib.c +++ b/liblua/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.289.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lauxlib.c $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -27,6 +27,12 @@ #include "lauxlib.h" +#if !defined(MAX_SIZET) +/* maximum value for size_t */ +#define MAX_SIZET ((size_t)(~(size_t)0)) +#endif + + /* ** {====================================================== ** Traceback @@ -40,8 +46,8 @@ /* -** search for 'objidx' in table at index -1. -** return 1 + string at top if find a good name. +** Search for 'objidx' in table at index -1. ('objidx' must be an +** absolute index.) Return 1 + string at top if it found a good name. */ static int findfield (lua_State *L, int objidx, int level) { if (level == 0 || !lua_istable(L, -1)) @@ -54,10 +60,10 @@ static int findfield (lua_State *L, int objidx, int level) { return 1; } else if (findfield(L, objidx, level - 1)) { /* try recursively */ - lua_remove(L, -2); /* remove table (but keep name) */ - lua_pushliteral(L, "."); - lua_insert(L, -2); /* place '.' between the two names */ - lua_concat(L, 3); + /* stack: lib_name, lib_table, field_name (top) */ + lua_pushliteral(L, "."); /* place '.' between the two names */ + lua_replace(L, -3); /* (in the slot occupied by table) */ + lua_concat(L, 3); /* lib_name.field_name */ return 1; } } @@ -74,14 +80,15 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { int top = lua_gettop(L); lua_getinfo(L, "f", ar); /* push function */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + luaL_checkstack(L, 6, "not enough stack"); /* slots for 'findfield' */ if (findfield(L, top + 1, 2)) { const char *name = lua_tostring(L, -1); - if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */ + if (strncmp(name, LUA_GNAME ".", 3) == 0) { /* name start with '_G.'? */ lua_pushstring(L, name + 3); /* push name without prefix */ lua_remove(L, -2); /* remove original name */ } - lua_copy(L, -1, top + 1); /* move name to proper place */ - lua_pop(L, 2); /* remove pushed values */ + lua_copy(L, -1, top + 1); /* copy name to proper place */ + lua_settop(L, top + 1); /* remove table "loaded" and name copy */ return 1; } else { @@ -124,32 +131,37 @@ static int lastlevel (lua_State *L) { LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level) { + luaL_Buffer b; lua_Debug ar; - int top = lua_gettop(L); int last = lastlevel(L1); - int n1 = (last - level > LEVELS1 + LEVELS2) ? LEVELS1 : -1; - if (msg) - lua_pushfstring(L, "%s\n", msg); - luaL_checkstack(L, 10, NULL); - lua_pushliteral(L, "stack traceback:"); + int limit2show = (last - level > LEVELS1 + LEVELS2) ? LEVELS1 : -1; + luaL_buffinit(L, &b); + if (msg) { + luaL_addstring(&b, msg); + luaL_addchar(&b, '\n'); + } + luaL_addstring(&b, "stack traceback:"); while (lua_getstack(L1, level++, &ar)) { - if (n1-- == 0) { /* too many levels? */ - lua_pushliteral(L, "\n\t..."); /* add a '...' */ - level = last - LEVELS2 + 1; /* and skip to last ones */ + if (limit2show-- == 0) { /* too many levels? */ + int n = last - level - LEVELS2 + 1; /* number of levels to skip */ + lua_pushfstring(L, "\n\t...\t(skipping %d levels)", n); + luaL_addvalue(&b); /* add warning about skip */ + level += n; /* and skip to last levels */ } else { lua_getinfo(L1, "Slnt", &ar); - lua_pushfstring(L, "\n\t%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); - lua_pushliteral(L, " in "); + if (ar.currentline <= 0) + lua_pushfstring(L, "\n\t%s: in ", ar.short_src); + else + lua_pushfstring(L, "\n\t%s:%d: in ", ar.short_src, ar.currentline); + luaL_addvalue(&b); pushfuncname(L, &ar); + luaL_addvalue(&b); if (ar.istailcall) - lua_pushliteral(L, "\n\t(...tail calls...)"); - lua_concat(L, lua_gettop(L) - top); + luaL_addstring(&b, "\n\t(...tail calls...)"); } } - lua_concat(L, lua_gettop(L) - top); + luaL_pushresult(&b); } /* }====================================================== */ @@ -179,7 +191,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) { } -static int typeerror (lua_State *L, int arg, const char *tname) { +LUALIB_API int luaL_typeerror (lua_State *L, int arg, const char *tname) { const char *msg; const char *typearg; /* name for the type of the actual argument */ if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) @@ -194,7 +206,7 @@ static int typeerror (lua_State *L, int arg, const char *tname) { static void tag_error (lua_State *L, int arg, int tag) { - typeerror(L, arg, lua_typename(L, tag)); + luaL_typeerror(L, arg, lua_typename(L, tag)); } @@ -238,11 +250,13 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { return 1; } else { - lua_pushnil(L); + const char *msg; + luaL_pushfail(L); + msg = (en != 0) ? strerror(en) : "(no extra info)"; if (fname) - lua_pushfstring(L, "%s: %s", fname, strerror(en)); + lua_pushfstring(L, "%s: %s", fname, msg); else - lua_pushstring(L, strerror(en)); + lua_pushstring(L, msg); lua_pushinteger(L, en); return 3; } @@ -272,24 +286,25 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { LUALIB_API int luaL_execresult (lua_State *L, int stat) { - const char *what = "exit"; /* type of termination */ - if (stat == -1) /* error? */ + if (stat != 0 && errno != 0) /* error with an 'errno'? */ return luaL_fileresult(L, 0, NULL); else { + const char *what = "exit"; /* type of termination */ l_inspectstat(stat, what); /* interpret result */ if (*what == 'e' && stat == 0) /* successful termination? */ lua_pushboolean(L, 1); else - lua_pushnil(L); + luaL_pushfail(L); lua_pushstring(L, what); lua_pushinteger(L, stat); - return 3; /* return true/nil,what,code */ + return 3; /* return true/fail,what,code */ } } /* }====================================================== */ + /* ** {====================================================== ** Userdata's metatable manipulation @@ -332,7 +347,7 @@ LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { void *p = luaL_testudata(L, ud, tname); - if (p == NULL) typeerror(L, ud, tname); + luaL_argexpected(L, p != NULL, ud, tname); return p; } @@ -366,7 +381,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def, ** but without 'msg'.) */ LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { - if (!lua_checkstack(L, space)) { + if (l_unlikely(!lua_checkstack(L, space))) { if (msg) luaL_error(L, "stack overflow (%s)", msg); else @@ -376,20 +391,20 @@ LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { LUALIB_API void luaL_checktype (lua_State *L, int arg, int t) { - if (lua_type(L, arg) != t) + if (l_unlikely(lua_type(L, arg) != t)) tag_error(L, arg, t); } LUALIB_API void luaL_checkany (lua_State *L, int arg) { - if (lua_type(L, arg) == LUA_TNONE) + if (l_unlikely(lua_type(L, arg) == LUA_TNONE)) luaL_argerror(L, arg, "value expected"); } LUALIB_API const char *luaL_checklstring (lua_State *L, int arg, size_t *len) { const char *s = lua_tolstring(L, arg, len); - if (!s) tag_error(L, arg, LUA_TSTRING); + if (l_unlikely(!s)) tag_error(L, arg, LUA_TSTRING); return s; } @@ -408,7 +423,7 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int arg, LUALIB_API lua_Number luaL_checknumber (lua_State *L, int arg) { int isnum; lua_Number d = lua_tonumberx(L, arg, &isnum); - if (!isnum) + if (l_unlikely(!isnum)) tag_error(L, arg, LUA_TNUMBER); return d; } @@ -430,7 +445,7 @@ static void interror (lua_State *L, int arg) { LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) { int isnum; lua_Integer d = lua_tointegerx(L, arg, &isnum); - if (!isnum) { + if (l_unlikely(!isnum)) { interror(L, arg); } return d; @@ -463,9 +478,9 @@ static void *resizebox (lua_State *L, int idx, size_t newsize) { lua_Alloc allocf = lua_getallocf(L, &ud); UBox *box = (UBox *)lua_touserdata(L, idx); void *temp = allocf(ud, box->box, box->bsize, newsize); - if (temp == NULL && newsize > 0) { /* allocation error? */ - resizebox(L, idx, 0); /* free buffer */ - luaL_error(L, "not enough memory for buffer allocation"); + if (l_unlikely(temp == NULL && newsize > 0)) { /* allocation error? */ + lua_pushliteral(L, "not enough memory"); + lua_error(L); /* raise a memory error */ } box->box = temp; box->bsize = newsize; @@ -479,16 +494,20 @@ static int boxgc (lua_State *L) { } -static void *newbox (lua_State *L, size_t newsize) { - UBox *box = (UBox *)lua_newuserdata(L, sizeof(UBox)); +static const luaL_Reg boxmt[] = { /* box metamethods */ + {"__gc", boxgc}, + {"__close", boxgc}, + {NULL, NULL} +}; + + +static void newbox (lua_State *L) { + UBox *box = (UBox *)lua_newuserdatauv(L, sizeof(UBox), 0); box->box = NULL; box->bsize = 0; - if (luaL_newmetatable(L, "LUABOX")) { /* creating metatable? */ - lua_pushcfunction(L, boxgc); - lua_setfield(L, -2, "__gc"); /* metatable.__gc = boxgc */ - } + if (luaL_newmetatable(L, "_UBOX*")) /* creating metatable? */ + luaL_setfuncs(L, boxmt, 0); /* set its metamethods */ lua_setmetatable(L, -2); - return resizebox(L, -1, newsize); } @@ -496,38 +515,74 @@ static void *newbox (lua_State *L, size_t newsize) { ** check whether buffer is using a userdata on the stack as a temporary ** buffer */ -#define buffonstack(B) ((B)->b != (B)->initb) +#define buffonstack(B) ((B)->b != (B)->init.b) /* -** returns a pointer to a free area with at least 'sz' bytes +** Whenever buffer is accessed, slot 'idx' must either be a box (which +** cannot be NULL) or it is a placeholder for the buffer. */ -LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { - lua_State *L = B->L; - if (B->size - B->n < sz) { /* not enough space? */ +#define checkbufferlevel(B,idx) \ + lua_assert(buffonstack(B) ? lua_touserdata(B->L, idx) != NULL \ + : lua_touserdata(B->L, idx) == (void*)B) + + +/* +** Compute new size for buffer 'B', enough to accommodate extra 'sz' +** bytes. (The test for "not big enough" also gets the case when the +** computation of 'newsize' overflows.) +*/ +static size_t newbuffsize (luaL_Buffer *B, size_t sz) { + size_t newsize = (B->size / 2) * 3; /* buffer size * 1.5 */ + if (l_unlikely(MAX_SIZET - sz < B->n)) /* overflow in (B->n + sz)? */ + return luaL_error(B->L, "buffer too large"); + if (newsize < B->n + sz) /* not big enough? */ + newsize = B->n + sz; + return newsize; +} + + +/* +** Returns a pointer to a free area with at least 'sz' bytes in buffer +** 'B'. 'boxidx' is the relative position in the stack where is the +** buffer's box or its placeholder. +*/ +static char *prepbuffsize (luaL_Buffer *B, size_t sz, int boxidx) { + checkbufferlevel(B, boxidx); + if (B->size - B->n >= sz) /* enough space? */ + return B->b + B->n; + else { + lua_State *L = B->L; char *newbuff; - size_t newsize = B->size * 2; /* double buffer size */ - if (newsize - B->n < sz) /* not big enough? */ - newsize = B->n + sz; - if (newsize < B->n || newsize - B->n < sz) - luaL_error(L, "buffer too large"); + size_t newsize = newbuffsize(B, sz); /* create larger buffer */ - if (buffonstack(B)) - newbuff = (char *)resizebox(L, -1, newsize); - else { /* no buffer yet */ - newbuff = (char *)newbox(L, newsize); + if (buffonstack(B)) /* buffer already has a box? */ + newbuff = (char *)resizebox(L, boxidx, newsize); /* resize it */ + else { /* no box yet */ + lua_remove(L, boxidx); /* remove placeholder */ + newbox(L); /* create a new box */ + lua_insert(L, boxidx); /* move box to its intended position */ + lua_toclose(L, boxidx); + newbuff = (char *)resizebox(L, boxidx, newsize); memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */ } B->b = newbuff; B->size = newsize; + return newbuff + B->n; } - return &B->b[B->n]; +} + +/* +** returns a pointer to a free area with at least 'sz' bytes +*/ +LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { + return prepbuffsize(B, sz, -1); } LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { if (l > 0) { /* avoid 'memcpy' when 's' can be NULL */ - char *b = luaL_prepbuffsize(B, l); + char *b = prepbuffsize(B, l, -1); memcpy(b, s, l * sizeof(char)); luaL_addsize(B, l); } @@ -541,11 +596,11 @@ LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { LUALIB_API void luaL_pushresult (luaL_Buffer *B) { lua_State *L = B->L; + checkbufferlevel(B, -1); lua_pushlstring(L, B->b, B->n); - if (buffonstack(B)) { - resizebox(L, -2, 0); /* delete old buffer */ - lua_remove(L, -2); /* remove its header from the stack */ - } + if (buffonstack(B)) + lua_closeslot(L, -2); /* close the box */ + lua_remove(L, -2); /* remove box or placeholder from the stack */ } @@ -555,28 +610,38 @@ LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) { } +/* +** 'luaL_addvalue' is the only function in the Buffer system where the +** box (if existent) is not on the top of the stack. So, instead of +** calling 'luaL_addlstring', it replicates the code using -2 as the +** last argument to 'prepbuffsize', signaling that the box is (or will +** be) below the string being added to the buffer. (Box creation can +** trigger an emergency GC, so we should not remove the string from the +** stack before we have the space guaranteed.) +*/ LUALIB_API void luaL_addvalue (luaL_Buffer *B) { lua_State *L = B->L; - size_t l; - const char *s = lua_tolstring(L, -1, &l); - if (buffonstack(B)) - lua_insert(L, -2); /* put value below buffer */ - luaL_addlstring(B, s, l); - lua_remove(L, (buffonstack(B)) ? -2 : -1); /* remove value */ + size_t len; + const char *s = lua_tolstring(L, -1, &len); + char *b = prepbuffsize(B, len, -2); + memcpy(b, s, len * sizeof(char)); + luaL_addsize(B, len); + lua_pop(L, 1); /* pop string */ } LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { B->L = L; - B->b = B->initb; + B->b = B->init.b; B->n = 0; B->size = LUAL_BUFFERSIZE; + lua_pushlightuserdata(L, (void*)B); /* push placeholder */ } LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { luaL_buffinit(L, B); - return luaL_prepbuffsize(B, sz); + return prepbuffsize(B, sz, -1); } /* }====================================================== */ @@ -588,10 +653,14 @@ LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { ** ======================================================= */ -/* index of free-list header */ -#define freelist 0 - +/* index of free-list header (after the predefined values) */ +#define freelist (LUA_RIDX_LAST + 1) +/* +** The previously freed references form a linked list: +** t[freelist] is the index of a first free index, or zero if list is +** empty; t[t[freelist]] is the index of the second element; etc. +*/ LUALIB_API int luaL_ref (lua_State *L, int t) { int ref; if (lua_isnil(L, -1)) { @@ -599,9 +668,16 @@ LUALIB_API int luaL_ref (lua_State *L, int t) { return LUA_REFNIL; /* 'nil' has a unique fixed reference */ } t = lua_absindex(L, t); - lua_rawgeti(L, t, freelist); /* get first free element */ - ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ - lua_pop(L, 1); /* remove it from stack */ + if (lua_rawgeti(L, t, freelist) == LUA_TNIL) { /* first access? */ + ref = 0; /* list is empty */ + lua_pushinteger(L, 0); /* initialize as an empty list */ + lua_rawseti(L, t, freelist); /* ref = t[freelist] = 0 */ + } + else { /* already initialized */ + lua_assert(lua_isinteger(L, -1)); + ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ + } + lua_pop(L, 1); /* remove element from stack */ if (ref != 0) { /* any free element? */ lua_rawgeti(L, t, ref); /* remove it from list */ lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */ @@ -617,6 +693,7 @@ LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { if (ref >= 0) { t = lua_absindex(L, t); lua_rawgeti(L, t, freelist); + lua_assert(lua_isinteger(L, -1)); lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ lua_pushinteger(L, ref); lua_rawseti(L, t, freelist); /* t[freelist] = ref */ @@ -658,25 +735,29 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { static int errfile (lua_State *L, const char *what, int fnameindex) { - const char *serr = strerror(errno); + int err = errno; const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + if (err != 0) + lua_pushfstring(L, "cannot %s %s: %s", what, filename, strerror(err)); + else + lua_pushfstring(L, "cannot %s %s", what, filename); lua_remove(L, fnameindex); return LUA_ERRFILE; } -static int skipBOM (LoadF *lf) { - const char *p = "\xEF\xBB\xBF"; /* UTF-8 BOM mark */ - int c; - lf->n = 0; - do { - c = getc(lf->f); - if (c == EOF || c != *(const unsigned char *)p++) return c; - lf->buff[lf->n++] = c; /* to be read by the parser */ - } while (*p != '\0'); - lf->n = 0; /* prefix matched; discard it */ - return getc(lf->f); /* return next character */ +/* +** Skip an optional BOM at the start of a stream. If there is an +** incomplete BOM (the first character is correct but the rest is +** not), returns the first character anyway to force an error +** (as no chunk can start with 0xEF). +*/ +static int skipBOM (FILE *f) { + int c = getc(f); /* read first character */ + if (c == 0xEF && getc(f) == 0xBB && getc(f) == 0xBF) /* correct BOM? */ + return getc(f); /* ignore BOM and return next char */ + else /* no (valid) BOM */ + return c; /* return first character */ } @@ -687,13 +768,13 @@ static int skipBOM (LoadF *lf) { ** first "valid" character of the file (after the optional BOM and ** a first-line comment). */ -static int skipcomment (LoadF *lf, int *cp) { - int c = *cp = skipBOM(lf); +static int skipcomment (FILE *f, int *cp) { + int c = *cp = skipBOM(f); if (c == '#') { /* first line is a comment (Unix exec. file)? */ do { /* skip first line */ - c = getc(lf->f); + c = getc(f); } while (c != EOF && c != '\n'); - *cp = getc(lf->f); /* skip end-of-line, if present */ + *cp = getc(f); /* next character after comment, if present */ return 1; /* there was a comment */ } else return 0; /* no comment */ @@ -712,18 +793,25 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, } else { lua_pushfstring(L, "@%s", filename); + errno = 0; lf.f = fopen(filename, "r"); if (lf.f == NULL) return errfile(L, "open", fnameindex); } - if (skipcomment(&lf, &c)) /* read initial portion */ - lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ - if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ - lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ - if (lf.f == NULL) return errfile(L, "reopen", fnameindex); - skipcomment(&lf, &c); /* re-read initial portion */ + lf.n = 0; + if (skipcomment(lf.f, &c)) /* read initial portion */ + lf.buff[lf.n++] = '\n'; /* add newline to correct line numbers */ + if (c == LUA_SIGNATURE[0]) { /* binary file? */ + lf.n = 0; /* remove possible newline */ + if (filename) { /* "real" file? */ + errno = 0; + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + skipcomment(lf.f, &c); /* re-read initial portion */ + } } if (c != EOF) lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ + errno = 0; status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); readstatus = ferror(lf.f); if (filename) fclose(lf.f); /* close file (even in case of errors) */ @@ -800,7 +888,7 @@ LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) { int isnum; lua_len(L, idx); l = lua_tointegerx(L, -1, &isnum); - if (!isnum) + if (l_unlikely(!isnum)) luaL_error(L, "object length is not an integer"); lua_pop(L, 1); /* remove object */ return l; @@ -808,6 +896,7 @@ LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) { LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { + idx = lua_absindex(L,idx); if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */ if (!lua_isstring(L, -1)) luaL_error(L, "'__tostring' must return a string"); @@ -845,87 +934,6 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { } -/* -** {====================================================== -** Compatibility with 5.1 module functions -** ======================================================= -*/ -#if defined(LUA_COMPAT_MODULE) - -static const char *luaL_findtable (lua_State *L, int idx, - const char *fname, int szhint) { - const char *e; - if (idx) lua_pushvalue(L, idx); - do { - e = strchr(fname, '.'); - if (e == NULL) e = fname + strlen(fname); - lua_pushlstring(L, fname, e - fname); - if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */ - lua_pop(L, 1); /* remove this nil */ - lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ - lua_pushlstring(L, fname, e - fname); - lua_pushvalue(L, -2); - lua_settable(L, -4); /* set new table into field */ - } - else if (!lua_istable(L, -1)) { /* field has a non-table value? */ - lua_pop(L, 2); /* remove table and value */ - return fname; /* return problematic part of the name */ - } - lua_remove(L, -2); /* remove previous table */ - fname = e + 1; - } while (*e == '.'); - return NULL; -} - - -/* -** Count number of elements in a luaL_Reg list. -*/ -static int libsize (const luaL_Reg *l) { - int size = 0; - for (; l && l->name; l++) size++; - return size; -} - - -/* -** Find or create a module table with a given name. The function -** first looks at the LOADED table and, if that fails, try a -** global variable with that name. In any case, leaves on the stack -** the module table. -*/ -LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, - int sizehint) { - luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1); - if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - lua_pushglobaltable(L); - if (luaL_findtable(L, 0, modname, sizehint) != NULL) - luaL_error(L, "name conflict for module '%s'", modname); - lua_pushvalue(L, -1); - lua_setfield(L, -3, modname); /* LOADED[modname] = new table */ - } - lua_remove(L, -2); /* remove LOADED table */ -} - - -LUALIB_API void luaL_openlib (lua_State *L, const char *libname, - const luaL_Reg *l, int nup) { - luaL_checkversion(L); - if (libname) { - luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ - lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ - } - if (l) - luaL_setfuncs(L, l, nup); - else - lua_pop(L, nup); /* remove upvalues */ -} - -#endif -/* }====================================================== */ - /* ** set functions from list 'l' into table at top - 'nup'; each ** function gets the 'nup' elements at the top as upvalues. @@ -934,10 +942,14 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { luaL_checkstack(L, nup, "too many upvalues"); for (; l->name != NULL; l++) { /* fill the table with given functions */ - int i; - for (i = 0; i < nup; i++) /* copy upvalues to the top */ - lua_pushvalue(L, -nup); - lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ + if (l->func == NULL) /* placeholder? */ + lua_pushboolean(L, 0); + else { + int i; + for (i = 0; i < nup; i++) /* copy upvalues to the top */ + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ + } lua_setfield(L, -(nup + 2), l->name); } lua_pop(L, nup); /* remove upvalues */ @@ -988,18 +1000,24 @@ LUALIB_API void luaL_requiref (lua_State *L, const char *modname, } -LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, - const char *r) { +LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, + const char *p, const char *r) { const char *wild; size_t l = strlen(p); - luaL_Buffer b; - luaL_buffinit(L, &b); while ((wild = strstr(s, p)) != NULL) { - luaL_addlstring(&b, s, wild - s); /* push prefix */ - luaL_addstring(&b, r); /* push replacement in place of pattern */ + luaL_addlstring(b, s, wild - s); /* push prefix */ + luaL_addstring(b, r); /* push replacement in place of pattern */ s = wild + l; /* continue after 'p' */ } - luaL_addstring(&b, s); /* push last suffix */ + luaL_addstring(b, s); /* push last suffix */ +} + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, + const char *p, const char *r) { + luaL_Buffer b; + luaL_buffinit(L, &b); + luaL_addgsub(&b, s, p, r); luaL_pushresult(&b); return lua_tostring(L, -1); } @@ -1016,28 +1034,93 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { } +/* +** Standard panic funcion just prints an error message. The test +** with 'lua_type' avoids possible memory errors in 'lua_tostring'. +*/ static int panic (lua_State *L) { + const char *msg = (lua_type(L, -1) == LUA_TSTRING) + ? lua_tostring(L, -1) + : "error object is not a string"; lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", - lua_tostring(L, -1)); + msg); return 0; /* return to Lua to abort */ } +/* +** Warning functions: +** warnfoff: warning system is off +** warnfon: ready to start a new message +** warnfcont: previous message is to be continued +*/ +static void warnfoff (void *ud, const char *message, int tocont); +static void warnfon (void *ud, const char *message, int tocont); +static void warnfcont (void *ud, const char *message, int tocont); + + +/* +** Check whether message is a control message. If so, execute the +** control or ignore it if unknown. +*/ +static int checkcontrol (lua_State *L, const char *message, int tocont) { + if (tocont || *(message++) != '@') /* not a control message? */ + return 0; + else { + if (strcmp(message, "off") == 0) + lua_setwarnf(L, warnfoff, L); /* turn warnings off */ + else if (strcmp(message, "on") == 0) + lua_setwarnf(L, warnfon, L); /* turn warnings on */ + return 1; /* it was a control message */ + } +} + + +static void warnfoff (void *ud, const char *message, int tocont) { + checkcontrol((lua_State *)ud, message, tocont); +} + + +/* +** Writes the message and handle 'tocont', finishing the message +** if needed and setting the next warn function. +*/ +static void warnfcont (void *ud, const char *message, int tocont) { + lua_State *L = (lua_State *)ud; + lua_writestringerror("%s", message); /* write message */ + if (tocont) /* not the last part? */ + lua_setwarnf(L, warnfcont, L); /* to be continued */ + else { /* last part */ + lua_writestringerror("%s", "\n"); /* finish message with end-of-line */ + lua_setwarnf(L, warnfon, L); /* next call is a new message */ + } +} + + +static void warnfon (void *ud, const char *message, int tocont) { + if (checkcontrol((lua_State *)ud, message, tocont)) /* control message? */ + return; /* nothing else to be done */ + lua_writestringerror("%s", "Lua warning: "); /* start a new warning */ + warnfcont(ud, message, tocont); /* finish processing */ +} + + LUALIB_API lua_State *luaL_newstate (void) { lua_State *L = lua_newstate(l_alloc, NULL); - if (L) lua_atpanic(L, &panic); + if (l_likely(L)) { + lua_atpanic(L, &panic); + lua_setwarnf(L, warnfoff, L); /* default is warnings off */ + } return L; } LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) { - const lua_Number *v = lua_version(L); + lua_Number v = lua_version(L); if (sz != LUAL_NUMSIZES) /* check numeric types */ luaL_error(L, "core and library have incompatible numeric types"); - if (v != lua_version(NULL)) - luaL_error(L, "multiple Lua VMs detected"); - else if (*v != ver) + else if (v != ver) luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", - (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v); + (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)v); } diff --git a/liblua/lauxlib.h b/liblua/lauxlib.h index 6151dabb..5b977e2a 100644 --- a/liblua/lauxlib.h +++ b/liblua/lauxlib.h @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lauxlib.h $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -12,9 +12,16 @@ #include #include +#include "luaconf.h" #include "lua.h" +/* global table */ +#define LUA_GNAME "_G" + + +typedef struct luaL_Buffer luaL_Buffer; + /* extra error code for 'luaL_loadfilex' */ #define LUA_ERRFILE (LUA_ERRERR+1) @@ -44,6 +51,7 @@ LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); +LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname); LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, size_t *l); LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, @@ -73,6 +81,7 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + /* predefined references */ #define LUA_NOREF (-2) #define LUA_REFNIL (-1) @@ -93,8 +102,10 @@ LUALIB_API lua_State *(luaL_newstate) (void); LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); -LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, - const char *r); +LUALIB_API void (luaL_addgsub) (luaL_Buffer *b, const char *s, + const char *p, const char *r); +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, + const char *p, const char *r); LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); @@ -120,7 +131,11 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) #define luaL_argcheck(L, cond,arg,extramsg) \ - ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) + ((void)(luai_likely(cond) || luaL_argerror(L, (arg), (extramsg)))) + +#define luaL_argexpected(L,cond,arg,tname) \ + ((void)(luai_likely(cond) || luaL_typeerror(L, (arg), (tname)))) + #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) @@ -139,19 +154,54 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) +/* +** Perform arithmetic operations on lua_Integer values with wrap-around +** semantics, as the Lua core does. +*/ +#define luaL_intop(op,v1,v2) \ + ((lua_Integer)((lua_Unsigned)(v1) op (lua_Unsigned)(v2))) + + +/* push the value used to represent failure/error */ +#define luaL_pushfail(L) lua_pushnil(L) + + +/* +** Internal assertions for in-house debugging +*/ +#if !defined(lua_assert) + +#if defined LUAI_ASSERT + #include + #define lua_assert(c) assert(c) +#else + #define lua_assert(c) ((void)0) +#endif + +#endif + + + /* ** {====================================================== ** Generic Buffer manipulation ** ======================================================= */ -typedef struct luaL_Buffer { +struct luaL_Buffer { char *b; /* buffer address */ size_t size; /* buffer size */ size_t n; /* number of characters in buffer */ lua_State *L; - char initb[LUAL_BUFFERSIZE]; /* initial buffer */ -} luaL_Buffer; + union { + LUAI_MAXALIGN; /* ensure maximum alignment for buffer */ + char b[LUAL_BUFFERSIZE]; /* initial buffer */ + } init; +}; + + +#define luaL_bufflen(bf) ((bf)->n) +#define luaL_buffaddr(bf) ((bf)->b) #define luaL_addchar(B,c) \ @@ -160,6 +210,8 @@ typedef struct luaL_Buffer { #define luaL_addsize(B,s) ((B)->n += (s)) +#define luaL_buffsub(B,s) ((B)->n -= (s)) + LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); @@ -197,21 +249,6 @@ typedef struct luaL_Stream { /* }====================================================== */ - - -/* compatibility with old module system */ -#if defined(LUA_COMPAT_MODULE) - -LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, - int sizehint); -LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, - const luaL_Reg *l, int nup); - -#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) - -#endif - - /* ** {================================================================== ** "Abstraction Layer" for basic report of messages and errors @@ -220,12 +257,8 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, /* print a string */ #if !defined(lua_writestring) -#ifdef U8W_H -#define lua_writestring(s,l) fprintf(stdout, "%s", s) -#else #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) #endif -#endif /* print a newline and flush the output */ #if !defined(lua_writeline) diff --git a/liblua/lbaselib.c b/liblua/lbaselib.c index 6460e4f8..1d60c9de 100644 --- a/liblua/lbaselib.c +++ b/liblua/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.314.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lbaselib.c $ ** Basic library ** See Copyright Notice in lua.h */ @@ -24,18 +24,12 @@ static int luaB_print (lua_State *L) { int n = lua_gettop(L); /* number of arguments */ int i; - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; + for (i = 1; i <= n; i++) { /* for each argument */ size_t l; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tolstring(L, -1, &l); /* get result */ - if (s == NULL) - return luaL_error(L, "'tostring' must return a string to 'print'"); - if (i>1) lua_writestring("\t", 1); - lua_writestring(s, l); + const char *s = luaL_tolstring(L, i, &l); /* convert it to string */ + if (i > 1) /* not the first element? */ + lua_writestring("\t", 1); /* add a tab before it */ + lua_writestring(s, l); /* print it */ lua_pop(L, 1); /* pop result */ } lua_writeline(); @@ -43,13 +37,31 @@ static int luaB_print (lua_State *L) { } +/* +** Creates a warning with all given arguments. +** Check first for errors; otherwise an error may interrupt +** the composition of a warning, leaving it unfinished. +*/ +static int luaB_warn (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + luaL_checkstring(L, 1); /* at least one argument */ + for (i = 2; i <= n; i++) + luaL_checkstring(L, i); /* make sure all arguments are strings */ + for (i = 1; i < n; i++) /* compose warning */ + lua_warning(L, lua_tostring(L, i), 1); + lua_warning(L, lua_tostring(L, n), 0); /* close warning */ + return 0; +} + + #define SPACECHARS " \f\n\r\t\v" static const char *b_str2int (const char *s, int base, lua_Integer *pn) { lua_Unsigned n = 0; int neg = 0; s += strspn(s, SPACECHARS); /* skip initial spaces */ - if (*s == '-') { s++; neg = 1; } /* handle signal */ + if (*s == '-') { s++; neg = 1; } /* handle sign */ else if (*s == '+') s++; if (!isalnum((unsigned char)*s)) /* no digit? */ return NULL; @@ -68,7 +80,6 @@ static const char *b_str2int (const char *s, int base, lua_Integer *pn) { static int luaB_tonumber (lua_State *L) { if (lua_isnoneornil(L, 2)) { /* standard conversion? */ - luaL_checkany(L, 1); if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */ lua_settop(L, 1); /* yes; return it */ return 1; @@ -79,6 +90,7 @@ static int luaB_tonumber (lua_State *L) { if (s != NULL && lua_stringtonumber(L, s) == l + 1) return 1; /* successful conversion to number */ /* else not a number */ + luaL_checkany(L, 1); /* (but there must be some parameter) */ } } else { @@ -94,7 +106,7 @@ static int luaB_tonumber (lua_State *L) { return 1; } /* else not a number */ } /* else not a number */ - lua_pushnil(L); /* not a number */ + luaL_pushfail(L); /* not a number */ return 1; } @@ -125,9 +137,8 @@ static int luaB_getmetatable (lua_State *L) { static int luaB_setmetatable (lua_State *L) { int t = lua_type(L, 2); luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); - if (luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL) + luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table"); + if (l_unlikely(luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL)) return luaL_error(L, "cannot change a protected metatable"); lua_settop(L, 2); lua_setmetatable(L, 1); @@ -145,8 +156,8 @@ static int luaB_rawequal (lua_State *L) { static int luaB_rawlen (lua_State *L) { int t = lua_type(L, 1); - luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1, - "table or string expected"); + luaL_argexpected(L, t == LUA_TTABLE || t == LUA_TSTRING, 1, + "table or string"); lua_pushinteger(L, lua_rawlen(L, 1)); return 1; } @@ -170,31 +181,78 @@ static int luaB_rawset (lua_State *L) { } +static int pushmode (lua_State *L, int oldmode) { + if (oldmode == -1) + luaL_pushfail(L); /* invalid call to 'lua_gc' */ + else + lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental" + : "generational"); + return 1; +} + + +/* +** check whether call to 'lua_gc' was valid (not inside a finalizer) +*/ +#define checkvalres(res) { if (res == -1) break; } + static int luaB_collectgarbage (lua_State *L) { static const char *const opts[] = {"stop", "restart", "collect", "count", "step", "setpause", "setstepmul", - "isrunning", NULL}; + "isrunning", "generational", "incremental", NULL}; static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, - LUA_GCISRUNNING}; + LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC}; int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; - int ex = (int)luaL_optinteger(L, 2, 0); - int res = lua_gc(L, o, ex); switch (o) { case LUA_GCCOUNT: { - int b = lua_gc(L, LUA_GCCOUNTB, 0); - lua_pushnumber(L, (lua_Number)res + ((lua_Number)b/1024)); + int k = lua_gc(L, o); + int b = lua_gc(L, LUA_GCCOUNTB); + checkvalres(k); + lua_pushnumber(L, (lua_Number)k + ((lua_Number)b/1024)); return 1; } - case LUA_GCSTEP: case LUA_GCISRUNNING: { + case LUA_GCSTEP: { + int step = (int)luaL_optinteger(L, 2, 0); + int res = lua_gc(L, o, step); + checkvalres(res); lua_pushboolean(L, res); return 1; } + case LUA_GCSETPAUSE: + case LUA_GCSETSTEPMUL: { + int p = (int)luaL_optinteger(L, 2, 0); + int previous = lua_gc(L, o, p); + checkvalres(previous); + lua_pushinteger(L, previous); + return 1; + } + case LUA_GCISRUNNING: { + int res = lua_gc(L, o); + checkvalres(res); + lua_pushboolean(L, res); + return 1; + } + case LUA_GCGEN: { + int minormul = (int)luaL_optinteger(L, 2, 0); + int majormul = (int)luaL_optinteger(L, 3, 0); + return pushmode(L, lua_gc(L, o, minormul, majormul)); + } + case LUA_GCINC: { + int pause = (int)luaL_optinteger(L, 2, 0); + int stepmul = (int)luaL_optinteger(L, 3, 0); + int stepsize = (int)luaL_optinteger(L, 4, 0); + return pushmode(L, lua_gc(L, o, pause, stepmul, stepsize)); + } default: { + int res = lua_gc(L, o); + checkvalres(res); lua_pushinteger(L, res); return 1; } } + luaL_pushfail(L); /* invalid call (inside a finalizer) */ + return 1; } @@ -206,23 +264,6 @@ static int luaB_type (lua_State *L) { } -static int pairsmeta (lua_State *L, const char *method, int iszero, - lua_CFunction iter) { - luaL_checkany(L, 1); - if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ - lua_pushcfunction(L, iter); /* will return generator, */ - lua_pushvalue(L, 1); /* state, */ - if (iszero) lua_pushinteger(L, 0); /* and initial value */ - else lua_pushnil(L); - } - else { - lua_pushvalue(L, 1); /* argument 'self' to metamethod */ - lua_call(L, 1, 3); /* get 3 values from metamethod */ - } - return 3; -} - - static int luaB_next (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 2); /* create a 2nd argument if there isn't one */ @@ -235,8 +276,23 @@ static int luaB_next (lua_State *L) { } +static int pairscont (lua_State *L, int status, lua_KContext k) { + (void)L; (void)status; (void)k; /* unused */ + return 3; +} + static int luaB_pairs (lua_State *L) { - return pairsmeta(L, "__pairs", 0, luaB_next); + luaL_checkany(L, 1); + if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */ + lua_pushcfunction(L, luaB_next); /* will return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + } + else { + lua_pushvalue(L, 1); /* argument 'self' to metamethod */ + lua_callk(L, 1, 3, 0, pairscont); /* get 3 values from metamethod */ + } + return 3; } @@ -244,7 +300,8 @@ static int luaB_pairs (lua_State *L) { ** Traversal function for 'ipairs' */ static int ipairsaux (lua_State *L) { - lua_Integer i = luaL_checkinteger(L, 2) + 1; + lua_Integer i = luaL_checkinteger(L, 2); + i = luaL_intop(+, i, 1); lua_pushinteger(L, i); return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2; } @@ -255,20 +312,16 @@ static int ipairsaux (lua_State *L) { ** (The given "table" may not be a table.) */ static int luaB_ipairs (lua_State *L) { -#if defined(LUA_COMPAT_IPAIRS) - return pairsmeta(L, "__ipairs", 1, ipairsaux); -#else luaL_checkany(L, 1); lua_pushcfunction(L, ipairsaux); /* iteration function */ lua_pushvalue(L, 1); /* state */ lua_pushinteger(L, 0); /* initial value */ return 3; -#endif } static int load_aux (lua_State *L, int status, int envidx) { - if (status == LUA_OK) { + if (l_likely(status == LUA_OK)) { if (envidx != 0) { /* 'env' parameter? */ lua_pushvalue(L, envidx); /* environment for loaded function */ if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ @@ -277,9 +330,9 @@ static int load_aux (lua_State *L, int status, int envidx) { return 1; } else { /* error (message is on top of the stack) */ - lua_pushnil(L); + luaL_pushfail(L); lua_insert(L, -2); /* put before error message */ - return 2; /* return nil plus error message */ + return 2; /* return fail plus error message */ } } @@ -324,7 +377,7 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { *size = 0; return NULL; } - else if (!lua_isstring(L, -1)) + else if (l_unlikely(!lua_isstring(L, -1))) luaL_error(L, "reader function must return a string"); lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ return lua_tolstring(L, RESERVEDSLOT, size); @@ -362,7 +415,7 @@ static int dofilecont (lua_State *L, int d1, lua_KContext d2) { static int luaB_dofile (lua_State *L) { const char *fname = luaL_optstring(L, 1, NULL); lua_settop(L, 1); - if (luaL_loadfile(L, fname) != LUA_OK) + if (l_unlikely(luaL_loadfile(L, fname) != LUA_OK)) return lua_error(L); lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); return dofilecont(L, 0, 0); @@ -370,7 +423,7 @@ static int luaB_dofile (lua_State *L) { static int luaB_assert (lua_State *L) { - if (lua_toboolean(L, 1)) /* condition is true? */ + if (l_likely(lua_toboolean(L, 1))) /* condition is true? */ return lua_gettop(L); /* return all arguments */ else { /* error */ luaL_checkany(L, 1); /* there must be a condition */ @@ -406,7 +459,7 @@ static int luaB_select (lua_State *L) { ** ignored). */ static int finishpcall (lua_State *L, int status, lua_KContext extra) { - if (status != LUA_OK && status != LUA_YIELD) { /* error? */ + if (l_unlikely(status != LUA_OK && status != LUA_YIELD)) { /* error? */ lua_pushboolean(L, 0); /* first result (false) */ lua_pushvalue(L, -2); /* error message */ return 2; /* return false, msg */ @@ -459,13 +512,11 @@ static const luaL_Reg base_funcs[] = { {"ipairs", luaB_ipairs}, {"loadfile", luaB_loadfile}, {"load", luaB_load}, -#if defined(LUA_COMPAT_LOADSTRING) - {"loadstring", luaB_load}, -#endif {"next", luaB_next}, {"pairs", luaB_pairs}, {"pcall", luaB_pcall}, {"print", luaB_print}, + {"warn", luaB_warn}, {"rawequal", luaB_rawequal}, {"rawlen", luaB_rawlen}, {"rawget", luaB_rawget}, @@ -477,7 +528,7 @@ static const luaL_Reg base_funcs[] = { {"type", luaB_type}, {"xpcall", luaB_xpcall}, /* placeholders */ - {"_G", NULL}, + {LUA_GNAME, NULL}, {"_VERSION", NULL}, {NULL, NULL} }; @@ -489,7 +540,7 @@ LUAMOD_API int luaopen_base (lua_State *L) { luaL_setfuncs(L, base_funcs, 0); /* set global _G */ lua_pushvalue(L, -1); - lua_setfield(L, -2, "_G"); + lua_setfield(L, -2, LUA_GNAME); /* set global _VERSION */ lua_pushliteral(L, LUA_VERSION); lua_setfield(L, -2, "_VERSION"); diff --git a/liblua/lbitlib.c b/liblua/lbitlib.c deleted file mode 100644 index 4786c0d4..00000000 --- a/liblua/lbitlib.c +++ /dev/null @@ -1,233 +0,0 @@ -/* -** $Id: lbitlib.c,v 1.30.1.1 2017/04/19 17:20:42 roberto Exp $ -** Standard library for bitwise operations -** See Copyright Notice in lua.h -*/ - -#define lbitlib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include "lua.h" - -#include "lauxlib.h" -#include "lualib.h" - - -#if defined(LUA_COMPAT_BITLIB) /* { */ - - -#define pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) -#define checkunsigned(L,i) ((lua_Unsigned)luaL_checkinteger(L,i)) - - -/* number of bits to consider in a number */ -#if !defined(LUA_NBITS) -#define LUA_NBITS 32 -#endif - - -/* -** a lua_Unsigned with its first LUA_NBITS bits equal to 1. (Shift must -** be made in two parts to avoid problems when LUA_NBITS is equal to the -** number of bits in a lua_Unsigned.) -*/ -#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) - - -/* macro to trim extra bits */ -#define trim(x) ((x) & ALLONES) - - -/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */ -#define mask(n) (~((ALLONES << 1) << ((n) - 1))) - - - -static lua_Unsigned andaux (lua_State *L) { - int i, n = lua_gettop(L); - lua_Unsigned r = ~(lua_Unsigned)0; - for (i = 1; i <= n; i++) - r &= checkunsigned(L, i); - return trim(r); -} - - -static int b_and (lua_State *L) { - lua_Unsigned r = andaux(L); - pushunsigned(L, r); - return 1; -} - - -static int b_test (lua_State *L) { - lua_Unsigned r = andaux(L); - lua_pushboolean(L, r != 0); - return 1; -} - - -static int b_or (lua_State *L) { - int i, n = lua_gettop(L); - lua_Unsigned r = 0; - for (i = 1; i <= n; i++) - r |= checkunsigned(L, i); - pushunsigned(L, trim(r)); - return 1; -} - - -static int b_xor (lua_State *L) { - int i, n = lua_gettop(L); - lua_Unsigned r = 0; - for (i = 1; i <= n; i++) - r ^= checkunsigned(L, i); - pushunsigned(L, trim(r)); - return 1; -} - - -static int b_not (lua_State *L) { - lua_Unsigned r = ~checkunsigned(L, 1); - pushunsigned(L, trim(r)); - return 1; -} - - -static int b_shift (lua_State *L, lua_Unsigned r, lua_Integer i) { - if (i < 0) { /* shift right? */ - i = -i; - r = trim(r); - if (i >= LUA_NBITS) r = 0; - else r >>= i; - } - else { /* shift left */ - if (i >= LUA_NBITS) r = 0; - else r <<= i; - r = trim(r); - } - pushunsigned(L, r); - return 1; -} - - -static int b_lshift (lua_State *L) { - return b_shift(L, checkunsigned(L, 1), luaL_checkinteger(L, 2)); -} - - -static int b_rshift (lua_State *L) { - return b_shift(L, checkunsigned(L, 1), -luaL_checkinteger(L, 2)); -} - - -static int b_arshift (lua_State *L) { - lua_Unsigned r = checkunsigned(L, 1); - lua_Integer i = luaL_checkinteger(L, 2); - if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1)))) - return b_shift(L, r, -i); - else { /* arithmetic shift for 'negative' number */ - if (i >= LUA_NBITS) r = ALLONES; - else - r = trim((r >> i) | ~(trim(~(lua_Unsigned)0) >> i)); /* add signal bit */ - pushunsigned(L, r); - return 1; - } -} - - -static int b_rot (lua_State *L, lua_Integer d) { - lua_Unsigned r = checkunsigned(L, 1); - int i = d & (LUA_NBITS - 1); /* i = d % NBITS */ - r = trim(r); - if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */ - r = (r << i) | (r >> (LUA_NBITS - i)); - pushunsigned(L, trim(r)); - return 1; -} - - -static int b_lrot (lua_State *L) { - return b_rot(L, luaL_checkinteger(L, 2)); -} - - -static int b_rrot (lua_State *L) { - return b_rot(L, -luaL_checkinteger(L, 2)); -} - - -/* -** get field and width arguments for field-manipulation functions, -** checking whether they are valid. -** ('luaL_error' called without 'return' to avoid later warnings about -** 'width' being used uninitialized.) -*/ -static int fieldargs (lua_State *L, int farg, int *width) { - lua_Integer f = luaL_checkinteger(L, farg); - lua_Integer w = luaL_optinteger(L, farg + 1, 1); - luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); - luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); - if (f + w > LUA_NBITS) - luaL_error(L, "trying to access non-existent bits"); - *width = (int)w; - return (int)f; -} - - -static int b_extract (lua_State *L) { - int w; - lua_Unsigned r = trim(checkunsigned(L, 1)); - int f = fieldargs(L, 2, &w); - r = (r >> f) & mask(w); - pushunsigned(L, r); - return 1; -} - - -static int b_replace (lua_State *L) { - int w; - lua_Unsigned r = trim(checkunsigned(L, 1)); - lua_Unsigned v = trim(checkunsigned(L, 2)); - int f = fieldargs(L, 3, &w); - lua_Unsigned m = mask(w); - r = (r & ~(m << f)) | ((v & m) << f); - pushunsigned(L, r); - return 1; -} - - -static const luaL_Reg bitlib[] = { - {"arshift", b_arshift}, - {"band", b_and}, - {"bnot", b_not}, - {"bor", b_or}, - {"bxor", b_xor}, - {"btest", b_test}, - {"extract", b_extract}, - {"lrotate", b_lrot}, - {"lshift", b_lshift}, - {"replace", b_replace}, - {"rrotate", b_rrot}, - {"rshift", b_rshift}, - {NULL, NULL} -}; - - - -LUAMOD_API int luaopen_bit32 (lua_State *L) { - luaL_newlib(L, bitlib); - return 1; -} - - -#else /* }{ */ - - -LUAMOD_API int luaopen_bit32 (lua_State *L) { - return luaL_error(L, "library 'bit32' has been deprecated"); -} - -#endif /* } */ diff --git a/liblua/lcode.c b/liblua/lcode.c index 12619f54..87616140 100644 --- a/liblua/lcode.c +++ b/liblua/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.112.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lcode.c $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -10,6 +10,8 @@ #include "lprefix.h" +#include +#include #include #include @@ -36,11 +38,22 @@ #define hasjumps(e) ((e)->t != (e)->f) +static int codesJ (FuncState *fs, OpCode o, int sj, int k); + + + +/* semantic error */ +l_noret luaK_semerror (LexState *ls, const char *msg) { + ls->t.token = 0; /* remove "near " from final message */ + luaX_syntaxerror(ls, msg); +} + + /* ** If expression is a numeric constant, fills 'v' with its value ** and returns 1. Otherwise, returns 0. */ -static int tonumeral(const expdesc *e, TValue *v) { +static int tonumeral (const expdesc *e, TValue *v) { if (hasjumps(e)) return 0; /* not a numeral */ switch (e->k) { @@ -55,6 +68,60 @@ static int tonumeral(const expdesc *e, TValue *v) { } +/* +** Get the constant value from a constant expression +*/ +static TValue *const2val (FuncState *fs, const expdesc *e) { + lua_assert(e->k == VCONST); + return &fs->ls->dyd->actvar.arr[e->u.info].k; +} + + +/* +** If expression is a constant, fills 'v' with its value +** and returns 1. Otherwise, returns 0. +*/ +int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v) { + if (hasjumps(e)) + return 0; /* not a constant */ + switch (e->k) { + case VFALSE: + setbfvalue(v); + return 1; + case VTRUE: + setbtvalue(v); + return 1; + case VNIL: + setnilvalue(v); + return 1; + case VKSTR: { + setsvalue(fs->ls->L, v, e->u.strval); + return 1; + } + case VCONST: { + setobj(fs->ls->L, v, const2val(fs, e)); + return 1; + } + default: return tonumeral(e, v); + } +} + + +/* +** Return the previous instruction of the current code. If there +** may be a jump target between the current instruction and the +** previous one, return an invalid instruction (to avoid wrong +** optimizations). +*/ +static Instruction *previousinstruction (FuncState *fs) { + static const Instruction invalidinstruction = ~(Instruction)0; + if (fs->pc > fs->lasttarget) + return &fs->f->code[fs->pc - 1]; /* previous instruction */ + else + return cast(Instruction*, &invalidinstruction); +} + + /* ** Create a OP_LOADNIL instruction, but try to optimize: if the previous ** instruction is also OP_LOADNIL and ranges are compatible, adjust @@ -62,21 +129,18 @@ static int tonumeral(const expdesc *e, TValue *v) { ** instance, 'local a; local b' will generate a single opcode.) */ void luaK_nil (FuncState *fs, int from, int n) { - Instruction *previous; int l = from + n - 1; /* last register to set nil */ - if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - previous = &fs->f->code[fs->pc-1]; - if (GET_OPCODE(*previous) == OP_LOADNIL) { /* previous is LOADNIL? */ - int pfrom = GETARG_A(*previous); /* get previous range */ - int pl = pfrom + GETARG_B(*previous); - if ((pfrom <= from && from <= pl + 1) || - (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ - if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ - if (pl > l) l = pl; /* l = max(l, pl) */ - SETARG_A(*previous, from); - SETARG_B(*previous, l - from); - return; - } + Instruction *previous = previousinstruction(fs); + if (GET_OPCODE(*previous) == OP_LOADNIL) { /* previous is LOADNIL? */ + int pfrom = GETARG_A(*previous); /* get previous range */ + int pl = pfrom + GETARG_B(*previous); + if ((pfrom <= from && from <= pl + 1) || + (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ + if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ + if (pl > l) l = pl; /* l = max(l, pl) */ + SETARG_A(*previous, from); + SETARG_B(*previous, l - from); + return; } /* else go through */ } luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ @@ -88,7 +152,7 @@ void luaK_nil (FuncState *fs, int from, int n) { ** a list of jumps. */ static int getjump (FuncState *fs, int pc) { - int offset = GETARG_sBx(fs->f->code[pc]); + int offset = GETARG_sJ(fs->f->code[pc]); if (offset == NO_JUMP) /* point to itself represents end of list */ return NO_JUMP; /* end of list */ else @@ -104,9 +168,10 @@ static void fixjump (FuncState *fs, int pc, int dest) { Instruction *jmp = &fs->f->code[pc]; int offset = dest - (pc + 1); lua_assert(dest != NO_JUMP); - if (abs(offset) > MAXARG_sBx) + if (!(-OFFSET_sJ <= offset && offset <= MAXARG_sJ - OFFSET_sJ)) luaX_syntaxerror(fs->ls, "control structure too long"); - SETARG_sBx(*jmp, offset); + lua_assert(GET_OPCODE(*jmp) == OP_JMP); + SETARG_sJ(*jmp, offset); } @@ -129,17 +194,10 @@ void luaK_concat (FuncState *fs, int *l1, int l2) { /* ** Create a jump instruction and return its position, so its destination -** can be fixed later (with 'fixjump'). If there are jumps to -** this position (kept in 'jpc'), link them all together so that -** 'patchlistaux' will fix all them directly to the final destination. +** can be fixed later (with 'fixjump'). */ int luaK_jump (FuncState *fs) { - int jpc = fs->jpc; /* save list of jumps to here */ - int j; - fs->jpc = NO_JUMP; /* no more jumps to here */ - j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); - luaK_concat(fs, &j, jpc); /* keep them on hold */ - return j; + return codesJ(fs, OP_JMP, NO_JUMP, 0); } @@ -147,7 +205,13 @@ int luaK_jump (FuncState *fs) { ** Code a 'return' instruction */ void luaK_ret (FuncState *fs, int first, int nret) { - luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); + OpCode op; + switch (nret) { + case 0: op = OP_RETURN0; break; + case 1: op = OP_RETURN1; break; + default: op = OP_RETURN; break; + } + luaK_codeABC(fs, op, first, nret + 1, 0); } @@ -155,8 +219,8 @@ void luaK_ret (FuncState *fs, int first, int nret) { ** Code a "conditional jump", that is, a test or comparison opcode ** followed by a jump. Return jump position. */ -static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { - luaK_codeABC(fs, op, A, B, C); +static int condjump (FuncState *fs, OpCode op, int A, int B, int C, int k) { + luaK_codeABCk(fs, op, A, B, C, k); return luaK_jump(fs); } @@ -201,7 +265,7 @@ static int patchtestreg (FuncState *fs, int node, int reg) { else { /* no register to put value or register already has the value; change instruction to simple test */ - *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + *i = CREATE_ABCk(OP_TEST, GETARG_B(*i), 0, 0, GETARG_k(*i)); } return 1; } @@ -235,54 +299,79 @@ static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, /* -** Ensure all pending jumps to current position are fixed (jumping -** to current position with no values) and reset list of pending -** jumps +** Path all jumps in 'list' to jump to 'target'. +** (The assert means that we cannot fix a jump to a forward address +** because we only know addresses once code is generated.) */ -static void dischargejpc (FuncState *fs) { - patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); - fs->jpc = NO_JUMP; +void luaK_patchlist (FuncState *fs, int list, int target) { + lua_assert(target <= fs->pc); + patchlistaux(fs, list, target, NO_REG, target); } -/* -** Add elements in 'list' to list of pending jumps to "here" -** (current position) -*/ void luaK_patchtohere (FuncState *fs, int list) { - luaK_getlabel(fs); /* mark "here" as a jump target */ - luaK_concat(fs, &fs->jpc, list); + int hr = luaK_getlabel(fs); /* mark "here" as a jump target */ + luaK_patchlist(fs, list, hr); } +/* limit for difference between lines in relative line info. */ +#define LIMLINEDIFF 0x80 + + /* -** Path all jumps in 'list' to jump to 'target'. -** (The assert means that we cannot fix a jump to a forward address -** because we only know addresses once code is generated.) +** Save line info for a new instruction. If difference from last line +** does not fit in a byte, of after that many instructions, save a new +** absolute line info; (in that case, the special value 'ABSLINEINFO' +** in 'lineinfo' signals the existence of this absolute information.) +** Otherwise, store the difference from last line in 'lineinfo'. */ -void luaK_patchlist (FuncState *fs, int list, int target) { - if (target == fs->pc) /* 'target' is current position? */ - luaK_patchtohere(fs, list); /* add list to pending jumps */ - else { - lua_assert(target < fs->pc); - patchlistaux(fs, list, target, NO_REG, target); +static void savelineinfo (FuncState *fs, Proto *f, int line) { + int linedif = line - fs->previousline; + int pc = fs->pc - 1; /* last instruction coded */ + if (abs(linedif) >= LIMLINEDIFF || fs->iwthabs++ >= MAXIWTHABS) { + luaM_growvector(fs->ls->L, f->abslineinfo, fs->nabslineinfo, + f->sizeabslineinfo, AbsLineInfo, MAX_INT, "lines"); + f->abslineinfo[fs->nabslineinfo].pc = pc; + f->abslineinfo[fs->nabslineinfo++].line = line; + linedif = ABSLINEINFO; /* signal that there is absolute information */ + fs->iwthabs = 1; /* restart counter */ } + luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte, + MAX_INT, "opcodes"); + f->lineinfo[pc] = linedif; + fs->previousline = line; /* last line saved */ } /* -** Path all jumps in 'list' to close upvalues up to given 'level' -** (The assertion checks that jumps either were closing nothing -** or were closing higher levels, from inner blocks.) +** Remove line information from the last instruction. +** If line information for that instruction is absolute, set 'iwthabs' +** above its max to force the new (replacing) instruction to have +** absolute line info, too. */ -void luaK_patchclose (FuncState *fs, int list, int level) { - level++; /* argument is +1 to reserve 0 as non-op */ - for (; list != NO_JUMP; list = getjump(fs, list)) { - lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP && - (GETARG_A(fs->f->code[list]) == 0 || - GETARG_A(fs->f->code[list]) >= level)); - SETARG_A(fs->f->code[list], level); +static void removelastlineinfo (FuncState *fs) { + Proto *f = fs->f; + int pc = fs->pc - 1; /* last instruction coded */ + if (f->lineinfo[pc] != ABSLINEINFO) { /* relative line info? */ + fs->previousline -= f->lineinfo[pc]; /* correct last line saved */ + fs->iwthabs--; /* undo previous increment */ } + else { /* absolute line information */ + lua_assert(f->abslineinfo[fs->nabslineinfo - 1].pc == pc); + fs->nabslineinfo--; /* remove it */ + fs->iwthabs = MAXIWTHABS + 1; /* force next line info to be absolute */ + } +} + + +/* +** Remove the last instruction created, correcting line information +** accordingly. +*/ +static void removelastinstruction (FuncState *fs) { + removelastlineinfo(fs); + fs->pc--; } @@ -290,18 +379,14 @@ void luaK_patchclose (FuncState *fs, int list, int level) { ** Emit instruction 'i', checking for array sizes and saving also its ** line information. Return 'i' position. */ -static int luaK_code (FuncState *fs, Instruction i) { +int luaK_code (FuncState *fs, Instruction i) { Proto *f = fs->f; - dischargejpc(fs); /* 'pc' will change */ /* put new instruction in code array */ luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, MAX_INT, "opcodes"); - f->code[fs->pc] = i; - /* save corresponding line information */ - luaM_growvector(fs->ls->L, f->lineinfo, fs->pc, f->sizelineinfo, int, - MAX_INT, "opcodes"); - f->lineinfo[fs->pc] = fs->ls->lastline; - return fs->pc++; + f->code[fs->pc++] = i; + savelineinfo(fs, f, fs->ls->lastline); + return fs->pc - 1; /* index of new instruction */ } @@ -309,12 +394,11 @@ static int luaK_code (FuncState *fs, Instruction i) { ** Format and emit an 'iABC' instruction. (Assertions check consistency ** of parameters versus opcode.) */ -int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { +int luaK_codeABCk (FuncState *fs, OpCode o, int a, int b, int c, int k) { lua_assert(getOpMode(o) == iABC); - lua_assert(getBMode(o) != OpArgN || b == 0); - lua_assert(getCMode(o) != OpArgN || c == 0); - lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); - return luaK_code(fs, CREATE_ABC(o, a, b, c)); + lua_assert(a <= MAXARG_A && b <= MAXARG_B && + c <= MAXARG_C && (k & ~1) == 0); + return luaK_code(fs, CREATE_ABCk(o, a, b, c, k)); } @@ -322,13 +406,34 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { ** Format and emit an 'iABx' instruction. */ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { - lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); - lua_assert(getCMode(o) == OpArgN); + lua_assert(getOpMode(o) == iABx); lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); return luaK_code(fs, CREATE_ABx(o, a, bc)); } +/* +** Format and emit an 'iAsBx' instruction. +*/ +static int codeAsBx (FuncState *fs, OpCode o, int a, int bc) { + unsigned int b = bc + OFFSET_sBx; + lua_assert(getOpMode(o) == iAsBx); + lua_assert(a <= MAXARG_A && b <= MAXARG_Bx); + return luaK_code(fs, CREATE_ABx(o, a, b)); +} + + +/* +** Format and emit an 'isJ' instruction. +*/ +static int codesJ (FuncState *fs, OpCode o, int sj, int k) { + unsigned int j = sj + OFFSET_sJ; + lua_assert(getOpMode(o) == isJ); + lua_assert(j <= MAXARG_sJ && (k & ~1) == 0); + return luaK_code(fs, CREATE_sJ(o, j, k)); +} + + /* ** Emit an "extra argument" instruction (format 'iAx') */ @@ -343,7 +448,7 @@ static int codeextraarg (FuncState *fs, int a) { ** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX' ** instruction with "extra argument". */ -int luaK_codek (FuncState *fs, int reg, int k) { +static int luaK_codek (FuncState *fs, int reg, int k) { if (k <= MAXARG_Bx) return luaK_codeABx(fs, OP_LOADK, reg, k); else { @@ -384,13 +489,28 @@ void luaK_reserveregs (FuncState *fs, int n) { ) */ static void freereg (FuncState *fs, int reg) { - if (!ISK(reg) && reg >= fs->nactvar) { + if (reg >= luaY_nvarstack(fs)) { fs->freereg--; lua_assert(reg == fs->freereg); } } +/* +** Free two registers in proper order +*/ +static void freeregs (FuncState *fs, int r1, int r2) { + if (r1 > r2) { + freereg(fs, r1); + freereg(fs, r2); + } + else { + freereg(fs, r2); + freereg(fs, r1); + } +} + + /* ** Free register used by expression 'e' (if any) */ @@ -407,14 +527,7 @@ static void freeexp (FuncState *fs, expdesc *e) { static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { int r1 = (e1->k == VNONRELOC) ? e1->u.info : -1; int r2 = (e2->k == VNONRELOC) ? e2->u.info : -1; - if (r1 > r2) { - freereg(fs, r1); - freereg(fs, r2); - } - else { - freereg(fs, r2); - freereg(fs, r1); - } + freeregs(fs, r1, r2); } @@ -424,16 +537,19 @@ static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { ** and try to reuse constants. Because some values should not be used ** as keys (nil cannot be a key, integer keys can collapse with float ** keys), the caller must provide a useful 'key' for indexing the cache. +** Note that all functions share the same table, so entering or exiting +** a function can make some indices wrong. */ static int addk (FuncState *fs, TValue *key, TValue *v) { + TValue val; lua_State *L = fs->ls->L; Proto *f = fs->f; - TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */ + const TValue *idx = luaH_get(fs->ls->h, key); /* query scanner table */ int k, oldsize; if (ttisinteger(idx)) { /* is there an index there? */ k = cast_int(ivalue(idx)); /* correct value? (warning: must distinguish floats from integers!) */ - if (k < fs->nk && ttype(&f->k[k]) == ttype(v) && + if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && luaV_rawequalobj(&f->k[k], v)) return k; /* reuse index */ } @@ -442,7 +558,8 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { k = fs->nk; /* numerical value does not need GC barrier; table has no metatable, so it does not need to invalidate cache */ - setivalue(idx, k); + setivalue(&val, k); + luaH_finishset(L, fs->ls->h, key, idx, &val); luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); setobj(L, &f->k[k], v); @@ -455,7 +572,7 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { /* ** Add a string to list of constants and return its index. */ -int luaK_stringK (FuncState *fs, TString *s) { +static int stringK (FuncState *fs, TString *s) { TValue o; setsvalue(fs->ls->L, &o, s); return addk(fs, &o, &o); /* use string itself as key */ @@ -464,33 +581,60 @@ int luaK_stringK (FuncState *fs, TString *s) { /* ** Add an integer to list of constants and return its index. -** Integers use userdata as keys to avoid collision with floats with -** same value; conversion to 'void*' is used only for hashing, so there -** are no "precision" problems. */ -int luaK_intK (FuncState *fs, lua_Integer n) { - TValue k, o; - setpvalue(&k, cast(void*, cast(size_t, n))); +static int luaK_intK (FuncState *fs, lua_Integer n) { + TValue o; setivalue(&o, n); - return addk(fs, &k, &o); + return addk(fs, &o, &o); /* use integer itself as key */ } /* -** Add a float to list of constants and return its index. +** Add a float to list of constants and return its index. Floats +** with integral values need a different key, to avoid collision +** with actual integers. To that, we add to the number its smaller +** power-of-two fraction that is still significant in its scale. +** For doubles, that would be 1/2^52. +** (This method is not bulletproof: there may be another float +** with that value, and for floats larger than 2^53 the result is +** still an integer. At worst, this only wastes an entry with +** a duplicate.) */ static int luaK_numberK (FuncState *fs, lua_Number r) { TValue o; + lua_Integer ik; setfltvalue(&o, r); - return addk(fs, &o, &o); /* use number itself as key */ + if (!luaV_flttointeger(r, &ik, F2Ieq)) /* not an integral value? */ + return addk(fs, &o, &o); /* use number itself as key */ + else { /* must build an alternative key */ + const int nbm = l_floatatt(MANT_DIG); + const lua_Number q = l_mathop(ldexp)(l_mathop(1.0), -nbm + 1); + const lua_Number k = (ik == 0) ? q : r + r*q; /* new key */ + TValue kv; + setfltvalue(&kv, k); + /* result is not an integral value, unless value is too large */ + lua_assert(!luaV_flttointeger(k, &ik, F2Ieq) || + l_mathop(fabs)(r) >= l_mathop(1e6)); + return addk(fs, &kv, &o); + } +} + + +/* +** Add a false to list of constants and return its index. +*/ +static int boolF (FuncState *fs) { + TValue o; + setbfvalue(&o); + return addk(fs, &o, &o); /* use boolean itself as key */ } /* -** Add a boolean to list of constants and return its index. +** Add a true to list of constants and return its index. */ -static int boolK (FuncState *fs, int b) { +static int boolT (FuncState *fs) { TValue o; - setbvalue(&o, b); + setbtvalue(&o); return addk(fs, &o, &o); /* use boolean itself as key */ } @@ -507,22 +651,93 @@ static int nilK (FuncState *fs) { } +/* +** Check whether 'i' can be stored in an 'sC' operand. Equivalent to +** (0 <= int2sC(i) && int2sC(i) <= MAXARG_C) but without risk of +** overflows in the hidden addition inside 'int2sC'. +*/ +static int fitsC (lua_Integer i) { + return (l_castS2U(i) + OFFSET_sC <= cast_uint(MAXARG_C)); +} + + +/* +** Check whether 'i' can be stored in an 'sBx' operand. +*/ +static int fitsBx (lua_Integer i) { + return (-OFFSET_sBx <= i && i <= MAXARG_Bx - OFFSET_sBx); +} + + +void luaK_int (FuncState *fs, int reg, lua_Integer i) { + if (fitsBx(i)) + codeAsBx(fs, OP_LOADI, reg, cast_int(i)); + else + luaK_codek(fs, reg, luaK_intK(fs, i)); +} + + +static void luaK_float (FuncState *fs, int reg, lua_Number f) { + lua_Integer fi; + if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi)) + codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); + else + luaK_codek(fs, reg, luaK_numberK(fs, f)); +} + + +/* +** Convert a constant in 'v' into an expression description 'e' +*/ +static void const2exp (TValue *v, expdesc *e) { + switch (ttypetag(v)) { + case LUA_VNUMINT: + e->k = VKINT; e->u.ival = ivalue(v); + break; + case LUA_VNUMFLT: + e->k = VKFLT; e->u.nval = fltvalue(v); + break; + case LUA_VFALSE: + e->k = VFALSE; + break; + case LUA_VTRUE: + e->k = VTRUE; + break; + case LUA_VNIL: + e->k = VNIL; + break; + case LUA_VSHRSTR: case LUA_VLNGSTR: + e->k = VKSTR; e->u.strval = tsvalue(v); + break; + default: lua_assert(0); + } +} + + /* ** Fix an expression to return the number of results 'nresults'. -** Either 'e' is a multi-ret expression (function call or vararg) -** or 'nresults' is LUA_MULTRET (as any expression can satisfy that). +** 'e' must be a multi-ret expression (function call or vararg). */ void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { - if (e->k == VCALL) { /* expression is an open function call? */ - SETARG_C(getinstruction(fs, e), nresults + 1); - } - else if (e->k == VVARARG) { - Instruction *pc = &getinstruction(fs, e); - SETARG_B(*pc, nresults + 1); + Instruction *pc = &getinstruction(fs, e); + if (e->k == VCALL) /* expression is an open function call? */ + SETARG_C(*pc, nresults + 1); + else { + lua_assert(e->k == VVARARG); + SETARG_C(*pc, nresults + 1); SETARG_A(*pc, fs->freereg); luaK_reserveregs(fs, 1); } - else lua_assert(nresults == LUA_MULTRET); +} + + +/* +** Convert a VKSTR to a VK +*/ +static void str2K (FuncState *fs, expdesc *e) { + lua_assert(e->k == VKSTR); + e->u.info = stringK(fs, e->u.strval); + e->k = VK; } @@ -532,7 +747,7 @@ void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { ** vararg), it already returns one result, so nothing needs to be done. ** Function calls become VNONRELOC expressions (as its result comes ** fixed in the base register of the call), while vararg expressions -** become VRELOCABLE (as OP_VARARG puts its results where it wants). +** become VRELOC (as OP_VARARG puts its results where it wants). ** (Calls are created returning one result, so that does not need ** to be fixed.) */ @@ -544,39 +759,54 @@ void luaK_setoneret (FuncState *fs, expdesc *e) { e->u.info = GETARG_A(getinstruction(fs, e)); } else if (e->k == VVARARG) { - SETARG_B(getinstruction(fs, e), 2); - e->k = VRELOCABLE; /* can relocate its simple result */ + SETARG_C(getinstruction(fs, e), 2); + e->k = VRELOC; /* can relocate its simple result */ } } /* -** Ensure that expression 'e' is not a variable. +** Ensure that expression 'e' is not a variable (nor a ). +** (Expression still may have jump lists.) */ void luaK_dischargevars (FuncState *fs, expdesc *e) { switch (e->k) { + case VCONST: { + const2exp(const2val(fs, e), e); + break; + } case VLOCAL: { /* already in a register */ + int temp = e->u.var.ridx; + e->u.info = temp; /* (can't do a direct assignment; values overlap) */ e->k = VNONRELOC; /* becomes a non-relocatable value */ break; } case VUPVAL: { /* move value to some (pending) register */ e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); - e->k = VRELOCABLE; + e->k = VRELOC; + break; + } + case VINDEXUP: { + e->u.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.ind.t, e->u.ind.idx); + e->k = VRELOC; + break; + } + case VINDEXI: { + freereg(fs, e->u.ind.t); + e->u.info = luaK_codeABC(fs, OP_GETI, 0, e->u.ind.t, e->u.ind.idx); + e->k = VRELOC; + break; + } + case VINDEXSTR: { + freereg(fs, e->u.ind.t); + e->u.info = luaK_codeABC(fs, OP_GETFIELD, 0, e->u.ind.t, e->u.ind.idx); + e->k = VRELOC; break; } case VINDEXED: { - OpCode op; - freereg(fs, e->u.ind.idx); - if (e->u.ind.vt == VLOCAL) { /* is 't' in a register? */ - freereg(fs, e->u.ind.t); - op = OP_GETTABLE; - } - else { - lua_assert(e->u.ind.vt == VUPVAL); - op = OP_GETTABUP; /* 't' is in an upvalue */ - } - e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx); - e->k = VRELOCABLE; + freeregs(fs, e->u.ind.t, e->u.ind.idx); + e->u.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.ind.t, e->u.ind.idx); + e->k = VRELOC; break; } case VVARARG: case VCALL: { @@ -589,8 +819,9 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { /* -** Ensures expression value is in register 'reg' (and therefore -** 'e' will become a non-relocatable expression). +** Ensure expression value is in register 'reg', making 'e' a +** non-relocatable expression. +** (Expression still may have jump lists.) */ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { luaK_dischargevars(fs, e); @@ -599,23 +830,30 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { luaK_nil(fs, reg, 1); break; } - case VFALSE: case VTRUE: { - luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + case VFALSE: { + luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0); + break; + } + case VTRUE: { + luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0); break; } + case VKSTR: { + str2K(fs, e); + } /* FALLTHROUGH */ case VK: { luaK_codek(fs, reg, e->u.info); break; } case VKFLT: { - luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); + luaK_float(fs, reg, e->u.nval); break; } case VKINT: { - luaK_codek(fs, reg, luaK_intK(fs, e->u.ival)); + luaK_int(fs, reg, e->u.ival); break; } - case VRELOCABLE: { + case VRELOC: { Instruction *pc = &getinstruction(fs, e); SETARG_A(*pc, reg); /* instruction will put result in 'reg' */ break; @@ -636,7 +874,9 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { /* -** Ensures expression value is in any register. +** Ensure expression value is in a register, making 'e' a +** non-relocatable expression. +** (Expression still may have jump lists.) */ static void discharge2anyreg (FuncState *fs, expdesc *e) { if (e->k != VNONRELOC) { /* no fixed register yet? */ @@ -646,9 +886,9 @@ static void discharge2anyreg (FuncState *fs, expdesc *e) { } -static int code_loadbool (FuncState *fs, int A, int b, int jump) { +static int code_loadbool (FuncState *fs, int A, OpCode op) { luaK_getlabel(fs); /* those instructions may be jump targets */ - return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); + return luaK_codeABC(fs, op, A, 0, 0); } @@ -666,8 +906,8 @@ static int need_value (FuncState *fs, int list) { /* -** Ensures final expression result (including results from its jump -** lists) is in register 'reg'. +** Ensures final expression result (which includes results from its +** jump lists) is in register 'reg'. ** If expression has jumps, need to patch these jumps either to ** its final position or to "load" instructions (for those tests ** that do not produce values). @@ -682,8 +922,9 @@ static void exp2reg (FuncState *fs, expdesc *e, int reg) { int p_t = NO_JUMP; /* position of an eventual LOAD true */ if (need_value(fs, e->t) || need_value(fs, e->f)) { int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); - p_f = code_loadbool(fs, reg, 0, 1); - p_t = code_loadbool(fs, reg, 1, 0); + p_f = code_loadbool(fs, reg, OP_LFALSESKIP); /* skip next inst. */ + p_t = code_loadbool(fs, reg, OP_LOADTRUE); + /* jump around these booleans if 'e' is not a test */ luaK_patchtohere(fs, fj); } final = luaK_getlabel(fs); @@ -697,8 +938,7 @@ static void exp2reg (FuncState *fs, expdesc *e, int reg) { /* -** Ensures final expression result (including results from its jump -** lists) is in next available register. +** Ensures final expression result is in next available register. */ void luaK_exp2nextreg (FuncState *fs, expdesc *e) { luaK_dischargevars(fs, e); @@ -709,27 +949,30 @@ void luaK_exp2nextreg (FuncState *fs, expdesc *e) { /* -** Ensures final expression result (including results from its jump -** lists) is in some (any) register and return that register. +** Ensures final expression result is in some (any) register +** and return that register. */ int luaK_exp2anyreg (FuncState *fs, expdesc *e) { luaK_dischargevars(fs, e); if (e->k == VNONRELOC) { /* expression already has a register? */ if (!hasjumps(e)) /* no jumps? */ return e->u.info; /* result is already in a register */ - if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ + if (e->u.info >= luaY_nvarstack(fs)) { /* reg. is not a local? */ exp2reg(fs, e, e->u.info); /* put final result in it */ return e->u.info; } + /* else expression has jumps and cannot change its register + to hold the jump values, because it is a local variable. + Go through to the default case. */ } - luaK_exp2nextreg(fs, e); /* otherwise, use next available register */ + luaK_exp2nextreg(fs, e); /* default: use next available register */ return e->u.info; } /* -** Ensures final expression result is either in a register or in an -** upvalue. +** Ensures final expression result is either in a register +** or in an upvalue. */ void luaK_exp2anyregup (FuncState *fs, expdesc *e) { if (e->k != VUPVAL || hasjumps(e)) @@ -738,8 +981,8 @@ void luaK_exp2anyregup (FuncState *fs, expdesc *e) { /* -** Ensures final expression result is either in a register or it is -** a constant. +** Ensures final expression result is either in a register +** or it is a constant. */ void luaK_exp2val (FuncState *fs, expdesc *e) { if (hasjumps(e)) @@ -749,30 +992,54 @@ void luaK_exp2val (FuncState *fs, expdesc *e) { } +/* +** Try to make 'e' a K expression with an index in the range of R/K +** indices. Return true iff succeeded. +*/ +static int luaK_exp2K (FuncState *fs, expdesc *e) { + if (!hasjumps(e)) { + int info; + switch (e->k) { /* move constants to 'k' */ + case VTRUE: info = boolT(fs); break; + case VFALSE: info = boolF(fs); break; + case VNIL: info = nilK(fs); break; + case VKINT: info = luaK_intK(fs, e->u.ival); break; + case VKFLT: info = luaK_numberK(fs, e->u.nval); break; + case VKSTR: info = stringK(fs, e->u.strval); break; + case VK: info = e->u.info; break; + default: return 0; /* not a constant */ + } + if (info <= MAXINDEXRK) { /* does constant fit in 'argC'? */ + e->k = VK; /* make expression a 'K' expression */ + e->u.info = info; + return 1; + } + } + /* else, expression doesn't fit; leave it unchanged */ + return 0; +} + + /* ** Ensures final expression result is in a valid R/K index ** (that is, it is either in a register or in 'k' with an index ** in the range of R/K indices). -** Returns R/K index. -*/ -int luaK_exp2RK (FuncState *fs, expdesc *e) { - luaK_exp2val(fs, e); - switch (e->k) { /* move constants to 'k' */ - case VTRUE: e->u.info = boolK(fs, 1); goto vk; - case VFALSE: e->u.info = boolK(fs, 0); goto vk; - case VNIL: e->u.info = nilK(fs); goto vk; - case VKINT: e->u.info = luaK_intK(fs, e->u.ival); goto vk; - case VKFLT: e->u.info = luaK_numberK(fs, e->u.nval); goto vk; - case VK: - vk: - e->k = VK; - if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ - return RKASK(e->u.info); - else break; - default: break; +** Returns 1 iff expression is K. +*/ +static int exp2RK (FuncState *fs, expdesc *e) { + if (luaK_exp2K(fs, e)) + return 1; + else { /* not a constant in the right range: put it in a register */ + luaK_exp2anyreg(fs, e); + return 0; } - /* not a constant in the right range: put it in a register */ - return luaK_exp2anyreg(fs, e); +} + + +static void codeABRK (FuncState *fs, OpCode o, int a, int b, + expdesc *ec) { + int k = exp2RK(fs, ec); + luaK_codeABCk(fs, o, a, b, ec->u.info, k); } @@ -783,7 +1050,7 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { switch (var->k) { case VLOCAL: { freeexp(fs, ex); - exp2reg(fs, ex, var->u.info); /* compute 'ex' into proper place */ + exp2reg(fs, ex, var->u.var.ridx); /* compute 'ex' into proper place */ return; } case VUPVAL: { @@ -791,10 +1058,20 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); break; } + case VINDEXUP: { + codeABRK(fs, OP_SETTABUP, var->u.ind.t, var->u.ind.idx, ex); + break; + } + case VINDEXI: { + codeABRK(fs, OP_SETI, var->u.ind.t, var->u.ind.idx, ex); + break; + } + case VINDEXSTR: { + codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex); + break; + } case VINDEXED: { - OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; - int e = luaK_exp2RK(fs, ex); - luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); + codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex); break; } default: lua_assert(0); /* invalid var kind to store */ @@ -814,7 +1091,7 @@ void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { e->u.info = fs->freereg; /* base register for op_self */ e->k = VNONRELOC; /* self expression has a fixed register */ luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ - luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key)); + codeABRK(fs, OP_SELF, e->u.info, ereg, key); freeexp(fs, key); } @@ -826,7 +1103,7 @@ static void negatecondition (FuncState *fs, expdesc *e) { Instruction *pc = getjumpcontrol(fs, e->u.info); lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && GET_OPCODE(*pc) != OP_TEST); - SETARG_A(*pc, !(GETARG_A(*pc))); + SETARG_k(*pc, (GETARG_k(*pc) ^ 1)); } @@ -837,17 +1114,17 @@ static void negatecondition (FuncState *fs, expdesc *e) { ** and removing the 'not'. */ static int jumponcond (FuncState *fs, expdesc *e, int cond) { - if (e->k == VRELOCABLE) { + if (e->k == VRELOC) { Instruction ie = getinstruction(fs, e); if (GET_OPCODE(ie) == OP_NOT) { - fs->pc--; /* remove previous OP_NOT */ - return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + removelastinstruction(fs); /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond); } /* else go through */ } discharge2anyreg(fs, e); freeexp(fs, e); - return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond); + return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond); } @@ -863,7 +1140,7 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { pc = e->u.info; /* save jump position */ break; } - case VK: case VKFLT: case VKINT: case VTRUE: { + case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: { pc = NO_JUMP; /* always true; do nothing */ break; } @@ -908,13 +1185,12 @@ void luaK_goiffalse (FuncState *fs, expdesc *e) { ** Code 'not e', doing constant folding. */ static void codenot (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); switch (e->k) { case VNIL: case VFALSE: { e->k = VTRUE; /* true == not nil == not false */ break; } - case VK: case VKFLT: case VKINT: case VTRUE: { + case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: { e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */ break; } @@ -922,12 +1198,12 @@ static void codenot (FuncState *fs, expdesc *e) { negatecondition(fs, e); break; } - case VRELOCABLE: + case VRELOC: case VNONRELOC: { discharge2anyreg(fs, e); freeexp(fs, e); e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); - e->k = VRELOCABLE; + e->k = VRELOC; break; } default: lua_assert(0); /* cannot happen */ @@ -939,16 +1215,97 @@ static void codenot (FuncState *fs, expdesc *e) { } +/* +** Check whether expression 'e' is a short literal string +*/ +static int isKstr (FuncState *fs, expdesc *e) { + return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B && + ttisshrstring(&fs->f->k[e->u.info])); +} + +/* +** Check whether expression 'e' is a literal integer. +*/ +static int isKint (expdesc *e) { + return (e->k == VKINT && !hasjumps(e)); +} + + +/* +** Check whether expression 'e' is a literal integer in +** proper range to fit in register C +*/ +static int isCint (expdesc *e) { + return isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); +} + + +/* +** Check whether expression 'e' is a literal integer in +** proper range to fit in register sC +*/ +static int isSCint (expdesc *e) { + return isKint(e) && fitsC(e->u.ival); +} + + +/* +** Check whether expression 'e' is a literal integer or float in +** proper range to fit in a register (sB or sC). +*/ +static int isSCnumber (expdesc *e, int *pi, int *isfloat) { + lua_Integer i; + if (e->k == VKINT) + i = e->u.ival; + else if (e->k == VKFLT && luaV_flttointeger(e->u.nval, &i, F2Ieq)) + *isfloat = 1; + else + return 0; /* not a number */ + if (!hasjumps(e) && fitsC(i)) { + *pi = int2sC(cast_int(i)); + return 1; + } + else + return 0; +} + + /* ** Create expression 't[k]'. 't' must have its final result already in a -** register or upvalue. +** register or upvalue. Upvalues can only be indexed by literal strings. +** Keys can be literal strings in the constant table or arbitrary +** values in registers. */ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { - lua_assert(!hasjumps(t) && (vkisinreg(t->k) || t->k == VUPVAL)); - t->u.ind.t = t->u.info; /* register or upvalue index */ - t->u.ind.idx = luaK_exp2RK(fs, k); /* R/K index for key */ - t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL : VLOCAL; - t->k = VINDEXED; + if (k->k == VKSTR) + str2K(fs, k); + lua_assert(!hasjumps(t) && + (t->k == VLOCAL || t->k == VNONRELOC || t->k == VUPVAL)); + if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ + luaK_exp2anyreg(fs, t); /* put it in a register */ + if (t->k == VUPVAL) { + int temp = t->u.info; /* upvalue index */ + lua_assert(isKstr(fs, k)); + t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */ + t->u.ind.idx = k->u.info; /* literal short string */ + t->k = VINDEXUP; + } + else { + /* register index of the table */ + t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info; + if (isKstr(fs, k)) { + t->u.ind.idx = k->u.info; /* literal short string */ + t->k = VINDEXSTR; + } + else if (isCint(k)) { + t->u.ind.idx = cast_int(k->u.ival); /* int. constant in proper range */ + t->k = VINDEXI; + } + else { + t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ + t->k = VINDEXED; + } + } } @@ -962,7 +1319,8 @@ static int validop (int op, TValue *v1, TValue *v2) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ lua_Integer i; - return (tointeger(v1, &i) && tointeger(v2, &i)); + return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) && + luaV_tointegerns(v2, &i, LUA_FLOORN2I)); } case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ return (nvalue(v2) != 0); @@ -976,11 +1334,11 @@ static int validop (int op, TValue *v1, TValue *v2) { ** (In this case, 'e1' has the final result.) */ static int constfolding (FuncState *fs, int op, expdesc *e1, - const expdesc *e2) { + const expdesc *e2) { TValue v1, v2, res; if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) return 0; /* non-numeric operands or not safe to fold */ - luaO_arith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ + luaO_rawarith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ if (ttisinteger(&res)) { e1->k = VKINT; e1->u.ival = ivalue(&res); @@ -996,6 +1354,35 @@ static int constfolding (FuncState *fs, int op, expdesc *e1, } +/* +** Convert a BinOpr to an OpCode (ORDER OPR - ORDER OP) +*/ +l_sinline OpCode binopr2op (BinOpr opr, BinOpr baser, OpCode base) { + lua_assert(baser <= opr && + ((baser == OPR_ADD && opr <= OPR_SHR) || + (baser == OPR_LT && opr <= OPR_LE))); + return cast(OpCode, (cast_int(opr) - cast_int(baser)) + cast_int(base)); +} + + +/* +** Convert a UnOpr to an OpCode (ORDER OPR - ORDER OP) +*/ +l_sinline OpCode unopr2op (UnOpr opr) { + return cast(OpCode, (cast_int(opr) - cast_int(OPR_MINUS)) + + cast_int(OP_UNM)); +} + + +/* +** Convert a BinOpr to a tag method (ORDER OPR - ORDER TM) +*/ +l_sinline TMS binopr2TM (BinOpr opr) { + lua_assert(OPR_ADD <= opr && opr <= OPR_SHR); + return cast(TMS, (cast_int(opr) - cast_int(OPR_ADD)) + cast_int(TM_ADD)); +} + + /* ** Emit code for unary expressions that "produce values" ** (everything but 'not'). @@ -1005,7 +1392,7 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ freeexp(fs, e); e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ - e->k = VRELOCABLE; /* all those operations are relocatable */ + e->k = VRELOC; /* all those operations are relocatable */ luaK_fixline(fs, line); } @@ -1015,63 +1402,226 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { ** (everything but logical operators 'and'/'or' and comparison ** operators). ** Expression to produce final result will be encoded in 'e1'. -** Because 'luaK_exp2RK' can free registers, its calls must be -** in "stack order" (that is, first on 'e2', which may have more -** recent registers to be released). */ -static void codebinexpval (FuncState *fs, OpCode op, - expdesc *e1, expdesc *e2, int line) { - int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */ - int rk1 = luaK_exp2RK(fs, e1); +static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, + OpCode op, int v2, int flip, int line, + OpCode mmop, TMS event) { + int v1 = luaK_exp2anyreg(fs, e1); + int pc = luaK_codeABCk(fs, op, 0, v1, v2, 0); freeexps(fs, e1, e2); - e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */ - e1->k = VRELOCABLE; /* all those operations are relocatable */ + e1->u.info = pc; + e1->k = VRELOC; /* all those operations are relocatable */ + luaK_fixline(fs, line); + luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */ luaK_fixline(fs, line); } /* -** Emit code for comparisons. -** 'e1' was already put in R/K form by 'luaK_infix'. +** Emit code for binary expressions that "produce values" over +** two registers. */ -static void codecomp (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { - int rk1 = (e1->k == VK) ? RKASK(e1->u.info) - : check_exp(e1->k == VNONRELOC, e1->u.info); - int rk2 = luaK_exp2RK(fs, e2); - freeexps(fs, e1, e2); - switch (opr) { - case OPR_NE: { /* '(a ~= b)' ==> 'not (a == b)' */ - e1->u.info = condjump(fs, OP_EQ, 0, rk1, rk2); - break; - } - case OPR_GT: case OPR_GE: { - /* '(a > b)' ==> '(b < a)'; '(a >= b)' ==> '(b <= a)' */ - OpCode op = cast(OpCode, (opr - OPR_NE) + OP_EQ); - e1->u.info = condjump(fs, op, 1, rk2, rk1); /* invert operands */ - break; - } - default: { /* '==', '<', '<=' use their own opcodes */ - OpCode op = cast(OpCode, (opr - OPR_EQ) + OP_EQ); - e1->u.info = condjump(fs, op, 1, rk1, rk2); - break; +static void codebinexpval (FuncState *fs, BinOpr opr, + expdesc *e1, expdesc *e2, int line) { + OpCode op = binopr2op(opr, OPR_ADD, OP_ADD); + int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */ + /* 'e1' must be already in a register or it is a constant */ + lua_assert((VNIL <= e1->k && e1->k <= VKSTR) || + e1->k == VNONRELOC || e1->k == VRELOC); + lua_assert(OP_ADD <= op && op <= OP_SHR); + finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, binopr2TM(opr)); +} + + +/* +** Code binary operators with immediate operands. +*/ +static void codebini (FuncState *fs, OpCode op, + expdesc *e1, expdesc *e2, int flip, int line, + TMS event) { + int v2 = int2sC(cast_int(e2->u.ival)); /* immediate operand */ + lua_assert(e2->k == VKINT); + finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINI, event); +} + + +/* +** Code binary operators with K operand. +*/ +static void codebinK (FuncState *fs, BinOpr opr, + expdesc *e1, expdesc *e2, int flip, int line) { + TMS event = binopr2TM(opr); + int v2 = e2->u.info; /* K index */ + OpCode op = binopr2op(opr, OPR_ADD, OP_ADDK); + finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event); +} + + +/* Try to code a binary operator negating its second operand. +** For the metamethod, 2nd operand must keep its original value. +*/ +static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, + OpCode op, int line, TMS event) { + if (!isKint(e2)) + return 0; /* not an integer constant */ + else { + lua_Integer i2 = e2->u.ival; + if (!(fitsC(i2) && fitsC(-i2))) + return 0; /* not in the proper range */ + else { /* operating a small integer constant */ + int v2 = cast_int(i2); + finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event); + /* correct metamethod argument */ + SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2)); + return 1; /* successfully coded */ } } +} + + +static void swapexps (expdesc *e1, expdesc *e2) { + expdesc temp = *e1; *e1 = *e2; *e2 = temp; /* swap 'e1' and 'e2' */ +} + + +/* +** Code binary operators with no constant operand. +*/ +static void codebinNoK (FuncState *fs, BinOpr opr, + expdesc *e1, expdesc *e2, int flip, int line) { + if (flip) + swapexps(e1, e2); /* back to original order */ + codebinexpval(fs, opr, e1, e2, line); /* use standard operators */ +} + + +/* +** Code arithmetic operators ('+', '-', ...). If second operand is a +** constant in the proper range, use variant opcodes with K operands. +*/ +static void codearith (FuncState *fs, BinOpr opr, + expdesc *e1, expdesc *e2, int flip, int line) { + if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) /* K operand? */ + codebinK(fs, opr, e1, e2, flip, line); + else /* 'e2' is neither an immediate nor a K operand */ + codebinNoK(fs, opr, e1, e2, flip, line); +} + + +/* +** Code commutative operators ('+', '*'). If first operand is a +** numeric constant, change order of operands to try to use an +** immediate or K operator. +*/ +static void codecommutative (FuncState *fs, BinOpr op, + expdesc *e1, expdesc *e2, int line) { + int flip = 0; + if (tonumeral(e1, NULL)) { /* is first operand a numeric constant? */ + swapexps(e1, e2); /* change order */ + flip = 1; + } + if (op == OPR_ADD && isSCint(e2)) /* immediate operand? */ + codebini(fs, OP_ADDI, e1, e2, flip, line, TM_ADD); + else + codearith(fs, op, e1, e2, flip, line); +} + + +/* +** Code bitwise operations; they are all commutative, so the function +** tries to put an integer constant as the 2nd operand (a K operand). +*/ +static void codebitwise (FuncState *fs, BinOpr opr, + expdesc *e1, expdesc *e2, int line) { + int flip = 0; + if (e1->k == VKINT) { + swapexps(e1, e2); /* 'e2' will be the constant operand */ + flip = 1; + } + if (e2->k == VKINT && luaK_exp2K(fs, e2)) /* K operand? */ + codebinK(fs, opr, e1, e2, flip, line); + else /* no constants */ + codebinNoK(fs, opr, e1, e2, flip, line); +} + + +/* +** Emit code for order comparisons. When using an immediate operand, +** 'isfloat' tells whether the original value was a float. +*/ +static void codeorder (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { + int r1, r2; + int im; + int isfloat = 0; + OpCode op; + if (isSCnumber(e2, &im, &isfloat)) { + /* use immediate operand */ + r1 = luaK_exp2anyreg(fs, e1); + r2 = im; + op = binopr2op(opr, OPR_LT, OP_LTI); + } + else if (isSCnumber(e1, &im, &isfloat)) { + /* transform (A < B) to (B > A) and (A <= B) to (B >= A) */ + r1 = luaK_exp2anyreg(fs, e2); + r2 = im; + op = binopr2op(opr, OPR_LT, OP_GTI); + } + else { /* regular case, compare two registers */ + r1 = luaK_exp2anyreg(fs, e1); + r2 = luaK_exp2anyreg(fs, e2); + op = binopr2op(opr, OPR_LT, OP_LT); + } + freeexps(fs, e1, e2); + e1->u.info = condjump(fs, op, r1, r2, isfloat, 1); e1->k = VJMP; } /* -** Aplly prefix operation 'op' to expression 'e'. +** Emit code for equality comparisons ('==', '~='). +** 'e1' was already put as RK by 'luaK_infix'. */ -void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { +static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { + int r1, r2; + int im; + int isfloat = 0; /* not needed here, but kept for symmetry */ + OpCode op; + if (e1->k != VNONRELOC) { + lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT); + swapexps(e1, e2); + } + r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */ + if (isSCnumber(e2, &im, &isfloat)) { + op = OP_EQI; + r2 = im; /* immediate operand */ + } + else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */ + op = OP_EQK; + r2 = e2->u.info; /* constant index */ + } + else { + op = OP_EQ; /* will compare two registers */ + r2 = luaK_exp2anyreg(fs, e2); + } + freeexps(fs, e1, e2); + e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ)); + e1->k = VJMP; +} + + +/* +** Apply prefix operation 'op' to expression 'e'. +*/ +void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) { static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; - switch (op) { + luaK_dischargevars(fs, e); + switch (opr) { case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */ - if (constfolding(fs, op + LUA_OPUNM, e, &ef)) + if (constfolding(fs, opr + LUA_OPUNM, e, &ef)) break; - /* FALLTHROUGH */ + /* else */ /* FALLTHROUGH */ case OPR_LEN: - codeunexpval(fs, cast(OpCode, op + OP_UNM), e, line); + codeunexpval(fs, unopr2op(opr), e, line); break; case OPR_NOT: codenot(fs, e); break; default: lua_assert(0); @@ -1084,6 +1634,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { ** 2nd operand. */ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + luaK_dischargevars(fs, v); switch (op) { case OPR_AND: { luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ @@ -1094,7 +1645,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { break; } case OPR_CONCAT: { - luaK_exp2nextreg(fs, v); /* operand must be on the 'stack' */ + luaK_exp2nextreg(fs, v); /* operand must be on the stack */ break; } case OPR_ADD: case OPR_SUB: @@ -1103,67 +1654,124 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { case OPR_BAND: case OPR_BOR: case OPR_BXOR: case OPR_SHL: case OPR_SHR: { if (!tonumeral(v, NULL)) - luaK_exp2RK(fs, v); - /* else keep numeral, which may be folded with 2nd operand */ + luaK_exp2anyreg(fs, v); + /* else keep numeral, which may be folded or used as an immediate + operand */ break; } - default: { - luaK_exp2RK(fs, v); + case OPR_EQ: case OPR_NE: { + if (!tonumeral(v, NULL)) + exp2RK(fs, v); + /* else keep numeral, which may be an immediate operand */ break; } + case OPR_LT: case OPR_LE: + case OPR_GT: case OPR_GE: { + int dummy, dummy2; + if (!isSCnumber(v, &dummy, &dummy2)) + luaK_exp2anyreg(fs, v); + /* else keep numeral, which may be an immediate operand */ + break; + } + default: lua_assert(0); + } +} + +/* +** Create code for '(e1 .. e2)'. +** For '(e1 .. e2.1 .. e2.2)' (which is '(e1 .. (e2.1 .. e2.2))', +** because concatenation is right associative), merge both CONCATs. +*/ +static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) { + Instruction *ie2 = previousinstruction(fs); + if (GET_OPCODE(*ie2) == OP_CONCAT) { /* is 'e2' a concatenation? */ + int n = GETARG_B(*ie2); /* # of elements concatenated in 'e2' */ + lua_assert(e1->u.info + 1 == GETARG_A(*ie2)); + freeexp(fs, e2); + SETARG_A(*ie2, e1->u.info); /* correct first element ('e1') */ + SETARG_B(*ie2, n + 1); /* will concatenate one more element */ + } + else { /* 'e2' is not a concatenation */ + luaK_codeABC(fs, OP_CONCAT, e1->u.info, 2, 0); /* new concat opcode */ + freeexp(fs, e2); + luaK_fixline(fs, line); } } /* ** Finalize code for binary operation, after reading 2nd operand. -** For '(a .. b .. c)' (which is '(a .. (b .. c))', because -** concatenation is right associative), merge second CONCAT into first -** one. */ -void luaK_posfix (FuncState *fs, BinOpr op, +void luaK_posfix (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2, int line) { - switch (op) { + luaK_dischargevars(fs, e2); + if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2)) + return; /* done by folding */ + switch (opr) { case OPR_AND: { - lua_assert(e1->t == NO_JUMP); /* list closed by 'luK_infix' */ - luaK_dischargevars(fs, e2); + lua_assert(e1->t == NO_JUMP); /* list closed by 'luaK_infix' */ luaK_concat(fs, &e2->f, e1->f); *e1 = *e2; break; } case OPR_OR: { - lua_assert(e1->f == NO_JUMP); /* list closed by 'luK_infix' */ - luaK_dischargevars(fs, e2); + lua_assert(e1->f == NO_JUMP); /* list closed by 'luaK_infix' */ luaK_concat(fs, &e2->t, e1->t); *e1 = *e2; break; } - case OPR_CONCAT: { - luaK_exp2val(fs, e2); - if (e2->k == VRELOCABLE && - GET_OPCODE(getinstruction(fs, e2)) == OP_CONCAT) { - lua_assert(e1->u.info == GETARG_B(getinstruction(fs, e2))-1); - freeexp(fs, e1); - SETARG_B(getinstruction(fs, e2), e1->u.info); - e1->k = VRELOCABLE; e1->u.info = e2->u.info; + case OPR_CONCAT: { /* e1 .. e2 */ + luaK_exp2nextreg(fs, e2); + codeconcat(fs, e1, e2, line); + break; + } + case OPR_ADD: case OPR_MUL: { + codecommutative(fs, opr, e1, e2, line); + break; + } + case OPR_SUB: { + if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB)) + break; /* coded as (r1 + -I) */ + /* ELSE */ + } /* FALLTHROUGH */ + case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: { + codearith(fs, opr, e1, e2, 0, line); + break; + } + case OPR_BAND: case OPR_BOR: case OPR_BXOR: { + codebitwise(fs, opr, e1, e2, line); + break; + } + case OPR_SHL: { + if (isSCint(e1)) { + swapexps(e1, e2); + codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); /* I << r2 */ } - else { - luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ - codebinexpval(fs, OP_CONCAT, e1, e2, line); + else if (finishbinexpneg(fs, e1, e2, OP_SHRI, line, TM_SHL)) { + /* coded as (r1 >> -I) */; } + else /* regular case (two registers) */ + codebinexpval(fs, opr, e1, e2, line); break; } - case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: - case OPR_IDIV: case OPR_MOD: case OPR_POW: - case OPR_BAND: case OPR_BOR: case OPR_BXOR: - case OPR_SHL: case OPR_SHR: { - if (!constfolding(fs, op + LUA_OPADD, e1, e2)) - codebinexpval(fs, cast(OpCode, op + OP_ADD), e1, e2, line); + case OPR_SHR: { + if (isSCint(e2)) + codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */ + else /* regular case (two registers) */ + codebinexpval(fs, opr, e1, e2, line); + break; + } + case OPR_EQ: case OPR_NE: { + codeeq(fs, opr, e1, e2); break; } - case OPR_EQ: case OPR_LT: case OPR_LE: - case OPR_NE: case OPR_GT: case OPR_GE: { - codecomp(fs, op, e1, e2); + case OPR_GT: case OPR_GE: { + /* '(a > b)' <=> '(b < a)'; '(a >= b)' <=> '(b <= a)' */ + swapexps(e1, e2); + opr = cast(BinOpr, (opr - OPR_GT) + OPR_LT); + } /* FALLTHROUGH */ + case OPR_LT: case OPR_LE: { + codeorder(fs, opr, e1, e2); break; } default: lua_assert(0); @@ -1172,10 +1780,23 @@ void luaK_posfix (FuncState *fs, BinOpr op, /* -** Change line information associated with current position. +** Change line information associated with current position, by removing +** previous info and adding it again with new line. */ void luaK_fixline (FuncState *fs, int line) { - fs->f->lineinfo[fs->pc - 1] = line; + removelastlineinfo(fs); + savelineinfo(fs, fs->f, line); +} + + +void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) { + Instruction *inst = &fs->f->code[pc]; + int rb = (hsize != 0) ? luaO_ceillog2(hsize) + 1 : 0; /* hash size */ + int extra = asize / (MAXARG_C + 1); /* higher bits of array size */ + int rc = asize % (MAXARG_C + 1); /* lower bits of array size */ + int k = (extra > 0); /* true iff needs extra argument */ + *inst = CREATE_ABCk(OP_NEWTABLE, ra, rb, rc, k); + *(inst + 1) = CREATE_Ax(OP_EXTRAARG, extra); } @@ -1187,17 +1808,67 @@ void luaK_fixline (FuncState *fs, int line) { ** table (or LUA_MULTRET to add up to stack top). */ void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { - int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; - int b = (tostore == LUA_MULTRET) ? 0 : tostore; lua_assert(tostore != 0 && tostore <= LFIELDS_PER_FLUSH); - if (c <= MAXARG_C) - luaK_codeABC(fs, OP_SETLIST, base, b, c); - else if (c <= MAXARG_Ax) { - luaK_codeABC(fs, OP_SETLIST, base, b, 0); - codeextraarg(fs, c); + if (tostore == LUA_MULTRET) + tostore = 0; + if (nelems <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, tostore, nelems); + else { + int extra = nelems / (MAXARG_C + 1); + nelems %= (MAXARG_C + 1); + luaK_codeABCk(fs, OP_SETLIST, base, tostore, nelems, 1); + codeextraarg(fs, extra); } - else - luaX_syntaxerror(fs->ls, "constructor too long"); fs->freereg = base + 1; /* free registers with list values */ } + +/* +** return the final target of a jump (skipping jumps to jumps) +*/ +static int finaltarget (Instruction *code, int i) { + int count; + for (count = 0; count < 100; count++) { /* avoid infinite loops */ + Instruction pc = code[i]; + if (GET_OPCODE(pc) != OP_JMP) + break; + else + i += GETARG_sJ(pc) + 1; + } + return i; +} + + +/* +** Do a final pass over the code of a function, doing small peephole +** optimizations and adjustments. +*/ +void luaK_finish (FuncState *fs) { + int i; + Proto *p = fs->f; + for (i = 0; i < fs->pc; i++) { + Instruction *pc = &p->code[i]; + lua_assert(i == 0 || isOT(*(pc - 1)) == isIT(*pc)); + switch (GET_OPCODE(*pc)) { + case OP_RETURN0: case OP_RETURN1: { + if (!(fs->needclose || p->is_vararg)) + break; /* no extra work */ + /* else use OP_RETURN to do the extra work */ + SET_OPCODE(*pc, OP_RETURN); + } /* FALLTHROUGH */ + case OP_RETURN: case OP_TAILCALL: { + if (fs->needclose) + SETARG_k(*pc, 1); /* signal that it needs to close */ + if (p->is_vararg) + SETARG_C(*pc, p->numparams + 1); /* signal that it is vararg */ + break; + } + case OP_JMP: { + int target = finaltarget(p->code, i); + fixjump(fs, i, target); + break; + } + default: break; + } + } +} diff --git a/liblua/lcode.h b/liblua/lcode.h index 882dc9c1..0b971fc4 100644 --- a/liblua/lcode.h +++ b/liblua/lcode.h @@ -1,5 +1,5 @@ /* -** $Id: lcode.h,v 1.64.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lcode.h $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -24,46 +24,56 @@ ** grep "ORDER OPR" if you change these enums (ORDER OP) */ typedef enum BinOpr { + /* arithmetic operators */ OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, - OPR_DIV, - OPR_IDIV, + OPR_DIV, OPR_IDIV, + /* bitwise operators */ OPR_BAND, OPR_BOR, OPR_BXOR, OPR_SHL, OPR_SHR, + /* string operator */ OPR_CONCAT, + /* comparison operators */ OPR_EQ, OPR_LT, OPR_LE, OPR_NE, OPR_GT, OPR_GE, + /* logical operators */ OPR_AND, OPR_OR, OPR_NOBINOPR } BinOpr; +/* true if operation is foldable (that is, it is arithmetic or bitwise) */ +#define foldbinop(op) ((op) <= OPR_SHR) + + +#define luaK_codeABC(fs,o,a,b,c) luaK_codeABCk(fs,o,a,b,c,0) + + typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; /* get (pointer to) instruction of given 'expdesc' */ #define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) -#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) +LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); -LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); -LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); +LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, + int B, int C, int k); +LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); LUAI_FUNC void luaK_fixline (FuncState *fs, int line); LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); -LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); -LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); +LUAI_FUNC void luaK_int (FuncState *fs, int reg, lua_Integer n); LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); @@ -75,14 +85,17 @@ LUAI_FUNC int luaK_jump (FuncState *fs); LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); -LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); LUAI_FUNC int luaK_getlabel (FuncState *fs); LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2, int line); +LUAI_FUNC void luaK_settablesize (FuncState *fs, int pc, + int ra, int asize, int hsize); LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); +LUAI_FUNC void luaK_finish (FuncState *fs); +LUAI_FUNC l_noret luaK_semerror (LexState *ls, const char *msg); #endif diff --git a/liblua/lcorolib.c b/liblua/lcorolib.c index 0b17af9e..c64adf08 100644 --- a/liblua/lcorolib.c +++ b/liblua/lcorolib.c @@ -1,5 +1,5 @@ /* -** $Id: lcorolib.c,v 1.10.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lcorolib.c $ ** Coroutine Library ** See Copyright Notice in lua.h */ @@ -20,26 +20,25 @@ static lua_State *getco (lua_State *L) { lua_State *co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "thread expected"); + luaL_argexpected(L, co, 1, "thread"); return co; } +/* +** Resumes a coroutine. Returns the number of results for non-error +** cases or -1 for errors. +*/ static int auxresume (lua_State *L, lua_State *co, int narg) { - int status; - if (!lua_checkstack(co, narg)) { + int status, nres; + if (l_unlikely(!lua_checkstack(co, narg))) { lua_pushliteral(L, "too many arguments to resume"); return -1; /* error flag */ } - if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { - lua_pushliteral(L, "cannot resume dead coroutine"); - return -1; /* error flag */ - } lua_xmove(L, co, narg); - status = lua_resume(co, L, narg); - if (status == LUA_OK || status == LUA_YIELD) { - int nres = lua_gettop(co); - if (!lua_checkstack(L, nres + 1)) { + status = lua_resume(co, L, narg, &nres); + if (l_likely(status == LUA_OK || status == LUA_YIELD)) { + if (l_unlikely(!lua_checkstack(L, nres + 1))) { lua_pop(co, nres); /* remove results anyway */ lua_pushliteral(L, "too many results to resume"); return -1; /* error flag */ @@ -58,7 +57,7 @@ static int luaB_coresume (lua_State *L) { lua_State *co = getco(L); int r; r = auxresume(L, co, lua_gettop(L) - 1); - if (r < 0) { + if (l_unlikely(r < 0)) { lua_pushboolean(L, 0); lua_insert(L, -2); return 2; /* return false + error message */ @@ -74,9 +73,16 @@ static int luaB_coresume (lua_State *L) { static int luaB_auxwrap (lua_State *L) { lua_State *co = lua_tothread(L, lua_upvalueindex(1)); int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { - if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ - luaL_where(L, 1); /* add extra info */ + if (l_unlikely(r < 0)) { /* error? */ + int stat = lua_status(co); + if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ + stat = lua_closethread(co, L); /* close its tbc variables */ + lua_assert(stat != LUA_OK); + lua_xmove(co, L, 1); /* move error message to the caller */ + } + if (stat != LUA_ERRMEM && /* not a memory error and ... */ + lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ + luaL_where(L, 1); /* add extra info, if available */ lua_insert(L, -2); lua_concat(L, 2); } @@ -108,35 +114,48 @@ static int luaB_yield (lua_State *L) { } -static int luaB_costatus (lua_State *L) { - lua_State *co = getco(L); - if (L == co) lua_pushliteral(L, "running"); +#define COS_RUN 0 +#define COS_DEAD 1 +#define COS_YIELD 2 +#define COS_NORM 3 + + +static const char *const statname[] = + {"running", "dead", "suspended", "normal"}; + + +static int auxstatus (lua_State *L, lua_State *co) { + if (L == co) return COS_RUN; else { switch (lua_status(co)) { case LUA_YIELD: - lua_pushliteral(L, "suspended"); - break; + return COS_YIELD; case LUA_OK: { lua_Debug ar; - if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ - lua_pushliteral(L, "normal"); /* it is running */ + if (lua_getstack(co, 0, &ar)) /* does it have frames? */ + return COS_NORM; /* it is running */ else if (lua_gettop(co) == 0) - lua_pushliteral(L, "dead"); + return COS_DEAD; else - lua_pushliteral(L, "suspended"); /* initial state */ - break; + return COS_YIELD; /* initial state */ } default: /* some error occurred */ - lua_pushliteral(L, "dead"); - break; + return COS_DEAD; } } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = getco(L); + lua_pushstring(L, statname[auxstatus(L, co)]); return 1; } static int luaB_yieldable (lua_State *L) { - lua_pushboolean(L, lua_isyieldable(L)); + lua_State *co = lua_isnone(L, 1) ? L : getco(L); + lua_pushboolean(L, lua_isyieldable(co)); return 1; } @@ -148,6 +167,28 @@ static int luaB_corunning (lua_State *L) { } +static int luaB_close (lua_State *L) { + lua_State *co = getco(L); + int status = auxstatus(L, co); + switch (status) { + case COS_DEAD: case COS_YIELD: { + status = lua_closethread(co, L); + if (status == LUA_OK) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushboolean(L, 0); + lua_xmove(co, L, 1); /* move error message */ + return 2; + } + } + default: /* normal or running coroutine */ + return luaL_error(L, "cannot close a %s coroutine", statname[status]); + } +} + + static const luaL_Reg co_funcs[] = { {"create", luaB_cocreate}, {"resume", luaB_coresume}, @@ -156,6 +197,7 @@ static const luaL_Reg co_funcs[] = { {"wrap", luaB_cowrap}, {"yield", luaB_yield}, {"isyieldable", luaB_yieldable}, + {"close", luaB_close}, {NULL, NULL} }; diff --git a/liblua/lctype.c b/liblua/lctype.c index f8ad7a2e..95422809 100644 --- a/liblua/lctype.c +++ b/liblua/lctype.c @@ -1,5 +1,5 @@ /* -** $Id: lctype.c,v 1.12.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lctype.c $ ** 'ctype' functions for Lua ** See Copyright Notice in lua.h */ @@ -16,6 +16,15 @@ #include + +#if defined (LUA_UCID) /* accept UniCode IDentifiers? */ +/* consider all non-ascii codepoints to be alphabetic */ +#define NONA 0x01 +#else +#define NONA 0x00 /* default */ +#endif + + LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 0x00, /* EOZ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ @@ -34,22 +43,22 @@ LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 8. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 9. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* a. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* b. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + 0x00, 0x00, NONA, NONA, NONA, NONA, NONA, NONA, /* c. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* d. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* e. */ + NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, + NONA, NONA, NONA, NONA, NONA, 0x00, 0x00, 0x00, /* f. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #endif /* } */ diff --git a/liblua/lctype.h b/liblua/lctype.h index b09b21a3..864e1901 100644 --- a/liblua/lctype.h +++ b/liblua/lctype.h @@ -1,5 +1,5 @@ /* -** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: lctype.h $ ** 'ctype' functions for Lua ** See Copyright Notice in lua.h */ @@ -13,7 +13,7 @@ /* ** WARNING: the functions defined here do not necessarily correspond ** to the similar functions in the standard C ctype.h. They are -** optimized for the specific needs of Lua +** optimized for the specific needs of Lua. */ #if !defined(LUA_USE_CTYPE) @@ -61,14 +61,20 @@ #define lisprint(c) testprop(c, MASK(PRINTBIT)) #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) + /* -** this 'ltolower' only works for alphabetic characters +** In ASCII, this 'ltolower' is correct for alphabetic characters and +** for '.'. That is enough for Lua needs. ('check_exp' ensures that +** the character either is an upper-case letter or is unchanged by +** the transformation, which holds for lower-case letters and '.'.) */ -#define ltolower(c) ((c) | ('A' ^ 'a')) +#define ltolower(c) \ + check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \ + (c) | ('A' ^ 'a')) -/* two more entries for 0 and -1 (EOZ) */ -LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; +/* one entry for each character and for -1 (EOZ) */ +LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) #else /* }{ */ diff --git a/liblua/ldblib.c b/liblua/ldblib.c index 9d29afb0..6dcbaa98 100644 --- a/liblua/ldblib.c +++ b/liblua/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.151.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ldblib.c $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -21,10 +21,10 @@ /* -** The hook table at registry[&HOOKKEY] maps threads to their current -** hook function. (We only need the unique address of 'HOOKKEY'.) +** The hook table at registry[HOOKKEY] maps threads to their current +** hook function. */ -static const int HOOKKEY = 0; +static const char *const HOOKKEY = "_HOOKKEY"; /* @@ -33,7 +33,7 @@ static const int HOOKKEY = 0; ** checked. */ static void checkstack (lua_State *L, lua_State *L1, int n) { - if (L != L1 && !lua_checkstack(L1, n)) + if (l_unlikely(L != L1 && !lua_checkstack(L1, n))) luaL_error(L, "stack overflow"); } @@ -55,8 +55,7 @@ static int db_getmetatable (lua_State *L) { static int db_setmetatable (lua_State *L) { int t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); + luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table"); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; /* return 1st argument */ @@ -64,19 +63,24 @@ static int db_setmetatable (lua_State *L) { static int db_getuservalue (lua_State *L) { + int n = (int)luaL_optinteger(L, 2, 1); if (lua_type(L, 1) != LUA_TUSERDATA) - lua_pushnil(L); - else - lua_getuservalue(L, 1); + luaL_pushfail(L); + else if (lua_getiuservalue(L, 1, n) != LUA_TNONE) { + lua_pushboolean(L, 1); + return 2; + } return 1; } static int db_setuservalue (lua_State *L) { + int n = (int)luaL_optinteger(L, 3, 1); luaL_checktype(L, 1, LUA_TUSERDATA); luaL_checkany(L, 2); lua_settop(L, 2); - lua_setuservalue(L, 1); + if (!lua_setiuservalue(L, 1, n)) + luaL_pushfail(L); return 1; } @@ -146,8 +150,9 @@ static int db_getinfo (lua_State *L) { lua_Debug ar; int arg; lua_State *L1 = getthread(L, &arg); - const char *options = luaL_optstring(L, arg+2, "flnStu"); + const char *options = luaL_optstring(L, arg+2, "flnSrtu"); checkstack(L, L1, 3); + luaL_argcheck(L, options[0] != '>', arg + 2, "invalid option '>'"); if (lua_isfunction(L, arg + 1)) { /* info about a function? */ options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */ lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ @@ -155,7 +160,7 @@ static int db_getinfo (lua_State *L) { } else { /* stack level */ if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) { - lua_pushnil(L); /* level out of range */ + luaL_pushfail(L); /* level out of range */ return 1; } } @@ -163,7 +168,8 @@ static int db_getinfo (lua_State *L) { return luaL_argerror(L, arg+2, "invalid option"); lua_newtable(L); /* table to collect results */ if (strchr(options, 'S')) { - settabss(L, "source", ar.source); + lua_pushlstring(L, ar.source, ar.srclen); + lua_setfield(L, -2, "source"); settabss(L, "short_src", ar.short_src); settabsi(L, "linedefined", ar.linedefined); settabsi(L, "lastlinedefined", ar.lastlinedefined); @@ -180,6 +186,10 @@ static int db_getinfo (lua_State *L) { settabss(L, "name", ar.name); settabss(L, "namewhat", ar.namewhat); } + if (strchr(options, 'r')) { + settabsi(L, "ftransfer", ar.ftransfer); + settabsi(L, "ntransfer", ar.ntransfer); + } if (strchr(options, 't')) settabsb(L, "istailcall", ar.istailcall); if (strchr(options, 'L')) @@ -193,8 +203,6 @@ static int db_getinfo (lua_State *L) { static int db_getlocal (lua_State *L) { int arg; lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - const char *name; int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */ if (lua_isfunction(L, arg + 1)) { /* function argument? */ lua_pushvalue(L, arg + 1); /* push function */ @@ -202,8 +210,10 @@ static int db_getlocal (lua_State *L) { return 1; /* return only name (there is no value) */ } else { /* stack-level argument */ + lua_Debug ar; + const char *name; int level = (int)luaL_checkinteger(L, arg + 1); - if (!lua_getstack(L1, level, &ar)) /* out of range? */ + if (l_unlikely(!lua_getstack(L1, level, &ar))) /* out of range? */ return luaL_argerror(L, arg+1, "level out of range"); checkstack(L, L1, 1); name = lua_getlocal(L1, &ar, nvar); @@ -214,7 +224,7 @@ static int db_getlocal (lua_State *L) { return 2; } else { - lua_pushnil(L); /* no name (nor value) */ + luaL_pushfail(L); /* no name (nor value) */ return 1; } } @@ -228,7 +238,7 @@ static int db_setlocal (lua_State *L) { lua_Debug ar; int level = (int)luaL_checkinteger(L, arg + 1); int nvar = (int)luaL_checkinteger(L, arg + 2); - if (!lua_getstack(L1, level, &ar)) /* out of range? */ + if (l_unlikely(!lua_getstack(L1, level, &ar))) /* out of range? */ return luaL_argerror(L, arg+1, "level out of range"); luaL_checkany(L, arg+3); lua_settop(L, arg+3); @@ -272,25 +282,33 @@ static int db_setupvalue (lua_State *L) { ** Check whether a given upvalue from a given closure exists and ** returns its index */ -static int checkupval (lua_State *L, int argf, int argnup) { +static void *checkupval (lua_State *L, int argf, int argnup, int *pnup) { + void *id; int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */ luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ - luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup, - "invalid upvalue index"); - return nup; + id = lua_upvalueid(L, argf, nup); + if (pnup) { + luaL_argcheck(L, id != NULL, argnup, "invalid upvalue index"); + *pnup = nup; + } + return id; } static int db_upvalueid (lua_State *L) { - int n = checkupval(L, 1, 2); - lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); + void *id = checkupval(L, 1, 2, NULL); + if (id != NULL) + lua_pushlightuserdata(L, id); + else + luaL_pushfail(L); return 1; } static int db_upvaluejoin (lua_State *L) { - int n1 = checkupval(L, 1, 2); - int n2 = checkupval(L, 3, 4); + int n1, n2; + checkupval(L, 1, 2, &n1); + checkupval(L, 3, 4, &n2); luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); lua_upvaluejoin(L, 1, n1, 3, n2); @@ -305,7 +323,7 @@ static int db_upvaluejoin (lua_State *L) { static void hookf (lua_State *L, lua_Debug *ar) { static const char *const hooknames[] = {"call", "return", "line", "count", "tail call"}; - lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY); + lua_getfield(L, LUA_REGISTRYINDEX, HOOKKEY); lua_pushthread(L); if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */ lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */ @@ -358,14 +376,12 @@ static int db_sethook (lua_State *L) { count = (int)luaL_optinteger(L, arg + 3, 0); func = hookf; mask = makemask(smask, count); } - if (lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY) == LUA_TNIL) { - lua_createtable(L, 0, 2); /* create a hook table */ - lua_pushvalue(L, -1); - lua_rawsetp(L, LUA_REGISTRYINDEX, &HOOKKEY); /* set it in position */ - lua_pushstring(L, "k"); + if (!luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY)) { + /* table just created; initialize it */ + lua_pushliteral(L, "k"); lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ lua_pushvalue(L, -1); - lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ + lua_setmetatable(L, -2); /* metatable(hooktable) = hooktable */ } checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); /* key (thread) */ @@ -382,12 +398,14 @@ static int db_gethook (lua_State *L) { char buff[5]; int mask = lua_gethookmask(L1); lua_Hook hook = lua_gethook(L1); - if (hook == NULL) /* no hook? */ - lua_pushnil(L); + if (hook == NULL) { /* no hook? */ + luaL_pushfail(L); + return 1; + } else if (hook != hookf) /* external hook? */ lua_pushliteral(L, "external hook"); else { /* hook table must exist */ - lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY); + lua_getfield(L, LUA_REGISTRYINDEX, HOOKKEY); checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_rawget(L, -2); /* 1st result = hooktable[L1] */ @@ -403,12 +421,12 @@ static int db_debug (lua_State *L) { for (;;) { char buffer[250]; lua_writestringerror("%s", "lua_debug> "); - if (fgets(buffer, sizeof(buffer), stdin) == 0 || + if (fgets(buffer, sizeof(buffer), stdin) == NULL || strcmp(buffer, "cont\n") == 0) return 0; if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || lua_pcall(L, 0, 0, 0)) - lua_writestringerror("%s\n", lua_tostring(L, -1)); + lua_writestringerror("%s\n", luaL_tolstring(L, -1, NULL)); lua_settop(L, 0); /* remove eventual returns */ } } @@ -428,6 +446,14 @@ static int db_traceback (lua_State *L) { } +static int db_setcstacklimit (lua_State *L) { + int limit = (int)luaL_checkinteger(L, 1); + int res = lua_setcstacklimit(L, limit); + lua_pushinteger(L, res); + return 1; +} + + static const luaL_Reg dblib[] = { {"debug", db_debug}, {"getuservalue", db_getuservalue}, @@ -445,6 +471,7 @@ static const luaL_Reg dblib[] = { {"setmetatable", db_setmetatable}, {"setupvalue", db_setupvalue}, {"traceback", db_traceback}, + {"setcstacklimit", db_setcstacklimit}, {NULL, NULL} }; diff --git a/liblua/ldebug.c b/liblua/ldebug.c index e1389296..591b3528 100644 --- a/liblua/ldebug.c +++ b/liblua/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.121.1.2 2017/07/10 17:21:50 roberto Exp $ +** $Id: ldebug.c $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -31,15 +31,11 @@ -#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL) +#define LuaClosure(f) ((f) != NULL && (f)->c.tt == LUA_VLCL) -/* Active Lua function (given call info) */ -#define ci_func(ci) (clLvalue((ci)->func)) - - -static const char *funcnamefromcode (lua_State *L, CallInfo *ci, - const char **name); +static const char *funcnamefromcall (lua_State *L, CallInfo *ci, + const char **name); static int currentpc (CallInfo *ci) { @@ -48,47 +44,101 @@ static int currentpc (CallInfo *ci) { } -static int currentline (CallInfo *ci) { - return getfuncline(ci_func(ci)->p, currentpc(ci)); +/* +** Get a "base line" to find the line corresponding to an instruction. +** Base lines are regularly placed at MAXIWTHABS intervals, so usually +** an integer division gets the right place. When the source file has +** large sequences of empty/comment lines, it may need extra entries, +** so the original estimate needs a correction. +** If the original estimate is -1, the initial 'if' ensures that the +** 'while' will run at least once. +** The assertion that the estimate is a lower bound for the correct base +** is valid as long as the debug info has been generated with the same +** value for MAXIWTHABS or smaller. (Previous releases use a little +** smaller value.) +*/ +static int getbaseline (const Proto *f, int pc, int *basepc) { + if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) { + *basepc = -1; /* start from the beginning */ + return f->linedefined; + } + else { + int i = cast_uint(pc) / MAXIWTHABS - 1; /* get an estimate */ + /* estimate must be a lower bound of the correct base */ + lua_assert(i < 0 || + (i < f->sizeabslineinfo && f->abslineinfo[i].pc <= pc)); + while (i + 1 < f->sizeabslineinfo && pc >= f->abslineinfo[i + 1].pc) + i++; /* low estimate; adjust it */ + *basepc = f->abslineinfo[i].pc; + return f->abslineinfo[i].line; + } } /* -** If function yielded, its 'func' can be in the 'extra' field. The -** next function restores 'func' to its correct value for debugging -** purposes. (It exchanges 'func' and 'extra'; so, when called again, -** after debugging, it also "re-restores" ** 'func' to its altered value. +** Get the line corresponding to instruction 'pc' in function 'f'; +** first gets a base line and from there does the increments until +** the desired instruction. */ -static void swapextra (lua_State *L) { - if (L->status == LUA_YIELD) { - CallInfo *ci = L->ci; /* get function that yielded */ - StkId temp = ci->func; /* exchange its 'func' and 'extra' values */ - ci->func = restorestack(L, ci->extra); - ci->extra = savestack(L, temp); +int luaG_getfuncline (const Proto *f, int pc) { + if (f->lineinfo == NULL) /* no debug information? */ + return -1; + else { + int basepc; + int baseline = getbaseline(f, pc, &basepc); + while (basepc++ < pc) { /* walk until given instruction */ + lua_assert(f->lineinfo[basepc] != ABSLINEINFO); + baseline += f->lineinfo[basepc]; /* correct line */ + } + return baseline; } } +static int getcurrentline (CallInfo *ci) { + return luaG_getfuncline(ci_func(ci)->p, currentpc(ci)); +} + + +/* +** Set 'trap' for all active Lua frames. +** This function can be called during a signal, under "reasonable" +** assumptions. A new 'ci' is completely linked in the list before it +** becomes part of the "active" list, and we assume that pointers are +** atomic; see comment in next function. +** (A compiler doing interprocedural optimizations could, theoretically, +** reorder memory writes in such a way that the list could be +** temporarily broken while inserting a new element. We simply assume it +** has no good reasons to do that.) +*/ +static void settraps (CallInfo *ci) { + for (; ci != NULL; ci = ci->previous) + if (isLua(ci)) + ci->u.l.trap = 1; +} + + /* -** This function can be called asynchronously (e.g. during a signal). -** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by -** 'resethookcount') are for debug only, and it is no problem if they -** get arbitrary values (causes at most one wrong hook call). 'hookmask' -** is an atomic value. We assume that pointers are atomic too (e.g., gcc -** ensures that for all platforms where it runs). Moreover, 'hook' is -** always checked before being called (see 'luaD_hook'). +** This function can be called during a signal, under "reasonable" +** assumptions. +** Fields 'basehookcount' and 'hookcount' (set by 'resethookcount') +** are for debug only, and it is no problem if they get arbitrary +** values (causes at most one wrong hook call). 'hookmask' is an atomic +** value. We assume that pointers are atomic too (e.g., gcc ensures that +** for all platforms where it runs). Moreover, 'hook' is always checked +** before being called (see 'luaD_hook'). */ LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { if (func == NULL || mask == 0) { /* turn off hooks? */ mask = 0; func = NULL; } - if (isLua(L->ci)) - L->oldpc = L->ci->u.l.savedpc; L->hook = func; L->basehookcount = count; resethookcount(L); L->hookmask = cast_byte(mask); + if (mask) + settraps(L->ci); /* to trace inside 'luaV_execute' */ } @@ -124,7 +174,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { } -static const char *upvalname (Proto *p, int uv) { +static const char *upvalname (const Proto *p, int uv) { TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); if (s == NULL) return "?"; else return getstr(s); @@ -132,38 +182,37 @@ static const char *upvalname (Proto *p, int uv) { static const char *findvararg (CallInfo *ci, int n, StkId *pos) { - int nparams = clLvalue(ci->func)->p->numparams; - if (n >= cast_int(ci->u.l.base - ci->func) - nparams) - return NULL; /* no such vararg */ - else { - *pos = ci->func + nparams + n; - return "(*vararg)"; /* generic name for any vararg */ + if (clLvalue(s2v(ci->func.p))->p->is_vararg) { + int nextra = ci->u.l.nextraargs; + if (n >= -nextra) { /* 'n' is negative */ + *pos = ci->func.p - nextra - (n + 1); + return "(vararg)"; /* generic name for any vararg */ + } } + return NULL; /* no such vararg */ } -static const char *findlocal (lua_State *L, CallInfo *ci, int n, - StkId *pos) { +const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { + StkId base = ci->func.p + 1; const char *name = NULL; - StkId base; if (isLua(ci)) { if (n < 0) /* access to vararg values? */ - return findvararg(ci, -n, pos); - else { - base = ci->u.l.base; + return findvararg(ci, n, pos); + else name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); - } } - else - base = ci->func + 1; if (name == NULL) { /* no 'standard' name? */ - StkId limit = (ci == L->ci) ? L->top : ci->next->func; - if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - name = "(*temporary)"; /* generic name for any valid slot */ + StkId limit = (ci == L->ci) ? L->top.p : ci->next->func.p; + if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */ + /* generic name for any valid slot */ + name = isLua(ci) ? "(temporary)" : "(C temporary)"; + } else return NULL; /* no name */ } - *pos = base + (n - 1); + if (pos) + *pos = base + (n - 1); return name; } @@ -171,22 +220,20 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n, LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { const char *name; lua_lock(L); - swapextra(L); if (ar == NULL) { /* information about non-active function? */ - if (!isLfunction(L->top - 1)) /* not a Lua function? */ + if (!isLfunction(s2v(L->top.p - 1))) /* not a Lua function? */ name = NULL; else /* consider live variables at function start (parameters) */ - name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); + name = luaF_getlocalname(clLvalue(s2v(L->top.p - 1))->p, n, 0); } else { /* active function; get information through 'ar' */ StkId pos = NULL; /* to avoid warnings */ - name = findlocal(L, ar->i_ci, n, &pos); + name = luaG_findlocal(L, ar->i_ci, n, &pos); if (name) { - setobj2s(L, L->top, pos); + setobjs2s(L, L->top.p, pos); api_incr_top(L); } } - swapextra(L); lua_unlock(L); return name; } @@ -196,65 +243,85 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { StkId pos = NULL; /* to avoid warnings */ const char *name; lua_lock(L); - swapextra(L); - name = findlocal(L, ar->i_ci, n, &pos); + name = luaG_findlocal(L, ar->i_ci, n, &pos); if (name) { - setobjs2s(L, pos, L->top - 1); - L->top--; /* pop value */ + setobjs2s(L, pos, L->top.p - 1); + L->top.p--; /* pop value */ } - swapextra(L); lua_unlock(L); return name; } static void funcinfo (lua_Debug *ar, Closure *cl) { - if (noLuaClosure(cl)) { + if (!LuaClosure(cl)) { ar->source = "=[C]"; + ar->srclen = LL("=[C]"); ar->linedefined = -1; ar->lastlinedefined = -1; ar->what = "C"; } else { - Proto *p = cl->l.p; - ar->source = p->source ? getstr(p->source) : "=?"; + const Proto *p = cl->l.p; + if (p->source) { + ar->source = getstr(p->source); + ar->srclen = tsslen(p->source); + } + else { + ar->source = "=?"; + ar->srclen = LL("=?"); + } ar->linedefined = p->linedefined; ar->lastlinedefined = p->lastlinedefined; ar->what = (ar->linedefined == 0) ? "main" : "Lua"; } - luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + luaO_chunkid(ar->short_src, ar->source, ar->srclen); +} + + +static int nextline (const Proto *p, int currentline, int pc) { + if (p->lineinfo[pc] != ABSLINEINFO) + return currentline + p->lineinfo[pc]; + else + return luaG_getfuncline(p, pc); } static void collectvalidlines (lua_State *L, Closure *f) { - if (noLuaClosure(f)) { - setnilvalue(L->top); + if (!LuaClosure(f)) { + setnilvalue(s2v(L->top.p)); api_incr_top(L); } else { - int i; - TValue v; - int *lineinfo = f->l.p->lineinfo; + const Proto *p = f->l.p; + int currentline = p->linedefined; Table *t = luaH_new(L); /* new table to store active lines */ - sethvalue(L, L->top, t); /* push it on stack */ + sethvalue2s(L, L->top.p, t); /* push it on stack */ api_incr_top(L); - setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ - for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ - luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ + if (p->lineinfo != NULL) { /* proto with debug information? */ + int i; + TValue v; + setbtvalue(&v); /* boolean 'true' to be the value of all indices */ + if (!p->is_vararg) /* regular function? */ + i = 0; /* consider all instructions */ + else { /* vararg function */ + lua_assert(GET_OPCODE(p->code[0]) == OP_VARARGPREP); + currentline = nextline(p, currentline, 0); + i = 1; /* skip first instruction (OP_VARARGPREP) */ + } + for (; i < p->sizelineinfo; i++) { /* for each instruction */ + currentline = nextline(p, currentline, i); /* get its line */ + luaH_setint(L, t, currentline, &v); /* table[line] = true */ + } + } } } static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { - if (ci == NULL) /* no 'ci'? */ - return NULL; /* no info */ - else if (ci->callstatus & CIST_FIN) { /* is this a finalizer? */ - *name = "__gc"; - return "metamethod"; /* report it as such */ - } - /* calling function is a known Lua function? */ - else if (!(ci->callstatus & CIST_TAIL) && isLua(ci->previous)) - return funcnamefromcode(L, ci->previous, name); + /* calling function is a known function? */ + if (ci != NULL && !(ci->callstatus & CIST_TAIL)) + return funcnamefromcall(L, ci->previous, name); else return NULL; /* no way to find a name */ } @@ -269,12 +336,12 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, break; } case 'l': { - ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; + ar->currentline = (ci && isLua(ci)) ? getcurrentline(ci) : -1; break; } case 'u': { ar->nups = (f == NULL) ? 0 : f->c.nupvalues; - if (noLuaClosure(f)) { + if (!LuaClosure(f)) { ar->isvararg = 1; ar->nparams = 0; } @@ -296,6 +363,15 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, } break; } + case 'r': { + if (ci == NULL || !(ci->callstatus & CIST_TRAN)) + ar->ftransfer = ar->ntransfer = 0; + else { + ar->ftransfer = ci->u2.transferinfo.ftransfer; + ar->ntransfer = ci->u2.transferinfo.ntransfer; + } + break; + } case 'L': case 'f': /* handled by lua_getinfo */ break; @@ -310,28 +386,26 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { int status; Closure *cl; CallInfo *ci; - StkId func; + TValue *func; lua_lock(L); - swapextra(L); if (*what == '>') { ci = NULL; - func = L->top - 1; + func = s2v(L->top.p - 1); api_check(L, ttisfunction(func), "function expected"); what++; /* skip the '>' */ - L->top--; /* pop function */ + L->top.p--; /* pop function */ } else { ci = ar->i_ci; - func = ci->func; - lua_assert(ttisfunction(ci->func)); + func = s2v(ci->func.p); + lua_assert(ttisfunction(func)); } cl = ttisclosure(func) ? clvalue(func) : NULL; status = auxgetinfo(L, what, ar, cl, ci); if (strchr(what, 'f')) { - setobjs2s(L, L->top, func); + setobj2s(L, L->top.p, func); api_incr_top(L); } - swapextra(L); /* correct before option 'L', which can raise a mem. error */ if (strchr(what, 'L')) collectvalidlines(L, cl); lua_unlock(L); @@ -345,32 +419,6 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { ** ======================================================= */ -static const char *getobjname (Proto *p, int lastpc, int reg, - const char **name); - - -/* -** find a "name" for the RK value 'c' -*/ -static void kname (Proto *p, int pc, int c, const char **name) { - if (ISK(c)) { /* is 'c' a constant? */ - TValue *kvalue = &p->k[INDEXK(c)]; - if (ttisstring(kvalue)) { /* literal constant? */ - *name = svalue(kvalue); /* it is its own name */ - return; - } - /* else no reasonable name found */ - } - else { /* 'c' is a register */ - const char *what = getobjname(p, pc, c, name); /* search for 'c' */ - if (what && *what == 'c') { /* found a constant name? */ - return; /* 'name' already filled */ - } - /* else no reasonable name found */ - } - *name = "?"; /* no reasonable name found */ -} - static int filterpc (int pc, int jmptarget) { if (pc < jmptarget) /* is code conditional (inside a jump)? */ @@ -380,62 +428,78 @@ static int filterpc (int pc, int jmptarget) { /* -** try to find last instruction before 'lastpc' that modified register 'reg' +** Try to find last instruction before 'lastpc' that modified register 'reg'. */ -static int findsetreg (Proto *p, int lastpc, int reg) { +static int findsetreg (const Proto *p, int lastpc, int reg) { int pc; int setreg = -1; /* keep last instruction that changed 'reg' */ int jmptarget = 0; /* any code before this address is conditional */ + if (testMMMode(GET_OPCODE(p->code[lastpc]))) + lastpc--; /* previous instruction was not actually executed */ for (pc = 0; pc < lastpc; pc++) { Instruction i = p->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); + int change; /* true if current instruction changed 'reg' */ switch (op) { - case OP_LOADNIL: { + case OP_LOADNIL: { /* set registers from 'a' to 'a+b' */ int b = GETARG_B(i); - if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ - setreg = filterpc(pc, jmptarget); + change = (a <= reg && reg <= a + b); break; } - case OP_TFORCALL: { - if (reg >= a + 2) /* affect all regs above its base */ - setreg = filterpc(pc, jmptarget); + case OP_TFORCALL: { /* affect all regs above its base */ + change = (reg >= a + 2); break; } case OP_CALL: - case OP_TAILCALL: { - if (reg >= a) /* affect all registers above base */ - setreg = filterpc(pc, jmptarget); + case OP_TAILCALL: { /* affect all registers above base */ + change = (reg >= a); break; } - case OP_JMP: { - int b = GETARG_sBx(i); + case OP_JMP: { /* doesn't change registers, but changes 'jmptarget' */ + int b = GETARG_sJ(i); int dest = pc + 1 + b; - /* jump is forward and do not skip 'lastpc'? */ - if (pc < dest && dest <= lastpc) { - if (dest > jmptarget) - jmptarget = dest; /* update 'jmptarget' */ - } + /* jump does not skip 'lastpc' and is larger than current one? */ + if (dest <= lastpc && dest > jmptarget) + jmptarget = dest; /* update 'jmptarget' */ + change = 0; break; } - default: - if (testAMode(op) && reg == a) /* any instruction that set A */ - setreg = filterpc(pc, jmptarget); + default: /* any instruction that sets A */ + change = (testAMode(op) && reg == a); break; } + if (change) + setreg = filterpc(pc, jmptarget); } return setreg; } -static const char *getobjname (Proto *p, int lastpc, int reg, - const char **name) { - int pc; - *name = luaF_getlocalname(p, reg + 1, lastpc); +/* +** Find a "name" for the constant 'c'. +*/ +static const char *kname (const Proto *p, int index, const char **name) { + TValue *kvalue = &p->k[index]; + if (ttisstring(kvalue)) { + *name = getstr(tsvalue(kvalue)); + return "constant"; + } + else { + *name = "?"; + return NULL; + } +} + + +static const char *basicgetobjname (const Proto *p, int *ppc, int reg, + const char **name) { + int pc = *ppc; + *name = luaF_getlocalname(p, reg + 1, pc); if (*name) /* is a local? */ return "local"; /* else try symbolic execution */ - pc = findsetreg(p, lastpc, reg); + *ppc = pc = findsetreg(p, pc, reg); if (pc != -1) { /* could find instruction? */ Instruction i = p->code[pc]; OpCode op = GET_OPCODE(i); @@ -443,36 +507,92 @@ static const char *getobjname (Proto *p, int lastpc, int reg, case OP_MOVE: { int b = GETARG_B(i); /* move from 'b' to 'a' */ if (b < GETARG_A(i)) - return getobjname(p, pc, b, name); /* get name for 'b' */ + return basicgetobjname(p, ppc, b, name); /* get name for 'b' */ break; } - case OP_GETTABUP: - case OP_GETTABLE: { - int k = GETARG_C(i); /* key index */ - int t = GETARG_B(i); /* table index */ - const char *vn = (op == OP_GETTABLE) /* name of indexed variable */ - ? luaF_getlocalname(p, t + 1, pc) - : upvalname(p, t); - kname(p, pc, k, name); - return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"; - } case OP_GETUPVAL: { *name = upvalname(p, GETARG_B(i)); return "upvalue"; } - case OP_LOADK: - case OP_LOADKX: { - int b = (op == OP_LOADK) ? GETARG_Bx(i) - : GETARG_Ax(p->code[pc + 1]); - if (ttisstring(&p->k[b])) { - *name = svalue(&p->k[b]); - return "constant"; - } - break; + case OP_LOADK: return kname(p, GETARG_Bx(i), name); + case OP_LOADKX: return kname(p, GETARG_Ax(p->code[pc + 1]), name); + default: break; + } + } + return NULL; /* could not find reasonable name */ +} + + +/* +** Find a "name" for the register 'c'. +*/ +static void rname (const Proto *p, int pc, int c, const char **name) { + const char *what = basicgetobjname(p, &pc, c, name); /* search for 'c' */ + if (!(what && *what == 'c')) /* did not find a constant name? */ + *name = "?"; +} + + +/* +** Find a "name" for a 'C' value in an RK instruction. +*/ +static void rkname (const Proto *p, int pc, Instruction i, const char **name) { + int c = GETARG_C(i); /* key index */ + if (GETARG_k(i)) /* is 'c' a constant? */ + kname(p, c, name); + else /* 'c' is a register */ + rname(p, pc, c, name); +} + + +/* +** Check whether table being indexed by instruction 'i' is the +** environment '_ENV' +*/ +static const char *isEnv (const Proto *p, int pc, Instruction i, int isup) { + int t = GETARG_B(i); /* table index */ + const char *name; /* name of indexed variable */ + if (isup) /* is 't' an upvalue? */ + name = upvalname(p, t); + else /* 't' is a register */ + basicgetobjname(p, &pc, t, &name); + return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field"; +} + + +/* +** Extend 'basicgetobjname' to handle table accesses +*/ +static const char *getobjname (const Proto *p, int lastpc, int reg, + const char **name) { + const char *kind = basicgetobjname(p, &lastpc, reg, name); + if (kind != NULL) + return kind; + else if (lastpc != -1) { /* could find instruction? */ + Instruction i = p->code[lastpc]; + OpCode op = GET_OPCODE(i); + switch (op) { + case OP_GETTABUP: { + int k = GETARG_C(i); /* key index */ + kname(p, k, name); + return isEnv(p, lastpc, i, 1); } - case OP_SELF: { + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + rname(p, lastpc, k, name); + return isEnv(p, lastpc, i, 0); + } + case OP_GETI: { + *name = "integer index"; + return "field"; + } + case OP_GETFIELD: { int k = GETARG_C(i); /* key index */ - kname(p, pc, k, name); + kname(p, k, name); + return isEnv(p, lastpc, i, 0); + } + case OP_SELF: { + rkname(p, lastpc, i, name); return "method"; } default: break; /* go through to return NULL */ @@ -488,16 +608,10 @@ static const char *getobjname (Proto *p, int lastpc, int reg, ** Returns what the name is (e.g., "for iterator", "method", ** "metamethod") and sets '*name' to point to the name. */ -static const char *funcnamefromcode (lua_State *L, CallInfo *ci, - const char **name) { +static const char *funcnamefromcode (lua_State *L, const Proto *p, + int pc, const char **name) { TMS tm = (TMS)0; /* (initial value avoids warnings) */ - Proto *p = ci_func(ci)->p; /* calling function */ - int pc = currentpc(ci); /* calling instruction index */ Instruction i = p->code[pc]; /* calling instruction */ - if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */ - *name = "?"; - return "hook"; - } switch (GET_OPCODE(i)) { case OP_CALL: case OP_TAILCALL: @@ -508,16 +622,14 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci, } /* other instructions can do calls through metamethods */ case OP_SELF: case OP_GETTABUP: case OP_GETTABLE: + case OP_GETI: case OP_GETFIELD: tm = TM_INDEX; break; - case OP_SETTABUP: case OP_SETTABLE: + case OP_SETTABUP: case OP_SETTABLE: case OP_SETI: case OP_SETFIELD: tm = TM_NEWINDEX; break; - case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD: - case OP_POW: case OP_DIV: case OP_IDIV: case OP_BAND: - case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: { - int offset = cast_int(GET_OPCODE(i)) - cast_int(OP_ADD); /* ORDER OP */ - tm = cast(TMS, offset + cast_int(TM_ADD)); /* ORDER TM */ + case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: { + tm = cast(TMS, GETARG_C(i)); break; } case OP_UNM: tm = TM_UNM; break; @@ -525,27 +637,55 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci, case OP_LEN: tm = TM_LEN; break; case OP_CONCAT: tm = TM_CONCAT; break; case OP_EQ: tm = TM_EQ; break; - case OP_LT: tm = TM_LT; break; - case OP_LE: tm = TM_LE; break; + /* no cases for OP_EQI and OP_EQK, as they don't call metamethods */ + case OP_LT: case OP_LTI: case OP_GTI: tm = TM_LT; break; + case OP_LE: case OP_LEI: case OP_GEI: tm = TM_LE; break; + case OP_CLOSE: case OP_RETURN: tm = TM_CLOSE; break; default: return NULL; /* cannot find a reasonable name */ } - *name = getstr(G(L)->tmname[tm]); + *name = getshrstr(G(L)->tmname[tm]) + 2; return "metamethod"; } + +/* +** Try to find a name for a function based on how it was called. +*/ +static const char *funcnamefromcall (lua_State *L, CallInfo *ci, + const char **name) { + if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */ + *name = "?"; + return "hook"; + } + else if (ci->callstatus & CIST_FIN) { /* was it called as a finalizer? */ + *name = "__gc"; + return "metamethod"; /* report it as such */ + } + else if (isLua(ci)) + return funcnamefromcode(L, ci_func(ci)->p, currentpc(ci), name); + else + return NULL; +} + /* }====================================================== */ /* -** The subtraction of two potentially unrelated pointers is -** not ISO C, but it should not crash a program; the subsequent -** checks are ISO C and ensure a correct result. +** Check whether pointer 'o' points to some value in the stack frame of +** the current function and, if so, returns its index. Because 'o' may +** not point to a value in this stack, we cannot compare it with the +** region boundaries (undefined behavior in ISO C). */ -static int isinstack (CallInfo *ci, const TValue *o) { - ptrdiff_t i = o - ci->u.l.base; - return (0 <= i && i < (ci->top - ci->u.l.base) && ci->u.l.base + i == o); +static int instack (CallInfo *ci, const TValue *o) { + int pos; + StkId base = ci->func.p + 1; + for (pos = 0; base + pos < ci->top.p; pos++) { + if (o == s2v(base + pos)) + return pos; + } + return -1; /* not found */ } @@ -559,7 +699,7 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, LClosure *c = ci_func(ci); int i; for (i = 0; i < c->nupvalues; i++) { - if (c->upvals[i]->v == o) { + if (c->upvals[i]->v.p == o) { *name = upvalname(c->p, i); return "upvalue"; } @@ -568,23 +708,70 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, } +static const char *formatvarinfo (lua_State *L, const char *kind, + const char *name) { + if (kind == NULL) + return ""; /* no information */ + else + return luaO_pushfstring(L, " (%s '%s')", kind, name); +} + +/* +** Build a string with a "description" for the value 'o', such as +** "variable 'x'" or "upvalue 'y'". +*/ static const char *varinfo (lua_State *L, const TValue *o) { - const char *name = NULL; /* to avoid warnings */ CallInfo *ci = L->ci; + const char *name = NULL; /* to avoid warnings */ const char *kind = NULL; if (isLua(ci)) { kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ - if (!kind && isinstack(ci, o)) /* no? try a register */ - kind = getobjname(ci_func(ci)->p, currentpc(ci), - cast_int(o - ci->u.l.base), &name); + if (!kind) { /* not an upvalue? */ + int reg = instack(ci, o); /* try a register */ + if (reg >= 0) /* is 'o' a register? */ + kind = getobjname(ci_func(ci)->p, currentpc(ci), reg, &name); + } } - return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; + return formatvarinfo(L, kind, name); } -l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { +/* +** Raise a type error +*/ +static l_noret typeerror (lua_State *L, const TValue *o, const char *op, + const char *extra) { const char *t = luaT_objtypename(L, o); - luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o)); + luaG_runerror(L, "attempt to %s a %s value%s", op, t, extra); +} + + +/* +** Raise a type error with "standard" information about the faulty +** object 'o' (using 'varinfo'). +*/ +l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + typeerror(L, o, op, varinfo(L, o)); +} + + +/* +** Raise an error for calling a non-callable object. Try to find a name +** for the object based on how it was called ('funcnamefromcall'); if it +** cannot get a name there, try 'varinfo'. +*/ +l_noret luaG_callerror (lua_State *L, const TValue *o) { + CallInfo *ci = L->ci; + const char *name = NULL; /* to avoid warnings */ + const char *kind = funcnamefromcall(L, ci, &name); + const char *extra = kind ? formatvarinfo(L, kind, name) : varinfo(L, o); + typeerror(L, o, "call", extra); +} + + +l_noret luaG_forerror (lua_State *L, const TValue *o, const char *what) { + luaG_runerror(L, "bad 'for' %s (number expected, got %s)", + what, luaT_objtypename(L, o)); } @@ -596,8 +783,7 @@ l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) { l_noret luaG_opinterror (lua_State *L, const TValue *p1, const TValue *p2, const char *msg) { - lua_Number temp; - if (!tonumber(p1, &temp)) /* first operand is wrong? */ + if (!ttisnumber(p1)) /* first operand is wrong? */ p2 = p1; /* now second is wrong */ luaG_typeerror(L, p2, msg); } @@ -608,7 +794,7 @@ l_noret luaG_opinterror (lua_State *L, const TValue *p1, */ l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { lua_Integer temp; - if (!tointeger(p1, &temp)) + if (!luaV_tointegerns(p1, &temp, LUA_FLOORN2I)) p2 = p1; luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2)); } @@ -629,7 +815,7 @@ const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, int line) { char buff[LUA_IDSIZE]; if (src) - luaO_chunkid(buff, getstr(src), LUA_IDSIZE); + luaO_chunkid(buff, getstr(src), tsslen(src)); else { /* no source available; use "?" instead */ buff[0] = '?'; buff[1] = '\0'; } @@ -640,10 +826,11 @@ const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, l_noret luaG_errormsg (lua_State *L) { if (L->errfunc != 0) { /* is there an error handling function? */ StkId errfunc = restorestack(L, L->errfunc); - setobjs2s(L, L->top, L->top - 1); /* move argument */ - setobjs2s(L, L->top - 1, errfunc); /* push function */ - L->top++; /* assume EXTRA_STACK */ - luaD_callnoyield(L, L->top - 2, 1); /* call it */ + lua_assert(ttisfunction(s2v(errfunc))); + setobjs2s(L, L->top.p, L->top.p - 1); /* move argument */ + setobjs2s(L, L->top.p - 1, errfunc); /* push function */ + L->top.p++; /* assume EXTRA_STACK */ + luaD_callnoyield(L, L->top.p - 2, 1); /* call it */ } luaD_throw(L, LUA_ERRRUN); } @@ -657,43 +844,119 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { va_start(argp, fmt); msg = luaO_pushvfstring(L, fmt, argp); /* format message */ va_end(argp); - if (isLua(ci)) /* if Lua function, add source:line information */ - luaG_addinfo(L, msg, ci_func(ci)->p->source, currentline(ci)); + if (isLua(ci)) { /* if Lua function, add source:line information */ + luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); + setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ + L->top.p--; + } luaG_errormsg(L); } -void luaG_traceexec (lua_State *L) { +/* +** Check whether new instruction 'newpc' is in a different line from +** previous instruction 'oldpc'. More often than not, 'newpc' is only +** one or a few instructions after 'oldpc' (it must be after, see +** caller), so try to avoid calling 'luaG_getfuncline'. If they are +** too far apart, there is a good chance of a ABSLINEINFO in the way, +** so it goes directly to 'luaG_getfuncline'. +*/ +static int changedline (const Proto *p, int oldpc, int newpc) { + if (p->lineinfo == NULL) /* no debug information? */ + return 0; + if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */ + int delta = 0; /* line difference */ + int pc = oldpc; + for (;;) { + int lineinfo = p->lineinfo[++pc]; + if (lineinfo == ABSLINEINFO) + break; /* cannot compute delta; fall through */ + delta += lineinfo; + if (pc == newpc) + return (delta != 0); /* delta computed successfully */ + } + } + /* either instructions are too far apart or there is an absolute line + info in the way; compute line difference explicitly */ + return (luaG_getfuncline(p, oldpc) != luaG_getfuncline(p, newpc)); +} + + +/* +** Traces Lua calls. If code is running the first instruction of a function, +** and function is not vararg, and it is not coming from an yield, +** calls 'luaD_hookcall'. (Vararg functions will call 'luaD_hookcall' +** after adjusting its variable arguments; otherwise, they could call +** a line/count hook before the call hook. Functions coming from +** an yield already called 'luaD_hookcall' before yielding.) +*/ +int luaG_tracecall (lua_State *L) { + CallInfo *ci = L->ci; + Proto *p = ci_func(ci)->p; + ci->u.l.trap = 1; /* ensure hooks will be checked */ + if (ci->u.l.savedpc == p->code) { /* first instruction (not resuming)? */ + if (p->is_vararg) + return 0; /* hooks will start at VARARGPREP instruction */ + else if (!(ci->callstatus & CIST_HOOKYIELD)) /* not yieded? */ + luaD_hookcall(L, ci); /* check 'call' hook */ + } + return 1; /* keep 'trap' on */ +} + + +/* +** Traces the execution of a Lua function. Called before the execution +** of each opcode, when debug is on. 'L->oldpc' stores the last +** instruction traced, to detect line changes. When entering a new +** function, 'npci' will be zero and will test as a new line whatever +** the value of 'oldpc'. Some exceptional conditions may return to +** a function without setting 'oldpc'. In that case, 'oldpc' may be +** invalid; if so, use zero as a valid value. (A wrong but valid 'oldpc' +** at most causes an extra call to a line hook.) +** This function is not "Protected" when called, so it should correct +** 'L->top.p' before calling anything that can run the GC. +*/ +int luaG_traceexec (lua_State *L, const Instruction *pc) { CallInfo *ci = L->ci; lu_byte mask = L->hookmask; - int counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT)); + const Proto *p = ci_func(ci)->p; + int counthook; + if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) { /* no hooks? */ + ci->u.l.trap = 0; /* don't need to stop again */ + return 0; /* turn off 'trap' */ + } + pc++; /* reference is always next instruction */ + ci->u.l.savedpc = pc; /* save 'pc' */ + counthook = (mask & LUA_MASKCOUNT) && (--L->hookcount == 0); if (counthook) resethookcount(L); /* reset count */ else if (!(mask & LUA_MASKLINE)) - return; /* no line hook and count != 0; nothing to be done */ - if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ + return 1; /* no line hook and count != 0; nothing to be done now */ + if (ci->callstatus & CIST_HOOKYIELD) { /* hook yielded last time? */ ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ - return; /* do not call hook again (VM yielded, so it did not move) */ + return 1; /* do not call hook again (VM yielded, so it did not move) */ } + if (!isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */ + L->top.p = ci->top.p; /* correct top */ if (counthook) - luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ + luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ if (mask & LUA_MASKLINE) { - Proto *p = ci_func(ci)->p; - int npc = pcRel(ci->u.l.savedpc, p); - int newline = getfuncline(p, npc); - if (npc == 0 || /* call linehook when enter a new function, */ - ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ - newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ - luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ - } - L->oldpc = ci->u.l.savedpc; + /* 'L->oldpc' may be invalid; use zero in this case */ + int oldpc = (L->oldpc < p->sizecode) ? L->oldpc : 0; + int npci = pcRel(pc, p); + if (npci <= oldpc || /* call hook when jump back (loop), */ + changedline(p, oldpc, npci)) { /* or when enter new line */ + int newline = luaG_getfuncline(p, npci); + luaD_hook(L, LUA_HOOKLINE, newline, 0, 0); /* call line hook */ + } + L->oldpc = npci; /* 'pc' of last call to line hook */ + } if (L->status == LUA_YIELD) { /* did hook yield? */ if (counthook) L->hookcount = 1; /* undo decrement to zero */ - ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ - ci->func = L->top - 1; /* protect stack below results */ luaD_throw(L, LUA_YIELD); } + return 1; /* keep 'trap' on */ } diff --git a/liblua/ldebug.h b/liblua/ldebug.h index 8cea0ee0..2bfce3cb 100644 --- a/liblua/ldebug.h +++ b/liblua/ldebug.h @@ -1,5 +1,5 @@ /* -** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ldebug.h $ ** Auxiliary functions from Debug Interface module ** See Copyright Notice in lua.h */ @@ -11,15 +11,39 @@ #include "lstate.h" -#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) +#define pcRel(pc, p) (cast_int((pc) - (p)->code) - 1) + + +/* Active Lua function (given call info) */ +#define ci_func(ci) (clLvalue(s2v((ci)->func.p))) -#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) #define resethookcount(L) (L->hookcount = L->basehookcount) +/* +** mark for entries in 'lineinfo' array that has absolute information in +** 'abslineinfo' array +*/ +#define ABSLINEINFO (-0x80) + + +/* +** MAXimum number of successive Instructions WiTHout ABSolute line +** information. (A power of two allows fast divisions.) +*/ +#if !defined(MAXIWTHABS) +#define MAXIWTHABS 128 +#endif + +LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); +LUAI_FUNC const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, + StkId *pos); LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *opname); +LUAI_FUNC l_noret luaG_callerror (lua_State *L, const TValue *o); +LUAI_FUNC l_noret luaG_forerror (lua_State *L, const TValue *o, + const char *what); LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2); LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, @@ -33,7 +57,8 @@ LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, int line); LUAI_FUNC l_noret luaG_errormsg (lua_State *L); -LUAI_FUNC void luaG_traceexec (lua_State *L); +LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc); +LUAI_FUNC int luaG_tracecall (lua_State *L); #endif diff --git a/liblua/ldo.c b/liblua/ldo.c index 316e45c8..ea052950 100644 --- a/liblua/ldo.c +++ b/liblua/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.157.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ldo.c $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -88,7 +88,7 @@ struct lua_longjmp { }; -static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { switch (errcode) { case LUA_ERRMEM: { /* memory error? */ setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ @@ -98,12 +98,17 @@ static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); break; } + case LUA_OK: { /* special case only for closing upvalues */ + setnilvalue(s2v(oldtop)); /* no error message */ + break; + } default: { - setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + lua_assert(errorstatus(errcode)); /* real error */ + setobjs2s(L, oldtop, L->top.p - 1); /* error message on current top */ break; } } - L->top = oldtop + 1; + L->top.p = oldtop + 1; } @@ -114,16 +119,13 @@ l_noret luaD_throw (lua_State *L, int errcode) { } else { /* thread has no error handler */ global_State *g = G(L); - L->status = cast_byte(errcode); /* mark it as dead */ + errcode = luaE_resetthread(L, errcode); /* close all upvalues */ if (g->mainthread->errorJmp) { /* main thread has a handler? */ - setobjs2s(L, g->mainthread->top++, L->top - 1); /* copy error obj. */ + setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ } else { /* no handler at all; abort */ if (g->panic) { /* panic function? */ - seterrorobj(L, errcode, L->top); /* assume EXTRA_STACK */ - if (L->ci->top < L->top) - L->ci->top = L->top; /* pushing msg. can break this invariant */ lua_unlock(L); g->panic(L); /* call panic function (last chance to jump out) */ } @@ -134,7 +136,7 @@ l_noret luaD_throw (lua_State *L, int errcode) { int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { - unsigned short oldnCcalls = L->nCcalls; + l_uint32 oldnCcalls = L->nCcalls; struct lua_longjmp lj; lj.status = LUA_OK; lj.previous = L->errorJmp; /* chain new error handler */ @@ -155,17 +157,40 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { ** Stack reallocation ** =================================================================== */ -static void correctstack (lua_State *L, TValue *oldstack) { + + +/* +** Change all pointers to the stack into offsets. +*/ +static void relstack (lua_State *L) { + CallInfo *ci; + UpVal *up; + L->top.offset = savestack(L, L->top.p); + L->tbclist.offset = savestack(L, L->tbclist.p); + for (up = L->openupval; up != NULL; up = up->u.open.next) + up->v.offset = savestack(L, uplevel(up)); + for (ci = L->ci; ci != NULL; ci = ci->previous) { + ci->top.offset = savestack(L, ci->top.p); + ci->func.offset = savestack(L, ci->func.p); + } +} + + +/* +** Change back all offsets into pointers. +*/ +static void correctstack (lua_State *L) { CallInfo *ci; UpVal *up; - L->top = (L->top - oldstack) + L->stack; + L->top.p = restorestack(L, L->top.offset); + L->tbclist.p = restorestack(L, L->tbclist.offset); for (up = L->openupval; up != NULL; up = up->u.open.next) - up->v = (up->v - oldstack) + L->stack; + up->v.p = s2v(restorestack(L, up->v.offset)); for (ci = L->ci; ci != NULL; ci = ci->previous) { - ci->top = (ci->top - oldstack) + L->stack; - ci->func = (ci->func - oldstack) + L->stack; + ci->top.p = restorestack(L, ci->top.offset); + ci->func.p = restorestack(L, ci->func.offset); if (isLua(ci)) - ci->u.l.base = (ci->u.l.base - oldstack) + L->stack; + ci->u.l.trap = 1; /* signal to update 'trap' in 'luaV_execute' */ } } @@ -173,73 +198,123 @@ static void correctstack (lua_State *L, TValue *oldstack) { /* some space for error handling */ #define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) - -void luaD_reallocstack (lua_State *L, int newsize) { - TValue *oldstack = L->stack; - int lim = L->stacksize; +/* +** Reallocate the stack to a new size, correcting all pointers into it. +** In ISO C, any pointer use after the pointer has been deallocated is +** undefined behavior. So, before the reallocation, all pointers are +** changed to offsets, and after the reallocation they are changed back +** to pointers. As during the reallocation the pointers are invalid, the +** reallocation cannot run emergency collections. +** +** In case of allocation error, raise an error or return false according +** to 'raiseerror'. +*/ +int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) { + int oldsize = stacksize(L); + int i; + StkId newstack; + int oldgcstop = G(L)->gcstopem; lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); - luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue); - for (; lim < newsize; lim++) - setnilvalue(L->stack + lim); /* erase new segment */ - L->stacksize = newsize; - L->stack_last = L->stack + newsize - EXTRA_STACK; - correctstack(L, oldstack); + relstack(L); /* change pointers to offsets */ + G(L)->gcstopem = 1; /* stop emergency collection */ + newstack = luaM_reallocvector(L, L->stack.p, oldsize + EXTRA_STACK, + newsize + EXTRA_STACK, StackValue); + G(L)->gcstopem = oldgcstop; /* restore emergency collection */ + if (l_unlikely(newstack == NULL)) { /* reallocation failed? */ + correctstack(L); /* change offsets back to pointers */ + if (raiseerror) + luaM_error(L); + else return 0; /* do not raise an error */ + } + L->stack.p = newstack; + correctstack(L); /* change offsets back to pointers */ + L->stack_last.p = L->stack.p + newsize; + for (i = oldsize + EXTRA_STACK; i < newsize + EXTRA_STACK; i++) + setnilvalue(s2v(newstack + i)); /* erase new segment */ + return 1; } -void luaD_growstack (lua_State *L, int n) { - int size = L->stacksize; - if (size > LUAI_MAXSTACK) /* error after extra size? */ - luaD_throw(L, LUA_ERRERR); - else { - int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; - int newsize = 2 * size; - if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; - if (newsize < needed) newsize = needed; - if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ - luaD_reallocstack(L, ERRORSTACKSIZE); - luaG_runerror(L, "stack overflow"); - } - else - luaD_reallocstack(L, newsize); +/* +** Try to grow the stack by at least 'n' elements. When 'raiseerror' +** is true, raises any error; otherwise, return 0 in case of errors. +*/ +int luaD_growstack (lua_State *L, int n, int raiseerror) { + int size = stacksize(L); + if (l_unlikely(size > LUAI_MAXSTACK)) { + /* if stack is larger than maximum, thread is already using the + extra space reserved for errors, that is, thread is handling + a stack error; cannot grow further than that. */ + lua_assert(stacksize(L) == ERRORSTACKSIZE); + if (raiseerror) + luaD_throw(L, LUA_ERRERR); /* error inside message handler */ + return 0; /* if not 'raiseerror', just signal it */ } + else if (n < LUAI_MAXSTACK) { /* avoids arithmetic overflows */ + int newsize = 2 * size; /* tentative new size */ + int needed = cast_int(L->top.p - L->stack.p) + n; + if (newsize > LUAI_MAXSTACK) /* cannot cross the limit */ + newsize = LUAI_MAXSTACK; + if (newsize < needed) /* but must respect what was asked for */ + newsize = needed; + if (l_likely(newsize <= LUAI_MAXSTACK)) + return luaD_reallocstack(L, newsize, raiseerror); + } + /* else stack overflow */ + /* add extra size to be able to handle the error message */ + luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror); + if (raiseerror) + luaG_runerror(L, "stack overflow"); + return 0; } +/* +** Compute how much of the stack is being used, by computing the +** maximum top of all call frames in the stack and the current top. +*/ static int stackinuse (lua_State *L) { CallInfo *ci; - StkId lim = L->top; + int res; + StkId lim = L->top.p; for (ci = L->ci; ci != NULL; ci = ci->previous) { - if (lim < ci->top) lim = ci->top; + if (lim < ci->top.p) lim = ci->top.p; } - lua_assert(lim <= L->stack_last); - return cast_int(lim - L->stack) + 1; /* part of stack in use */ + lua_assert(lim <= L->stack_last.p + EXTRA_STACK); + res = cast_int(lim - L->stack.p) + 1; /* part of stack in use */ + if (res < LUA_MINSTACK) + res = LUA_MINSTACK; /* ensure a minimum size */ + return res; } +/* +** If stack size is more than 3 times the current use, reduce that size +** to twice the current use. (So, the final stack size is at most 2/3 the +** previous size, and half of its entries are empty.) +** As a particular case, if stack was handling a stack overflow and now +** it is not, 'max' (limited by LUAI_MAXSTACK) will be smaller than +** stacksize (equal to ERRORSTACKSIZE in this case), and so the stack +** will be reduced to a "regular" size. +*/ void luaD_shrinkstack (lua_State *L) { int inuse = stackinuse(L); - int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK; - if (goodsize > LUAI_MAXSTACK) - goodsize = LUAI_MAXSTACK; /* respect stack limit */ - if (L->stacksize > LUAI_MAXSTACK) /* had been handling stack overflow? */ - luaE_freeCI(L); /* free all CIs (list grew because of an error) */ - else - luaE_shrinkCI(L); /* shrink list */ + int max = (inuse > LUAI_MAXSTACK / 3) ? LUAI_MAXSTACK : inuse * 3; /* if thread is currently not handling a stack overflow and its - good size is smaller than current size, shrink its stack */ - if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && - goodsize < L->stacksize) - luaD_reallocstack(L, goodsize); + size is larger than maximum "reasonable" size, shrink it */ + if (inuse <= LUAI_MAXSTACK && stacksize(L) > max) { + int nsize = (inuse > LUAI_MAXSTACK / 2) ? LUAI_MAXSTACK : inuse * 2; + luaD_reallocstack(L, nsize, 0); /* ok if that fails */ + } else /* don't change stack */ condmovestack(L,{},{}); /* (change only for debugging) */ + luaE_shrinkCI(L); /* shrink CI list */ } void luaD_inctop (lua_State *L) { luaD_checkstack(L, 1); - L->top++; + L->top.p++; } /* }================================================================== */ @@ -247,81 +322,105 @@ void luaD_inctop (lua_State *L) { /* ** Call a hook for the given event. Make sure there is a hook to be -** called. (Both 'L->hook' and 'L->hookmask', which triggers this +** called. (Both 'L->hook' and 'L->hookmask', which trigger this ** function, can be changed asynchronously by signals.) */ -void luaD_hook (lua_State *L, int event, int line) { +void luaD_hook (lua_State *L, int event, int line, + int ftransfer, int ntransfer) { lua_Hook hook = L->hook; if (hook && L->allowhook) { /* make sure there is a hook */ + int mask = CIST_HOOKED; CallInfo *ci = L->ci; - ptrdiff_t top = savestack(L, L->top); - ptrdiff_t ci_top = savestack(L, ci->top); + ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */ + ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */ lua_Debug ar; ar.event = event; ar.currentline = line; ar.i_ci = ci; + if (ntransfer != 0) { + mask |= CIST_TRAN; /* 'ci' has transfer information */ + ci->u2.transferinfo.ftransfer = ftransfer; + ci->u2.transferinfo.ntransfer = ntransfer; + } + if (isLua(ci) && L->top.p < ci->top.p) + L->top.p = ci->top.p; /* protect entire activation register */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - ci->top = L->top + LUA_MINSTACK; - lua_assert(ci->top <= L->stack_last); + if (ci->top.p < L->top.p + LUA_MINSTACK) + ci->top.p = L->top.p + LUA_MINSTACK; L->allowhook = 0; /* cannot call hooks inside a hook */ - ci->callstatus |= CIST_HOOKED; + ci->callstatus |= mask; lua_unlock(L); (*hook)(L, &ar); lua_lock(L); lua_assert(!L->allowhook); L->allowhook = 1; - ci->top = restorestack(L, ci_top); - L->top = restorestack(L, top); - ci->callstatus &= ~CIST_HOOKED; + ci->top.p = restorestack(L, ci_top); + L->top.p = restorestack(L, top); + ci->callstatus &= ~mask; } } -static void callhook (lua_State *L, CallInfo *ci) { - int hook = LUA_HOOKCALL; - ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ - if (isLua(ci->previous) && - GET_OPCODE(*(ci->previous->u.l.savedpc - 1)) == OP_TAILCALL) { - ci->callstatus |= CIST_TAIL; - hook = LUA_HOOKTAILCALL; +/* +** Executes a call hook for Lua functions. This function is called +** whenever 'hookmask' is not zero, so it checks whether call hooks are +** active. +*/ +void luaD_hookcall (lua_State *L, CallInfo *ci) { + L->oldpc = 0; /* set 'oldpc' for new function */ + if (L->hookmask & LUA_MASKCALL) { /* is call hook on? */ + int event = (ci->callstatus & CIST_TAIL) ? LUA_HOOKTAILCALL + : LUA_HOOKCALL; + Proto *p = ci_func(ci)->p; + ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_hook(L, event, -1, 1, p->numparams); + ci->u.l.savedpc--; /* correct 'pc' */ } - luaD_hook(L, hook, -1); - ci->u.l.savedpc--; /* correct 'pc' */ } -static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { - int i; - int nfixargs = p->numparams; - StkId base, fixed; - /* move fixed parameters to final position */ - fixed = L->top - actual; /* first fixed argument */ - base = L->top; /* final position of first argument */ - for (i = 0; i < nfixargs && i < actual; i++) { - setobjs2s(L, L->top++, fixed + i); - setnilvalue(fixed + i); /* erase original copy (for GC) */ +/* +** Executes a return hook for Lua and C functions and sets/corrects +** 'oldpc'. (Note that this correction is needed by the line hook, so it +** is done even when return hooks are off.) +*/ +static void rethook (lua_State *L, CallInfo *ci, int nres) { + if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ + StkId firstres = L->top.p - nres; /* index of first result */ + int delta = 0; /* correction for vararg functions */ + int ftransfer; + if (isLua(ci)) { + Proto *p = ci_func(ci)->p; + if (p->is_vararg) + delta = ci->u.l.nextraargs + p->numparams + 1; + } + ci->func.p += delta; /* if vararg, back to virtual 'func' */ + ftransfer = cast(unsigned short, firstres - ci->func.p); + luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ + ci->func.p -= delta; } - for (; i < nfixargs; i++) - setnilvalue(L->top++); /* complete missing arguments */ - return base; + if (isLua(ci = ci->previous)) + L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */ } /* -** Check whether __call metafield of 'func' is a function. If so, put -** it in stack below original 'func' so that 'luaD_precall' can call -** it. Raise an error if __call metafield is not a function. +** Check whether 'func' has a '__call' metafield. If so, put it in the +** stack, below original 'func', so that 'luaD_precall' can call it. Raise +** an error if there is no '__call' metafield. */ -static void tryfuncTM (lua_State *L, StkId func) { - const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm; StkId p; - if (!ttisfunction(tm)) - luaG_typeerror(L, func, "call"); - /* Open a hole inside the stack at 'func' */ - for (p = L->top; p > func; p--) + checkstackGCp(L, 1, func); /* space for metamethod */ + tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ + if (l_unlikely(ttisnil(tm))) + luaG_callerror(L, s2v(func)); /* nothing to call */ + for (p = L->top.p; p > func; p--) /* open space for metamethod */ setobjs2s(L, p, p-1); - L->top++; /* slot ensured by caller */ - setobj2s(L, func, tm); /* tag method is the new function to be called */ + L->top.p++; /* stack space pre-allocated by the caller */ + setobj2s(L, func, tm); /* metamethod is the new function to be called */ + return func; } @@ -331,229 +430,318 @@ static void tryfuncTM (lua_State *L, StkId func) { ** expressions, multiple results for tail calls/single parameters) ** separated. */ -static int moveresults (lua_State *L, const TValue *firstResult, StkId res, - int nres, int wanted) { +l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) { + StkId firstresult; + int i; switch (wanted) { /* handle typical cases separately */ - case 0: break; /* nothing to move */ - case 1: { /* one result needed */ + case 0: /* no values needed */ + L->top.p = res; + return; + case 1: /* one value needed */ if (nres == 0) /* no results? */ - firstResult = luaO_nilobject; /* adjust with nil */ - setobjs2s(L, res, firstResult); /* move it to proper place */ + setnilvalue(s2v(res)); /* adjust with nil */ + else /* at least one result */ + setobjs2s(L, res, L->top.p - nres); /* move it to proper place */ + L->top.p = res + 1; + return; + case LUA_MULTRET: + wanted = nres; /* we want all results */ break; - } - case LUA_MULTRET: { - int i; - for (i = 0; i < nres; i++) /* move all results to correct place */ - setobjs2s(L, res + i, firstResult + i); - L->top = res + nres; - return 0; /* wanted == LUA_MULTRET */ - } - default: { - int i; - if (wanted <= nres) { /* enough results? */ - for (i = 0; i < wanted; i++) /* move wanted results to correct place */ - setobjs2s(L, res + i, firstResult + i); - } - else { /* not enough results; use all of them plus nils */ - for (i = 0; i < nres; i++) /* move all results to correct place */ - setobjs2s(L, res + i, firstResult + i); - for (; i < wanted; i++) /* complete wanted number of results */ - setnilvalue(res + i); + default: /* two/more results and/or to-be-closed variables */ + if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */ + L->ci->callstatus |= CIST_CLSRET; /* in case of yields */ + L->ci->u2.nres = nres; + res = luaF_close(L, res, CLOSEKTOP, 1); + L->ci->callstatus &= ~CIST_CLSRET; + if (L->hookmask) { /* if needed, call hook after '__close's */ + ptrdiff_t savedres = savestack(L, res); + rethook(L, L->ci, nres); + res = restorestack(L, savedres); /* hook can move stack */ + } + wanted = decodeNresults(wanted); + if (wanted == LUA_MULTRET) + wanted = nres; /* we want all results */ } break; - } } - L->top = res + wanted; /* top points after the last result */ - return 1; + /* generic case */ + firstresult = L->top.p - nres; /* index of first result */ + if (nres > wanted) /* extra results? */ + nres = wanted; /* don't need them */ + for (i = 0; i < nres; i++) /* move all results to correct place */ + setobjs2s(L, res + i, firstresult + i); + for (; i < wanted; i++) /* complete wanted number of results */ + setnilvalue(s2v(res + i)); + L->top.p = res + wanted; /* top points after the last result */ } /* -** Finishes a function call: calls hook if necessary, removes CallInfo, -** moves current number of results to proper place; returns 0 iff call -** wanted multiple (variable number of) results. +** Finishes a function call: calls hook if necessary, moves current +** number of results to proper place, and returns to previous call +** info. If function has to close variables, hook must be called after +** that. */ -int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) { - StkId res; +void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { int wanted = ci->nresults; - if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) { - if (L->hookmask & LUA_MASKRET) { - ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */ - luaD_hook(L, LUA_HOOKRET, -1); - firstResult = restorestack(L, fr); - } - L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ - } - res = ci->func; /* res == final position of 1st result */ - L->ci = ci->previous; /* back to caller */ + if (l_unlikely(L->hookmask && !hastocloseCfunc(wanted))) + rethook(L, ci, nres); /* move results to proper place */ - return moveresults(L, firstResult, res, nres, wanted); + moveresults(L, ci->func.p, nres, wanted); + /* function cannot be in any of these cases when returning */ + lua_assert(!(ci->callstatus & + (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_TRAN | CIST_CLSRET))); + L->ci = ci->previous; /* back to caller (after closing variables) */ } -#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L))) +#define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L)) -/* macro to check stack size, preserving 'p' */ -#define checkstackp(L,n,p) \ - luaD_checkstackaux(L, n, \ - ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ - luaC_checkGC(L), /* stack grow uses memory */ \ - p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ +l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret, + int mask, StkId top) { + CallInfo *ci = L->ci = next_ci(L); /* new frame */ + ci->func.p = func; + ci->nresults = nret; + ci->callstatus = mask; + ci->top.p = top; + return ci; +} /* -** Prepares a function call: checks the stack, creates a new CallInfo -** entry, fills in the relevant information, calls hook if needed. -** If function is a C function, does the call, too. (Otherwise, leave -** the execution ('luaV_execute') to the caller, to allow stackless -** calls.) Returns true iff function has been executed (C function). +** precall for C functions */ -int luaD_precall (lua_State *L, StkId func, int nresults) { - lua_CFunction f; +l_sinline int precallC (lua_State *L, StkId func, int nresults, + lua_CFunction f) { + int n; /* number of returns */ CallInfo *ci; - switch (ttype(func)) { - case LUA_TCCL: /* C closure */ - f = clCvalue(func)->f; - goto Cfunc; - case LUA_TLCF: /* light C function */ - f = fvalue(func); - Cfunc: { - int n; /* number of returns */ - checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ - ci = next_ci(L); /* now 'enter' new function */ - ci->nresults = nresults; - ci->func = func; - ci->top = L->top + LUA_MINSTACK; - lua_assert(ci->top <= L->stack_last); - ci->callstatus = 0; - if (L->hookmask & LUA_MASKCALL) - luaD_hook(L, LUA_HOOKCALL, -1); - lua_unlock(L); - n = (*f)(L); /* do the actual call */ - lua_lock(L); - api_checknelems(L, n); - luaD_poscall(L, ci, L->top - n, n); - return 1; + checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ + L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, + L->top.p + LUA_MINSTACK); + lua_assert(ci->top.p <= L->stack_last.p); + if (l_unlikely(L->hookmask & LUA_MASKCALL)) { + int narg = cast_int(L->top.p - func) - 1; + luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); + } + lua_unlock(L); + n = (*f)(L); /* do the actual call */ + lua_lock(L); + api_checknelems(L, n); + luaD_poscall(L, ci, n); + return n; +} + + +/* +** Prepare a function for a tail call, building its call info on top +** of the current call info. 'narg1' is the number of arguments plus 1 +** (so that it includes the function itself). Return the number of +** results, if it was a C function, or -1 for a Lua function. +*/ +int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, + int narg1, int delta) { + retry: + switch (ttypetag(s2v(func))) { + case LUA_VCCL: /* C closure */ + return precallC(L, func, LUA_MULTRET, clCvalue(s2v(func))->f); + case LUA_VLCF: /* light C function */ + return precallC(L, func, LUA_MULTRET, fvalue(s2v(func))); + case LUA_VLCL: { /* Lua function */ + Proto *p = clLvalue(s2v(func))->p; + int fsize = p->maxstacksize; /* frame size */ + int nfixparams = p->numparams; + int i; + checkstackGCp(L, fsize - delta, func); + ci->func.p -= delta; /* restore 'func' (if vararg) */ + for (i = 0; i < narg1; i++) /* move down function and arguments */ + setobjs2s(L, ci->func.p + i, func + i); + func = ci->func.p; /* moved-down function */ + for (; narg1 <= nfixparams; narg1++) + setnilvalue(s2v(func + narg1)); /* complete missing arguments */ + ci->top.p = func + 1 + fsize; /* top for new function */ + lua_assert(ci->top.p <= L->stack_last.p); + ci->u.l.savedpc = p->code; /* starting point */ + ci->callstatus |= CIST_TAIL; + L->top.p = func + narg1; /* set top */ + return -1; + } + default: { /* not a function */ + func = tryfuncTM(L, func); /* try to get '__call' metamethod */ + /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */ + narg1++; + goto retry; /* try again */ } - case LUA_TLCL: { /* Lua function: prepare its call */ - StkId base; - Proto *p = clLvalue(func)->p; - int n = cast_int(L->top - func) - 1; /* number of real arguments */ + } +} + + +/* +** Prepares the call to a function (C or Lua). For C functions, also do +** the call. The function to be called is at '*func'. The arguments +** are on the stack, right after the function. Returns the CallInfo +** to be executed, if it was a Lua function. Otherwise (a C function) +** returns NULL, with all the results on the stack, starting at the +** original function position. +*/ +CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { + retry: + switch (ttypetag(s2v(func))) { + case LUA_VCCL: /* C closure */ + precallC(L, func, nresults, clCvalue(s2v(func))->f); + return NULL; + case LUA_VLCF: /* light C function */ + precallC(L, func, nresults, fvalue(s2v(func))); + return NULL; + case LUA_VLCL: { /* Lua function */ + CallInfo *ci; + Proto *p = clLvalue(s2v(func))->p; + int narg = cast_int(L->top.p - func) - 1; /* number of real arguments */ + int nfixparams = p->numparams; int fsize = p->maxstacksize; /* frame size */ - checkstackp(L, fsize, func); - if (p->is_vararg) - base = adjust_varargs(L, p, n); - else { /* non vararg function */ - for (; n < p->numparams; n++) - setnilvalue(L->top++); /* complete missing arguments */ - base = func + 1; - } - ci = next_ci(L); /* now 'enter' new function */ - ci->nresults = nresults; - ci->func = func; - ci->u.l.base = base; - L->top = ci->top = base + fsize; - lua_assert(ci->top <= L->stack_last); + checkstackGCp(L, fsize, func); + L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize); ci->u.l.savedpc = p->code; /* starting point */ - ci->callstatus = CIST_LUA; - if (L->hookmask & LUA_MASKCALL) - callhook(L, ci); - return 0; + for (; narg < nfixparams; narg++) + setnilvalue(s2v(L->top.p++)); /* complete missing arguments */ + lua_assert(ci->top.p <= L->stack_last.p); + return ci; } default: { /* not a function */ - checkstackp(L, 1, func); /* ensure space for metamethod */ - tryfuncTM(L, func); /* try to get '__call' metamethod */ - return luaD_precall(L, func, nresults); /* now it must be a function */ + func = tryfuncTM(L, func); /* try to get '__call' metamethod */ + /* return luaD_precall(L, func, nresults); */ + goto retry; /* try again with metamethod */ } } } /* -** Check appropriate error for stack overflow ("regular" overflow or -** overflow while handling stack overflow). If 'nCalls' is larger than -** LUAI_MAXCCALLS (which means it is handling a "regular" overflow) but -** smaller than 9/8 of LUAI_MAXCCALLS, does not report an error (to -** allow overflow handling to work) +** Call a function (C or Lua) through C. 'inc' can be 1 (increment +** number of recursive invocations in the C stack) or nyci (the same +** plus increment number of non-yieldable calls). +** This function can be called with some use of EXTRA_STACK, so it should +** check the stack before doing anything else. 'luaD_precall' already +** does that. */ -static void stackerror (lua_State *L) { - if (L->nCcalls == LUAI_MAXCCALLS) - luaG_runerror(L, "C stack overflow"); - else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) - luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ +l_sinline void ccall (lua_State *L, StkId func, int nResults, l_uint32 inc) { + CallInfo *ci; + L->nCcalls += inc; + if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) { + checkstackp(L, 0, func); /* free any use of EXTRA_STACK */ + luaE_checkcstack(L); + } + if ((ci = luaD_precall(L, func, nResults)) != NULL) { /* Lua function? */ + ci->callstatus = CIST_FRESH; /* mark that it is a "fresh" execute */ + luaV_execute(L, ci); /* call it */ + } + L->nCcalls -= inc; } /* -** Call a function (C or Lua). The function to be called is at *func. -** The arguments are on the stack, right after the function. -** When returns, all the results are on the stack, starting at the original -** function position. +** External interface for 'ccall' */ void luaD_call (lua_State *L, StkId func, int nResults) { - if (++L->nCcalls >= LUAI_MAXCCALLS) - stackerror(L); - if (!luaD_precall(L, func, nResults)) /* is a Lua function? */ - luaV_execute(L); /* call it */ - L->nCcalls--; + ccall(L, func, nResults, 1); } /* -** Similar to 'luaD_call', but does not allow yields during the call +** Similar to 'luaD_call', but does not allow yields during the call. */ void luaD_callnoyield (lua_State *L, StkId func, int nResults) { - L->nny++; - luaD_call(L, func, nResults); - L->nny--; + ccall(L, func, nResults, nyci); } /* -** Completes the execution of an interrupted C function, calling its -** continuation function. +** Finish the job of 'lua_pcallk' after it was interrupted by an yield. +** (The caller, 'finishCcall', does the final call to 'adjustresults'.) +** The main job is to complete the 'luaD_pcall' called by 'lua_pcallk'. +** If a '__close' method yields here, eventually control will be back +** to 'finishCcall' (when that '__close' method finally returns) and +** 'finishpcallk' will run again and close any still pending '__close' +** methods. Similarly, if a '__close' method errs, 'precover' calls +** 'unroll' which calls ''finishCcall' and we are back here again, to +** close any pending '__close' methods. +** Note that, up to the call to 'luaF_close', the corresponding +** 'CallInfo' is not modified, so that this repeated run works like the +** first one (except that it has at least one less '__close' to do). In +** particular, field CIST_RECST preserves the error status across these +** multiple runs, changing only if there is a new error. */ -static void finishCcall (lua_State *L, int status) { - CallInfo *ci = L->ci; - int n; - /* must have a continuation and must be able to call it */ - lua_assert(ci->u.c.k != NULL && L->nny == 0); - /* error status can only happen in a protected call */ - lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD); - if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ - ci->callstatus &= ~CIST_YPCALL; /* continuation is also inside it */ - L->errfunc = ci->u.c.old_errfunc; /* with the same error function */ - } - /* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already - handled */ - adjustresults(L, ci->nresults); - lua_unlock(L); - n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation function */ - lua_lock(L); - api_checknelems(L, n); - luaD_poscall(L, ci, L->top - n, n); /* finish 'luaD_precall' */ +static int finishpcallk (lua_State *L, CallInfo *ci) { + int status = getcistrecst(ci); /* get original status */ + if (l_likely(status == LUA_OK)) /* no error? */ + status = LUA_YIELD; /* was interrupted by an yield */ + else { /* error */ + StkId func = restorestack(L, ci->u2.funcidx); + L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */ + func = luaF_close(L, func, status, 1); /* can yield or raise an error */ + luaD_seterrorobj(L, status, func); + luaD_shrinkstack(L); /* restore stack size in case of overflow */ + setcistrecst(ci, LUA_OK); /* clear original status */ + } + ci->callstatus &= ~CIST_YPCALL; + L->errfunc = ci->u.c.old_errfunc; + /* if it is here, there were errors or yields; unlike 'lua_pcallk', + do not change status */ + return status; +} + + +/* +** Completes the execution of a C function interrupted by an yield. +** The interruption must have happened while the function was either +** closing its tbc variables in 'moveresults' or executing +** 'lua_callk'/'lua_pcallk'. In the first case, it just redoes +** 'luaD_poscall'. In the second case, the call to 'finishpcallk' +** finishes the interrupted execution of 'lua_pcallk'. After that, it +** calls the continuation of the interrupted function and finally it +** completes the job of the 'luaD_call' that called the function. In +** the call to 'adjustresults', we do not know the number of results +** of the function called by 'lua_callk'/'lua_pcallk', so we are +** conservative and use LUA_MULTRET (always adjust). +*/ +static void finishCcall (lua_State *L, CallInfo *ci) { + int n; /* actual number of results from C function */ + if (ci->callstatus & CIST_CLSRET) { /* was returning? */ + lua_assert(hastocloseCfunc(ci->nresults)); + n = ci->u2.nres; /* just redo 'luaD_poscall' */ + /* don't need to reset CIST_CLSRET, as it will be set again anyway */ + } + else { + int status = LUA_YIELD; /* default if there were no errors */ + /* must have a continuation and must be able to call it */ + lua_assert(ci->u.c.k != NULL && yieldable(L)); + if (ci->callstatus & CIST_YPCALL) /* was inside a 'lua_pcallk'? */ + status = finishpcallk(L, ci); /* finish it */ + adjustresults(L, LUA_MULTRET); /* finish 'lua_callk' */ + lua_unlock(L); + n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation */ + lua_lock(L); + api_checknelems(L, n); + } + luaD_poscall(L, ci, n); /* finish 'luaD_call' */ } /* ** Executes "full continuation" (everything in the stack) of a ** previously interrupted coroutine until the stack is empty (or another -** interruption long-jumps out of the loop). If the coroutine is -** recovering from an error, 'ud' points to the error status, which must -** be passed to the first continuation function (otherwise the default -** status is LUA_YIELD). +** interruption long-jumps out of the loop). */ static void unroll (lua_State *L, void *ud) { - if (ud != NULL) /* error status? */ - finishCcall(L, *(int *)ud); /* finish 'lua_pcallk' callee */ - while (L->ci != &L->base_ci) { /* something in the stack */ - if (!isLua(L->ci)) /* C function? */ - finishCcall(L, LUA_YIELD); /* complete its execution */ + CallInfo *ci; + UNUSED(ud); + while ((ci = L->ci) != &L->base_ci) { /* something in the stack */ + if (!isLua(ci)) /* C function? */ + finishCcall(L, ci); /* complete its execution */ else { /* Lua function */ luaV_finishOp(L); /* finish interrupted instruction */ - luaV_execute(L); /* execute down to higher C 'boundary' */ + luaV_execute(L, ci); /* execute down to higher C 'boundary' */ } } } @@ -573,36 +761,14 @@ static CallInfo *findpcall (lua_State *L) { } -/* -** Recovers from an error in a coroutine. Finds a recover point (if -** there is one) and completes the execution of the interrupted -** 'luaD_pcall'. If there is no recover point, returns zero. -*/ -static int recover (lua_State *L, int status) { - StkId oldtop; - CallInfo *ci = findpcall(L); - if (ci == NULL) return 0; /* no recovery point */ - /* "finish" luaD_pcall */ - oldtop = restorestack(L, ci->extra); - luaF_close(L, oldtop); - seterrorobj(L, status, oldtop); - L->ci = ci; - L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */ - L->nny = 0; /* should be zero to be yieldable */ - luaD_shrinkstack(L); - L->errfunc = ci->u.c.old_errfunc; - return 1; /* continue running the coroutine */ -} - - /* ** Signal an error in the call to 'lua_resume', not in the execution ** of the coroutine itself. (Such errors should not be handled by any ** coroutine error handler and should not kill the coroutine.) */ static int resume_error (lua_State *L, const char *msg, int narg) { - L->top -= narg; /* remove args from the stack */ - setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ + L->top.p -= narg; /* remove args from the stack */ + setsvalue2s(L, L->top.p, luaS_new(L, msg)); /* push error message */ api_incr_top(L); lua_unlock(L); return LUA_ERRRUN; @@ -618,98 +784,117 @@ static int resume_error (lua_State *L, const char *msg, int narg) { */ static void resume (lua_State *L, void *ud) { int n = *(cast(int*, ud)); /* number of arguments */ - StkId firstArg = L->top - n; /* first argument */ + StkId firstArg = L->top.p - n; /* first argument */ CallInfo *ci = L->ci; - if (L->status == LUA_OK) { /* starting a coroutine? */ - if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ - luaV_execute(L); /* call it */ - } + if (L->status == LUA_OK) /* starting a coroutine? */ + ccall(L, firstArg - 1, LUA_MULTRET, 0); /* just call its body */ else { /* resuming from previous yield */ lua_assert(L->status == LUA_YIELD); L->status = LUA_OK; /* mark that it is running (again) */ - ci->func = restorestack(L, ci->extra); - if (isLua(ci)) /* yielded inside a hook? */ - luaV_execute(L); /* just continue running Lua code */ + if (isLua(ci)) { /* yielded inside a hook? */ + /* undo increment made by 'luaG_traceexec': instruction was not + executed yet */ + lua_assert(ci->callstatus & CIST_HOOKYIELD); + ci->u.l.savedpc--; + L->top.p = firstArg; /* discard arguments */ + luaV_execute(L, ci); /* just continue running Lua code */ + } else { /* 'common' yield */ if (ci->u.c.k != NULL) { /* does it have a continuation function? */ lua_unlock(L); n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */ lua_lock(L); api_checknelems(L, n); - firstArg = L->top - n; /* yield results come from continuation */ } - luaD_poscall(L, ci, firstArg, n); /* finish 'luaD_precall' */ + luaD_poscall(L, ci, n); /* finish 'luaD_call' */ } unroll(L, NULL); /* run continuation */ } } -LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { +/* +** Unrolls a coroutine in protected mode while there are recoverable +** errors, that is, errors inside a protected call. (Any error +** interrupts 'unroll', and this loop protects it again so it can +** continue.) Stops with a normal end (status == LUA_OK), an yield +** (status == LUA_YIELD), or an unprotected error ('findpcall' doesn't +** find a recover point). +*/ +static int precover (lua_State *L, int status) { + CallInfo *ci; + while (errorstatus(status) && (ci = findpcall(L)) != NULL) { + L->ci = ci; /* go down to recovery functions */ + setcistrecst(ci, status); /* status to finish 'pcall' */ + status = luaD_rawrunprotected(L, unroll, NULL); + } + return status; +} + + +LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, + int *nresults) { int status; - unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */ lua_lock(L); if (L->status == LUA_OK) { /* may be starting a coroutine */ if (L->ci != &L->base_ci) /* not in base level? */ return resume_error(L, "cannot resume non-suspended coroutine", nargs); + else if (L->top.p - (L->ci->func.p + 1) == nargs) /* no function? */ + return resume_error(L, "cannot resume dead coroutine", nargs); } - else if (L->status != LUA_YIELD) + else if (L->status != LUA_YIELD) /* ended with errors? */ return resume_error(L, "cannot resume dead coroutine", nargs); - L->nCcalls = (from) ? from->nCcalls + 1 : 1; - if (L->nCcalls >= LUAI_MAXCCALLS) + L->nCcalls = (from) ? getCcalls(from) : 0; + if (getCcalls(L) >= LUAI_MAXCCALLS) return resume_error(L, "C stack overflow", nargs); + L->nCcalls++; luai_userstateresume(L, nargs); - L->nny = 0; /* allow yields */ api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); status = luaD_rawrunprotected(L, resume, &nargs); - if (status == -1) /* error calling 'lua_resume'? */ - status = LUA_ERRRUN; - else { /* continue running after recoverable errors */ - while (errorstatus(status) && recover(L, status)) { - /* unroll continuation */ - status = luaD_rawrunprotected(L, unroll, &status); - } - if (errorstatus(status)) { /* unrecoverable error? */ - L->status = cast_byte(status); /* mark thread as 'dead' */ - seterrorobj(L, status, L->top); /* push error message */ - L->ci->top = L->top; - } - else lua_assert(status == L->status); /* normal end or yield */ + /* continue running after recoverable errors */ + status = precover(L, status); + if (l_likely(!errorstatus(status))) + lua_assert(status == L->status); /* normal end or yield */ + else { /* unrecoverable error */ + L->status = cast_byte(status); /* mark thread as 'dead' */ + luaD_seterrorobj(L, status, L->top.p); /* push error message */ + L->ci->top.p = L->top.p; } - L->nny = oldnny; /* restore 'nny' */ - L->nCcalls--; - lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); + *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield + : cast_int(L->top.p - (L->ci->func.p + 1)); lua_unlock(L); return status; } LUA_API int lua_isyieldable (lua_State *L) { - return (L->nny == 0); + return yieldable(L); } LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k) { - CallInfo *ci = L->ci; + CallInfo *ci; luai_userstateyield(L, nresults); lua_lock(L); + ci = L->ci; api_checknelems(L, nresults); - if (L->nny > 0) { + if (l_unlikely(!yieldable(L))) { if (L != G(L)->mainthread) luaG_runerror(L, "attempt to yield across a C-call boundary"); else luaG_runerror(L, "attempt to yield from outside a coroutine"); } L->status = LUA_YIELD; - ci->extra = savestack(L, ci->func); /* save current 'func' */ + ci->u2.nyield = nresults; /* save number of results */ if (isLua(ci)) { /* inside a hook? */ + lua_assert(!isLuacode(ci)); + api_check(L, nresults == 0, "hooks cannot yield values"); api_check(L, k == NULL, "hooks cannot continue after yielding"); } else { if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ ci->u.c.ctx = ctx; /* save context */ - ci->func = L->top - nresults - 1; /* protect stack below results */ luaD_throw(L, LUA_YIELD); } lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */ @@ -718,23 +903,64 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, } +/* +** Auxiliary structure to call 'luaF_close' in protected mode. +*/ +struct CloseP { + StkId level; + int status; +}; + + +/* +** Auxiliary function to call 'luaF_close' in protected mode. +*/ +static void closepaux (lua_State *L, void *ud) { + struct CloseP *pcl = cast(struct CloseP *, ud); + luaF_close(L, pcl->level, pcl->status, 0); +} + + +/* +** Calls 'luaF_close' in protected mode. Return the original status +** or, in case of errors, the new status. +*/ +int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status) { + CallInfo *old_ci = L->ci; + lu_byte old_allowhooks = L->allowhook; + for (;;) { /* keep closing upvalues until no more errors */ + struct CloseP pcl; + pcl.level = restorestack(L, level); pcl.status = status; + status = luaD_rawrunprotected(L, &closepaux, &pcl); + if (l_likely(status == LUA_OK)) /* no more errors? */ + return pcl.status; + else { /* an error occurred; restore saved state and repeat */ + L->ci = old_ci; + L->allowhook = old_allowhooks; + } + } +} + + +/* +** Call the C function 'func' in protected mode, restoring basic +** thread information ('allowhook', etc.) and in particular +** its stack level in case of errors. +*/ int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef) { int status; CallInfo *old_ci = L->ci; lu_byte old_allowhooks = L->allowhook; - unsigned short old_nny = L->nny; ptrdiff_t old_errfunc = L->errfunc; L->errfunc = ef; status = luaD_rawrunprotected(L, func, u); - if (status != LUA_OK) { /* an error occurred? */ - StkId oldtop = restorestack(L, old_top); - luaF_close(L, oldtop); /* close possible pending closures */ - seterrorobj(L, status, oldtop); + if (l_unlikely(status != LUA_OK)) { /* an error occurred? */ L->ci = old_ci; L->allowhook = old_allowhooks; - L->nny = old_nny; - luaD_shrinkstack(L); + status = luaD_closeprotected(L, old_top, status); + luaD_seterrorobj(L, status, restorestack(L, old_top)); + luaD_shrinkstack(L); /* restore stack size in case of overflow */ } L->errfunc = old_errfunc; return status; @@ -784,18 +1010,18 @@ int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, const char *mode) { struct SParser p; int status; - L->nny++; /* cannot yield during parsing */ + incnny(L); /* cannot yield during parsing */ p.z = z; p.name = name; p.mode = mode; p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; p.dyd.label.arr = NULL; p.dyd.label.size = 0; luaZ_initbuffer(L, &p.buff); - status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top.p), L->errfunc); luaZ_freebuffer(L, &p.buff); luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); - L->nny--; + decnny(L); return status; } diff --git a/liblua/ldo.h b/liblua/ldo.h index 3b2983a3..56008ab3 100644 --- a/liblua/ldo.h +++ b/liblua/ldo.h @@ -1,5 +1,5 @@ /* -** $Id: ldo.h,v 2.29.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ldo.h $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -8,6 +8,7 @@ #define ldo_h +#include "llimits.h" #include "lobject.h" #include "lstate.h" #include "lzio.h" @@ -17,37 +18,65 @@ ** Macro to check stack size and grow stack if needed. Parameters ** 'pre'/'pos' allow the macro to preserve a pointer into the ** stack across reallocations, doing the work only when needed. +** It also allows the running of one GC step when the stack is +** reallocated. ** 'condmovestack' is used in heavy tests to force a stack reallocation ** at every check. */ #define luaD_checkstackaux(L,n,pre,pos) \ - if (L->stack_last - L->top <= (n)) \ - { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } + if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \ + { pre; luaD_growstack(L, n, 1); pos; } \ + else { condmovestack(L,pre,pos); } /* In general, 'pre'/'pos' are empty (nothing to save) */ #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) -#define savestack(L,p) ((char *)(p) - (char *)L->stack) -#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) +#define savestack(L,pt) (cast_charp(pt) - cast_charp(L->stack.p)) +#define restorestack(L,n) cast(StkId, cast_charp(L->stack.p) + (n)) + + +/* macro to check stack size, preserving 'p' */ +#define checkstackp(L,n,p) \ + luaD_checkstackaux(L, n, \ + ptrdiff_t t__ = savestack(L, p), /* save 'p' */ \ + p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ + + +/* macro to check stack size and GC, preserving 'p' */ +#define checkstackGCp(L,n,p) \ + luaD_checkstackaux(L, n, \ + ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ + luaC_checkGC(L), /* stack grow uses memory */ \ + p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ + + +/* macro to check stack size and GC */ +#define checkstackGC(L,fsize) \ + luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) /* type of protected functions, to be ran by 'runprotected' */ typedef void (*Pfunc) (lua_State *L, void *ud); +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, const char *mode); -LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); -LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, + int fTransfer, int nTransfer); +LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); +LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, + int narg1, int delta); +LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t oldtop, ptrdiff_t ef); -LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, - int nres); -LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); -LUAI_FUNC void luaD_growstack (lua_State *L, int n); +LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); +LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); +LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror); LUAI_FUNC void luaD_shrinkstack (lua_State *L); LUAI_FUNC void luaD_inctop (lua_State *L); diff --git a/liblua/ldump.c b/liblua/ldump.c index f025acac..f231691b 100644 --- a/liblua/ldump.c +++ b/liblua/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 2.37.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ldump.c $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -10,6 +10,7 @@ #include "lprefix.h" +#include #include #include "lua.h" @@ -29,15 +30,15 @@ typedef struct { /* -** All high-level dumps go through DumpVector; you can change it to +** All high-level dumps go through dumpVector; you can change it to ** change the endianness of the result */ -#define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) +#define dumpVector(D,v,n) dumpBlock(D,v,(n)*sizeof((v)[0])) -#define DumpLiteral(s,D) DumpBlock(s, sizeof(s) - sizeof(char), D) +#define dumpLiteral(D, s) dumpBlock(D,s,sizeof(s) - sizeof(char)) -static void DumpBlock (const void *b, size_t size, DumpState *D) { +static void dumpBlock (DumpState *D, const void *b, size_t size) { if (D->status == 0 && size > 0) { lua_unlock(D->L); D->status = (*D->writer)(D->L, b, size, D->data); @@ -46,153 +47,167 @@ static void DumpBlock (const void *b, size_t size, DumpState *D) { } -#define DumpVar(x,D) DumpVector(&x,1,D) +#define dumpVar(D,x) dumpVector(D,&x,1) -static void DumpByte (int y, DumpState *D) { +static void dumpByte (DumpState *D, int y) { lu_byte x = (lu_byte)y; - DumpVar(x, D); + dumpVar(D, x); } -static void DumpInt (int x, DumpState *D) { - DumpVar(x, D); +/* +** 'dumpSize' buffer size: each byte can store up to 7 bits. (The "+6" +** rounds up the division.) +*/ +#define DIBS ((sizeof(size_t) * CHAR_BIT + 6) / 7) + +static void dumpSize (DumpState *D, size_t x) { + lu_byte buff[DIBS]; + int n = 0; + do { + buff[DIBS - (++n)] = x & 0x7f; /* fill buffer in reverse order */ + x >>= 7; + } while (x != 0); + buff[DIBS - 1] |= 0x80; /* mark last byte */ + dumpVector(D, buff + DIBS - n, n); +} + + +static void dumpInt (DumpState *D, int x) { + dumpSize(D, x); } -static void DumpNumber (lua_Number x, DumpState *D) { - DumpVar(x, D); +static void dumpNumber (DumpState *D, lua_Number x) { + dumpVar(D, x); } -static void DumpInteger (lua_Integer x, DumpState *D) { - DumpVar(x, D); +static void dumpInteger (DumpState *D, lua_Integer x) { + dumpVar(D, x); } -static void DumpString (const TString *s, DumpState *D) { +static void dumpString (DumpState *D, const TString *s) { if (s == NULL) - DumpByte(0, D); + dumpSize(D, 0); else { - size_t size = tsslen(s) + 1; /* include trailing '\0' */ + size_t size = tsslen(s); const char *str = getstr(s); - if (size < 0xFF) - DumpByte(cast_int(size), D); - else { - DumpByte(0xFF, D); - DumpVar(size, D); - } - DumpVector(str, size - 1, D); /* no need to save '\0' */ + dumpSize(D, size + 1); + dumpVector(D, str, size); } } -static void DumpCode (const Proto *f, DumpState *D) { - DumpInt(f->sizecode, D); - DumpVector(f->code, f->sizecode, D); +static void dumpCode (DumpState *D, const Proto *f) { + dumpInt(D, f->sizecode); + dumpVector(D, f->code, f->sizecode); } -static void DumpFunction(const Proto *f, TString *psource, DumpState *D); +static void dumpFunction(DumpState *D, const Proto *f, TString *psource); -static void DumpConstants (const Proto *f, DumpState *D) { +static void dumpConstants (DumpState *D, const Proto *f) { int i; int n = f->sizek; - DumpInt(n, D); + dumpInt(D, n); for (i = 0; i < n; i++) { const TValue *o = &f->k[i]; - DumpByte(ttype(o), D); - switch (ttype(o)) { - case LUA_TNIL: - break; - case LUA_TBOOLEAN: - DumpByte(bvalue(o), D); - break; - case LUA_TNUMFLT: - DumpNumber(fltvalue(o), D); - break; - case LUA_TNUMINT: - DumpInteger(ivalue(o), D); - break; - case LUA_TSHRSTR: - case LUA_TLNGSTR: - DumpString(tsvalue(o), D); - break; - default: - lua_assert(0); + int tt = ttypetag(o); + dumpByte(D, tt); + switch (tt) { + case LUA_VNUMFLT: + dumpNumber(D, fltvalue(o)); + break; + case LUA_VNUMINT: + dumpInteger(D, ivalue(o)); + break; + case LUA_VSHRSTR: + case LUA_VLNGSTR: + dumpString(D, tsvalue(o)); + break; + default: + lua_assert(tt == LUA_VNIL || tt == LUA_VFALSE || tt == LUA_VTRUE); } } } -static void DumpProtos (const Proto *f, DumpState *D) { +static void dumpProtos (DumpState *D, const Proto *f) { int i; int n = f->sizep; - DumpInt(n, D); + dumpInt(D, n); for (i = 0; i < n; i++) - DumpFunction(f->p[i], f->source, D); + dumpFunction(D, f->p[i], f->source); } -static void DumpUpvalues (const Proto *f, DumpState *D) { +static void dumpUpvalues (DumpState *D, const Proto *f) { int i, n = f->sizeupvalues; - DumpInt(n, D); + dumpInt(D, n); for (i = 0; i < n; i++) { - DumpByte(f->upvalues[i].instack, D); - DumpByte(f->upvalues[i].idx, D); + dumpByte(D, f->upvalues[i].instack); + dumpByte(D, f->upvalues[i].idx); + dumpByte(D, f->upvalues[i].kind); } } -static void DumpDebug (const Proto *f, DumpState *D) { +static void dumpDebug (DumpState *D, const Proto *f) { int i, n; n = (D->strip) ? 0 : f->sizelineinfo; - DumpInt(n, D); - DumpVector(f->lineinfo, n, D); + dumpInt(D, n); + dumpVector(D, f->lineinfo, n); + n = (D->strip) ? 0 : f->sizeabslineinfo; + dumpInt(D, n); + for (i = 0; i < n; i++) { + dumpInt(D, f->abslineinfo[i].pc); + dumpInt(D, f->abslineinfo[i].line); + } n = (D->strip) ? 0 : f->sizelocvars; - DumpInt(n, D); + dumpInt(D, n); for (i = 0; i < n; i++) { - DumpString(f->locvars[i].varname, D); - DumpInt(f->locvars[i].startpc, D); - DumpInt(f->locvars[i].endpc, D); + dumpString(D, f->locvars[i].varname); + dumpInt(D, f->locvars[i].startpc); + dumpInt(D, f->locvars[i].endpc); } n = (D->strip) ? 0 : f->sizeupvalues; - DumpInt(n, D); + dumpInt(D, n); for (i = 0; i < n; i++) - DumpString(f->upvalues[i].name, D); + dumpString(D, f->upvalues[i].name); } -static void DumpFunction (const Proto *f, TString *psource, DumpState *D) { +static void dumpFunction (DumpState *D, const Proto *f, TString *psource) { if (D->strip || f->source == psource) - DumpString(NULL, D); /* no debug info or same source as its parent */ + dumpString(D, NULL); /* no debug info or same source as its parent */ else - DumpString(f->source, D); - DumpInt(f->linedefined, D); - DumpInt(f->lastlinedefined, D); - DumpByte(f->numparams, D); - DumpByte(f->is_vararg, D); - DumpByte(f->maxstacksize, D); - DumpCode(f, D); - DumpConstants(f, D); - DumpUpvalues(f, D); - DumpProtos(f, D); - DumpDebug(f, D); + dumpString(D, f->source); + dumpInt(D, f->linedefined); + dumpInt(D, f->lastlinedefined); + dumpByte(D, f->numparams); + dumpByte(D, f->is_vararg); + dumpByte(D, f->maxstacksize); + dumpCode(D, f); + dumpConstants(D, f); + dumpUpvalues(D, f); + dumpProtos(D, f); + dumpDebug(D, f); } -static void DumpHeader (DumpState *D) { - DumpLiteral(LUA_SIGNATURE, D); - DumpByte(LUAC_VERSION, D); - DumpByte(LUAC_FORMAT, D); - DumpLiteral(LUAC_DATA, D); - DumpByte(sizeof(int), D); - DumpByte(sizeof(size_t), D); - DumpByte(sizeof(Instruction), D); - DumpByte(sizeof(lua_Integer), D); - DumpByte(sizeof(lua_Number), D); - DumpInteger(LUAC_INT, D); - DumpNumber(LUAC_NUM, D); +static void dumpHeader (DumpState *D) { + dumpLiteral(D, LUA_SIGNATURE); + dumpByte(D, LUAC_VERSION); + dumpByte(D, LUAC_FORMAT); + dumpLiteral(D, LUAC_DATA); + dumpByte(D, sizeof(Instruction)); + dumpByte(D, sizeof(lua_Integer)); + dumpByte(D, sizeof(lua_Number)); + dumpInteger(D, LUAC_INT); + dumpNumber(D, LUAC_NUM); } @@ -207,9 +222,9 @@ int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, D.data = data; D.strip = strip; D.status = 0; - DumpHeader(&D); - DumpByte(f->sizeupvalues, &D); - DumpFunction(f, NULL, &D); + dumpHeader(&D); + dumpByte(&D, f->sizeupvalues); + dumpFunction(&D, f, NULL); return D.status; } diff --git a/liblua/lfunc.c b/liblua/lfunc.c index ccafbb8a..0945f241 100644 --- a/liblua/lfunc.c +++ b/liblua/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.45.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lfunc.c $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -14,6 +14,8 @@ #include "lua.h" +#include "ldebug.h" +#include "ldo.h" #include "lfunc.h" #include "lgc.h" #include "lmem.h" @@ -22,92 +24,232 @@ -CClosure *luaF_newCclosure (lua_State *L, int n) { - GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); +CClosure *luaF_newCclosure (lua_State *L, int nupvals) { + GCObject *o = luaC_newobj(L, LUA_VCCL, sizeCclosure(nupvals)); CClosure *c = gco2ccl(o); - c->nupvalues = cast_byte(n); + c->nupvalues = cast_byte(nupvals); return c; } -LClosure *luaF_newLclosure (lua_State *L, int n) { - GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); +LClosure *luaF_newLclosure (lua_State *L, int nupvals) { + GCObject *o = luaC_newobj(L, LUA_VLCL, sizeLclosure(nupvals)); LClosure *c = gco2lcl(o); c->p = NULL; - c->nupvalues = cast_byte(n); - while (n--) c->upvals[n] = NULL; + c->nupvalues = cast_byte(nupvals); + while (nupvals--) c->upvals[nupvals] = NULL; return c; } + /* ** fill a closure with new closed upvalues */ void luaF_initupvals (lua_State *L, LClosure *cl) { int i; for (i = 0; i < cl->nupvalues; i++) { - UpVal *uv = luaM_new(L, UpVal); - uv->refcount = 1; - uv->v = &uv->u.value; /* make it closed */ - setnilvalue(uv->v); + GCObject *o = luaC_newobj(L, LUA_VUPVAL, sizeof(UpVal)); + UpVal *uv = gco2upv(o); + uv->v.p = &uv->u.value; /* make it closed */ + setnilvalue(uv->v.p); cl->upvals[i] = uv; + luaC_objbarrier(L, cl, uv); } } +/* +** Create a new upvalue at the given level, and link it to the list of +** open upvalues of 'L' after entry 'prev'. +**/ +static UpVal *newupval (lua_State *L, StkId level, UpVal **prev) { + GCObject *o = luaC_newobj(L, LUA_VUPVAL, sizeof(UpVal)); + UpVal *uv = gco2upv(o); + UpVal *next = *prev; + uv->v.p = s2v(level); /* current value lives in the stack */ + uv->u.open.next = next; /* link it to list of open upvalues */ + uv->u.open.previous = prev; + if (next) + next->u.open.previous = &uv->u.open.next; + *prev = uv; + if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ + L->twups = G(L)->twups; /* link it to the list */ + G(L)->twups = L; + } + return uv; +} + + +/* +** Find and reuse, or create if it does not exist, an upvalue +** at the given level. +*/ UpVal *luaF_findupval (lua_State *L, StkId level) { UpVal **pp = &L->openupval; UpVal *p; - UpVal *uv; lua_assert(isintwups(L) || L->openupval == NULL); - while (*pp != NULL && (p = *pp)->v >= level) { - lua_assert(upisopen(p)); - if (p->v == level) /* found a corresponding upvalue? */ + while ((p = *pp) != NULL && uplevel(p) >= level) { /* search for it */ + lua_assert(!isdead(G(L), p)); + if (uplevel(p) == level) /* corresponding upvalue? */ return p; /* return it */ pp = &p->u.open.next; } - /* not found: create a new upvalue */ - uv = luaM_new(L, UpVal); - uv->refcount = 0; - uv->u.open.next = *pp; /* link it to list of open upvalues */ - uv->u.open.touched = 1; - *pp = uv; - uv->v = level; /* current value lives in the stack */ - if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ - L->twups = G(L)->twups; /* link it to the list */ - G(L)->twups = L; + /* not found: create a new upvalue after 'pp' */ + return newupval(L, level, pp); +} + + +/* +** Call closing method for object 'obj' with error message 'err'. The +** boolean 'yy' controls whether the call is yieldable. +** (This function assumes EXTRA_STACK.) +*/ +static void callclosemethod (lua_State *L, TValue *obj, TValue *err, int yy) { + StkId top = L->top.p; + const TValue *tm = luaT_gettmbyobj(L, obj, TM_CLOSE); + setobj2s(L, top, tm); /* will call metamethod... */ + setobj2s(L, top + 1, obj); /* with 'self' as the 1st argument */ + setobj2s(L, top + 2, err); /* and error msg. as 2nd argument */ + L->top.p = top + 3; /* add function and arguments */ + if (yy) + luaD_call(L, top, 0); + else + luaD_callnoyield(L, top, 0); +} + + +/* +** Check whether object at given level has a close metamethod and raise +** an error if not. +*/ +static void checkclosemth (lua_State *L, StkId level) { + const TValue *tm = luaT_gettmbyobj(L, s2v(level), TM_CLOSE); + if (ttisnil(tm)) { /* no metamethod? */ + int idx = cast_int(level - L->ci->func.p); /* variable index */ + const char *vname = luaG_findlocal(L, L->ci, idx, NULL); + if (vname == NULL) vname = "?"; + luaG_runerror(L, "variable '%s' got a non-closable value", vname); } - return uv; } -void luaF_close (lua_State *L, StkId level) { +/* +** Prepare and call a closing method. +** If status is CLOSEKTOP, the call to the closing method will be pushed +** at the top of the stack. Otherwise, values can be pushed right after +** the 'level' of the upvalue being closed, as everything after that +** won't be used again. +*/ +static void prepcallclosemth (lua_State *L, StkId level, int status, int yy) { + TValue *uv = s2v(level); /* value being closed */ + TValue *errobj; + if (status == CLOSEKTOP) + errobj = &G(L)->nilvalue; /* error object is nil */ + else { /* 'luaD_seterrorobj' will set top to level + 2 */ + errobj = s2v(level + 1); /* error object goes after 'uv' */ + luaD_seterrorobj(L, status, level + 1); /* set error object */ + } + callclosemethod(L, uv, errobj, yy); +} + + +/* +** Maximum value for deltas in 'tbclist', dependent on the type +** of delta. (This macro assumes that an 'L' is in scope where it +** is used.) +*/ +#define MAXDELTA \ + ((256ul << ((sizeof(L->stack.p->tbclist.delta) - 1) * 8)) - 1) + + +/* +** Insert a variable in the list of to-be-closed variables. +*/ +void luaF_newtbcupval (lua_State *L, StkId level) { + lua_assert(level > L->tbclist.p); + if (l_isfalse(s2v(level))) + return; /* false doesn't need to be closed */ + checkclosemth(L, level); /* value must have a close method */ + while (cast_uint(level - L->tbclist.p) > MAXDELTA) { + L->tbclist.p += MAXDELTA; /* create a dummy node at maximum delta */ + L->tbclist.p->tbclist.delta = 0; + } + level->tbclist.delta = cast(unsigned short, level - L->tbclist.p); + L->tbclist.p = level; +} + + +void luaF_unlinkupval (UpVal *uv) { + lua_assert(upisopen(uv)); + *uv->u.open.previous = uv->u.open.next; + if (uv->u.open.next) + uv->u.open.next->u.open.previous = uv->u.open.previous; +} + + +/* +** Close all upvalues up to the given stack level. +*/ +void luaF_closeupval (lua_State *L, StkId level) { UpVal *uv; - while (L->openupval != NULL && (uv = L->openupval)->v >= level) { - lua_assert(upisopen(uv)); - L->openupval = uv->u.open.next; /* remove from 'open' list */ - if (uv->refcount == 0) /* no references? */ - luaM_free(L, uv); /* free upvalue */ - else { - setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ - uv->v = &uv->u.value; /* now current value lives here */ - luaC_upvalbarrier(L, uv); + StkId upl; /* stack index pointed by 'uv' */ + while ((uv = L->openupval) != NULL && (upl = uplevel(uv)) >= level) { + TValue *slot = &uv->u.value; /* new position for value */ + lua_assert(uplevel(uv) < L->top.p); + luaF_unlinkupval(uv); /* remove upvalue from 'openupval' list */ + setobj(L, slot, uv->v.p); /* move value to upvalue slot */ + uv->v.p = slot; /* now current value lives here */ + if (!iswhite(uv)) { /* neither white nor dead? */ + nw2black(uv); /* closed upvalues cannot be gray */ + luaC_barrier(L, uv, slot); } } } +/* +** Remove first element from the tbclist plus its dummy nodes. +*/ +static void poptbclist (lua_State *L) { + StkId tbc = L->tbclist.p; + lua_assert(tbc->tbclist.delta > 0); /* first element cannot be dummy */ + tbc -= tbc->tbclist.delta; + while (tbc > L->stack.p && tbc->tbclist.delta == 0) + tbc -= MAXDELTA; /* remove dummy nodes */ + L->tbclist.p = tbc; +} + + +/* +** Close all upvalues and to-be-closed variables up to the given stack +** level. Return restored 'level'. +*/ +StkId luaF_close (lua_State *L, StkId level, int status, int yy) { + ptrdiff_t levelrel = savestack(L, level); + luaF_closeupval(L, level); /* first, close the upvalues */ + while (L->tbclist.p >= level) { /* traverse tbc's down to that level */ + StkId tbc = L->tbclist.p; /* get variable index */ + poptbclist(L); /* remove it from list */ + prepcallclosemth(L, tbc, status, yy); /* close variable */ + level = restorestack(L, levelrel); + } + return level; +} + + Proto *luaF_newproto (lua_State *L) { - GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto)); + GCObject *o = luaC_newobj(L, LUA_VPROTO, sizeof(Proto)); Proto *f = gco2p(o); f->k = NULL; f->sizek = 0; f->p = NULL; f->sizep = 0; f->code = NULL; - f->cache = NULL; f->sizecode = 0; f->lineinfo = NULL; f->sizelineinfo = 0; + f->abslineinfo = NULL; + f->sizeabslineinfo = 0; f->upvalues = NULL; f->sizeupvalues = 0; f->numparams = 0; @@ -127,6 +269,7 @@ void luaF_freeproto (lua_State *L, Proto *f) { luaM_freearray(L, f->p, f->sizep); luaM_freearray(L, f->k, f->sizek); luaM_freearray(L, f->lineinfo, f->sizelineinfo); + luaM_freearray(L, f->abslineinfo, f->sizeabslineinfo); luaM_freearray(L, f->locvars, f->sizelocvars); luaM_freearray(L, f->upvalues, f->sizeupvalues); luaM_free(L, f); diff --git a/liblua/lfunc.h b/liblua/lfunc.h index c916e987..3be265ef 100644 --- a/liblua/lfunc.h +++ b/liblua/lfunc.h @@ -1,5 +1,5 @@ /* -** $Id: lfunc.h,v 2.15.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lfunc.h $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -11,11 +11,11 @@ #include "lobject.h" -#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ - cast(int, sizeof(TValue)*((n)-1))) +#define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ + cast_int(sizeof(TValue)) * (n)) -#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ - cast(int, sizeof(TValue *)*((n)-1))) +#define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ + cast_int(sizeof(TValue *)) * (n)) /* test whether thread is in 'twups' list */ @@ -29,30 +29,33 @@ #define MAXUPVAL 255 +#define upisopen(up) ((up)->v.p != &(up)->u.value) + + +#define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v.p)) + + /* -** Upvalues for Lua closures +** maximum number of misses before giving up the cache of closures +** in prototypes */ -struct UpVal { - TValue *v; /* points to stack or to its own value */ - lu_mem refcount; /* reference counter */ - union { - struct { /* (when open) */ - UpVal *next; /* linked list */ - int touched; /* mark to avoid cycles with dead threads */ - } open; - TValue value; /* the value (when closed) */ - } u; -}; +#define MAXMISS 10 + + -#define upisopen(up) ((up)->v != &(up)->u.value) +/* special status to close upvalues preserving the top of the stack */ +#define CLOSEKTOP (-1) LUAI_FUNC Proto *luaF_newproto (lua_State *L); -LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); -LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); +LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); +LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); -LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level); +LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, int status, int yy); +LUAI_FUNC void luaF_unlinkupval (UpVal *uv); LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, int pc); diff --git a/liblua/lgc.c b/liblua/lgc.c index db4df829..5817f9ee 100644 --- a/liblua/lgc.c +++ b/liblua/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.215.1.2 2017/08/31 16:15:27 roberto Exp $ +** $Id: lgc.c $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -9,9 +9,10 @@ #include "lprefix.h" - +#include #include + #include "lua.h" #include "ldebug.h" @@ -27,29 +28,29 @@ /* -** internal state for collector while inside the atomic phase. The -** collector should never be in this state while running regular code. +** Maximum number of elements to sweep in each single step. +** (Large enough to dissipate fixed overheads but small enough +** to allow small steps for the collector.) */ -#define GCSinsideatomic (GCSpause + 1) +#define GCSWEEPMAX 100 /* -** cost of sweeping one element (the size of a small object divided -** by some adjust for the sweep speed) +** Maximum number of finalizers to call in each single step. */ -#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) +#define GCFINMAX 10 -/* maximum number of elements to sweep in each single step */ -#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) -/* cost of calling one finalizer */ -#define GCFINALIZECOST GCSWEEPCOST +/* +** Cost of calling one finalizer. +*/ +#define GCFINALIZECOST 50 /* -** macro to adjust 'stepmul': 'stepmul' is actually used like -** 'stepmul / STEPMULADJ' (value chosen by tests) +** The equivalent, in bytes, of one unit of "work" (visiting a slot, +** sweeping an object, etc.) */ -#define STEPMULADJ 200 +#define WORK2MEM sizeof(TValue) /* @@ -59,30 +60,42 @@ #define PAUSEADJ 100 -/* -** 'makewhite' erases all color bits then sets only the current white -** bit -*/ -#define maskcolors (~(bitmask(BLACKBIT) | WHITEBITS)) +/* mask with all color bits */ +#define maskcolors (bitmask(BLACKBIT) | WHITEBITS) + +/* mask with all GC bits */ +#define maskgcbits (maskcolors | AGEBITS) + + +/* macro to erase all color bits then set only the current white bit */ #define makewhite(g,x) \ - (x->marked = cast_byte((x->marked & maskcolors) | luaC_white(g))) + (x->marked = cast_byte((x->marked & ~maskcolors) | luaC_white(g))) + +/* make an object gray (neither white nor black) */ +#define set2gray(x) resetbits(x->marked, maskcolors) -#define white2gray(x) resetbits(x->marked, WHITEBITS) -#define black2gray(x) resetbit(x->marked, BLACKBIT) + +/* make an object black (coming from any color) */ +#define set2black(x) \ + (x->marked = cast_byte((x->marked & ~WHITEBITS) | bitmask(BLACKBIT))) #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) -#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n))) +#define keyiswhite(n) (keyiscollectable(n) && iswhite(gckey(n))) -#define checkconsistency(obj) \ - lua_longassert(!iscollectable(obj) || righttt(obj)) +/* +** Protected access to objects in values +*/ +#define gcvalueN(o) (iscollectable(o) ? gcvalue(o) : NULL) -#define markvalue(g,o) { checkconsistency(o); \ +#define markvalue(g,o) { checkliveness(g->mainthread,o); \ if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } +#define markkey(g, n) { if keyiswhite(n) reallymarkobject(g,gckey(n)); } + #define markobject(g,t) { if (iswhite(t)) reallymarkobject(g, obj2gco(t)); } /* @@ -92,6 +105,8 @@ #define markobjectN(g,t) { if (t) markobject(g,t); } static void reallymarkobject (global_State *g, GCObject *o); +static lu_mem atomic (lua_State *L); +static void entersweep (lua_State *L); /* @@ -104,28 +119,59 @@ static void reallymarkobject (global_State *g, GCObject *o); /* ** one after last element in a hash array */ -#define gnodelast(h) gnode(h, cast(size_t, sizenode(h))) +#define gnodelast(h) gnode(h, cast_sizet(sizenode(h))) + + +static GCObject **getgclist (GCObject *o) { + switch (o->tt) { + case LUA_VTABLE: return &gco2t(o)->gclist; + case LUA_VLCL: return &gco2lcl(o)->gclist; + case LUA_VCCL: return &gco2ccl(o)->gclist; + case LUA_VTHREAD: return &gco2th(o)->gclist; + case LUA_VPROTO: return &gco2p(o)->gclist; + case LUA_VUSERDATA: { + Udata *u = gco2u(o); + lua_assert(u->nuvalue > 0); + return &u->gclist; + } + default: lua_assert(0); return 0; + } +} + + +/* +** Link a collectable object 'o' with a known type into the list 'p'. +** (Must be a macro to access the 'gclist' field in different types.) +*/ +#define linkgclist(o,p) linkgclist_(obj2gco(o), &(o)->gclist, &(p)) + +static void linkgclist_ (GCObject *o, GCObject **pnext, GCObject **list) { + lua_assert(!isgray(o)); /* cannot be in a gray list */ + *pnext = *list; + *list = o; + set2gray(o); /* now it is */ +} /* -** link collectable object 'o' into list pointed by 'p' +** Link a generic collectable object 'o' into the list 'p'. */ -#define linkgclist(o,p) ((o)->gclist = (p), (p) = obj2gco(o)) +#define linkobjgclist(o,p) linkgclist_(obj2gco(o), getgclist(o), &(p)) + /* -** If key is not marked, mark its entry as dead. This allows key to be -** collected, but keeps its entry in the table. A dead node is needed -** when Lua looks up for a key (it may be part of a chain) and when -** traversing a weak table (key might be removed from the table during -** traversal). Other places never manipulate dead keys, because its -** associated nil value is enough to signal that the entry is logically -** empty. +** Clear keys for empty entries in tables. If entry is empty, mark its +** entry as dead. This allows the collection of the key, but keeps its +** entry in the table: its removal could break a chain and could break +** a table traversal. Other places never manipulate dead keys, because +** its associated empty value is enough to signal that the entry is +** logically empty. */ -static void removeentry (Node *n) { - lua_assert(ttisnil(gval(n))); - if (valiswhite(gkey(n))) - setdeadvalue(wgkey(n)); /* unused and unmarked key; remove it */ +static void clearkey (Node *n) { + lua_assert(isempty(gval(n))); + if (keyiscollectable(n)) + setdeadkey(n); /* unused key; remove it */ } @@ -136,30 +182,43 @@ static void removeentry (Node *n) { ** other objects: if really collected, cannot keep them; for objects ** being finalized, keep them in keys, but not in values */ -static int iscleared (global_State *g, const TValue *o) { - if (!iscollectable(o)) return 0; - else if (ttisstring(o)) { - markobject(g, tsvalue(o)); /* strings are 'values', so are never weak */ +static int iscleared (global_State *g, const GCObject *o) { + if (o == NULL) return 0; /* non-collectable value */ + else if (novariant(o->tt) == LUA_TSTRING) { + markobject(g, o); /* strings are 'values', so are never weak */ return 0; } - else return iswhite(gcvalue(o)); + else return iswhite(o); } /* -** barrier that moves collector forward, that is, mark the white object -** being pointed by a black object. (If in sweep phase, clear the black -** object to white [sweep it] to avoid other barrier calls for this -** same object.) +** Barrier that moves collector forward, that is, marks the white object +** 'v' being pointed by the black object 'o'. In the generational +** mode, 'v' must also become old, if 'o' is old; however, it cannot +** be changed directly to OLD, because it may still point to non-old +** objects. So, it is marked as OLD0. In the next cycle it will become +** OLD1, and in the next it will finally become OLD (regular old). By +** then, any object it points to will also be old. If called in the +** incremental sweep phase, it clears the black object to white (sweep +** it) to avoid other barrier calls for this same object. (That cannot +** be done is generational mode, as its sweep does not distinguish +** whites from deads.) */ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { global_State *g = G(L); lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); - if (keepinvariant(g)) /* must keep invariant? */ + if (keepinvariant(g)) { /* must keep invariant? */ reallymarkobject(g, v); /* restore invariant */ + if (isold(o)) { + lua_assert(!isold(v)); /* white object could not be old */ + setage(v, G_OLD0); /* restore generational invariant */ + } + } else { /* sweep phase */ lua_assert(issweepphase(g)); - makewhite(g, o); /* mark main obj. as white to avoid other barriers */ + if (g->gckind == KGC_INC) /* incremental mode? */ + makewhite(g, o); /* mark 'o' as white to avoid other barriers */ } } @@ -168,33 +227,24 @@ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { ** barrier that moves collector backward, that is, mark the black object ** pointing to a white object as gray again. */ -void luaC_barrierback_ (lua_State *L, Table *t) { +void luaC_barrierback_ (lua_State *L, GCObject *o) { global_State *g = G(L); - lua_assert(isblack(t) && !isdead(g, t)); - black2gray(t); /* make table gray (again) */ - linkgclist(t, g->grayagain); -} - - -/* -** barrier for assignments to closed upvalues. Because upvalues are -** shared among closures, it is impossible to know the color of all -** closures pointing to it. So, we assume that the object being assigned -** must be marked. -*/ -void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) { - global_State *g = G(L); - GCObject *o = gcvalue(uv->v); - lua_assert(!upisopen(uv)); /* ensured by macro luaC_upvalbarrier */ - if (keepinvariant(g)) - markobject(g, o); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert((g->gckind == KGC_GEN) == (isold(o) && getage(o) != G_TOUCHED1)); + if (getage(o) == G_TOUCHED2) /* already in gray list? */ + set2gray(o); /* make it gray to become touched1 */ + else /* link it in 'grayagain' and paint it gray */ + linkobjgclist(o, g->grayagain); + if (isold(o)) /* generational mode? */ + setage(o, G_TOUCHED1); /* touched in current cycle */ } void luaC_fix (lua_State *L, GCObject *o) { global_State *g = G(L); lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */ - white2gray(o); /* they will be gray forever */ + set2gray(o); /* they will be gray forever */ + setage(o, G_OLD); /* and old forever */ g->allgc = o->next; /* remove object from 'allgc' list */ o->next = g->fixedgc; /* link it to 'fixedgc' list */ g->fixedgc = o; @@ -202,12 +252,13 @@ void luaC_fix (lua_State *L, GCObject *o) { /* -** create a new collectable object (with given type and size) and link -** it to 'allgc' list. +** create a new collectable object (with given type, size, and offset) +** and link it to 'allgc' list. */ -GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { +GCObject *luaC_newobjdt (lua_State *L, int tt, size_t sz, size_t offset) { global_State *g = G(L); - GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz)); + char *p = cast_charp(luaM_newobject(L, novariant(tt), sz)); + GCObject *o = cast(GCObject *, p + offset); o->marked = luaC_white(g); o->tt = tt; o->next = g->allgc; @@ -215,6 +266,11 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { return o; } + +GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { + return luaC_newobjdt(L, tt, sz, 0); +} + /* }====================================================== */ @@ -227,55 +283,45 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { /* -** mark an object. Userdata, strings, and closed upvalues are visited -** and turned black here. Other objects are marked gray and added -** to appropriate list to be visited (and turned black) later. (Open -** upvalues are already linked in 'headuv' list.) +** Mark an object. Userdata with no user values, strings, and closed +** upvalues are visited and turned black here. Open upvalues are +** already indirectly linked through their respective threads in the +** 'twups' list, so they don't go to the gray list; nevertheless, they +** are kept gray to avoid barriers, as their values will be revisited +** by the thread or by 'remarkupvals'. Other objects are added to the +** gray list to be visited (and turned black) later. Both userdata and +** upvalues can call this function recursively, but this recursion goes +** for at most two levels: An upvalue cannot refer to another upvalue +** (only closures can), and a userdata's metatable must be a table. */ static void reallymarkobject (global_State *g, GCObject *o) { - reentry: - white2gray(o); switch (o->tt) { - case LUA_TSHRSTR: { - gray2black(o); - g->GCmemtrav += sizelstring(gco2ts(o)->shrlen); + case LUA_VSHRSTR: + case LUA_VLNGSTR: { + set2black(o); /* nothing to visit */ break; } - case LUA_TLNGSTR: { - gray2black(o); - g->GCmemtrav += sizelstring(gco2ts(o)->u.lnglen); + case LUA_VUPVAL: { + UpVal *uv = gco2upv(o); + if (upisopen(uv)) + set2gray(uv); /* open upvalues are kept gray */ + else + set2black(uv); /* closed upvalues are visited here */ + markvalue(g, uv->v.p); /* mark its content */ break; } - case LUA_TUSERDATA: { - TValue uvalue; - markobjectN(g, gco2u(o)->metatable); /* mark its metatable */ - gray2black(o); - g->GCmemtrav += sizeudata(gco2u(o)); - getuservalue(g->mainthread, gco2u(o), &uvalue); - if (valiswhite(&uvalue)) { /* markvalue(g, &uvalue); */ - o = gcvalue(&uvalue); - goto reentry; + case LUA_VUSERDATA: { + Udata *u = gco2u(o); + if (u->nuvalue == 0) { /* no user values? */ + markobjectN(g, u->metatable); /* mark its metatable */ + set2black(u); /* nothing else to mark */ + break; } - break; - } - case LUA_TLCL: { - linkgclist(gco2lcl(o), g->gray); - break; - } - case LUA_TCCL: { - linkgclist(gco2ccl(o), g->gray); - break; - } - case LUA_TTABLE: { - linkgclist(gco2t(o), g->gray); - break; - } - case LUA_TTHREAD: { - linkgclist(gco2th(o), g->gray); - break; - } - case LUA_TPROTO: { - linkgclist(gco2p(o), g->gray); + /* else... */ + } /* FALLTHROUGH */ + case LUA_VLCL: case LUA_VCCL: case LUA_VTABLE: + case LUA_VTHREAD: case LUA_VPROTO: { + linkobjgclist(o, g->gray); /* to be visited later */ break; } default: lua_assert(0); break; @@ -296,38 +342,58 @@ static void markmt (global_State *g) { /* ** mark all objects in list of being-finalized */ -static void markbeingfnz (global_State *g) { +static lu_mem markbeingfnz (global_State *g) { GCObject *o; - for (o = g->tobefnz; o != NULL; o = o->next) + lu_mem count = 0; + for (o = g->tobefnz; o != NULL; o = o->next) { + count++; markobject(g, o); + } + return count; } /* -** Mark all values stored in marked open upvalues from non-marked threads. -** (Values from marked threads were already marked when traversing the -** thread.) Remove from the list threads that no longer have upvalues and -** not-marked threads. +** For each non-marked thread, simulates a barrier between each open +** upvalue and its value. (If the thread is collected, the value will be +** assigned to the upvalue, but then it can be too late for the barrier +** to act. The "barrier" does not need to check colors: A non-marked +** thread must be young; upvalues cannot be older than their threads; so +** any visited upvalue must be young too.) Also removes the thread from +** the list, as it was already visited. Removes also threads with no +** upvalues, as they have nothing to be checked. (If the thread gets an +** upvalue later, it will be linked in the list again.) */ -static void remarkupvals (global_State *g) { +static int remarkupvals (global_State *g) { lua_State *thread; lua_State **p = &g->twups; + int work = 0; /* estimate of how much work was done here */ while ((thread = *p) != NULL) { - lua_assert(!isblack(thread)); /* threads are never black */ - if (isgray(thread) && thread->openupval != NULL) + work++; + if (!iswhite(thread) && thread->openupval != NULL) p = &thread->twups; /* keep marked thread with upvalues in the list */ else { /* thread is not marked or without upvalues */ UpVal *uv; + lua_assert(!isold(thread) || thread->openupval == NULL); *p = thread->twups; /* remove thread from the list */ thread->twups = thread; /* mark that it is out of list */ for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) { - if (uv->u.open.touched) { - markvalue(g, uv->v); /* remark upvalue's value */ - uv->u.open.touched = 0; + lua_assert(getage(uv) <= getage(thread)); + work++; + if (!iswhite(uv)) { /* upvalue already visited? */ + lua_assert(upisopen(uv) && isgray(uv)); + markvalue(g, uv->v.p); /* mark its value */ } } } } + return work; +} + + +static void cleargraylists (global_State *g) { + g->gray = g->grayagain = NULL; + g->weak = g->allweak = g->ephemeron = NULL; } @@ -335,8 +401,7 @@ static void remarkupvals (global_State *g) { ** mark root set and reset all gray lists, to start a new collection */ static void restartcollection (global_State *g) { - g->gray = g->grayagain = NULL; - g->weak = g->allweak = g->ephemeron = NULL; + cleargraylists(g); markobject(g, g->mainthread); markvalue(g, &g->l_registry); markmt(g); @@ -352,6 +417,26 @@ static void restartcollection (global_State *g) { ** ======================================================= */ + +/* +** Check whether object 'o' should be kept in the 'grayagain' list for +** post-processing by 'correctgraylist'. (It could put all old objects +** in the list and leave all the work to 'correctgraylist', but it is +** more efficient to avoid adding elements that will be removed.) Only +** TOUCHED1 objects need to be in the list. TOUCHED2 doesn't need to go +** back to a gray list, but then it must become OLD. (That is what +** 'correctgraylist' does when it finds a TOUCHED2 object.) +*/ +static void genlink (global_State *g, GCObject *o) { + lua_assert(isblack(o)); + if (getage(o) == G_TOUCHED1) { /* touched in this cycle? */ + linkobjgclist(o, g->grayagain); /* link it back in 'grayagain' */ + } /* everything else do not need to be linked back */ + else if (getage(o) == G_TOUCHED2) + changeage(o, G_TOUCHED2, G_OLD); /* advance age */ +} + + /* ** Traverse a table with weak values and link it to proper list. During ** propagate phase, keep it in 'grayagain' list, to be revisited in the @@ -362,22 +447,21 @@ static void traverseweakvalue (global_State *g, Table *h) { Node *n, *limit = gnodelast(h); /* if there is array part, assume it may have white values (it is not worth traversing it now just to check) */ - int hasclears = (h->sizearray > 0); + int hasclears = (h->alimit > 0); for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ - checkdeadkey(n); - if (ttisnil(gval(n))) /* entry is empty? */ - removeentry(n); /* remove it */ + if (isempty(gval(n))) /* entry is empty? */ + clearkey(n); /* clear its key */ else { - lua_assert(!ttisnil(gkey(n))); - markvalue(g, gkey(n)); /* mark key */ - if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ + lua_assert(!keyisnil(n)); + markkey(g, n); + if (!hasclears && iscleared(g, gcvalueN(gval(n)))) /* a white value? */ hasclears = 1; /* table will have to be cleared */ } } - if (g->gcstate == GCSpropagate) - linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ - else if (hasclears) + if (g->gcstate == GCSatomic && hasclears) linkgclist(h, g->weak); /* has to be cleared later */ + else + linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ } @@ -389,27 +473,31 @@ static void traverseweakvalue (global_State *g, Table *h) { ** the atomic phase, if table has any white->white entry, it has to ** be revisited during ephemeron convergence (as that key may turn ** black). Otherwise, if it has any white key, table has to be cleared -** (in the atomic phase). +** (in the atomic phase). In generational mode, some tables +** must be kept in some gray list for post-processing; this is done +** by 'genlink'. */ -static int traverseephemeron (global_State *g, Table *h) { +static int traverseephemeron (global_State *g, Table *h, int inv) { int marked = 0; /* true if an object is marked in this traversal */ int hasclears = 0; /* true if table has white keys */ int hasww = 0; /* true if table has entry "white-key -> white-value" */ - Node *n, *limit = gnodelast(h); unsigned int i; + unsigned int asize = luaH_realasize(h); + unsigned int nsize = sizenode(h); /* traverse array part */ - for (i = 0; i < h->sizearray; i++) { + for (i = 0; i < asize; i++) { if (valiswhite(&h->array[i])) { marked = 1; reallymarkobject(g, gcvalue(&h->array[i])); } } - /* traverse hash part */ - for (n = gnode(h, 0); n < limit; n++) { - checkdeadkey(n); - if (ttisnil(gval(n))) /* entry is empty? */ - removeentry(n); /* remove it */ - else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ + /* traverse hash part; if 'inv', traverse descending + (see 'convergeephemerons') */ + for (i = 0; i < nsize; i++) { + Node *n = inv ? gnode(h, nsize - 1 - i) : gnode(h, i); + if (isempty(gval(n))) /* entry is empty? */ + clearkey(n); /* clear its key */ + else if (iscleared(g, gckeyN(n))) { /* key is not marked (yet)? */ hasclears = 1; /* table must be cleared */ if (valiswhite(gval(n))) /* value not marked yet? */ hasww = 1; /* white-white entry */ @@ -426,6 +514,8 @@ static int traverseephemeron (global_State *g, Table *h) { linkgclist(h, g->ephemeron); /* have to propagate again */ else if (hasclears) /* table has white keys? */ linkgclist(h, g->allweak); /* may have to clean white keys */ + else + genlink(g, obj2gco(h)); /* check whether collector still needs to see it */ return marked; } @@ -433,41 +523,52 @@ static int traverseephemeron (global_State *g, Table *h) { static void traversestrongtable (global_State *g, Table *h) { Node *n, *limit = gnodelast(h); unsigned int i; - for (i = 0; i < h->sizearray; i++) /* traverse array part */ + unsigned int asize = luaH_realasize(h); + for (i = 0; i < asize; i++) /* traverse array part */ markvalue(g, &h->array[i]); for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ - checkdeadkey(n); - if (ttisnil(gval(n))) /* entry is empty? */ - removeentry(n); /* remove it */ + if (isempty(gval(n))) /* entry is empty? */ + clearkey(n); /* clear its key */ else { - lua_assert(!ttisnil(gkey(n))); - markvalue(g, gkey(n)); /* mark key */ - markvalue(g, gval(n)); /* mark value */ + lua_assert(!keyisnil(n)); + markkey(g, n); + markvalue(g, gval(n)); } } + genlink(g, obj2gco(h)); } static lu_mem traversetable (global_State *g, Table *h) { const char *weakkey, *weakvalue; const TValue *mode = gfasttm(g, h->metatable, TM_MODE); + TString *smode; markobjectN(g, h->metatable); - if (mode && ttisstring(mode) && /* is there a weak mode? */ - ((weakkey = strchr(svalue(mode), 'k')), - (weakvalue = strchr(svalue(mode), 'v')), + if (mode && ttisshrstring(mode) && /* is there a weak mode? */ + (cast_void(smode = tsvalue(mode)), + cast_void(weakkey = strchr(getshrstr(smode), 'k')), + cast_void(weakvalue = strchr(getshrstr(smode), 'v')), (weakkey || weakvalue))) { /* is really weak? */ - black2gray(h); /* keep table gray */ if (!weakkey) /* strong keys? */ traverseweakvalue(g, h); else if (!weakvalue) /* strong values? */ - traverseephemeron(g, h); + traverseephemeron(g, h, 0); else /* all weak */ linkgclist(h, g->allweak); /* nothing to traverse now */ } else /* not weak */ traversestrongtable(g, h); - return sizeof(Table) + sizeof(TValue) * h->sizearray + - sizeof(Node) * cast(size_t, allocsizenode(h)); + return 1 + h->alimit + 2 * allocsizenode(h); +} + + +static int traverseudata (global_State *g, Udata *u) { + int i; + markobjectN(g, u->metatable); /* mark its metatable */ + for (i = 0; i < u->nuvalue; i++) + markvalue(g, &u->uv[i].uv); + genlink(g, obj2gco(u)); + return 1 + u->nuvalue; } @@ -478,8 +579,6 @@ static lu_mem traversetable (global_State *g, Table *h) { */ static int traverseproto (global_State *g, Proto *f) { int i; - if (f->cache && iswhite(f->cache)) - f->cache = NULL; /* allow cache to be collected */ markobjectN(g, f->source); for (i = 0; i < f->sizek; i++) /* mark literals */ markvalue(g, &f->k[i]); @@ -489,137 +588,125 @@ static int traverseproto (global_State *g, Proto *f) { markobjectN(g, f->p[i]); for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ markobjectN(g, f->locvars[i].varname); - return sizeof(Proto) + sizeof(Instruction) * f->sizecode + - sizeof(Proto *) * f->sizep + - sizeof(TValue) * f->sizek + - sizeof(int) * f->sizelineinfo + - sizeof(LocVar) * f->sizelocvars + - sizeof(Upvaldesc) * f->sizeupvalues; + return 1 + f->sizek + f->sizeupvalues + f->sizep + f->sizelocvars; } -static lu_mem traverseCclosure (global_State *g, CClosure *cl) { +static int traverseCclosure (global_State *g, CClosure *cl) { int i; for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ markvalue(g, &cl->upvalue[i]); - return sizeCclosure(cl->nupvalues); + return 1 + cl->nupvalues; } /* -** open upvalues point to values in a thread, so those values should -** be marked when the thread is traversed except in the atomic phase -** (because then the value cannot be changed by the thread and the -** thread may not be traversed again) +** Traverse a Lua closure, marking its prototype and its upvalues. +** (Both can be NULL while closure is being created.) */ -static lu_mem traverseLclosure (global_State *g, LClosure *cl) { +static int traverseLclosure (global_State *g, LClosure *cl) { int i; markobjectN(g, cl->p); /* mark its prototype */ - for (i = 0; i < cl->nupvalues; i++) { /* mark its upvalues */ + for (i = 0; i < cl->nupvalues; i++) { /* visit its upvalues */ UpVal *uv = cl->upvals[i]; - if (uv != NULL) { - if (upisopen(uv) && g->gcstate != GCSinsideatomic) - uv->u.open.touched = 1; /* can be marked in 'remarkupvals' */ - else - markvalue(g, uv->v); - } + markobjectN(g, uv); /* mark upvalue */ } - return sizeLclosure(cl->nupvalues); + return 1 + cl->nupvalues; } -static lu_mem traversethread (global_State *g, lua_State *th) { - StkId o = th->stack; +/* +** Traverse a thread, marking the elements in the stack up to its top +** and cleaning the rest of the stack in the final traversal. That +** ensures that the entire stack have valid (non-dead) objects. +** Threads have no barriers. In gen. mode, old threads must be visited +** at every cycle, because they might point to young objects. In inc. +** mode, the thread can still be modified before the end of the cycle, +** and therefore it must be visited again in the atomic phase. To ensure +** these visits, threads must return to a gray list if they are not new +** (which can only happen in generational mode) or if the traverse is in +** the propagate phase (which can only happen in incremental mode). +*/ +static int traversethread (global_State *g, lua_State *th) { + UpVal *uv; + StkId o = th->stack.p; + if (isold(th) || g->gcstate == GCSpropagate) + linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ if (o == NULL) return 1; /* stack not completely built yet */ - lua_assert(g->gcstate == GCSinsideatomic || + lua_assert(g->gcstate == GCSatomic || th->openupval == NULL || isintwups(th)); - for (; o < th->top; o++) /* mark live elements in the stack */ - markvalue(g, o); - if (g->gcstate == GCSinsideatomic) { /* final traversal? */ - StkId lim = th->stack + th->stacksize; /* real end of stack */ - for (; o < lim; o++) /* clear not-marked stack slice */ - setnilvalue(o); + for (; o < th->top.p; o++) /* mark live elements in the stack */ + markvalue(g, s2v(o)); + for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) + markobject(g, uv); /* open upvalues cannot be collected */ + if (g->gcstate == GCSatomic) { /* final traversal? */ + if (!g->gcemergency) + luaD_shrinkstack(th); /* do not change stack in emergency cycle */ + for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++) + setnilvalue(s2v(o)); /* clear dead stack slice */ /* 'remarkupvals' may have removed thread from 'twups' list */ if (!isintwups(th) && th->openupval != NULL) { th->twups = g->twups; /* link it back to the list */ g->twups = th; } } - else if (g->gckind != KGC_EMERGENCY) - luaD_shrinkstack(th); /* do not change stack in emergency cycle */ - return (sizeof(lua_State) + sizeof(TValue) * th->stacksize + - sizeof(CallInfo) * th->nci); + return 1 + stacksize(th); } /* -** traverse one gray object, turning it to black (except for threads, -** which are always gray). +** traverse one gray object, turning it to black. */ -static void propagatemark (global_State *g) { - lu_mem size; +static lu_mem propagatemark (global_State *g) { GCObject *o = g->gray; - lua_assert(isgray(o)); - gray2black(o); + nw2black(o); + g->gray = *getgclist(o); /* remove from 'gray' list */ switch (o->tt) { - case LUA_TTABLE: { - Table *h = gco2t(o); - g->gray = h->gclist; /* remove from 'gray' list */ - size = traversetable(g, h); - break; - } - case LUA_TLCL: { - LClosure *cl = gco2lcl(o); - g->gray = cl->gclist; /* remove from 'gray' list */ - size = traverseLclosure(g, cl); - break; - } - case LUA_TCCL: { - CClosure *cl = gco2ccl(o); - g->gray = cl->gclist; /* remove from 'gray' list */ - size = traverseCclosure(g, cl); - break; - } - case LUA_TTHREAD: { - lua_State *th = gco2th(o); - g->gray = th->gclist; /* remove from 'gray' list */ - linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ - black2gray(o); - size = traversethread(g, th); - break; - } - case LUA_TPROTO: { - Proto *p = gco2p(o); - g->gray = p->gclist; /* remove from 'gray' list */ - size = traverseproto(g, p); - break; - } - default: lua_assert(0); return; + case LUA_VTABLE: return traversetable(g, gco2t(o)); + case LUA_VUSERDATA: return traverseudata(g, gco2u(o)); + case LUA_VLCL: return traverseLclosure(g, gco2lcl(o)); + case LUA_VCCL: return traverseCclosure(g, gco2ccl(o)); + case LUA_VPROTO: return traverseproto(g, gco2p(o)); + case LUA_VTHREAD: return traversethread(g, gco2th(o)); + default: lua_assert(0); return 0; } - g->GCmemtrav += size; } -static void propagateall (global_State *g) { - while (g->gray) propagatemark(g); +static lu_mem propagateall (global_State *g) { + lu_mem tot = 0; + while (g->gray) + tot += propagatemark(g); + return tot; } +/* +** Traverse all ephemeron tables propagating marks from keys to values. +** Repeat until it converges, that is, nothing new is marked. 'dir' +** inverts the direction of the traversals, trying to speed up +** convergence on chains in the same table. +** +*/ static void convergeephemerons (global_State *g) { int changed; + int dir = 0; do { GCObject *w; GCObject *next = g->ephemeron; /* get ephemeron list */ g->ephemeron = NULL; /* tables may return to this list when traversed */ changed = 0; - while ((w = next) != NULL) { - next = gco2t(w)->gclist; - if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */ + while ((w = next) != NULL) { /* for each ephemeron table */ + Table *h = gco2t(w); + next = h->gclist; /* list is rebuilt during loop */ + nw2black(h); /* out of the list (for now) */ + if (traverseephemeron(g, h, dir)) { /* marked some value? */ propagateall(g); /* propagate changes */ changed = 1; /* will have to revisit all ephemeron tables */ } } - } while (changed); + dir = !dir; /* invert direction next time */ + } while (changed); /* repeat until no more changes */ } /* }====================================================== */ @@ -633,19 +720,18 @@ static void convergeephemerons (global_State *g) { /* -** clear entries with unmarked keys from all weaktables in list 'l' up -** to element 'f' +** clear entries with unmarked keys from all weaktables in list 'l' */ -static void clearkeys (global_State *g, GCObject *l, GCObject *f) { - for (; l != f; l = gco2t(l)->gclist) { +static void clearbykeys (global_State *g, GCObject *l) { + for (; l; l = gco2t(l)->gclist) { Table *h = gco2t(l); - Node *n, *limit = gnodelast(h); + Node *limit = gnodelast(h); + Node *n; for (n = gnode(h, 0); n < limit; n++) { - if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { - setnilvalue(gval(n)); /* remove value ... */ - } - if (ttisnil(gval(n))) /* is entry empty? */ - removeentry(n); /* remove entry from table */ + if (iscleared(g, gckeyN(n))) /* unmarked key? */ + setempty(gval(n)); /* remove entry */ + if (isempty(gval(n))) /* is entry empty? */ + clearkey(n); /* clear its key */ } } } @@ -655,65 +741,72 @@ static void clearkeys (global_State *g, GCObject *l, GCObject *f) { ** clear entries with unmarked values from all weaktables in list 'l' up ** to element 'f' */ -static void clearvalues (global_State *g, GCObject *l, GCObject *f) { +static void clearbyvalues (global_State *g, GCObject *l, GCObject *f) { for (; l != f; l = gco2t(l)->gclist) { Table *h = gco2t(l); Node *n, *limit = gnodelast(h); unsigned int i; - for (i = 0; i < h->sizearray; i++) { + unsigned int asize = luaH_realasize(h); + for (i = 0; i < asize; i++) { TValue *o = &h->array[i]; - if (iscleared(g, o)) /* value was collected? */ - setnilvalue(o); /* remove value */ + if (iscleared(g, gcvalueN(o))) /* value was collected? */ + setempty(o); /* remove entry */ } for (n = gnode(h, 0); n < limit; n++) { - if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { - setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* and remove entry from table */ - } + if (iscleared(g, gcvalueN(gval(n)))) /* unmarked value? */ + setempty(gval(n)); /* remove entry */ + if (isempty(gval(n))) /* is entry empty? */ + clearkey(n); /* clear its key */ } } } -void luaC_upvdeccount (lua_State *L, UpVal *uv) { - lua_assert(uv->refcount > 0); - uv->refcount--; - if (uv->refcount == 0 && !upisopen(uv)) - luaM_free(L, uv); -} - - -static void freeLclosure (lua_State *L, LClosure *cl) { - int i; - for (i = 0; i < cl->nupvalues; i++) { - UpVal *uv = cl->upvals[i]; - if (uv) - luaC_upvdeccount(L, uv); - } - luaM_freemem(L, cl, sizeLclosure(cl->nupvalues)); +static void freeupval (lua_State *L, UpVal *uv) { + if (upisopen(uv)) + luaF_unlinkupval(uv); + luaM_free(L, uv); } static void freeobj (lua_State *L, GCObject *o) { switch (o->tt) { - case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; - case LUA_TLCL: { - freeLclosure(L, gco2lcl(o)); + case LUA_VPROTO: + luaF_freeproto(L, gco2p(o)); + break; + case LUA_VUPVAL: + freeupval(L, gco2upv(o)); + break; + case LUA_VLCL: { + LClosure *cl = gco2lcl(o); + luaM_freemem(L, cl, sizeLclosure(cl->nupvalues)); + break; + } + case LUA_VCCL: { + CClosure *cl = gco2ccl(o); + luaM_freemem(L, cl, sizeCclosure(cl->nupvalues)); break; } - case LUA_TCCL: { - luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); + case LUA_VTABLE: + luaH_free(L, gco2t(o)); + break; + case LUA_VTHREAD: + luaE_freethread(L, gco2th(o)); + break; + case LUA_VUSERDATA: { + Udata *u = gco2u(o); + luaM_freemem(L, o, sizeudata(u->nuvalue, u->len)); break; } - case LUA_TTABLE: luaH_free(L, gco2t(o)); break; - case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; - case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; - case LUA_TSHRSTR: - luaS_remove(L, gco2ts(o)); /* remove it from hash table */ - luaM_freemem(L, o, sizelstring(gco2ts(o)->shrlen)); + case LUA_VSHRSTR: { + TString *ts = gco2ts(o); + luaS_remove(L, ts); /* remove it from hash table */ + luaM_freemem(L, ts, sizelstring(ts->shrlen)); break; - case LUA_TLNGSTR: { - luaM_freemem(L, o, sizelstring(gco2ts(o)->u.lnglen)); + } + case LUA_VLNGSTR: { + TString *ts = gco2ts(o); + luaM_freemem(L, ts, sizelstring(ts->u.lnglen)); break; } default: lua_assert(0); @@ -721,22 +814,20 @@ static void freeobj (lua_State *L, GCObject *o) { } -#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) -static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count); - - /* -** sweep at most 'count' elements from a list of GCObjects erasing dead +** sweep at most 'countin' elements from a list of GCObjects erasing dead ** objects, where a dead object is one marked with the old (non current) ** white; change all non-dead objects back to white, preparing for next ** collection cycle. Return where to continue the traversal or NULL if -** list is finished. +** list is finished. ('*countout' gets the number of elements traversed.) */ -static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { +static GCObject **sweeplist (lua_State *L, GCObject **p, int countin, + int *countout) { global_State *g = G(L); int ow = otherwhite(g); + int i; int white = luaC_white(g); /* current white */ - while (*p != NULL && count-- > 0) { + for (i = 0; *p != NULL && i < countin; i++) { GCObject *curr = *p; int marked = curr->marked; if (isdeadm(ow, marked)) { /* is 'curr' dead? */ @@ -744,10 +835,12 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { freeobj(L, curr); /* erase 'curr' */ } else { /* change mark to 'white' */ - curr->marked = cast_byte((marked & maskcolors) | white); + curr->marked = cast_byte((marked & ~maskgcbits) | white); p = &curr->next; /* go to next element */ } } + if (countout) + *countout = i; /* number of elements traversed */ return (*p == NULL) ? NULL : p; } @@ -758,7 +851,7 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { static GCObject **sweeptolive (lua_State *L, GCObject **p) { GCObject **old = p; do { - p = sweeplist(L, p, 1); + p = sweeplist(L, p, 1, NULL); } while (p == old); return p; } @@ -773,18 +866,23 @@ static GCObject **sweeptolive (lua_State *L, GCObject **p) { */ /* -** If possible, shrink string table +** If possible, shrink string table. */ static void checkSizes (lua_State *L, global_State *g) { - if (g->gckind != KGC_EMERGENCY) { - l_mem olddebt = g->GCdebt; - if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ - luaS_resize(L, g->strt.size / 2); /* shrink it a little */ - g->GCestimate += g->GCdebt - olddebt; /* update estimate */ + if (!g->gcemergency) { + if (g->strt.nuse < g->strt.size / 4) { /* string table too big? */ + l_mem olddebt = g->GCdebt; + luaS_resize(L, g->strt.size / 2); + g->GCestimate += g->GCdebt - olddebt; /* correct estimate */ + } } } +/* +** Get the next udata to be finalized from the 'tobefnz' list, and +** link it back into the 'allgc' list. +*/ static GCObject *udata2finalize (global_State *g) { GCObject *o = g->tobefnz; /* get first element */ lua_assert(tofinalize(o)); @@ -794,61 +892,54 @@ static GCObject *udata2finalize (global_State *g) { resetbit(o->marked, FINALIZEDBIT); /* object is "normal" again */ if (issweepphase(g)) makewhite(g, o); /* "sweep" object */ + else if (getage(o) == G_OLD1) + g->firstold1 = o; /* it is the first OLD1 object in the list */ return o; } static void dothecall (lua_State *L, void *ud) { UNUSED(ud); - luaD_callnoyield(L, L->top - 2, 0); + luaD_callnoyield(L, L->top.p - 2, 0); } -static void GCTM (lua_State *L, int propagateerrors) { +static void GCTM (lua_State *L) { global_State *g = G(L); const TValue *tm; TValue v; + lua_assert(!g->gcemergency); setgcovalue(L, &v, udata2finalize(g)); tm = luaT_gettmbyobj(L, &v, TM_GC); - if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */ + if (!notm(tm)) { /* is there a finalizer? */ int status; lu_byte oldah = L->allowhook; - int running = g->gcrunning; + int oldgcstp = g->gcstp; + g->gcstp |= GCSTPGC; /* avoid GC steps */ L->allowhook = 0; /* stop debug hooks during GC metamethod */ - g->gcrunning = 0; /* avoid GC steps */ - setobj2s(L, L->top, tm); /* push finalizer... */ - setobj2s(L, L->top + 1, &v); /* ... and its argument */ - L->top += 2; /* and (next line) call the finalizer */ + setobj2s(L, L->top.p++, tm); /* push finalizer... */ + setobj2s(L, L->top.p++, &v); /* ... and its argument */ L->ci->callstatus |= CIST_FIN; /* will run a finalizer */ - status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); + status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top.p - 2), 0); L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */ L->allowhook = oldah; /* restore hooks */ - g->gcrunning = running; /* restore state */ - if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ - if (status == LUA_ERRRUN) { /* is there an error object? */ - const char *msg = (ttisstring(L->top - 1)) - ? svalue(L->top - 1) - : "no message"; - luaO_pushfstring(L, "error in __gc metamethod (%s)", msg); - status = LUA_ERRGCMM; /* error in __gc metamethod */ - } - luaD_throw(L, status); /* re-throw error */ + g->gcstp = oldgcstp; /* restore state */ + if (l_unlikely(status != LUA_OK)) { /* error while running __gc? */ + luaE_warnerror(L, "__gc"); + L->top.p--; /* pops error object */ } } } /* -** call a few (up to 'g->gcfinnum') finalizers +** Call a few finalizers */ -static int runafewfinalizers (lua_State *L) { +static int runafewfinalizers (lua_State *L, int n) { global_State *g = G(L); - unsigned int i; - lua_assert(!g->tobefnz || g->gcfinnum > 0); - for (i = 0; g->tobefnz && i < g->gcfinnum; i++) - GCTM(L, 1); /* call one finalizer */ - g->gcfinnum = (!g->tobefnz) ? 0 /* nothing more to finalize? */ - : g->gcfinnum * 2; /* else call a few more next time */ + int i; + for (i = 0; i < n && g->tobefnz; i++) + GCTM(L); /* call one finalizer */ return i; } @@ -859,7 +950,7 @@ static int runafewfinalizers (lua_State *L) { static void callallpendingfinalizers (lua_State *L) { global_State *g = G(L); while (g->tobefnz) - GCTM(L, 0); + GCTM(L); } @@ -874,18 +965,23 @@ static GCObject **findlast (GCObject **p) { /* -** move all unreachable objects (or 'all' objects) that need -** finalization from list 'finobj' to list 'tobefnz' (to be finalized) +** Move all unreachable objects (or 'all' objects) that need +** finalization from list 'finobj' to list 'tobefnz' (to be finalized). +** (Note that objects after 'finobjold1' cannot be white, so they +** don't need to be traversed. In incremental mode, 'finobjold1' is NULL, +** so the whole list is traversed.) */ static void separatetobefnz (global_State *g, int all) { GCObject *curr; GCObject **p = &g->finobj; GCObject **lastnext = findlast(&g->tobefnz); - while ((curr = *p) != NULL) { /* traverse all finalizable objects */ + while ((curr = *p) != g->finobjold1) { /* traverse all finalizable objects */ lua_assert(tofinalize(curr)); if (!(iswhite(curr) || all)) /* not being collected? */ p = &curr->next; /* don't bother with it */ else { + if (curr == g->finobjsur) /* removing 'finobjsur'? */ + g->finobjsur = curr->next; /* correct it */ *p = curr->next; /* remove 'curr' from 'finobj' list */ curr->next = *lastnext; /* link at the end of 'tobefnz' list */ *lastnext = curr; @@ -895,6 +991,27 @@ static void separatetobefnz (global_State *g, int all) { } +/* +** If pointer 'p' points to 'o', move it to the next element. +*/ +static void checkpointer (GCObject **p, GCObject *o) { + if (o == *p) + *p = o->next; +} + + +/* +** Correct pointers to objects inside 'allgc' list when +** object 'o' is being removed from the list. +*/ +static void correctpointers (global_State *g, GCObject *o) { + checkpointer(&g->survival, o); + checkpointer(&g->old1, o); + checkpointer(&g->reallyold, o); + checkpointer(&g->firstold1, o); +} + + /* ** if object 'o' has a finalizer, remove it from 'allgc' list (must ** search the list to find it) and link it in 'finobj' list. @@ -902,7 +1019,8 @@ static void separatetobefnz (global_State *g, int all) { void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { global_State *g = G(L); if (tofinalize(o) || /* obj. is already marked... */ - gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ + gfasttm(g, mt, TM_GC) == NULL || /* or has no finalizer... */ + (g->gcstp & GCSTPCLS)) /* or closing state? */ return; /* nothing to be done */ else { /* move 'o' to 'finobj' list */ GCObject **p; @@ -911,6 +1029,8 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */ g->sweepgc = sweeptolive(L, g->sweepgc); /* change 'sweepgc' */ } + else + correctpointers(g, o); /* search for pointer pointing to 'o' */ for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ } *p = o->next; /* remove 'o' from 'allgc' list */ @@ -923,35 +1043,442 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { /* }====================================================== */ - /* ** {====================================================== -** GC control +** Generational Collector ** ======================================================= */ /* -** Set a reasonable "time" to wait before starting a new GC cycle; cycle -** will start when memory use hits threshold. (Division by 'estimate' -** should be OK: it cannot be zero (because Lua cannot even start with -** less than PAUSEADJ bytes). +** Set the "time" to wait before starting a new GC cycle; cycle will +** start when memory use hits the threshold of ('estimate' * pause / +** PAUSEADJ). (Division by 'estimate' should be OK: it cannot be zero, +** because Lua cannot even start with less than PAUSEADJ bytes). */ static void setpause (global_State *g) { l_mem threshold, debt; + int pause = getgcparam(g->gcpause); l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ lua_assert(estimate > 0); - threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ - ? estimate * g->gcpause /* no overflow */ + threshold = (pause < MAX_LMEM / estimate) /* overflow? */ + ? estimate * pause /* no overflow */ : MAX_LMEM; /* overflow; truncate to maximum */ debt = gettotalbytes(g) - threshold; + if (debt > 0) debt = 0; luaE_setdebt(g, debt); } +/* +** Sweep a list of objects to enter generational mode. Deletes dead +** objects and turns the non dead to old. All non-dead threads---which +** are now old---must be in a gray list. Everything else is not in a +** gray list. Open upvalues are also kept gray. +*/ +static void sweep2old (lua_State *L, GCObject **p) { + GCObject *curr; + global_State *g = G(L); + while ((curr = *p) != NULL) { + if (iswhite(curr)) { /* is 'curr' dead? */ + lua_assert(isdead(g, curr)); + *p = curr->next; /* remove 'curr' from list */ + freeobj(L, curr); /* erase 'curr' */ + } + else { /* all surviving objects become old */ + setage(curr, G_OLD); + if (curr->tt == LUA_VTHREAD) { /* threads must be watched */ + lua_State *th = gco2th(curr); + linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ + } + else if (curr->tt == LUA_VUPVAL && upisopen(gco2upv(curr))) + set2gray(curr); /* open upvalues are always gray */ + else /* everything else is black */ + nw2black(curr); + p = &curr->next; /* go to next element */ + } + } +} + + +/* +** Sweep for generational mode. Delete dead objects. (Because the +** collection is not incremental, there are no "new white" objects +** during the sweep. So, any white object must be dead.) For +** non-dead objects, advance their ages and clear the color of +** new objects. (Old objects keep their colors.) +** The ages of G_TOUCHED1 and G_TOUCHED2 objects cannot be advanced +** here, because these old-generation objects are usually not swept +** here. They will all be advanced in 'correctgraylist'. That function +** will also remove objects turned white here from any gray list. +*/ +static GCObject **sweepgen (lua_State *L, global_State *g, GCObject **p, + GCObject *limit, GCObject **pfirstold1) { + static const lu_byte nextage[] = { + G_SURVIVAL, /* from G_NEW */ + G_OLD1, /* from G_SURVIVAL */ + G_OLD1, /* from G_OLD0 */ + G_OLD, /* from G_OLD1 */ + G_OLD, /* from G_OLD (do not change) */ + G_TOUCHED1, /* from G_TOUCHED1 (do not change) */ + G_TOUCHED2 /* from G_TOUCHED2 (do not change) */ + }; + int white = luaC_white(g); + GCObject *curr; + while ((curr = *p) != limit) { + if (iswhite(curr)) { /* is 'curr' dead? */ + lua_assert(!isold(curr) && isdead(g, curr)); + *p = curr->next; /* remove 'curr' from list */ + freeobj(L, curr); /* erase 'curr' */ + } + else { /* correct mark and age */ + if (getage(curr) == G_NEW) { /* new objects go back to white */ + int marked = curr->marked & ~maskgcbits; /* erase GC bits */ + curr->marked = cast_byte(marked | G_SURVIVAL | white); + } + else { /* all other objects will be old, and so keep their color */ + setage(curr, nextage[getage(curr)]); + if (getage(curr) == G_OLD1 && *pfirstold1 == NULL) + *pfirstold1 = curr; /* first OLD1 object in the list */ + } + p = &curr->next; /* go to next element */ + } + } + return p; +} + + +/* +** Traverse a list making all its elements white and clearing their +** age. In incremental mode, all objects are 'new' all the time, +** except for fixed strings (which are always old). +*/ +static void whitelist (global_State *g, GCObject *p) { + int white = luaC_white(g); + for (; p != NULL; p = p->next) + p->marked = cast_byte((p->marked & ~maskgcbits) | white); +} + + +/* +** Correct a list of gray objects. Return pointer to where rest of the +** list should be linked. +** Because this correction is done after sweeping, young objects might +** be turned white and still be in the list. They are only removed. +** 'TOUCHED1' objects are advanced to 'TOUCHED2' and remain on the list; +** Non-white threads also remain on the list; 'TOUCHED2' objects become +** regular old; they and anything else are removed from the list. +*/ +static GCObject **correctgraylist (GCObject **p) { + GCObject *curr; + while ((curr = *p) != NULL) { + GCObject **next = getgclist(curr); + if (iswhite(curr)) + goto remove; /* remove all white objects */ + else if (getage(curr) == G_TOUCHED1) { /* touched in this cycle? */ + lua_assert(isgray(curr)); + nw2black(curr); /* make it black, for next barrier */ + changeage(curr, G_TOUCHED1, G_TOUCHED2); + goto remain; /* keep it in the list and go to next element */ + } + else if (curr->tt == LUA_VTHREAD) { + lua_assert(isgray(curr)); + goto remain; /* keep non-white threads on the list */ + } + else { /* everything else is removed */ + lua_assert(isold(curr)); /* young objects should be white here */ + if (getage(curr) == G_TOUCHED2) /* advance from TOUCHED2... */ + changeage(curr, G_TOUCHED2, G_OLD); /* ... to OLD */ + nw2black(curr); /* make object black (to be removed) */ + goto remove; + } + remove: *p = *next; continue; + remain: p = next; continue; + } + return p; +} + + +/* +** Correct all gray lists, coalescing them into 'grayagain'. +*/ +static void correctgraylists (global_State *g) { + GCObject **list = correctgraylist(&g->grayagain); + *list = g->weak; g->weak = NULL; + list = correctgraylist(list); + *list = g->allweak; g->allweak = NULL; + list = correctgraylist(list); + *list = g->ephemeron; g->ephemeron = NULL; + correctgraylist(list); +} + + +/* +** Mark black 'OLD1' objects when starting a new young collection. +** Gray objects are already in some gray list, and so will be visited +** in the atomic step. +*/ +static void markold (global_State *g, GCObject *from, GCObject *to) { + GCObject *p; + for (p = from; p != to; p = p->next) { + if (getage(p) == G_OLD1) { + lua_assert(!iswhite(p)); + changeage(p, G_OLD1, G_OLD); /* now they are old */ + if (isblack(p)) + reallymarkobject(g, p); + } + } +} + + +/* +** Finish a young-generation collection. +*/ +static void finishgencycle (lua_State *L, global_State *g) { + correctgraylists(g); + checkSizes(L, g); + g->gcstate = GCSpropagate; /* skip restart */ + if (!g->gcemergency) + callallpendingfinalizers(L); +} + + +/* +** Does a young collection. First, mark 'OLD1' objects. Then does the +** atomic step. Then, sweep all lists and advance pointers. Finally, +** finish the collection. +*/ +static void youngcollection (lua_State *L, global_State *g) { + GCObject **psurvival; /* to point to first non-dead survival object */ + GCObject *dummy; /* dummy out parameter to 'sweepgen' */ + lua_assert(g->gcstate == GCSpropagate); + if (g->firstold1) { /* are there regular OLD1 objects? */ + markold(g, g->firstold1, g->reallyold); /* mark them */ + g->firstold1 = NULL; /* no more OLD1 objects (for now) */ + } + markold(g, g->finobj, g->finobjrold); + markold(g, g->tobefnz, NULL); + atomic(L); + + /* sweep nursery and get a pointer to its last live element */ + g->gcstate = GCSswpallgc; + psurvival = sweepgen(L, g, &g->allgc, g->survival, &g->firstold1); + /* sweep 'survival' */ + sweepgen(L, g, psurvival, g->old1, &g->firstold1); + g->reallyold = g->old1; + g->old1 = *psurvival; /* 'survival' survivals are old now */ + g->survival = g->allgc; /* all news are survivals */ + + /* repeat for 'finobj' lists */ + dummy = NULL; /* no 'firstold1' optimization for 'finobj' lists */ + psurvival = sweepgen(L, g, &g->finobj, g->finobjsur, &dummy); + /* sweep 'survival' */ + sweepgen(L, g, psurvival, g->finobjold1, &dummy); + g->finobjrold = g->finobjold1; + g->finobjold1 = *psurvival; /* 'survival' survivals are old now */ + g->finobjsur = g->finobj; /* all news are survivals */ + + sweepgen(L, g, &g->tobefnz, NULL, &dummy); + finishgencycle(L, g); +} + + +/* +** Clears all gray lists, sweeps objects, and prepare sublists to enter +** generational mode. The sweeps remove dead objects and turn all +** surviving objects to old. Threads go back to 'grayagain'; everything +** else is turned black (not in any gray list). +*/ +static void atomic2gen (lua_State *L, global_State *g) { + cleargraylists(g); + /* sweep all elements making them old */ + g->gcstate = GCSswpallgc; + sweep2old(L, &g->allgc); + /* everything alive now is old */ + g->reallyold = g->old1 = g->survival = g->allgc; + g->firstold1 = NULL; /* there are no OLD1 objects anywhere */ + + /* repeat for 'finobj' lists */ + sweep2old(L, &g->finobj); + g->finobjrold = g->finobjold1 = g->finobjsur = g->finobj; + + sweep2old(L, &g->tobefnz); + + g->gckind = KGC_GEN; + g->lastatomic = 0; + g->GCestimate = gettotalbytes(g); /* base for memory control */ + finishgencycle(L, g); +} + + +/* +** Set debt for the next minor collection, which will happen when +** memory grows 'genminormul'%. +*/ +static void setminordebt (global_State *g) { + luaE_setdebt(g, -(cast(l_mem, (gettotalbytes(g) / 100)) * g->genminormul)); +} + + +/* +** Enter generational mode. Must go until the end of an atomic cycle +** to ensure that all objects are correctly marked and weak tables +** are cleared. Then, turn all objects into old and finishes the +** collection. +*/ +static lu_mem entergen (lua_State *L, global_State *g) { + lu_mem numobjs; + luaC_runtilstate(L, bitmask(GCSpause)); /* prepare to start a new cycle */ + luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */ + numobjs = atomic(L); /* propagates all and then do the atomic stuff */ + atomic2gen(L, g); + setminordebt(g); /* set debt assuming next cycle will be minor */ + return numobjs; +} + + +/* +** Enter incremental mode. Turn all objects white, make all +** intermediate lists point to NULL (to avoid invalid pointers), +** and go to the pause state. +*/ +static void enterinc (global_State *g) { + whitelist(g, g->allgc); + g->reallyold = g->old1 = g->survival = NULL; + whitelist(g, g->finobj); + whitelist(g, g->tobefnz); + g->finobjrold = g->finobjold1 = g->finobjsur = NULL; + g->gcstate = GCSpause; + g->gckind = KGC_INC; + g->lastatomic = 0; +} + + +/* +** Change collector mode to 'newmode'. +*/ +void luaC_changemode (lua_State *L, int newmode) { + global_State *g = G(L); + if (newmode != g->gckind) { + if (newmode == KGC_GEN) /* entering generational mode? */ + entergen(L, g); + else + enterinc(g); /* entering incremental mode */ + } + g->lastatomic = 0; +} + + +/* +** Does a full collection in generational mode. +*/ +static lu_mem fullgen (lua_State *L, global_State *g) { + enterinc(g); + return entergen(L, g); +} + + +/* +** Does a major collection after last collection was a "bad collection". +** +** When the program is building a big structure, it allocates lots of +** memory but generates very little garbage. In those scenarios, +** the generational mode just wastes time doing small collections, and +** major collections are frequently what we call a "bad collection", a +** collection that frees too few objects. To avoid the cost of switching +** between generational mode and the incremental mode needed for full +** (major) collections, the collector tries to stay in incremental mode +** after a bad collection, and to switch back to generational mode only +** after a "good" collection (one that traverses less than 9/8 objects +** of the previous one). +** The collector must choose whether to stay in incremental mode or to +** switch back to generational mode before sweeping. At this point, it +** does not know the real memory in use, so it cannot use memory to +** decide whether to return to generational mode. Instead, it uses the +** number of objects traversed (returned by 'atomic') as a proxy. The +** field 'g->lastatomic' keeps this count from the last collection. +** ('g->lastatomic != 0' also means that the last collection was bad.) +*/ +static void stepgenfull (lua_State *L, global_State *g) { + lu_mem newatomic; /* count of traversed objects */ + lu_mem lastatomic = g->lastatomic; /* count from last collection */ + if (g->gckind == KGC_GEN) /* still in generational mode? */ + enterinc(g); /* enter incremental mode */ + luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */ + newatomic = atomic(L); /* mark everybody */ + if (newatomic < lastatomic + (lastatomic >> 3)) { /* good collection? */ + atomic2gen(L, g); /* return to generational mode */ + setminordebt(g); + } + else { /* another bad collection; stay in incremental mode */ + g->GCestimate = gettotalbytes(g); /* first estimate */ + entersweep(L); + luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ + setpause(g); + g->lastatomic = newatomic; + } +} + + +/* +** Does a generational "step". +** Usually, this means doing a minor collection and setting the debt to +** make another collection when memory grows 'genminormul'% larger. +** +** However, there are exceptions. If memory grows 'genmajormul'% +** larger than it was at the end of the last major collection (kept +** in 'g->GCestimate'), the function does a major collection. At the +** end, it checks whether the major collection was able to free a +** decent amount of memory (at least half the growth in memory since +** previous major collection). If so, the collector keeps its state, +** and the next collection will probably be minor again. Otherwise, +** we have what we call a "bad collection". In that case, set the field +** 'g->lastatomic' to signal that fact, so that the next collection will +** go to 'stepgenfull'. +** +** 'GCdebt <= 0' means an explicit call to GC step with "size" zero; +** in that case, do a minor collection. +*/ +static void genstep (lua_State *L, global_State *g) { + if (g->lastatomic != 0) /* last collection was a bad one? */ + stepgenfull(L, g); /* do a full step */ + else { + lu_mem majorbase = g->GCestimate; /* memory after last major collection */ + lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul); + if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) { + lu_mem numobjs = fullgen(L, g); /* do a major collection */ + if (gettotalbytes(g) < majorbase + (majorinc / 2)) { + /* collected at least half of memory growth since last major + collection; keep doing minor collections. */ + lua_assert(g->lastatomic == 0); + } + else { /* bad collection */ + g->lastatomic = numobjs; /* signal that last collection was bad */ + setpause(g); /* do a long wait for next (major) collection */ + } + } + else { /* regular case; do a minor collection */ + youngcollection(L, g); + setminordebt(g); + g->GCestimate = majorbase; /* preserve base value */ + } + } + lua_assert(isdecGCmodegen(g)); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** GC control +** ======================================================= +*/ + + /* ** Enter first sweep phase. -** The call to 'sweeplist' tries to make pointer point to an object +** The call to 'sweeptolive' makes the pointer point to an object ** inside the list (instead of to the header), so that the real sweep do ** not need to skip objects created between "now" and the start of the ** real sweep. @@ -960,140 +1487,161 @@ static void entersweep (lua_State *L) { global_State *g = G(L); g->gcstate = GCSswpallgc; lua_assert(g->sweepgc == NULL); - g->sweepgc = sweeplist(L, &g->allgc, 1); + g->sweepgc = sweeptolive(L, &g->allgc); } +/* +** Delete all objects in list 'p' until (but not including) object +** 'limit'. +*/ +static void deletelist (lua_State *L, GCObject *p, GCObject *limit) { + while (p != limit) { + GCObject *next = p->next; + freeobj(L, p); + p = next; + } +} + + +/* +** Call all finalizers of the objects in the given Lua state, and +** then free all objects, except for the main thread. +*/ void luaC_freeallobjects (lua_State *L) { global_State *g = G(L); + g->gcstp = GCSTPCLS; /* no extra finalizers after here */ + luaC_changemode(L, KGC_INC); separatetobefnz(g, 1); /* separate all objects with finalizers */ lua_assert(g->finobj == NULL); callallpendingfinalizers(L); - lua_assert(g->tobefnz == NULL); - g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ - g->gckind = KGC_NORMAL; - sweepwholelist(L, &g->finobj); - sweepwholelist(L, &g->allgc); - sweepwholelist(L, &g->fixedgc); /* collect fixed objects */ + deletelist(L, g->allgc, obj2gco(g->mainthread)); + lua_assert(g->finobj == NULL); /* no new finalizers */ + deletelist(L, g->fixedgc, NULL); /* collect fixed objects */ lua_assert(g->strt.nuse == 0); } -static l_mem atomic (lua_State *L) { +static lu_mem atomic (lua_State *L) { global_State *g = G(L); - l_mem work; + lu_mem work = 0; GCObject *origweak, *origall; GCObject *grayagain = g->grayagain; /* save original list */ + g->grayagain = NULL; lua_assert(g->ephemeron == NULL && g->weak == NULL); lua_assert(!iswhite(g->mainthread)); - g->gcstate = GCSinsideatomic; - g->GCmemtrav = 0; /* start counting work */ + g->gcstate = GCSatomic; markobject(g, L); /* mark running thread */ /* registry and global metatables may be changed by API */ markvalue(g, &g->l_registry); markmt(g); /* mark global metatables */ + work += propagateall(g); /* empties 'gray' list */ /* remark occasional upvalues of (maybe) dead threads */ - remarkupvals(g); - propagateall(g); /* propagate changes */ - work = g->GCmemtrav; /* stop counting (do not recount 'grayagain') */ + work += remarkupvals(g); + work += propagateall(g); /* propagate changes */ g->gray = grayagain; - propagateall(g); /* traverse 'grayagain' list */ - g->GCmemtrav = 0; /* restart counting */ + work += propagateall(g); /* traverse 'grayagain' list */ convergeephemerons(g); /* at this point, all strongly accessible objects are marked. */ /* Clear values from weak tables, before checking finalizers */ - clearvalues(g, g->weak, NULL); - clearvalues(g, g->allweak, NULL); + clearbyvalues(g, g->weak, NULL); + clearbyvalues(g, g->allweak, NULL); origweak = g->weak; origall = g->allweak; - work += g->GCmemtrav; /* stop counting (objects being finalized) */ separatetobefnz(g, 0); /* separate objects to be finalized */ - g->gcfinnum = 1; /* there may be objects to be finalized */ - markbeingfnz(g); /* mark objects that will be finalized */ - propagateall(g); /* remark, to propagate 'resurrection' */ - g->GCmemtrav = 0; /* restart counting */ + work += markbeingfnz(g); /* mark objects that will be finalized */ + work += propagateall(g); /* remark, to propagate 'resurrection' */ convergeephemerons(g); /* at this point, all resurrected objects are marked. */ /* remove dead objects from weak tables */ - clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ - clearkeys(g, g->allweak, NULL); /* clear keys from all 'allweak' tables */ + clearbykeys(g, g->ephemeron); /* clear keys from all ephemeron tables */ + clearbykeys(g, g->allweak); /* clear keys from all 'allweak' tables */ /* clear values from resurrected weak tables */ - clearvalues(g, g->weak, origweak); - clearvalues(g, g->allweak, origall); + clearbyvalues(g, g->weak, origweak); + clearbyvalues(g, g->allweak, origall); luaS_clearcache(g); g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ - work += g->GCmemtrav; /* complete counting */ - return work; /* estimate of memory marked by 'atomic' */ + lua_assert(g->gray == NULL); + return work; /* estimate of slots marked by 'atomic' */ } -static lu_mem sweepstep (lua_State *L, global_State *g, - int nextstate, GCObject **nextlist) { +static int sweepstep (lua_State *L, global_State *g, + int nextstate, GCObject **nextlist) { if (g->sweepgc) { l_mem olddebt = g->GCdebt; - g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + int count; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX, &count); g->GCestimate += g->GCdebt - olddebt; /* update estimate */ - if (g->sweepgc) /* is there still something to sweep? */ - return (GCSWEEPMAX * GCSWEEPCOST); + return count; + } + else { /* enter next state */ + g->gcstate = nextstate; + g->sweepgc = nextlist; + return 0; /* no work done */ } - /* else enter next state */ - g->gcstate = nextstate; - g->sweepgc = nextlist; - return 0; } static lu_mem singlestep (lua_State *L) { global_State *g = G(L); + lu_mem work; + lua_assert(!g->gcstopem); /* collector is not reentrant */ + g->gcstopem = 1; /* no emergency collections while collecting */ switch (g->gcstate) { case GCSpause: { - g->GCmemtrav = g->strt.size * sizeof(GCObject*); restartcollection(g); g->gcstate = GCSpropagate; - return g->GCmemtrav; + work = 1; + break; } case GCSpropagate: { - g->GCmemtrav = 0; - lua_assert(g->gray); - propagatemark(g); - if (g->gray == NULL) /* no more gray objects? */ - g->gcstate = GCSatomic; /* finish propagate phase */ - return g->GCmemtrav; /* memory traversed in this step */ + if (g->gray == NULL) { /* no more gray objects? */ + g->gcstate = GCSenteratomic; /* finish propagate phase */ + work = 0; + } + else + work = propagatemark(g); /* traverse one gray object */ + break; } - case GCSatomic: { - lu_mem work; - propagateall(g); /* make sure gray list is empty */ + case GCSenteratomic: { work = atomic(L); /* work is what was traversed by 'atomic' */ entersweep(L); - g->GCestimate = gettotalbytes(g); /* first estimate */; - return work; + g->GCestimate = gettotalbytes(g); /* first estimate */ + break; } case GCSswpallgc: { /* sweep "regular" objects */ - return sweepstep(L, g, GCSswpfinobj, &g->finobj); + work = sweepstep(L, g, GCSswpfinobj, &g->finobj); + break; } case GCSswpfinobj: { /* sweep objects with finalizers */ - return sweepstep(L, g, GCSswptobefnz, &g->tobefnz); + work = sweepstep(L, g, GCSswptobefnz, &g->tobefnz); + break; } case GCSswptobefnz: { /* sweep objects to be finalized */ - return sweepstep(L, g, GCSswpend, NULL); + work = sweepstep(L, g, GCSswpend, NULL); + break; } case GCSswpend: { /* finish sweeps */ - makewhite(g, g->mainthread); /* sweep main thread */ checkSizes(L, g); g->gcstate = GCScallfin; - return 0; + work = 0; + break; } case GCScallfin: { /* call remaining finalizers */ - if (g->tobefnz && g->gckind != KGC_EMERGENCY) { - int n = runafewfinalizers(L); - return (n * GCFINALIZECOST); + if (g->tobefnz && !g->gcemergency) { + g->gcstopem = 0; /* ok collections during finalizers */ + work = runafewfinalizers(L, GCFINMAX) * GCFINALIZECOST; } else { /* emergency mode or no more finalizers */ g->gcstate = GCSpause; /* finish collection */ - return 0; + work = 0; } + break; } default: lua_assert(0); return 0; } + g->gcstopem = 0; + return work; } @@ -1108,72 +1656,88 @@ void luaC_runtilstate (lua_State *L, int statesmask) { } + /* -** get GC debt and convert it from Kb to 'work units' (avoid zero debt -** and overflows) +** Performs a basic incremental step. The debt and step size are +** converted from bytes to "units of work"; then the function loops +** running single steps until adding that many units of work or +** finishing a cycle (pause state). Finally, it sets the debt that +** controls when next step will be performed. */ -static l_mem getdebt (global_State *g) { - l_mem debt = g->GCdebt; - int stepmul = g->gcstepmul; - if (debt <= 0) return 0; /* minimal debt */ +static void incstep (lua_State *L, global_State *g) { + int stepmul = (getgcparam(g->gcstepmul) | 1); /* avoid division by 0 */ + l_mem debt = (g->GCdebt / WORK2MEM) * stepmul; + l_mem stepsize = (g->gcstepsize <= log2maxs(l_mem)) + ? ((cast(l_mem, 1) << g->gcstepsize) / WORK2MEM) * stepmul + : MAX_LMEM; /* overflow; keep maximum value */ + do { /* repeat until pause or enough "credit" (negative debt) */ + lu_mem work = singlestep(L); /* perform one single step */ + debt -= work; + } while (debt > -stepsize && g->gcstate != GCSpause); + if (g->gcstate == GCSpause) + setpause(g); /* pause until next cycle */ else { - debt = (debt / STEPMULADJ) + 1; - debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; - return debt; + debt = (debt / stepmul) * WORK2MEM; /* convert 'work units' to bytes */ + luaE_setdebt(g, debt); } } /* -** performs a basic GC step when collector is running +** Performs a basic GC step if collector is running. (If collector is +** not running, set a reasonable debt to avoid it being called at +** every single check.) */ void luaC_step (lua_State *L) { global_State *g = G(L); - l_mem debt = getdebt(g); /* GC deficit (be paid now) */ - if (!g->gcrunning) { /* not running? */ - luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */ - return; - } - do { /* repeat until pause or enough "credit" (negative debt) */ - lu_mem work = singlestep(L); /* perform one single step */ - debt -= work; - } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); - if (g->gcstate == GCSpause) - setpause(g); /* pause until next cycle */ + if (!gcrunning(g)) /* not running? */ + luaE_setdebt(g, -2000); else { - debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */ - luaE_setdebt(g, debt); - runafewfinalizers(L); + if(isdecGCmodegen(g)) + genstep(L, g); + else + incstep(L, g); } } /* -** Performs a full GC cycle; if 'isemergency', set a flag to avoid -** some operations which could change the interpreter state in some -** unexpected ways (running finalizers and shrinking some structures). +** Perform a full collection in incremental mode. ** Before running the collection, check 'keepinvariant'; if it is true, ** there may be some objects marked as black, so the collector has ** to sweep all objects to turn them back to white (as white has not ** changed, nothing will be collected). */ -void luaC_fullgc (lua_State *L, int isemergency) { - global_State *g = G(L); - lua_assert(g->gckind == KGC_NORMAL); - if (isemergency) g->gckind = KGC_EMERGENCY; /* set flag */ - if (keepinvariant(g)) { /* black objects? */ +static void fullinc (lua_State *L, global_State *g) { + if (keepinvariant(g)) /* black objects? */ entersweep(L); /* sweep everything to turn them back to white */ - } /* finish any pending sweep phase to start a new cycle */ luaC_runtilstate(L, bitmask(GCSpause)); - luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */ + luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */ + g->gcstate = GCSenteratomic; /* go straight to atomic phase */ luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ /* estimate must be correct after a full GC cycle */ lua_assert(g->GCestimate == gettotalbytes(g)); luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ - g->gckind = KGC_NORMAL; setpause(g); } + +/* +** Performs a full GC cycle; if 'isemergency', set a flag to avoid +** some operations which could change the interpreter state in some +** unexpected ways (running finalizers and shrinking some structures). +*/ +void luaC_fullgc (lua_State *L, int isemergency) { + global_State *g = G(L); + lua_assert(!g->gcemergency); + g->gcemergency = isemergency; /* set flag */ + if (g->gckind == KGC_INC) + fullinc(L, g); + else + fullgen(L, g); + g->gcemergency = 0; +} + /* }====================================================== */ diff --git a/liblua/lgc.h b/liblua/lgc.h index 425cd7ce..538f6edc 100644 --- a/liblua/lgc.h +++ b/liblua/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.91.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lgc.h $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -12,38 +12,31 @@ #include "lstate.h" /* -** Collectable objects may have one of three colors: white, which -** means the object is not marked; gray, which means the -** object is marked, but its references may be not marked; and -** black, which means that the object and all its references are marked. -** The main invariant of the garbage collector, while marking objects, -** is that a black object can never point to a white one. Moreover, -** any gray object must be in a "gray list" (gray, grayagain, weak, -** allweak, ephemeron) so that it can be visited again before finishing -** the collection cycle. These lists have no meaning when the invariant -** is not being enforced (e.g., sweep phase). +** Collectable objects may have one of three colors: white, which means +** the object is not marked; gray, which means the object is marked, but +** its references may be not marked; and black, which means that the +** object and all its references are marked. The main invariant of the +** garbage collector, while marking objects, is that a black object can +** never point to a white one. Moreover, any gray object must be in a +** "gray list" (gray, grayagain, weak, allweak, ephemeron) so that it +** can be visited again before finishing the collection cycle. (Open +** upvalues are an exception to this rule.) These lists have no meaning +** when the invariant is not being enforced (e.g., sweep phase). */ - -/* how much to allocate before next GC step */ -#if !defined(GCSTEPSIZE) -/* ~100 small strings */ -#define GCSTEPSIZE (cast_int(100 * sizeof(TString))) -#endif - - /* ** Possible states of the Garbage Collector */ #define GCSpropagate 0 -#define GCSatomic 1 -#define GCSswpallgc 2 -#define GCSswpfinobj 3 -#define GCSswptobefnz 4 -#define GCSswpend 5 -#define GCScallfin 6 -#define GCSpause 7 +#define GCSenteratomic 1 +#define GCSatomic 2 +#define GCSswpallgc 3 +#define GCSswpfinobj 4 +#define GCSswptobefnz 5 +#define GCSswpend 6 +#define GCScallfin 7 +#define GCSpause 8 #define issweepphase(g) \ @@ -64,7 +57,7 @@ /* ** some useful bit tricks */ -#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define resetbits(x,m) ((x) &= cast_byte(~(m))) #define setbits(x,m) ((x) |= (m)) #define testbits(x,m) ((x) & (m)) #define bitmask(b) (1<<(b)) @@ -74,12 +67,19 @@ #define testbit(x,b) testbits(x, bitmask(b)) -/* Layout for bit use in 'marked' field: */ -#define WHITE0BIT 0 /* object is white (type 0) */ -#define WHITE1BIT 1 /* object is white (type 1) */ -#define BLACKBIT 2 /* object is black */ -#define FINALIZEDBIT 3 /* object has been marked for finalization */ -/* bit 7 is currently used by tests (luaL_checkmemory) */ +/* +** Layout for bit use in 'marked' field. First three bits are +** used for object "age" in generational mode. Last bit is used +** by tests. +*/ +#define WHITE0BIT 3 /* object is white (type 0) */ +#define WHITE1BIT 4 /* object is white (type 1) */ +#define BLACKBIT 5 /* object is black */ +#define FINALIZEDBIT 6 /* object has been marked for finalization */ + +#define TESTBIT 7 + + #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) @@ -92,13 +92,70 @@ #define tofinalize(x) testbit((x)->marked, FINALIZEDBIT) #define otherwhite(g) ((g)->currentwhite ^ WHITEBITS) -#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) +#define isdeadm(ow,m) ((m) & (ow)) #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) #define changewhite(x) ((x)->marked ^= WHITEBITS) -#define gray2black(x) l_setbit((x)->marked, BLACKBIT) +#define nw2black(x) \ + check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT)) + +#define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS) + + +/* object age in generational mode */ +#define G_NEW 0 /* created in current cycle */ +#define G_SURVIVAL 1 /* created in previous cycle */ +#define G_OLD0 2 /* marked old by frw. barrier in this cycle */ +#define G_OLD1 3 /* first full cycle as old */ +#define G_OLD 4 /* really old object (not to be visited) */ +#define G_TOUCHED1 5 /* old object touched this cycle */ +#define G_TOUCHED2 6 /* old object touched in previous cycle */ + +#define AGEBITS 7 /* all age bits (111) */ + +#define getage(o) ((o)->marked & AGEBITS) +#define setage(o,a) ((o)->marked = cast_byte(((o)->marked & (~AGEBITS)) | a)) +#define isold(o) (getage(o) > G_SURVIVAL) + +#define changeage(o,f,t) \ + check_exp(getage(o) == (f), (o)->marked ^= ((f)^(t))) + + +/* Default Values for GC parameters */ +#define LUAI_GENMAJORMUL 100 +#define LUAI_GENMINORMUL 20 + +/* wait memory to double before starting new cycle */ +#define LUAI_GCPAUSE 200 + +/* +** some gc parameters are stored divided by 4 to allow a maximum value +** up to 1023 in a 'lu_byte'. +*/ +#define getgcparam(p) ((p) * 4) +#define setgcparam(p,v) ((p) = (v) / 4) + +#define LUAI_GCMUL 100 + +/* how much to allocate before next GC step (log2) */ +#define LUAI_GCSTEPSIZE 13 /* 8 KB */ + -#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) +/* +** Check whether the declared GC mode is generational. While in +** generational mode, the collector can go temporarily to incremental +** mode to improve performance. This is signaled by 'g->lastatomic != 0'. +*/ +#define isdecGCmodegen(g) (g->gckind == KGC_GEN || g->lastatomic != 0) + + +/* +** Control when GC is running: +*/ +#define GCSTPUSR 1 /* bit true when GC stopped by user */ +#define GCSTPGC 2 /* bit true when GC stopped by itself */ +#define GCSTPCLS 4 /* bit true when closing Lua state */ +#define gcrunning(g) ((g)->gcstp == 0) /* @@ -115,21 +172,18 @@ #define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) -#define luaC_barrier(L,p,v) ( \ - (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ - luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0)) - -#define luaC_barrierback(L,p,v) ( \ - (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ - luaC_barrierback_(L,p) : cast_void(0)) - #define luaC_objbarrier(L,p,o) ( \ (isblack(p) && iswhite(o)) ? \ luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0)) -#define luaC_upvalbarrier(L,uv) ( \ - (iscollectable((uv)->v) && !upisopen(uv)) ? \ - luaC_upvalbarrier_(L,uv) : cast_void(0)) +#define luaC_barrier(L,p,v) ( \ + iscollectable(v) ? luaC_objbarrier(L,p,gcvalue(v)) : cast_void(0)) + +#define luaC_objbarrierback(L,p,o) ( \ + (isblack(p) && iswhite(o)) ? luaC_barrierback_(L,p) : cast_void(0)) + +#define luaC_barrierback(L,p,v) ( \ + iscollectable(v) ? luaC_objbarrierback(L, p, gcvalue(v)) : cast_void(0)) LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); LUAI_FUNC void luaC_freeallobjects (lua_State *L); @@ -137,11 +191,12 @@ LUAI_FUNC void luaC_step (lua_State *L); LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); +LUAI_FUNC GCObject *luaC_newobjdt (lua_State *L, int tt, size_t sz, + size_t offset); LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); -LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o); -LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o); LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); -LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_changemode (lua_State *L, int newmode); #endif diff --git a/liblua/liblua.rc b/liblua/liblua.rc index 86cd97b2..cdd410f5 100644 --- a/liblua/liblua.rc +++ b/liblua/liblua.rc @@ -2,8 +2,8 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,3,5,0 -PRODUCTVERSION 5,3,5,0 +FILEVERSION 5,4,7,0 +PRODUCTVERSION 5,4,7,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifndef _DEBUG FILEFLAGS 0x00000000L @@ -20,12 +20,12 @@ FILESUBTYPE VFT2_UNKNOWN { VALUE "CompanyName", "Lua.org, PUC-Rio" VALUE "FileDescription", "Lua Language Library with Wide Character Patch" - VALUE "FileVersion", "5.3.5" - VALUE "InternalName", "lua53" - VALUE "LegalCopyright", "Copyright (C) 1994-2018 Lua.org, PUC-Rio." - VALUE "OriginalFilename", "lua53.dll" + VALUE "FileVersion", "5.4.7" + VALUE "InternalName", "lua54" + VALUE "LegalCopyright", "Copyright (C) 1994-2024 Lua.org, PUC-Rio." + VALUE "OriginalFilename", "lua54.dll" VALUE "ProductName", "Lua Language" - VALUE "ProductVersion", "5.3.5" + VALUE "ProductVersion", "5.4.7" } } BLOCK "VarFileInfo" diff --git a/liblua/liblua.vcxproj b/liblua/liblua.vcxproj index 894125ac..be5408ae 100644 --- a/liblua/liblua.vcxproj +++ b/liblua/liblua.vcxproj @@ -1,14 +1,6 @@  - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + {3DD6BBBB-4BCF-4991-A568-0D04B37D5E51} @@ -44,130 +36,99 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 - Unicode - - - DynamicLibrary - true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 - true - Unicode - - - DynamicLibrary - false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode - + - - - - + - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + lua54 true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + lua54 true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + lua54 false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + lua54 false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + lua54 false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - lua53 + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + lua54 @@ -176,9 +137,10 @@ Disabled LUA_BUILD_AS_DLL;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -195,28 +157,10 @@ Disabled LUA_BUILD_AS_DLL;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - true - true - - - Windows - true - - - /c 65001 - - - - - Use - Level3 - Disabled - LUA_BUILD_AS_DLL;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -233,9 +177,10 @@ Disabled LUA_BUILD_AS_DLL;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) false true + pch.h Windows @@ -254,10 +199,11 @@ true LUA_BUILD_AS_DLL;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -265,6 +211,7 @@ true No UseLinkTimeCodeGeneration + true /c 65001 @@ -279,35 +226,11 @@ true LUA_BUILD_AS_DLL;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h - true - true - Guard - - - Windows - true - true - No - UseLinkTimeCodeGeneration - - - /c 65001 - - - - - Level3 - Use - MaxSpeed - true - true - LUA_BUILD_AS_DLL;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -315,6 +238,7 @@ true No UseLinkTimeCodeGeneration + true /c 65001 @@ -329,10 +253,11 @@ true LUA_BUILD_AS_DLL;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -354,11 +279,13 @@ + + @@ -373,13 +300,12 @@ - + - @@ -410,14 +336,12 @@ - + Create Create - Create Create Create Create - Create Create diff --git a/liblua/liblua.vcxproj.filters b/liblua/liblua.vcxproj.filters index 7728119a..1d37da9e 100644 --- a/liblua/liblua.vcxproj.filters +++ b/liblua/liblua.vcxproj.filters @@ -15,7 +15,7 @@ - + Header Files @@ -42,6 +42,9 @@ Header Files + + Header Files + Header Files @@ -57,6 +60,9 @@ Header Files + + Header Files + Header Files @@ -101,7 +107,7 @@ - + Source Files @@ -113,9 +119,6 @@ Source Files - - Source Files - Source Files diff --git a/liblua/linit.c b/liblua/linit.c index 480da52c..69808f84 100644 --- a/liblua/linit.c +++ b/liblua/linit.c @@ -1,5 +1,5 @@ /* -** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: linit.c $ ** Initialization of libraries for lua.c and other clients ** See Copyright Notice in lua.h */ @@ -40,7 +40,7 @@ ** program */ static const luaL_Reg loadedlibs[] = { - {"_G", luaopen_base}, + {LUA_GNAME, luaopen_base}, {LUA_LOADLIBNAME, luaopen_package}, {LUA_COLIBNAME, luaopen_coroutine}, {LUA_TABLIBNAME, luaopen_table}, @@ -50,9 +50,6 @@ static const luaL_Reg loadedlibs[] = { {LUA_MATHLIBNAME, luaopen_math}, {LUA_UTF8LIBNAME, luaopen_utf8}, {LUA_DBLIBNAME, luaopen_debug}, -#if defined(LUA_COMPAT_BITLIB) - {LUA_BITLIBNAME, luaopen_bit32}, -#endif {NULL, NULL} }; diff --git a/liblua/liolib.c b/liblua/liolib.c index d8c70fb3..23920847 100644 --- a/liblua/liolib.c +++ b/liblua/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.151.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: liolib.c $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -39,7 +39,7 @@ /* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */ static int l_checkmode (const char *mode) { return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && - (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ + (*mode != '+' || ((void)(++mode), 1)) && /* skip if char is '+' */ (strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */ } @@ -64,11 +64,17 @@ static int l_checkmode (const char *mode) { #define l_popen(L,c,m) (_popen(c,m)) #define l_pclose(L,file) (_pclose(file)) +#if !defined(l_checkmodep) +/* Windows accepts "[rw][bt]?" as valid modes */ +#define l_checkmodep(m) ((m[0] == 'r' || m[0] == 'w') && \ + (m[1] == '\0' || ((m[1] == 'b' || m[1] == 't') && m[2] == '\0'))) +#endif + #else /* }{ */ /* ISO C definitions */ #define l_popen(L,c,m) \ - ((void)((void)c, m), \ + ((void)c, (void)m, \ luaL_error(L, "'popen' not supported"), \ (FILE*)0) #define l_pclose(L,file) ((void)L, (void)file, -1) @@ -77,6 +83,12 @@ static int l_checkmode (const char *mode) { #endif /* } */ + +#if !defined(l_checkmodep) +/* By default, Lua accepts only "r" or "w" as valid modes */ +#define l_checkmodep(m) ((m[0] == 'r' || m[0] == 'w') && m[1] == '\0') +#endif + /* }====================================================== */ @@ -133,6 +145,7 @@ static int l_checkmode (const char *mode) { /* }====================================================== */ + #define IO_PREFIX "_IO_" #define IOPREF_LEN (sizeof(IO_PREFIX)/sizeof(char) - 1) #define IO_INPUT (IO_PREFIX "input") @@ -152,7 +165,7 @@ static int io_type (lua_State *L) { luaL_checkany(L, 1); p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE); if (p == NULL) - lua_pushnil(L); /* not a file */ + luaL_pushfail(L); /* not a file */ else if (isclosed(p)) lua_pushliteral(L, "closed file"); else @@ -173,7 +186,7 @@ static int f_tostring (lua_State *L) { static FILE *tofile (lua_State *L) { LStream *p = tolstream(L); - if (isclosed(p)) + if (l_unlikely(isclosed(p))) luaL_error(L, "attempt to use a closed file"); lua_assert(p->f); return p->f; @@ -186,7 +199,7 @@ static FILE *tofile (lua_State *L) { ** handle is in a consistent state. */ static LStream *newprefile (lua_State *L) { - LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream)); + LStream *p = (LStream *)lua_newuserdatauv(L, sizeof(LStream), 0); p->closef = NULL; /* mark file handle as 'closed' */ luaL_setmetatable(L, LUA_FILEHANDLE); return p; @@ -214,7 +227,7 @@ static int f_close (lua_State *L) { static int io_close (lua_State *L) { if (lua_isnone(L, 1)) /* no argument? */ - lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use default output */ return f_close(L); } @@ -232,8 +245,8 @@ static int f_gc (lua_State *L) { */ static int io_fclose (lua_State *L) { LStream *p = tolstream(L); - int res = fclose(p->f); - return luaL_fileresult(L, (res == 0), NULL); + errno = 0; + return luaL_fileresult(L, (fclose(p->f) == 0), NULL); } @@ -248,7 +261,7 @@ static LStream *newfile (lua_State *L) { static void opencheck (lua_State *L, const char *fname, const char *mode) { LStream *p = newfile(L); p->f = fopen(fname, mode); - if (p->f == NULL) + if (l_unlikely(p->f == NULL)) luaL_error(L, "cannot open file '%s' (%s)", fname, strerror(errno)); } @@ -259,6 +272,7 @@ static int io_open (lua_State *L) { LStream *p = newfile(L); const char *md = mode; /* to traverse/check mode */ luaL_argcheck(L, l_checkmode(md), 2, "invalid mode"); + errno = 0; p->f = fopen(filename, mode); return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; } @@ -269,6 +283,7 @@ static int io_open (lua_State *L) { */ static int io_pclose (lua_State *L) { LStream *p = tolstream(L); + errno = 0; return luaL_execresult(L, l_pclose(L, p->f)); } @@ -277,6 +292,8 @@ static int io_popen (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); LStream *p = newprefile(L); + luaL_argcheck(L, l_checkmodep(mode), 2, "invalid mode"); + errno = 0; p->f = l_popen(L, filename, mode); p->closef = &io_pclose; return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; @@ -285,6 +302,7 @@ static int io_popen (lua_State *L) { static int io_tmpfile (lua_State *L) { LStream *p = newfile(L); + errno = 0; p->f = tmpfile(); return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1; } @@ -294,8 +312,8 @@ static FILE *getiofile (lua_State *L, const char *findex) { LStream *p; lua_getfield(L, LUA_REGISTRYINDEX, findex); p = (LStream *)lua_touserdata(L, -1); - if (isclosed(p)) - luaL_error(L, "standard %s file is closed", findex + IOPREF_LEN); + if (l_unlikely(isclosed(p))) + luaL_error(L, "default %s file is closed", findex + IOPREF_LEN); return p->f; } @@ -336,12 +354,22 @@ static int io_readline (lua_State *L); */ #define MAXARGLINE 250 +/* +** Auxiliary function to create the iteration function for 'lines'. +** The iteration function is a closure over 'io_readline', with +** the following upvalues: +** 1) The file being read (first value in the stack) +** 2) the number of arguments to read +** 3) a boolean, true iff file has to be closed when finished ('toclose') +** *) a variable number of format arguments (rest of the stack) +*/ static void aux_lines (lua_State *L, int toclose) { int n = lua_gettop(L) - 1; /* number of arguments to read */ luaL_argcheck(L, n <= MAXARGLINE, MAXARGLINE + 2, "too many arguments"); + lua_pushvalue(L, 1); /* file */ lua_pushinteger(L, n); /* number of arguments to read */ lua_pushboolean(L, toclose); /* close/not close file when finished */ - lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */ + lua_rotate(L, 2, 3); /* move the three values to their positions */ lua_pushcclosure(L, io_readline, 3 + n); } @@ -353,6 +381,11 @@ static int f_lines (lua_State *L) { } +/* +** Return an iteration function for 'io.lines'. If file has to be +** closed, also returns the file itself as a second result (to be +** closed as the state at the exit of a generic for). +*/ static int io_lines (lua_State *L) { int toclose; if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */ @@ -368,8 +401,15 @@ static int io_lines (lua_State *L) { lua_replace(L, 1); /* put file at index 1 */ toclose = 1; /* close it after iteration */ } - aux_lines(L, toclose); - return 1; + aux_lines(L, toclose); /* push iteration function */ + if (toclose) { + lua_pushnil(L); /* state */ + lua_pushnil(L); /* control */ + lua_pushvalue(L, 1); /* file is the to-be-closed variable (4th result) */ + return 4; + } + else + return 1; } @@ -399,7 +439,7 @@ typedef struct { ** Add current char to buffer (if not out of space) and read next one */ static int nextc (RN *rn) { - if (rn->n >= L_MAXLENNUM) { /* buffer overflow? */ + if (l_unlikely(rn->n >= L_MAXLENNUM)) { /* buffer overflow? */ rn->buff[0] = '\0'; /* invalidate result */ return 0; /* fail */ } @@ -435,7 +475,7 @@ static int readdigits (RN *rn, int hex) { /* ** Read a number: first reads a valid prefix of a numeral into a buffer. ** Then it calls 'lua_stringtonumber' to check whether the format is -** correct and to convert it to a Lua number +** correct and to convert it to a Lua number. */ static int read_number (lua_State *L, FILE *f) { RN rn; @@ -447,7 +487,7 @@ static int read_number (lua_State *L, FILE *f) { decp[1] = '.'; /* always accept a dot */ l_lockfile(rn.f); do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */ - test2(&rn, "-+"); /* optional signal */ + test2(&rn, "-+"); /* optional sign */ if (test2(&rn, "00")) { if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */ else count = 1; /* count initial '0' as a valid digit */ @@ -456,14 +496,14 @@ static int read_number (lua_State *L, FILE *f) { if (test2(&rn, decp)) /* decimal point? */ count += readdigits(&rn, hex); /* fractional part */ if (count > 0 && test2(&rn, (hex ? "pP" : "eE"))) { /* exponent mark? */ - test2(&rn, "-+"); /* exponent signal */ + test2(&rn, "-+"); /* exponent sign */ readdigits(&rn, 0); /* exponent digits */ } ungetc(rn.c, rn.f); /* unread look-ahead char */ l_unlockfile(rn.f); rn.buff[rn.n] = '\0'; /* finish string */ - if (lua_stringtonumber(L, rn.buff)) /* is this a valid number? */ - return 1; /* ok */ + if (l_likely(lua_stringtonumber(L, rn.buff))) + return 1; /* ok, it is a valid number */ else { /* invalid format */ lua_pushnil(L); /* "result" to be removed */ return 0; /* read fails */ @@ -481,15 +521,15 @@ static int test_eof (lua_State *L, FILE *f) { static int read_line (lua_State *L, FILE *f, int chop) { luaL_Buffer b; - int c = '\0'; + int c; luaL_buffinit(L, &b); - while (c != EOF && c != '\n') { /* repeat until end of line */ - char *buff = luaL_prepbuffer(&b); /* preallocate buffer */ + do { /* may need to read several chunks to get whole line */ + char *buff = luaL_prepbuffer(&b); /* preallocate buffer space */ int i = 0; l_lockfile(f); /* no memory errors can happen inside the lock */ #ifdef U8W_H if (f == stdin) { - char *pb = u8fgets(buff, LUAL_BUFFERSIZE, f); + char *pb = fgets(buff, LUAL_BUFFERSIZE, f); if (pb != NULL) { char *pbn = strchr(buff, '\n'); if (pbn != NULL) { @@ -503,15 +543,16 @@ static int read_line (lua_State *L, FILE *f, int chop) { } } else { -#endif - while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') - buff[i++] = c; -#ifdef U8W_H + while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') + buff[i++] = c; /* read up to end of line or buffer limit */ } +#else + while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') + buff[i++] = c; /* read up to end of line or buffer limit */ #endif l_unlockfile(f); luaL_addsize(&b, i); - } + } while (c != EOF && c != '\n'); /* repeat until end of line */ if (!chop && c == '\n') /* want a newline and have one? */ luaL_addchar(&b, c); /* add ending newline to result */ luaL_pushresult(&b); /* close buffer */ @@ -548,14 +589,15 @@ static int read_chars (lua_State *L, FILE *f, size_t n) { static int g_read (lua_State *L, FILE *f, int first) { int nargs = lua_gettop(L) - 1; - int success; - int n; + int n, success; clearerr(f); + errno = 0; if (nargs == 0) { /* no arguments? */ success = read_line(L, f, 1); - n = first+1; /* to return 1 result */ + n = first + 1; /* to return 1 result */ } - else { /* ensure stack space for all results and for auxlib's buffer */ + else { + /* ensure stack space for all results and for auxlib's buffer */ luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); success = 1; for (n = first; nargs-- && success; n++) { @@ -590,7 +632,7 @@ static int g_read (lua_State *L, FILE *f, int first) { return luaL_fileresult(L, 0, NULL); if (!success) { lua_pop(L, 1); /* remove last result */ - lua_pushnil(L); /* push nil instead */ + luaL_pushfail(L); /* push nil instead */ } return n - first; } @@ -606,6 +648,9 @@ static int f_read (lua_State *L) { } +/* +** Iteration function for 'lines'. +*/ static int io_readline (lua_State *L) { LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1)); int i; @@ -620,14 +665,14 @@ static int io_readline (lua_State *L) { lua_assert(n > 0); /* should return at least a nil */ if (lua_toboolean(L, -n)) /* read at least one value? */ return n; /* return them */ - else { /* first result is nil: EOF or error */ + else { /* first result is false: EOF or error */ if (n > 1) { /* is there error information? */ /* 2nd result is error message */ return luaL_error(L, "%s", lua_tostring(L, -n + 1)); } if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ - lua_settop(L, 0); - lua_pushvalue(L, lua_upvalueindex(1)); + lua_settop(L, 0); /* clear stack */ + lua_pushvalue(L, lua_upvalueindex(1)); /* push file at index 1 */ aux_close(L); /* close it */ } return 0; @@ -640,6 +685,7 @@ static int io_readline (lua_State *L) { static int g_write (lua_State *L, FILE *f, int arg) { int nargs = lua_gettop(L) - arg; int status = 1; + errno = 0; for (; nargs--; arg++) { if (lua_type(L, arg) == LUA_TNUMBER) { /* optimization: could be done exactly as for strings */ @@ -663,8 +709,10 @@ static int g_write (lua_State *L, FILE *f, int arg) { #endif } } - if (status) return 1; /* file handle already on stack top */ - else return luaL_fileresult(L, status, NULL); + if (l_likely(status)) + return 1; /* file handle already on stack top */ + else + return luaL_fileresult(L, status, NULL); } @@ -689,8 +737,9 @@ static int f_seek (lua_State *L) { l_seeknum offset = (l_seeknum)p3; luaL_argcheck(L, (lua_Integer)offset == p3, 3, "not an integer in proper range"); + errno = 0; op = l_fseek(f, offset, mode[op]); - if (op) + if (l_unlikely(op)) return luaL_fileresult(L, 0, NULL); /* error */ else { lua_pushinteger(L, (lua_Integer)l_ftell(f)); @@ -705,19 +754,25 @@ static int f_setvbuf (lua_State *L) { FILE *f = tofile(L); int op = luaL_checkoption(L, 2, NULL, modenames); lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); - int res = setvbuf(f, NULL, mode[op], (size_t)sz); + int res; + errno = 0; + res = setvbuf(f, NULL, mode[op], (size_t)sz); return luaL_fileresult(L, res == 0, NULL); } static int io_flush (lua_State *L) { - return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); + FILE *f = getiofile(L, IO_OUTPUT); + errno = 0; + return luaL_fileresult(L, fflush(f) == 0, NULL); } static int f_flush (lua_State *L) { - return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); + FILE *f = tofile(L); + errno = 0; + return luaL_fileresult(L, fflush(f) == 0, NULL); } @@ -743,26 +798,37 @@ static const luaL_Reg iolib[] = { /* ** methods for file handles */ -static const luaL_Reg flib[] = { - {"close", f_close}, - {"flush", f_flush}, - {"lines", f_lines}, +static const luaL_Reg meth[] = { {"read", f_read}, + {"write", f_write}, + {"lines", f_lines}, + {"flush", f_flush}, {"seek", f_seek}, + {"close", f_close}, {"setvbuf", f_setvbuf}, - {"write", f_write}, + {NULL, NULL} +}; + + +/* +** metamethods for file handles +*/ +static const luaL_Reg metameth[] = { + {"__index", NULL}, /* placeholder */ {"__gc", f_gc}, + {"__close", f_gc}, {"__tostring", f_tostring}, {NULL, NULL} }; static void createmeta (lua_State *L) { - luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ - lua_pop(L, 1); /* pop new metatable */ + luaL_newmetatable(L, LUA_FILEHANDLE); /* metatable for file handles */ + luaL_setfuncs(L, metameth, 0); /* add metamethods to new metatable */ + luaL_newlibtable(L, meth); /* create method table */ + luaL_setfuncs(L, meth, 0); /* add file methods to method table */ + lua_setfield(L, -2, "__index"); /* metatable.__index = method table */ + lua_pop(L, 1); /* pop metatable */ } @@ -772,7 +838,7 @@ static void createmeta (lua_State *L) { static int io_noclose (lua_State *L) { LStream *p = tolstream(L); p->closef = &io_noclose; /* keep file opened */ - lua_pushnil(L); + luaL_pushfail(L); lua_pushliteral(L, "cannot close standard file"); return 2; } diff --git a/liblua/ljumptab.h b/liblua/ljumptab.h new file mode 100644 index 00000000..8306f250 --- /dev/null +++ b/liblua/ljumptab.h @@ -0,0 +1,112 @@ +/* +** $Id: ljumptab.h $ +** Jump Table for the Lua interpreter +** See Copyright Notice in lua.h +*/ + + +#undef vmdispatch +#undef vmcase +#undef vmbreak + +#define vmdispatch(x) goto *disptab[x]; + +#define vmcase(l) L_##l: + +#define vmbreak vmfetch(); vmdispatch(GET_OPCODE(i)); + + +static const void *const disptab[NUM_OPCODES] = { + +#if 0 +** you can update the following list with this command: +** +** sed -n '/^OP_/\!d; s/OP_/\&\&L_OP_/ ; s/,.*/,/ ; s/\/.*// ; p' lopcodes.h +** +#endif + +&&L_OP_MOVE, +&&L_OP_LOADI, +&&L_OP_LOADF, +&&L_OP_LOADK, +&&L_OP_LOADKX, +&&L_OP_LOADFALSE, +&&L_OP_LFALSESKIP, +&&L_OP_LOADTRUE, +&&L_OP_LOADNIL, +&&L_OP_GETUPVAL, +&&L_OP_SETUPVAL, +&&L_OP_GETTABUP, +&&L_OP_GETTABLE, +&&L_OP_GETI, +&&L_OP_GETFIELD, +&&L_OP_SETTABUP, +&&L_OP_SETTABLE, +&&L_OP_SETI, +&&L_OP_SETFIELD, +&&L_OP_NEWTABLE, +&&L_OP_SELF, +&&L_OP_ADDI, +&&L_OP_ADDK, +&&L_OP_SUBK, +&&L_OP_MULK, +&&L_OP_MODK, +&&L_OP_POWK, +&&L_OP_DIVK, +&&L_OP_IDIVK, +&&L_OP_BANDK, +&&L_OP_BORK, +&&L_OP_BXORK, +&&L_OP_SHRI, +&&L_OP_SHLI, +&&L_OP_ADD, +&&L_OP_SUB, +&&L_OP_MUL, +&&L_OP_MOD, +&&L_OP_POW, +&&L_OP_DIV, +&&L_OP_IDIV, +&&L_OP_BAND, +&&L_OP_BOR, +&&L_OP_BXOR, +&&L_OP_SHL, +&&L_OP_SHR, +&&L_OP_MMBIN, +&&L_OP_MMBINI, +&&L_OP_MMBINK, +&&L_OP_UNM, +&&L_OP_BNOT, +&&L_OP_NOT, +&&L_OP_LEN, +&&L_OP_CONCAT, +&&L_OP_CLOSE, +&&L_OP_TBC, +&&L_OP_JMP, +&&L_OP_EQ, +&&L_OP_LT, +&&L_OP_LE, +&&L_OP_EQK, +&&L_OP_EQI, +&&L_OP_LTI, +&&L_OP_LEI, +&&L_OP_GTI, +&&L_OP_GEI, +&&L_OP_TEST, +&&L_OP_TESTSET, +&&L_OP_CALL, +&&L_OP_TAILCALL, +&&L_OP_RETURN, +&&L_OP_RETURN0, +&&L_OP_RETURN1, +&&L_OP_FORLOOP, +&&L_OP_FORPREP, +&&L_OP_TFORPREP, +&&L_OP_TFORCALL, +&&L_OP_TFORLOOP, +&&L_OP_SETLIST, +&&L_OP_CLOSURE, +&&L_OP_VARARG, +&&L_OP_VARARGPREP, +&&L_OP_EXTRAARG + +}; diff --git a/liblua/llex.c b/liblua/llex.c index 66fd411b..5fc39a5c 100644 --- a/liblua/llex.c +++ b/liblua/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.96.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: llex.c $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -29,7 +29,7 @@ -#define next(ls) (ls->current = zgetc(ls->z)) +#define next(ls) (ls->current = zgetc(ls->z)) @@ -63,7 +63,7 @@ static void save (LexState *ls, int c) { newsize = luaZ_sizebuffer(b) * 2; luaZ_resizebuffer(ls->L, b, newsize); } - b->buffer[luaZ_bufflen(b)++] = cast(char, c); + b->buffer[luaZ_bufflen(b)++] = cast_char(c); } @@ -81,8 +81,10 @@ void luaX_init (lua_State *L) { const char *luaX_token2str (LexState *ls, int token) { if (token < FIRST_RESERVED) { /* single-byte symbols? */ - lua_assert(token == cast_uchar(token)); - return luaO_pushfstring(ls->L, "'%c'", token); + if (lisprint(token)) + return luaO_pushfstring(ls->L, "'%c'", token); + else /* control character */ + return luaO_pushfstring(ls->L, "'<\\%d>'", token); } else { const char *s = luaX_tokens[token - FIRST_RESERVED]; @@ -120,26 +122,29 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) { /* -** creates a new string and anchors it in scanner's table so that -** it will not be collected until the end of the compilation -** (by that time it should be anchored somewhere) +** Creates a new string and anchors it in scanner's table so that it +** will not be collected until the end of the compilation; by that time +** it should be anchored somewhere. It also internalizes long strings, +** ensuring there is only one copy of each unique string. The table +** here is used as a set: the string enters as the key, while its value +** is irrelevant. We use the string itself as the value only because it +** is a TValue readily available. Later, the code generation can change +** this value. */ TString *luaX_newstring (LexState *ls, const char *str, size_t l) { lua_State *L = ls->L; - TValue *o; /* entry for 'str' */ TString *ts = luaS_newlstr(L, str, l); /* create new string */ - setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */ - o = luaH_set(L, ls->h, L->top - 1); - if (ttisnil(o)) { /* not in use yet? */ - /* boolean value does not need GC barrier; - table has no metatable, so it does not need to invalidate cache */ - setbvalue(o, 1); /* t[string] = true */ + const TValue *o = luaH_getstr(ls->h, ts); + if (!ttisnil(o)) /* string already present? */ + ts = keystrval(nodefromval(o)); /* get saved copy */ + else { /* not in use yet */ + TValue *stv = s2v(L->top.p++); /* reserve stack space for string */ + setsvalue(L, stv, ts); /* temporarily anchor the string */ + luaH_finishset(L, ls->h, stv, o, stv); /* t[string] = string */ + /* table is not a metatable, so it does not need to invalidate cache */ luaC_checkGC(L); + L->top.p--; /* remove string from stack */ } - else { /* string already present */ - ts = tsvalue(keyfromval(o)); /* re-use value previously stored */ - } - L->top--; /* remove string from stack */ return ts; } @@ -208,8 +213,16 @@ static int check_next2 (LexState *ls, const char *set) { /* LUA_NUMBER */ /* -** this function is quite liberal in what it accepts, as 'luaO_str2num' -** will reject ill-formed numerals. +** This function is quite liberal in what it accepts, as 'luaO_str2num' +** will reject ill-formed numerals. Roughly, it accepts the following +** pattern: +** +** %d(%x|%.|([Ee][+-]?))* | 0[Xx](%x|%.|([Pp][+-]?))* +** +** The only tricky part is to accept [+-] only after a valid exponent +** mark, to avoid reading '3-4' or '0xe+1' as a single number. +** +** The caller might have already read an initial dot. */ static int read_numeral (LexState *ls, SemInfo *seminfo) { TValue obj; @@ -220,14 +233,14 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) { if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */ expo = "Pp"; for (;;) { - if (check_next2(ls, expo)) /* exponent part? */ + if (check_next2(ls, expo)) /* exponent mark? */ check_next2(ls, "-+"); /* optional exponent sign */ - if (lisxdigit(ls->current)) - save_and_next(ls); - else if (ls->current == '.') + else if (lisxdigit(ls->current) || ls->current == '.') /* '%x|%.' */ save_and_next(ls); else break; } + if (lislalpha(ls->current)) /* is numeral touching a letter? */ + save_and_next(ls); /* force an error */ save(ls, '\0'); if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */ lexerror(ls, "malformed number", TK_FLT); @@ -244,12 +257,13 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) { /* -** skip a sequence '[=*[' or ']=*]'; if sequence is well formed, return -** its number of '='s; otherwise, return a negative number (-1 iff there -** are no '='s after initial bracket) +** read a sequence '[=*[' or ']=*]', leaving the last bracket. If +** sequence is well formed, return its number of '='s + 2; otherwise, +** return 1 if it is a single bracket (no '='s and no 2nd bracket); +** otherwise (an unfinished '[==...') return 0. */ -static int skip_sep (LexState *ls) { - int count = 0; +static size_t skip_sep (LexState *ls) { + size_t count = 0; int s = ls->current; lua_assert(s == '[' || s == ']'); save_and_next(ls); @@ -257,11 +271,13 @@ static int skip_sep (LexState *ls) { save_and_next(ls); count++; } - return (ls->current == s) ? count : (-count) - 1; + return (ls->current == s) ? count + 2 + : (count == 0) ? 1 + : 0; } -static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { +static void read_long_string (LexState *ls, SemInfo *seminfo, size_t sep) { int line = ls->linenumber; /* initial line (for error message) */ save_and_next(ls); /* skip 2nd '[' */ if (currIsNewline(ls)) /* string starts with a newline? */ @@ -295,8 +311,8 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { } } endloop: if (seminfo) - seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), - luaZ_bufflen(ls->buff) - 2*(2 + sep)); + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + sep, + luaZ_bufflen(ls->buff) - 2 * sep); } @@ -330,10 +346,10 @@ static unsigned long readutf8esc (LexState *ls) { save_and_next(ls); /* skip 'u' */ esccheck(ls, ls->current == '{', "missing '{'"); r = gethexa(ls); /* must have at least one digit */ - while ((save_and_next(ls), lisxdigit(ls->current))) { + while (cast_void(save_and_next(ls)), lisxdigit(ls->current)) { i++; + esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large"); r = (r << 4) + luaO_hexavalue(ls->current); - esccheck(ls, r <= 0x10FFFF, "UTF-8 value too large"); } esccheck(ls, ls->current == '}', "missing '}'"); next(ls); /* skip '}' */ @@ -444,9 +460,9 @@ static int llex (LexState *ls, SemInfo *seminfo) { /* else is a comment */ next(ls); if (ls->current == '[') { /* long comment? */ - int sep = skip_sep(ls); + size_t sep = skip_sep(ls); luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */ - if (sep >= 0) { + if (sep >= 2) { read_long_string(ls, NULL, sep); /* skip long comment */ luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ break; @@ -458,45 +474,45 @@ static int llex (LexState *ls, SemInfo *seminfo) { break; } case '[': { /* long string or simply '[' */ - int sep = skip_sep(ls); - if (sep >= 0) { + size_t sep = skip_sep(ls); + if (sep >= 2) { read_long_string(ls, seminfo, sep); return TK_STRING; } - else if (sep != -1) /* '[=...' missing second bracket */ + else if (sep == 0) /* '[=...' missing second bracket? */ lexerror(ls, "invalid long string delimiter", TK_STRING); return '['; } case '=': { next(ls); - if (check_next1(ls, '=')) return TK_EQ; + if (check_next1(ls, '=')) return TK_EQ; /* '==' */ else return '='; } case '<': { next(ls); - if (check_next1(ls, '=')) return TK_LE; - else if (check_next1(ls, '<')) return TK_SHL; + if (check_next1(ls, '=')) return TK_LE; /* '<=' */ + else if (check_next1(ls, '<')) return TK_SHL; /* '<<' */ else return '<'; } case '>': { next(ls); - if (check_next1(ls, '=')) return TK_GE; - else if (check_next1(ls, '>')) return TK_SHR; + if (check_next1(ls, '=')) return TK_GE; /* '>=' */ + else if (check_next1(ls, '>')) return TK_SHR; /* '>>' */ else return '>'; } case '/': { next(ls); - if (check_next1(ls, '/')) return TK_IDIV; + if (check_next1(ls, '/')) return TK_IDIV; /* '//' */ else return '/'; } case '~': { next(ls); - if (check_next1(ls, '=')) return TK_NE; + if (check_next1(ls, '=')) return TK_NE; /* '~=' */ else return '~'; } case ':': { next(ls); - if (check_next1(ls, ':')) return TK_DBCOLON; + if (check_next1(ls, ':')) return TK_DBCOLON; /* '::' */ else return ':'; } case '"': case '\'': { /* short literal strings */ @@ -535,7 +551,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { return TK_NAME; } } - else { /* single-char tokens (+ - / ...) */ + else { /* single-char tokens ('+', '*', '%', '{', '}', ...) */ int c = ls->current; next(ls); return c; diff --git a/liblua/llex.h b/liblua/llex.h index 2ed0af66..389d2f86 100644 --- a/liblua/llex.h +++ b/liblua/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.79.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: llex.h $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -7,11 +7,17 @@ #ifndef llex_h #define llex_h +#include + #include "lobject.h" #include "lzio.h" -#define FIRST_RESERVED 257 +/* +** Single-char tokens (terminal symbols) are represented by their own +** numeric code. Other tokens start at the following value. +*/ +#define FIRST_RESERVED (UCHAR_MAX + 1) #if !defined(LUA_ENV) @@ -37,7 +43,7 @@ enum RESERVED { }; /* number of reserved words */ -#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) +#define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1)) typedef union { diff --git a/liblua/llimits.h b/liblua/llimits.h index d1036f6b..1c826f7b 100644 --- a/liblua/llimits.h +++ b/liblua/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.141.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: llimits.h $ ** Limits, basic types, and some other 'installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -14,6 +14,7 @@ #include "lua.h" + /* ** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count ** the total memory used by Lua (in bytes). Usually, 'size_t' and @@ -22,7 +23,7 @@ #if defined(LUAI_MEM) /* { external definitions? */ typedef LUAI_UMEM lu_mem; typedef LUAI_MEM l_mem; -#elif LUAI_BITSINT >= 32 /* }{ */ +#elif LUAI_IS32INT /* }{ */ typedef size_t lu_mem; typedef ptrdiff_t l_mem; #else /* 16-bit ints */ /* }{ */ @@ -33,12 +34,13 @@ typedef long l_mem; /* chars used as small naturals (so that 'char' is reserved for characters) */ typedef unsigned char lu_byte; +typedef signed char ls_byte; /* maximum value for size_t */ #define MAX_SIZET ((size_t)(~(size_t)0)) -/* maximum size visible for Lua (must be representable in a lua_Integer */ +/* maximum size visible for Lua (must be representable in a lua_Integer) */ #define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ : (size_t)(LUA_MAXINTEGER)) @@ -52,27 +54,42 @@ typedef unsigned char lu_byte; /* -** conversion of pointer to unsigned integer: -** this is for hashing only; there is no problem if the integer -** cannot hold the whole pointer value +** floor of the log2 of the maximum signed value for integral type 't'. +** (That is, maximum 'n' such that '2^n' fits in the given signed type.) */ -#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) +#define log2maxs(t) (sizeof(t) * 8 - 2) +/* +** test whether an unsigned value is a power of 2 (or zero) +*/ +#define ispow2(x) (((x) & ((x) - 1)) == 0) -/* type to ensure maximum alignment */ -#if defined(LUAI_USER_ALIGNMENT_T) -typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; -#else -typedef union { - lua_Number n; - double u; - void *s; - lua_Integer i; - long l; -} L_Umaxalign; + +/* number of chars of a literal string without the ending \0 */ +#define LL(x) (sizeof(x)/sizeof(char) - 1) + + +/* +** conversion of pointer to unsigned integer: this is for hashing only; +** there is no problem if the integer cannot hold the whole pointer +** value. (In strict ISO C this may cause undefined behavior, but no +** actual machine seems to bother.) +*/ +#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 199901L +#include +#if defined(UINTPTR_MAX) /* even in C99 this type is optional */ +#define L_P2I uintptr_t +#else /* no 'intptr'? */ +#define L_P2I uintmax_t /* use the largest available integer */ +#endif +#else /* C89 option */ +#define L_P2I size_t #endif +#define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX)) + /* types of 'usual argument conversions' for lua_Number and lua_Integer */ @@ -80,7 +97,15 @@ typedef LUAI_UACNUMBER l_uacNumber; typedef LUAI_UACINT l_uacInt; -/* internal assertions for in-house debugging */ +/* +** Internal assertions for in-house debugging +*/ +#if defined LUAI_ASSERT +#undef NDEBUG +#include +#define lua_assert(c) assert(c) +#endif + #if defined(lua_assert) #define check_exp(c,e) (lua_assert(c), (e)) /* to avoid problems with conditions too long */ @@ -95,7 +120,7 @@ typedef LUAI_UACINT l_uacInt; ** assertion for checking API calls */ #if !defined(luai_apicheck) -#define luai_apicheck(l,e) lua_assert(e) +#define luai_apicheck(l,e) ((void)l, lua_assert(e)) #endif #define api_check(l,e,msg) luai_apicheck(l,(e) && msg) @@ -111,10 +136,15 @@ typedef LUAI_UACINT l_uacInt; #define cast(t, exp) ((t)(exp)) #define cast_void(i) cast(void, (i)) -#define cast_byte(i) cast(lu_byte, (i)) +#define cast_voidp(i) cast(void *, (i)) #define cast_num(i) cast(lua_Number, (i)) #define cast_int(i) cast(int, (i)) +#define cast_uint(i) cast(unsigned int, (i)) +#define cast_byte(i) cast(lu_byte, (i)) #define cast_uchar(i) cast(unsigned char, (i)) +#define cast_char(i) cast(char, (i)) +#define cast_charp(i) cast(char *, (i)) +#define cast_sizet(i) cast(size_t, (i)) /* cast a signed lua_Integer to lua_Unsigned */ @@ -135,6 +165,8 @@ typedef LUAI_UACINT l_uacInt; /* ** non-return type */ +#if !defined(l_noret) + #if defined(__GNUC__) #define l_noret void __attribute__((noreturn)) #elif defined(_MSC_VER) && _MSC_VER >= 1200 @@ -143,28 +175,35 @@ typedef LUAI_UACINT l_uacInt; #define l_noret void #endif +#endif /* -** maximum depth for nested C calls and syntactical nested non-terminals -** in a program. (Value must fit in an unsigned short int.) +** Inline functions */ -#if !defined(LUAI_MAXCCALLS) -#define LUAI_MAXCCALLS 200 +#if !defined(LUA_USE_C89) +#define l_inline inline +#elif defined(__GNUC__) +#define l_inline __inline__ +#else +#define l_inline /* empty */ #endif +#define l_sinline static l_inline /* ** type for virtual-machine instructions; ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) */ -#if LUAI_BITSINT >= 32 -typedef unsigned int Instruction; +#if LUAI_IS32INT +typedef unsigned int l_uint32; #else -typedef unsigned long Instruction; +typedef unsigned long l_uint32; #endif +typedef l_uint32 Instruction; + /* @@ -206,6 +245,17 @@ typedef unsigned long Instruction; #endif +/* +** Maximum depth for nested C calls, syntactical nested non-terminals, +** and other features implemented through recursion in C. (Value must +** fit in a 16-bit unsigned integer. It must also be compatible with +** the size of the C stack.) +*/ +#if !defined(LUAI_MAXCCALLS) +#define LUAI_MAXCCALLS 200 +#endif + + /* ** macros that are executed whenever program enters the Lua core ** ('lua_lock') and leaves the core ('lua_unlock') @@ -225,8 +275,7 @@ typedef unsigned long Instruction; /* -** these macros allow user-specific actions on threads when you defined -** LUAI_EXTRASPACE and need to do something extra when a thread is +** these macros allow user-specific actions when a thread is ** created/deleted/resumed/yielded. */ #if !defined(luai_userstateopen) @@ -270,20 +319,26 @@ typedef unsigned long Instruction; #endif /* -** modulo: defined as 'a - floor(a/b)*b'; this definition gives NaN when -** 'b' is huge, but the result should be 'a'. 'fmod' gives the result of -** 'a - trunc(a/b)*b', and therefore must be corrected when 'trunc(a/b) -** ~= floor(a/b)'. That happens when the division has a non-integer -** negative result, which is equivalent to the test below. +** modulo: defined as 'a - floor(a/b)*b'; the direct computation +** using this definition has several problems with rounding errors, +** so it is better to use 'fmod'. 'fmod' gives the result of +** 'a - trunc(a/b)*b', and therefore must be corrected when +** 'trunc(a/b) ~= floor(a/b)'. That happens when the division has a +** non-integer negative result: non-integer result is equivalent to +** a non-zero remainder 'm'; negative result is equivalent to 'a' and +** 'b' with different signs, or 'm' and 'b' with different signs +** (as the result 'm' of 'fmod' has the same sign of 'a'). */ #if !defined(luai_nummod) #define luai_nummod(L,a,b,m) \ - { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); } + { (void)L; (m) = l_mathop(fmod)(a,b); \ + if (((m) > 0) ? (b) < 0 : ((m) < 0 && (b) > 0)) (m) += (b); } #endif /* exponentiation */ #if !defined(luai_numpow) -#define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) +#define luai_numpow(L,a,b) \ + ((void)L, (b == 2) ? (a)*(a) : l_mathop(pow)(a,b)) #endif /* the others are quite standard operations */ @@ -295,6 +350,8 @@ typedef unsigned long Instruction; #define luai_numeq(a,b) ((a)==(b)) #define luai_numlt(a,b) ((a)<(b)) #define luai_numle(a,b) ((a)<=(b)) +#define luai_numgt(a,b) ((a)>(b)) +#define luai_numge(a,b) ((a)>=(b)) #define luai_numisnan(a) (!luai_numeq((a), (a))) #endif @@ -310,14 +367,14 @@ typedef unsigned long Instruction; #else /* realloc stack keeping its size */ #define condmovestack(L,pre,pos) \ - { int sz_ = (L)->stacksize; pre; luaD_reallocstack((L), sz_); pos; } + { int sz_ = stacksize(L); pre; luaD_reallocstack((L), sz_, 0); pos; } #endif #if !defined(HARDMEMTESTS) #define condchangemem(L,pre,pos) ((void)0) #else #define condchangemem(L,pre,pos) \ - { if (G(L)->gcrunning) { pre; luaC_fullgc(L, 0); pos; } } + { if (gcrunning(G(L))) { pre; luaC_fullgc(L, 0); pos; } } #endif #endif diff --git a/liblua/lmathlib.c b/liblua/lmathlib.c index 7ef7e593..43810634 100644 --- a/liblua/lmathlib.c +++ b/liblua/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.119.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lmathlib.c $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -10,8 +10,11 @@ #include "lprefix.h" -#include +#include +#include #include +#include +#include #include "lua.h" @@ -23,19 +26,6 @@ #define PI (l_mathop(3.141592653589793238462643383279502884)) -#if !defined(l_rand) /* { */ -#if defined(LUA_USE_POSIX) -#define l_rand() random() -#define l_srand(x) srandom(x) -#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */ -#else -#define l_rand() rand() -#define l_srand(x) srand(x) -#define L_RANDMAX RAND_MAX -#endif -#endif /* } */ - - static int math_abs (lua_State *L) { if (lua_isinteger(L, 1)) { lua_Integer n = lua_tointeger(L, 1); @@ -83,11 +73,11 @@ static int math_atan (lua_State *L) { static int math_toint (lua_State *L) { int valid; lua_Integer n = lua_tointegerx(L, 1, &valid); - if (valid) + if (l_likely(valid)) lua_pushinteger(L, n); else { luaL_checkany(L, 1); - lua_pushnil(L); /* value is not convertible to integer */ + luaL_pushfail(L); /* value is not convertible to integer */ } return 1; } @@ -185,7 +175,8 @@ static int math_log (lua_State *L) { lua_Number base = luaL_checknumber(L, 2); #if !defined(LUA_USE_C89) if (base == l_mathop(2.0)) - res = l_mathop(log2)(x); else + res = l_mathop(log2)(x); + else #endif if (base == l_mathop(10.0)) res = l_mathop(log10)(x); @@ -239,22 +230,364 @@ static int math_max (lua_State *L) { return 1; } + +static int math_type (lua_State *L) { + if (lua_type(L, 1) == LUA_TNUMBER) + lua_pushstring(L, (lua_isinteger(L, 1)) ? "integer" : "float"); + else { + luaL_checkany(L, 1); + luaL_pushfail(L); + } + return 1; +} + + + +/* +** {================================================================== +** Pseudo-Random Number Generator based on 'xoshiro256**'. +** =================================================================== +*/ + /* -** This function uses 'double' (instead of 'lua_Number') to ensure that -** all bits from 'l_rand' can be represented, and that 'RANDMAX + 1.0' -** will keep full precision (ensuring that 'r' is always less than 1.0.) +** This code uses lots of shifts. ANSI C does not allow shifts greater +** than or equal to the width of the type being shifted, so some shifts +** are written in convoluted ways to match that restriction. For +** preprocessor tests, it assumes a width of 32 bits, so the maximum +** shift there is 31 bits. */ + + +/* number of binary digits in the mantissa of a float */ +#define FIGS l_floatatt(MANT_DIG) + +#if FIGS > 64 +/* there are only 64 random bits; use them all */ +#undef FIGS +#define FIGS 64 +#endif + + +/* +** LUA_RAND32 forces the use of 32-bit integers in the implementation +** of the PRN generator (mainly for testing). +*/ +#if !defined(LUA_RAND32) && !defined(Rand64) + +/* try to find an integer type with at least 64 bits */ + +#if ((ULONG_MAX >> 31) >> 31) >= 3 + +/* 'long' has at least 64 bits */ +#define Rand64 unsigned long +#define SRand64 long + +#elif !defined(LUA_USE_C89) && defined(LLONG_MAX) + +/* there is a 'long long' type (which must have at least 64 bits) */ +#define Rand64 unsigned long long +#define SRand64 long long + +#elif ((LUA_MAXUNSIGNED >> 31) >> 31) >= 3 + +/* 'lua_Unsigned' has at least 64 bits */ +#define Rand64 lua_Unsigned +#define SRand64 lua_Integer + +#endif + +#endif + + +#if defined(Rand64) /* { */ + +/* +** Standard implementation, using 64-bit integers. +** If 'Rand64' has more than 64 bits, the extra bits do not interfere +** with the 64 initial bits, except in a right shift. Moreover, the +** final result has to discard the extra bits. +*/ + +/* avoid using extra bits when needed */ +#define trim64(x) ((x) & 0xffffffffffffffffu) + + +/* rotate left 'x' by 'n' bits */ +static Rand64 rotl (Rand64 x, int n) { + return (x << n) | (trim64(x) >> (64 - n)); +} + +static Rand64 nextrand (Rand64 *state) { + Rand64 state0 = state[0]; + Rand64 state1 = state[1]; + Rand64 state2 = state[2] ^ state0; + Rand64 state3 = state[3] ^ state1; + Rand64 res = rotl(state1 * 5, 7) * 9; + state[0] = state0 ^ state3; + state[1] = state1 ^ state2; + state[2] = state2 ^ (state1 << 17); + state[3] = rotl(state3, 45); + return res; +} + + +/* +** Convert bits from a random integer into a float in the +** interval [0,1), getting the higher FIG bits from the +** random unsigned integer and converting that to a float. +** Some old Microsoft compilers cannot cast an unsigned long +** to a floating-point number, so we use a signed long as an +** intermediary. When lua_Number is float or double, the shift ensures +** that 'sx' is non negative; in that case, a good compiler will remove +** the correction. +*/ + +/* must throw out the extra (64 - FIGS) bits */ +#define shift64_FIG (64 - FIGS) + +/* 2^(-FIGS) == 2^-1 / 2^(FIGS-1) */ +#define scaleFIG (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1))) + +static lua_Number I2d (Rand64 x) { + SRand64 sx = (SRand64)(trim64(x) >> shift64_FIG); + lua_Number res = (lua_Number)(sx) * scaleFIG; + if (sx < 0) + res += l_mathop(1.0); /* correct the two's complement if negative */ + lua_assert(0 <= res && res < 1); + return res; +} + +/* convert a 'Rand64' to a 'lua_Unsigned' */ +#define I2UInt(x) ((lua_Unsigned)trim64(x)) + +/* convert a 'lua_Unsigned' to a 'Rand64' */ +#define Int2I(x) ((Rand64)(x)) + + +#else /* no 'Rand64' }{ */ + +/* get an integer with at least 32 bits */ +#if LUAI_IS32INT +typedef unsigned int lu_int32; +#else +typedef unsigned long lu_int32; +#endif + + +/* +** Use two 32-bit integers to represent a 64-bit quantity. +*/ +typedef struct Rand64 { + lu_int32 h; /* higher half */ + lu_int32 l; /* lower half */ +} Rand64; + + +/* +** If 'lu_int32' has more than 32 bits, the extra bits do not interfere +** with the 32 initial bits, except in a right shift and comparisons. +** Moreover, the final result has to discard the extra bits. +*/ + +/* avoid using extra bits when needed */ +#define trim32(x) ((x) & 0xffffffffu) + + +/* +** basic operations on 'Rand64' values +*/ + +/* build a new Rand64 value */ +static Rand64 packI (lu_int32 h, lu_int32 l) { + Rand64 result; + result.h = h; + result.l = l; + return result; +} + +/* return i << n */ +static Rand64 Ishl (Rand64 i, int n) { + lua_assert(n > 0 && n < 32); + return packI((i.h << n) | (trim32(i.l) >> (32 - n)), i.l << n); +} + +/* i1 ^= i2 */ +static void Ixor (Rand64 *i1, Rand64 i2) { + i1->h ^= i2.h; + i1->l ^= i2.l; +} + +/* return i1 + i2 */ +static Rand64 Iadd (Rand64 i1, Rand64 i2) { + Rand64 result = packI(i1.h + i2.h, i1.l + i2.l); + if (trim32(result.l) < trim32(i1.l)) /* carry? */ + result.h++; + return result; +} + +/* return i * 5 */ +static Rand64 times5 (Rand64 i) { + return Iadd(Ishl(i, 2), i); /* i * 5 == (i << 2) + i */ +} + +/* return i * 9 */ +static Rand64 times9 (Rand64 i) { + return Iadd(Ishl(i, 3), i); /* i * 9 == (i << 3) + i */ +} + +/* return 'i' rotated left 'n' bits */ +static Rand64 rotl (Rand64 i, int n) { + lua_assert(n > 0 && n < 32); + return packI((i.h << n) | (trim32(i.l) >> (32 - n)), + (trim32(i.h) >> (32 - n)) | (i.l << n)); +} + +/* for offsets larger than 32, rotate right by 64 - offset */ +static Rand64 rotl1 (Rand64 i, int n) { + lua_assert(n > 32 && n < 64); + n = 64 - n; + return packI((trim32(i.h) >> n) | (i.l << (32 - n)), + (i.h << (32 - n)) | (trim32(i.l) >> n)); +} + +/* +** implementation of 'xoshiro256**' algorithm on 'Rand64' values +*/ +static Rand64 nextrand (Rand64 *state) { + Rand64 res = times9(rotl(times5(state[1]), 7)); + Rand64 t = Ishl(state[1], 17); + Ixor(&state[2], state[0]); + Ixor(&state[3], state[1]); + Ixor(&state[1], state[2]); + Ixor(&state[0], state[3]); + Ixor(&state[2], t); + state[3] = rotl1(state[3], 45); + return res; +} + + +/* +** Converts a 'Rand64' into a float. +*/ + +/* an unsigned 1 with proper type */ +#define UONE ((lu_int32)1) + + +#if FIGS <= 32 + +/* 2^(-FIGS) */ +#define scaleFIG (l_mathop(0.5) / (UONE << (FIGS - 1))) + +/* +** get up to 32 bits from higher half, shifting right to +** throw out the extra bits. +*/ +static lua_Number I2d (Rand64 x) { + lua_Number h = (lua_Number)(trim32(x.h) >> (32 - FIGS)); + return h * scaleFIG; +} + +#else /* 32 < FIGS <= 64 */ + +/* 2^(-FIGS) = 1.0 / 2^30 / 2^3 / 2^(FIGS-33) */ +#define scaleFIG \ + (l_mathop(1.0) / (UONE << 30) / l_mathop(8.0) / (UONE << (FIGS - 33))) + +/* +** use FIGS - 32 bits from lower half, throwing out the other +** (32 - (FIGS - 32)) = (64 - FIGS) bits +*/ +#define shiftLOW (64 - FIGS) + +/* +** higher 32 bits go after those (FIGS - 32) bits: shiftHI = 2^(FIGS - 32) +*/ +#define shiftHI ((lua_Number)(UONE << (FIGS - 33)) * l_mathop(2.0)) + + +static lua_Number I2d (Rand64 x) { + lua_Number h = (lua_Number)trim32(x.h) * shiftHI; + lua_Number l = (lua_Number)(trim32(x.l) >> shiftLOW); + return (h + l) * scaleFIG; +} + +#endif + + +/* convert a 'Rand64' to a 'lua_Unsigned' */ +static lua_Unsigned I2UInt (Rand64 x) { + return (((lua_Unsigned)trim32(x.h) << 31) << 1) | (lua_Unsigned)trim32(x.l); +} + +/* convert a 'lua_Unsigned' to a 'Rand64' */ +static Rand64 Int2I (lua_Unsigned n) { + return packI((lu_int32)((n >> 31) >> 1), (lu_int32)n); +} + +#endif /* } */ + + +/* +** A state uses four 'Rand64' values. +*/ +typedef struct { + Rand64 s[4]; +} RanState; + + +/* +** Project the random integer 'ran' into the interval [0, n]. +** Because 'ran' has 2^B possible values, the projection can only be +** uniform when the size of the interval is a power of 2 (exact +** division). Otherwise, to get a uniform projection into [0, n], we +** first compute 'lim', the smallest Mersenne number not smaller than +** 'n'. We then project 'ran' into the interval [0, lim]. If the result +** is inside [0, n], we are done. Otherwise, we try with another 'ran', +** until we have a result inside the interval. +*/ +static lua_Unsigned project (lua_Unsigned ran, lua_Unsigned n, + RanState *state) { + if ((n & (n + 1)) == 0) /* is 'n + 1' a power of 2? */ + return ran & n; /* no bias */ + else { + lua_Unsigned lim = n; + /* compute the smallest (2^b - 1) not smaller than 'n' */ + lim |= (lim >> 1); + lim |= (lim >> 2); + lim |= (lim >> 4); + lim |= (lim >> 8); + lim |= (lim >> 16); +#if (LUA_MAXUNSIGNED >> 31) >= 3 + lim |= (lim >> 32); /* integer type has more than 32 bits */ +#endif + lua_assert((lim & (lim + 1)) == 0 /* 'lim + 1' is a power of 2, */ + && lim >= n /* not smaller than 'n', */ + && (lim >> 1) < n); /* and it is the smallest one */ + while ((ran &= lim) > n) /* project 'ran' into [0..lim] */ + ran = I2UInt(nextrand(state->s)); /* not inside [0..n]? try again */ + return ran; + } +} + + static int math_random (lua_State *L) { lua_Integer low, up; - double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0)); + lua_Unsigned p; + RanState *state = (RanState *)lua_touserdata(L, lua_upvalueindex(1)); + Rand64 rv = nextrand(state->s); /* next pseudo-random value */ switch (lua_gettop(L)) { /* check number of arguments */ case 0: { /* no arguments */ - lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */ + lua_pushnumber(L, I2d(rv)); /* float between 0 and 1 */ return 1; } case 1: { /* only upper limit */ low = 1; up = luaL_checkinteger(L, 1); + if (up == 0) { /* single 0 as argument? */ + lua_pushinteger(L, I2UInt(rv)); /* full random integer */ + return 1; + } break; } case 2: { /* lower and upper limits */ @@ -266,36 +599,73 @@ static int math_random (lua_State *L) { } /* random integer in the interval [low, up] */ luaL_argcheck(L, low <= up, 1, "interval is empty"); - luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, - "interval too large"); - r *= (double)(up - low) + 1.0; - lua_pushinteger(L, (lua_Integer)r + low); + /* project random integer into the interval [0, up - low] */ + p = project(I2UInt(rv), (lua_Unsigned)up - (lua_Unsigned)low, state); + lua_pushinteger(L, p + (lua_Unsigned)low); return 1; } -static int math_randomseed (lua_State *L) { - l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1)); - (void)l_rand(); /* discard first value to avoid undesirable correlations */ - return 0; +static void setseed (lua_State *L, Rand64 *state, + lua_Unsigned n1, lua_Unsigned n2) { + int i; + state[0] = Int2I(n1); + state[1] = Int2I(0xff); /* avoid a zero state */ + state[2] = Int2I(n2); + state[3] = Int2I(0); + for (i = 0; i < 16; i++) + nextrand(state); /* discard initial values to "spread" seed */ + lua_pushinteger(L, n1); + lua_pushinteger(L, n2); } -static int math_type (lua_State *L) { - if (lua_type(L, 1) == LUA_TNUMBER) { - if (lua_isinteger(L, 1)) - lua_pushliteral(L, "integer"); - else - lua_pushliteral(L, "float"); +/* +** Set a "random" seed. To get some randomness, use the current time +** and the address of 'L' (in case the machine does address space layout +** randomization). +*/ +static void randseed (lua_State *L, RanState *state) { + lua_Unsigned seed1 = (lua_Unsigned)time(NULL); + lua_Unsigned seed2 = (lua_Unsigned)(size_t)L; + setseed(L, state->s, seed1, seed2); +} + + +static int math_randomseed (lua_State *L) { + RanState *state = (RanState *)lua_touserdata(L, lua_upvalueindex(1)); + if (lua_isnone(L, 1)) { + randseed(L, state); } else { - luaL_checkany(L, 1); - lua_pushnil(L); + lua_Integer n1 = luaL_checkinteger(L, 1); + lua_Integer n2 = luaL_optinteger(L, 2, 0); + setseed(L, state->s, n1, n2); } - return 1; + return 2; /* return seeds */ } +static const luaL_Reg randfuncs[] = { + {"random", math_random}, + {"randomseed", math_randomseed}, + {NULL, NULL} +}; + + +/* +** Register the random functions and initialize their state. +*/ +static void setrandfunc (lua_State *L) { + RanState *state = (RanState *)lua_newuserdatauv(L, sizeof(RanState), 0); + randseed(L, state); /* initialize with a "random" seed */ + lua_pop(L, 2); /* remove pushed seeds */ + luaL_setfuncs(L, randfuncs, 1); +} + +/* }================================================================== */ + + /* ** {================================================================== ** Deprecated functions (for compatibility only) @@ -367,8 +737,6 @@ static const luaL_Reg mathlib[] = { {"min", math_min}, {"modf", math_modf}, {"rad", math_rad}, - {"random", math_random}, - {"randomseed", math_randomseed}, {"sin", math_sin}, {"sqrt", math_sqrt}, {"tan", math_tan}, @@ -384,6 +752,8 @@ static const luaL_Reg mathlib[] = { {"log10", math_log10}, #endif /* placeholders */ + {"random", NULL}, + {"randomseed", NULL}, {"pi", NULL}, {"huge", NULL}, {"maxinteger", NULL}, @@ -405,6 +775,7 @@ LUAMOD_API int luaopen_math (lua_State *L) { lua_setfield(L, -2, "maxinteger"); lua_pushinteger(L, LUA_MININTEGER); lua_setfield(L, -2, "mininteger"); + setrandfunc(L); return 1; } diff --git a/liblua/lmem.c b/liblua/lmem.c index 0241cc3b..9800a86f 100644 --- a/liblua/lmem.c +++ b/liblua/lmem.c @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.91.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lmem.c $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -25,76 +25,191 @@ /* ** About the realloc function: -** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** void *frealloc (void *ud, void *ptr, size_t osize, size_t nsize); ** ('osize' is the old size, 'nsize' is the new size) ** -** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no -** matter 'x'). +** - frealloc(ud, p, x, 0) frees the block 'p' and returns NULL. +** Particularly, frealloc(ud, NULL, 0, 0) does nothing, +** which is equivalent to free(NULL) in ISO C. ** -** * frealloc(ud, p, x, 0) frees the block 'p' -** (in this specific case, frealloc must return NULL); -** particularly, frealloc(ud, NULL, 0, 0) does nothing -** (which is equivalent to free(NULL) in ISO C) +** - frealloc(ud, NULL, x, s) creates a new block of size 's' +** (no matter 'x'). Returns NULL if it cannot create the new block. ** -** frealloc returns NULL if it cannot create or reallocate the area -** (any reallocation to an equal or smaller size cannot fail!) +** - otherwise, frealloc(ud, b, x, y) reallocates the block 'b' from +** size 'x' to size 'y'. Returns NULL if it cannot reallocate the +** block to the new size. */ +/* +** Macro to call the allocation function. +*/ +#define callfrealloc(g,block,os,ns) ((*g->frealloc)(g->ud, block, os, ns)) + + +/* +** When an allocation fails, it will try again after an emergency +** collection, except when it cannot run a collection. The GC should +** not be called while the state is not fully built, as the collector +** is not yet fully initialized. Also, it should not be called when +** 'gcstopem' is true, because then the interpreter is in the middle of +** a collection step. +*/ +#define cantryagain(g) (completestate(g) && !g->gcstopem) + + + + +#if defined(EMERGENCYGCTESTS) +/* +** First allocation will fail except when freeing a block (frees never +** fail) and when it cannot try again; this fail will trigger 'tryagain' +** and a full GC cycle at every allocation. +*/ +static void *firsttry (global_State *g, void *block, size_t os, size_t ns) { + if (ns > 0 && cantryagain(g)) + return NULL; /* fail */ + else /* normal allocation */ + return callfrealloc(g, block, os, ns); +} +#else +#define firsttry(g,block,os,ns) callfrealloc(g, block, os, ns) +#endif + + + + +/* +** {================================================================== +** Functions to allocate/deallocate arrays for the Parser +** =================================================================== +*/ + +/* +** Minimum size for arrays during parsing, to avoid overhead of +** reallocating to size 1, then 2, and then 4. All these arrays +** will be reallocated to exact sizes or erased when parsing ends. +*/ #define MINSIZEARRAY 4 -void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, - int limit, const char *what) { +void *luaM_growaux_ (lua_State *L, void *block, int nelems, int *psize, + int size_elems, int limit, const char *what) { void *newblock; - int newsize; - if (*size >= limit/2) { /* cannot double it? */ - if (*size >= limit) /* cannot grow even a little? */ + int size = *psize; + if (nelems + 1 <= size) /* does one extra element still fit? */ + return block; /* nothing to be done */ + if (size >= limit / 2) { /* cannot double it? */ + if (l_unlikely(size >= limit)) /* cannot grow even a little? */ luaG_runerror(L, "too many %s (limit is %d)", what, limit); - newsize = limit; /* still have at least one free place */ + size = limit; /* still have at least one free place */ } else { - newsize = (*size)*2; - if (newsize < MINSIZEARRAY) - newsize = MINSIZEARRAY; /* minimum size */ + size *= 2; + if (size < MINSIZEARRAY) + size = MINSIZEARRAY; /* minimum size */ } - newblock = luaM_reallocv(L, block, *size, newsize, size_elems); - *size = newsize; /* update only when everything else is OK */ + lua_assert(nelems + 1 <= size && size <= limit); + /* 'limit' ensures that multiplication will not overflow */ + newblock = luaM_saferealloc_(L, block, cast_sizet(*psize) * size_elems, + cast_sizet(size) * size_elems); + *psize = size; /* update only when everything else is OK */ + return newblock; +} + + +/* +** In prototypes, the size of the array is also its number of +** elements (to save memory). So, if it cannot shrink an array +** to its number of elements, the only option is to raise an +** error. +*/ +void *luaM_shrinkvector_ (lua_State *L, void *block, int *size, + int final_n, int size_elem) { + void *newblock; + size_t oldsize = cast_sizet((*size) * size_elem); + size_t newsize = cast_sizet(final_n * size_elem); + lua_assert(newsize <= oldsize); + newblock = luaM_saferealloc_(L, block, oldsize, newsize); + *size = final_n; return newblock; } +/* }================================================================== */ + l_noret luaM_toobig (lua_State *L) { luaG_runerror(L, "memory allocation error: block too big"); } +/* +** Free memory +*/ +void luaM_free_ (lua_State *L, void *block, size_t osize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + callfrealloc(g, block, osize, 0); + g->GCdebt -= osize; +} + /* -** generic allocation routine. +** In case of allocation fail, this function will do an emergency +** collection to free some memory and then try the allocation again. +*/ +static void *tryagain (lua_State *L, void *block, + size_t osize, size_t nsize) { + global_State *g = G(L); + if (cantryagain(g)) { + luaC_fullgc(L, 1); /* try to free some memory... */ + return callfrealloc(g, block, osize, nsize); /* try again */ + } + else return NULL; /* cannot run an emergency collection */ +} + + +/* +** Generic allocation routine. */ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { void *newblock; global_State *g = G(L); - size_t realosize = (block) ? osize : 0; - lua_assert((realosize == 0) == (block == NULL)); -#if defined(HARDMEMTESTS) - if (nsize > realosize && g->gcrunning) - luaC_fullgc(L, 1); /* force a GC whenever possible */ -#endif - newblock = (*g->frealloc)(g->ud, block, osize, nsize); - if (newblock == NULL && nsize > 0) { - lua_assert(nsize > realosize); /* cannot fail when shrinking a block */ - if (g->version) { /* is state fully built? */ - luaC_fullgc(L, 1); /* try to free some memory... */ - newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ - } - if (newblock == NULL) - luaD_throw(L, LUA_ERRMEM); + lua_assert((osize == 0) == (block == NULL)); + newblock = firsttry(g, block, osize, nsize); + if (l_unlikely(newblock == NULL && nsize > 0)) { + newblock = tryagain(L, block, osize, nsize); + if (newblock == NULL) /* still no memory? */ + return NULL; /* do not update 'GCdebt' */ } lua_assert((nsize == 0) == (newblock == NULL)); - g->GCdebt = (g->GCdebt + nsize) - realosize; + g->GCdebt = (g->GCdebt + nsize) - osize; return newblock; } + +void *luaM_saferealloc_ (lua_State *L, void *block, size_t osize, + size_t nsize) { + void *newblock = luaM_realloc_(L, block, osize, nsize); + if (l_unlikely(newblock == NULL && nsize > 0)) /* allocation failed? */ + luaM_error(L); + return newblock; +} + + +void *luaM_malloc_ (lua_State *L, size_t size, int tag) { + if (size == 0) + return NULL; /* that's all */ + else { + global_State *g = G(L); + void *newblock = firsttry(g, NULL, tag, size); + if (l_unlikely(newblock == NULL)) { + newblock = tryagain(L, NULL, tag, size); + if (newblock == NULL) + luaM_error(L); + } + g->GCdebt += size; + return newblock; + } +} diff --git a/liblua/lmem.h b/liblua/lmem.h index 357b1e43..8c75a44b 100644 --- a/liblua/lmem.h +++ b/liblua/lmem.h @@ -1,5 +1,5 @@ /* -** $Id: lmem.h,v 1.43.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lmem.h $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -14,12 +14,13 @@ #include "lua.h" +#define luaM_error(L) luaD_throw(L, LUA_ERRMEM) + + /* -** This macro reallocs a vector 'b' from 'on' to 'n' elements, where -** each element has size 'e'. In case of arithmetic overflow of the -** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because -** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). -** +** This macro tests whether it is safe to multiply 'n' by the size of +** type 't' without overflows. Because 'e' is always constant, it avoids +** the runtime division MAX_SIZET/(e). ** (The macro is somewhat complex to avoid warnings: The 'sizeof' ** comparison avoids a runtime comparison when overflow cannot occur. ** The compiler should be able to optimize the real test by itself, but @@ -27,43 +28,66 @@ ** false due to limited range of data type"; the +1 tricks the compiler, ** avoiding this warning but also this optimization.) */ -#define luaM_reallocv(L,b,on,n,e) \ - (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ - ? luaM_toobig(L) : cast_void(0)) , \ - luaM_realloc_(L, (b), (on)*(e), (n)*(e))) +#define luaM_testsize(n,e) \ + (sizeof(n) >= sizeof(size_t) && cast_sizet((n)) + 1 > MAX_SIZET/(e)) + +#define luaM_checksize(L,n,e) \ + (luaM_testsize(n,e) ? luaM_toobig(L) : cast_void(0)) + + +/* +** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that +** the result is not larger than 'n' and cannot overflow a 'size_t' +** when multiplied by the size of type 't'. (Assumes that 'n' is an +** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) +*/ +#define luaM_limitN(n,t) \ + ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ + cast_uint((MAX_SIZET/sizeof(t)))) + /* ** Arrays of chars do not need any test */ #define luaM_reallocvchar(L,b,on,n) \ - cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) + cast_charp(luaM_saferealloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) -#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) -#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) -#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) +#define luaM_freemem(L, b, s) luaM_free_(L, (b), (s)) +#define luaM_free(L, b) luaM_free_(L, (b), sizeof(*(b))) +#define luaM_freearray(L, b, n) luaM_free_(L, (b), (n)*sizeof(*(b))) -#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) -#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) -#define luaM_newvector(L,n,t) \ - cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) +#define luaM_new(L,t) cast(t*, luaM_malloc_(L, sizeof(t), 0)) +#define luaM_newvector(L,n,t) cast(t*, luaM_malloc_(L, (n)*sizeof(t), 0)) +#define luaM_newvectorchecked(L,n,t) \ + (luaM_checksize(L,n,sizeof(t)), luaM_newvector(L,n,t)) -#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) +#define luaM_newobject(L,tag,s) luaM_malloc_(L, (s), tag) #define luaM_growvector(L,v,nelems,size,t,limit,e) \ - if ((nelems)+1 > (size)) \ - ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + ((v)=cast(t *, luaM_growaux_(L,v,nelems,&(size),sizeof(t), \ + luaM_limitN(limit,t),e))) #define luaM_reallocvector(L, v,oldn,n,t) \ - ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + (cast(t *, luaM_realloc_(L, v, cast_sizet(oldn) * sizeof(t), \ + cast_sizet(n) * sizeof(t)))) + +#define luaM_shrinkvector(L,v,size,fs,t) \ + ((v)=cast(t *, luaM_shrinkvector_(L, v, &(size), fs, sizeof(t)))) LUAI_FUNC l_noret luaM_toobig (lua_State *L); /* not to be called directly */ LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, size_t size); -LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, - size_t size_elem, int limit, +LUAI_FUNC void *luaM_saferealloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void luaM_free_ (lua_State *L, void *block, size_t osize); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int nelems, + int *size, int size_elem, int limit, const char *what); +LUAI_FUNC void *luaM_shrinkvector_ (lua_State *L, void *block, int *nelem, + int final_n, int size_elem); +LUAI_FUNC void *luaM_malloc_ (lua_State *L, size_t size, int tag); #endif diff --git a/liblua/loadlib.c b/liblua/loadlib.c index 4a6692d6..3b5c9df8 100644 --- a/liblua/loadlib.c +++ b/liblua/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.130.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: loadlib.c $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -24,15 +24,6 @@ #include "lualib.h" -/* -** LUA_IGMARK is a mark to ignore all before it when building the -** luaopen_ function name. -*/ -#if !defined (LUA_IGMARK) -#define LUA_IGMARK "-" -#endif - - /* ** LUA_CSUBSEP is the character that replaces dots in submodule names ** when searching for a C loader. @@ -56,10 +47,10 @@ /* -** unique key for table in the registry that keeps handles +** key for table in the registry that keeps handles ** for all loaded C libraries */ -static const int CLIBS = 0; +static const char *const CLIBS = "_CLIBS"; #define LIB_FAIL "open" @@ -67,6 +58,13 @@ static const int CLIBS = 0; #define setprogdir(L) ((void)0) +/* +** Special type equivalent to '(void*)' for functions in gcc +** (to suppress warnings when converting function pointers) +*/ +typedef void (*voidf)(void); + + /* ** system-dependent functions */ @@ -125,14 +123,16 @@ static void lsys_unloadlib (void *lib) { static void *lsys_load (lua_State *L, const char *path, int seeglb) { void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL)); - if (lib == NULL) lua_pushstring(L, dlerror()); + if (l_unlikely(lib == NULL)) + lua_pushstring(L, dlerror()); return lib; } static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { lua_CFunction f = cast_func(dlsym(lib, sym)); - if (f == NULL) lua_pushstring(L, dlerror()); + if (l_unlikely(f == NULL)) + lua_pushstring(L, dlerror()); return f; } @@ -206,7 +206,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) { static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym); + lua_CFunction f = (lua_CFunction)(voidf)GetProcAddress((HMODULE)lib, sym); if (f == NULL) pusherror(L); return f; } @@ -269,8 +269,6 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { #endif -#define AUXMARK "\1" /* auxiliary mark */ - /* ** return registry.LUA_NOENV as a boolean @@ -290,28 +288,36 @@ static int noenv (lua_State *L) { static void setpath (lua_State *L, const char *fieldname, const char *envname, const char *dft) { + const char *dftmark; const char *nver = lua_pushfstring(L, "%s%s", envname, LUA_VERSUFFIX); - const char *path = getenv(nver); /* use versioned name */ - if (path == NULL) /* no environment variable? */ + const char *path = getenv(nver); /* try versioned name */ + if (path == NULL) /* no versioned environment variable? */ path = getenv(envname); /* try unversioned name */ if (path == NULL || noenv(L)) /* no environment variable? */ lua_pushstring(L, dft); /* use default */ - else { -#ifdef U8W_H - const char *path_env = path; -#endif - /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ - path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP, - LUA_PATH_SEP AUXMARK LUA_PATH_SEP); - luaL_gsub(L, path, AUXMARK, dft); + else if ((dftmark = strstr(path, LUA_PATH_SEP LUA_PATH_SEP)) == NULL) + lua_pushstring(L, path); /* nothing to change */ + else { /* path contains a ";;": insert default path in its place */ + size_t len = strlen(path); + luaL_Buffer b; + luaL_buffinit(L, &b); + if (path < dftmark) { /* is there a prefix before ';;'? */ + luaL_addlstring(&b, path, dftmark - path); /* add it */ + luaL_addchar(&b, *LUA_PATH_SEP); + } + luaL_addstring(&b, dft); /* add default */ + if (dftmark < path + len - 2) { /* is there a suffix after ';;'? */ + luaL_addchar(&b, *LUA_PATH_SEP); + luaL_addlstring(&b, dftmark + 2, (path + len - 2) - dftmark); + } + luaL_pushresult(&b); + } #ifdef U8W_H - free((void *)path_env); + free((void *)path); #endif - lua_remove(L, -2); /* remove result from 1st 'gsub' */ - } setprogdir(L); lua_setfield(L, -3, fieldname); /* package[fieldname] = path value */ - lua_pop(L, 1); /* pop versioned variable name */ + lua_pop(L, 1); /* pop versioned variable name ('nver') */ } /* }================================================================== */ @@ -322,7 +328,7 @@ static void setpath (lua_State *L, const char *fieldname, */ static void *checkclib (lua_State *L, const char *path) { void *plib; - lua_rawgetp(L, LUA_REGISTRYINDEX, &CLIBS); + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); lua_getfield(L, -1, path); plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ lua_pop(L, 2); /* pop CLIBS table and 'plib' */ @@ -335,7 +341,7 @@ static void *checkclib (lua_State *L, const char *path) { ** registry.CLIBS[#CLIBS + 1] = plib -- also keep a list of all libraries */ static void addtoclib (lua_State *L, const char *path, void *plib) { - lua_rawgetp(L, LUA_REGISTRYINDEX, &CLIBS); + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); lua_pushlightuserdata(L, plib); lua_pushvalue(L, -1); lua_setfield(L, -3, path); /* CLIBS[path] = plib */ @@ -400,13 +406,13 @@ static int ll_loadlib (lua_State *L) { const char *path = luaL_checkstring(L, 1); const char *init = luaL_checkstring(L, 2); int stat = lookforfunc(L, path, init); - if (stat == 0) /* no errors? */ + if (l_likely(stat == 0)) /* no errors? */ return 1; /* return the loaded function */ else { /* error; error message is on stack top */ - lua_pushnil(L); + luaL_pushfail(L); lua_insert(L, -2); lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); - return 3; /* return nil, error message, and where */ + return 3; /* return fail, error message, and where */ } } @@ -427,14 +433,42 @@ static int readable (const char *filename) { } -static const char *pushnexttemplate (lua_State *L, const char *path) { - const char *l; - while (*path == *LUA_PATH_SEP) path++; /* skip separators */ - if (*path == '\0') return NULL; /* no more templates */ - l = strchr(path, *LUA_PATH_SEP); /* find next separator */ - if (l == NULL) l = path + strlen(path); - lua_pushlstring(L, path, l - path); /* template */ - return l; +/* +** Get the next name in '*path' = 'name1;name2;name3;...', changing +** the ending ';' to '\0' to create a zero-terminated string. Return +** NULL when list ends. +*/ +static const char *getnextfilename (char **path, char *end) { + char *sep; + char *name = *path; + if (name == end) + return NULL; /* no more names */ + else if (*name == '\0') { /* from previous iteration? */ + *name = *LUA_PATH_SEP; /* restore separator */ + name++; /* skip it */ + } + sep = strchr(name, *LUA_PATH_SEP); /* find next separator */ + if (sep == NULL) /* separator not found? */ + sep = end; /* name goes until the end */ + *sep = '\0'; /* finish file name */ + *path = sep; /* will start next search from here */ + return name; +} + + +/* +** Given a path such as ";blabla.so;blublu.so", pushes the string +** +** no file 'blabla.so' +** no file 'blublu.so' +*/ +static void pusherrornotfound (lua_State *L, const char *path) { + luaL_Buffer b; + luaL_buffinit(L, &b); + luaL_addstring(&b, "no file '"); + luaL_addgsub(&b, path, LUA_PATH_SEP, "'\n\tno file '"); + luaL_addstring(&b, "'"); + luaL_pushresult(&b); } @@ -442,21 +476,25 @@ static const char *searchpath (lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep) { - luaL_Buffer msg; /* to build error message */ - luaL_buffinit(L, &msg); - if (*sep != '\0') /* non-empty separator? */ + luaL_Buffer buff; + char *pathname; /* path with name inserted */ + char *endpathname; /* its end */ + const char *filename; + /* separator is non-empty and appears in 'name'? */ + if (*sep != '\0' && strchr(name, *sep) != NULL) name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ - while ((path = pushnexttemplate(L, path)) != NULL) { - const char *filename = luaL_gsub(L, lua_tostring(L, -1), - LUA_PATH_MARK, name); - lua_remove(L, -2); /* remove path template */ + luaL_buffinit(L, &buff); + /* add path to the buffer, replacing marks ('?') with the file name */ + luaL_addgsub(&buff, path, LUA_PATH_MARK, name); + luaL_addchar(&buff, '\0'); + pathname = luaL_buffaddr(&buff); /* writable list of file names */ + endpathname = pathname + luaL_bufflen(&buff) - 1; + while ((filename = getnextfilename(&pathname, endpathname)) != NULL) { if (readable(filename)) /* does file exist and is readable? */ - return filename; /* return that file name */ - lua_pushfstring(L, "\n\tno file '%s'", filename); - lua_remove(L, -2); /* remove file name */ - luaL_addvalue(&msg); /* concatenate error msg. entry */ + return lua_pushstring(L, filename); /* save and return name */ } - luaL_pushresult(&msg); /* create error message */ + luaL_pushresult(&buff); /* push path to create error message */ + pusherrornotfound(L, lua_tostring(L, -1)); /* create error message */ return NULL; /* not found */ } @@ -468,9 +506,9 @@ static int ll_searchpath (lua_State *L) { luaL_optstring(L, 4, LUA_DIRSEP)); if (f != NULL) return 1; else { /* error message is on top of the stack */ - lua_pushnil(L); + luaL_pushfail(L); lua_insert(L, -2); - return 2; /* return nil + error message */ + return 2; /* return fail + error message */ } } @@ -481,14 +519,14 @@ static const char *findfile (lua_State *L, const char *name, const char *path; lua_getfield(L, lua_upvalueindex(1), pname); path = lua_tostring(L, -1); - if (path == NULL) + if (l_unlikely(path == NULL)) luaL_error(L, "'package.%s' must be a string", pname); return searchpath(L, name, path, ".", dirsep); } static int checkload (lua_State *L, int stat, const char *filename) { - if (stat) { /* module loaded successfully? */ + if (l_likely(stat)) { /* module loaded successfully? */ lua_pushstring(L, filename); /* will be 2nd argument to module */ return 2; /* return open function and file name */ } @@ -554,7 +592,7 @@ static int searcher_Croot (lua_State *L) { if (stat != ERRFUNC) return checkload(L, 0, filename); /* real error */ else { /* open function not found */ - lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename); + lua_pushfstring(L, "no module '%s' in file '%s'", name, filename); return 1; } } @@ -566,23 +604,31 @@ static int searcher_Croot (lua_State *L) { static int searcher_preload (lua_State *L) { const char *name = luaL_checkstring(L, 1); lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); - if (lua_getfield(L, -1, name) == LUA_TNIL) /* not found? */ - lua_pushfstring(L, "\n\tno field package.preload['%s']", name); - return 1; + if (lua_getfield(L, -1, name) == LUA_TNIL) { /* not found? */ + lua_pushfstring(L, "no field package.preload['%s']", name); + return 1; + } + else { + lua_pushliteral(L, ":preload:"); + return 2; + } } static void findloader (lua_State *L, const char *name) { int i; luaL_Buffer msg; /* to build error message */ - luaL_buffinit(L, &msg); /* push 'package.searchers' to index 3 in the stack */ - if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE) + if (l_unlikely(lua_getfield(L, lua_upvalueindex(1), "searchers") + != LUA_TTABLE)) luaL_error(L, "'package.searchers' must be a table"); + luaL_buffinit(L, &msg); /* iterate over available searchers to find a loader */ for (i = 1; ; i++) { - if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ + luaL_addstring(&msg, "\n\t"); /* error-message prefix */ + if (l_unlikely(lua_rawgeti(L, 3, i) == LUA_TNIL)) { /* no more searchers? */ lua_pop(L, 1); /* remove nil */ + luaL_buffsub(&msg, 2); /* remove prefix */ luaL_pushresult(&msg); /* create error message */ luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1)); } @@ -594,8 +640,10 @@ static void findloader (lua_State *L, const char *name) { lua_pop(L, 1); /* remove extra return */ luaL_addvalue(&msg); /* concatenate error message */ } - else + else { /* no error message */ lua_pop(L, 2); /* remove both returns */ + luaL_buffsub(&msg, 2); /* remove prefix */ + } } } @@ -610,113 +658,33 @@ static int ll_require (lua_State *L) { /* else must load package */ lua_pop(L, 1); /* remove 'getfield' result */ findloader(L, name); - lua_pushstring(L, name); /* pass name as argument to module loader */ - lua_insert(L, -2); /* name is 1st argument (before search data) */ + lua_rotate(L, -2, 1); /* function <-> loader data */ + lua_pushvalue(L, 1); /* name is 1st argument to module loader */ + lua_pushvalue(L, -3); /* loader data is 2nd argument */ + /* stack: ...; loader data; loader function; mod. name; loader data */ lua_call(L, 2, 1); /* run loader to load module */ + /* stack: ...; loader data; result from loader */ if (!lua_isnil(L, -1)) /* non-nil return? */ lua_setfield(L, 2, name); /* LOADED[name] = returned value */ + else + lua_pop(L, 1); /* pop nil */ if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */ lua_pushboolean(L, 1); /* use true as result */ - lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_copy(L, -1, -2); /* replace loader result */ lua_setfield(L, 2, name); /* LOADED[name] = true */ } - return 1; + lua_rotate(L, -2, 1); /* loader data <-> module result */ + return 2; /* return module result and loader data */ } /* }====================================================== */ -/* -** {====================================================== -** 'module' function -** ======================================================= -*/ -#if defined(LUA_COMPAT_MODULE) - -/* -** changes the environment variable of calling function -*/ -static void set_env (lua_State *L) { - lua_Debug ar; - if (lua_getstack(L, 1, &ar) == 0 || - lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ - lua_iscfunction(L, -1)) - luaL_error(L, "'module' not called from a Lua function"); - lua_pushvalue(L, -2); /* copy new environment table to top */ - lua_setupvalue(L, -2, 1); - lua_pop(L, 1); /* remove function */ -} - - -static void dooptions (lua_State *L, int n) { - int i; - for (i = 2; i <= n; i++) { - if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */ - lua_pushvalue(L, i); /* get option (a function) */ - lua_pushvalue(L, -2); /* module */ - lua_call(L, 1, 0); - } - } -} - - -static void modinit (lua_State *L, const char *modname) { - const char *dot; - lua_pushvalue(L, -1); - lua_setfield(L, -2, "_M"); /* module._M = module */ - lua_pushstring(L, modname); - lua_setfield(L, -2, "_NAME"); - dot = strrchr(modname, '.'); /* look for last dot in module name */ - if (dot == NULL) dot = modname; - else dot++; - /* set _PACKAGE as package name (full module name minus last part) */ - lua_pushlstring(L, modname, dot - modname); - lua_setfield(L, -2, "_PACKAGE"); -} - - -static int ll_module (lua_State *L) { - const char *modname = luaL_checkstring(L, 1); - int lastarg = lua_gettop(L); /* last parameter */ - luaL_pushmodule(L, modname, 1); /* get/create module table */ - /* check whether table already has a _NAME field */ - if (lua_getfield(L, -1, "_NAME") != LUA_TNIL) - lua_pop(L, 1); /* table is an initialized module */ - else { /* no; initialize it */ - lua_pop(L, 1); - modinit(L, modname); - } - lua_pushvalue(L, -1); - set_env(L); - dooptions(L, lastarg); - return 1; -} - - -static int ll_seeall (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - if (!lua_getmetatable(L, 1)) { - lua_createtable(L, 0, 1); /* create new metatable */ - lua_pushvalue(L, -1); - lua_setmetatable(L, 1); - } - lua_pushglobaltable(L); - lua_setfield(L, -2, "__index"); /* mt.__index = _G */ - return 0; -} - -#endif -/* }====================================================== */ - - static const luaL_Reg pk_funcs[] = { {"loadlib", ll_loadlib}, {"searchpath", ll_searchpath}, -#if defined(LUA_COMPAT_MODULE) - {"seeall", ll_seeall}, -#endif /* placeholders */ {"preload", NULL}, {"cpath", NULL}, @@ -728,17 +696,19 @@ static const luaL_Reg pk_funcs[] = { static const luaL_Reg ll_funcs[] = { -#if defined(LUA_COMPAT_MODULE) - {"module", ll_module}, -#endif {"require", ll_require}, {NULL, NULL} }; static void createsearcherstable (lua_State *L) { - static const lua_CFunction searchers[] = - {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; + static const lua_CFunction searchers[] = { + searcher_preload, + searcher_Lua, + searcher_C, + searcher_Croot, + NULL + }; int i; /* create 'searchers' table */ lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); @@ -748,10 +718,6 @@ static void createsearcherstable (lua_State *L) { lua_pushcclosure(L, searchers[i], 1); lua_rawseti(L, -2, i+1); } -#if defined(LUA_COMPAT_LOADERS) - lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ - lua_setfield(L, -3, "loaders"); /* put it in field 'loaders' */ -#endif lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ } @@ -761,12 +727,11 @@ static void createsearcherstable (lua_State *L) { ** setting a finalizer to close all libraries when closing state. */ static void createclibstable (lua_State *L) { - lua_newtable(L); /* create CLIBS table */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); /* create CLIBS table */ lua_createtable(L, 0, 1); /* create metatable for CLIBS */ lua_pushcfunction(L, gctm); lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ lua_setmetatable(L, -2); - lua_rawsetp(L, LUA_REGISTRYINDEX, &CLIBS); /* set CLIBS table in registry */ } diff --git a/liblua/lobject.c b/liblua/lobject.c index 2218c8cd..9cfa5227 100644 --- a/liblua/lobject.c +++ b/liblua/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.113.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: lobject.c $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -29,36 +29,6 @@ #include "lvm.h" - -LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; - - -/* -** converts an integer to a "floating point byte", represented as -** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if -** eeeee != 0 and (xxx) otherwise. -*/ -int luaO_int2fb (unsigned int x) { - int e = 0; /* exponent */ - if (x < 8) return x; - while (x >= (8 << 4)) { /* coarse steps */ - x = (x + 0xf) >> 4; /* x = ceil(x / 16) */ - e += 4; - } - while (x >= (8 << 1)) { /* fine steps */ - x = (x + 1) >> 1; /* x = ceil(x / 2) */ - e++; - } - return ((e+1) << 3) | (cast_int(x) - 8); -} - - -/* converts back */ -int luaO_fb2int (int x) { - return (x < 8) ? x : ((x & 7) + 8) << ((x >> 3) - 1); -} - - /* ** Computes ceil(log2(x)) */ @@ -87,12 +57,12 @@ static lua_Integer intarith (lua_State *L, int op, lua_Integer v1, case LUA_OPSUB:return intop(-, v1, v2); case LUA_OPMUL:return intop(*, v1, v2); case LUA_OPMOD: return luaV_mod(L, v1, v2); - case LUA_OPIDIV: return luaV_div(L, v1, v2); + case LUA_OPIDIV: return luaV_idiv(L, v1, v2); case LUA_OPBAND: return intop(&, v1, v2); case LUA_OPBOR: return intop(|, v1, v2); case LUA_OPBXOR: return intop(^, v1, v2); case LUA_OPSHL: return luaV_shiftl(v1, v2); - case LUA_OPSHR: return luaV_shiftl(v1, -v2); + case LUA_OPSHR: return luaV_shiftr(v1, v2); case LUA_OPUNM: return intop(-, 0, v1); case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1); default: lua_assert(0); return 0; @@ -110,53 +80,55 @@ static lua_Number numarith (lua_State *L, int op, lua_Number v1, case LUA_OPPOW: return luai_numpow(L, v1, v2); case LUA_OPIDIV: return luai_numidiv(L, v1, v2); case LUA_OPUNM: return luai_numunm(L, v1); - case LUA_OPMOD: { - lua_Number m; - luai_nummod(L, v1, v2, m); - return m; - } + case LUA_OPMOD: return luaV_modf(L, v1, v2); default: lua_assert(0); return 0; } } -void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, - TValue *res) { +int luaO_rawarith (lua_State *L, int op, const TValue *p1, const TValue *p2, + TValue *res) { switch (op) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* operate only on integers */ lua_Integer i1; lua_Integer i2; - if (tointeger(p1, &i1) && tointeger(p2, &i2)) { + if (tointegerns(p1, &i1) && tointegerns(p2, &i2)) { setivalue(res, intarith(L, op, i1, i2)); - return; + return 1; } - else break; /* go to the end */ + else return 0; /* fail */ } case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */ lua_Number n1; lua_Number n2; - if (tonumber(p1, &n1) && tonumber(p2, &n2)) { + if (tonumberns(p1, n1) && tonumberns(p2, n2)) { setfltvalue(res, numarith(L, op, n1, n2)); - return; + return 1; } - else break; /* go to the end */ + else return 0; /* fail */ } default: { /* other operations */ lua_Number n1; lua_Number n2; if (ttisinteger(p1) && ttisinteger(p2)) { setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); - return; + return 1; } - else if (tonumber(p1, &n1) && tonumber(p2, &n2)) { + else if (tonumberns(p1, n1) && tonumberns(p2, n2)) { setfltvalue(res, numarith(L, op, n1, n2)); - return; + return 1; } - else break; /* go to the end */ + else return 0; /* fail */ } } - /* could not perform raw operation; try metamethod */ - lua_assert(L != NULL); /* should not fail when folding (compile time) */ - luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD)); +} + + +void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, + StkId res) { + if (!luaO_rawarith(L, op, p1, p2, s2v(res))) { + /* could not perform raw operation; try metamethod */ + luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD)); + } } @@ -187,22 +159,22 @@ static int isneg (const char **s) { #define MAXSIGDIG 30 /* -** convert an hexadecimal numeric string to a number, following +** convert a hexadecimal numeric string to a number, following ** C99 specification for 'strtod' */ static lua_Number lua_strx2number (const char *s, char **endptr) { int dot = lua_getlocaledecpoint(); - lua_Number r = 0.0; /* result (accumulator) */ + lua_Number r = l_mathop(0.0); /* result (accumulator) */ int sigdig = 0; /* number of significant digits */ int nosigdig = 0; /* number of non-significant digits */ int e = 0; /* exponent correction */ int neg; /* 1 if number is negative */ int hasdot = 0; /* true after seen a dot */ - *endptr = cast(char *, s); /* nothing is valid yet */ + *endptr = cast_charp(s); /* nothing is valid yet */ while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ - neg = isneg(&s); /* check signal */ + neg = isneg(&s); /* check sign */ if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ - return 0.0; /* invalid format (no '0x') */ + return l_mathop(0.0); /* invalid format (no '0x') */ for (s += 2; ; s++) { /* skip '0x' and read numeral */ if (*s == dot) { if (hasdot) break; /* second dot? stop loop */ @@ -212,28 +184,28 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ nosigdig++; else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ - r = (r * cast_num(16.0)) + luaO_hexavalue(*s); + r = (r * l_mathop(16.0)) + luaO_hexavalue(*s); else e++; /* too many digits; ignore, but still count for exponent */ if (hasdot) e--; /* decimal digit? correct exponent */ } else break; /* neither a dot nor a digit */ } if (nosigdig + sigdig == 0) /* no digits? */ - return 0.0; /* invalid format */ - *endptr = cast(char *, s); /* valid up to here */ + return l_mathop(0.0); /* invalid format */ + *endptr = cast_charp(s); /* valid up to here */ e *= 4; /* each digit multiplies/divides value by 2^4 */ if (*s == 'p' || *s == 'P') { /* exponent part? */ int exp1 = 0; /* exponent value */ - int neg1; /* exponent signal */ + int neg1; /* exponent sign */ s++; /* skip 'p' */ - neg1 = isneg(&s); /* signal */ + neg1 = isneg(&s); /* sign */ if (!lisdigit(cast_uchar(*s))) - return 0.0; /* invalid; must have at least one digit */ + return l_mathop(0.0); /* invalid; must have at least one digit */ while (lisdigit(cast_uchar(*s))) /* read exponent */ exp1 = exp1 * 10 + *(s++) - '0'; if (neg1) exp1 = -exp1; e += exp1; - *endptr = cast(char *, s); /* valid up to here */ + *endptr = cast_charp(s); /* valid up to here */ } if (neg) r = -r; return l_mathop(ldexp)(r, e); @@ -243,37 +215,42 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { /* }====================================================== */ -/* maximum length of a numeral */ +/* maximum length of a numeral to be converted to a number */ #if !defined (L_MAXLENNUM) #define L_MAXLENNUM 200 #endif +/* +** Convert string 's' to a Lua number (put in 'result'). Return NULL on +** fail or the address of the ending '\0' on success. ('mode' == 'x') +** means a hexadecimal numeral. +*/ static const char *l_str2dloc (const char *s, lua_Number *result, int mode) { char *endptr; *result = (mode == 'x') ? lua_strx2number(s, &endptr) /* try to convert */ : lua_str2number(s, &endptr); if (endptr == s) return NULL; /* nothing recognized? */ while (lisspace(cast_uchar(*endptr))) endptr++; /* skip trailing spaces */ - return (*endptr == '\0') ? endptr : NULL; /* OK if no trailing characters */ + return (*endptr == '\0') ? endptr : NULL; /* OK iff no trailing chars */ } /* -** Convert string 's' to a Lua number (put in 'result'). Return NULL -** on fail or the address of the ending '\0' on success. -** 'pmode' points to (and 'mode' contains) special things in the string: -** - 'x'/'X' means an hexadecimal numeral -** - 'n'/'N' means 'inf' or 'nan' (which should be rejected) -** - '.' just optimizes the search for the common case (nothing special) +** Convert string 's' to a Lua number (put in 'result') handling the +** current locale. ** This function accepts both the current locale or a dot as the radix -** mark. If the convertion fails, it may mean number has a dot but +** mark. If the conversion fails, it may mean number has a dot but ** locale accepts something else. In that case, the code copies 's' ** to a buffer (because 's' is read-only), changes the dot to the ** current locale radix mark, and tries to convert again. +** The variable 'mode' checks for special characters in the string: +** - 'n' means 'inf' or 'nan' (which should be rejected) +** - 'x' means a hexadecimal numeral +** - '.' just optimizes the search for the common case (no special chars) */ static const char *l_str2d (const char *s, lua_Number *result) { const char *endptr; - const char *pmode = strpbrk(s, ".xXnN"); + const char *pmode = strpbrk(s, ".xXnN"); /* look for special chars */ int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0; if (mode == 'n') /* reject 'inf' and 'nan' */ return NULL; @@ -281,7 +258,7 @@ static const char *l_str2d (const char *s, lua_Number *result) { if (endptr == NULL) { /* failed? may be a different locale */ char buff[L_MAXLENNUM + 1]; const char *pdot = strchr(s, '.'); - if (strlen(s) > L_MAXLENNUM || pdot == NULL) + if (pdot == NULL || strlen(s) > L_MAXLENNUM) return NULL; /* string too long or no dot; fail */ strcpy(buff, s); /* copy string to buffer */ buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */ @@ -345,109 +322,214 @@ size_t luaO_str2num (const char *s, TValue *o) { int luaO_utf8esc (char *buff, unsigned long x) { int n = 1; /* number of bytes put in buffer (backwards) */ - lua_assert(x <= 0x10FFFF); + lua_assert(x <= 0x7FFFFFFFu); if (x < 0x80) /* ascii? */ - buff[UTF8BUFFSZ - 1] = cast(char, x); + buff[UTF8BUFFSZ - 1] = cast_char(x); else { /* need continuation bytes */ unsigned int mfb = 0x3f; /* maximum that fits in first byte */ do { /* add continuation bytes */ - buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x & 0x3f)); + buff[UTF8BUFFSZ - (n++)] = cast_char(0x80 | (x & 0x3f)); x >>= 6; /* remove added bits */ mfb >>= 1; /* now there is one less bit available in first byte */ } while (x > mfb); /* still needs continuation byte? */ - buff[UTF8BUFFSZ - n] = cast(char, (~mfb << 1) | x); /* add first byte */ + buff[UTF8BUFFSZ - n] = cast_char((~mfb << 1) | x); /* add first byte */ } return n; } -/* maximum length of the conversion of a number to a string */ -#define MAXNUMBER2STR 50 +/* +** Maximum length of the conversion of a number to a string. Must be +** enough to accommodate both LUA_INTEGER_FMT and LUA_NUMBER_FMT. +** (For a long long int, this is 19 digits plus a sign and a final '\0', +** adding to 21. For a long double, it can go to a sign, 33 digits, +** the dot, an exponent letter, an exponent sign, 5 exponent digits, +** and a final '\0', adding to 43.) +*/ +#define MAXNUMBER2STR 44 /* -** Convert a number object to a string +** Convert a number object to a string, adding it to a buffer */ -void luaO_tostring (lua_State *L, StkId obj) { - char buff[MAXNUMBER2STR]; - size_t len; +static int tostringbuff (TValue *obj, char *buff) { + int len; lua_assert(ttisnumber(obj)); if (ttisinteger(obj)) - len = lua_integer2str(buff, sizeof(buff), ivalue(obj)); + len = lua_integer2str(buff, MAXNUMBER2STR, ivalue(obj)); else { - len = lua_number2str(buff, sizeof(buff), fltvalue(obj)); -#if !defined(LUA_COMPAT_FLOATSTRING) + len = lua_number2str(buff, MAXNUMBER2STR, fltvalue(obj)); if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ buff[len++] = lua_getlocaledecpoint(); buff[len++] = '0'; /* adds '.0' to result */ } -#endif } - setsvalue2s(L, obj, luaS_newlstr(L, buff, len)); + return len; +} + + +/* +** Convert a number object to a Lua string, replacing the value at 'obj' +*/ +void luaO_tostring (lua_State *L, TValue *obj) { + char buff[MAXNUMBER2STR]; + int len = tostringbuff(obj, buff); + setsvalue(L, obj, luaS_newlstr(L, buff, len)); +} + + + + +/* +** {================================================================== +** 'luaO_pushvfstring' +** =================================================================== +*/ + +/* +** Size for buffer space used by 'luaO_pushvfstring'. It should be +** (LUA_IDSIZE + MAXNUMBER2STR) + a minimal space for basic messages, +** so that 'luaG_addinfo' can work directly on the buffer. +*/ +#define BUFVFS (LUA_IDSIZE + MAXNUMBER2STR + 95) + +/* buffer used by 'luaO_pushvfstring' */ +typedef struct BuffFS { + lua_State *L; + int pushed; /* true if there is a part of the result on the stack */ + int blen; /* length of partial string in 'space' */ + char space[BUFVFS]; /* holds last part of the result */ +} BuffFS; + + +/* +** Push given string to the stack, as part of the result, and +** join it to previous partial result if there is one. +** It may call 'luaV_concat' while using one slot from EXTRA_STACK. +** This call cannot invoke metamethods, as both operands must be +** strings. It can, however, raise an error if the result is too +** long. In that case, 'luaV_concat' frees the extra slot before +** raising the error. +*/ +static void pushstr (BuffFS *buff, const char *str, size_t lstr) { + lua_State *L = buff->L; + setsvalue2s(L, L->top.p, luaS_newlstr(L, str, lstr)); + L->top.p++; /* may use one slot from EXTRA_STACK */ + if (!buff->pushed) /* no previous string on the stack? */ + buff->pushed = 1; /* now there is one */ + else /* join previous string with new one */ + luaV_concat(L, 2); +} + + +/* +** empty the buffer space into the stack +*/ +static void clearbuff (BuffFS *buff) { + pushstr(buff, buff->space, buff->blen); /* push buffer contents */ + buff->blen = 0; /* space now is empty */ +} + + +/* +** Get a space of size 'sz' in the buffer. If buffer has not enough +** space, empty it. 'sz' must fit in an empty buffer. +*/ +static char *getbuff (BuffFS *buff, int sz) { + lua_assert(buff->blen <= BUFVFS); lua_assert(sz <= BUFVFS); + if (sz > BUFVFS - buff->blen) /* not enough space? */ + clearbuff(buff); + return buff->space + buff->blen; +} + + +#define addsize(b,sz) ((b)->blen += (sz)) + + +/* +** Add 'str' to the buffer. If string is larger than the buffer space, +** push the string directly to the stack. +*/ +static void addstr2buff (BuffFS *buff, const char *str, size_t slen) { + if (slen <= BUFVFS) { /* does string fit into buffer? */ + char *bf = getbuff(buff, cast_int(slen)); + memcpy(bf, str, slen); /* add string to buffer */ + addsize(buff, cast_int(slen)); + } + else { /* string larger than buffer */ + clearbuff(buff); /* string comes after buffer's content */ + pushstr(buff, str, slen); /* push string */ + } } -static void pushstr (lua_State *L, const char *str, size_t l) { - setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); - luaD_inctop(L); +/* +** Add a numeral to the buffer. +*/ +static void addnum2buff (BuffFS *buff, TValue *num) { + char *numbuff = getbuff(buff, MAXNUMBER2STR); + int len = tostringbuff(num, numbuff); /* format number into 'numbuff' */ + addsize(buff, len); } /* -** this function handles only '%d', '%c', '%f', '%p', and '%s' +** this function handles only '%d', '%c', '%f', '%p', '%s', and '%%' conventional formats, plus Lua-specific '%I' and '%U' */ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { - int n = 0; - for (;;) { - const char *e = strchr(fmt, '%'); - if (e == NULL) break; - pushstr(L, fmt, e - fmt); - switch (*(e+1)) { + BuffFS buff; /* holds last part of the result */ + const char *e; /* points to next '%' */ + buff.pushed = buff.blen = 0; + buff.L = L; + while ((e = strchr(fmt, '%')) != NULL) { + addstr2buff(&buff, fmt, e - fmt); /* add 'fmt' up to '%' */ + switch (*(e + 1)) { /* conversion specifier */ case 's': { /* zero-terminated string */ const char *s = va_arg(argp, char *); if (s == NULL) s = "(null)"; - pushstr(L, s, strlen(s)); + addstr2buff(&buff, s, strlen(s)); break; } case 'c': { /* an 'int' as a character */ - char buff = cast(char, va_arg(argp, int)); - if (lisprint(cast_uchar(buff))) - pushstr(L, &buff, 1); - else /* non-printable character; print its code */ - luaO_pushfstring(L, "<\\%d>", cast_uchar(buff)); + char c = cast_uchar(va_arg(argp, int)); + addstr2buff(&buff, &c, sizeof(char)); break; } case 'd': { /* an 'int' */ - setivalue(L->top, va_arg(argp, int)); - goto top2str; + TValue num; + setivalue(&num, va_arg(argp, int)); + addnum2buff(&buff, &num); + break; } case 'I': { /* a 'lua_Integer' */ - setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt))); - goto top2str; + TValue num; + setivalue(&num, cast(lua_Integer, va_arg(argp, l_uacInt))); + addnum2buff(&buff, &num); + break; } case 'f': { /* a 'lua_Number' */ - setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); - top2str: /* convert the top element to a string */ - luaD_inctop(L); - luaO_tostring(L, L->top - 1); + TValue num; + setfltvalue(&num, cast_num(va_arg(argp, l_uacNumber))); + addnum2buff(&buff, &num); break; } case 'p': { /* a pointer */ - char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */ + const int sz = 3 * sizeof(void*) + 8; /* enough space for '%p' */ + char *bf = getbuff(&buff, sz); void *p = va_arg(argp, void *); - int l = lua_pointer2str(buff, sizeof(buff), p); - pushstr(L, buff, l); + int len = lua_pointer2str(bf, sz, p); + addsize(&buff, len); break; } - case 'U': { /* an 'int' as a UTF-8 sequence */ - char buff[UTF8BUFFSZ]; - int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long))); - pushstr(L, buff + UTF8BUFFSZ - l, l); + case 'U': { /* a 'long' as a UTF-8 sequence */ + char bf[UTF8BUFFSZ]; + int len = luaO_utf8esc(bf, va_arg(argp, long)); + addstr2buff(&buff, bf + UTF8BUFFSZ - len, len); break; } case '%': { - pushstr(L, "%", 1); + addstr2buff(&buff, "%", 1); break; } default: { @@ -455,13 +537,12 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { *(e + 1)); } } - n += 2; - fmt = e+2; + fmt = e + 2; /* skip '%' and the specifier */ } - luaD_checkstack(L, 1); - pushstr(L, fmt, strlen(fmt)); - if (n > 0) luaV_concat(L, n + 1); - return svalue(L->top - 1); + addstr2buff(&buff, fmt, strlen(fmt)); /* rest of 'fmt' */ + clearbuff(&buff); /* empty buffer into the stack */ + lua_assert(buff.pushed == 1); + return getstr(tsvalue(s2v(L->top.p - 1))); } @@ -474,9 +555,8 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { return msg; } +/* }================================================================== */ -/* number of chars of a literal string without the ending \0 */ -#define LL(x) (sizeof(x)/sizeof(char) - 1) #define RETS "..." #define PRE "[string \"" @@ -484,36 +564,36 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { #define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) ) -void luaO_chunkid (char *out, const char *source, size_t bufflen) { - size_t l = strlen(source); +void luaO_chunkid (char *out, const char *source, size_t srclen) { + size_t bufflen = LUA_IDSIZE; /* free space in buffer */ if (*source == '=') { /* 'literal' source */ - if (l <= bufflen) /* small enough? */ - memcpy(out, source + 1, l * sizeof(char)); + if (srclen <= bufflen) /* small enough? */ + memcpy(out, source + 1, srclen * sizeof(char)); else { /* truncate it */ addstr(out, source + 1, bufflen - 1); *out = '\0'; } } else if (*source == '@') { /* file name */ - if (l <= bufflen) /* small enough? */ - memcpy(out, source + 1, l * sizeof(char)); + if (srclen <= bufflen) /* small enough? */ + memcpy(out, source + 1, srclen * sizeof(char)); else { /* add '...' before rest of name */ addstr(out, RETS, LL(RETS)); bufflen -= LL(RETS); - memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char)); + memcpy(out, source + 1 + srclen - bufflen, bufflen * sizeof(char)); } } else { /* string; format as [string "source"] */ const char *nl = strchr(source, '\n'); /* find first new line (if any) */ addstr(out, PRE, LL(PRE)); /* add prefix */ bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */ - if (l < bufflen && nl == NULL) { /* small one-line source? */ - addstr(out, source, l); /* keep it */ + if (srclen < bufflen && nl == NULL) { /* small one-line source? */ + addstr(out, source, srclen); /* keep it */ } else { - if (nl != NULL) l = nl - source; /* stop at first newline */ - if (l > bufflen) l = bufflen; - addstr(out, source, l); + if (nl != NULL) srclen = nl - source; /* stop at first newline */ + if (srclen > bufflen) srclen = bufflen; + addstr(out, source, srclen); addstr(out, RETS, LL(RETS)); } memcpy(out, POS, (LL(POS) + 1) * sizeof(char)); diff --git a/liblua/lobject.h b/liblua/lobject.h index 24088614..980e42f8 100644 --- a/liblua/lobject.h +++ b/liblua/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.117.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lobject.h $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -17,367 +17,494 @@ /* -** Extra tags for non-values +** Extra types for collectable non-values */ -#define LUA_TPROTO LUA_NUMTAGS /* function prototypes */ -#define LUA_TDEADKEY (LUA_NUMTAGS+1) /* removed keys in tables */ +#define LUA_TUPVAL LUA_NUMTYPES /* upvalues */ +#define LUA_TPROTO (LUA_NUMTYPES+1) /* function prototypes */ +#define LUA_TDEADKEY (LUA_NUMTYPES+2) /* removed keys in tables */ + + /* -** number of all possible tags (including LUA_TNONE but excluding DEADKEY) +** number of all possible types (including LUA_TNONE but excluding DEADKEY) */ -#define LUA_TOTALTAGS (LUA_TPROTO + 2) +#define LUA_TOTALTYPES (LUA_TPROTO + 2) /* ** tags for Tagged Values have the following use of bits: -** bits 0-3: actual tag (a LUA_T* value) +** bits 0-3: actual tag (a LUA_T* constant) ** bits 4-5: variant bits ** bit 6: whether value is collectable */ +/* add variant bits to a type */ +#define makevariant(t,v) ((t) | ((v) << 4)) + + /* -** LUA_TFUNCTION variants: -** 0 - Lua function -** 1 - light C function -** 2 - regular C function (closure) +** Union of all Lua values */ +typedef union Value { + struct GCObject *gc; /* collectable objects */ + void *p; /* light userdata */ + lua_CFunction f; /* light C functions */ + lua_Integer i; /* integer numbers */ + lua_Number n; /* float numbers */ + /* not used, but may avoid warnings for uninitialized value */ + lu_byte ub; +} Value; -/* Variant tags for functions */ -#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */ -#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */ -#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ +/* +** Tagged Values. This is the basic representation of values in Lua: +** an actual value plus a tag with its type. +*/ -/* Variant tags for strings */ -#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ -#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ +#define TValuefields Value value_; lu_byte tt_ +typedef struct TValue { + TValuefields; +} TValue; -/* Variant tags for numbers */ -#define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */ -#define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */ +#define val_(o) ((o)->value_) +#define valraw(o) (val_(o)) -/* Bit mark for collectable types */ -#define BIT_ISCOLLECTABLE (1 << 6) -/* mark a tag as collectable */ -#define ctb(t) ((t) | BIT_ISCOLLECTABLE) +/* raw type tag of a TValue */ +#define rawtt(o) ((o)->tt_) + +/* tag with no variants (bits 0-3) */ +#define novariant(t) ((t) & 0x0F) + +/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ +#define withvariant(t) ((t) & 0x3F) +#define ttypetag(o) withvariant(rawtt(o)) +/* type of a TValue */ +#define ttype(o) (novariant(rawtt(o))) + + +/* Macros to test type */ +#define checktag(o,t) (rawtt(o) == (t)) +#define checktype(o,t) (ttype(o) == (t)) + + +/* Macros for internal tests */ + +/* collectable object has the same tag as the original value */ +#define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) /* -** Common type for all collectable objects +** Any value being manipulated by the program either is non +** collectable, or the collectable object has the right tag +** and it is not dead. The option 'L == NULL' allows other +** macros using this one to be used where L is not available. */ -typedef struct GCObject GCObject; +#define checkliveness(L,obj) \ + ((void)L, lua_longassert(!iscollectable(obj) || \ + (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) +/* Macros to set values */ + +/* set a value's tag */ +#define settt_(o,t) ((o)->tt_=(t)) + + +/* main macro to copy values (from 'obj2' to 'obj1') */ +#define setobj(L,obj1,obj2) \ + { TValue *io1=(obj1); const TValue *io2=(obj2); \ + io1->value_ = io2->value_; settt_(io1, io2->tt_); \ + checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); } + /* -** Common Header for all collectable objects (in macro form, to be -** included in other objects) +** Different types of assignments, according to source and destination. +** (They are mostly equal now, but may be different in the future.) */ -#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + +/* from stack to stack */ +#define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2)) +/* to stack (not from same stack) */ +#define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2) +/* from table to same table */ +#define setobjt2t setobj +/* to new object */ +#define setobj2n setobj +/* to table */ +#define setobj2t setobj /* -** Common type has only the common header +** Entries in a Lua stack. Field 'tbclist' forms a list of all +** to-be-closed variables active in this stack. Dummy entries are +** used when the distance between two tbc variables does not fit +** in an unsigned short. They are represented by delta==0, and +** their real delta is always the maximum value that fits in +** that field. */ -struct GCObject { - CommonHeader; -}; +typedef union StackValue { + TValue val; + struct { + TValuefields; + unsigned short delta; + } tbclist; +} StackValue; +/* index to stack elements */ +typedef StackValue *StkId; /* -** Tagged Values. This is the basic representation of values in Lua, -** an actual value plus a tag with its type. +** When reallocating the stack, change all pointers to the stack into +** proper offsets. */ +typedef union { + StkId p; /* actual pointer */ + ptrdiff_t offset; /* used while the stack is being reallocated */ +} StkIdRel; + + +/* convert a 'StackValue' to a 'TValue' */ +#define s2v(o) (&(o)->val) + + /* -** Union of all Lua values +** {================================================================== +** Nil +** =================================================================== */ -typedef union Value { - GCObject *gc; /* collectable objects */ - void *p; /* light userdata */ - int b; /* booleans */ - lua_CFunction f; /* light C functions */ - lua_Integer i; /* integer numbers */ - lua_Number n; /* float numbers */ -} Value; +/* Standard nil */ +#define LUA_VNIL makevariant(LUA_TNIL, 0) -#define TValuefields Value value_; int tt_ +/* Empty slot (which might be different from a slot containing nil) */ +#define LUA_VEMPTY makevariant(LUA_TNIL, 1) +/* Value returned for a key not found in a table (absent key) */ +#define LUA_VABSTKEY makevariant(LUA_TNIL, 2) -typedef struct lua_TValue { - TValuefields; -} TValue; +/* macro to test for (any kind of) nil */ +#define ttisnil(v) checktype((v), LUA_TNIL) -/* macro defining a nil value */ -#define NILCONSTANT {NULL}, LUA_TNIL +/* macro to test for a standard nil */ +#define ttisstrictnil(o) checktag((o), LUA_VNIL) -#define val_(o) ((o)->value_) +#define setnilvalue(obj) settt_(obj, LUA_VNIL) -/* raw type tag of a TValue */ -#define rttype(o) ((o)->tt_) +#define isabstkey(v) checktag((v), LUA_VABSTKEY) -/* tag with no variants (bits 0-3) */ -#define novariant(x) ((x) & 0x0F) -/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ -#define ttype(o) (rttype(o) & 0x3F) +/* +** macro to detect non-standard nils (used only in assertions) +*/ +#define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v)) -/* type tag of a TValue with no variants (bits 0-3) */ -#define ttnov(o) (novariant(rttype(o))) +/* +** By default, entries with any kind of nil are considered empty. +** (In any definition, values associated with absent keys must also +** be accepted as empty.) +*/ +#define isempty(v) ttisnil(v) -/* Macros to test type */ -#define checktag(o,t) (rttype(o) == (t)) -#define checktype(o,t) (ttnov(o) == (t)) -#define ttisnumber(o) checktype((o), LUA_TNUMBER) -#define ttisfloat(o) checktag((o), LUA_TNUMFLT) -#define ttisinteger(o) checktag((o), LUA_TNUMINT) -#define ttisnil(o) checktag((o), LUA_TNIL) -#define ttisboolean(o) checktag((o), LUA_TBOOLEAN) -#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) -#define ttisstring(o) checktype((o), LUA_TSTRING) -#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) -#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) -#define ttistable(o) checktag((o), ctb(LUA_TTABLE)) -#define ttisfunction(o) checktype(o, LUA_TFUNCTION) -#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) -#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) -#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) -#define ttislcf(o) checktag((o), LUA_TLCF) -#define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA)) -#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD)) -#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY) +/* macro defining a value corresponding to an absent key */ +#define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY -/* Macros to access values */ -#define ivalue(o) check_exp(ttisinteger(o), val_(o).i) -#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) -#define nvalue(o) check_exp(ttisnumber(o), \ - (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) -#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) -#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) -#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) -#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) -#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) -#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) -#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) -#define fvalue(o) check_exp(ttislcf(o), val_(o).f) -#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) -#define bvalue(o) check_exp(ttisboolean(o), val_(o).b) -#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) -/* a dead value may get the 'gc' field, but cannot access its contents */ -#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) -#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) +/* mark an entry as empty */ +#define setempty(v) settt_(v, LUA_VEMPTY) -#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) +/* }================================================================== */ -/* Macros for internal tests */ -#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) -#define checkliveness(L,obj) \ - lua_longassert(!iscollectable(obj) || \ - (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))) +/* +** {================================================================== +** Booleans +** =================================================================== +*/ -/* Macros to set values */ -#define settt_(o,t) ((o)->tt_=(t)) +#define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0) +#define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1) -#define setfltvalue(obj,x) \ - { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); } +#define ttisboolean(o) checktype((o), LUA_TBOOLEAN) +#define ttisfalse(o) checktag((o), LUA_VFALSE) +#define ttistrue(o) checktag((o), LUA_VTRUE) -#define chgfltvalue(obj,x) \ - { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } -#define setivalue(obj,x) \ - { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); } +#define l_isfalse(o) (ttisfalse(o) || ttisnil(o)) -#define chgivalue(obj,x) \ - { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } -#define setnilvalue(obj) settt_(obj, LUA_TNIL) +#define setbfvalue(obj) settt_(obj, LUA_VFALSE) +#define setbtvalue(obj) settt_(obj, LUA_VTRUE) -#define setfvalue(obj,x) \ - { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } +/* }================================================================== */ -#define setpvalue(obj,x) \ - { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } -#define setbvalue(obj,x) \ - { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } +/* +** {================================================================== +** Threads +** =================================================================== +*/ -#define setgcovalue(L,obj,x) \ - { TValue *io = (obj); GCObject *i_g=(x); \ - val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } +#define LUA_VTHREAD makevariant(LUA_TTHREAD, 0) -#define setsvalue(L,obj,x) \ - { TValue *io = (obj); TString *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ - checkliveness(L,io); } +#define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) -#define setuvalue(L,obj,x) \ - { TValue *io = (obj); Udata *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \ - checkliveness(L,io); } +#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) #define setthvalue(L,obj,x) \ { TValue *io = (obj); lua_State *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \ checkliveness(L,io); } -#define setclLvalue(L,obj,x) \ - { TValue *io = (obj); LClosure *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \ - checkliveness(L,io); } +#define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t) -#define setclCvalue(L,obj,x) \ - { TValue *io = (obj); CClosure *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \ - checkliveness(L,io); } +/* }================================================================== */ -#define sethvalue(L,obj,x) \ - { TValue *io = (obj); Table *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \ - checkliveness(L,io); } -#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) +/* +** {================================================================== +** Collectable Objects +** =================================================================== +*/ +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked -#define setobj(L,obj1,obj2) \ - { TValue *io1=(obj1); *io1 = *(obj2); \ - (void)L; checkliveness(L,io1); } +/* Common type for all collectable objects */ +typedef struct GCObject { + CommonHeader; +} GCObject; + + +/* Bit mark for collectable types */ +#define BIT_ISCOLLECTABLE (1 << 6) + +#define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE) + +/* mark a tag as collectable */ +#define ctb(t) ((t) | BIT_ISCOLLECTABLE) + +#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) + +#define gcvalueraw(v) ((v).gc) + +#define setgcovalue(L,obj,x) \ + { TValue *io = (obj); GCObject *i_g=(x); \ + val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } + +/* }================================================================== */ /* -** different types of assignments, according to destination +** {================================================================== +** Numbers +** =================================================================== */ -/* from stack to (same) stack */ -#define setobjs2s setobj -/* to stack (not from same stack) */ -#define setobj2s setobj -#define setsvalue2s setsvalue -#define sethvalue2s sethvalue -#define setptvalue2s setptvalue -/* from table to same table */ -#define setobjt2t setobj -/* to new object */ -#define setobj2n setobj -#define setsvalue2n setsvalue +/* Variant tags for numbers */ +#define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) /* integer numbers */ +#define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) /* float numbers */ + +#define ttisnumber(o) checktype((o), LUA_TNUMBER) +#define ttisfloat(o) checktag((o), LUA_VNUMFLT) +#define ttisinteger(o) checktag((o), LUA_VNUMINT) + +#define nvalue(o) check_exp(ttisnumber(o), \ + (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) +#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) +#define ivalue(o) check_exp(ttisinteger(o), val_(o).i) + +#define fltvalueraw(v) ((v).n) +#define ivalueraw(v) ((v).i) + +#define setfltvalue(obj,x) \ + { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); } + +#define chgfltvalue(obj,x) \ + { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } -/* to table (define it as an expression to be used in macros) */ -#define setobj2t(L,o1,o2) ((void)L, *(o1)=*(o2), checkliveness(L,(o1))) +#define setivalue(obj,x) \ + { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); } +#define chgivalue(obj,x) \ + { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } +/* }================================================================== */ /* -** {====================================================== -** types and prototypes -** ======================================================= +** {================================================================== +** Strings +** =================================================================== */ +/* Variant tags for strings */ +#define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) /* short strings */ +#define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) /* long strings */ -typedef TValue *StkId; /* index to stack elements */ +#define ttisstring(o) checktype((o), LUA_TSTRING) +#define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) +#define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR)) +#define tsvalueraw(v) (gco2ts((v).gc)) +#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) + +#define setsvalue(L,obj,x) \ + { TValue *io = (obj); TString *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ + checkliveness(L,io); } + +/* set a string to the stack */ +#define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s) + +/* set a string to a new object */ +#define setsvalue2n setsvalue /* -** Header for string value; string bytes follow the end of this structure -** (aligned according to 'UTString'; see next). +** Header for a string value. */ typedef struct TString { CommonHeader; lu_byte extra; /* reserved words for short strings; "has hash" for longs */ - lu_byte shrlen; /* length for short strings */ + lu_byte shrlen; /* length for short strings, 0xFF for long strings */ unsigned int hash; union { size_t lnglen; /* length for long strings */ struct TString *hnext; /* linked list for hash table */ } u; + char contents[1]; } TString; + /* -** Ensures that address after this type is always fully aligned. +** Get the actual string (array of bytes) from a 'TString'. (Generic +** version and specialized versions for long and short strings.) */ -typedef union UTString { - L_Umaxalign dummy; /* ensures maximum alignment for strings */ - TString tsv; -} UTString; +#define getstr(ts) ((ts)->contents) +#define getlngstr(ts) check_exp((ts)->shrlen == 0xFF, (ts)->contents) +#define getshrstr(ts) check_exp((ts)->shrlen != 0xFF, (ts)->contents) + + +/* get string length from 'TString *s' */ +#define tsslen(s) \ + ((s)->shrlen != 0xFF ? (s)->shrlen : (s)->u.lnglen) + +/* }================================================================== */ /* -** Get the actual string (array of bytes) from a 'TString'. -** (Access to 'extra' ensures that value is really a 'TString'.) +** {================================================================== +** Userdata +** =================================================================== */ -#define getstr(ts) \ - check_exp(sizeof((ts)->extra), cast(char *, (ts)) + sizeof(UTString)) -/* get the actual string (array of bytes) from a Lua value */ -#define svalue(o) getstr(tsvalue(o)) +/* +** Light userdata should be a variant of userdata, but for compatibility +** reasons they are also different types. +*/ +#define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0) -/* get string length from 'TString *s' */ -#define tsslen(s) ((s)->tt == LUA_TSHRSTR ? (s)->shrlen : (s)->u.lnglen) +#define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0) -/* get string length from 'TValue *o' */ -#define vslen(o) tsslen(tsvalue(o)) +#define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) +#define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) + +#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) +#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) + +#define pvalueraw(v) ((v).p) + +#define setpvalue(obj,x) \ + { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); } + +#define setuvalue(L,obj,x) \ + { TValue *io = (obj); Udata *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \ + checkliveness(L,io); } + + +/* Ensures that addresses after this type are always fully aligned. */ +typedef union UValue { + TValue uv; + LUAI_MAXALIGN; /* ensures maximum alignment for udata bytes */ +} UValue; /* -** Header for userdata; memory area follows the end of this structure -** (aligned according to 'UUdata'; see next). +** Header for userdata with user values; +** memory area follows the end of this structure. */ typedef struct Udata { CommonHeader; - lu_byte ttuv_; /* user value's tag */ - struct Table *metatable; + unsigned short nuvalue; /* number of user values */ size_t len; /* number of bytes */ - union Value user_; /* user value */ + struct Table *metatable; + GCObject *gclist; + UValue uv[1]; /* user values */ } Udata; /* -** Ensures that address after this type is always fully aligned. +** Header for userdata with no user values. These userdata do not need +** to be gray during GC, and therefore do not need a 'gclist' field. +** To simplify, the code always use 'Udata' for both kinds of userdata, +** making sure it never accesses 'gclist' on userdata with no user values. +** This structure here is used only to compute the correct size for +** this representation. (The 'bindata' field in its end ensures correct +** alignment for binary data following this header.) */ -typedef union UUdata { - L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */ - Udata uv; -} UUdata; +typedef struct Udata0 { + CommonHeader; + unsigned short nuvalue; /* number of user values */ + size_t len; /* number of bytes */ + struct Table *metatable; + union {LUAI_MAXALIGN;} bindata; +} Udata0; -/* -** Get the address of memory block inside 'Udata'. -** (Access to 'ttuv_' ensures that value is really a 'Udata'.) -*/ -#define getudatamem(u) \ - check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata))) +/* compute the offset of the memory area of a userdata */ +#define udatamemoffset(nuv) \ + ((nuv) == 0 ? offsetof(Udata0, bindata) \ + : offsetof(Udata, uv) + (sizeof(UValue) * (nuv))) -#define setuservalue(L,u,o) \ - { const TValue *io=(o); Udata *iu = (u); \ - iu->user_ = io->value_; iu->ttuv_ = rttype(io); \ - checkliveness(L,io); } +/* get the address of the memory block inside 'Udata' */ +#define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) +/* compute the size of a userdata */ +#define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb)) -#define getuservalue(L,u,o) \ - { TValue *io=(o); const Udata *iu = (u); \ - io->value_ = iu->user_; settt_(io, iu->ttuv_); \ - checkliveness(L,io); } +/* }================================================================== */ + + +/* +** {================================================================== +** Prototypes +** =================================================================== +*/ + +#define LUA_VPROTO makevariant(LUA_TPROTO, 0) /* @@ -387,6 +514,7 @@ typedef struct Upvaldesc { TString *name; /* upvalue name (for debug information) */ lu_byte instack; /* whether it is in stack (register) */ lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ + lu_byte kind; /* kind of corresponding variable */ } Upvaldesc; @@ -401,12 +529,27 @@ typedef struct LocVar { } LocVar; +/* +** Associates the absolute line source for a given instruction ('pc'). +** The array 'lineinfo' gives, for each instruction, the difference in +** lines from the previous instruction. When that difference does not +** fit into a byte, Lua saves the absolute line for that instruction. +** (Lua also saves the absolute line periodically, to speed up the +** computation of a line number: we can use binary search in the +** absolute-line array, but we must traverse the 'lineinfo' array +** linearly to compute a line.) +*/ +typedef struct AbsLineInfo { + int pc; + int line; +} AbsLineInfo; + /* ** Function Prototypes */ typedef struct Proto { CommonHeader; - lu_byte numparams; /* number of fixed parameters */ + lu_byte numparams; /* number of fixed (named) parameters */ lu_byte is_vararg; lu_byte maxstacksize; /* number of registers needed by this function */ int sizeupvalues; /* size of 'upvalues' */ @@ -415,30 +558,88 @@ typedef struct Proto { int sizelineinfo; int sizep; /* size of 'p' */ int sizelocvars; + int sizeabslineinfo; /* size of 'abslineinfo' */ int linedefined; /* debug information */ int lastlinedefined; /* debug information */ TValue *k; /* constants used by the function */ Instruction *code; /* opcodes */ struct Proto **p; /* functions defined inside the function */ - int *lineinfo; /* map from opcodes to source lines (debug information) */ - LocVar *locvars; /* information about local variables (debug information) */ Upvaldesc *upvalues; /* upvalue information */ - struct LClosure *cache; /* last-created closure with this prototype */ + ls_byte *lineinfo; /* information about source lines (debug information) */ + AbsLineInfo *abslineinfo; /* idem */ + LocVar *locvars; /* information about local variables (debug information) */ TString *source; /* used for debug information */ GCObject *gclist; } Proto; +/* }================================================================== */ /* -** Lua Upvalues +** {================================================================== +** Functions +** =================================================================== */ -typedef struct UpVal UpVal; + +#define LUA_VUPVAL makevariant(LUA_TUPVAL, 0) + + +/* Variant tags for functions */ +#define LUA_VLCL makevariant(LUA_TFUNCTION, 0) /* Lua closure */ +#define LUA_VLCF makevariant(LUA_TFUNCTION, 1) /* light C function */ +#define LUA_VCCL makevariant(LUA_TFUNCTION, 2) /* C closure */ + +#define ttisfunction(o) checktype(o, LUA_TFUNCTION) +#define ttisLclosure(o) checktag((o), ctb(LUA_VLCL)) +#define ttislcf(o) checktag((o), LUA_VLCF) +#define ttisCclosure(o) checktag((o), ctb(LUA_VCCL)) +#define ttisclosure(o) (ttisLclosure(o) || ttisCclosure(o)) + + +#define isLfunction(o) ttisLclosure(o) + +#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) +#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) +#define fvalue(o) check_exp(ttislcf(o), val_(o).f) +#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) + +#define fvalueraw(v) ((v).f) + +#define setclLvalue(L,obj,x) \ + { TValue *io = (obj); LClosure *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \ + checkliveness(L,io); } + +#define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl) + +#define setfvalue(obj,x) \ + { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); } + +#define setclCvalue(L,obj,x) \ + { TValue *io = (obj); CClosure *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \ + checkliveness(L,io); } /* -** Closures +** Upvalues for Lua closures */ +typedef struct UpVal { + CommonHeader; + union { + TValue *p; /* points to stack or to its own value */ + ptrdiff_t offset; /* used while the stack is being reallocated */ + } v; + union { + struct { /* (when open) */ + struct UpVal *next; /* linked list */ + struct UpVal **previous; + } open; + TValue value; /* the value (when closed) */ + } u; +} UpVal; + + #define ClosureHeader \ CommonHeader; lu_byte nupvalues; GCObject *gclist @@ -463,42 +664,81 @@ typedef union Closure { } Closure; -#define isLfunction(o) ttisLclosure(o) - #define getproto(o) (clLvalue(o)->p) +/* }================================================================== */ + /* +** {================================================================== ** Tables +** =================================================================== */ -typedef union TKey { - struct { - TValuefields; - int next; /* for chaining (offset for next node) */ - } nk; - TValue tvk; -} TKey; +#define LUA_VTABLE makevariant(LUA_TTABLE, 0) + +#define ttistable(o) checktag((o), ctb(LUA_VTABLE)) + +#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) +#define sethvalue(L,obj,x) \ + { TValue *io = (obj); Table *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \ + checkliveness(L,io); } -/* copy a value into a key without messing up field 'next' */ -#define setnodekey(L,key,obj) \ - { TKey *k_=(key); const TValue *io_=(obj); \ - k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ - (void)L; checkliveness(L,io_); } +#define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h) -typedef struct Node { - TValue i_val; - TKey i_key; +/* +** Nodes for Hash tables: A pack of two TValue's (key-value pairs) +** plus a 'next' field to link colliding entries. The distribution +** of the key's fields ('key_tt' and 'key_val') not forming a proper +** 'TValue' allows for a smaller size for 'Node' both in 4-byte +** and 8-byte alignments. +*/ +typedef union Node { + struct NodeKey { + TValuefields; /* fields for value */ + lu_byte key_tt; /* key type */ + int next; /* for chaining */ + Value key_val; /* key value */ + } u; + TValue i_val; /* direct access to node's value as a proper 'TValue' */ } Node; +/* copy a value into a key */ +#define setnodekey(L,node,obj) \ + { Node *n_=(node); const TValue *io_=(obj); \ + n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \ + checkliveness(L,io_); } + + +/* copy a value from a key */ +#define getnodekey(L,obj,node) \ + { TValue *io_=(obj); const Node *n_=(node); \ + io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \ + checkliveness(L,io_); } + + +/* +** About 'alimit': if 'isrealasize(t)' is true, then 'alimit' is the +** real size of 'array'. Otherwise, the real size of 'array' is the +** smallest power of two not smaller than 'alimit' (or zero iff 'alimit' +** is zero); 'alimit' is then used as a hint for #t. +*/ + +#define BITRAS (1 << 7) +#define isrealasize(t) (!((t)->flags & BITRAS)) +#define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS)) +#define setnorealasize(t) ((t)->flags |= BITRAS) + + typedef struct Table { CommonHeader; lu_byte flags; /* 1<

u.key_tt) +#define keyval(node) ((node)->u.key_val) + +#define keyisnil(node) (keytt(node) == LUA_TNIL) +#define keyisinteger(node) (keytt(node) == LUA_VNUMINT) +#define keyival(node) (keyval(node).i) +#define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR)) +#define keystrval(node) (gco2ts(keyval(node).gc)) + +#define setnilkey(node) (keytt(node) = LUA_TNIL) + +#define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE) + +#define gckey(n) (keyval(n).gc) +#define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL) + /* -** 'module' operation for hashing (size is always a power of 2) +** Dead keys in tables have the tag DEADKEY but keep their original +** gcvalue. This distinguishes them from regular keys but allows them to +** be found when searched in a special way. ('next' needs that to find +** keys removed from a table during a traversal.) */ -#define lmod(s,size) \ - (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1))))) +#define setdeadkey(node) (keytt(node) = LUA_TDEADKEY) +#define keyisdead(node) (keytt(node) == LUA_TDEADKEY) +/* }================================================================== */ -#define twoto(x) (1<<(x)) -#define sizenode(t) (twoto((t)->lsizenode)) /* -** (address of) a fixed nil value +** 'module' operation for hashing (size is always a power of 2) */ -#define luaO_nilobject (&luaO_nilobject_) +#define lmod(s,size) \ + (check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1))))) + +#define twoto(x) (1<<(x)) +#define sizenode(t) (twoto((t)->lsizenode)) -LUAI_DDEC const TValue luaO_nilobject_; /* size of buffer for 'luaO_utf8esc' function */ #define UTF8BUFFSZ 8 -LUAI_FUNC int luaO_int2fb (unsigned int x); -LUAI_FUNC int luaO_fb2int (int x); LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); LUAI_FUNC int luaO_ceillog2 (unsigned int x); +LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1, + const TValue *p2, TValue *res); LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1, - const TValue *p2, TValue *res); + const TValue *p2, StkId res); LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o); LUAI_FUNC int luaO_hexavalue (int c); -LUAI_FUNC void luaO_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj); LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); -LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen); #endif diff --git a/liblua/lopcodes.c b/liblua/lopcodes.c index 5ca3eb26..c67aa227 100644 --- a/liblua/lopcodes.c +++ b/liblua/lopcodes.c @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.c,v 1.55.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lopcodes.c $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -10,115 +10,95 @@ #include "lprefix.h" -#include - #include "lopcodes.h" /* ORDER OP */ -LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { - "MOVE", - "LOADK", - "LOADKX", - "LOADBOOL", - "LOADNIL", - "GETUPVAL", - "GETTABUP", - "GETTABLE", - "SETTABUP", - "SETUPVAL", - "SETTABLE", - "NEWTABLE", - "SELF", - "ADD", - "SUB", - "MUL", - "MOD", - "POW", - "DIV", - "IDIV", - "BAND", - "BOR", - "BXOR", - "SHL", - "SHR", - "UNM", - "BNOT", - "NOT", - "LEN", - "CONCAT", - "JMP", - "EQ", - "LT", - "LE", - "TEST", - "TESTSET", - "CALL", - "TAILCALL", - "RETURN", - "FORLOOP", - "FORPREP", - "TFORCALL", - "TFORLOOP", - "SETLIST", - "CLOSURE", - "VARARG", - "EXTRAARG", - NULL -}; - - -#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) - LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { -/* T A B C mode opcode */ - opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ - ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ - ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ - ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ - ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ - ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ - ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ - ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ - ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ - ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ - ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ - ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ - ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ - ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ - ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ - ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ - ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ - ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ +/* MM OT IT T A mode opcode */ + opmode(0, 0, 0, 0, 1, iABC) /* OP_MOVE */ + ,opmode(0, 0, 0, 0, 1, iAsBx) /* OP_LOADI */ + ,opmode(0, 0, 0, 0, 1, iAsBx) /* OP_LOADF */ + ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADK */ + ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADKX */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADFALSE */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LFALSESKIP */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADTRUE */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADNIL */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETUPVAL */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETTABUP */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETI */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETFIELD */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETTABUP */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETTABLE */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETI */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_SETFIELD */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_NEWTABLE */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SELF */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_ADDI */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_ADDK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SUBK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MULK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MODK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_POWK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_DIVK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_IDIVK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BANDK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BORK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BXORK */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHRI */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHLI */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_ADD */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SUB */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MUL */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_MOD */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_POW */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_DIV */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_IDIV */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BAND */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BOR */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BXOR */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHL */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_SHR */ + ,opmode(1, 0, 0, 0, 0, iABC) /* OP_MMBIN */ + ,opmode(1, 0, 0, 0, 0, iABC) /* OP_MMBINI*/ + ,opmode(1, 0, 0, 0, 0, iABC) /* OP_MMBINK*/ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_UNM */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_BNOT */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_NOT */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LEN */ + ,opmode(0, 0, 0, 0, 1, iABC) /* OP_CONCAT */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_CLOSE */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_TBC */ + ,opmode(0, 0, 0, 0, 0, isJ) /* OP_JMP */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_EQ */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LT */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LE */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_EQK */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_EQI */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LTI */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_LEI */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_GTI */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_GEI */ + ,opmode(0, 0, 0, 1, 0, iABC) /* OP_TEST */ + ,opmode(0, 0, 0, 1, 1, iABC) /* OP_TESTSET */ + ,opmode(0, 1, 1, 0, 1, iABC) /* OP_CALL */ + ,opmode(0, 1, 1, 0, 1, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, 1, 0, 0, iABC) /* OP_RETURN */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_RETURN0 */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_RETURN1 */ + ,opmode(0, 0, 0, 0, 1, iABx) /* OP_FORLOOP */ + ,opmode(0, 0, 0, 0, 1, iABx) /* OP_FORPREP */ + ,opmode(0, 0, 0, 0, 0, iABx) /* OP_TFORPREP */ + ,opmode(0, 0, 0, 0, 0, iABC) /* OP_TFORCALL */ + ,opmode(0, 0, 0, 0, 1, iABx) /* OP_TFORLOOP */ + ,opmode(0, 0, 1, 0, 0, iABC) /* OP_SETLIST */ + ,opmode(0, 0, 0, 0, 1, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, 0, 0, 1, iABC) /* OP_VARARG */ + ,opmode(0, 0, 1, 0, 1, iABC) /* OP_VARARGPREP */ + ,opmode(0, 0, 0, 0, 0, iAx) /* OP_EXTRAARG */ }; diff --git a/liblua/lopcodes.h b/liblua/lopcodes.h index 6feaa1cd..46911cac 100644 --- a/liblua/lopcodes.h +++ b/liblua/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.149.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lopcodes.h $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -11,69 +11,94 @@ /*=========================================================================== - We assume that instructions are unsigned numbers. - All instructions have an opcode in the first 6 bits. - Instructions can have the following fields: - 'A' : 8 bits - 'B' : 9 bits - 'C' : 9 bits - 'Ax' : 26 bits ('A', 'B', and 'C' together) - 'Bx' : 18 bits ('B' and 'C' together) - 'sBx' : signed Bx - - A signed argument is represented in excess K; that is, the number - value is the unsigned value minus K. K is exactly the maximum value - for that argument (so that -max is represented by 0, and +max is - represented by 2*max), which is half the maximum for the corresponding - unsigned argument. + We assume that instructions are unsigned 32-bit integers. + All instructions have an opcode in the first 7 bits. + Instructions can have the following formats: + + 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +iABC C(8) | B(8) |k| A(8) | Op(7) | +iABx Bx(17) | A(8) | Op(7) | +iAsBx sBx (signed)(17) | A(8) | Op(7) | +iAx Ax(25) | Op(7) | +isJ sJ (signed)(25) | Op(7) | + + A signed argument is represented in excess K: the represented value is + the written unsigned value minus K, where K is half the maximum for the + corresponding unsigned argument. ===========================================================================*/ -enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */ +enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */ /* ** size and position of opcode arguments. */ -#define SIZE_C 9 -#define SIZE_B 9 -#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_C 8 +#define SIZE_B 8 +#define SIZE_Bx (SIZE_C + SIZE_B + 1) #define SIZE_A 8 -#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A) +#define SIZE_Ax (SIZE_Bx + SIZE_A) +#define SIZE_sJ (SIZE_Bx + SIZE_A) -#define SIZE_OP 6 +#define SIZE_OP 7 #define POS_OP 0 + #define POS_A (POS_OP + SIZE_OP) -#define POS_C (POS_A + SIZE_A) -#define POS_B (POS_C + SIZE_C) -#define POS_Bx POS_C +#define POS_k (POS_A + SIZE_A) +#define POS_B (POS_k + 1) +#define POS_C (POS_B + SIZE_B) + +#define POS_Bx POS_k + #define POS_Ax POS_A +#define POS_sJ POS_A + /* ** limits for opcode arguments. -** we use (signed) int to manipulate most arguments, -** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +** we use (signed) 'int' to manipulate most arguments, +** so they must fit in ints. */ -#if SIZE_Bx < LUAI_BITSINT-1 -#define MAXARG_Bx ((1<>1) /* 'sBx' is signed */ + +/* Check whether type 'int' has at least 'b' bits ('b' < 32) */ +#define L_INTHASBITS(b) ((UINT_MAX >> ((b) - 1)) >= 1) + + +#if L_INTHASBITS(SIZE_Bx) +#define MAXARG_Bx ((1<>1) /* 'sBx' is signed */ + + +#if L_INTHASBITS(SIZE_Ax) #define MAXARG_Ax ((1<> 1) -#define MAXARG_A ((1<> 1) + +#define int2sC(i) ((i) + OFFSET_sC) +#define sC2int(i) ((i) - OFFSET_sC) /* creates a mask with 'n' 1 bits at position 'p' */ @@ -90,33 +115,49 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */ #define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ ((cast(Instruction, o)<>pos) & MASK1(size,0))) +#define checkopm(i,m) (getOpMode(GET_OPCODE(i)) == m) + + +#define getarg(i,pos,size) (cast_int(((i)>>(pos)) & MASK1(size,0))) #define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ ((cast(Instruction, v)<> RK(C) */ -OP_UNM,/* A B R(A) := -R(B) */ -OP_BNOT,/* A B R(A) := ~R(B) */ -OP_NOT,/* A B R(A) := not R(B) */ -OP_LEN,/* A B R(A) := length of R(B) */ - -OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ - -OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */ -OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ -OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ -OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ - -OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ -OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ - -OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ -OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ -OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ - -OP_FORLOOP,/* A sBx R(A)+=R(A+2); - if R(A) > sC */ +OP_SHLI,/* A B sC R[A] := sC << R[B] */ + +OP_ADD,/* A B C R[A] := R[B] + R[C] */ +OP_SUB,/* A B C R[A] := R[B] - R[C] */ +OP_MUL,/* A B C R[A] := R[B] * R[C] */ +OP_MOD,/* A B C R[A] := R[B] % R[C] */ +OP_POW,/* A B C R[A] := R[B] ^ R[C] */ +OP_DIV,/* A B C R[A] := R[B] / R[C] */ +OP_IDIV,/* A B C R[A] := R[B] // R[C] */ + +OP_BAND,/* A B C R[A] := R[B] & R[C] */ +OP_BOR,/* A B C R[A] := R[B] | R[C] */ +OP_BXOR,/* A B C R[A] := R[B] ~ R[C] */ +OP_SHL,/* A B C R[A] := R[B] << R[C] */ +OP_SHR,/* A B C R[A] := R[B] >> R[C] */ + +OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] (*) */ +OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ +OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */ + +OP_UNM,/* A B R[A] := -R[B] */ +OP_BNOT,/* A B R[A] := ~R[B] */ +OP_NOT,/* A B R[A] := not R[B] */ +OP_LEN,/* A B R[A] := #R[B] (length operator) */ + +OP_CONCAT,/* A B R[A] := R[A].. ... ..R[A + B - 1] */ + +OP_CLOSE,/* A close all upvalues >= R[A] */ +OP_TBC,/* A mark variable A "to be closed" */ +OP_JMP,/* sJ pc += sJ */ +OP_EQ,/* A B k if ((R[A] == R[B]) ~= k) then pc++ */ +OP_LT,/* A B k if ((R[A] < R[B]) ~= k) then pc++ */ +OP_LE,/* A B k if ((R[A] <= R[B]) ~= k) then pc++ */ + +OP_EQK,/* A B k if ((R[A] == K[B]) ~= k) then pc++ */ +OP_EQI,/* A sB k if ((R[A] == sB) ~= k) then pc++ */ +OP_LTI,/* A sB k if ((R[A] < sB) ~= k) then pc++ */ +OP_LEI,/* A sB k if ((R[A] <= sB) ~= k) then pc++ */ +OP_GTI,/* A sB k if ((R[A] > sB) ~= k) then pc++ */ +OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ + +OP_TEST,/* A k if (not R[A] == k) then pc++ */ +OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] (*) */ + +OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ +OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ + +OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] (see note) */ +OP_RETURN0,/* return */ +OP_RETURN1,/* A return R[A] */ + +OP_FORLOOP,/* A Bx update counters; if loop continues then pc-=Bx; */ +OP_FORPREP,/* A Bx ; + if not to run then pc+=Bx+1; */ + +OP_TFORPREP,/* A Bx create upvalue for R[A + 3]; pc+=Bx */ +OP_TFORCALL,/* A C R[A+4], ... ,R[A+3+C] := R[A](R[A+1], R[A+2]); */ +OP_TFORLOOP,/* A Bx if R[A+2] ~= nil then { R[A]=R[A+2]; pc -= Bx } */ + +OP_SETLIST,/* A B C k R[A][C+i] := R[A+i], 1 <= i <= B */ + +OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */ + +OP_VARARG,/* A C R[A], R[A+1], ..., R[A+C-2] = vararg */ -OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ - -OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ - -OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */ +OP_VARARGPREP,/*A (adjust vararg parameters) */ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ } OpCode; -#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1) +#define NUM_OPCODES ((int)(OP_EXTRAARG) + 1) /*=========================================================================== Notes: - (*) In OP_CALL, if (B == 0) then B = top. If (C == 0), then 'top' is - set to last_result+1, so next open instruction (OP_CALL, OP_RETURN, - OP_SETLIST) may use 'top'. - (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + (*) Opcode OP_LFALSESKIP is used to convert a condition to a boolean + value, in a code equivalent to (not cond ? false : true). (It + produces false and skips the next instruction producing true.) + + (*) Opcodes OP_MMBIN and variants follow each arithmetic and + bitwise opcode. If the operation succeeds, it skips this next + opcode. Otherwise, this opcode calls the corresponding metamethod. + + (*) Opcode OP_TESTSET is used in short-circuit expressions that need + both to jump and to produce a value, such as (a = b or c). + + (*) In OP_CALL, if (B == 0) then B = top - A. If (C == 0), then + 'top' is set to last_result+1, so next open instruction (OP_CALL, + OP_RETURN*, OP_SETLIST) may use 'top'. + + (*) In OP_VARARG, if (C == 0) then use actual number of varargs and set top (like in OP_CALL with C == 0). (*) In OP_RETURN, if (B == 0) then return up to 'top'. - (*) In OP_SETLIST, if (B == 0) then B = 'top'; if (C == 0) then next - 'instruction' is EXTRAARG(real C). + (*) In OP_LOADKX and OP_NEWTABLE, the next instruction is always + OP_EXTRAARG. - (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG. + (*) In OP_SETLIST, if (B == 0) then real B = 'top'; if k, then + real C = EXTRAARG _ C (the bits of EXTRAARG concatenated with the + bits of C). - (*) For comparisons, A specifies what condition the test should accept + (*) In OP_NEWTABLE, B is log2 of the hash size (which is always a + power of 2) plus 1, or zero for size zero. If not k, the array size + is C. Otherwise, the array size is EXTRAARG _ C. + + (*) For comparisons, k specifies what condition the test should accept (true or false). + (*) In OP_MMBINI/OP_MMBINK, k means the arguments were flipped + (the constant is the first operand). + (*) All 'skips' (pc++) assume that next instruction is a jump. + (*) In instructions OP_RETURN/OP_TAILCALL, 'k' specifies that the + function builds upvalues, which may need to be closed. C > 0 means + the function is vararg, so that its 'func' must be corrected before + returning; in this case, (C - 1) is its number of fixed parameters. + + (*) In comparisons with an immediate operand, C signals whether the + original operand was a float. (It must be corrected in case of + metamethods.) + ===========================================================================*/ /* ** masks for instruction properties. The format is: -** bits 0-1: op mode -** bits 2-3: C arg mode -** bits 4-5: B arg mode -** bit 6: instruction set register A -** bit 7: operator is a test (next instruction must be a jump) +** bits 0-2: op mode +** bit 3: instruction set register A +** bit 4: operator is a test (next instruction must be a jump) +** bit 5: instruction uses 'L->top' set by previous instruction (when B == 0) +** bit 6: instruction sets 'L->top' for next instruction (when C == 0) +** bit 7: instruction is an MM instruction (call a metamethod) */ -enum OpArgMask { - OpArgN, /* argument is not used */ - OpArgU, /* argument is used */ - OpArgR, /* argument is a register or a jump offset */ - OpArgK /* argument is a constant or register/constant */ -}; +LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];) -LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 7)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 3)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 4)) +#define testITMode(m) (luaP_opmodes[m] & (1 << 5)) +#define testOTMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testMMMode(m) (luaP_opmodes[m] & (1 << 7)) -#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) -#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) -#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) -#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) -#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) +/* "out top" (set top for next instruction) */ +#define isOT(i) \ + ((testOTMode(GET_OPCODE(i)) && GETARG_C(i) == 0) || \ + GET_OPCODE(i) == OP_TAILCALL) +/* "in top" (uses top from previous instruction) */ +#define isIT(i) (testITMode(GET_OPCODE(i)) && GETARG_B(i) == 0) -LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ +#define opmode(mm,ot,it,t,a,m) \ + (((mm) << 7) | ((ot) << 6) | ((it) << 5) | ((t) << 4) | ((a) << 3) | (m)) /* number of list items to accumulate before a SETLIST instruction */ #define LFIELDS_PER_FLUSH 50 - #endif diff --git a/liblua/lopnames.h b/liblua/lopnames.h new file mode 100644 index 00000000..965cec9b --- /dev/null +++ b/liblua/lopnames.h @@ -0,0 +1,103 @@ +/* +** $Id: lopnames.h $ +** Opcode names +** See Copyright Notice in lua.h +*/ + +#if !defined(lopnames_h) +#define lopnames_h + +#include + + +/* ORDER OP */ + +static const char *const opnames[] = { + "MOVE", + "LOADI", + "LOADF", + "LOADK", + "LOADKX", + "LOADFALSE", + "LFALSESKIP", + "LOADTRUE", + "LOADNIL", + "GETUPVAL", + "SETUPVAL", + "GETTABUP", + "GETTABLE", + "GETI", + "GETFIELD", + "SETTABUP", + "SETTABLE", + "SETI", + "SETFIELD", + "NEWTABLE", + "SELF", + "ADDI", + "ADDK", + "SUBK", + "MULK", + "MODK", + "POWK", + "DIVK", + "IDIVK", + "BANDK", + "BORK", + "BXORK", + "SHRI", + "SHLI", + "ADD", + "SUB", + "MUL", + "MOD", + "POW", + "DIV", + "IDIV", + "BAND", + "BOR", + "BXOR", + "SHL", + "SHR", + "MMBIN", + "MMBINI", + "MMBINK", + "UNM", + "BNOT", + "NOT", + "LEN", + "CONCAT", + "CLOSE", + "TBC", + "JMP", + "EQ", + "LT", + "LE", + "EQK", + "EQI", + "LTI", + "LEI", + "GTI", + "GEI", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "RETURN0", + "RETURN1", + "FORLOOP", + "FORPREP", + "TFORPREP", + "TFORCALL", + "TFORLOOP", + "SETLIST", + "CLOSURE", + "VARARG", + "VARARGPREP", + "EXTRAARG", + NULL +}; + +#endif + diff --git a/liblua/loslib.c b/liblua/loslib.c index 5caff42d..4cf1500c 100644 --- a/liblua/loslib.c +++ b/liblua/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.65.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: loslib.c $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -30,23 +30,14 @@ */ #if !defined(LUA_STRFTIMEOPTIONS) /* { */ -/* options for ANSI C 89 (only 1-char options) */ -#define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%" - -/* options for ISO C 99 and POSIX */ -#define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ - "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */ - -/* options for Windows */ -#define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \ - "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */ - #if defined(LUA_USE_WINDOWS) -#define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN -#elif defined(LUA_USE_C89) -#define LUA_STRFTIMEOPTIONS L_STRFTIMEC89 +#define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYzZ%" \ + "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */ +#elif defined(LUA_USE_C89) /* ANSI C 89 (only 1-char options) */ +#define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYZ%" #else /* C99 specification */ -#define LUA_STRFTIMEOPTIONS L_STRFTIMEC99 +#define LUA_STRFTIMEOPTIONS "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ + "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */ #endif #endif /* } */ @@ -59,18 +50,20 @@ ** =================================================================== */ -#if !defined(l_time_t) /* { */ /* ** type to represent time_t in Lua */ +#if !defined(LUA_NUMTIME) /* { */ + #define l_timet lua_Integer #define l_pushtime(L,t) lua_pushinteger(L,(lua_Integer)(t)) +#define l_gettime(L,arg) luaL_checkinteger(L, arg) -static time_t l_checktime (lua_State *L, int arg) { - lua_Integer t = luaL_checkinteger(L, arg); - luaL_argcheck(L, (time_t)t == t, arg, "time out-of-bounds"); - return (time_t)t; -} +#else /* }{ */ + +#define l_timet lua_Number +#define l_pushtime(L,t) lua_pushnumber(L,(lua_Number)(t)) +#define l_gettime(L,arg) luaL_checknumber(L, arg) #endif /* } */ @@ -90,7 +83,7 @@ static time_t l_checktime (lua_State *L, int arg) { /* ISO C definitions */ #define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t)) -#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) +#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) #endif /* } */ @@ -136,11 +129,21 @@ static time_t l_checktime (lua_State *L, int arg) { /* }================================================================== */ +#if !defined(l_system) +#if defined(LUA_USE_IOS) +/* Despite claiming to be ISO C, iOS does not implement 'system'. */ +#define l_system(cmd) ((cmd) == NULL ? 0 : -1) +#else +#define l_system(cmd) system(cmd) /* default definition */ +#endif +#endif static int os_execute (lua_State *L) { const char *cmd = luaL_optstring(L, 1, NULL); - int stat = system(cmd); + int stat; + errno = 0; + stat = l_system(cmd); if (cmd != NULL) return luaL_execresult(L, stat); else { @@ -152,6 +155,7 @@ static int os_execute (lua_State *L) { static int os_remove (lua_State *L) { const char *filename = luaL_checkstring(L, 1); + errno = 0; return luaL_fileresult(L, remove(filename) == 0, filename); } @@ -159,6 +163,7 @@ static int os_remove (lua_State *L) { static int os_rename (lua_State *L) { const char *fromname = luaL_checkstring(L, 1); const char *toname = luaL_checkstring(L, 2); + errno = 0; return luaL_fileresult(L, rename(fromname, toname) == 0, NULL); } @@ -167,7 +172,7 @@ static int os_tmpname (lua_State *L) { char buff[LUA_TMPNAMBUFSIZE]; int err; lua_tmpnam(buff, err); - if (err) + if (l_unlikely(err)) return luaL_error(L, "unable to generate a unique filename"); lua_pushstring(L, buff); return 1; @@ -200,11 +205,25 @@ static int os_clock (lua_State *L) { ** ======================================================= */ -static void setfield (lua_State *L, const char *key, int value) { - lua_pushinteger(L, value); +/* +** About the overflow check: an overflow cannot occur when time +** is represented by a lua_Integer, because either lua_Integer is +** large enough to represent all int fields or it is not large enough +** to represent a time that cause a field to overflow. However, if +** times are represented as doubles and lua_Integer is int, then the +** time 0x1.e1853b0d184f6p+55 would cause an overflow when adding 1900 +** to compute the year. +*/ +static void setfield (lua_State *L, const char *key, int value, int delta) { + #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX) + if (l_unlikely(value > LUA_MAXINTEGER - delta)) + luaL_error(L, "field '%s' is out-of-bound", key); + #endif + lua_pushinteger(L, (lua_Integer)value + delta); lua_setfield(L, -2, key); } + static void setboolfield (lua_State *L, const char *key, int value) { if (value < 0) /* undefined? */ return; /* does not set field */ @@ -217,14 +236,14 @@ static void setboolfield (lua_State *L, const char *key, int value) { ** Set all fields from structure 'tm' in the table on top of the stack */ static void setallfields (lua_State *L, struct tm *stm) { - setfield(L, "sec", stm->tm_sec); - setfield(L, "min", stm->tm_min); - setfield(L, "hour", stm->tm_hour); - setfield(L, "day", stm->tm_mday); - setfield(L, "month", stm->tm_mon + 1); - setfield(L, "year", stm->tm_year + 1900); - setfield(L, "wday", stm->tm_wday + 1); - setfield(L, "yday", stm->tm_yday + 1); + setfield(L, "year", stm->tm_year, 1900); + setfield(L, "month", stm->tm_mon, 1); + setfield(L, "day", stm->tm_mday, 0); + setfield(L, "hour", stm->tm_hour, 0); + setfield(L, "min", stm->tm_min, 0); + setfield(L, "sec", stm->tm_sec, 0); + setfield(L, "yday", stm->tm_yday, 1); + setfield(L, "wday", stm->tm_wday, 1); setboolfield(L, "isdst", stm->tm_isdst); } @@ -237,24 +256,19 @@ static int getboolfield (lua_State *L, const char *key) { } -/* maximum value for date fields (to avoid arithmetic overflows with 'int') */ -#if !defined(L_MAXDATEFIELD) -#define L_MAXDATEFIELD (INT_MAX / 2) -#endif - static int getfield (lua_State *L, const char *key, int d, int delta) { int isnum; int t = lua_getfield(L, -1, key); /* get field and its type */ lua_Integer res = lua_tointegerx(L, -1, &isnum); if (!isnum) { /* field is not an integer? */ - if (t != LUA_TNIL) /* some other value? */ + if (l_unlikely(t != LUA_TNIL)) /* some other value? */ return luaL_error(L, "field '%s' is not an integer", key); - else if (d < 0) /* absent field; no default? */ + else if (l_unlikely(d < 0)) /* absent field; no default? */ return luaL_error(L, "field '%s' missing in date table", key); res = d; } else { - if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) + if (!(res >= 0 ? res - delta <= INT_MAX : INT_MIN + delta <= res)) return luaL_error(L, "field '%s' is out-of-bound", key); res -= delta; } @@ -282,6 +296,13 @@ static const char *checkoption (lua_State *L, const char *conv, } +static time_t l_checktime (lua_State *L, int arg) { + l_timet t = l_gettime(L, arg); + luaL_argcheck(L, (time_t)t == t, arg, "time out-of-bounds"); + return (time_t)t; +} + + /* maximum size for an individual 'strftime' item */ #define SIZETIMEFMT 250 @@ -300,7 +321,7 @@ static int os_date (lua_State *L) { stm = l_localtime(&t, &tmr); if (stm == NULL) /* invalid date? */ return luaL_error(L, - "time result cannot be represented in this installation"); + "date result cannot be represented in this installation"); if (strcmp(s, "*t") == 0) { lua_createtable(L, 0, 9); /* 9 = number of fields */ setallfields(L, stm); @@ -336,12 +357,12 @@ static int os_time (lua_State *L) { struct tm ts; luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ - ts.tm_sec = getfield(L, "sec", 0, 0); - ts.tm_min = getfield(L, "min", 0, 0); - ts.tm_hour = getfield(L, "hour", 12, 0); - ts.tm_mday = getfield(L, "day", -1, 0); - ts.tm_mon = getfield(L, "month", -1, 1); ts.tm_year = getfield(L, "year", -1, 1900); + ts.tm_mon = getfield(L, "month", -1, 1); + ts.tm_mday = getfield(L, "day", -1, 0); + ts.tm_hour = getfield(L, "hour", 12, 0); + ts.tm_min = getfield(L, "min", 0, 0); + ts.tm_sec = getfield(L, "sec", 0, 0); ts.tm_isdst = getboolfield(L, "isdst"); t = mktime(&ts); setallfields(L, &ts); /* update fields with normalized values */ diff --git a/liblua/lparser.c b/liblua/lparser.c index cc54de43..2b888c7c 100644 --- a/liblua/lparser.c +++ b/liblua/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.155.1.2 2017/04/29 18:11:40 roberto Exp $ +** $Id: lparser.c $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -10,6 +10,7 @@ #include "lprefix.h" +#include #include #include "lua.h" @@ -52,6 +53,7 @@ typedef struct BlockCnt { lu_byte nactvar; /* # active locals outside the block */ lu_byte upval; /* true if some variable in the block is an upvalue */ lu_byte isloop; /* true if 'block' is a loop */ + lu_byte insidetbc; /* true if inside the scope of a to-be-closed var. */ } BlockCnt; @@ -63,13 +65,6 @@ static void statement (LexState *ls); static void expr (LexState *ls, expdesc *v); -/* semantic error */ -static l_noret semerror (LexState *ls, const char *msg) { - ls->t.token = 0; /* remove "near " from final message */ - luaX_syntaxerror(ls, msg); -} - - static l_noret error_expected (LexState *ls, int token) { luaX_syntaxerror(ls, luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); @@ -94,6 +89,9 @@ static void checklimit (FuncState *fs, int v, int l, const char *what) { } +/* +** Test whether next token is 'c'; if so, skip it. +*/ static int testnext (LexState *ls, int c) { if (ls->t.token == c) { luaX_next(ls); @@ -103,12 +101,18 @@ static int testnext (LexState *ls, int c) { } +/* +** Check that next token is 'c'. +*/ static void check (LexState *ls, int c) { if (ls->t.token != c) error_expected(ls, c); } +/* +** Check that next token is 'c' and skip it. +*/ static void checknext (LexState *ls, int c) { check(ls, c); luaX_next(ls); @@ -118,11 +122,15 @@ static void checknext (LexState *ls, int c) { #define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } - +/* +** Check that next token is 'what' and skip it. In case of error, +** raise an error that the expected 'what' should match a 'who' +** in line 'where' (if that is not the current line). +*/ static void check_match (LexState *ls, int what, int who, int where) { - if (!testnext(ls, what)) { - if (where == ls->linenumber) - error_expected(ls, what); + if (l_unlikely(!testnext(ls, what))) { + if (where == ls->linenumber) /* all in the same line? */ + error_expected(ls, what); /* do not need a complex message */ else { luaX_syntaxerror(ls, luaO_pushfstring(ls->L, "%s expected (to close %s at line %d)", @@ -148,73 +156,189 @@ static void init_exp (expdesc *e, expkind k, int i) { } -static void codestring (LexState *ls, expdesc *e, TString *s) { - init_exp(e, VK, luaK_stringK(ls->fs, s)); +static void codestring (expdesc *e, TString *s) { + e->f = e->t = NO_JUMP; + e->k = VKSTR; + e->u.strval = s; } -static void checkname (LexState *ls, expdesc *e) { - codestring(ls, e, str_checkname(ls)); +static void codename (LexState *ls, expdesc *e) { + codestring(e, str_checkname(ls)); } -static int registerlocalvar (LexState *ls, TString *varname) { - FuncState *fs = ls->fs; +/* +** Register a new local variable in the active 'Proto' (for debug +** information). +*/ +static int registerlocalvar (LexState *ls, FuncState *fs, TString *varname) { Proto *f = fs->f; int oldsize = f->sizelocvars; - luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + luaM_growvector(ls->L, f->locvars, fs->ndebugvars, f->sizelocvars, LocVar, SHRT_MAX, "local variables"); while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; - f->locvars[fs->nlocvars].varname = varname; + f->locvars[fs->ndebugvars].varname = varname; + f->locvars[fs->ndebugvars].startpc = fs->pc; luaC_objbarrier(ls->L, f, varname); - return fs->nlocvars++; + return fs->ndebugvars++; } -static void new_localvar (LexState *ls, TString *name) { +/* +** Create a new local variable with the given 'name'. Return its index +** in the function. +*/ +static int new_localvar (LexState *ls, TString *name) { + lua_State *L = ls->L; FuncState *fs = ls->fs; Dyndata *dyd = ls->dyd; - int reg = registerlocalvar(ls, name); + Vardesc *var; checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, - MAXVARS, "local variables"); - luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1, - dyd->actvar.size, Vardesc, MAX_INT, "local variables"); - dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg); + MAXVARS, "local variables"); + luaM_growvector(L, dyd->actvar.arr, dyd->actvar.n + 1, + dyd->actvar.size, Vardesc, USHRT_MAX, "local variables"); + var = &dyd->actvar.arr[dyd->actvar.n++]; + var->vd.kind = VDKREG; /* default */ + var->vd.name = name; + return dyd->actvar.n - 1 - fs->firstlocal; } +#define new_localvarliteral(ls,v) \ + new_localvar(ls, \ + luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char)) - 1)); + -static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) { - new_localvar(ls, luaX_newstring(ls, name, sz)); + +/* +** Return the "variable description" (Vardesc) of a given variable. +** (Unless noted otherwise, all variables are referred to by their +** compiler indices.) +*/ +static Vardesc *getlocalvardesc (FuncState *fs, int vidx) { + return &fs->ls->dyd->actvar.arr[fs->firstlocal + vidx]; } -#define new_localvarliteral(ls,v) \ - new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1) + +/* +** Convert 'nvar', a compiler index level, to its corresponding +** register. For that, search for the highest variable below that level +** that is in a register and uses its register index ('ridx') plus one. +*/ +static int reglevel (FuncState *fs, int nvar) { + while (nvar-- > 0) { + Vardesc *vd = getlocalvardesc(fs, nvar); /* get previous variable */ + if (vd->vd.kind != RDKCTC) /* is in a register? */ + return vd->vd.ridx + 1; + } + return 0; /* no variables in registers */ +} + + +/* +** Return the number of variables in the register stack for the given +** function. +*/ +int luaY_nvarstack (FuncState *fs) { + return reglevel(fs, fs->nactvar); +} -static LocVar *getlocvar (FuncState *fs, int i) { - int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx; - lua_assert(idx < fs->nlocvars); - return &fs->f->locvars[idx]; +/* +** Get the debug-information entry for current variable 'vidx'. +*/ +static LocVar *localdebuginfo (FuncState *fs, int vidx) { + Vardesc *vd = getlocalvardesc(fs, vidx); + if (vd->vd.kind == RDKCTC) + return NULL; /* no debug info. for constants */ + else { + int idx = vd->vd.pidx; + lua_assert(idx < fs->ndebugvars); + return &fs->f->locvars[idx]; + } } +/* +** Create an expression representing variable 'vidx' +*/ +static void init_var (FuncState *fs, expdesc *e, int vidx) { + e->f = e->t = NO_JUMP; + e->k = VLOCAL; + e->u.var.vidx = vidx; + e->u.var.ridx = getlocalvardesc(fs, vidx)->vd.ridx; +} + + +/* +** Raises an error if variable described by 'e' is read only +*/ +static void check_readonly (LexState *ls, expdesc *e) { + FuncState *fs = ls->fs; + TString *varname = NULL; /* to be set if variable is const */ + switch (e->k) { + case VCONST: { + varname = ls->dyd->actvar.arr[e->u.info].vd.name; + break; + } + case VLOCAL: { + Vardesc *vardesc = getlocalvardesc(fs, e->u.var.vidx); + if (vardesc->vd.kind != VDKREG) /* not a regular variable? */ + varname = vardesc->vd.name; + break; + } + case VUPVAL: { + Upvaldesc *up = &fs->f->upvalues[e->u.info]; + if (up->kind != VDKREG) + varname = up->name; + break; + } + default: + return; /* other cases cannot be read-only */ + } + if (varname) { + const char *msg = luaO_pushfstring(ls->L, + "attempt to assign to const variable '%s'", getstr(varname)); + luaK_semerror(ls, msg); /* error */ + } +} + + +/* +** Start the scope for the last 'nvars' created variables. +*/ static void adjustlocalvars (LexState *ls, int nvars) { FuncState *fs = ls->fs; - fs->nactvar = cast_byte(fs->nactvar + nvars); - for (; nvars; nvars--) { - getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc; + int reglevel = luaY_nvarstack(fs); + int i; + for (i = 0; i < nvars; i++) { + int vidx = fs->nactvar++; + Vardesc *var = getlocalvardesc(fs, vidx); + var->vd.ridx = reglevel++; + var->vd.pidx = registerlocalvar(ls, fs, var->vd.name); } } +/* +** Close the scope for all variables up to level 'tolevel'. +** (debug info.) +*/ static void removevars (FuncState *fs, int tolevel) { fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel); - while (fs->nactvar > tolevel) - getlocvar(fs, --fs->nactvar)->endpc = fs->pc; + while (fs->nactvar > tolevel) { + LocVar *var = localdebuginfo(fs, --fs->nactvar); + if (var) /* does it have debug information? */ + var->endpc = fs->pc; + } } +/* +** Search the upvalues of the function 'fs' for one +** with the given 'name'. +*/ static int searchupvalue (FuncState *fs, TString *name) { int i; Upvaldesc *up = fs->f->upvalues; @@ -225,7 +349,7 @@ static int searchupvalue (FuncState *fs, TString *name) { } -static int newupvalue (FuncState *fs, TString *name, expdesc *v) { +static Upvaldesc *allocupvalue (FuncState *fs) { Proto *f = fs->f; int oldsize = f->sizeupvalues; checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); @@ -233,58 +357,98 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) { Upvaldesc, MAXUPVAL, "upvalues"); while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; - f->upvalues[fs->nups].instack = (v->k == VLOCAL); - f->upvalues[fs->nups].idx = cast_byte(v->u.info); - f->upvalues[fs->nups].name = name; - luaC_objbarrier(fs->ls->L, f, name); - return fs->nups++; + return &f->upvalues[fs->nups++]; } -static int searchvar (FuncState *fs, TString *n) { +static int newupvalue (FuncState *fs, TString *name, expdesc *v) { + Upvaldesc *up = allocupvalue(fs); + FuncState *prev = fs->prev; + if (v->k == VLOCAL) { + up->instack = 1; + up->idx = v->u.var.ridx; + up->kind = getlocalvardesc(prev, v->u.var.vidx)->vd.kind; + lua_assert(eqstr(name, getlocalvardesc(prev, v->u.var.vidx)->vd.name)); + } + else { + up->instack = 0; + up->idx = cast_byte(v->u.info); + up->kind = prev->f->upvalues[v->u.info].kind; + lua_assert(eqstr(name, prev->f->upvalues[v->u.info].name)); + } + up->name = name; + luaC_objbarrier(fs->ls->L, fs->f, name); + return fs->nups - 1; +} + + +/* +** Look for an active local variable with the name 'n' in the +** function 'fs'. If found, initialize 'var' with it and return +** its expression kind; otherwise return -1. +*/ +static int searchvar (FuncState *fs, TString *n, expdesc *var) { int i; for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) { - if (eqstr(n, getlocvar(fs, i)->varname)) - return i; + Vardesc *vd = getlocalvardesc(fs, i); + if (eqstr(n, vd->vd.name)) { /* found? */ + if (vd->vd.kind == RDKCTC) /* compile-time constant? */ + init_exp(var, VCONST, fs->firstlocal + i); + else /* real variable */ + init_var(fs, var, i); + return var->k; + } } return -1; /* not found */ } /* - Mark block where variable at given level was defined - (to emit close instructions later). +** Mark block where variable at given level was defined +** (to emit close instructions later). */ static void markupval (FuncState *fs, int level) { BlockCnt *bl = fs->bl; while (bl->nactvar > level) bl = bl->previous; bl->upval = 1; + fs->needclose = 1; } /* - Find variable with given name 'n'. If it is an upvalue, add this - upvalue into all intermediate functions. +** Mark that current block has a to-be-closed variable. +*/ +static void marktobeclosed (FuncState *fs) { + BlockCnt *bl = fs->bl; + bl->upval = 1; + bl->insidetbc = 1; + fs->needclose = 1; +} + + +/* +** Find a variable with the given name 'n'. If it is an upvalue, add +** this upvalue into all intermediate functions. If it is a global, set +** 'var' as 'void' as a flag. */ static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { if (fs == NULL) /* no more levels? */ init_exp(var, VVOID, 0); /* default is global */ else { - int v = searchvar(fs, n); /* look up locals at current level */ + int v = searchvar(fs, n, var); /* look up locals at current level */ if (v >= 0) { /* found? */ - init_exp(var, VLOCAL, v); /* variable is local */ - if (!base) - markupval(fs, v); /* local will be used as an upval */ + if (v == VLOCAL && !base) + markupval(fs, var->u.var.vidx); /* local will be used as an upval */ } else { /* not found as local at current level; try upvalues */ int idx = searchupvalue(fs, n); /* try existing upvalues */ if (idx < 0) { /* not found? */ singlevaraux(fs->prev, n, var, 0); /* try upper levels */ - if (var->k == VVOID) /* not found? */ - return; /* it is a global */ - /* else was LOCAL or UPVAL */ - idx = newupvalue(fs, n, var); /* will be a new upvalue */ + if (var->k == VLOCAL || var->k == VUPVAL) /* local or upvalue? */ + idx = newupvalue(fs, n, var); /* will be a new upvalue */ + else /* it is a global or a constant */ + return; /* don't need to do anything at this level */ } init_exp(var, VUPVAL, idx); /* new or old upvalue */ } @@ -292,6 +456,10 @@ static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { } +/* +** Find a variable with the given name 'n', handling global variables +** too. +*/ static void singlevar (LexState *ls, expdesc *var) { TString *varname = str_checkname(ls); FuncState *fs = ls->fs; @@ -300,88 +468,95 @@ static void singlevar (LexState *ls, expdesc *var) { expdesc key; singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ lua_assert(var->k != VVOID); /* this one must exist */ - codestring(ls, &key, varname); /* key is variable name */ + luaK_exp2anyregup(fs, var); /* but could be a constant */ + codestring(&key, varname); /* key is variable name */ luaK_indexed(fs, var, &key); /* env[varname] */ } } +/* +** Adjust the number of results from an expression list 'e' with 'nexps' +** expressions to 'nvars' values. +*/ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { FuncState *fs = ls->fs; - int extra = nvars - nexps; - if (hasmultret(e->k)) { - extra++; /* includes call itself */ - if (extra < 0) extra = 0; + int needed = nvars - nexps; /* extra values needed */ + if (hasmultret(e->k)) { /* last expression has multiple returns? */ + int extra = needed + 1; /* discount last expression itself */ + if (extra < 0) + extra = 0; luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ - if (extra > 1) luaK_reserveregs(fs, extra-1); } else { - if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ - if (extra > 0) { - int reg = fs->freereg; - luaK_reserveregs(fs, extra); - luaK_nil(fs, reg, extra); - } + if (e->k != VVOID) /* at least one expression? */ + luaK_exp2nextreg(fs, e); /* close last expression */ + if (needed > 0) /* missing values? */ + luaK_nil(fs, fs->freereg, needed); /* complete with nils */ } - if (nexps > nvars) - ls->fs->freereg -= nexps - nvars; /* remove extra values */ + if (needed > 0) + luaK_reserveregs(fs, needed); /* registers for extra values */ + else /* adding 'needed' is actually a subtraction */ + fs->freereg += needed; /* remove extra values */ } -static void enterlevel (LexState *ls) { - lua_State *L = ls->L; - ++L->nCcalls; - checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels"); -} +#define enterlevel(ls) luaE_incCstack(ls->L) + +#define leavelevel(ls) ((ls)->L->nCcalls--) -#define leavelevel(ls) ((ls)->L->nCcalls--) + +/* +** Generates an error that a goto jumps into the scope of some +** local variable. +*/ +static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) { + const char *varname = getstr(getlocalvardesc(ls->fs, gt->nactvar)->vd.name); + const char *msg = " at line %d jumps into the scope of local '%s'"; + msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line, varname); + luaK_semerror(ls, msg); /* raise the error */ +} -static void closegoto (LexState *ls, int g, Labeldesc *label) { +/* +** Solves the goto at index 'g' to given 'label' and removes it +** from the list of pending gotos. +** If it jumps into the scope of some variable, raises an error. +*/ +static void solvegoto (LexState *ls, int g, Labeldesc *label) { int i; - FuncState *fs = ls->fs; - Labellist *gl = &ls->dyd->gt; - Labeldesc *gt = &gl->arr[g]; + Labellist *gl = &ls->dyd->gt; /* list of gotos */ + Labeldesc *gt = &gl->arr[g]; /* goto to be resolved */ lua_assert(eqstr(gt->name, label->name)); - if (gt->nactvar < label->nactvar) { - TString *vname = getlocvar(fs, gt->nactvar)->varname; - const char *msg = luaO_pushfstring(ls->L, - " at line %d jumps into the scope of local '%s'", - getstr(gt->name), gt->line, getstr(vname)); - semerror(ls, msg); - } - luaK_patchlist(fs, gt->pc, label->pc); - /* remove goto from pending list */ - for (i = g; i < gl->n - 1; i++) + if (l_unlikely(gt->nactvar < label->nactvar)) /* enter some scope? */ + jumpscopeerror(ls, gt); + luaK_patchlist(ls->fs, gt->pc, label->pc); + for (i = g; i < gl->n - 1; i++) /* remove goto from pending list */ gl->arr[i] = gl->arr[i + 1]; gl->n--; } /* -** try to close a goto with existing labels; this solves backward jumps +** Search for an active label with the given name. */ -static int findlabel (LexState *ls, int g) { +static Labeldesc *findlabel (LexState *ls, TString *name) { int i; - BlockCnt *bl = ls->fs->bl; Dyndata *dyd = ls->dyd; - Labeldesc *gt = &dyd->gt.arr[g]; - /* check labels in current block for a match */ - for (i = bl->firstlabel; i < dyd->label.n; i++) { + /* check labels in current function for a match */ + for (i = ls->fs->firstlabel; i < dyd->label.n; i++) { Labeldesc *lb = &dyd->label.arr[i]; - if (eqstr(lb->name, gt->name)) { /* correct label? */ - if (gt->nactvar > lb->nactvar && - (bl->upval || dyd->label.n > bl->firstlabel)) - luaK_patchclose(ls->fs, gt->pc, lb->nactvar); - closegoto(ls, g, lb); /* close it */ - return 1; - } + if (eqstr(lb->name, name)) /* correct label? */ + return lb; } - return 0; /* label not found; cannot close goto */ + return NULL; /* label not found */ } +/* +** Adds a new label/goto in the corresponding list. +*/ static int newlabelentry (LexState *ls, Labellist *l, TString *name, int line, int pc) { int n = l->n; @@ -390,48 +565,76 @@ static int newlabelentry (LexState *ls, Labellist *l, TString *name, l->arr[n].name = name; l->arr[n].line = line; l->arr[n].nactvar = ls->fs->nactvar; + l->arr[n].close = 0; l->arr[n].pc = pc; l->n = n + 1; return n; } +static int newgotoentry (LexState *ls, TString *name, int line, int pc) { + return newlabelentry(ls, &ls->dyd->gt, name, line, pc); +} + + /* -** check whether new label 'lb' matches any pending gotos in current -** block; solves forward jumps +** Solves forward jumps. Check whether new label 'lb' matches any +** pending gotos in current block and solves them. Return true +** if any of the gotos need to close upvalues. */ -static void findgotos (LexState *ls, Labeldesc *lb) { +static int solvegotos (LexState *ls, Labeldesc *lb) { Labellist *gl = &ls->dyd->gt; int i = ls->fs->bl->firstgoto; + int needsclose = 0; while (i < gl->n) { - if (eqstr(gl->arr[i].name, lb->name)) - closegoto(ls, i, lb); + if (eqstr(gl->arr[i].name, lb->name)) { + needsclose |= gl->arr[i].close; + solvegoto(ls, i, lb); /* will remove 'i' from the list */ + } else i++; } + return needsclose; } /* -** export pending gotos to outer level, to check them against -** outer labels; if the block being exited has upvalues, and -** the goto exits the scope of any variable (which can be the -** upvalue), close those variables being exited. +** Create a new label with the given 'name' at the given 'line'. +** 'last' tells whether label is the last non-op statement in its +** block. Solves all pending gotos to this new label and adds +** a close instruction if necessary. +** Returns true iff it added a close instruction. +*/ +static int createlabel (LexState *ls, TString *name, int line, + int last) { + FuncState *fs = ls->fs; + Labellist *ll = &ls->dyd->label; + int l = newlabelentry(ls, ll, name, line, luaK_getlabel(fs)); + if (last) { /* label is last no-op statement in the block? */ + /* assume that locals are already out of scope */ + ll->arr[l].nactvar = fs->bl->nactvar; + } + if (solvegotos(ls, &ll->arr[l])) { /* need close? */ + luaK_codeABC(fs, OP_CLOSE, luaY_nvarstack(fs), 0, 0); + return 1; + } + return 0; +} + + +/* +** Adjust pending gotos to outer level of a block. */ static void movegotosout (FuncState *fs, BlockCnt *bl) { - int i = bl->firstgoto; + int i; Labellist *gl = &fs->ls->dyd->gt; - /* correct pending gotos to current block and try to close it - with visible labels */ - while (i < gl->n) { + /* correct pending gotos to current block */ + for (i = bl->firstgoto; i < gl->n; i++) { /* for each pending goto */ Labeldesc *gt = &gl->arr[i]; - if (gt->nactvar > bl->nactvar) { - if (bl->upval) - luaK_patchclose(fs, gt->pc, bl->nactvar); - gt->nactvar = bl->nactvar; - } - if (!findlabel(fs->ls, i)) - i++; /* move to next one */ + /* leaving a variable scope? */ + if (reglevel(fs, gt->nactvar) > reglevel(fs, bl->nactvar)) + gt->close |= bl->upval; /* jump may need a close */ + gt->nactvar = bl->nactvar; /* update goto level */ } } @@ -442,54 +645,50 @@ static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { bl->firstlabel = fs->ls->dyd->label.n; bl->firstgoto = fs->ls->dyd->gt.n; bl->upval = 0; + bl->insidetbc = (fs->bl != NULL && fs->bl->insidetbc); bl->previous = fs->bl; fs->bl = bl; - lua_assert(fs->freereg == fs->nactvar); + lua_assert(fs->freereg == luaY_nvarstack(fs)); } /* -** create a label named 'break' to resolve break statements -*/ -static void breaklabel (LexState *ls) { - TString *n = luaS_new(ls->L, "break"); - int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc); - findgotos(ls, &ls->dyd->label.arr[l]); -} - -/* -** generates an error for an undefined 'goto'; choose appropriate -** message when label name is a reserved word (which can only be 'break') +** generates an error for an undefined 'goto'. */ static l_noret undefgoto (LexState *ls, Labeldesc *gt) { - const char *msg = isreserved(gt->name) - ? "<%s> at line %d not inside a loop" - : "no visible label '%s' for at line %d"; - msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); - semerror(ls, msg); + const char *msg; + if (eqstr(gt->name, luaS_newliteral(ls->L, "break"))) { + msg = "break outside loop at line %d"; + msg = luaO_pushfstring(ls->L, msg, gt->line); + } + else { + msg = "no visible label '%s' for at line %d"; + msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); + } + luaK_semerror(ls, msg); } static void leaveblock (FuncState *fs) { BlockCnt *bl = fs->bl; LexState *ls = fs->ls; - if (bl->previous && bl->upval) { - /* create a 'jump to here' to close upvalues */ - int j = luaK_jump(fs); - luaK_patchclose(fs, j, bl->nactvar); - luaK_patchtohere(fs, j); - } - if (bl->isloop) - breaklabel(ls); /* close pending breaks */ - fs->bl = bl->previous; - removevars(fs, bl->nactvar); - lua_assert(bl->nactvar == fs->nactvar); - fs->freereg = fs->nactvar; /* free registers */ + int hasclose = 0; + int stklevel = reglevel(fs, bl->nactvar); /* level outside the block */ + removevars(fs, bl->nactvar); /* remove block locals */ + lua_assert(bl->nactvar == fs->nactvar); /* back to level on entry */ + if (bl->isloop) /* has to fix pending breaks? */ + hasclose = createlabel(ls, luaS_newliteral(ls->L, "break"), 0, 0); + if (!hasclose && bl->previous && bl->upval) /* still need a 'close'? */ + luaK_codeABC(fs, OP_CLOSE, stklevel, 0, 0); + fs->freereg = stklevel; /* free registers */ ls->dyd->label.n = bl->firstlabel; /* remove local labels */ - if (bl->previous) /* inner block? */ - movegotosout(fs, bl); /* update pending gotos to outer block */ - else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ - undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ + fs->bl = bl->previous; /* current block now is previous one */ + if (bl->previous) /* was it a nested block? */ + movegotosout(fs, bl); /* update pending gotos to enclosing block */ + else { + if (bl->firstgoto < ls->dyd->gt.n) /* still pending gotos? */ + undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ + } } @@ -515,35 +714,40 @@ static Proto *addprototype (LexState *ls) { /* ** codes instruction to create new closure in parent function. -** The OP_CLOSURE instruction must use the last available register, +** The OP_CLOSURE instruction uses the last available register, ** so that, if it invokes the GC, the GC knows which registers ** are in use at that time. + */ static void codeclosure (LexState *ls, expdesc *v) { FuncState *fs = ls->fs->prev; - init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); + init_exp(v, VRELOC, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); luaK_exp2nextreg(fs, v); /* fix it at the last register */ } static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { - Proto *f; + Proto *f = fs->f; fs->prev = ls->fs; /* linked list of funcstates */ fs->ls = ls; ls->fs = fs; fs->pc = 0; + fs->previousline = f->linedefined; + fs->iwthabs = 0; fs->lasttarget = 0; - fs->jpc = NO_JUMP; fs->freereg = 0; fs->nk = 0; + fs->nabslineinfo = 0; fs->np = 0; fs->nups = 0; - fs->nlocvars = 0; + fs->ndebugvars = 0; fs->nactvar = 0; + fs->needclose = 0; fs->firstlocal = ls->dyd->actvar.n; + fs->firstlabel = ls->dyd->label.n; fs->bl = NULL; - f = fs->f; f->source = ls->source; + luaC_objbarrier(ls->L, f, f->source); f->maxstacksize = 2; /* registers 0/1 are always valid */ enterblock(fs, bl, 0); } @@ -553,21 +757,18 @@ static void close_func (LexState *ls) { lua_State *L = ls->L; FuncState *fs = ls->fs; Proto *f = fs->f; - luaK_ret(fs, 0, 0); /* final return */ + luaK_ret(fs, luaY_nvarstack(fs), 0); /* final return */ leaveblock(fs); - luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); - f->sizecode = fs->pc; - luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); - f->sizelineinfo = fs->pc; - luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); - f->sizek = fs->nk; - luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); - f->sizep = fs->np; - luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); - f->sizelocvars = fs->nlocvars; - luaM_reallocvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc); - f->sizeupvalues = fs->nups; lua_assert(fs->bl == NULL); + luaK_finish(fs); + luaM_shrinkvector(L, f->code, f->sizecode, fs->pc, Instruction); + luaM_shrinkvector(L, f->lineinfo, f->sizelineinfo, fs->pc, ls_byte); + luaM_shrinkvector(L, f->abslineinfo, f->sizeabslineinfo, + fs->nabslineinfo, AbsLineInfo); + luaM_shrinkvector(L, f->k, f->sizek, fs->nk, TValue); + luaM_shrinkvector(L, f->p, f->sizep, fs->np, Proto *); + luaM_shrinkvector(L, f->locvars, f->sizelocvars, fs->ndebugvars, LocVar); + luaM_shrinkvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc); ls->fs = fs->prev; luaC_checkGC(L); } @@ -613,7 +814,7 @@ static void fieldsel (LexState *ls, expdesc *v) { expdesc key; luaK_exp2anyregup(fs, v); luaX_next(ls); /* skip the dot or colon */ - checkname(ls, &key); + codename(ls, &key); luaK_indexed(fs, v, &key); } @@ -634,48 +835,49 @@ static void yindex (LexState *ls, expdesc *v) { */ -struct ConsControl { +typedef struct ConsControl { expdesc v; /* last list item read */ expdesc *t; /* table descriptor */ int nh; /* total number of 'record' elements */ - int na; /* total number of array elements */ + int na; /* number of array elements already stored */ int tostore; /* number of array elements pending to be stored */ -}; +} ConsControl; -static void recfield (LexState *ls, struct ConsControl *cc) { - /* recfield -> (NAME | '['exp1']') = exp1 */ +static void recfield (LexState *ls, ConsControl *cc) { + /* recfield -> (NAME | '['exp']') = exp */ FuncState *fs = ls->fs; int reg = ls->fs->freereg; - expdesc key, val; - int rkkey; + expdesc tab, key, val; if (ls->t.token == TK_NAME) { checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); - checkname(ls, &key); + codename(ls, &key); } else /* ls->t.token == '[' */ yindex(ls, &key); cc->nh++; checknext(ls, '='); - rkkey = luaK_exp2RK(fs, &key); + tab = *cc->t; + luaK_indexed(fs, &tab, &key); expr(ls, &val); - luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val)); + luaK_storevar(fs, &tab, &val); fs->freereg = reg; /* free registers */ } -static void closelistfield (FuncState *fs, struct ConsControl *cc) { +static void closelistfield (FuncState *fs, ConsControl *cc) { if (cc->v.k == VVOID) return; /* there is no list item */ luaK_exp2nextreg(fs, &cc->v); cc->v.k = VVOID; if (cc->tostore == LFIELDS_PER_FLUSH) { luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */ + cc->na += cc->tostore; cc->tostore = 0; /* no more items pending */ } } -static void lastlistfield (FuncState *fs, struct ConsControl *cc) { +static void lastlistfield (FuncState *fs, ConsControl *cc) { if (cc->tostore == 0) return; if (hasmultret(cc->v.k)) { luaK_setmultret(fs, &cc->v); @@ -687,19 +889,18 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) { luaK_exp2nextreg(fs, &cc->v); luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); } + cc->na += cc->tostore; } -static void listfield (LexState *ls, struct ConsControl *cc) { +static void listfield (LexState *ls, ConsControl *cc) { /* listfield -> exp */ expr(ls, &cc->v); - checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); - cc->na++; cc->tostore++; } -static void field (LexState *ls, struct ConsControl *cc) { +static void field (LexState *ls, ConsControl *cc) { /* field -> listfield | recfield */ switch(ls->t.token) { case TK_NAME: { /* may be 'listfield' or 'recfield' */ @@ -727,12 +928,13 @@ static void constructor (LexState *ls, expdesc *t) { FuncState *fs = ls->fs; int line = ls->linenumber; int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); - struct ConsControl cc; + ConsControl cc; + luaK_code(fs, 0); /* space for extra arg. */ cc.na = cc.nh = cc.tostore = 0; cc.t = t; - init_exp(t, VRELOCABLE, pc); + init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */ + luaK_reserveregs(fs, 1); init_exp(&cc.v, VVOID, 0); /* no value (yet) */ - luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ checknext(ls, '{'); do { lua_assert(cc.v.k == VVOID || cc.tostore > 0); @@ -742,40 +944,46 @@ static void constructor (LexState *ls, expdesc *t) { } while (testnext(ls, ',') || testnext(ls, ';')); check_match(ls, '}', '{', line); lastlistfield(fs, &cc); - SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ - SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ + luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh); } /* }====================================================================== */ +static void setvararg (FuncState *fs, int nparams) { + fs->f->is_vararg = 1; + luaK_codeABC(fs, OP_VARARGPREP, nparams, 0, 0); +} + static void parlist (LexState *ls) { - /* parlist -> [ param { ',' param } ] */ + /* parlist -> [ {NAME ','} (NAME | '...') ] */ FuncState *fs = ls->fs; Proto *f = fs->f; int nparams = 0; - f->is_vararg = 0; + int isvararg = 0; if (ls->t.token != ')') { /* is 'parlist' not empty? */ do { switch (ls->t.token) { - case TK_NAME: { /* param -> NAME */ + case TK_NAME: { new_localvar(ls, str_checkname(ls)); nparams++; break; } - case TK_DOTS: { /* param -> '...' */ + case TK_DOTS: { luaX_next(ls); - f->is_vararg = 1; /* declared vararg */ + isvararg = 1; break; } default: luaX_syntaxerror(ls, " or '...' expected"); } - } while (!f->is_vararg && testnext(ls, ',')); + } while (!isvararg && testnext(ls, ',')); } adjustlocalvars(ls, nparams); f->numparams = cast_byte(fs->nactvar); - luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ + if (isvararg) + setvararg(fs, f->numparams); /* declared vararg */ + luaK_reserveregs(fs, fs->nactvar); /* reserve registers for parameters */ } @@ -814,10 +1022,11 @@ static int explist (LexState *ls, expdesc *v) { } -static void funcargs (LexState *ls, expdesc *f, int line) { +static void funcargs (LexState *ls, expdesc *f) { FuncState *fs = ls->fs; expdesc args; int base, nparams; + int line = ls->linenumber; switch (ls->t.token) { case '(': { /* funcargs -> '(' [ explist ] ')' */ luaX_next(ls); @@ -825,7 +1034,8 @@ static void funcargs (LexState *ls, expdesc *f, int line) { args.k = VVOID; else { explist(ls, &args); - luaK_setmultret(fs, &args); + if (hasmultret(args.k)) + luaK_setmultret(fs, &args); } check_match(ls, ')', '(', line); break; @@ -835,7 +1045,7 @@ static void funcargs (LexState *ls, expdesc *f, int line) { break; } case TK_STRING: { /* funcargs -> STRING */ - codestring(ls, &args, ls->t.seminfo.ts); + codestring(&args, ls->t.seminfo.ts); luaX_next(ls); /* must use 'seminfo' before 'next' */ break; } @@ -854,8 +1064,8 @@ static void funcargs (LexState *ls, expdesc *f, int line) { } init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); luaK_fixline(fs, line); - fs->freereg = base+1; /* call remove function and arguments and leaves - (unless changed) one result */ + fs->freereg = base+1; /* call removes function and arguments and leaves + one result (unless changed later) */ } @@ -894,7 +1104,6 @@ static void suffixedexp (LexState *ls, expdesc *v) { /* suffixedexp -> primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ FuncState *fs = ls->fs; - int line = ls->linenumber; primaryexp(ls, v); for (;;) { switch (ls->t.token) { @@ -902,7 +1111,7 @@ static void suffixedexp (LexState *ls, expdesc *v) { fieldsel(ls, v); break; } - case '[': { /* '[' exp1 ']' */ + case '[': { /* '[' exp ']' */ expdesc key; luaK_exp2anyregup(fs, v); yindex(ls, &key); @@ -912,14 +1121,14 @@ static void suffixedexp (LexState *ls, expdesc *v) { case ':': { /* ':' NAME funcargs */ expdesc key; luaX_next(ls); - checkname(ls, &key); + codename(ls, &key); luaK_self(fs, v, &key); - funcargs(ls, v, line); + funcargs(ls, v); break; } case '(': case TK_STRING: case '{': { /* funcargs */ luaK_exp2nextreg(fs, v); - funcargs(ls, v, line); + funcargs(ls, v); break; } default: return; @@ -943,7 +1152,7 @@ static void simpleexp (LexState *ls, expdesc *v) { break; } case TK_STRING: { - codestring(ls, v, ls->t.seminfo.ts); + codestring(v, ls->t.seminfo.ts); break; } case TK_NIL: { @@ -962,7 +1171,7 @@ static void simpleexp (LexState *ls, expdesc *v) { FuncState *fs = ls->fs; check_condition(ls, fs->f->is_vararg, "cannot use '...' outside a vararg function"); - init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 0, 1)); break; } case '{': { /* constructor */ @@ -1022,6 +1231,9 @@ static BinOpr getbinopr (int op) { } +/* +** Priority table for binary operators. +*/ static const struct { lu_byte left; /* left priority for each binary operator */ lu_byte right; /* right priority */ @@ -1050,9 +1262,9 @@ static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { UnOpr uop; enterlevel(ls); uop = getunopr(ls->t.token); - if (uop != OPR_NOUNOPR) { + if (uop != OPR_NOUNOPR) { /* prefix (unary) operator? */ int line = ls->linenumber; - luaX_next(ls); + luaX_next(ls); /* skip operator */ subexpr(ls, v, UNARY_PRIORITY); luaK_prefix(ls->fs, uop, v, line); } @@ -1063,7 +1275,7 @@ static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { expdesc v2; BinOpr nextop; int line = ls->linenumber; - luaX_next(ls); + luaX_next(ls); /* skip operator */ luaK_infix(ls->fs, op, v); /* read sub-expression with higher priority */ nextop = subexpr(ls, &v2, priority[op].right); @@ -1121,43 +1333,60 @@ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { int extra = fs->freereg; /* eventual position to save local variable */ int conflict = 0; for (; lh; lh = lh->prev) { /* check all previous assignments */ - if (lh->v.k == VINDEXED) { /* assigning to a table? */ - /* table is the upvalue/local being assigned now? */ - if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) { - conflict = 1; - lh->v.u.ind.vt = VLOCAL; - lh->v.u.ind.t = extra; /* previous assignment will use safe copy */ + if (vkisindexed(lh->v.k)) { /* assignment to table field? */ + if (lh->v.k == VINDEXUP) { /* is table an upvalue? */ + if (v->k == VUPVAL && lh->v.u.ind.t == v->u.info) { + conflict = 1; /* table is the upvalue being assigned now */ + lh->v.k = VINDEXSTR; + lh->v.u.ind.t = extra; /* assignment will use safe copy */ + } } - /* index is the local being assigned? (index cannot be upvalue) */ - if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { - conflict = 1; - lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ + else { /* table is a register */ + if (v->k == VLOCAL && lh->v.u.ind.t == v->u.var.ridx) { + conflict = 1; /* table is the local being assigned now */ + lh->v.u.ind.t = extra; /* assignment will use safe copy */ + } + /* is index the local being assigned? */ + if (lh->v.k == VINDEXED && v->k == VLOCAL && + lh->v.u.ind.idx == v->u.var.ridx) { + conflict = 1; + lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ + } } } } if (conflict) { /* copy upvalue/local value to a temporary (in position 'extra') */ - OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; - luaK_codeABC(fs, op, extra, v->u.info, 0); + if (v->k == VLOCAL) + luaK_codeABC(fs, OP_MOVE, extra, v->u.var.ridx, 0); + else + luaK_codeABC(fs, OP_GETUPVAL, extra, v->u.info, 0); luaK_reserveregs(fs, 1); } } - -static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { +/* +** Parse and compile a multiple assignment. The first "variable" +** (a 'suffixedexp') was already read by the caller. +** +** assignment -> suffixedexp restassign +** restassign -> ',' suffixedexp restassign | '=' explist +*/ +static void restassign (LexState *ls, struct LHS_assign *lh, int nvars) { expdesc e; check_condition(ls, vkisvar(lh->v.k), "syntax error"); - if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ + check_readonly(ls, &lh->v); + if (testnext(ls, ',')) { /* restassign -> ',' suffixedexp restassign */ struct LHS_assign nv; nv.prev = lh; suffixedexp(ls, &nv.v); - if (nv.v.k != VINDEXED) + if (!vkisindexed(nv.v.k)) check_conflict(ls, lh, &nv.v); - checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, - "C levels"); - assignment(ls, &nv, nvars+1); + enterlevel(ls); /* control recursion depth */ + restassign(ls, &nv, nvars+1); + leavelevel(ls); } - else { /* assignment -> '=' explist */ + else { /* restassign -> '=' explist */ int nexps; checknext(ls, '='); nexps = explist(ls, &e); @@ -1184,57 +1413,55 @@ static int cond (LexState *ls) { } -static void gotostat (LexState *ls, int pc) { +static void gotostat (LexState *ls) { + FuncState *fs = ls->fs; int line = ls->linenumber; - TString *label; - int g; - if (testnext(ls, TK_GOTO)) - label = str_checkname(ls); - else { - luaX_next(ls); /* skip break */ - label = luaS_new(ls->L, "break"); + TString *name = str_checkname(ls); /* label's name */ + Labeldesc *lb = findlabel(ls, name); + if (lb == NULL) /* no label? */ + /* forward jump; will be resolved when the label is declared */ + newgotoentry(ls, name, line, luaK_jump(fs)); + else { /* found a label */ + /* backward jump; will be resolved here */ + int lblevel = reglevel(fs, lb->nactvar); /* label level */ + if (luaY_nvarstack(fs) > lblevel) /* leaving the scope of a variable? */ + luaK_codeABC(fs, OP_CLOSE, lblevel, 0, 0); + /* create jump and link it to the label */ + luaK_patchlist(fs, luaK_jump(fs), lb->pc); } - g = newlabelentry(ls, &ls->dyd->gt, label, line, pc); - findlabel(ls, g); /* close it if label already defined */ } -/* check for repeated labels on the same block */ -static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { - int i; - for (i = fs->bl->firstlabel; i < ll->n; i++) { - if (eqstr(label, ll->arr[i].name)) { - const char *msg = luaO_pushfstring(fs->ls->L, - "label '%s' already defined on line %d", - getstr(label), ll->arr[i].line); - semerror(fs->ls, msg); - } - } +/* +** Break statement. Semantically equivalent to "goto break". +*/ +static void breakstat (LexState *ls) { + int line = ls->linenumber; + luaX_next(ls); /* skip break */ + newgotoentry(ls, luaS_newliteral(ls->L, "break"), line, luaK_jump(ls->fs)); } -/* skip no-op statements */ -static void skipnoopstat (LexState *ls) { - while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) - statement(ls); +/* +** Check whether there is already a label with the given 'name'. +*/ +static void checkrepeated (LexState *ls, TString *name) { + Labeldesc *lb = findlabel(ls, name); + if (l_unlikely(lb != NULL)) { /* already defined? */ + const char *msg = "label '%s' already defined on line %d"; + msg = luaO_pushfstring(ls->L, msg, getstr(name), lb->line); + luaK_semerror(ls, msg); /* error */ + } } -static void labelstat (LexState *ls, TString *label, int line) { +static void labelstat (LexState *ls, TString *name, int line) { /* label -> '::' NAME '::' */ - FuncState *fs = ls->fs; - Labellist *ll = &ls->dyd->label; - int l; /* index of new label being created */ - checkrepeated(fs, ll, label); /* check for repeated labels */ checknext(ls, TK_DBCOLON); /* skip double colon */ - /* create new entry for this label */ - l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs)); - skipnoopstat(ls); /* skip other no-op statements */ - if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ - /* assume that locals are already out of scope */ - ll->arr[l].nactvar = fs->bl->nactvar; - } - findgotos(ls, &ll->arr[l]); + while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) + statement(ls); /* skip other no-op statements */ + checkrepeated(ls, name); /* check for repeated labels */ + createlabel(ls, name, line, block_follow(ls, 0)); } @@ -1269,58 +1496,83 @@ static void repeatstat (LexState *ls, int line) { statlist(ls); check_match(ls, TK_UNTIL, TK_REPEAT, line); condexit = cond(ls); /* read condition (inside scope block) */ - if (bl2.upval) /* upvalues? */ - luaK_patchclose(fs, condexit, bl2.nactvar); leaveblock(fs); /* finish scope */ + if (bl2.upval) { /* upvalues? */ + int exit = luaK_jump(fs); /* normal exit must jump over fix */ + luaK_patchtohere(fs, condexit); /* repetition must close upvalues */ + luaK_codeABC(fs, OP_CLOSE, reglevel(fs, bl2.nactvar), 0, 0); + condexit = luaK_jump(fs); /* repeat after closing upvalues */ + luaK_patchtohere(fs, exit); /* normal exit comes to here */ + } luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ leaveblock(fs); /* finish loop */ } -static int exp1 (LexState *ls) { +/* +** Read an expression and generate code to put its results in next +** stack slot. +** +*/ +static void exp1 (LexState *ls) { expdesc e; - int reg; expr(ls, &e); luaK_exp2nextreg(ls->fs, &e); lua_assert(e.k == VNONRELOC); - reg = e.u.info; - return reg; } -static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { +/* +** Fix for instruction at position 'pc' to jump to 'dest'. +** (Jump addresses are relative in Lua). 'back' true means +** a back jump. +*/ +static void fixforjump (FuncState *fs, int pc, int dest, int back) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest - (pc + 1); + if (back) + offset = -offset; + if (l_unlikely(offset > MAXARG_Bx)) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_Bx(*jmp, offset); +} + + +/* +** Generate code for a 'for' loop. +*/ +static void forbody (LexState *ls, int base, int line, int nvars, int isgen) { /* forbody -> DO block */ + static const OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP}; + static const OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP}; BlockCnt bl; FuncState *fs = ls->fs; int prep, endfor; - adjustlocalvars(ls, 3); /* control variables */ checknext(ls, TK_DO); - prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + prep = luaK_codeABx(fs, forprep[isgen], base, 0); enterblock(fs, &bl, 0); /* scope for declared variables */ adjustlocalvars(ls, nvars); luaK_reserveregs(fs, nvars); block(ls); leaveblock(fs); /* end of scope for declared variables */ - luaK_patchtohere(fs, prep); - if (isnum) /* numeric for? */ - endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); - else { /* generic for */ + fixforjump(fs, prep, luaK_getlabel(fs), 0); + if (isgen) { /* generic for? */ luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); luaK_fixline(fs, line); - endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); } - luaK_patchlist(fs, endfor, prep + 1); + endfor = luaK_codeABx(fs, forloop[isgen], base, 0); + fixforjump(fs, endfor, prep + 1, 1); luaK_fixline(fs, line); } static void fornum (LexState *ls, TString *varname, int line) { - /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + /* fornum -> NAME = exp,exp[,exp] forbody */ FuncState *fs = ls->fs; int base = fs->freereg; - new_localvarliteral(ls, "(for index)"); - new_localvarliteral(ls, "(for limit)"); - new_localvarliteral(ls, "(for step)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for state)"); new_localvar(ls, varname); checknext(ls, '='); exp1(ls); /* initial value */ @@ -1329,10 +1581,11 @@ static void fornum (LexState *ls, TString *varname, int line) { if (testnext(ls, ',')) exp1(ls); /* optional step */ else { /* default step = 1 */ - luaK_codek(fs, fs->freereg, luaK_intK(fs, 1)); + luaK_int(fs, fs->freereg, 1); luaK_reserveregs(fs, 1); } - forbody(ls, base, line, 1, 1); + adjustlocalvars(ls, 3); /* control variables */ + forbody(ls, base, line, 1, 0); } @@ -1340,13 +1593,14 @@ static void forlist (LexState *ls, TString *indexname) { /* forlist -> NAME {,NAME} IN explist forbody */ FuncState *fs = ls->fs; expdesc e; - int nvars = 4; /* gen, state, control, plus at least one declared var */ + int nvars = 5; /* gen, state, control, toclose, 'indexname' */ int line; int base = fs->freereg; /* create control variables */ - new_localvarliteral(ls, "(for generator)"); new_localvarliteral(ls, "(for state)"); - new_localvarliteral(ls, "(for control)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for state)"); /* create declared variables */ new_localvar(ls, indexname); while (testnext(ls, ',')) { @@ -1355,9 +1609,11 @@ static void forlist (LexState *ls, TString *indexname) { } checknext(ls, TK_IN); line = ls->linenumber; - adjust_assign(ls, 3, explist(ls, &e), &e); + adjust_assign(ls, 4, explist(ls, &e), &e); + adjustlocalvars(ls, 4); /* control variables */ + marktobeclosed(fs); /* last control var. must be closed */ luaK_checkstack(fs, 3); /* extra space to call generator */ - forbody(ls, base, line, nvars - 3, 0); + forbody(ls, base, line, nvars - 4, 1); } @@ -1388,19 +1644,21 @@ static void test_then_block (LexState *ls, int *escapelist) { luaX_next(ls); /* skip IF or ELSEIF */ expr(ls, &v); /* read condition */ checknext(ls, TK_THEN); - if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) { - luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ + if (ls->t.token == TK_BREAK) { /* 'if x then break' ? */ + int line = ls->linenumber; + luaK_goiffalse(ls->fs, &v); /* will jump if condition is true */ + luaX_next(ls); /* skip 'break' */ enterblock(fs, &bl, 0); /* must enter block before 'goto' */ - gotostat(ls, v.t); /* handle goto/break */ - while (testnext(ls, ';')) {} /* skip colons */ - if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ + newgotoentry(ls, luaS_newliteral(ls->L, "break"), line, v.t); + while (testnext(ls, ';')) {} /* skip semicolons */ + if (block_follow(ls, 0)) { /* jump is the entire block? */ leaveblock(fs); return; /* and that is it */ } else /* must skip over 'then' part if condition is false */ jf = luaK_jump(fs); } - else { /* regular case (not goto/break) */ + else { /* regular case (not a break) */ luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */ enterblock(fs, &bl, 0); jf = v.f; @@ -1431,21 +1689,58 @@ static void ifstat (LexState *ls, int line) { static void localfunc (LexState *ls) { expdesc b; FuncState *fs = ls->fs; + int fvar = fs->nactvar; /* function's variable index */ new_localvar(ls, str_checkname(ls)); /* new local variable */ adjustlocalvars(ls, 1); /* enter its scope */ body(ls, &b, 0, ls->linenumber); /* function created in next register */ /* debug information will only see the variable after this point! */ - getlocvar(fs, b.u.info)->startpc = fs->pc; + localdebuginfo(fs, fvar)->startpc = fs->pc; +} + + +static int getlocalattribute (LexState *ls) { + /* ATTRIB -> ['<' Name '>'] */ + if (testnext(ls, '<')) { + const char *attr = getstr(str_checkname(ls)); + checknext(ls, '>'); + if (strcmp(attr, "const") == 0) + return RDKCONST; /* read-only variable */ + else if (strcmp(attr, "close") == 0) + return RDKTOCLOSE; /* to-be-closed variable */ + else + luaK_semerror(ls, + luaO_pushfstring(ls->L, "unknown attribute '%s'", attr)); + } + return VDKREG; /* regular variable */ +} + + +static void checktoclose (FuncState *fs, int level) { + if (level != -1) { /* is there a to-be-closed variable? */ + marktobeclosed(fs); + luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0); + } } static void localstat (LexState *ls) { - /* stat -> LOCAL NAME {',' NAME} ['=' explist] */ + /* stat -> LOCAL NAME ATTRIB { ',' NAME ATTRIB } ['=' explist] */ + FuncState *fs = ls->fs; + int toclose = -1; /* index of to-be-closed variable (if any) */ + Vardesc *var; /* last variable */ + int vidx, kind; /* index and kind of last variable */ int nvars = 0; int nexps; expdesc e; do { - new_localvar(ls, str_checkname(ls)); + vidx = new_localvar(ls, str_checkname(ls)); + kind = getlocalattribute(ls); + getlocalvardesc(fs, vidx)->vd.kind = kind; + if (kind == RDKTOCLOSE) { /* to-be-closed? */ + if (toclose != -1) /* one already present? */ + luaK_semerror(ls, "multiple to-be-closed variables in local list"); + toclose = fs->nactvar + nvars; + } nvars++; } while (testnext(ls, ',')); if (testnext(ls, '=')) @@ -1454,8 +1749,19 @@ static void localstat (LexState *ls) { e.k = VVOID; nexps = 0; } - adjust_assign(ls, nvars, nexps, &e); - adjustlocalvars(ls, nvars); + var = getlocalvardesc(fs, vidx); /* get last variable */ + if (nvars == nexps && /* no adjustments? */ + var->vd.kind == RDKCONST && /* last variable is const? */ + luaK_exp2const(fs, &e, &var->k)) { /* compile-time constant? */ + var->vd.kind = RDKCTC; /* variable is a compile-time constant */ + adjustlocalvars(ls, nvars - 1); /* exclude last variable */ + fs->nactvar++; /* but count it */ + } + else { + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); + } + checktoclose(fs, toclose); } @@ -1480,6 +1786,7 @@ static void funcstat (LexState *ls, int line) { luaX_next(ls); /* skip FUNCTION */ ismethod = funcname(ls, &v); body(ls, &b, ismethod, line); + check_readonly(ls, &v); luaK_storevar(ls->fs, &v, &b); luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ } @@ -1492,11 +1799,13 @@ static void exprstat (LexState *ls) { suffixedexp(ls, &v.v); if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ v.prev = NULL; - assignment(ls, &v, 1); + restassign(ls, &v, 1); } else { /* stat -> func */ + Instruction *inst; check_condition(ls, v.v.k == VCALL, "syntax error"); - SETARG_C(getinstruction(fs, &v.v), 1); /* call statement uses no results */ + inst = &getinstruction(fs, &v.v); + SETARG_C(*inst, 1); /* call statement uses no results */ } } @@ -1505,26 +1814,25 @@ static void retstat (LexState *ls) { /* stat -> RETURN [explist] [';'] */ FuncState *fs = ls->fs; expdesc e; - int first, nret; /* registers with returned values */ + int nret; /* number of values being returned */ + int first = luaY_nvarstack(fs); /* first slot to be returned */ if (block_follow(ls, 1) || ls->t.token == ';') - first = nret = 0; /* return no values */ + nret = 0; /* return no values */ else { nret = explist(ls, &e); /* optional return values */ if (hasmultret(e.k)) { luaK_setmultret(fs, &e); - if (e.k == VCALL && nret == 1) { /* tail call? */ + if (e.k == VCALL && nret == 1 && !fs->bl->insidetbc) { /* tail call? */ SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL); - lua_assert(GETARG_A(getinstruction(fs,&e)) == fs->nactvar); + lua_assert(GETARG_A(getinstruction(fs,&e)) == luaY_nvarstack(fs)); } - first = fs->nactvar; nret = LUA_MULTRET; /* return all values */ } else { if (nret == 1) /* only one single value? */ - first = luaK_exp2anyreg(fs, &e); - else { - luaK_exp2nextreg(fs, &e); /* values must go to the stack */ - first = fs->nactvar; /* return all active values */ + first = luaK_exp2anyreg(fs, &e); /* can use original slot */ + else { /* values must go to the top of the stack */ + luaK_exp2nextreg(fs, &e); lua_assert(nret == fs->freereg - first); } } @@ -1586,9 +1894,13 @@ static void statement (LexState *ls) { retstat(ls); break; } - case TK_BREAK: /* stat -> breakstat */ + case TK_BREAK: { /* stat -> breakstat */ + breakstat(ls); + break; + } case TK_GOTO: { /* stat -> 'goto' NAME */ - gotostat(ls, luaK_jump(ls->fs)); + luaX_next(ls); /* skip 'goto' */ + gotostat(ls); break; } default: { /* stat -> func | assignment */ @@ -1597,8 +1909,8 @@ static void statement (LexState *ls) { } } lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && - ls->fs->freereg >= ls->fs->nactvar); - ls->fs->freereg = ls->fs->nactvar; /* free registers */ + ls->fs->freereg >= luaY_nvarstack(ls->fs)); + ls->fs->freereg = luaY_nvarstack(ls->fs); /* free registers */ leavelevel(ls); } @@ -1611,11 +1923,15 @@ static void statement (LexState *ls) { */ static void mainfunc (LexState *ls, FuncState *fs) { BlockCnt bl; - expdesc v; + Upvaldesc *env; open_func(ls, fs, &bl); - fs->f->is_vararg = 1; /* main function is always declared vararg */ - init_exp(&v, VLOCAL, 0); /* create and... */ - newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ + setvararg(fs, 0); /* main function is always declared vararg */ + env = allocupvalue(fs); /* ...set environment upvalue */ + env->instack = 1; + env->idx = 0; + env->kind = VDKREG; + env->name = ls->envn; + luaC_objbarrier(ls->L, fs->f, env->name); luaX_next(ls); /* read first token */ statlist(ls); /* parse main body */ check(ls, TK_EOS); @@ -1628,14 +1944,15 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, LexState lexstate; FuncState funcstate; LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ - setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */ + setclLvalue2s(L, L->top.p, cl); /* anchor it (to avoid being collected) */ luaD_inctop(L); lexstate.h = luaH_new(L); /* create table for scanner */ - sethvalue(L, L->top, lexstate.h); /* anchor it */ + sethvalue2s(L, L->top.p, lexstate.h); /* anchor it */ luaD_inctop(L); funcstate.f = cl->p = luaF_newproto(L); + luaC_objbarrier(L, cl, cl->p); funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ - lua_assert(iswhite(funcstate.f)); /* do not need barrier here */ + luaC_objbarrier(L, funcstate.f, funcstate.f->source); lexstate.buff = buff; lexstate.dyd = dyd; dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; @@ -1644,7 +1961,7 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); /* all scopes should be correctly finished */ lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); - L->top--; /* remove scanner's table */ + L->top.p--; /* remove scanner's table */ return cl; /* closure is on the stack, too */ } diff --git a/liblua/lparser.h b/liblua/lparser.h index f45b23cb..5e4500f1 100644 --- a/liblua/lparser.h +++ b/liblua/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.76.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lparser.h $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -23,63 +23,96 @@ /* kinds of variables/expressions */ typedef enum { - VVOID, /* when 'expdesc' describes the last expression a list, + VVOID, /* when 'expdesc' describes the last expression of a list, this kind means an empty list (so, no expression) */ VNIL, /* constant nil */ VTRUE, /* constant true */ VFALSE, /* constant false */ VK, /* constant in 'k'; info = index of constant in 'k' */ VKFLT, /* floating constant; nval = numerical float value */ - VKINT, /* integer constant; nval = numerical integer value */ + VKINT, /* integer constant; ival = numerical integer value */ + VKSTR, /* string constant; strval = TString address; + (string is fixed by the lexer) */ VNONRELOC, /* expression has its value in a fixed register; info = result register */ - VLOCAL, /* local variable; info = local register */ + VLOCAL, /* local variable; var.ridx = register index; + var.vidx = relative index in 'actvar.arr' */ VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ + VCONST, /* compile-time variable; + info = absolute index in 'actvar.arr' */ VINDEXED, /* indexed variable; - ind.vt = whether 't' is register or upvalue; - ind.t = table register or upvalue; - ind.idx = key's R/K index */ + ind.t = table register; + ind.idx = key's R index */ + VINDEXUP, /* indexed upvalue; + ind.t = table upvalue; + ind.idx = key's K index */ + VINDEXI, /* indexed variable with constant integer; + ind.t = table register; + ind.idx = key's value */ + VINDEXSTR, /* indexed variable with literal string; + ind.t = table register; + ind.idx = key's K index */ VJMP, /* expression is a test/comparison; info = pc of corresponding jump instruction */ - VRELOCABLE, /* expression can put result in any register; - info = instruction pc */ + VRELOC, /* expression can put result in any register; + info = instruction pc */ VCALL, /* expression is a function call; info = instruction pc */ VVARARG /* vararg expression; info = instruction pc */ } expkind; -#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) -#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) +#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXSTR) +#define vkisindexed(k) (VINDEXED <= (k) && (k) <= VINDEXSTR) + typedef struct expdesc { expkind k; union { lua_Integer ival; /* for VKINT */ lua_Number nval; /* for VKFLT */ + TString *strval; /* for VKSTR */ int info; /* for generic use */ - struct { /* for indexed variables (VINDEXED) */ - short idx; /* index (R/K) */ + struct { /* for indexed variables */ + short idx; /* index (R or "long" K) */ lu_byte t; /* table (register or upvalue) */ - lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ } ind; + struct { /* for local variables */ + lu_byte ridx; /* register holding the variable */ + unsigned short vidx; /* compiler index (in 'actvar.arr') */ + } var; } u; int t; /* patch list of 'exit when true' */ int f; /* patch list of 'exit when false' */ } expdesc; -/* description of active local variable */ -typedef struct Vardesc { - short idx; /* variable index in stack */ +/* kinds of variables */ +#define VDKREG 0 /* regular */ +#define RDKCONST 1 /* constant */ +#define RDKTOCLOSE 2 /* to-be-closed */ +#define RDKCTC 3 /* compile-time constant */ + +/* description of an active local variable */ +typedef union Vardesc { + struct { + TValuefields; /* constant value (if it is a compile-time constant) */ + lu_byte kind; + lu_byte ridx; /* register holding the variable */ + short pidx; /* index of the variable in the Proto's 'locvars' array */ + TString *name; /* variable name */ + } vd; + TValue k; /* constant value (if any) */ } Vardesc; + /* description of pending goto statements and label statements */ typedef struct Labeldesc { TString *name; /* label identifier */ int pc; /* position in code */ int line; /* line where it appeared */ - lu_byte nactvar; /* local level where it appears in current block */ + lu_byte nactvar; /* number of active variables in that position */ + lu_byte close; /* goto that escapes upvalues */ } Labeldesc; @@ -93,7 +126,7 @@ typedef struct Labellist { /* dynamic structures used by the parser */ typedef struct Dyndata { - struct { /* list of active local variables */ + struct { /* list of all active local variables */ Vardesc *arr; int n; int size; @@ -115,17 +148,22 @@ typedef struct FuncState { struct BlockCnt *bl; /* chain of current blocks */ int pc; /* next position to code (equivalent to 'ncode') */ int lasttarget; /* 'label' of last 'jump label' */ - int jpc; /* list of pending jumps to 'pc' */ + int previousline; /* last line that was saved in 'lineinfo' */ int nk; /* number of elements in 'k' */ int np; /* number of elements in 'p' */ + int nabslineinfo; /* number of elements in 'abslineinfo' */ int firstlocal; /* index of first local var (in Dyndata array) */ - short nlocvars; /* number of elements in 'f->locvars' */ + int firstlabel; /* index of first label (in 'dyd->label->arr') */ + short ndebugvars; /* number of elements in 'f->locvars' */ lu_byte nactvar; /* number of active local variables */ lu_byte nups; /* number of upvalues */ lu_byte freereg; /* first free register */ + lu_byte iwthabs; /* instructions issued since last absolute line info */ + lu_byte needclose; /* function needs to close upvalues when returning */ } FuncState; +LUAI_FUNC int luaY_nvarstack (FuncState *fs); LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar); diff --git a/liblua/lprefix.h b/liblua/lprefix.h index 9a749a3f..484f2ad6 100644 --- a/liblua/lprefix.h +++ b/liblua/lprefix.h @@ -1,5 +1,5 @@ /* -** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lprefix.h $ ** Definitions for Lua code that must come before any other header file ** See Copyright Notice in lua.h */ @@ -33,7 +33,7 @@ /* ** Windows stuff */ -#if defined(_WIN32) /* { */ +#if defined(_WIN32) /* { */ #if !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ diff --git a/liblua/lstate.c b/liblua/lstate.c index c1a76643..7fefacba 100644 --- a/liblua/lstate.c +++ b/liblua/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.133.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lstate.c $ ** Global State ** See Copyright Notice in lua.h */ @@ -28,25 +28,6 @@ #include "ltm.h" -#if !defined(LUAI_GCPAUSE) -#define LUAI_GCPAUSE 200 /* 200% */ -#endif - -#if !defined(LUAI_GCMUL) -#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ -#endif - - -/* -** a macro to help the creation of a unique random seed when a state is -** created; the seed is used to randomize hashes. -*/ -#if !defined(luai_makeseed) -#include -#define luai_makeseed() cast(unsigned int, time(NULL)) -#endif - - /* ** thread state + extra space @@ -71,25 +52,35 @@ typedef struct LG { /* -** Compute an initial seed as random as possible. Rely on Address Space -** Layout Randomization (if present) to increase randomness.. +** A macro to create a "random" seed when a state is created; +** the seed is used to randomize string hashes. +*/ +#if !defined(luai_makeseed) + +#include + +/* +** Compute an initial seed with some level of randomness. +** Rely on Address Space Layout Randomization (if present) and +** current time. */ #define addbuff(b,p,e) \ - { size_t t = cast(size_t, e); \ + { size_t t = cast_sizet(e); \ memcpy(b + p, &t, sizeof(t)); p += sizeof(t); } -static unsigned int makeseed (lua_State *L) { - char buff[4 * sizeof(size_t)]; - unsigned int h = luai_makeseed(); +static unsigned int luai_makeseed (lua_State *L) { + char buff[3 * sizeof(size_t)]; + unsigned int h = cast_uint(time(NULL)); int p = 0; addbuff(buff, p, L); /* heap variable */ addbuff(buff, p, &h); /* local variable */ - addbuff(buff, p, luaO_nilobject); /* global variable */ addbuff(buff, p, &lua_newstate); /* public function */ lua_assert(p == sizeof(buff)); return luaS_hash(buff, p, h); } +#endif + /* ** set GCdebt to a new value keeping the value (totalbytes + GCdebt) @@ -105,12 +96,21 @@ void luaE_setdebt (global_State *g, l_mem debt) { } +LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) { + UNUSED(L); UNUSED(limit); + return LUAI_MAXCCALLS; /* warning?? */ +} + + CallInfo *luaE_extendCI (lua_State *L) { - CallInfo *ci = luaM_new(L, CallInfo); + CallInfo *ci; + lua_assert(L->ci->next == NULL); + ci = luaM_new(L, CallInfo); lua_assert(L->ci->next == NULL); L->ci->next = ci; ci->previous = L->ci; ci->next = NULL; + ci->u.l.trap = 0; L->nci++; return ci; } @@ -119,7 +119,7 @@ CallInfo *luaE_extendCI (lua_State *L) { /* ** free all CallInfo structures not in use by a thread */ -void luaE_freeCI (lua_State *L) { +static void freeCI (lua_State *L) { CallInfo *ci = L->ci; CallInfo *next = ci->next; ci->next = NULL; @@ -132,49 +132,81 @@ void luaE_freeCI (lua_State *L) { /* -** free half of the CallInfo structures not in use by a thread +** free half of the CallInfo structures not in use by a thread, +** keeping the first one. */ void luaE_shrinkCI (lua_State *L) { - CallInfo *ci = L->ci; - CallInfo *next2; /* next's next */ - /* while there are two nexts */ - while (ci->next != NULL && (next2 = ci->next->next) != NULL) { - luaM_free(L, ci->next); /* free next */ + CallInfo *ci = L->ci->next; /* first free CallInfo */ + CallInfo *next; + if (ci == NULL) + return; /* no extra elements */ + while ((next = ci->next) != NULL) { /* two extra elements? */ + CallInfo *next2 = next->next; /* next's next */ + ci->next = next2; /* remove next from the list */ L->nci--; - ci->next = next2; /* remove 'next' from the list */ - next2->previous = ci; - ci = next2; /* keep next's next */ + luaM_free(L, next); /* free next */ + if (next2 == NULL) + break; /* no more elements */ + else { + next2->previous = ci; + ci = next2; /* continue */ + } } } +/* +** Called when 'getCcalls(L)' larger or equal to LUAI_MAXCCALLS. +** If equal, raises an overflow error. If value is larger than +** LUAI_MAXCCALLS (which means it is handling an overflow) but +** not much larger, does not report an error (to allow overflow +** handling to work). +*/ +void luaE_checkcstack (lua_State *L) { + if (getCcalls(L) == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) + luaD_throw(L, LUA_ERRERR); /* error while handling stack error */ +} + + +LUAI_FUNC void luaE_incCstack (lua_State *L) { + L->nCcalls++; + if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) + luaE_checkcstack(L); +} + + static void stack_init (lua_State *L1, lua_State *L) { int i; CallInfo *ci; /* initialize stack array */ - L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); - L1->stacksize = BASIC_STACK_SIZE; - for (i = 0; i < BASIC_STACK_SIZE; i++) - setnilvalue(L1->stack + i); /* erase new stack */ - L1->top = L1->stack; - L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; + L1->stack.p = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); + L1->tbclist.p = L1->stack.p; + for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++) + setnilvalue(s2v(L1->stack.p + i)); /* erase new stack */ + L1->top.p = L1->stack.p; + L1->stack_last.p = L1->stack.p + BASIC_STACK_SIZE; /* initialize first ci */ ci = &L1->base_ci; ci->next = ci->previous = NULL; - ci->callstatus = 0; - ci->func = L1->top; - setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ - ci->top = L1->top + LUA_MINSTACK; + ci->callstatus = CIST_C; + ci->func.p = L1->top.p; + ci->u.c.k = NULL; + ci->nresults = 0; + setnilvalue(s2v(L1->top.p)); /* 'function' entry for this 'ci' */ + L1->top.p++; + ci->top.p = L1->top.p + LUA_MINSTACK; L1->ci = ci; } static void freestack (lua_State *L) { - if (L->stack == NULL) + if (L->stack.p == NULL) return; /* stack not completely built yet */ L->ci = &L->base_ci; /* free the entire 'ci' list */ - luaE_freeCI(L); + freeCI(L); lua_assert(L->nci == 0); - luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ + luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */ } @@ -182,23 +214,19 @@ static void freestack (lua_State *L) { ** Create registry table and its predefined values */ static void init_registry (lua_State *L, global_State *g) { - TValue temp; /* create registry */ Table *registry = luaH_new(L); sethvalue(L, &g->l_registry, registry); luaH_resize(L, registry, LUA_RIDX_LAST, 0); /* registry[LUA_RIDX_MAINTHREAD] = L */ - setthvalue(L, &temp, L); /* temp = L */ - luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); - /* registry[LUA_RIDX_GLOBALS] = table of globals */ - sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ - luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); + setthvalue(L, ®istry->array[LUA_RIDX_MAINTHREAD - 1], L); + /* registry[LUA_RIDX_GLOBALS] = new table (table of globals) */ + sethvalue(L, ®istry->array[LUA_RIDX_GLOBALS - 1], luaH_new(L)); } /* ** open parts of the state that may cause memory-allocation errors. -** ('g->version' != NULL flags that the state was completely build) */ static void f_luaopen (lua_State *L, void *ud) { global_State *g = G(L); @@ -208,8 +236,8 @@ static void f_luaopen (lua_State *L, void *ud) { luaS_init(L); luaT_init(L); luaX_init(L); - g->gcrunning = 1; /* allow gc */ - g->version = lua_version(NULL); + g->gcstp = 0; /* allow gc */ + setnilvalue(&g->nilvalue); /* now state is complete */ luai_userstateopen(L); } @@ -220,31 +248,34 @@ static void f_luaopen (lua_State *L, void *ud) { */ static void preinit_thread (lua_State *L, global_State *g) { G(L) = g; - L->stack = NULL; + L->stack.p = NULL; L->ci = NULL; L->nci = 0; - L->stacksize = 0; L->twups = L; /* thread has no upvalues */ - L->errorJmp = NULL; L->nCcalls = 0; + L->errorJmp = NULL; L->hook = NULL; L->hookmask = 0; L->basehookcount = 0; L->allowhook = 1; resethookcount(L); L->openupval = NULL; - L->nny = 1; L->status = LUA_OK; L->errfunc = 0; + L->oldpc = 0; } static void close_state (lua_State *L) { global_State *g = G(L); - luaF_close(L, L->stack); /* close all upvalues for this thread */ - luaC_freeallobjects(L); /* collect all objects */ - if (g->version) /* closing a fully built state? */ + if (!completestate(g)) /* closing a partially built state? */ + luaC_freeallobjects(L); /* just collect its objects */ + else { /* closing a fully built state */ + L->ci = &L->base_ci; /* unwind CallInfo list */ + luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */ + luaC_freeallobjects(L); /* collect all objects */ luai_userstateclose(L); + } luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); freestack(L); lua_assert(gettotalbytes(g) == sizeof(LG)); @@ -254,18 +285,15 @@ static void close_state (lua_State *L) { LUA_API lua_State *lua_newthread (lua_State *L) { global_State *g = G(L); + GCObject *o; lua_State *L1; lua_lock(L); luaC_checkGC(L); /* create new thread */ - L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; - L1->marked = luaC_white(g); - L1->tt = LUA_TTHREAD; - /* link it on list 'allgc' */ - L1->next = g->allgc; - g->allgc = obj2gco(L1); + o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l)); + L1 = gco2th(o); /* anchor it on L stack */ - setthvalue(L, L->top, L1); + setthvalue2s(L, L->top.p, L1); api_incr_top(L); preinit_thread(L1, g); L1->hookmask = L->hookmask; @@ -284,7 +312,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { void luaE_freethread (lua_State *L, lua_State *L1) { LX *l = fromstate(L1); - luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + luaF_closeupval(L1, L1->stack.p); /* close all upvalues */ lua_assert(L1->openupval == NULL); luai_userstatefree(L, L1); freestack(L1); @@ -292,6 +320,43 @@ void luaE_freethread (lua_State *L, lua_State *L1) { } +int luaE_resetthread (lua_State *L, int status) { + CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */ + setnilvalue(s2v(L->stack.p)); /* 'function' entry for basic 'ci' */ + ci->func.p = L->stack.p; + ci->callstatus = CIST_C; + if (status == LUA_YIELD) + status = LUA_OK; + L->status = LUA_OK; /* so it can run __close metamethods */ + status = luaD_closeprotected(L, 1, status); + if (status != LUA_OK) /* errors? */ + luaD_seterrorobj(L, status, L->stack.p + 1); + else + L->top.p = L->stack.p + 1; + ci->top.p = L->top.p + LUA_MINSTACK; + luaD_reallocstack(L, cast_int(ci->top.p - L->stack.p), 0); + return status; +} + + +LUA_API int lua_closethread (lua_State *L, lua_State *from) { + int status; + lua_lock(L); + L->nCcalls = (from) ? getCcalls(from) : 0; + status = luaE_resetthread(L, L->status); + lua_unlock(L); + return status; +} + + +/* +** Deprecated! Use 'lua_closethread' instead. +*/ +LUA_API int lua_resetthread (lua_State *L) { + return lua_closethread(L, NULL); +} + + LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { int i; lua_State *L; @@ -300,34 +365,44 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { if (l == NULL) return NULL; L = &l->l.l; g = &l->g; - L->next = NULL; - L->tt = LUA_TTHREAD; + L->tt = LUA_VTHREAD; g->currentwhite = bitmask(WHITE0BIT); L->marked = luaC_white(g); preinit_thread(L, g); + g->allgc = obj2gco(L); /* by now, only object is the main thread */ + L->next = NULL; + incnny(L); /* main thread is always non yieldable */ g->frealloc = f; g->ud = ud; + g->warnf = NULL; + g->ud_warn = NULL; g->mainthread = L; - g->seed = makeseed(L); - g->gcrunning = 0; /* no GC while building state */ - g->GCestimate = 0; + g->seed = luai_makeseed(L); + g->gcstp = GCSTPGC; /* no GC while building state */ g->strt.size = g->strt.nuse = 0; g->strt.hash = NULL; setnilvalue(&g->l_registry); g->panic = NULL; - g->version = NULL; g->gcstate = GCSpause; - g->gckind = KGC_NORMAL; - g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL; + g->gckind = KGC_INC; + g->gcstopem = 0; + g->gcemergency = 0; + g->finobj = g->tobefnz = g->fixedgc = NULL; + g->firstold1 = g->survival = g->old1 = g->reallyold = NULL; + g->finobjsur = g->finobjold1 = g->finobjrold = NULL; g->sweepgc = NULL; g->gray = g->grayagain = NULL; g->weak = g->ephemeron = g->allweak = NULL; g->twups = NULL; g->totalbytes = sizeof(LG); g->GCdebt = 0; - g->gcfinnum = 0; - g->gcpause = LUAI_GCPAUSE; - g->gcstepmul = LUAI_GCMUL; + g->lastatomic = 0; + setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */ + setgcparam(g->gcpause, LUAI_GCPAUSE); + setgcparam(g->gcstepmul, LUAI_GCMUL); + g->gcstepsize = LUAI_GCSTEPSIZE; + setgcparam(g->genmajormul, LUAI_GENMAJORMUL); + g->genminormul = LUAI_GENMINORMUL; for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { /* memory allocation error: free partial state */ @@ -339,9 +414,32 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { LUA_API void lua_close (lua_State *L) { - L = G(L)->mainthread; /* only the main thread can be closed */ lua_lock(L); + L = G(L)->mainthread; /* only the main thread can be closed */ close_state(L); } +void luaE_warning (lua_State *L, const char *msg, int tocont) { + lua_WarnFunction wf = G(L)->warnf; + if (wf != NULL) + wf(G(L)->ud_warn, msg, tocont); +} + + +/* +** Generate a warning from an error message +*/ +void luaE_warnerror (lua_State *L, const char *where) { + TValue *errobj = s2v(L->top.p - 1); /* error object */ + const char *msg = (ttisstring(errobj)) + ? getstr(tsvalue(errobj)) + : "error object is not a string"; + /* produce warning "error in %s (%s)" (where, msg) */ + luaE_warning(L, "error in ", 1); + luaE_warning(L, where, 1); + luaE_warning(L, " (", 1); + luaE_warning(L, msg, 1); + luaE_warning(L, ")", 0); +} + diff --git a/liblua/lstate.h b/liblua/lstate.h index 56b37410..007704c8 100644 --- a/liblua/lstate.h +++ b/liblua/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.133.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lstate.h $ ** Global State ** See Copyright Notice in lua.h */ @@ -9,13 +9,17 @@ #include "lua.h" + +/* Some header files included here need this definition */ +typedef struct CallInfo CallInfo; + + #include "lobject.h" #include "ltm.h" #include "lzio.h" /* - ** Some notes about garbage-collected objects: All objects in Lua must ** be kept somehow accessible until being freed, so all objects always ** belong to one (and only one) of these lists, using field 'next' of @@ -27,12 +31,44 @@ ** 'fixedgc': all objects that are not to be collected (currently ** only small strings, such as reserved words). ** +** For the generational collector, some of these lists have marks for +** generations. Each mark points to the first element in the list for +** that particular generation; that generation goes until the next mark. +** +** 'allgc' -> 'survival': new objects; +** 'survival' -> 'old': objects that survived one collection; +** 'old1' -> 'reallyold': objects that became old in last collection; +** 'reallyold' -> NULL: objects old for more than one cycle. +** +** 'finobj' -> 'finobjsur': new objects marked for finalization; +** 'finobjsur' -> 'finobjold1': survived """"; +** 'finobjold1' -> 'finobjrold': just old """"; +** 'finobjrold' -> NULL: really old """". +** +** All lists can contain elements older than their main ages, due +** to 'luaC_checkfinalizer' and 'udata2finalize', which move +** objects between the normal lists and the "marked for finalization" +** lists. Moreover, barriers can age young objects in young lists as +** OLD0, which then become OLD1. However, a list never contains +** elements younger than their main ages. +** +** The generational collector also uses a pointer 'firstold1', which +** points to the first OLD1 object in the list. It is used to optimize +** 'markold'. (Potentially OLD1 objects can be anywhere between 'allgc' +** and 'reallyold', but often the list has no OLD1 objects or they are +** after 'old1'.) Note the difference between it and 'old1': +** 'firstold1': no OLD1 objects before this point; there can be all +** ages after it. +** 'old1': no objects younger than OLD1 after this point. +*/ + +/* ** Moreover, there is another set of lists that control gray objects. ** These lists are linked by fields 'gclist'. (All objects that ** can become gray have such a field. The field is not the same ** in all objects, but it always has this name.) Any gray object ** must belong to one of these lists, and all objects in these lists -** must be gray: +** must be gray (with two exceptions explained below): ** ** 'gray': regular gray objects, still waiting to be visited. ** 'grayagain': objects that must be revisited at the atomic phase. @@ -43,11 +79,46 @@ ** 'weak': tables with weak values to be cleared; ** 'ephemeron': ephemeron tables with white->white entries; ** 'allweak': tables with weak keys and/or weak values to be cleared. -** The last three lists are used only during the atomic phase. +** +** The exceptions to that "gray rule" are: +** - TOUCHED2 objects in generational mode stay in a gray list (because +** they must be visited again at the end of the cycle), but they are +** marked black because assignments to them must activate barriers (to +** move them back to TOUCHED1). +** - Open upvales are kept gray to avoid barriers, but they stay out +** of gray lists. (They don't even have a 'gclist' field.) +*/ + + +/* +** About 'nCcalls': This count has two parts: the lower 16 bits counts +** the number of recursive invocations in the C stack; the higher +** 16 bits counts the number of non-yieldable calls in the stack. +** (They are together so that we can change and save both with one +** instruction.) */ +/* true if this thread does not have non-yieldable calls in the stack */ +#define yieldable(L) (((L)->nCcalls & 0xffff0000) == 0) + +/* real number of C calls */ +#define getCcalls(L) ((L)->nCcalls & 0xffff) + + +/* Increment the number of non-yieldable calls */ +#define incnny(L) ((L)->nCcalls += 0x10000) + +/* Decrement the number of non-yieldable calls */ +#define decnny(L) ((L)->nCcalls -= 0x10000) + +/* Non-yieldable call increment */ +#define nyci (0x10000 | 1) + + + + struct lua_longjmp; /* defined in ldo.c */ @@ -61,16 +132,24 @@ struct lua_longjmp; /* defined in ldo.c */ #endif -/* extra stack space to handle TM calls and some other extras */ +/* +** Extra stack space to handle TM calls and some other extras. This +** space is not included in 'stack_last'. It is used only to avoid stack +** checks, either because the element will be promptly popped or because +** there will be a stack check soon after the push. Function frames +** never use this extra space, so it does not need to be kept clean. +*/ #define EXTRA_STACK 5 #define BASIC_STACK_SIZE (2*LUA_MINSTACK) +#define stacksize(th) cast_int((th)->stack_last.p - (th)->stack.p) + /* kinds of Garbage Collection */ -#define KGC_NORMAL 0 -#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */ +#define KGC_INC 0 /* incremental gc */ +#define KGC_GEN 1 /* generational gc */ typedef struct stringtable { @@ -82,21 +161,28 @@ typedef struct stringtable { /* ** Information about a call. -** When a thread yields, 'func' is adjusted to pretend that the -** top function has only the yielded values in its stack; in that -** case, the actual 'func' value is saved in field 'extra'. -** When a function calls another with a continuation, 'extra' keeps -** the function index so that, in case of errors, the continuation -** function can be called with the correct top. +** About union 'u': +** - field 'l' is used only for Lua functions; +** - field 'c' is used only for C functions. +** About union 'u2': +** - field 'funcidx' is used only by C functions while doing a +** protected call; +** - field 'nyield' is used only while a function is "doing" an +** yield (from the yield until the next resume); +** - field 'nres' is used only while closing tbc variables when +** returning from a function; +** - field 'transferinfo' is used only during call/returnhooks, +** before the function starts or after it ends. */ -typedef struct CallInfo { - StkId func; /* function index in the stack */ - StkId top; /* top for this function */ +struct CallInfo { + StkIdRel func; /* function index in the stack */ + StkIdRel top; /* top for this function */ struct CallInfo *previous, *next; /* dynamic call link */ union { struct { /* only for Lua functions */ - StkId base; /* base for this function */ const Instruction *savedpc; + volatile l_signalT trap; /* function is tracing lines/counts */ + int nextraargs; /* # of extra arguments in vararg functions */ } l; struct { /* only for C functions */ lua_KFunction k; /* continuation in case of yields */ @@ -104,27 +190,58 @@ typedef struct CallInfo { lua_KContext ctx; /* context info. in case of yields */ } c; } u; - ptrdiff_t extra; + union { + int funcidx; /* called-function index */ + int nyield; /* number of values yielded */ + int nres; /* number of values returned */ + struct { /* info about transferred values (for call/return hooks) */ + unsigned short ftransfer; /* offset of first value transferred */ + unsigned short ntransfer; /* number of values transferred */ + } transferinfo; + } u2; short nresults; /* expected number of results from this function */ unsigned short callstatus; -} CallInfo; +}; /* ** Bits in CallInfo status */ #define CIST_OAH (1<<0) /* original value of 'allowhook' */ -#define CIST_LUA (1<<1) /* call is running a Lua function */ -#define CIST_HOOKED (1<<2) /* call is running a debug hook */ -#define CIST_FRESH (1<<3) /* call is running on a fresh invocation - of luaV_execute */ -#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ +#define CIST_C (1<<1) /* call is running a C function */ +#define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */ +#define CIST_HOOKED (1<<3) /* call is running a debug hook */ +#define CIST_YPCALL (1<<4) /* doing a yieldable protected call */ #define CIST_TAIL (1<<5) /* call was tail called */ #define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ -#define CIST_LEQ (1<<7) /* using __lt for __le */ -#define CIST_FIN (1<<8) /* call is running a finalizer */ +#define CIST_FIN (1<<7) /* function "called" a finalizer */ +#define CIST_TRAN (1<<8) /* 'ci' has transfer information */ +#define CIST_CLSRET (1<<9) /* function is closing tbc variables */ +/* Bits 10-12 are used for CIST_RECST (see below) */ +#define CIST_RECST 10 +#if defined(LUA_COMPAT_LT_LE) +#define CIST_LEQ (1<<13) /* using __lt for __le */ +#endif + + +/* +** Field CIST_RECST stores the "recover status", used to keep the error +** status while closing to-be-closed variables in coroutines, so that +** Lua can correctly resume after an yield from a __close method called +** because of an error. (Three bits are enough for error status.) +*/ +#define getcistrecst(ci) (((ci)->callstatus >> CIST_RECST) & 7) +#define setcistrecst(ci,st) \ + check_exp(((st) & 7) == (st), /* status must fit in three bits */ \ + ((ci)->callstatus = ((ci)->callstatus & ~(7 << CIST_RECST)) \ + | ((st) << CIST_RECST))) + -#define isLua(ci) ((ci)->callstatus & CIST_LUA) +/* active function is a Lua function */ +#define isLua(ci) (!((ci)->callstatus & CIST_C)) + +/* call is running Lua code (not a hook) */ +#define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED))) /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) @@ -139,15 +256,23 @@ typedef struct global_State { void *ud; /* auxiliary data to 'frealloc' */ l_mem totalbytes; /* number of bytes currently allocated - GCdebt */ l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ - lu_mem GCmemtrav; /* memory traversed by the GC */ lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ + lu_mem lastatomic; /* see function 'genstep' in file 'lgc.c' */ stringtable strt; /* hash table for strings */ TValue l_registry; + TValue nilvalue; /* a nil value */ unsigned int seed; /* randomized seed for hashes */ lu_byte currentwhite; lu_byte gcstate; /* state of garbage collector */ lu_byte gckind; /* kind of GC running */ - lu_byte gcrunning; /* true if GC is running */ + lu_byte gcstopem; /* stops emergency collections */ + lu_byte genminormul; /* control for minor generational collections */ + lu_byte genmajormul; /* control for major generational collections */ + lu_byte gcstp; /* control whether GC is running */ + lu_byte gcemergency; /* true if this is an emergency collection */ + lu_byte gcpause; /* size of pause between successive GCs */ + lu_byte gcstepmul; /* GC "speed" */ + lu_byte gcstepsize; /* (log2 of) GC granularity */ GCObject *allgc; /* list of all collectable objects */ GCObject **sweepgc; /* current position of sweep in list */ GCObject *finobj; /* list of collectable objects with finalizers */ @@ -158,17 +283,23 @@ typedef struct global_State { GCObject *allweak; /* list of all-weak tables */ GCObject *tobefnz; /* list of userdata to be GC */ GCObject *fixedgc; /* list of objects not to be collected */ + /* fields for generational collector */ + GCObject *survival; /* start of objects that survived one GC cycle */ + GCObject *old1; /* start of old1 objects */ + GCObject *reallyold; /* objects more than one cycle old ("really old") */ + GCObject *firstold1; /* first OLD1 object in the list (if any) */ + GCObject *finobjsur; /* list of survival objects with finalizers */ + GCObject *finobjold1; /* list of old1 objects with finalizers */ + GCObject *finobjrold; /* list of really old objects with finalizers */ struct lua_State *twups; /* list of threads with open upvalues */ - unsigned int gcfinnum; /* number of finalizers to call in each GC step */ - int gcpause; /* size of pause between successive GCs */ - int gcstepmul; /* GC 'granularity' */ lua_CFunction panic; /* to be called in unprotected errors */ struct lua_State *mainthread; - const lua_Number *version; /* pointer to version number */ - TString *memerrmsg; /* memory-error message */ + TString *memerrmsg; /* message for memory-allocation errors */ TString *tmname[TM_N]; /* array with tag-method names */ - struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ + struct Table *mt[LUA_NUMTYPES]; /* metatables for basic types */ TString *strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */ + lua_WarnFunction warnf; /* warning function */ + void *ud_warn; /* auxiliary data to 'warnf' */ } global_State; @@ -177,36 +308,47 @@ typedef struct global_State { */ struct lua_State { CommonHeader; - unsigned short nci; /* number of items in 'ci' list */ lu_byte status; - StkId top; /* first free slot in the stack */ + lu_byte allowhook; + unsigned short nci; /* number of items in 'ci' list */ + StkIdRel top; /* first free slot in the stack */ global_State *l_G; CallInfo *ci; /* call info for current function */ - const Instruction *oldpc; /* last pc traced */ - StkId stack_last; /* last free slot in the stack */ - StkId stack; /* stack base */ + StkIdRel stack_last; /* end of stack (last element + 1) */ + StkIdRel stack; /* stack base */ UpVal *openupval; /* list of open upvalues in this stack */ + StkIdRel tbclist; /* list of to-be-closed variables */ GCObject *gclist; struct lua_State *twups; /* list of threads with open upvalues */ struct lua_longjmp *errorJmp; /* current error recover point */ CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ volatile lua_Hook hook; ptrdiff_t errfunc; /* current error handling function (stack index) */ - int stacksize; + l_uint32 nCcalls; /* number of nested (non-yieldable | C) calls */ + int oldpc; /* last pc traced */ int basehookcount; int hookcount; - unsigned short nny; /* number of non-yieldable calls in stack */ - unsigned short nCcalls; /* number of nested C calls */ - l_signalT hookmask; - lu_byte allowhook; + volatile l_signalT hookmask; }; #define G(L) (L->l_G) +/* +** 'g->nilvalue' being a nil value flags that the state was completely +** build. +*/ +#define completestate(g) ttisnil(&g->nilvalue) + /* ** Union of all collectable objects (only for conversions) +** ISO C99, 6.5.2.3 p.5: +** "if a union contains several structures that share a common initial +** sequence [...], and if the union object currently contains one +** of these structures, it is permitted to inspect the common initial +** part of any of them anywhere that a declaration of the complete type +** of the union is visible." */ union GCUnion { GCObject gc; /* common header */ @@ -216,27 +358,36 @@ union GCUnion { struct Table h; struct Proto p; struct lua_State th; /* thread */ + struct UpVal upv; }; +/* +** ISO C99, 6.7.2.1 p.14: +** "A pointer to a union object, suitably converted, points to each of +** its members [...], and vice versa." +*/ #define cast_u(o) cast(union GCUnion *, (o)) /* macros to convert a GCObject into a specific value */ #define gco2ts(o) \ check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts)) -#define gco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u)) -#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l)) -#define gco2ccl(o) check_exp((o)->tt == LUA_TCCL, &((cast_u(o))->cl.c)) +#define gco2u(o) check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u)) +#define gco2lcl(o) check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l)) +#define gco2ccl(o) check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c)) #define gco2cl(o) \ check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl)) -#define gco2t(o) check_exp((o)->tt == LUA_TTABLE, &((cast_u(o))->h)) -#define gco2p(o) check_exp((o)->tt == LUA_TPROTO, &((cast_u(o))->p)) -#define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th)) +#define gco2t(o) check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h)) +#define gco2p(o) check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p)) +#define gco2th(o) check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th)) +#define gco2upv(o) check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv)) -/* macro to convert a Lua object into a GCObject */ -#define obj2gco(v) \ - check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc))) +/* +** macro to convert a Lua object into a GCObject +** (The access to 'tt' tries to ensure that 'v' is actually a Lua object.) +*/ +#define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc)) /* actual number of total bytes allocated */ @@ -245,8 +396,12 @@ union GCUnion { LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); -LUAI_FUNC void luaE_freeCI (lua_State *L); LUAI_FUNC void luaE_shrinkCI (lua_State *L); +LUAI_FUNC void luaE_checkcstack (lua_State *L); +LUAI_FUNC void luaE_incCstack (lua_State *L); +LUAI_FUNC void luaE_warning (lua_State *L, const char *msg, int tocont); +LUAI_FUNC void luaE_warnerror (lua_State *L, const char *where); +LUAI_FUNC int luaE_resetthread (lua_State *L, int status); #endif diff --git a/liblua/lstring.c b/liblua/lstring.c index 6257f211..97757355 100644 --- a/liblua/lstring.c +++ b/liblua/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.56.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lstring.c $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -22,16 +22,10 @@ #include "lstring.h" -#define MEMERRMSG "not enough memory" - - /* -** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to -** compute its hash +** Maximum size for string table. */ -#if !defined(LUAI_HASHLIMIT) -#define LUAI_HASHLIMIT 5 -#endif +#define MAXSTRTB cast_int(luaM_limitN(MAX_INT, TString*)) /* @@ -39,60 +33,73 @@ */ int luaS_eqlngstr (TString *a, TString *b) { size_t len = a->u.lnglen; - lua_assert(a->tt == LUA_TLNGSTR && b->tt == LUA_TLNGSTR); + lua_assert(a->tt == LUA_VLNGSTR && b->tt == LUA_VLNGSTR); return (a == b) || /* same instance or... */ ((len == b->u.lnglen) && /* equal length and ... */ - (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ + (memcmp(getlngstr(a), getlngstr(b), len) == 0)); /* equal contents */ } unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { - unsigned int h = seed ^ cast(unsigned int, l); - size_t step = (l >> LUAI_HASHLIMIT) + 1; - for (; l >= step; l -= step) + unsigned int h = seed ^ cast_uint(l); + for (; l > 0; l--) h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1])); return h; } unsigned int luaS_hashlongstr (TString *ts) { - lua_assert(ts->tt == LUA_TLNGSTR); + lua_assert(ts->tt == LUA_VLNGSTR); if (ts->extra == 0) { /* no hash? */ - ts->hash = luaS_hash(getstr(ts), ts->u.lnglen, ts->hash); + size_t len = ts->u.lnglen; + ts->hash = luaS_hash(getlngstr(ts), len, ts->hash); ts->extra = 1; /* now it has its hash */ } return ts->hash; } -/* -** resizes the string table -*/ -void luaS_resize (lua_State *L, int newsize) { +static void tablerehash (TString **vect, int osize, int nsize) { int i; - stringtable *tb = &G(L)->strt; - if (newsize > tb->size) { /* grow table if needed */ - luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *); - for (i = tb->size; i < newsize; i++) - tb->hash[i] = NULL; - } - for (i = 0; i < tb->size; i++) { /* rehash */ - TString *p = tb->hash[i]; - tb->hash[i] = NULL; - while (p) { /* for each node in the list */ + for (i = osize; i < nsize; i++) /* clear new elements */ + vect[i] = NULL; + for (i = 0; i < osize; i++) { /* rehash old part of the array */ + TString *p = vect[i]; + vect[i] = NULL; + while (p) { /* for each string in the list */ TString *hnext = p->u.hnext; /* save next */ - unsigned int h = lmod(p->hash, newsize); /* new position */ - p->u.hnext = tb->hash[h]; /* chain it */ - tb->hash[h] = p; + unsigned int h = lmod(p->hash, nsize); /* new position */ + p->u.hnext = vect[h]; /* chain it into array */ + vect[h] = p; p = hnext; } } - if (newsize < tb->size) { /* shrink table if needed */ - /* vanishing slice should be empty */ - lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL); - luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *); +} + + +/* +** Resize the string table. If allocation fails, keep the current size. +** (This can degrade performance, but any non-zero size should work +** correctly.) +*/ +void luaS_resize (lua_State *L, int nsize) { + stringtable *tb = &G(L)->strt; + int osize = tb->size; + TString **newvect; + if (nsize < osize) /* shrinking table? */ + tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */ + newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); + if (l_unlikely(newvect == NULL)) { /* reallocation failed? */ + if (nsize < osize) /* was it shrinking table? */ + tablerehash(tb->hash, nsize, osize); /* restore to original size */ + /* leave table as it was */ + } + else { /* allocation succeeded */ + tb->hash = newvect; + tb->size = nsize; + if (nsize > osize) + tablerehash(newvect, osize, nsize); /* rehash for new size */ } - tb->size = newsize; } @@ -104,8 +111,8 @@ void luaS_clearcache (global_State *g) { int i, j; for (i = 0; i < STRCACHE_N; i++) for (j = 0; j < STRCACHE_M; j++) { - if (iswhite(g->strcache[i][j])) /* will entry be collected? */ - g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */ + if (iswhite(g->strcache[i][j])) /* will entry be collected? */ + g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */ } } @@ -116,7 +123,10 @@ void luaS_clearcache (global_State *g) { void luaS_init (lua_State *L) { global_State *g = G(L); int i, j; - luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + stringtable *tb = &G(L)->strt; + tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*); + tablerehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */ + tb->size = MINSTRTABSIZE; /* pre-create memory-error message */ g->memerrmsg = luaS_newliteral(L, MEMERRMSG); luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */ @@ -145,8 +155,9 @@ static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) { TString *luaS_createlngstrobj (lua_State *L, size_t l) { - TString *ts = createstrobj(L, l, LUA_TLNGSTR, G(L)->seed); + TString *ts = createstrobj(L, l, LUA_VLNGSTR, G(L)->seed); ts->u.lnglen = l; + ts->shrlen = 0xFF; /* signals that it is a long string */ return ts; } @@ -161,34 +172,46 @@ void luaS_remove (lua_State *L, TString *ts) { } +static void growstrtab (lua_State *L, stringtable *tb) { + if (l_unlikely(tb->nuse == MAX_INT)) { /* too many strings? */ + luaC_fullgc(L, 1); /* try to free some... */ + if (tb->nuse == MAX_INT) /* still too many? */ + luaM_error(L); /* cannot even create a message... */ + } + if (tb->size <= MAXSTRTB / 2) /* can grow string table? */ + luaS_resize(L, tb->size * 2); +} + + /* -** checks whether short string exists and reuses it or creates a new one +** Checks whether short string exists and reuses it or creates a new one. */ static TString *internshrstr (lua_State *L, const char *str, size_t l) { TString *ts; global_State *g = G(L); + stringtable *tb = &g->strt; unsigned int h = luaS_hash(str, l, g->seed); - TString **list = &g->strt.hash[lmod(h, g->strt.size)]; + TString **list = &tb->hash[lmod(h, tb->size)]; lua_assert(str != NULL); /* otherwise 'memcmp'/'memcpy' are undefined */ for (ts = *list; ts != NULL; ts = ts->u.hnext) { - if (l == ts->shrlen && - (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { + if (l == ts->shrlen && (memcmp(str, getshrstr(ts), l * sizeof(char)) == 0)) { /* found! */ if (isdead(g, ts)) /* dead (but not collected yet)? */ changewhite(ts); /* resurrect it */ return ts; } } - if (g->strt.nuse >= g->strt.size && g->strt.size <= MAX_INT/2) { - luaS_resize(L, g->strt.size * 2); - list = &g->strt.hash[lmod(h, g->strt.size)]; /* recompute with new size */ + /* else must create a new string */ + if (tb->nuse >= tb->size) { /* need to grow string table? */ + growstrtab(L, tb); + list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */ } - ts = createstrobj(L, l, LUA_TSHRSTR, h); - memcpy(getstr(ts), str, l * sizeof(char)); + ts = createstrobj(L, l, LUA_VSHRSTR, h); ts->shrlen = cast_byte(l); + memcpy(getshrstr(ts), str, l * sizeof(char)); ts->u.hnext = *list; *list = ts; - g->strt.nuse++; + tb->nuse++; return ts; } @@ -201,10 +224,10 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { return internshrstr(L, str, l); else { TString *ts; - if (l >= (MAX_SIZE - sizeof(TString))/sizeof(char)) + if (l_unlikely(l * sizeof(char) >= (MAX_SIZE - sizeof(TString)))) luaM_toobig(L); ts = luaS_createlngstrobj(L, l); - memcpy(getstr(ts), str, l * sizeof(char)); + memcpy(getlngstr(ts), str, l * sizeof(char)); return ts; } } @@ -233,16 +256,19 @@ TString *luaS_new (lua_State *L, const char *str) { } -Udata *luaS_newudata (lua_State *L, size_t s) { +Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue) { Udata *u; + int i; GCObject *o; - if (s > MAX_SIZE - sizeof(Udata)) + if (l_unlikely(s > MAX_SIZE - udatamemoffset(nuvalue))) luaM_toobig(L); - o = luaC_newobj(L, LUA_TUSERDATA, sizeludata(s)); + o = luaC_newobj(L, LUA_VUSERDATA, sizeudata(nuvalue, s)); u = gco2u(o); u->len = s; + u->nuvalue = nuvalue; u->metatable = NULL; - setuservalue(L, u, luaO_nilobject); + for (i = 0; i < nuvalue; i++) + setnilvalue(&u->uv[i].uv); return u; } diff --git a/liblua/lstring.h b/liblua/lstring.h index d612abd3..450c2390 100644 --- a/liblua/lstring.h +++ b/liblua/lstring.h @@ -1,5 +1,5 @@ /* -** $Id: lstring.h,v 1.61.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lstring.h $ ** String table (keep all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -12,10 +12,18 @@ #include "lstate.h" -#define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) +/* +** Memory-allocation error message must be preallocated (it cannot +** be created after memory is exhausted) +*/ +#define MEMERRMSG "not enough memory" + -#define sizeludata(l) (sizeof(union UUdata) + (l)) -#define sizeudata(u) sizeludata((u)->len) +/* +** Size of a TString: Size of the header plus space for the string +** itself (including final '\0'). +*/ +#define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char)) #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ (sizeof(s)/sizeof(char))-1)) @@ -24,13 +32,13 @@ /* ** test whether a string is a reserved word */ -#define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) +#define isreserved(s) ((s)->tt == LUA_VSHRSTR && (s)->extra > 0) /* ** equality for short strings, which are always internalized */ -#define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) +#define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); @@ -40,7 +48,7 @@ LUAI_FUNC void luaS_resize (lua_State *L, int newsize); LUAI_FUNC void luaS_clearcache (global_State *g); LUAI_FUNC void luaS_init (lua_State *L); LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); -LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue); LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); diff --git a/liblua/lstrlib.c b/liblua/lstrlib.c index b4bed7e9..03167161 100644 --- a/liblua/lstrlib.c +++ b/liblua/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.254.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: lstrlib.c $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -59,23 +60,50 @@ static int str_len (lua_State *L) { } -/* translate a relative string position: negative means back from end */ -static lua_Integer posrelat (lua_Integer pos, size_t len) { - if (pos >= 0) return pos; - else if (0u - (size_t)pos > len) return 0; - else return (lua_Integer)len + pos + 1; +/* +** translate a relative initial string position +** (negative means back from end): clip result to [1, inf). +** The length of any string in Lua must fit in a lua_Integer, +** so there are no overflows in the casts. +** The inverted comparison avoids a possible overflow +** computing '-pos'. +*/ +static size_t posrelatI (lua_Integer pos, size_t len) { + if (pos > 0) + return (size_t)pos; + else if (pos == 0) + return 1; + else if (pos < -(lua_Integer)len) /* inverted comparison */ + return 1; /* clip to 1 */ + else return len + (size_t)pos + 1; +} + + +/* +** Gets an optional ending string position from argument 'arg', +** with default value 'def'. +** Negative means back from end: clip result to [0, len] +*/ +static size_t getendpos (lua_State *L, int arg, lua_Integer def, + size_t len) { + lua_Integer pos = luaL_optinteger(L, arg, def); + if (pos > (lua_Integer)len) + return len; + else if (pos >= 0) + return (size_t)pos; + else if (pos < -(lua_Integer)len) + return 0; + else return len + (size_t)pos + 1; } static int str_sub (lua_State *L) { size_t l; const char *s = luaL_checklstring(L, 1, &l); - lua_Integer start = posrelat(luaL_checkinteger(L, 2), l); - lua_Integer end = posrelat(luaL_optinteger(L, 3, -1), l); - if (start < 1) start = 1; - if (end > (lua_Integer)l) end = l; + size_t start = posrelatI(luaL_checkinteger(L, 2), l); + size_t end = getendpos(L, 3, -1, l); if (start <= end) - lua_pushlstring(L, s + start - 1, (size_t)(end - start) + 1); + lua_pushlstring(L, s + start - 1, (end - start) + 1); else lua_pushliteral(L, ""); return 1; } @@ -124,8 +152,9 @@ static int str_rep (lua_State *L) { const char *s = luaL_checklstring(L, 1, &l); lua_Integer n = luaL_checkinteger(L, 2); const char *sep = luaL_optlstring(L, 3, "", &lsep); - if (n <= 0) lua_pushliteral(L, ""); - else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */ + if (n <= 0) + lua_pushliteral(L, ""); + else if (l_unlikely(l + lsep < l || l + lsep > MAXSIZE / n)) return luaL_error(L, "resulting string too large"); else { size_t totallen = (size_t)n * l + (size_t)(n - 1) * lsep; @@ -148,13 +177,12 @@ static int str_rep (lua_State *L) { static int str_byte (lua_State *L) { size_t l; const char *s = luaL_checklstring(L, 1, &l); - lua_Integer posi = posrelat(luaL_optinteger(L, 2, 1), l); - lua_Integer pose = posrelat(luaL_optinteger(L, 3, posi), l); + lua_Integer pi = luaL_optinteger(L, 2, 1); + size_t posi = posrelatI(pi, l); + size_t pose = getendpos(L, 3, pi, l); int n, i; - if (posi < 1) posi = 1; - if (pose > (lua_Integer)l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ - if (pose - posi >= INT_MAX) /* arithmetic overflow? */ + if (l_unlikely(pose - posi >= (size_t)INT_MAX)) /* arithmetic overflow? */ return luaL_error(L, "string slice too long"); n = (int)(pose - posi) + 1; luaL_checkstack(L, n, "string slice too long"); @@ -170,8 +198,8 @@ static int str_char (lua_State *L) { luaL_Buffer b; char *p = luaL_buffinitsize(L, &b, n); for (i=1; i<=n; i++) { - lua_Integer c = luaL_checkinteger(L, i); - luaL_argcheck(L, uchar(c) == c, i, "value out of range"); + lua_Unsigned c = (lua_Unsigned)luaL_checkinteger(L, i); + luaL_argcheck(L, c <= (lua_Unsigned)UCHAR_MAX, i, "value out of range"); p[i - 1] = uchar(c); } luaL_pushresultsize(&b, n); @@ -179,26 +207,142 @@ static int str_char (lua_State *L) { } -static int writer (lua_State *L, const void *b, size_t size, void *B) { - (void)L; - luaL_addlstring((luaL_Buffer *) B, (const char *)b, size); +/* +** Buffer to store the result of 'string.dump'. It must be initialized +** after the call to 'lua_dump', to ensure that the function is on the +** top of the stack when 'lua_dump' is called. ('luaL_buffinit' might +** push stuff.) +*/ +struct str_Writer { + int init; /* true iff buffer has been initialized */ + luaL_Buffer B; +}; + + +static int writer (lua_State *L, const void *b, size_t size, void *ud) { + struct str_Writer *state = (struct str_Writer *)ud; + if (!state->init) { + state->init = 1; + luaL_buffinit(L, &state->B); + } + luaL_addlstring(&state->B, (const char *)b, size); return 0; } static int str_dump (lua_State *L) { - luaL_Buffer b; + struct str_Writer state; int strip = lua_toboolean(L, 2); luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, 1); - luaL_buffinit(L,&b); - if (lua_dump(L, writer, &b, strip) != 0) + lua_settop(L, 1); /* ensure function is on the top of the stack */ + state.init = 0; + if (l_unlikely(lua_dump(L, writer, &state, strip) != 0)) return luaL_error(L, "unable to dump given function"); - luaL_pushresult(&b); + luaL_pushresult(&state.B); + return 1; +} + + + +/* +** {====================================================== +** METAMETHODS +** ======================================================= +*/ + +#if defined(LUA_NOCVTS2N) /* { */ + +/* no coercion from strings to numbers */ + +static const luaL_Reg stringmetamethods[] = { + {"__index", NULL}, /* placeholder */ + {NULL, NULL} +}; + +#else /* }{ */ + +static int tonum (lua_State *L, int arg) { + if (lua_type(L, arg) == LUA_TNUMBER) { /* already a number? */ + lua_pushvalue(L, arg); + return 1; + } + else { /* check whether it is a numerical string */ + size_t len; + const char *s = lua_tolstring(L, arg, &len); + return (s != NULL && lua_stringtonumber(L, s) == len + 1); + } +} + + +static void trymt (lua_State *L, const char *mtname) { + lua_settop(L, 2); /* back to the original arguments */ + if (l_unlikely(lua_type(L, 2) == LUA_TSTRING || + !luaL_getmetafield(L, 2, mtname))) + luaL_error(L, "attempt to %s a '%s' with a '%s'", mtname + 2, + luaL_typename(L, -2), luaL_typename(L, -1)); + lua_insert(L, -3); /* put metamethod before arguments */ + lua_call(L, 2, 1); /* call metamethod */ +} + + +static int arith (lua_State *L, int op, const char *mtname) { + if (tonum(L, 1) && tonum(L, 2)) + lua_arith(L, op); /* result will be on the top */ + else + trymt(L, mtname); return 1; } +static int arith_add (lua_State *L) { + return arith(L, LUA_OPADD, "__add"); +} + +static int arith_sub (lua_State *L) { + return arith(L, LUA_OPSUB, "__sub"); +} + +static int arith_mul (lua_State *L) { + return arith(L, LUA_OPMUL, "__mul"); +} + +static int arith_mod (lua_State *L) { + return arith(L, LUA_OPMOD, "__mod"); +} + +static int arith_pow (lua_State *L) { + return arith(L, LUA_OPPOW, "__pow"); +} + +static int arith_div (lua_State *L) { + return arith(L, LUA_OPDIV, "__div"); +} + +static int arith_idiv (lua_State *L) { + return arith(L, LUA_OPIDIV, "__idiv"); +} + +static int arith_unm (lua_State *L) { + return arith(L, LUA_OPUNM, "__unm"); +} + + +static const luaL_Reg stringmetamethods[] = { + {"__add", arith_add}, + {"__sub", arith_sub}, + {"__mul", arith_mul}, + {"__mod", arith_mod}, + {"__pow", arith_pow}, + {"__div", arith_div}, + {"__idiv", arith_idiv}, + {"__unm", arith_unm}, + {"__index", NULL}, /* placeholder */ + {NULL, NULL} +}; + +#endif /* } */ + +/* }====================================================== */ /* ** {====================================================== @@ -241,7 +385,8 @@ static const char *match (MatchState *ms, const char *s, const char *p); static int check_capture (MatchState *ms, int l) { l -= '1'; - if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) + if (l_unlikely(l < 0 || l >= ms->level || + ms->capture[l].len == CAP_UNFINISHED)) return luaL_error(ms->L, "invalid capture index %%%d", l + 1); return l; } @@ -258,14 +403,14 @@ static int capture_to_close (MatchState *ms) { static const char *classend (MatchState *ms, const char *p) { switch (*p++) { case L_ESC: { - if (p == ms->p_end) + if (l_unlikely(p == ms->p_end)) luaL_error(ms->L, "malformed pattern (ends with '%%')"); return p+1; } case '[': { if (*p == '^') p++; do { /* look for a ']' */ - if (p == ms->p_end) + if (l_unlikely(p == ms->p_end)) luaL_error(ms->L, "malformed pattern (missing ']')"); if (*(p++) == L_ESC && p < ms->p_end) p++; /* skip escapes (e.g. '%]') */ @@ -340,7 +485,7 @@ static int singlematch (MatchState *ms, const char *s, const char *p, static const char *matchbalance (MatchState *ms, const char *s, const char *p) { - if (p >= ms->p_end - 1) + if (l_unlikely(p >= ms->p_end - 1)) luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')"); if (*s != *p) return NULL; else { @@ -423,9 +568,9 @@ static const char *match_capture (MatchState *ms, const char *s, int l) { static const char *match (MatchState *ms, const char *s, const char *p) { - if (ms->matchdepth-- == 0) + if (l_unlikely(ms->matchdepth-- == 0)) luaL_error(ms->L, "pattern too complex"); - init: /* using goto's to optimize tail recursion */ + init: /* using goto to optimize tail recursion */ if (p != ms->p_end) { /* end of pattern? */ switch (*p) { case '(': { /* start capture */ @@ -457,7 +602,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { case 'f': { /* frontier? */ const char *ep; char previous; p += 2; - if (*p != '[') + if (l_unlikely(*p != '[')) luaL_error(ms->L, "missing '[' after '%%f' in pattern"); ep = classend(ms, p); /* points to what is next */ previous = (s == ms->src_init) ? '\0' : *(s - 1); @@ -547,25 +692,46 @@ static const char *lmemfind (const char *s1, size_t l1, } -static void push_onecapture (MatchState *ms, int i, const char *s, - const char *e) { +/* +** get information about the i-th capture. If there are no captures +** and 'i==0', return information about the whole match, which +** is the range 's'..'e'. If the capture is a string, return +** its length and put its address in '*cap'. If it is an integer +** (a position), push it on the stack and return CAP_POSITION. +*/ +static size_t get_onecapture (MatchState *ms, int i, const char *s, + const char *e, const char **cap) { if (i >= ms->level) { - if (i == 0) /* ms->level == 0, too */ - lua_pushlstring(ms->L, s, e - s); /* add whole match */ - else + if (l_unlikely(i != 0)) luaL_error(ms->L, "invalid capture index %%%d", i + 1); + *cap = s; + return e - s; } else { - ptrdiff_t l = ms->capture[i].len; - if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); - if (l == CAP_POSITION) + ptrdiff_t capl = ms->capture[i].len; + *cap = ms->capture[i].init; + if (l_unlikely(capl == CAP_UNFINISHED)) + luaL_error(ms->L, "unfinished capture"); + else if (capl == CAP_POSITION) lua_pushinteger(ms->L, (ms->capture[i].init - ms->src_init) + 1); - else - lua_pushlstring(ms->L, ms->capture[i].init, l); + return capl; } } +/* +** Push the i-th capture on the stack. +*/ +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + const char *cap; + ptrdiff_t l = get_onecapture(ms, i, s, e, &cap); + if (l != CAP_POSITION) + lua_pushlstring(ms->L, cap, l); + /* else position was already pushed */ +} + + static int push_captures (MatchState *ms, const char *s, const char *e) { int i; int nlevels = (ms->level == 0 && s) ? 1 : ms->level; @@ -608,16 +774,15 @@ static int str_find_aux (lua_State *L, int find) { size_t ls, lp; const char *s = luaL_checklstring(L, 1, &ls); const char *p = luaL_checklstring(L, 2, &lp); - lua_Integer init = posrelat(luaL_optinteger(L, 3, 1), ls); - if (init < 1) init = 1; - else if (init > (lua_Integer)ls + 1) { /* start after string's end? */ - lua_pushnil(L); /* cannot find anything */ + size_t init = posrelatI(luaL_optinteger(L, 3, 1), ls) - 1; + if (init > ls) { /* start after string's end? */ + luaL_pushfail(L); /* cannot find anything */ return 1; } /* explicit request or no special characters? */ if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { /* do a plain search */ - const char *s2 = lmemfind(s + init - 1, ls - (size_t)init + 1, p, lp); + const char *s2 = lmemfind(s + init, ls - init, p, lp); if (s2) { lua_pushinteger(L, (s2 - s) + 1); lua_pushinteger(L, (s2 - s) + lp); @@ -626,7 +791,7 @@ static int str_find_aux (lua_State *L, int find) { } else { MatchState ms; - const char *s1 = s + init - 1; + const char *s1 = s + init; int anchor = (*p == '^'); if (anchor) { p++; lp--; /* skip anchor character */ @@ -646,7 +811,7 @@ static int str_find_aux (lua_State *L, int find) { } } while (s1++ < ms.src_end && !anchor); } - lua_pushnil(L); /* not found */ + luaL_pushfail(L); /* not found */ return 1; } @@ -690,11 +855,14 @@ static int gmatch (lua_State *L) { size_t ls, lp; const char *s = luaL_checklstring(L, 1, &ls); const char *p = luaL_checklstring(L, 2, &lp); + size_t init = posrelatI(luaL_optinteger(L, 3, 1), ls) - 1; GMatchState *gm; - lua_settop(L, 2); /* keep them on closure to avoid being collected */ - gm = (GMatchState *)lua_newuserdata(L, sizeof(GMatchState)); + lua_settop(L, 2); /* keep strings on closure to avoid being collected */ + gm = (GMatchState *)lua_newuserdatauv(L, sizeof(GMatchState), 0); + if (init > ls) /* start after string's end? */ + init = ls + 1; /* avoid overflows in 's + init' */ prepstate(&gm->ms, L, s, ls, p, lp); - gm->src = s; gm->p = p; gm->lastmatch = NULL; + gm->src = s + init; gm->p = p; gm->lastmatch = NULL; lua_pushcclosure(L, gmatch_aux, 3); return 1; } @@ -702,60 +870,72 @@ static int gmatch (lua_State *L) { static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, const char *e) { - size_t l, i; + size_t l; lua_State *L = ms->L; const char *news = lua_tolstring(L, 3, &l); - for (i = 0; i < l; i++) { - if (news[i] != L_ESC) - luaL_addchar(b, news[i]); - else { - i++; /* skip ESC */ - if (!isdigit(uchar(news[i]))) { - if (news[i] != L_ESC) - luaL_error(L, "invalid use of '%c' in replacement string", L_ESC); - luaL_addchar(b, news[i]); - } - else if (news[i] == '0') - luaL_addlstring(b, s, e - s); - else { - push_onecapture(ms, news[i] - '1', s, e); - luaL_tolstring(L, -1, NULL); /* if number, convert it to string */ - lua_remove(L, -2); /* remove original value */ - luaL_addvalue(b); /* add capture to accumulated result */ - } + const char *p; + while ((p = (char *)memchr(news, L_ESC, l)) != NULL) { + luaL_addlstring(b, news, p - news); + p++; /* skip ESC */ + if (*p == L_ESC) /* '%%' */ + luaL_addchar(b, *p); + else if (*p == '0') /* '%0' */ + luaL_addlstring(b, s, e - s); + else if (isdigit(uchar(*p))) { /* '%n' */ + const char *cap; + ptrdiff_t resl = get_onecapture(ms, *p - '1', s, e, &cap); + if (resl == CAP_POSITION) + luaL_addvalue(b); /* add position to accumulated result */ + else + luaL_addlstring(b, cap, resl); } + else + luaL_error(L, "invalid use of '%c' in replacement string", L_ESC); + l -= p + 1 - news; + news = p + 1; } + luaL_addlstring(b, news, l); } -static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, - const char *e, int tr) { +/* +** Add the replacement value to the string buffer 'b'. +** Return true if the original string was changed. (Function calls and +** table indexing resulting in nil or false do not change the subject.) +*/ +static int add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e, int tr) { lua_State *L = ms->L; switch (tr) { - case LUA_TFUNCTION: { + case LUA_TFUNCTION: { /* call the function */ int n; - lua_pushvalue(L, 3); - n = push_captures(ms, s, e); - lua_call(L, n, 1); + lua_pushvalue(L, 3); /* push the function */ + n = push_captures(ms, s, e); /* all captures as arguments */ + lua_call(L, n, 1); /* call it */ break; } - case LUA_TTABLE: { - push_onecapture(ms, 0, s, e); + case LUA_TTABLE: { /* index the table */ + push_onecapture(ms, 0, s, e); /* first capture is the index */ lua_gettable(L, 3); break; } default: { /* LUA_TNUMBER or LUA_TSTRING */ - add_s(ms, b, s, e); - return; + add_s(ms, b, s, e); /* add value to the buffer */ + return 1; /* something changed */ } } if (!lua_toboolean(L, -1)) { /* nil or false? */ - lua_pop(L, 1); - lua_pushlstring(L, s, e - s); /* keep original text */ + lua_pop(L, 1); /* remove value */ + luaL_addlstring(b, s, e - s); /* keep original text */ + return 0; /* no changes */ + } + else if (l_unlikely(!lua_isstring(L, -1))) + return luaL_error(L, "invalid replacement value (a %s)", + luaL_typename(L, -1)); + else { + luaL_addvalue(b); /* add result to accumulator */ + return 1; /* something changed */ } - else if (!lua_isstring(L, -1)) - luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); - luaL_addvalue(b); /* add result to accumulator */ } @@ -768,11 +948,12 @@ static int str_gsub (lua_State *L) { lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1); /* max replacements */ int anchor = (*p == '^'); lua_Integer n = 0; /* replacement count */ + int changed = 0; /* change flag */ MatchState ms; luaL_Buffer b; - luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + luaL_argexpected(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, - "string/function/table expected"); + "string/function/table"); luaL_buffinit(L, &b); if (anchor) { p++; lp--; /* skip anchor character */ @@ -783,7 +964,7 @@ static int str_gsub (lua_State *L) { reprepstate(&ms); /* (re)prepare state for new match */ if ((e = match(&ms, src, p)) != NULL && e != lastmatch) { /* match? */ n++; - add_value(&ms, &b, src, e, tr); /* add replacement to buffer */ + changed = add_value(&ms, &b, src, e, tr) | changed; src = lastmatch = e; } else if (src < ms.src_end) /* otherwise, skip one character */ @@ -791,8 +972,12 @@ static int str_gsub (lua_State *L) { else break; /* end of subject */ if (anchor) break; } - luaL_addlstring(&b, src, ms.src_end-src); - luaL_pushresult(&b); + if (!changed) /* no changes? */ + lua_pushvalue(L, 1); /* return original string */ + else { /* something changed */ + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); /* create and return new string */ + } lua_pushinteger(L, n); /* number of substitutions */ return 2; } @@ -813,8 +998,6 @@ static int str_gsub (lua_State *L) { ** Hexadecimal floating-point formatter */ -#include - #define SIZELENMOD (sizeof(LUA_NUMBER_FRMLEN)/sizeof(char)) @@ -824,7 +1007,7 @@ static int str_gsub (lua_State *L) { ** to nibble boundaries by making what is left after that first digit a ** multiple of 4. */ -#define L_NBFD ((l_mathlim(MANT_DIG) - 1)%4 + 1) +#define L_NBFD ((l_floatatt(MANT_DIG) - 1)%4 + 1) /* @@ -851,7 +1034,7 @@ static int num2straux (char *buff, int sz, lua_Number x) { lua_Number m = l_mathop(frexp)(x, &e); /* 'x' fraction and exponent */ int n = 0; /* character count */ if (m < 0) { /* is number negative? */ - buff[n++] = '-'; /* add signal */ + buff[n++] = '-'; /* add sign */ m = -m; /* make it positive */ } buff[n++] = '0'; buff[n++] = 'x'; /* add "0x" */ @@ -878,7 +1061,7 @@ static int lua_number2strx (lua_State *L, char *buff, int sz, for (i = 0; i < n; i++) buff[i] = toupper(uchar(buff[i])); } - else if (fmt[SIZELENMOD] != 'a') + else if (l_unlikely(fmt[SIZELENMOD] != 'a')) return luaL_error(L, "modifiers for format '%%a'/'%%A' not implemented"); return n; } @@ -887,20 +1070,51 @@ static int lua_number2strx (lua_State *L, char *buff, int sz, /* -** Maximum size of each formatted item. This maximum size is produced +** Maximum size for items formatted with '%f'. This size is produced ** by format('%.99f', -maxfloat), and is equal to 99 + 3 ('-', '.', ** and '\0') + number of decimal digits to represent maxfloat (which -** is maximum exponent + 1). (99+3+1 then rounded to 120 for "extra -** expenses", such as locale-dependent stuff) +** is maximum exponent + 1). (99+3+1, adding some extra, 110) */ -#define MAX_ITEM (120 + l_mathlim(MAX_10_EXP)) +#define MAX_ITEMF (110 + l_floatatt(MAX_10_EXP)) + + +/* +** All formats except '%f' do not need that large limit. The other +** float formats use exponents, so that they fit in the 99 limit for +** significant digits; 's' for large strings and 'q' add items directly +** to the buffer; all integer formats also fit in the 99 limit. The +** worst case are floats: they may need 99 significant digits, plus +** '0x', '-', '.', 'e+XXXX', and '\0'. Adding some extra, 120. +*/ +#define MAX_ITEM 120 /* valid flags in a format specification */ -#define FLAGS "-+ #0" +#if !defined(L_FMTFLAGSF) + +/* valid flags for a, A, e, E, f, F, g, and G conversions */ +#define L_FMTFLAGSF "-+#0 " + +/* valid flags for o, x, and X conversions */ +#define L_FMTFLAGSX "-#0" + +/* valid flags for d and i conversions */ +#define L_FMTFLAGSI "-+0 " + +/* valid flags for u conversions */ +#define L_FMTFLAGSU "-0" + +/* valid flags for c, p, and s conversions */ +#define L_FMTFLAGSC "-" + +#endif + /* -** maximum size of each format specification (such as "%-099.99d") +** Maximum size of each format specification (such as "%-099.99d"): +** Initial '%', flags (up to 5), width (2), period, precision (2), +** length modifier (8), conversion specifier, and final '\0', plus some +** extra. */ #define MAX_FORMAT 32 @@ -929,14 +1143,32 @@ static void addquoted (luaL_Buffer *b, const char *s, size_t len) { /* -** Ensures the 'buff' string uses a dot as the radix character. +** Serialize a floating-point number in such a way that it can be +** scanned back by Lua. Use hexadecimal format for "common" numbers +** (to preserve precision); inf, -inf, and NaN are handled separately. +** (NaN cannot be expressed as a numeral, so we write '(0/0)' for it.) */ -static void checkdp (char *buff, int nb) { - if (memchr(buff, '.', nb) == NULL) { /* no dot? */ - char point = lua_getlocaledecpoint(); /* try locale point */ - char *ppoint = (char *)memchr(buff, point, nb); - if (ppoint) *ppoint = '.'; /* change it to a dot */ +static int quotefloat (lua_State *L, char *buff, lua_Number n) { + const char *s; /* for the fixed representations */ + if (n == (lua_Number)HUGE_VAL) /* inf? */ + s = "1e9999"; + else if (n == -(lua_Number)HUGE_VAL) /* -inf? */ + s = "-1e9999"; + else if (n != n) /* NaN? */ + s = "(0/0)"; + else { /* format number as hexadecimal */ + int nb = lua_number2strx(L, buff, MAX_ITEM, + "%" LUA_NUMBER_FRMLEN "a", n); + /* ensures that 'buff' string uses a dot as the radix character */ + if (memchr(buff, '.', nb) == NULL) { /* no dot? */ + char point = lua_getlocaledecpoint(); /* try locale point */ + char *ppoint = (char *)memchr(buff, point, nb); + if (ppoint) *ppoint = '.'; /* change it to a dot */ + } + return nb; } + /* for the fixed representations */ + return l_sprintf(buff, MAX_ITEM, "%s", s); } @@ -951,15 +1183,12 @@ static void addliteral (lua_State *L, luaL_Buffer *b, int arg) { case LUA_TNUMBER: { char *buff = luaL_prepbuffsize(b, MAX_ITEM); int nb; - if (!lua_isinteger(L, arg)) { /* float? */ - lua_Number n = lua_tonumber(L, arg); /* write as hexa ('%a') */ - nb = lua_number2strx(L, buff, MAX_ITEM, "%" LUA_NUMBER_FRMLEN "a", n); - checkdp(buff, nb); /* ensure it uses a dot */ - } + if (!lua_isinteger(L, arg)) /* float? */ + nb = quotefloat(L, buff, lua_tonumber(L, arg)); else { /* integers */ lua_Integer n = lua_tointeger(L, arg); const char *format = (n == LUA_MININTEGER) /* corner case? */ - ? "0x%" LUA_INTEGER_FRMLEN "x" /* use hexa */ + ? "0x%" LUA_INTEGER_FRMLEN "x" /* use hex */ : LUA_INTEGER_FMT; /* else use default format */ nb = l_sprintf(buff, MAX_ITEM, format, (LUAI_UACINT)n); } @@ -978,25 +1207,53 @@ static void addliteral (lua_State *L, luaL_Buffer *b, int arg) { } -static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { - const char *p = strfrmt; - while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ - if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) - luaL_error(L, "invalid format (repeated flags)"); - if (isdigit(uchar(*p))) p++; /* skip width */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - if (*p == '.') { - p++; - if (isdigit(uchar(*p))) p++; /* skip precision */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ +static const char *get2digits (const char *s) { + if (isdigit(uchar(*s))) { + s++; + if (isdigit(uchar(*s))) s++; /* (2 digits at most) */ } - if (isdigit(uchar(*p))) - luaL_error(L, "invalid format (width or precision too long)"); + return s; +} + + +/* +** Check whether a conversion specification is valid. When called, +** first character in 'form' must be '%' and last character must +** be a valid conversion specifier. 'flags' are the accepted flags; +** 'precision' signals whether to accept a precision. +*/ +static void checkformat (lua_State *L, const char *form, const char *flags, + int precision) { + const char *spec = form + 1; /* skip '%' */ + spec += strspn(spec, flags); /* skip flags */ + if (*spec != '0') { /* a width cannot start with '0' */ + spec = get2digits(spec); /* skip width */ + if (*spec == '.' && precision) { + spec++; + spec = get2digits(spec); /* skip precision */ + } + } + if (!isalpha(uchar(*spec))) /* did not go to the end? */ + luaL_error(L, "invalid conversion specification: '%s'", form); +} + + +/* +** Get a conversion specification and copy it to 'form'. +** Return the address of its last character. +*/ +static const char *getformat (lua_State *L, const char *strfrmt, + char *form) { + /* spans flags, width, and precision ('0' is included as a flag) */ + size_t len = strspn(strfrmt, L_FMTFLAGSF "123456789."); + len++; /* adds following character (should be the specifier) */ + /* still needs space for '%', '\0', plus a length modifier */ + if (len >= MAX_FORMAT - 10) + luaL_error(L, "invalid format (too long)"); *(form++) = '%'; - memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char)); - form += (p - strfrmt) + 1; - *form = '\0'; - return p; + memcpy(form, strfrmt, len * sizeof(char)); + *(form + len) = '\0'; + return strfrmt + len - 1; } @@ -1019,6 +1276,7 @@ static int str_format (lua_State *L) { size_t sfl; const char *strfrmt = luaL_checklstring(L, arg, &sfl); const char *strfrmt_end = strfrmt+sfl; + const char *flags; luaL_Buffer b; luaL_buffinit(L, &b); while (strfrmt < strfrmt_end) { @@ -1028,36 +1286,63 @@ static int str_format (lua_State *L) { luaL_addchar(&b, *strfrmt++); /* %% */ else { /* format item */ char form[MAX_FORMAT]; /* to store the format ('%...') */ - char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ - int nb = 0; /* number of bytes in added item */ + int maxitem = MAX_ITEM; /* maximum length for the result */ + char *buff = luaL_prepbuffsize(&b, maxitem); /* to put result */ + int nb = 0; /* number of bytes in result */ if (++arg > top) - luaL_argerror(L, arg, "no value"); - strfrmt = scanformat(L, strfrmt, form); + return luaL_argerror(L, arg, "no value"); + strfrmt = getformat(L, strfrmt, form); switch (*strfrmt++) { case 'c': { - nb = l_sprintf(buff, MAX_ITEM, form, (int)luaL_checkinteger(L, arg)); + checkformat(L, form, L_FMTFLAGSC, 0); + nb = l_sprintf(buff, maxitem, form, (int)luaL_checkinteger(L, arg)); break; } case 'd': case 'i': - case 'o': case 'u': case 'x': case 'X': { + flags = L_FMTFLAGSI; + goto intcase; + case 'u': + flags = L_FMTFLAGSU; + goto intcase; + case 'o': case 'x': case 'X': + flags = L_FMTFLAGSX; + intcase: { lua_Integer n = luaL_checkinteger(L, arg); + checkformat(L, form, flags, 1); addlenmod(form, LUA_INTEGER_FRMLEN); - nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACINT)n); + nb = l_sprintf(buff, maxitem, form, (LUAI_UACINT)n); break; } case 'a': case 'A': + checkformat(L, form, L_FMTFLAGSF, 1); addlenmod(form, LUA_NUMBER_FRMLEN); - nb = lua_number2strx(L, buff, MAX_ITEM, form, + nb = lua_number2strx(L, buff, maxitem, form, luaL_checknumber(L, arg)); break; - case 'e': case 'E': case 'f': - case 'g': case 'G': { + case 'f': + maxitem = MAX_ITEMF; /* extra space for '%f' */ + buff = luaL_prepbuffsize(&b, maxitem); + /* FALLTHROUGH */ + case 'e': case 'E': case 'g': case 'G': { lua_Number n = luaL_checknumber(L, arg); + checkformat(L, form, L_FMTFLAGSF, 1); addlenmod(form, LUA_NUMBER_FRMLEN); - nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACNUMBER)n); + nb = l_sprintf(buff, maxitem, form, (LUAI_UACNUMBER)n); + break; + } + case 'p': { + const void *p = lua_topointer(L, arg); + checkformat(L, form, L_FMTFLAGSC, 0); + if (p == NULL) { /* avoid calling 'printf' with argument NULL */ + p = "(null)"; /* result */ + form[strlen(form) - 1] = 's'; /* format it as a string */ + } + nb = l_sprintf(buff, maxitem, form, p); break; } case 'q': { + if (form[2] != '\0') /* modifiers? */ + return luaL_error(L, "specifier '%%q' cannot have modifiers"); addliteral(L, &b, arg); break; } @@ -1068,23 +1353,23 @@ static int str_format (lua_State *L) { luaL_addvalue(&b); /* keep entire string */ else { luaL_argcheck(L, l == strlen(s), arg, "string contains zeros"); - if (!strchr(form, '.') && l >= 100) { + checkformat(L, form, L_FMTFLAGSC, 1); + if (strchr(form, '.') == NULL && l >= 100) { /* no precision and string is too long to be formatted */ luaL_addvalue(&b); /* keep entire string */ } else { /* format the string into 'buff' */ - nb = l_sprintf(buff, MAX_ITEM, form, s); + nb = l_sprintf(buff, maxitem, form, s); lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ } } break; } default: { /* also treat cases 'pnLlh' */ - return luaL_error(L, "invalid option '%%%c' to 'format'", - *(strfrmt - 1)); + return luaL_error(L, "invalid conversion '%s' to 'format'", form); } } - lua_assert(nb < MAX_ITEM); + lua_assert(nb < maxitem); luaL_addsize(&b, nb); } } @@ -1127,26 +1412,6 @@ static const union { } nativeendian = {1}; -/* dummy structure to get native alignment requirements */ -struct cD { - char c; - union { double d; void *p; lua_Integer i; lua_Number n; } u; -}; - -#define MAXALIGN (offsetof(struct cD, u)) - - -/* -** Union for serializing floats -*/ -typedef union Ftypes { - float f; - double d; - lua_Number n; - char buff[5 * sizeof(lua_Number)]; /* enough for any float type */ -} Ftypes; - - /* ** information to pack/unpack stuff */ @@ -1163,7 +1428,9 @@ typedef struct Header { typedef enum KOption { Kint, /* signed integers */ Kuint, /* unsigned integers */ - Kfloat, /* floating-point numbers */ + Kfloat, /* single-precision floating-point numbers */ + Knumber, /* Lua "native" floating-point numbers */ + Kdouble, /* double-precision floating-point numbers */ Kchar, /* fixed-length strings */ Kstring, /* strings with prefixed length */ Kzstr, /* zero-terminated strings */ @@ -1198,7 +1465,7 @@ static int getnum (const char **fmt, int df) { */ static int getnumlimit (Header *h, const char **fmt, int df) { int sz = getnum(fmt, df); - if (sz > MAXINTSIZE || sz <= 0) + if (l_unlikely(sz > MAXINTSIZE || sz <= 0)) return luaL_error(h->L, "integral size (%d) out of limits [1,%d]", sz, MAXINTSIZE); return sz; @@ -1219,6 +1486,8 @@ static void initheader (lua_State *L, Header *h) { ** Read and classify next option. 'size' is filled with option's size. */ static KOption getoption (Header *h, const char **fmt, int *size) { + /* dummy structure to get native alignment requirements */ + struct cD { char c; union { LUAI_MAXALIGN; } u; }; int opt = *((*fmt)++); *size = 0; /* default */ switch (opt) { @@ -1232,14 +1501,14 @@ static KOption getoption (Header *h, const char **fmt, int *size) { case 'J': *size = sizeof(lua_Integer); return Kuint; case 'T': *size = sizeof(size_t); return Kuint; case 'f': *size = sizeof(float); return Kfloat; - case 'd': *size = sizeof(double); return Kfloat; - case 'n': *size = sizeof(lua_Number); return Kfloat; + case 'n': *size = sizeof(lua_Number); return Knumber; + case 'd': *size = sizeof(double); return Kdouble; case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint; case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint; case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring; case 'c': *size = getnum(fmt, -1); - if (*size == -1) + if (l_unlikely(*size == -1)) luaL_error(h->L, "missing size for format option 'c'"); return Kchar; case 'z': return Kzstr; @@ -1249,7 +1518,11 @@ static KOption getoption (Header *h, const char **fmt, int *size) { case '<': h->islittle = 1; break; case '>': h->islittle = 0; break; case '=': h->islittle = nativeendian.little; break; - case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break; + case '!': { + const int maxalign = offsetof(struct cD, u); + h->maxalign = getnumlimit(h, fmt, maxalign); + break; + } default: luaL_error(h->L, "invalid format option '%c'", opt); } return Knop; @@ -1278,7 +1551,7 @@ static KOption getdetails (Header *h, size_t totalsize, else { if (align > h->maxalign) /* enforce maximum alignment */ align = h->maxalign; - if ((align & (align - 1)) != 0) /* is 'align' not a power of 2? */ + if (l_unlikely((align & (align - 1)) != 0)) /* not a power of 2? */ luaL_argerror(h->L, 1, "format asks for alignment not power of 2"); *ntoalign = (align - (int)(totalsize & (align - 1))) & (align - 1); } @@ -1313,12 +1586,10 @@ static void packint (luaL_Buffer *b, lua_Unsigned n, ** Copy 'size' bytes from 'src' to 'dest', correcting endianness if ** given 'islittle' is different from native endianness. */ -static void copywithendian (volatile char *dest, volatile const char *src, +static void copywithendian (char *dest, const char *src, int size, int islittle) { - if (islittle == nativeendian.little) { - while (size-- != 0) - *(dest++) = *(src++); - } + if (islittle == nativeendian.little) + memcpy(dest, src, size); else { dest += size - 1; while (size-- != 0) @@ -1361,15 +1632,27 @@ static int str_pack (lua_State *L) { packint(&b, (lua_Unsigned)n, h.islittle, size, 0); break; } - case Kfloat: { /* floating-point options */ - volatile Ftypes u; - char *buff = luaL_prepbuffsize(&b, size); - lua_Number n = luaL_checknumber(L, arg); /* get argument */ - if (size == sizeof(u.f)) u.f = (float)n; /* copy it into 'u' */ - else if (size == sizeof(u.d)) u.d = (double)n; - else u.n = n; - /* move 'u' to final result, correcting endianness if needed */ - copywithendian(buff, u.buff, size, h.islittle); + case Kfloat: { /* C float */ + float f = (float)luaL_checknumber(L, arg); /* get argument */ + char *buff = luaL_prepbuffsize(&b, sizeof(f)); + /* move 'f' to final result, correcting endianness if needed */ + copywithendian(buff, (char *)&f, sizeof(f), h.islittle); + luaL_addsize(&b, size); + break; + } + case Knumber: { /* Lua float */ + lua_Number f = luaL_checknumber(L, arg); /* get argument */ + char *buff = luaL_prepbuffsize(&b, sizeof(f)); + /* move 'f' to final result, correcting endianness if needed */ + copywithendian(buff, (char *)&f, sizeof(f), h.islittle); + luaL_addsize(&b, size); + break; + } + case Kdouble: { /* C double */ + double f = (double)luaL_checknumber(L, arg); /* get argument */ + char *buff = luaL_prepbuffsize(&b, sizeof(f)); + /* move 'f' to final result, correcting endianness if needed */ + copywithendian(buff, (char *)&f, sizeof(f), h.islittle); luaL_addsize(&b, size); break; } @@ -1422,17 +1705,12 @@ static int str_packsize (lua_State *L) { while (*fmt != '\0') { int size, ntoalign; KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign); + luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1, + "variable-length format"); size += ntoalign; /* total space used by option */ luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, "format result too large"); totalsize += size; - switch (opt) { - case Kstring: /* strings with length count */ - case Kzstr: /* zero-terminated string */ - luaL_argerror(L, 1, "variable-length format"); - /* call never return, but to avoid warnings: *//* FALLTHROUGH */ - default: break; - } } lua_pushinteger(L, (lua_Integer)totalsize); return 1; @@ -1465,7 +1743,7 @@ static lua_Integer unpackint (lua_State *L, const char *str, else if (size > SZINT) { /* must check unread bytes */ int mask = (!issigned || (lua_Integer)res >= 0) ? 0 : MC; for (i = limit; i < size; i++) { - if ((unsigned char)str[islittle ? i : size - 1 - i] != mask) + if (l_unlikely((unsigned char)str[islittle ? i : size - 1 - i] != mask)) luaL_error(L, "%d-byte integer does not fit into Lua Integer", size); } } @@ -1478,15 +1756,15 @@ static int str_unpack (lua_State *L) { const char *fmt = luaL_checkstring(L, 1); size_t ld; const char *data = luaL_checklstring(L, 2, &ld); - size_t pos = (size_t)posrelat(luaL_optinteger(L, 3, 1), ld) - 1; + size_t pos = posrelatI(luaL_optinteger(L, 3, 1), ld) - 1; int n = 0; /* number of results */ luaL_argcheck(L, pos <= ld, 3, "initial position out of string"); initheader(L, &h); while (*fmt != '\0') { int size, ntoalign; KOption opt = getdetails(&h, pos, &fmt, &size, &ntoalign); - if ((size_t)ntoalign + size > ~pos || pos + ntoalign + size > ld) - luaL_argerror(L, 2, "data string too short"); + luaL_argcheck(L, (size_t)ntoalign + size <= ld - pos, 2, + "data string too short"); pos += ntoalign; /* skip alignment */ /* stack space for item + next position */ luaL_checkstack(L, 2, "too many results"); @@ -1500,13 +1778,21 @@ static int str_unpack (lua_State *L) { break; } case Kfloat: { - volatile Ftypes u; - lua_Number num; - copywithendian(u.buff, data + pos, size, h.islittle); - if (size == sizeof(u.f)) num = (lua_Number)u.f; - else if (size == sizeof(u.d)) num = (lua_Number)u.d; - else num = u.n; - lua_pushnumber(L, num); + float f; + copywithendian((char *)&f, data + pos, sizeof(f), h.islittle); + lua_pushnumber(L, (lua_Number)f); + break; + } + case Knumber: { + lua_Number f; + copywithendian((char *)&f, data + pos, sizeof(f), h.islittle); + lua_pushnumber(L, f); + break; + } + case Kdouble: { + double f; + copywithendian((char *)&f, data + pos, sizeof(f), h.islittle); + lua_pushnumber(L, (lua_Number)f); break; } case Kchar: { @@ -1515,13 +1801,15 @@ static int str_unpack (lua_State *L) { } case Kstring: { size_t len = (size_t)unpackint(L, data + pos, h.islittle, size, 0); - luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short"); + luaL_argcheck(L, len <= ld - pos - size, 2, "data string too short"); lua_pushlstring(L, data + pos + size, len); pos += len; /* skip string */ break; } case Kzstr: { - size_t len = (int)strlen(data + pos); + size_t len = strlen(data + pos); + luaL_argcheck(L, pos + len < ld, 2, + "unfinished string for format 'z'"); lua_pushlstring(L, data + pos, len); pos += len + 1; /* skip string plus final '\0' */ break; @@ -1562,7 +1850,9 @@ static const luaL_Reg strlib[] = { static void createmetatable (lua_State *L) { - lua_createtable(L, 0, 1); /* table to be metatable for strings */ + /* table to be metatable for strings */ + luaL_newlibtable(L, stringmetamethods); + luaL_setfuncs(L, stringmetamethods, 0); lua_pushliteral(L, ""); /* dummy string */ lua_pushvalue(L, -2); /* copy table */ lua_setmetatable(L, -2); /* set table as metatable for strings */ diff --git a/liblua/ltable.c b/liblua/ltable.c index ea4fe7fc..3353c047 100644 --- a/liblua/ltable.c +++ b/liblua/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.118.1.4 2018/06/08 16:22:51 roberto Exp $ +** $Id: ltable.c $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -40,46 +40,80 @@ /* -** Maximum size of array part (MAXASIZE) is 2^MAXABITS. MAXABITS is -** the largest integer such that MAXASIZE fits in an unsigned int. +** MAXABITS is the largest integer such that MAXASIZE fits in an +** unsigned int. */ #define MAXABITS cast_int(sizeof(int) * CHAR_BIT - 1) -#define MAXASIZE (1u << MAXABITS) + /* -** Maximum size of hash part is 2^MAXHBITS. MAXHBITS is the largest -** integer such that 2^MAXHBITS fits in a signed int. (Note that the -** maximum number of elements in a table, 2^MAXABITS + 2^MAXHBITS, still -** fits comfortably in an unsigned int.) +** MAXASIZE is the maximum size of the array part. It is the minimum +** between 2^MAXABITS and the maximum size that, measured in bytes, +** fits in a 'size_t'. +*/ +#define MAXASIZE luaM_limitN(1u << MAXABITS, TValue) + +/* +** MAXHBITS is the largest integer such that 2^MAXHBITS fits in a +** signed int. */ #define MAXHBITS (MAXABITS - 1) -#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) +/* +** MAXHSIZE is the maximum size of the hash part. It is the minimum +** between 2^MAXHBITS and the maximum size such that, measured in bytes, +** it fits in a 'size_t'. +*/ +#define MAXHSIZE luaM_limitN(1u << MAXHBITS, Node) -#define hashstr(t,str) hashpow2(t, (str)->hash) -#define hashboolean(t,p) hashpow2(t, p) -#define hashint(t,i) hashpow2(t, i) +/* +** When the original hash value is good, hashing by a power of 2 +** avoids the cost of '%'. +*/ +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) /* -** for some types, it is better to avoid modulus by power of 2, as -** they tend to have many 2 factors. +** for other types, it is better to avoid modulo by power of 2, as +** they can have many 2 factors. */ #define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) +#define hashstr(t,str) hashpow2(t, (str)->hash) +#define hashboolean(t,p) hashpow2(t, p) + + #define hashpointer(t,p) hashmod(t, point2uint(p)) #define dummynode (&dummynode_) static const Node dummynode_ = { - {NILCONSTANT}, /* value */ - {{NILCONSTANT, 0}} /* key */ + {{NULL}, LUA_VEMPTY, /* value's value and type */ + LUA_VNIL, 0, {NULL}} /* key type, next, and key value */ }; +static const TValue absentkey = {ABSTKEYCONSTANT}; + + +/* +** Hash for integers. To allow a good hash, use the remainder operator +** ('%'). If integer fits as a non-negative int, compute an int +** remainder, which is faster. Otherwise, use an unsigned-integer +** remainder, which uses all bits and ensures a non-negative result. +*/ +static Node *hashint (const Table *t, lua_Integer i) { + lua_Unsigned ui = l_castS2U(i); + if (ui <= cast_uint(INT_MAX)) + return hashmod(t, cast_int(ui)); + else + return hashmod(t, ui); +} + + /* ** Hash for floating-point numbers. ** The main computation should be just @@ -103,51 +137,189 @@ static int l_hashfloat (lua_Number n) { return 0; } else { /* normal case */ - unsigned int u = cast(unsigned int, i) + cast(unsigned int, ni); - return cast_int(u <= cast(unsigned int, INT_MAX) ? u : ~u); + unsigned int u = cast_uint(i) + cast_uint(ni); + return cast_int(u <= cast_uint(INT_MAX) ? u : ~u); } } #endif /* -** returns the 'main' position of an element in a table (that is, the index -** of its hash value) -*/ -static Node *mainposition (const Table *t, const TValue *key) { - switch (ttype(key)) { - case LUA_TNUMINT: - return hashint(t, ivalue(key)); - case LUA_TNUMFLT: - return hashmod(t, l_hashfloat(fltvalue(key))); - case LUA_TSHRSTR: - return hashstr(t, tsvalue(key)); - case LUA_TLNGSTR: - return hashpow2(t, luaS_hashlongstr(tsvalue(key))); - case LUA_TBOOLEAN: - return hashboolean(t, bvalue(key)); - case LUA_TLIGHTUSERDATA: - return hashpointer(t, pvalue(key)); - case LUA_TLCF: - return hashpointer(t, fvalue(key)); +** returns the 'main' position of an element in a table (that is, +** the index of its hash value). +*/ +static Node *mainpositionTV (const Table *t, const TValue *key) { + switch (ttypetag(key)) { + case LUA_VNUMINT: { + lua_Integer i = ivalue(key); + return hashint(t, i); + } + case LUA_VNUMFLT: { + lua_Number n = fltvalue(key); + return hashmod(t, l_hashfloat(n)); + } + case LUA_VSHRSTR: { + TString *ts = tsvalue(key); + return hashstr(t, ts); + } + case LUA_VLNGSTR: { + TString *ts = tsvalue(key); + return hashpow2(t, luaS_hashlongstr(ts)); + } + case LUA_VFALSE: + return hashboolean(t, 0); + case LUA_VTRUE: + return hashboolean(t, 1); + case LUA_VLIGHTUSERDATA: { + void *p = pvalue(key); + return hashpointer(t, p); + } + case LUA_VLCF: { + lua_CFunction f = fvalue(key); + return hashpointer(t, f); + } + default: { + GCObject *o = gcvalue(key); + return hashpointer(t, o); + } + } +} + + +l_sinline Node *mainpositionfromnode (const Table *t, Node *nd) { + TValue key; + getnodekey(cast(lua_State *, NULL), &key, nd); + return mainpositionTV(t, &key); +} + + +/* +** Check whether key 'k1' is equal to the key in node 'n2'. This +** equality is raw, so there are no metamethods. Floats with integer +** values have been normalized, so integers cannot be equal to +** floats. It is assumed that 'eqshrstr' is simply pointer equality, so +** that short strings are handled in the default case. +** A true 'deadok' means to accept dead keys as equal to their original +** values. All dead keys are compared in the default case, by pointer +** identity. (Only collectable objects can produce dead keys.) Note that +** dead long strings are also compared by identity. +** Once a key is dead, its corresponding value may be collected, and +** then another value can be created with the same address. If this +** other value is given to 'next', 'equalkey' will signal a false +** positive. In a regular traversal, this situation should never happen, +** as all keys given to 'next' came from the table itself, and therefore +** could not have been collected. Outside a regular traversal, we +** have garbage in, garbage out. What is relevant is that this false +** positive does not break anything. (In particular, 'next' will return +** some other valid item on the table or nil.) +*/ +static int equalkey (const TValue *k1, const Node *n2, int deadok) { + if ((rawtt(k1) != keytt(n2)) && /* not the same variants? */ + !(deadok && keyisdead(n2) && iscollectable(k1))) + return 0; /* cannot be same key */ + switch (keytt(n2)) { + case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE: + return 1; + case LUA_VNUMINT: + return (ivalue(k1) == keyival(n2)); + case LUA_VNUMFLT: + return luai_numeq(fltvalue(k1), fltvalueraw(keyval(n2))); + case LUA_VLIGHTUSERDATA: + return pvalue(k1) == pvalueraw(keyval(n2)); + case LUA_VLCF: + return fvalue(k1) == fvalueraw(keyval(n2)); + case ctb(LUA_VLNGSTR): + return luaS_eqlngstr(tsvalue(k1), keystrval(n2)); default: - lua_assert(!ttisdeadkey(key)); - return hashpointer(t, gcvalue(key)); + return gcvalue(k1) == gcvalueraw(keyval(n2)); } } /* -** returns the index for 'key' if 'key' is an appropriate key to live in -** the array part of the table, 0 otherwise. +** True if value of 'alimit' is equal to the real size of the array +** part of table 't'. (Otherwise, the array part must be larger than +** 'alimit'.) +*/ +#define limitequalsasize(t) (isrealasize(t) || ispow2((t)->alimit)) + + +/* +** Returns the real size of the 'array' array */ -static unsigned int arrayindex (const TValue *key) { - if (ttisinteger(key)) { - lua_Integer k = ivalue(key); - if (0 < k && (lua_Unsigned)k <= MAXASIZE) - return cast(unsigned int, k); /* 'key' is an appropriate array index */ +LUAI_FUNC unsigned int luaH_realasize (const Table *t) { + if (limitequalsasize(t)) + return t->alimit; /* this is the size */ + else { + unsigned int size = t->alimit; + /* compute the smallest power of 2 not smaller than 'size' */ + size |= (size >> 1); + size |= (size >> 2); + size |= (size >> 4); + size |= (size >> 8); +#if (UINT_MAX >> 14) > 3 /* unsigned int has more than 16 bits */ + size |= (size >> 16); +#if (UINT_MAX >> 30) > 3 + size |= (size >> 32); /* unsigned int has more than 32 bits */ +#endif +#endif + size++; + lua_assert(ispow2(size) && size/2 < t->alimit && t->alimit < size); + return size; } - return 0; /* 'key' did not match some condition */ +} + + +/* +** Check whether real size of the array is a power of 2. +** (If it is not, 'alimit' cannot be changed to any other value +** without changing the real size.) +*/ +static int ispow2realasize (const Table *t) { + return (!isrealasize(t) || ispow2(t->alimit)); +} + + +static unsigned int setlimittosize (Table *t) { + t->alimit = luaH_realasize(t); + setrealasize(t); + return t->alimit; +} + + +#define limitasasize(t) check_exp(isrealasize(t), t->alimit) + + + +/* +** "Generic" get version. (Not that generic: not valid for integers, +** which may be in array part, nor for floats with integral values.) +** See explanation about 'deadok' in function 'equalkey'. +*/ +static const TValue *getgeneric (Table *t, const TValue *key, int deadok) { + Node *n = mainpositionTV(t, key); + for (;;) { /* check whether 'key' is somewhere in the chain */ + if (equalkey(key, n, deadok)) + return gval(n); /* that's it */ + else { + int nx = gnext(n); + if (nx == 0) + return &absentkey; /* not found */ + n += nx; + } + } +} + + +/* +** returns the index for 'k' if 'k' is an appropriate key to live in +** the array part of a table, 0 otherwise. +*/ +static unsigned int arrayindex (lua_Integer k) { + if (l_castS2U(k) - 1u < MAXASIZE) /* 'k' in [1, MAXASIZE]? */ + return cast_uint(k); /* 'key' is an appropriate array index */ + else + return 0; } @@ -156,46 +328,39 @@ static unsigned int arrayindex (const TValue *key) { ** elements in the array part, then elements in the hash part. The ** beginning of a traversal is signaled by 0. */ -static unsigned int findindex (lua_State *L, Table *t, StkId key) { +static unsigned int findindex (lua_State *L, Table *t, TValue *key, + unsigned int asize) { unsigned int i; if (ttisnil(key)) return 0; /* first iteration */ - i = arrayindex(key); - if (i != 0 && i <= t->sizearray) /* is 'key' inside array part? */ + i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0; + if (i - 1u < asize) /* is 'key' inside array part? */ return i; /* yes; that's the index */ else { - int nx; - Node *n = mainposition(t, key); - for (;;) { /* check whether 'key' is somewhere in the chain */ - /* key may be dead already, but it is ok to use it in 'next' */ - if (luaV_rawequalobj(gkey(n), key) || - (ttisdeadkey(gkey(n)) && iscollectable(key) && - deadvalue(gkey(n)) == gcvalue(key))) { - i = cast_int(n - gnode(t, 0)); /* key index in hash table */ - /* hash elements are numbered after array ones */ - return (i + 1) + t->sizearray; - } - nx = gnext(n); - if (nx == 0) - luaG_runerror(L, "invalid key to 'next'"); /* key not found */ - else n += nx; - } + const TValue *n = getgeneric(t, key, 1); + if (l_unlikely(isabstkey(n))) + luaG_runerror(L, "invalid key to 'next'"); /* key not found */ + i = cast_int(nodefromval(n) - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return (i + 1) + asize; } } int luaH_next (lua_State *L, Table *t, StkId key) { - unsigned int i = findindex(L, t, key); /* find original element */ - for (; i < t->sizearray; i++) { /* try first array part */ - if (!ttisnil(&t->array[i])) { /* a non-nil value? */ - setivalue(key, i + 1); - setobj2s(L, key+1, &t->array[i]); + unsigned int asize = luaH_realasize(t); + unsigned int i = findindex(L, t, s2v(key), asize); /* find original key */ + for (; i < asize; i++) { /* try first array part */ + if (!isempty(&t->array[i])) { /* a non-empty entry? */ + setivalue(s2v(key), i + 1); + setobj2s(L, key + 1, &t->array[i]); return 1; } } - for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */ - if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ - setobj2s(L, key, gkey(gnode(t, i))); - setobj2s(L, key+1, gval(gnode(t, i))); + for (i -= asize; cast_int(i) < sizenode(t); i++) { /* hash part */ + if (!isempty(gval(gnode(t, i)))) { /* a non-empty entry? */ + Node *n = gnode(t, i); + getnodekey(L, s2v(key), n); + setobj2s(L, key + 1, gval(n)); return 1; } } @@ -203,6 +368,12 @@ int luaH_next (lua_State *L, Table *t, StkId key) { } +static void freehash (lua_State *L, Table *t) { + if (!isdummy(t)) + luaM_freearray(L, t->node, cast_sizet(sizenode(t))); +} + + /* ** {============================================================= ** Rehash @@ -214,7 +385,8 @@ int luaH_next (lua_State *L, Table *t, StkId key) { ** "count array" where 'nums[i]' is the number of integers in the table ** between 2^(i - 1) + 1 and 2^i. 'pna' enters with the total number of ** integer keys in the table and leaves with the number of keys that -** will go to the array part; return the optimal size. +** will go to the array part; return the optimal size. (The condition +** 'twotoi > 0' in the for loop stops the loop if 'twotoi' overflows.) */ static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { int i; @@ -226,12 +398,10 @@ static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { for (i = 0, twotoi = 1; twotoi > 0 && *pna > twotoi / 2; i++, twotoi *= 2) { - if (nums[i] > 0) { - a += nums[i]; - if (a > twotoi/2) { /* more than half elements present? */ - optimal = twotoi; /* optimal size (till now) */ - na = a; /* all elements up to 'optimal' will go to array part */ - } + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + optimal = twotoi; /* optimal size (till now) */ + na = a; /* all elements up to 'optimal' will go to array part */ } } lua_assert((optimal == 0 || optimal / 2 < na) && na <= optimal); @@ -240,7 +410,7 @@ static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { } -static int countint (const TValue *key, unsigned int *nums) { +static int countint (lua_Integer key, unsigned int *nums) { unsigned int k = arrayindex(key); if (k != 0) { /* is 'key' an appropriate array index? */ nums[luaO_ceillog2(k)]++; /* count as such */ @@ -261,18 +431,19 @@ static unsigned int numusearray (const Table *t, unsigned int *nums) { unsigned int ttlg; /* 2^lg */ unsigned int ause = 0; /* summation of 'nums' */ unsigned int i = 1; /* count to traverse all array keys */ + unsigned int asize = limitasasize(t); /* real array size */ /* traverse each slice */ for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) { unsigned int lc = 0; /* counter */ unsigned int lim = ttlg; - if (lim > t->sizearray) { - lim = t->sizearray; /* adjust upper limit */ + if (lim > asize) { + lim = asize; /* adjust upper limit */ if (i > lim) break; /* no more elements to count */ } /* count elements in range (2^(lg - 1), 2^lg] */ for (; i <= lim; i++) { - if (!ttisnil(&t->array[i-1])) + if (!isempty(&t->array[i-1])) lc++; } nums[lg] += lc; @@ -288,8 +459,9 @@ static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) { int i = sizenode(t); while (i--) { Node *n = &t->node[i]; - if (!ttisnil(gval(n))) { - ause += countint(gkey(n), nums); + if (!isempty(gval(n))) { + if (keyisinteger(n)) + ause += countint(keyival(n), nums); totaluse++; } } @@ -298,15 +470,13 @@ static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) { } -static void setarrayvector (lua_State *L, Table *t, unsigned int size) { - unsigned int i; - luaM_reallocvector(L, t->array, t->sizearray, size, TValue); - for (i=t->sizearray; iarray[i]); - t->sizearray = size; -} - - +/* +** Creates an array for the hash part of a table with the given +** size, or reuses the dummy node if size is zero. +** The computation for size overflow is in two steps: the first +** comparison ensures that the shift in the second one does not +** overflow. +*/ static void setnodevector (lua_State *L, Table *t, unsigned int size) { if (size == 0) { /* no elements to hash part? */ t->node = cast(Node *, dummynode); /* use common 'dummynode' */ @@ -316,15 +486,15 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) { else { int i; int lsize = luaO_ceillog2(size); - if (lsize > MAXHBITS) + if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE) luaG_runerror(L, "table overflow"); size = twoto(lsize); t->node = luaM_newvector(L, size, Node); - for (i = 0; i < (int)size; i++) { + for (i = 0; i < cast_int(size); i++) { Node *n = gnode(t, i); gnext(n) = 0; - setnilvalue(wgkey(n)); - setnilvalue(gval(n)); + setnilkey(n); + setempty(gval(n)); } t->lsizenode = cast_byte(lsize); t->lastfree = gnode(t, size); /* all positions are free */ @@ -332,55 +502,88 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) { } -typedef struct { - Table *t; - unsigned int nhsize; -} AuxsetnodeT; +/* +** (Re)insert all elements from the hash part of 'ot' into table 't'. +*/ +static void reinsert (lua_State *L, Table *ot, Table *t) { + int j; + int size = sizenode(ot); + for (j = 0; j < size; j++) { + Node *old = gnode(ot, j); + if (!isempty(gval(old))) { + /* doesn't need barrier/invalidate cache, as entry was + already present in the table */ + TValue k; + getnodekey(L, &k, old); + luaH_set(L, t, &k, gval(old)); + } + } +} -static void auxsetnode (lua_State *L, void *ud) { - AuxsetnodeT *asn = cast(AuxsetnodeT *, ud); - setnodevector(L, asn->t, asn->nhsize); +/* +** Exchange the hash part of 't1' and 't2'. +*/ +static void exchangehashpart (Table *t1, Table *t2) { + lu_byte lsizenode = t1->lsizenode; + Node *node = t1->node; + Node *lastfree = t1->lastfree; + t1->lsizenode = t2->lsizenode; + t1->node = t2->node; + t1->lastfree = t2->lastfree; + t2->lsizenode = lsizenode; + t2->node = node; + t2->lastfree = lastfree; } -void luaH_resize (lua_State *L, Table *t, unsigned int nasize, +/* +** Resize table 't' for the new given sizes. Both allocations (for +** the hash part and for the array part) can fail, which creates some +** subtleties. If the first allocation, for the hash part, fails, an +** error is raised and that is it. Otherwise, it copies the elements from +** the shrinking part of the array (if it is shrinking) into the new +** hash. Then it reallocates the array part. If that fails, the table +** is in its original state; the function frees the new hash part and then +** raises the allocation error. Otherwise, it sets the new hash part +** into the table, initializes the new part of the array (if any) with +** nils and reinserts the elements of the old hash back into the new +** parts of the table. +*/ +void luaH_resize (lua_State *L, Table *t, unsigned int newasize, unsigned int nhsize) { unsigned int i; - int j; - AuxsetnodeT asn; - unsigned int oldasize = t->sizearray; - int oldhsize = allocsizenode(t); - Node *nold = t->node; /* save old hash ... */ - if (nasize > oldasize) /* array part must grow? */ - setarrayvector(L, t, nasize); - /* create new hash part with appropriate size */ - asn.t = t; asn.nhsize = nhsize; - if (luaD_rawrunprotected(L, auxsetnode, &asn) != LUA_OK) { /* mem. error? */ - setarrayvector(L, t, oldasize); /* array back to its original size */ - luaD_throw(L, LUA_ERRMEM); /* rethrow memory error */ - } - if (nasize < oldasize) { /* array part must shrink? */ - t->sizearray = nasize; - /* re-insert elements from vanishing slice */ - for (i=nasize; iarray[i])) + Table newt; /* to keep the new hash part */ + unsigned int oldasize = setlimittosize(t); + TValue *newarray; + /* create new hash part with appropriate size into 'newt' */ + setnodevector(L, &newt, nhsize); + if (newasize < oldasize) { /* will array shrink? */ + t->alimit = newasize; /* pretend array has new size... */ + exchangehashpart(t, &newt); /* and new hash */ + /* re-insert into the new hash the elements from vanishing slice */ + for (i = newasize; i < oldasize; i++) { + if (!isempty(&t->array[i])) luaH_setint(L, t, i + 1, &t->array[i]); } - /* shrink array */ - luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + t->alimit = oldasize; /* restore current size... */ + exchangehashpart(t, &newt); /* and hash (in case of errors) */ } - /* re-insert elements from hash part */ - for (j = oldhsize - 1; j >= 0; j--) { - Node *old = nold + j; - if (!ttisnil(gval(old))) { - /* doesn't need barrier/invalidate cache, as entry was - already present in the table */ - setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old)); - } + /* allocate new array */ + newarray = luaM_reallocvector(L, t->array, oldasize, newasize, TValue); + if (l_unlikely(newarray == NULL && newasize > 0)) { /* allocation failed? */ + freehash(L, &newt); /* release new hash part */ + luaM_error(L); /* raise error (with array unchanged) */ } - if (oldhsize > 0) /* not the dummy node? */ - luaM_freearray(L, nold, cast(size_t, oldhsize)); /* free old hash */ + /* allocation ok; initialize new part of the array */ + exchangehashpart(t, &newt); /* 't' has the new hash ('newt' has the old) */ + t->array = newarray; /* set new array part */ + t->alimit = newasize; + for (i = oldasize; i < newasize; i++) /* clear new slice of the array */ + setempty(&t->array[i]); + /* re-insert elements from old hash part into new parts */ + reinsert(L, &newt, t); /* 'newt' now has the old hash */ + freehash(L, &newt); /* free old hash part */ } @@ -399,11 +602,13 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { int i; int totaluse; for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ + setlimittosize(t); na = numusearray(t, nums); /* count keys in array part */ totaluse = na; /* all those keys are integer keys */ totaluse += numusehash(t, nums, &na); /* count keys in hash part */ /* count extra key */ - na += countint(ek, nums); + if (ttisinteger(ek)) + na += countint(ivalue(ek), nums); totaluse++; /* compute new size for array part */ asize = computesizes(nums, &na); @@ -419,21 +624,20 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { Table *luaH_new (lua_State *L) { - GCObject *o = luaC_newobj(L, LUA_TTABLE, sizeof(Table)); + GCObject *o = luaC_newobj(L, LUA_VTABLE, sizeof(Table)); Table *t = gco2t(o); t->metatable = NULL; - t->flags = cast_byte(~0); + t->flags = cast_byte(maskflags); /* table has no metamethod fields */ t->array = NULL; - t->sizearray = 0; + t->alimit = 0; setnodevector(L, t, 0); return t; } void luaH_free (lua_State *L, Table *t) { - if (!isdummy(t)) - luaM_freearray(L, t->node, cast(size_t, sizenode(t))); - luaM_freearray(L, t->array, t->sizearray); + freehash(L, t); + luaM_freearray(L, t->array, luaH_realasize(t)); luaM_free(L, t); } @@ -442,7 +646,7 @@ static Node *getfreepos (Table *t) { if (!isdummy(t)) { while (t->lastfree > t->node) { t->lastfree--; - if (ttisnil(gkey(t->lastfree))) + if (keyisnil(t->lastfree)) return t->lastfree; } } @@ -458,30 +662,36 @@ static Node *getfreepos (Table *t) { ** put new key in its main position; otherwise (colliding node is in its main ** position), new key goes to an empty position. */ -TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { +static void luaH_newkey (lua_State *L, Table *t, const TValue *key, + TValue *value) { Node *mp; TValue aux; - if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + if (l_unlikely(ttisnil(key))) + luaG_runerror(L, "table index is nil"); else if (ttisfloat(key)) { + lua_Number f = fltvalue(key); lua_Integer k; - if (luaV_tointeger(key, &k, 0)) { /* does index fit in an integer? */ + if (luaV_flttointeger(f, &k, F2Ieq)) { /* does key fit in an integer? */ setivalue(&aux, k); key = &aux; /* insert it as an integer */ } - else if (luai_numisnan(fltvalue(key))) + else if (l_unlikely(luai_numisnan(f))) luaG_runerror(L, "table index is NaN"); } - mp = mainposition(t, key); - if (!ttisnil(gval(mp)) || isdummy(t)) { /* main position is taken? */ + if (ttisnil(value)) + return; /* do not insert nil values */ + mp = mainpositionTV(t, key); + if (!isempty(gval(mp)) || isdummy(t)) { /* main position is taken? */ Node *othern; Node *f = getfreepos(t); /* get a free place */ if (f == NULL) { /* cannot find a free place? */ rehash(L, t, key); /* grow table */ /* whatever called 'newkey' takes care of TM cache */ - return luaH_set(L, t, key); /* insert key into grown table */ + luaH_set(L, t, key, value); /* insert key into grown table */ + return; } lua_assert(!isdummy(t)); - othern = mainposition(t, gkey(mp)); + othern = mainpositionfromnode(t, mp); if (othern != mp) { /* is colliding node out of its main position? */ /* yes; move colliding node into free position */ while (othern + gnext(othern) != mp) /* find previous */ @@ -492,7 +702,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { gnext(f) += cast_int(mp - f); /* correct 'next' */ gnext(mp) = 0; /* now 'mp' is free */ } - setnilvalue(gval(mp)); + setempty(gval(mp)); } else { /* colliding node is in its own main position */ /* new node will go into free position */ @@ -503,24 +713,48 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { mp = f; } } - setnodekey(L, &mp->i_key, key); - luaC_barrierback(L, t, key); - lua_assert(ttisnil(gval(mp))); - return gval(mp); + setnodekey(L, mp, key); + luaC_barrierback(L, obj2gco(t), key); + lua_assert(isempty(gval(mp))); + setobj2t(L, gval(mp), value); } /* -** search function for integers +** Search function for integers. If integer is inside 'alimit', get it +** directly from the array part. Otherwise, if 'alimit' is not +** the real size of the array, the key still can be in the array part. +** In this case, do the "Xmilia trick" to check whether 'key-1' is +** smaller than the real size. +** The trick works as follow: let 'p' be an integer such that +** '2^(p+1) >= alimit > 2^p', or '2^(p+1) > alimit-1 >= 2^p'. +** That is, 2^(p+1) is the real size of the array, and 'p' is the highest +** bit on in 'alimit-1'. What we have to check becomes 'key-1 < 2^(p+1)'. +** We compute '(key-1) & ~(alimit-1)', which we call 'res'; it will +** have the 'p' bit cleared. If the key is outside the array, that is, +** 'key-1 >= 2^(p+1)', then 'res' will have some bit on higher than 'p', +** therefore it will be larger or equal to 'alimit', and the check +** will fail. If 'key-1 < 2^(p+1)', then 'res' has no bit on higher than +** 'p', and as the bit 'p' itself was cleared, 'res' will be smaller +** than 2^p, therefore smaller than 'alimit', and the check succeeds. +** As special cases, when 'alimit' is 0 the condition is trivially false, +** and when 'alimit' is 1 the condition simplifies to 'key-1 < alimit'. +** If key is 0 or negative, 'res' will have its higher bit on, so that +** if cannot be smaller than alimit. */ const TValue *luaH_getint (Table *t, lua_Integer key) { - /* (1 <= key && key <= t->sizearray) */ - if (l_castS2U(key) - 1 < t->sizearray) + lua_Unsigned alimit = t->alimit; + if (l_castS2U(key) - 1u < alimit) /* 'key' in [1, t->alimit]? */ return &t->array[key - 1]; - else { + else if (!isrealasize(t) && /* key still may be in the array part? */ + (((l_castS2U(key) - 1u) & ~(alimit - 1u)) < alimit)) { + t->alimit = cast_uint(key); /* probably '#t' is here now */ + return &t->array[key - 1]; + } + else { /* key is not in the array part; check the hash */ Node *n = hashint(t, key); for (;;) { /* check whether 'key' is somewhere in the chain */ - if (ttisinteger(gkey(n)) && ivalue(gkey(n)) == key) + if (keyisinteger(n) && keyival(n) == key) return gval(n); /* that's it */ else { int nx = gnext(n); @@ -528,7 +762,7 @@ const TValue *luaH_getint (Table *t, lua_Integer key) { n += nx; } } - return luaO_nilobject; + return &absentkey; } } @@ -538,34 +772,14 @@ const TValue *luaH_getint (Table *t, lua_Integer key) { */ const TValue *luaH_getshortstr (Table *t, TString *key) { Node *n = hashstr(t, key); - lua_assert(key->tt == LUA_TSHRSTR); + lua_assert(key->tt == LUA_VSHRSTR); for (;;) { /* check whether 'key' is somewhere in the chain */ - const TValue *k = gkey(n); - if (ttisshrstring(k) && eqshrstr(tsvalue(k), key)) + if (keyisshrstr(n) && eqshrstr(keystrval(n), key)) return gval(n); /* that's it */ else { int nx = gnext(n); if (nx == 0) - return luaO_nilobject; /* not found */ - n += nx; - } - } -} - - -/* -** "Generic" get version. (Not that generic: not valid for integers, -** which may be in array part, nor for floats with integral values.) -*/ -static const TValue *getgeneric (Table *t, const TValue *key) { - Node *n = mainposition(t, key); - for (;;) { /* check whether 'key' is somewhere in the chain */ - if (luaV_rawequalobj(gkey(n), key)) - return gval(n); /* that's it */ - else { - int nx = gnext(n); - if (nx == 0) - return luaO_nilobject; /* not found */ + return &absentkey; /* not found */ n += nx; } } @@ -573,12 +787,12 @@ static const TValue *getgeneric (Table *t, const TValue *key) { const TValue *luaH_getstr (Table *t, TString *key) { - if (key->tt == LUA_TSHRSTR) + if (key->tt == LUA_VSHRSTR) return luaH_getshortstr(t, key); else { /* for long strings, use generic case */ TValue ko; setsvalue(cast(lua_State *, NULL), &ko, key); - return getgeneric(t, &ko); + return getgeneric(t, &ko, 0); } } @@ -587,66 +801,102 @@ const TValue *luaH_getstr (Table *t, TString *key) { ** main search function */ const TValue *luaH_get (Table *t, const TValue *key) { - switch (ttype(key)) { - case LUA_TSHRSTR: return luaH_getshortstr(t, tsvalue(key)); - case LUA_TNUMINT: return luaH_getint(t, ivalue(key)); - case LUA_TNIL: return luaO_nilobject; - case LUA_TNUMFLT: { + switch (ttypetag(key)) { + case LUA_VSHRSTR: return luaH_getshortstr(t, tsvalue(key)); + case LUA_VNUMINT: return luaH_getint(t, ivalue(key)); + case LUA_VNIL: return &absentkey; + case LUA_VNUMFLT: { lua_Integer k; - if (luaV_tointeger(key, &k, 0)) /* index is int? */ + if (luaV_flttointeger(fltvalue(key), &k, F2Ieq)) /* integral index? */ return luaH_getint(t, k); /* use specialized version */ /* else... */ } /* FALLTHROUGH */ default: - return getgeneric(t, key); + return getgeneric(t, key, 0); } } +/* +** Finish a raw "set table" operation, where 'slot' is where the value +** should have been (the result of a previous "get table"). +** Beware: when using this function you probably need to check a GC +** barrier and invalidate the TM cache. +*/ +void luaH_finishset (lua_State *L, Table *t, const TValue *key, + const TValue *slot, TValue *value) { + if (isabstkey(slot)) + luaH_newkey(L, t, key, value); + else + setobj2t(L, cast(TValue *, slot), value); +} + + /* ** beware: when using this function you probably need to check a GC ** barrier and invalidate the TM cache. */ -TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { - const TValue *p = luaH_get(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else return luaH_newkey(L, t, key); +void luaH_set (lua_State *L, Table *t, const TValue *key, TValue *value) { + const TValue *slot = luaH_get(t, key); + luaH_finishset(L, t, key, slot, value); } void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { const TValue *p = luaH_getint(t, key); - TValue *cell; - if (p != luaO_nilobject) - cell = cast(TValue *, p); - else { + if (isabstkey(p)) { TValue k; setivalue(&k, key); - cell = luaH_newkey(L, t, &k); + luaH_newkey(L, t, &k, value); } - setobj2t(L, cell, value); + else + setobj2t(L, cast(TValue *, p), value); } -static lua_Unsigned unbound_search (Table *t, lua_Unsigned j) { - lua_Unsigned i = j; /* i is zero or a present index */ - j++; - /* find 'i' and 'j' such that i is present and j is not */ - while (!ttisnil(luaH_getint(t, j))) { - i = j; - if (j > l_castS2U(LUA_MAXINTEGER) / 2) { /* overflow? */ - /* table was built with bad purposes: resort to linear search */ - i = 1; - while (!ttisnil(luaH_getint(t, i))) i++; - return i - 1; +/* +** Try to find a boundary in the hash part of table 't'. From the +** caller, we know that 'j' is zero or present and that 'j + 1' is +** present. We want to find a larger key that is absent from the +** table, so that we can do a binary search between the two keys to +** find a boundary. We keep doubling 'j' until we get an absent index. +** If the doubling would overflow, we try LUA_MAXINTEGER. If it is +** absent, we are ready for the binary search. ('j', being max integer, +** is larger or equal to 'i', but it cannot be equal because it is +** absent while 'i' is present; so 'j > i'.) Otherwise, 'j' is a +** boundary. ('j + 1' cannot be a present integer key because it is +** not a valid integer in Lua.) +*/ +static lua_Unsigned hash_search (Table *t, lua_Unsigned j) { + lua_Unsigned i; + if (j == 0) j++; /* the caller ensures 'j + 1' is present */ + do { + i = j; /* 'i' is a present index */ + if (j <= l_castS2U(LUA_MAXINTEGER) / 2) + j *= 2; + else { + j = LUA_MAXINTEGER; + if (isempty(luaH_getint(t, j))) /* t[j] not present? */ + break; /* 'j' now is an absent index */ + else /* weird case */ + return j; /* well, max integer is a boundary... */ } - j *= 2; + } while (!isempty(luaH_getint(t, j))); /* repeat until an absent t[j] */ + /* i < j && t[i] present && t[j] absent */ + while (j - i > 1u) { /* do a binary search between them */ + lua_Unsigned m = (i + j) / 2; + if (isempty(luaH_getint(t, m))) j = m; + else i = m; } - /* now do a binary search between them */ - while (j - i > 1) { - lua_Unsigned m = (i+j)/2; - if (ttisnil(luaH_getint(t, m))) j = m; + return i; +} + + +static unsigned int binsearch (const TValue *array, unsigned int i, + unsigned int j) { + while (j - i > 1u) { /* binary search */ + unsigned int m = (i + j) / 2; + if (isempty(&array[m - 1])) j = m; else i = m; } return i; @@ -654,35 +904,92 @@ static lua_Unsigned unbound_search (Table *t, lua_Unsigned j) { /* -** Try to find a boundary in table 't'. A 'boundary' is an integer index -** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +** Try to find a boundary in table 't'. (A 'boundary' is an integer index +** such that t[i] is present and t[i+1] is absent, or 0 if t[1] is absent +** and 'maxinteger' if t[maxinteger] is present.) +** (In the next explanation, we use Lua indices, that is, with base 1. +** The code itself uses base 0 when indexing the array part of the table.) +** The code starts with 'limit = t->alimit', a position in the array +** part that may be a boundary. +** +** (1) If 't[limit]' is empty, there must be a boundary before it. +** As a common case (e.g., after 't[#t]=nil'), check whether 'limit-1' +** is present. If so, it is a boundary. Otherwise, do a binary search +** between 0 and limit to find a boundary. In both cases, try to +** use this boundary as the new 'alimit', as a hint for the next call. +** +** (2) If 't[limit]' is not empty and the array has more elements +** after 'limit', try to find a boundary there. Again, try first +** the special case (which should be quite frequent) where 'limit+1' +** is empty, so that 'limit' is a boundary. Otherwise, check the +** last element of the array part. If it is empty, there must be a +** boundary between the old limit (present) and the last element +** (absent), which is found with a binary search. (This boundary always +** can be a new limit.) +** +** (3) The last case is when there are no elements in the array part +** (limit == 0) or its last element (the new limit) is present. +** In this case, must check the hash part. If there is no hash part +** or 'limit+1' is absent, 'limit' is a boundary. Otherwise, call +** 'hash_search' to find a boundary in the hash part of the table. +** (In those cases, the boundary is not inside the array part, and +** therefore cannot be used as a new limit.) */ lua_Unsigned luaH_getn (Table *t) { - unsigned int j = t->sizearray; - if (j > 0 && ttisnil(&t->array[j - 1])) { - /* there is a boundary in the array part: (binary) search for it */ - unsigned int i = 0; - while (j - i > 1) { - unsigned int m = (i+j)/2; - if (ttisnil(&t->array[m - 1])) j = m; - else i = m; + unsigned int limit = t->alimit; + if (limit > 0 && isempty(&t->array[limit - 1])) { /* (1)? */ + /* there must be a boundary before 'limit' */ + if (limit >= 2 && !isempty(&t->array[limit - 2])) { + /* 'limit - 1' is a boundary; can it be a new limit? */ + if (ispow2realasize(t) && !ispow2(limit - 1)) { + t->alimit = limit - 1; + setnorealasize(t); /* now 'alimit' is not the real size */ + } + return limit - 1; + } + else { /* must search for a boundary in [0, limit] */ + unsigned int boundary = binsearch(t->array, 0, limit); + /* can this boundary represent the real size of the array? */ + if (ispow2realasize(t) && boundary > luaH_realasize(t) / 2) { + t->alimit = boundary; /* use it as the new limit */ + setnorealasize(t); + } + return boundary; } - return i; } - /* else must find a boundary in hash part */ - else if (isdummy(t)) /* hash part is empty? */ - return j; /* that is easy... */ - else return unbound_search(t, j); + /* 'limit' is zero or present in table */ + if (!limitequalsasize(t)) { /* (2)? */ + /* 'limit' > 0 and array has more elements after 'limit' */ + if (isempty(&t->array[limit])) /* 'limit + 1' is empty? */ + return limit; /* this is the boundary */ + /* else, try last element in the array */ + limit = luaH_realasize(t); + if (isempty(&t->array[limit - 1])) { /* empty? */ + /* there must be a boundary in the array after old limit, + and it must be a valid new limit */ + unsigned int boundary = binsearch(t->array, t->alimit, limit); + t->alimit = boundary; + return boundary; + } + /* else, new limit is present in the table; check the hash part */ + } + /* (3) 'limit' is the last element and either is zero or present in table */ + lua_assert(limit == luaH_realasize(t) && + (limit == 0 || !isempty(&t->array[limit - 1]))); + if (isdummy(t) || isempty(luaH_getint(t, cast(lua_Integer, limit + 1)))) + return limit; /* 'limit + 1' is absent */ + else /* 'limit + 1' is also present */ + return hash_search(t, limit); } #if defined(LUA_DEBUG) +/* export these functions for the test library */ + Node *luaH_mainposition (const Table *t, const TValue *key) { - return mainposition(t, key); + return mainpositionTV(t, key); } -int luaH_isdummy (const Table *t) { return isdummy(t); } - #endif diff --git a/liblua/ltable.h b/liblua/ltable.h index 92db0ac7..8e689034 100644 --- a/liblua/ltable.h +++ b/liblua/ltable.h @@ -1,5 +1,5 @@ /* -** $Id: ltable.h,v 2.23.1.2 2018/05/24 19:39:05 roberto Exp $ +** $Id: ltable.h $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -12,19 +12,15 @@ #define gnode(t,i) (&(t)->node[i]) #define gval(n) (&(n)->i_val) -#define gnext(n) ((n)->i_key.nk.next) +#define gnext(n) ((n)->u.next) -/* 'const' to avoid wrong writings that can mess up field 'next' */ -#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) - /* -** writable version of 'gkey'; allows updates to individual fields, -** but not to the whole (which has incompatible type) +** Clear all bits of fast-access metamethods, which means that the table +** may have any of these metamethods. (First access that fails after the +** clearing will set the bit again.) */ -#define wgkey(n) (&(n)->i_key.nk) - -#define invalidateTMcache(t) ((t)->flags = 0) +#define invalidateTMcache(t) ((t)->flags &= ~maskflags) /* true when 't' is using 'dummynode' as its hash part */ @@ -35,9 +31,8 @@ #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) -/* returns the key, given the value of a table entry */ -#define keyfromval(v) \ - (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) +/* returns the Node, given the value of a table entry */ +#define nodefromval(v) cast(Node *, (v)) LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); @@ -46,8 +41,10 @@ LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); -LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); -LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, + TValue *value); +LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, + const TValue *slot, TValue *value); LUAI_FUNC Table *luaH_new (lua_State *L); LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, unsigned int nhsize); @@ -55,11 +52,11 @@ LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); LUAI_FUNC void luaH_free (lua_State *L, Table *t); LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); LUAI_FUNC lua_Unsigned luaH_getn (Table *t); +LUAI_FUNC unsigned int luaH_realasize (const Table *t); #if defined(LUA_DEBUG) LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); -LUAI_FUNC int luaH_isdummy (const Table *t); #endif diff --git a/liblua/ltablib.c b/liblua/ltablib.c index c5349578..e6bc4d04 100644 --- a/liblua/ltablib.c +++ b/liblua/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.93.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ltablib.c $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -58,27 +58,10 @@ static void checktab (lua_State *L, int arg, int what) { } -#if defined(LUA_COMPAT_MAXN) -static int maxn (lua_State *L) { - lua_Number max = 0; - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushnil(L); /* first key */ - while (lua_next(L, 1)) { - lua_pop(L, 1); /* remove value */ - if (lua_type(L, -1) == LUA_TNUMBER) { - lua_Number v = lua_tonumber(L, -1); - if (v > max) max = v; - } - } - lua_pushnumber(L, max); - return 1; -} -#endif - - static int tinsert (lua_State *L) { - lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ lua_Integer pos; /* where to insert new element */ + lua_Integer e = aux_getn(L, 1, TAB_RW); + e = luaL_intop(+, e, 1); /* first empty element */ switch (lua_gettop(L)) { case 2: { /* called with only 2 arguments */ pos = e; /* insert new element at the end */ @@ -87,7 +70,9 @@ static int tinsert (lua_State *L) { case 3: { lua_Integer i; pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ - luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); + /* check whether 'pos' is in [1, e] */ + luaL_argcheck(L, (lua_Unsigned)pos - 1u < (lua_Unsigned)e, 2, + "position out of bounds"); for (i = e; i > pos; i--) { /* move up elements */ lua_geti(L, 1, i - 1); lua_seti(L, 1, i); /* t[i] = t[i - 1] */ @@ -107,14 +92,16 @@ static int tremove (lua_State *L) { lua_Integer size = aux_getn(L, 1, TAB_RW); lua_Integer pos = luaL_optinteger(L, 2, size); if (pos != size) /* validate 'pos' if given */ - luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); + /* check whether 'pos' is in [1, size + 1] */ + luaL_argcheck(L, (lua_Unsigned)pos - 1u <= (lua_Unsigned)size, 2, + "position out of bounds"); lua_geti(L, 1, pos); /* result = t[pos] */ for ( ; pos < size; pos++) { lua_geti(L, 1, pos + 1); lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */ } lua_pushnil(L); - lua_seti(L, 1, pos); /* t[pos] = nil */ + lua_seti(L, 1, pos); /* remove entry t[pos] */ return 1; } @@ -159,9 +146,9 @@ static int tmove (lua_State *L) { static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { lua_geti(L, 1, i); - if (!lua_isstring(L, -1)) - luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", - luaL_typename(L, -1), i); + if (l_unlikely(!lua_isstring(L, -1))) + luaL_error(L, "invalid value (%s) at index %I in table for 'concat'", + luaL_typename(L, -1), (LUAI_UACINT)i); luaL_addvalue(b); } @@ -191,7 +178,7 @@ static int tconcat (lua_State *L) { ** ======================================================= */ -static int pack (lua_State *L) { +static int tpack (lua_State *L) { int i; int n = lua_gettop(L); /* number of elements to pack */ lua_createtable(L, n, 1); /* create result table */ @@ -204,13 +191,14 @@ static int pack (lua_State *L) { } -static int unpack (lua_State *L) { +static int tunpack (lua_State *L) { lua_Unsigned n; lua_Integer i = luaL_optinteger(L, 2, 1); lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); if (i > e) return 0; /* empty range */ n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ - if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n))) + if (l_unlikely(n >= (unsigned int)INT_MAX || + !lua_checkstack(L, (int)(++n)))) return luaL_error(L, "too many results to unpack"); for (; i < e; i++) { /* push arg[i..e - 1] (to avoid overflows) */ lua_geti(L, 1, i); @@ -313,15 +301,15 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) { /* loop invariant: a[lo .. i] <= P <= a[j .. up] */ for (;;) { /* next loop: repeat ++i while a[i] < P */ - while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ + while ((void)lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (l_unlikely(i == up - 1)) /* a[i] < P but a[up - 1] == P ?? */ luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[i] */ } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ - while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { - if (j < i) /* j < i but a[j] > P ?? */ + while ((void)lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { + if (l_unlikely(j < i)) /* j < i but a[j] > P ?? */ luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[j] */ } @@ -352,7 +340,7 @@ static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) { /* -** QuickSort algorithm (recursive function) +** Quicksort algorithm (recursive function) */ static void auxsort (lua_State *L, IdxT lo, IdxT up, unsigned int rnd) { @@ -425,12 +413,9 @@ static int sort (lua_State *L) { static const luaL_Reg tab_funcs[] = { {"concat", tconcat}, -#if defined(LUA_COMPAT_MAXN) - {"maxn", maxn}, -#endif {"insert", tinsert}, - {"pack", pack}, - {"unpack", unpack}, + {"pack", tpack}, + {"unpack", tunpack}, {"remove", tremove}, {"move", tmove}, {"sort", sort}, @@ -440,11 +425,6 @@ static const luaL_Reg tab_funcs[] = { LUAMOD_API int luaopen_table (lua_State *L) { luaL_newlib(L, tab_funcs); -#if defined(LUA_COMPAT_UNPACK) - /* _G.unpack = table.unpack */ - lua_getfield(L, -1, "unpack"); - lua_setglobal(L, "unpack"); -#endif return 1; } diff --git a/liblua/ltm.c b/liblua/ltm.c index 0e7c7132..07a06081 100644 --- a/liblua/ltm.c +++ b/liblua/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.38.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: ltm.c $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -16,6 +16,7 @@ #include "ldebug.h" #include "ldo.h" +#include "lgc.h" #include "lobject.h" #include "lstate.h" #include "lstring.h" @@ -26,11 +27,11 @@ static const char udatatypename[] = "userdata"; -LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { +LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTYPES] = { "no value", "nil", "boolean", udatatypename, "number", "string", "table", "function", udatatypename, "thread", - "proto" /* this last case is used for tests only */ + "upvalue", "proto" /* these last cases are used for tests only */ }; @@ -42,7 +43,7 @@ void luaT_init (lua_State *L) { "__div", "__idiv", "__band", "__bor", "__bxor", "__shl", "__shr", "__unm", "__bnot", "__lt", "__le", - "__concat", "__call" + "__concat", "__call", "__close" }; int i; for (i=0; iflags |= cast_byte(1u<metatable; break; @@ -77,9 +78,9 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { mt = uvalue(o)->metatable; break; default: - mt = G(L)->mt[ttnov(o)]; + mt = G(L)->mt[ttype(o)]; } - return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : luaO_nilobject); + return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue); } @@ -95,54 +96,62 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) { if (ttisstring(name)) /* is '__name' a string? */ return getstr(tsvalue(name)); /* use it as type name */ } - return ttypename(ttnov(o)); /* else use standard type name */ + return ttypename(ttype(o)); /* else use standard type name */ } void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, TValue *p3, int hasres) { - ptrdiff_t result = savestack(L, p3); - StkId func = L->top; + const TValue *p2, const TValue *p3) { + StkId func = L->top.p; setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ setobj2s(L, func + 1, p1); /* 1st argument */ setobj2s(L, func + 2, p2); /* 2nd argument */ - L->top += 3; - if (!hasres) /* no result? 'p3' is third argument */ - setobj2s(L, L->top++, p3); /* 3rd argument */ + setobj2s(L, func + 3, p3); /* 3rd argument */ + L->top.p = func + 4; /* metamethod may yield only when called from Lua code */ - if (isLua(L->ci)) - luaD_call(L, func, hasres); + if (isLuacode(L->ci)) + luaD_call(L, func, 0); else - luaD_callnoyield(L, func, hasres); - if (hasres) { /* if has result, move it to its place */ - p3 = restorestack(L, result); - setobjs2s(L, p3, --L->top); - } + luaD_callnoyield(L, func, 0); } -int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event) { +void luaT_callTMres (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, StkId res) { + ptrdiff_t result = savestack(L, res); + StkId func = L->top.p; + setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ + setobj2s(L, func + 1, p1); /* 1st argument */ + setobj2s(L, func + 2, p2); /* 2nd argument */ + L->top.p += 3; + /* metamethod may yield only when called from Lua code */ + if (isLuacode(L->ci)) + luaD_call(L, func, 1); + else + luaD_callnoyield(L, func, 1); + res = restorestack(L, result); + setobjs2s(L, res, --L->top.p); /* move result to its place */ +} + + +static int callbinTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ - if (ttisnil(tm)) + if (notm(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (ttisnil(tm)) return 0; - luaT_callTM(L, tm, p1, p2, res, 1); + if (notm(tm)) return 0; + luaT_callTMres(L, tm, p1, p2, res); return 1; } void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event) { - if (!luaT_callbinTM(L, p1, p2, res, event)) { + if (l_unlikely(!callbinTM(L, p1, p2, res, event))) { switch (event) { - case TM_CONCAT: - luaG_concaterror(L, p1, p2); - /* call never returns, but to avoid warnings: *//* FALLTHROUGH */ case TM_BAND: case TM_BOR: case TM_BXOR: case TM_SHL: case TM_SHR: case TM_BNOT: { - lua_Number dummy; - if (tonumber(p1, &dummy) && tonumber(p2, &dummy)) + if (ttisnumber(p1) && ttisnumber(p2)) luaG_tointerror(L, p1, p2); else luaG_opinterror(L, p1, p2, "perform bitwise operation on"); @@ -155,11 +164,108 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, } +void luaT_tryconcatTM (lua_State *L) { + StkId top = L->top.p; + if (l_unlikely(!callbinTM(L, s2v(top - 2), s2v(top - 1), top - 2, + TM_CONCAT))) + luaG_concaterror(L, s2v(top - 2), s2v(top - 1)); +} + + +void luaT_trybinassocTM (lua_State *L, const TValue *p1, const TValue *p2, + int flip, StkId res, TMS event) { + if (flip) + luaT_trybinTM(L, p2, p1, res, event); + else + luaT_trybinTM(L, p1, p2, res, event); +} + + +void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, + int flip, StkId res, TMS event) { + TValue aux; + setivalue(&aux, i2); + luaT_trybinassocTM(L, p1, &aux, flip, res, event); +} + + +/* +** Calls an order tag method. +** For lessequal, LUA_COMPAT_LT_LE keeps compatibility with old +** behavior: if there is no '__le', try '__lt', based on l <= r iff +** !(r < l) (assuming a total order). If the metamethod yields during +** this substitution, the continuation has to know about it (to negate +** the result of rtop, event)) - return -1; /* no metamethod */ + if (callbinTM(L, p1, p2, L->top.p, event)) /* try original event */ + return !l_isfalse(s2v(L->top.p)); +#if defined(LUA_COMPAT_LT_LE) + else if (event == TM_LE) { + /* try '!(p2 < p1)' for '(p1 <= p2)' */ + L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ + if (callbinTM(L, p2, p1, L->top.p, TM_LT)) { + L->ci->callstatus ^= CIST_LEQ; /* clear mark */ + return l_isfalse(s2v(L->top.p)); + } + /* else error will remove this 'ci'; no need to clear mark */ + } +#endif + luaG_ordererror(L, p1, p2); /* no metamethod found */ + return 0; /* to avoid warnings */ +} + + +int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, + int flip, int isfloat, TMS event) { + TValue aux; const TValue *p2; + if (isfloat) { + setfltvalue(&aux, cast_num(v2)); + } + else + setivalue(&aux, v2); + if (flip) { /* arguments were exchanged? */ + p2 = p1; p1 = &aux; /* correct them */ + } else - return !l_isfalse(L->top); + p2 = &aux; + return luaT_callorderTM(L, p1, p2, event); +} + + +void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci, + const Proto *p) { + int i; + int actual = cast_int(L->top.p - ci->func.p) - 1; /* number of arguments */ + int nextra = actual - nfixparams; /* number of extra arguments */ + ci->u.l.nextraargs = nextra; + luaD_checkstack(L, p->maxstacksize + 1); + /* copy function to the top of the stack */ + setobjs2s(L, L->top.p++, ci->func.p); + /* move fixed parameters to the top of the stack */ + for (i = 1; i <= nfixparams; i++) { + setobjs2s(L, L->top.p++, ci->func.p + i); + setnilvalue(s2v(ci->func.p + i)); /* erase original parameter (for GC) */ + } + ci->func.p += actual + 1; + ci->top.p += actual + 1; + lua_assert(L->top.p <= ci->top.p && ci->top.p <= L->stack_last.p); +} + + +void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { + int i; + int nextra = ci->u.l.nextraargs; + if (wanted < 0) { + wanted = nextra; /* get all extra arguments available */ + checkstackGCp(L, nextra, where); /* ensure stack space */ + L->top.p = where + nextra; /* next instruction will need top */ + } + for (i = 0; i < wanted && i < nextra; i++) + setobjs2s(L, where + i, ci->func.p - nextra + i); + for (; i < wanted; i++) /* complete required results with nil */ + setnilvalue(s2v(where + i)); } diff --git a/liblua/ltm.h b/liblua/ltm.h index 8170688d..73b833c6 100644 --- a/liblua/ltm.h +++ b/liblua/ltm.h @@ -1,5 +1,5 @@ /* -** $Id: ltm.h,v 2.22.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: ltm.h $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -40,10 +40,26 @@ typedef enum { TM_LE, TM_CONCAT, TM_CALL, + TM_CLOSE, TM_N /* number of elements in the enum */ } TMS; +/* +** Mask with 1 in all fast-access methods. A 1 in any of these bits +** in the flag of a (meta)table means the metatable does not have the +** corresponding metamethod field. (Bit 7 of the flag is used for +** 'isrealasize'.) +*/ +#define maskflags (~(~0u << (TM_EQ + 1))) + + +/* +** Test whether there is no tagmethod. +** (Because tagmethods use raw accesses, the result may be an "empty" nil.) +*/ +#define notm(tm) ttisnil(tm) + #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) @@ -52,7 +68,7 @@ typedef enum { #define ttypename(x) luaT_typenames_[(x) + 1] -LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; +LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];) LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); @@ -63,14 +79,25 @@ LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, LUAI_FUNC void luaT_init (lua_State *L); LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, TValue *p3, int hasres); -LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event); + const TValue *p2, const TValue *p3); +LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f, + const TValue *p1, const TValue *p2, StkId p3); LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event); +LUAI_FUNC void luaT_tryconcatTM (lua_State *L); +LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1, + const TValue *p2, int inv, StkId res, TMS event); +LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, + int inv, StkId res, TMS event); LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, TMS event); +LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, + int inv, int isfloat, TMS event); +LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, + struct CallInfo *ci, const Proto *p); +LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci, + StkId where, int wanted); #endif diff --git a/liblua/lu8w.c b/liblua/lu8w.c index 657e0efa..e2b9b7b3 100644 --- a/liblua/lu8w.c +++ b/liblua/lu8w.c @@ -1,5 +1,8 @@ /* - UTF-8 Wrapper for Windows + Lua with UTF-8 Wrapper for Windows + + Released under the MIT license + Copyright (C) 2014-2023 SASAKI Nobuyuki */ #include "lprefix.h" @@ -47,6 +50,34 @@ char *u8wstos(const wchar_t *s) return buf; } +char **make_u8argv(int argc, wchar_t **wargv) +{ + char **argv = (char **)calloc(argc + 1, sizeof(void *)); + if (argv == NULL) { + return NULL; + } + else { + for (int i = 0; i < argc; i++) { + argv[i] = u8wstos(wargv[i]); + if (argv[i] == NULL) { + free_u8argv(argc, argv); + return NULL; + } + } + } + return argv; +} + +void free_u8argv(int argc, char **argv) +{ + if (argv) { + for (int i = 0; i < argc; i++) { + free(argv[i]); + } + } + free(argv); +} + DWORD u8GetModuleFileName(HMODULE hModule, LPSTR lpFilename, DWORD nSize) { if (nSize == 0) return 0; diff --git a/liblua/lu8w.h b/liblua/lu8w.h index e54dfcc6..a23c699c 100644 --- a/liblua/lu8w.h +++ b/liblua/lu8w.h @@ -1,5 +1,8 @@ /* - UTF-8 Wrapper for Windows + Lua with UTF-8 Wrapper for Windows + + Released under the MIT license + Copyright (C) 2014-2023 SASAKI Nobuyuki */ #ifndef U8W_H @@ -14,6 +17,9 @@ wchar_t *u8stows(const char *s); /* call free function to deallocate */ /* from utf-16 to utf-8 */ char *u8wstos(const wchar_t *s); /* call free function to deallocate */ +char **make_u8argv(int argc, wchar_t **wargv); +void free_u8argv(int argc, char **argv); + DWORD u8GetModuleFileName(HMODULE hModule, LPSTR lpFilename, DWORD nSize); DWORD u8FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, va_list *Arguments); @@ -35,8 +41,8 @@ size_t u8strftime(char *buf, size_t len, const char *format, const struct tm *pt #if !defined(lu8w_c) #if defined(LUA_U8W) || defined(LUA_CORE) || defined(LUA_LIB) || defined(lua_c) || defined(luac_c) -#undef LoadString +#undef LoadString #define GetModuleFileNameA u8GetModuleFileName #define FormatMessageA u8FormatMessage #define LoadLibraryExA u8LoadLibraryEx @@ -55,6 +61,19 @@ size_t u8strftime(char *buf, size_t len, const char *format, const struct tm *pt #define rename u8rename #define strftime u8strftime +/* in lauxlib.h */ +/* print a string */ +#define lua_writestring(s,l) u8fprintf(stdout, "%s", s) + +/* in loslib.c */ +/* strftime function options for Visual Studio 2015-2022 */ +#define LUA_STRFTIMEOPTIONS \ + "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ + "||" "#a#A#b#B#g#G#h#n#p#t#u#w#X#z#Z#%" \ + "#c" \ + "#x" \ + "#d#D#e#F#H#I#j#m#M#r#R#S#T#U#V#W#y#Y" + #endif /* LUA_U8W or LUA_CORE or LUA_LIB or lua_c or luac_c */ #endif /* not lu8w_c */ diff --git a/liblua/lua.h b/liblua/lua.h index c236e360..f050dac0 100644 --- a/liblua/lua.h +++ b/liblua/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.332.1.2 2018/06/13 16:58:17 roberto Exp $ +** $Id: lua.h $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -17,13 +17,15 @@ #define LUA_VERSION_MAJOR "5" -#define LUA_VERSION_MINOR "3" -#define LUA_VERSION_NUM 503 -#define LUA_VERSION_RELEASE "5" +#define LUA_VERSION_MINOR "4" +#define LUA_VERSION_RELEASE "7" + +#define LUA_VERSION_NUM 504 +#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 7) #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2018 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2024 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" @@ -49,8 +51,7 @@ #define LUA_ERRRUN 2 #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 -#define LUA_ERRGCMM 5 -#define LUA_ERRERR 6 +#define LUA_ERRERR 5 typedef struct lua_State lua_State; @@ -71,7 +72,7 @@ typedef struct lua_State lua_State; #define LUA_TUSERDATA 7 #define LUA_TTHREAD 8 -#define LUA_NUMTAGS 9 +#define LUA_NUMTYPES 9 @@ -124,6 +125,23 @@ typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); +/* +** Type for warning functions +*/ +typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont); + + +/* +** Type used by the debug API to collect debug information +*/ +typedef struct lua_Debug lua_Debug; + + +/* +** Functions to be called by the debugger in specific events +*/ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + /* ** generic extra include file @@ -145,11 +163,13 @@ extern const char lua_ident[]; LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); LUA_API void (lua_close) (lua_State *L); LUA_API lua_State *(lua_newthread) (lua_State *L); +LUA_API int (lua_closethread) (lua_State *L, lua_State *from); +LUA_API int (lua_resetthread) (lua_State *L); /* Deprecated! */ LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); -LUA_API const lua_Number *(lua_version) (lua_State *L); +LUA_API lua_Number (lua_version) (lua_State *L); /* @@ -182,7 +202,7 @@ LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); LUA_API int (lua_toboolean) (lua_State *L, int idx); LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); -LUA_API size_t (lua_rawlen) (lua_State *L, int idx); +LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx); LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); LUA_API void *(lua_touserdata) (lua_State *L, int idx); LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); @@ -247,9 +267,9 @@ LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); -LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue); LUA_API int (lua_getmetatable) (lua_State *L, int objindex); -LUA_API int (lua_getuservalue) (lua_State *L, int idx); +LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n); /* @@ -263,7 +283,7 @@ LUA_API void (lua_rawset) (lua_State *L, int idx); LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); LUA_API int (lua_setmetatable) (lua_State *L, int objindex); -LUA_API void (lua_setuservalue) (lua_State *L, int idx); +LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n); /* @@ -288,13 +308,21 @@ LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); */ LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k); -LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg, + int *nres); LUA_API int (lua_status) (lua_State *L); LUA_API int (lua_isyieldable) (lua_State *L); #define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) +/* +** Warning-related functions +*/ +LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud); +LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont); + + /* ** garbage-collection function and options */ @@ -308,8 +336,10 @@ LUA_API int (lua_isyieldable) (lua_State *L); #define LUA_GCSETPAUSE 6 #define LUA_GCSETSTEPMUL 7 #define LUA_GCISRUNNING 9 +#define LUA_GCGEN 10 +#define LUA_GCINC 11 -LUA_API int (lua_gc) (lua_State *L, int what, int data); +LUA_API int (lua_gc) (lua_State *L, int what, ...); /* @@ -328,6 +358,8 @@ LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); +LUA_API void (lua_toclose) (lua_State *L, int idx); +LUA_API void (lua_closeslot) (lua_State *L, int idx); /* @@ -377,7 +409,7 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); /* ** {============================================================== -** compatibility macros for unsigned conversions +** compatibility macros ** =============================================================== */ #if defined(LUA_COMPAT_APIINTCASTS) @@ -387,6 +419,13 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) #endif + +#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) +#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) +#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1) + +#define LUA_NUMTAGS LUA_NUMTYPES + /* }============================================================== */ /* @@ -414,12 +453,6 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); #define LUA_MASKLINE (1 << LUA_HOOKLINE) #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) -typedef struct lua_Debug lua_Debug; /* activation record */ - - -/* Functions to be called by the debugger in specific events */ -typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); - LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); @@ -437,6 +470,7 @@ LUA_API lua_Hook (lua_gethook) (lua_State *L); LUA_API int (lua_gethookmask) (lua_State *L); LUA_API int (lua_gethookcount) (lua_State *L); +LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit); struct lua_Debug { int event; @@ -444,6 +478,7 @@ struct lua_Debug { const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ const char *source; /* (S) */ + size_t srclen; /* (S) */ int currentline; /* (l) */ int linedefined; /* (S) */ int lastlinedefined; /* (S) */ @@ -451,6 +486,8 @@ struct lua_Debug { unsigned char nparams;/* (u) number of parameters */ char isvararg; /* (u) */ char istailcall; /* (t) */ + unsigned short ftransfer; /* (r) index of first value transferred */ + unsigned short ntransfer; /* (r) number of transferred values */ char short_src[LUA_IDSIZE]; /* (S) */ /* private part */ struct CallInfo *i_ci; /* active function */ @@ -460,7 +497,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2018 Lua.org, PUC-Rio. +* Copyright (C) 1994-2024 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/liblua/luaconf.h b/liblua/luaconf.h index 024b96b9..436a91d3 100644 --- a/liblua/luaconf.h +++ b/liblua/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: luaconf.h $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -14,6 +14,16 @@ /* ** =================================================================== +** General Configuration File for Lua +** +** Some definitions here can be changed externally, through the compiler +** (e.g., with '-D' options): They are commented out or protected +** by '#if !defined' guards. However, several other definitions +** should be changed directly here, either because they affect the +** Lua ABI (by making the changes here, you ensure that all software +** connected to Lua, such as C libraries, will be compiled with the same +** configuration); or because they are seldom changed. +** ** Search for "@@" to find all configurable definitions. ** =================================================================== */ @@ -22,20 +32,10 @@ /* ** {==================================================================== ** System Configuration: macros to adapt (if needed) Lua to some -** particular platform, for instance compiling it with 32-bit numbers or -** restricting it to C89. +** particular platform, for instance restricting it to C89. ** ===================================================================== */ -/* -@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You -** can also define LUA_32BITS in the make file, but changing here you -** ensure that all software connected to Lua will be compiled with the -** same configuration. -*/ -/* #define LUA_32BITS */ - - /* @@ LUA_USE_C89 controls the use of non-ISO-C89 features. ** Define it if you want Lua to avoid the use of a few C99 features @@ -61,45 +61,43 @@ #if defined(LUA_USE_LINUX) #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ -#define LUA_USE_READLINE /* needs some extra libraries */ #endif #if defined(LUA_USE_MACOSX) #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* MacOS does not need -ldl */ -#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#endif + + +#if defined(LUA_USE_IOS) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN #endif /* -@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for -** C89 ('long' and 'double'); Windows always has '__int64', so it does -** not need to use this case. +@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. */ -#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) -#define LUA_C89_NUMBERS -#endif +#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3) + +/* }================================================================== */ /* -@@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. +** {================================================================== +** Configuration for Number types. These options should not be +** set externally, because any other code connected to Lua must +** use the same configuration. +** =================================================================== */ -/* avoid undefined shifts */ -#if ((INT_MAX >> 15) >> 15) >= 1 -#define LUAI_BITSINT 32 -#else -/* 'int' always must have at least 16 bits */ -#define LUAI_BITSINT 16 -#endif - /* @@ LUA_INT_TYPE defines the type for Lua integers. @@ LUA_FLOAT_TYPE defines the type for Lua floats. -** Lua should work fine with any mix of these options (if supported -** by your C compiler). The usual configurations are 64-bit integers +** Lua should work fine with any mix of these options supported +** by your C compiler. The usual configurations are 64-bit integers ** and 'double' (the default), 32-bit integers and 'float' (for ** restricted platforms), and 'long'/'double' (for C compilers not ** compliant with C99, which may not have support for 'long long'). @@ -115,43 +113,61 @@ #define LUA_FLOAT_DOUBLE 2 #define LUA_FLOAT_LONGDOUBLE 3 -#if defined(LUA_32BITS) /* { */ + +/* Default configuration ('long long' and 'double', for 64-bit Lua) */ +#define LUA_INT_DEFAULT LUA_INT_LONGLONG +#define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE + + +/* +@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. +*/ +#define LUA_32BITS 0 + + +/* +@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for +** C89 ('long' and 'double'); Windows always has '__int64', so it does +** not need to use this case. +*/ +#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) +#define LUA_C89_NUMBERS 1 +#else +#define LUA_C89_NUMBERS 0 +#endif + + +#if LUA_32BITS /* { */ /* ** 32-bit integers and 'float' */ -#if LUAI_BITSINT >= 32 /* use 'int' if big enough */ +#if LUAI_IS32INT /* use 'int' if big enough */ #define LUA_INT_TYPE LUA_INT_INT #else /* otherwise use 'long' */ #define LUA_INT_TYPE LUA_INT_LONG #endif #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT -#elif defined(LUA_C89_NUMBERS) /* }{ */ +#elif LUA_C89_NUMBERS /* }{ */ /* ** largest types available for C89 ('long' and 'double') */ #define LUA_INT_TYPE LUA_INT_LONG #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE -#endif /* } */ +#else /* }{ */ +/* use defaults */ +#define LUA_INT_TYPE LUA_INT_DEFAULT +#define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT -/* -** default configuration for 64-bit Lua ('long long' and 'double') -*/ -#if !defined(LUA_INT_TYPE) -#define LUA_INT_TYPE LUA_INT_LONGLONG -#endif +#endif /* } */ -#if !defined(LUA_FLOAT_TYPE) -#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE -#endif /* }================================================================== */ - /* ** {================================================================== ** Configuration for Paths. @@ -179,6 +195,7 @@ ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ + #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #if defined(_WIN32) /* { */ /* @@ -188,27 +205,40 @@ #define LUA_LDIR "!\\lua\\" #define LUA_CDIR "!\\" #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" + +#if !defined(LUA_PATH_DEFAULT) #define LUA_PATH_DEFAULT \ LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ ".\\?.lua;" ".\\?\\init.lua" +#endif + +#if !defined(LUA_CPATH_DEFAULT) #define LUA_CPATH_DEFAULT \ LUA_CDIR"?.dll;" \ LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ LUA_CDIR"loadall.dll;" ".\\?.dll" +#endif #else /* }{ */ #define LUA_ROOT "/usr/local/" #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" + +#if !defined(LUA_PATH_DEFAULT) #define LUA_PATH_DEFAULT \ LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ "./?.lua;" "./?/init.lua" +#endif + +#if !defined(LUA_CPATH_DEFAULT) #define LUA_CPATH_DEFAULT \ LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif + #endif /* } */ @@ -217,12 +247,25 @@ ** CHANGE it if your machine does not use "/" as the directory separator ** and is not Windows. (On Windows Lua automatically uses "\".) */ +#if !defined(LUA_DIRSEP) + #if defined(_WIN32) #define LUA_DIRSEP "\\" #else #define LUA_DIRSEP "/" #endif +#endif + + +/* +** LUA_IGMARK is a mark to ignore all after it when building the +** module name (e.g., used to build the luaopen_ function name). +** Typically, the suffix after the mark is the module version, +** as in "mod-v1.2.so". +*/ +#define LUA_IGMARK "-" + /* }================================================================== */ @@ -256,16 +299,18 @@ #endif /* } */ -/* more often than not the libs go together with the core */ +/* +** More often than not the libs go together with the core. +*/ #define LUALIB_API LUA_API -#define LUAMOD_API LUALIB_API +#define LUAMOD_API LUA_API /* @@ LUAI_FUNC is a mark for all extern functions that are not to be ** exported to outside modules. -@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables -** that are not to be exported to outside modules (LUAI_DDEF for +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables, +** none of which to be exported to outside modules (LUAI_DDEF for ** definitions and LUAI_DDEC for declarations). ** CHANGE them if you need to mark them in some special way. Elf/gcc ** (versions 3.2 and later) mark them as "hidden" to optimize access @@ -277,12 +322,12 @@ */ #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ defined(__ELF__) /* { */ -#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_FUNC __attribute__((visibility("internal"))) extern #else /* }{ */ #define LUAI_FUNC extern #endif /* } */ -#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEC(dec) LUAI_FUNC dec #define LUAI_DDEF /* empty */ /* }================================================================== */ @@ -295,88 +340,43 @@ */ /* -@@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. -@@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. +@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3. ** You can define it to get all options, or change specific options ** to fit your specific needs. */ -#if defined(LUA_COMPAT_5_2) /* { */ +#if defined(LUA_COMPAT_5_3) /* { */ /* @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated ** functions in the mathematical library. +** (These functions were already officially removed in 5.3; +** nevertheless they are still available here.) */ #define LUA_COMPAT_MATHLIB -/* -@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. -*/ -#define LUA_COMPAT_BITLIB - -/* -@@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. -*/ -#define LUA_COMPAT_IPAIRS - /* @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, ** luaL_checkint, luaL_checklong, etc.) +** (These macros were also officially removed in 5.3, but they are still +** available here.) */ #define LUA_COMPAT_APIINTCASTS -#endif /* } */ - - -#if defined(LUA_COMPAT_5_1) /* { */ - -/* Incompatibilities from 5.2 -> 5.3 */ -#define LUA_COMPAT_MATHLIB -#define LUA_COMPAT_APIINTCASTS - -/* -@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. -** You can replace it with 'table.unpack'. -*/ -#define LUA_COMPAT_UNPACK - -/* -@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. -** You can replace it with 'package.searchers'. -*/ -#define LUA_COMPAT_LOADERS - -/* -@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. -** You can call your C function directly (with light C functions). -*/ -#define lua_cpcall(L,f,u) \ - (lua_pushcfunction(L, (f)), \ - lua_pushlightuserdata(L,(u)), \ - lua_pcall(L,1,0,0)) - /* -@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. -** You can rewrite 'log10(x)' as 'log(x, 10)'. +@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod +** using '__lt'. */ -#define LUA_COMPAT_LOG10 +#define LUA_COMPAT_LT_LE -/* -@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base -** library. You can rewrite 'loadstring(s)' as 'load(s)'. -*/ -#define LUA_COMPAT_LOADSTRING - -/* -@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. -*/ -#define LUA_COMPAT_MAXN /* @@ The following macros supply trivial compatibility for some ** changes in the API. The macros themselves document how to ** change your code to avoid using them. +** (Once more, these macros were officially removed in 5.3, but they are +** still available here.) */ #define lua_strlen(L,i) lua_rawlen(L, (i)) @@ -385,47 +385,31 @@ #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) -/* -@@ LUA_COMPAT_MODULE controls compatibility with previous -** module functions 'module' (Lua) and 'luaL_register' (C). -*/ -#define LUA_COMPAT_MODULE - #endif /* } */ - -/* -@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a -@@ a float mark ('.0'). -** This macro is not on by default even in compatibility mode, -** because this is not really an incompatibility. -*/ -/* #define LUA_COMPAT_FLOATSTRING */ - /* }================================================================== */ /* ** {================================================================== -** Configuration for Numbers. +** Configuration for Numbers (low-level part). ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* ** satisfy your needs. ** =================================================================== */ /* -@@ LUA_NUMBER is the floating-point type used by Lua. @@ LUAI_UACNUMBER is the result of a 'default argument promotion' @@ over a floating number. -@@ l_mathlim(x) corrects limit name 'x' to the proper float type +@@ l_floatatt(x) corrects float attribute 'x' to the proper float type ** by prefixing it with one of FLT/DBL/LDBL. @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. @@ LUA_NUMBER_FMT is the format for writing floats. @@ lua_number2str converts a float to a string. @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. @@ l_floor takes the floor of a float. -@@ lua_str2number converts a decimal numeric string to a number. +@@ lua_str2number converts a decimal numeral to a number. */ @@ -437,12 +421,13 @@ l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) /* -@@ lua_numbertointeger converts a float number to an integer, or -** returns 0 if float is not within the range of a lua_Integer. -** (The range comparisons are tricky because of rounding. The tests -** here assume a two-complement representation, where MININTEGER always -** has an exact representation as a float; MAXINTEGER may not have one, -** and therefore its conversion to float may have an ill-defined value.) +@@ lua_numbertointeger converts a float number with an integral value +** to an integer, or returns 0 if float is not within the range of +** a lua_Integer. (The range comparisons are tricky because of +** rounding. The tests here assume a two-complement representation, +** where MININTEGER always has an exact representation as a float; +** MAXINTEGER may not have one, and therefore its conversion to float +** may have an ill-defined value.) */ #define lua_numbertointeger(n,p) \ ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ @@ -456,7 +441,7 @@ #define LUA_NUMBER float -#define l_mathlim(n) (FLT_##n) +#define l_floatatt(n) (FLT_##n) #define LUAI_UACNUMBER double @@ -472,7 +457,7 @@ #define LUA_NUMBER long double -#define l_mathlim(n) (LDBL_##n) +#define l_floatatt(n) (LDBL_##n) #define LUAI_UACNUMBER long double @@ -487,7 +472,7 @@ #define LUA_NUMBER double -#define l_mathlim(n) (DBL_##n) +#define l_floatatt(n) (DBL_##n) #define LUAI_UACNUMBER double @@ -507,16 +492,14 @@ /* -@@ LUA_INTEGER is the integer type used by Lua. -** @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. -** @@ LUAI_UACINT is the result of a 'default argument promotion' -@@ over a lUA_INTEGER. +@@ over a LUA_INTEGER. @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. @@ LUA_INTEGER_FMT is the format for writing integers. @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. +@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. @@ lua_integer2str converts an integer to a string. */ @@ -547,6 +530,8 @@ #define LUA_MAXINTEGER INT_MAX #define LUA_MININTEGER INT_MIN +#define LUA_MAXUNSIGNED UINT_MAX + #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ #define LUA_INTEGER long @@ -555,6 +540,8 @@ #define LUA_MAXINTEGER LONG_MAX #define LUA_MININTEGER LONG_MIN +#define LUA_MAXUNSIGNED ULONG_MAX + #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ /* use presence of macro LLONG_MAX as proxy for C99 compliance */ @@ -567,6 +554,8 @@ #define LUA_MAXINTEGER LLONG_MAX #define LUA_MININTEGER LLONG_MIN +#define LUA_MAXUNSIGNED ULLONG_MAX + #elif defined(LUA_USE_WINDOWS) /* }{ */ /* in Windows, can use specific Windows types */ @@ -576,6 +565,8 @@ #define LUA_MAXINTEGER _I64_MAX #define LUA_MININTEGER _I64_MIN +#define LUA_MAXUNSIGNED _UI64_MAX + #else /* }{ */ #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ @@ -610,7 +601,7 @@ /* -@@ lua_strx2number converts an hexadecimal numeric string to a number. +@@ lua_strx2number converts a hexadecimal numeral to a number. ** In C99, 'strtod' does that conversion. Otherwise, you can ** leave 'lua_strx2number' undefined and Lua will provide its own ** implementation. @@ -628,7 +619,7 @@ /* -@@ lua_number2strx converts a float to an hexadecimal numeric string. +@@ lua_number2strx converts a float to a hexadecimal numeral. ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will ** provide its own implementation. @@ -674,12 +665,40 @@ /* @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). ** Change that if you do not want to use C locales. (Code using this -** macro must include header 'locale.h'.) +** macro must include the header 'locale.h'.) */ #if !defined(lua_getlocaledecpoint) #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) #endif + +/* +** macros to improve jump prediction, used mostly for error handling +** and debug facilities. (Some macros in the Lua API use these macros. +** Define LUA_NOBUILTIN if you do not want '__builtin_expect' in your +** code.) +*/ +#if !defined(luai_likely) + +#if defined(__GNUC__) && !defined(LUA_NOBUILTIN) +#define luai_likely(x) (__builtin_expect(((x) != 0), 1)) +#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#else +#define luai_likely(x) (x) +#define luai_unlikely(x) (x) +#endif + +#endif + + +#if defined(LUA_CORE) || defined(LUA_LIB) +/* shorter names for Lua's own use */ +#define l_likely(x) luai_likely(x) +#define l_unlikely(x) luai_unlikely(x) +#endif + + + /* }================================================================== */ @@ -715,7 +734,7 @@ ** {================================================================== ** Macros that affect the API and must be stable (that is, must be the ** same when you compile Lua and when you compile code that links to -** Lua). You probably do not want/need to change them. +** Lua). ** ===================================================================== */ @@ -724,8 +743,9 @@ ** CHANGE it if you need a different limit. This limit is arbitrary; ** its only purpose is to stop Lua from consuming unlimited stack ** space (and to reserve some numbers for pseudo-indices). +** (It must fit into max(size_t)/32 and max(int)/2.) */ -#if LUAI_BITSINT >= 32 +#if LUAI_IS32INT #define LUAI_MAXSTACK 1000000 #else #define LUAI_MAXSTACK 15000 @@ -742,35 +762,27 @@ /* @@ LUA_IDSIZE gives the maximum size for the description of the source -@@ of a function in debug information. +** of a function in debug information. ** CHANGE it if you want a different size. */ #define LUA_IDSIZE 60 /* -@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. -** CHANGE it if it uses too much C-stack space. (For long double, -** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a -** smaller buffer would force a memory allocation for each call to -** 'string.format'.) +@@ LUAL_BUFFERSIZE is the initial buffer size used by the lauxlib +** buffer system. */ -#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE -#define LUAL_BUFFERSIZE 8192 -#else -#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) -#endif - -/* }================================================================== */ +#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) /* -@@ LUA_QL describes how error messages quote program elements. -** Lua does not use these macros anymore; they are here for -** compatibility only. +@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure +** maximum alignment for the other items in that union. */ -#define LUA_QL(x) "'" x "'" -#define LUA_QS LUA_QL("%s") +#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l + +/* }================================================================== */ + diff --git a/liblua/lualib.h b/liblua/lualib.h index f5304aa0..26255290 100644 --- a/liblua/lualib.h +++ b/liblua/lualib.h @@ -1,5 +1,5 @@ /* -** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lualib.h $ ** Lua standard libraries ** See Copyright Notice in lua.h */ @@ -35,9 +35,6 @@ LUAMOD_API int (luaopen_string) (lua_State *L); #define LUA_UTF8LIBNAME "utf8" LUAMOD_API int (luaopen_utf8) (lua_State *L); -#define LUA_BITLIBNAME "bit32" -LUAMOD_API int (luaopen_bit32) (lua_State *L); - #define LUA_MATHLIBNAME "math" LUAMOD_API int (luaopen_math) (lua_State *L); @@ -52,10 +49,4 @@ LUAMOD_API int (luaopen_package) (lua_State *L); LUALIB_API void (luaL_openlibs) (lua_State *L); - -#if !defined(lua_assert) -#define lua_assert(x) ((void)0) -#endif - - #endif diff --git a/liblua/lundump.c b/liblua/lundump.c index 7a67d75a..e8d92a85 100644 --- a/liblua/lundump.c +++ b/liblua/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.44.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lundump.c $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -10,6 +10,7 @@ #include "lprefix.h" +#include #include #include "lua.h" @@ -25,7 +26,7 @@ #if !defined(luai_verifycode) -#define luai_verifycode(L,b,f) /* empty */ +#define luai_verifycode(L,f) /* empty */ #endif @@ -36,224 +37,278 @@ typedef struct { } LoadState; -static l_noret error(LoadState *S, const char *why) { - luaO_pushfstring(S->L, "%s: %s precompiled chunk", S->name, why); +static l_noret error (LoadState *S, const char *why) { + luaO_pushfstring(S->L, "%s: bad binary format (%s)", S->name, why); luaD_throw(S->L, LUA_ERRSYNTAX); } /* -** All high-level loads go through LoadVector; you can change it to +** All high-level loads go through loadVector; you can change it to ** adapt to the endianness of the input */ -#define LoadVector(S,b,n) LoadBlock(S,b,(n)*sizeof((b)[0])) +#define loadVector(S,b,n) loadBlock(S,b,(n)*sizeof((b)[0])) -static void LoadBlock (LoadState *S, void *b, size_t size) { +static void loadBlock (LoadState *S, void *b, size_t size) { if (luaZ_read(S->Z, b, size) != 0) - error(S, "truncated"); + error(S, "truncated chunk"); } -#define LoadVar(S,x) LoadVector(S,&x,1) +#define loadVar(S,x) loadVector(S,&x,1) -static lu_byte LoadByte (LoadState *S) { - lu_byte x; - LoadVar(S, x); - return x; +static lu_byte loadByte (LoadState *S) { + int b = zgetc(S->Z); + if (b == EOZ) + error(S, "truncated chunk"); + return cast_byte(b); } -static int LoadInt (LoadState *S) { - int x; - LoadVar(S, x); +static size_t loadUnsigned (LoadState *S, size_t limit) { + size_t x = 0; + int b; + limit >>= 7; + do { + b = loadByte(S); + if (x >= limit) + error(S, "integer overflow"); + x = (x << 7) | (b & 0x7f); + } while ((b & 0x80) == 0); return x; } -static lua_Number LoadNumber (LoadState *S) { +static size_t loadSize (LoadState *S) { + return loadUnsigned(S, MAX_SIZET); +} + + +static int loadInt (LoadState *S) { + return cast_int(loadUnsigned(S, INT_MAX)); +} + + +static lua_Number loadNumber (LoadState *S) { lua_Number x; - LoadVar(S, x); + loadVar(S, x); return x; } -static lua_Integer LoadInteger (LoadState *S) { +static lua_Integer loadInteger (LoadState *S) { lua_Integer x; - LoadVar(S, x); + loadVar(S, x); return x; } -static TString *LoadString (LoadState *S) { - size_t size = LoadByte(S); - if (size == 0xFF) - LoadVar(S, size); - if (size == 0) +/* +** Load a nullable string into prototype 'p'. +*/ +static TString *loadStringN (LoadState *S, Proto *p) { + lua_State *L = S->L; + TString *ts; + size_t size = loadSize(S); + if (size == 0) /* no string? */ return NULL; else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */ char buff[LUAI_MAXSHORTLEN]; - LoadVector(S, buff, size); - return luaS_newlstr(S->L, buff, size); + loadVector(S, buff, size); /* load string into buffer */ + ts = luaS_newlstr(L, buff, size); /* create string */ } else { /* long string */ - TString *ts = luaS_createlngstrobj(S->L, size); - LoadVector(S, getstr(ts), size); /* load directly in final place */ - return ts; + ts = luaS_createlngstrobj(L, size); /* create string */ + setsvalue2s(L, L->top.p, ts); /* anchor it ('loadVector' can GC) */ + luaD_inctop(L); + loadVector(S, getlngstr(ts), size); /* load directly in final place */ + L->top.p--; /* pop string */ } + luaC_objbarrier(L, p, ts); + return ts; +} + + +/* +** Load a non-nullable string into prototype 'p'. +*/ +static TString *loadString (LoadState *S, Proto *p) { + TString *st = loadStringN(S, p); + if (st == NULL) + error(S, "bad format for constant string"); + return st; } -static void LoadCode (LoadState *S, Proto *f) { - int n = LoadInt(S); - f->code = luaM_newvector(S->L, n, Instruction); +static void loadCode (LoadState *S, Proto *f) { + int n = loadInt(S); + f->code = luaM_newvectorchecked(S->L, n, Instruction); f->sizecode = n; - LoadVector(S, f->code, n); + loadVector(S, f->code, n); } -static void LoadFunction(LoadState *S, Proto *f, TString *psource); +static void loadFunction(LoadState *S, Proto *f, TString *psource); -static void LoadConstants (LoadState *S, Proto *f) { +static void loadConstants (LoadState *S, Proto *f) { int i; - int n = LoadInt(S); - f->k = luaM_newvector(S->L, n, TValue); + int n = loadInt(S); + f->k = luaM_newvectorchecked(S->L, n, TValue); f->sizek = n; for (i = 0; i < n; i++) setnilvalue(&f->k[i]); for (i = 0; i < n; i++) { TValue *o = &f->k[i]; - int t = LoadByte(S); + int t = loadByte(S); switch (t) { - case LUA_TNIL: - setnilvalue(o); - break; - case LUA_TBOOLEAN: - setbvalue(o, LoadByte(S)); - break; - case LUA_TNUMFLT: - setfltvalue(o, LoadNumber(S)); - break; - case LUA_TNUMINT: - setivalue(o, LoadInteger(S)); - break; - case LUA_TSHRSTR: - case LUA_TLNGSTR: - setsvalue2n(S->L, o, LoadString(S)); - break; - default: - lua_assert(0); + case LUA_VNIL: + setnilvalue(o); + break; + case LUA_VFALSE: + setbfvalue(o); + break; + case LUA_VTRUE: + setbtvalue(o); + break; + case LUA_VNUMFLT: + setfltvalue(o, loadNumber(S)); + break; + case LUA_VNUMINT: + setivalue(o, loadInteger(S)); + break; + case LUA_VSHRSTR: + case LUA_VLNGSTR: + setsvalue2n(S->L, o, loadString(S, f)); + break; + default: lua_assert(0); } } } -static void LoadProtos (LoadState *S, Proto *f) { +static void loadProtos (LoadState *S, Proto *f) { int i; - int n = LoadInt(S); - f->p = luaM_newvector(S->L, n, Proto *); + int n = loadInt(S); + f->p = luaM_newvectorchecked(S->L, n, Proto *); f->sizep = n; for (i = 0; i < n; i++) f->p[i] = NULL; for (i = 0; i < n; i++) { f->p[i] = luaF_newproto(S->L); - LoadFunction(S, f->p[i], f->source); + luaC_objbarrier(S->L, f, f->p[i]); + loadFunction(S, f->p[i], f->source); } } -static void LoadUpvalues (LoadState *S, Proto *f) { +/* +** Load the upvalues for a function. The names must be filled first, +** because the filling of the other fields can raise read errors and +** the creation of the error message can call an emergency collection; +** in that case all prototypes must be consistent for the GC. +*/ +static void loadUpvalues (LoadState *S, Proto *f) { int i, n; - n = LoadInt(S); - f->upvalues = luaM_newvector(S->L, n, Upvaldesc); + n = loadInt(S); + f->upvalues = luaM_newvectorchecked(S->L, n, Upvaldesc); f->sizeupvalues = n; - for (i = 0; i < n; i++) + for (i = 0; i < n; i++) /* make array valid for GC */ f->upvalues[i].name = NULL; - for (i = 0; i < n; i++) { - f->upvalues[i].instack = LoadByte(S); - f->upvalues[i].idx = LoadByte(S); + for (i = 0; i < n; i++) { /* following calls can raise errors */ + f->upvalues[i].instack = loadByte(S); + f->upvalues[i].idx = loadByte(S); + f->upvalues[i].kind = loadByte(S); } } -static void LoadDebug (LoadState *S, Proto *f) { +static void loadDebug (LoadState *S, Proto *f) { int i, n; - n = LoadInt(S); - f->lineinfo = luaM_newvector(S->L, n, int); + n = loadInt(S); + f->lineinfo = luaM_newvectorchecked(S->L, n, ls_byte); f->sizelineinfo = n; - LoadVector(S, f->lineinfo, n); - n = LoadInt(S); - f->locvars = luaM_newvector(S->L, n, LocVar); + loadVector(S, f->lineinfo, n); + n = loadInt(S); + f->abslineinfo = luaM_newvectorchecked(S->L, n, AbsLineInfo); + f->sizeabslineinfo = n; + for (i = 0; i < n; i++) { + f->abslineinfo[i].pc = loadInt(S); + f->abslineinfo[i].line = loadInt(S); + } + n = loadInt(S); + f->locvars = luaM_newvectorchecked(S->L, n, LocVar); f->sizelocvars = n; for (i = 0; i < n; i++) f->locvars[i].varname = NULL; for (i = 0; i < n; i++) { - f->locvars[i].varname = LoadString(S); - f->locvars[i].startpc = LoadInt(S); - f->locvars[i].endpc = LoadInt(S); + f->locvars[i].varname = loadStringN(S, f); + f->locvars[i].startpc = loadInt(S); + f->locvars[i].endpc = loadInt(S); } - n = LoadInt(S); + n = loadInt(S); + if (n != 0) /* does it have debug information? */ + n = f->sizeupvalues; /* must be this many */ for (i = 0; i < n; i++) - f->upvalues[i].name = LoadString(S); + f->upvalues[i].name = loadStringN(S, f); } -static void LoadFunction (LoadState *S, Proto *f, TString *psource) { - f->source = LoadString(S); +static void loadFunction (LoadState *S, Proto *f, TString *psource) { + f->source = loadStringN(S, f); if (f->source == NULL) /* no source in dump? */ f->source = psource; /* reuse parent's source */ - f->linedefined = LoadInt(S); - f->lastlinedefined = LoadInt(S); - f->numparams = LoadByte(S); - f->is_vararg = LoadByte(S); - f->maxstacksize = LoadByte(S); - LoadCode(S, f); - LoadConstants(S, f); - LoadUpvalues(S, f); - LoadProtos(S, f); - LoadDebug(S, f); + f->linedefined = loadInt(S); + f->lastlinedefined = loadInt(S); + f->numparams = loadByte(S); + f->is_vararg = loadByte(S); + f->maxstacksize = loadByte(S); + loadCode(S, f); + loadConstants(S, f); + loadUpvalues(S, f); + loadProtos(S, f); + loadDebug(S, f); } static void checkliteral (LoadState *S, const char *s, const char *msg) { char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */ size_t len = strlen(s); - LoadVector(S, buff, len); + loadVector(S, buff, len); if (memcmp(s, buff, len) != 0) error(S, msg); } static void fchecksize (LoadState *S, size_t size, const char *tname) { - if (LoadByte(S) != size) - error(S, luaO_pushfstring(S->L, "%s size mismatch in", tname)); + if (loadByte(S) != size) + error(S, luaO_pushfstring(S->L, "%s size mismatch", tname)); } #define checksize(S,t) fchecksize(S,sizeof(t),#t) static void checkHeader (LoadState *S) { - checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */ - if (LoadByte(S) != LUAC_VERSION) - error(S, "version mismatch in"); - if (LoadByte(S) != LUAC_FORMAT) - error(S, "format mismatch in"); - checkliteral(S, LUAC_DATA, "corrupted"); - checksize(S, int); - checksize(S, size_t); + /* skip 1st char (already read and checked) */ + checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk"); + if (loadByte(S) != LUAC_VERSION) + error(S, "version mismatch"); + if (loadByte(S) != LUAC_FORMAT) + error(S, "format mismatch"); + checkliteral(S, LUAC_DATA, "corrupted chunk"); checksize(S, Instruction); checksize(S, lua_Integer); checksize(S, lua_Number); - if (LoadInteger(S) != LUAC_INT) - error(S, "endianness mismatch in"); - if (LoadNumber(S) != LUAC_NUM) - error(S, "float format mismatch in"); + if (loadInteger(S) != LUAC_INT) + error(S, "integer format mismatch"); + if (loadNumber(S) != LUAC_NUM) + error(S, "float format mismatch"); } /* -** load precompiled chunk +** Load precompiled chunk. */ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) { LoadState S; @@ -267,13 +322,14 @@ LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) { S.L = L; S.Z = Z; checkHeader(&S); - cl = luaF_newLclosure(L, LoadByte(&S)); - setclLvalue(L, L->top, cl); + cl = luaF_newLclosure(L, loadByte(&S)); + setclLvalue2s(L, L->top.p, cl); luaD_inctop(L); cl->p = luaF_newproto(L); - LoadFunction(&S, cl->p, NULL); + luaC_objbarrier(L, cl, cl->p); + loadFunction(&S, cl->p, NULL); lua_assert(cl->nupvalues == cl->p->sizeupvalues); - luai_verifycode(L, buff, cl->p); + luai_verifycode(L, cl->p); return cl; } diff --git a/liblua/lundump.h b/liblua/lundump.h index ce492d68..a97676ca 100644 --- a/liblua/lundump.h +++ b/liblua/lundump.h @@ -1,5 +1,5 @@ /* -** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lundump.h $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -18,8 +18,11 @@ #define LUAC_INT 0x5678 #define LUAC_NUM cast_num(370.5) -#define MYINT(s) (s[0]-'0') -#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) +/* +** Encode major-minor version in one byte, one nibble for each +*/ +#define LUAC_VERSION (((LUA_VERSION_NUM / 100) * 16) + LUA_VERSION_NUM % 100) + #define LUAC_FORMAT 0 /* this is the official format */ /* load one chunk; from lundump.c */ diff --git a/liblua/lutf8lib.c b/liblua/lutf8lib.c index 10bd238a..3a5b9bc3 100644 --- a/liblua/lutf8lib.c +++ b/liblua/lutf8lib.c @@ -1,5 +1,5 @@ /* -** $Id: lutf8lib.c,v 1.16.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: lutf8lib.c $ ** Standard library for UTF-8 manipulation ** See Copyright Notice in lua.h */ @@ -20,9 +20,26 @@ #include "lauxlib.h" #include "lualib.h" -#define MAXUNICODE 0x10FFFF -#define iscont(p) ((*(p) & 0xC0) == 0x80) +#define MAXUNICODE 0x10FFFFu + +#define MAXUTF 0x7FFFFFFFu + + +#define MSGInvalid "invalid UTF-8 code" + +/* +** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits. +*/ +#if (UINT_MAX >> 30) >= 1 +typedef unsigned int utfint; +#else +typedef unsigned long utfint; +#endif + + +#define iscont(c) (((c) & 0xC0) == 0x80) +#define iscontp(p) iscont(*(p)) /* from strlib */ @@ -35,53 +52,62 @@ static lua_Integer u_posrelat (lua_Integer pos, size_t len) { /* -** Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. +** Decode one UTF-8 sequence, returning NULL if byte sequence is +** invalid. The array 'limits' stores the minimum value for each +** sequence length, to check for overlong representations. Its first +** entry forces an error for non-ascii bytes with no continuation +** bytes (count == 0). */ -static const char *utf8_decode (const char *o, int *val) { - static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF}; - const unsigned char *s = (const unsigned char *)o; - unsigned int c = s[0]; - unsigned int res = 0; /* final result */ +static const char *utf8_decode (const char *s, utfint *val, int strict) { + static const utfint limits[] = + {~(utfint)0, 0x80, 0x800, 0x10000u, 0x200000u, 0x4000000u}; + unsigned int c = (unsigned char)s[0]; + utfint res = 0; /* final result */ if (c < 0x80) /* ascii? */ res = c; else { int count = 0; /* to count number of continuation bytes */ - while (c & 0x40) { /* still have continuation bytes? */ - int cc = s[++count]; /* read next byte */ - if ((cc & 0xC0) != 0x80) /* not a continuation byte? */ + for (; c & 0x40; c <<= 1) { /* while it needs continuation bytes... */ + unsigned int cc = (unsigned char)s[++count]; /* read next byte */ + if (!iscont(cc)) /* not a continuation byte? */ return NULL; /* invalid byte sequence */ res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */ - c <<= 1; /* to test next bit */ } - res |= ((c & 0x7F) << (count * 5)); /* add first byte */ - if (count > 3 || res > MAXUNICODE || res <= limits[count]) + res |= ((utfint)(c & 0x7F) << (count * 5)); /* add first byte */ + if (count > 5 || res > MAXUTF || res < limits[count]) return NULL; /* invalid byte sequence */ s += count; /* skip continuation bytes read */ } + if (strict) { + /* check for invalid code points; too large or surrogates */ + if (res > MAXUNICODE || (0xD800u <= res && res <= 0xDFFFu)) + return NULL; + } if (val) *val = res; - return (const char *)s + 1; /* +1 to include first byte */ + return s + 1; /* +1 to include first byte */ } /* -** utf8len(s [, i [, j]]) --> number of characters that start in the -** range [i,j], or nil + current position if 's' is not well formed in -** that interval +** utf8len(s [, i [, j [, lax]]]) --> number of characters that +** start in the range [i,j], or nil + current position if 's' is not +** well formed in that interval */ static int utflen (lua_State *L) { - int n = 0; - size_t len; + lua_Integer n = 0; /* counter for the number of characters */ + size_t len; /* string length in bytes */ const char *s = luaL_checklstring(L, 1, &len); lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); lua_Integer posj = u_posrelat(luaL_optinteger(L, 3, -1), len); + int lax = lua_toboolean(L, 4); luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 2, - "initial position out of string"); + "initial position out of bounds"); luaL_argcheck(L, --posj < (lua_Integer)len, 3, - "final position out of string"); + "final position out of bounds"); while (posi <= posj) { - const char *s1 = utf8_decode(s + posi, NULL); + const char *s1 = utf8_decode(s + posi, NULL, !lax); if (s1 == NULL) { /* conversion error? */ - lua_pushnil(L); /* return nil ... */ + luaL_pushfail(L); /* return fail ... */ lua_pushinteger(L, posi + 1); /* ... and current position */ return 2; } @@ -94,30 +120,31 @@ static int utflen (lua_State *L) { /* -** codepoint(s, [i, [j]]) -> returns codepoints for all characters -** that start in the range [i,j] +** codepoint(s, [i, [j [, lax]]]) -> returns codepoints for all +** characters that start in the range [i,j] */ static int codepoint (lua_State *L) { size_t len; const char *s = luaL_checklstring(L, 1, &len); lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len); + int lax = lua_toboolean(L, 4); int n; const char *se; - luaL_argcheck(L, posi >= 1, 2, "out of range"); - luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of range"); + luaL_argcheck(L, posi >= 1, 2, "out of bounds"); + luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of bounds"); if (posi > pose) return 0; /* empty interval; return no values */ if (pose - posi >= INT_MAX) /* (lua_Integer -> int) overflow? */ return luaL_error(L, "string slice too long"); - n = (int)(pose - posi) + 1; + n = (int)(pose - posi) + 1; /* upper bound for number of returns */ luaL_checkstack(L, n, "string slice too long"); - n = 0; - se = s + pose; + n = 0; /* count the number of returns */ + se = s + pose; /* string end */ for (s += posi - 1; s < se;) { - int code; - s = utf8_decode(s, &code); + utfint code; + s = utf8_decode(s, &code, !lax); if (s == NULL) - return luaL_error(L, "invalid UTF-8 code"); + return luaL_error(L, MSGInvalid); lua_pushinteger(L, code); n++; } @@ -126,8 +153,8 @@ static int codepoint (lua_State *L) { static void pushutfchar (lua_State *L, int arg) { - lua_Integer code = luaL_checkinteger(L, arg); - luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); + lua_Unsigned code = (lua_Unsigned)luaL_checkinteger(L, arg); + luaL_argcheck(L, code <= MAXUTF, arg, "value out of range"); lua_pushfstring(L, "%U", (long)code); } @@ -164,19 +191,19 @@ static int byteoffset (lua_State *L) { lua_Integer posi = (n >= 0) ? 1 : len + 1; posi = u_posrelat(luaL_optinteger(L, 3, posi), len); luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3, - "position out of range"); + "position out of bounds"); if (n == 0) { /* find beginning of current byte sequence */ - while (posi > 0 && iscont(s + posi)) posi--; + while (posi > 0 && iscontp(s + posi)) posi--; } else { - if (iscont(s + posi)) + if (iscontp(s + posi)) return luaL_error(L, "initial position is a continuation byte"); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ do { /* find beginning of previous character */ posi--; - } while (posi > 0 && iscont(s + posi)); + } while (posi > 0 && iscontp(s + posi)); n++; } } @@ -185,7 +212,7 @@ static int byteoffset (lua_State *L) { while (n > 0 && posi < (lua_Integer)len) { do { /* find beginning of next character */ posi++; - } while (iscont(s + posi)); /* (cannot pass final '\0') */ + } while (iscontp(s + posi)); /* (cannot pass final '\0') */ n--; } } @@ -193,28 +220,25 @@ static int byteoffset (lua_State *L) { if (n == 0) /* did it find given character? */ lua_pushinteger(L, posi + 1); else /* no such character */ - lua_pushnil(L); + luaL_pushfail(L); return 1; } -static int iter_aux (lua_State *L) { +static int iter_aux (lua_State *L, int strict) { size_t len; const char *s = luaL_checklstring(L, 1, &len); - lua_Integer n = lua_tointeger(L, 2) - 1; - if (n < 0) /* first iteration? */ - n = 0; /* start from here */ - else if (n < (lua_Integer)len) { - n++; /* skip current byte */ - while (iscont(s + n)) n++; /* and its continuations */ + lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2); + if (n < len) { + while (iscontp(s + n)) n++; /* go to next character */ } - if (n >= (lua_Integer)len) + if (n >= len) /* (also handles original 'n' being negative) */ return 0; /* no more codepoints */ else { - int code; - const char *next = utf8_decode(s + n, &code); - if (next == NULL || iscont(next)) - return luaL_error(L, "invalid UTF-8 code"); + utfint code; + const char *next = utf8_decode(s + n, &code, strict); + if (next == NULL || iscontp(next)) + return luaL_error(L, MSGInvalid); lua_pushinteger(L, n + 1); lua_pushinteger(L, code); return 2; @@ -222,9 +246,20 @@ static int iter_aux (lua_State *L) { } +static int iter_auxstrict (lua_State *L) { + return iter_aux(L, 1); +} + +static int iter_auxlax (lua_State *L) { + return iter_aux(L, 0); +} + + static int iter_codes (lua_State *L) { - luaL_checkstring(L, 1); - lua_pushcfunction(L, iter_aux); + int lax = lua_toboolean(L, 2); + const char *s = luaL_checkstring(L, 1); + luaL_argcheck(L, !iscontp(s), 1, MSGInvalid); + lua_pushcfunction(L, lax ? iter_auxlax : iter_auxstrict); lua_pushvalue(L, 1); lua_pushinteger(L, 0); return 3; @@ -232,7 +267,7 @@ static int iter_codes (lua_State *L) { /* pattern to match a single UTF-8 character */ -#define UTF8PATT "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" +#define UTF8PATT "[\0-\x7F\xC2-\xFD][\x80-\xBF]*" static const luaL_Reg funcs[] = { diff --git a/liblua/lvm.c b/liblua/lvm.c index cc43d871..fcd24e11 100644 --- a/liblua/lvm.c +++ b/liblua/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.268.1.1 2017/04/19 17:39:34 roberto Exp $ +** $Id: lvm.c $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -31,39 +31,72 @@ #include "lvm.h" -/* limit for table tag-method chains (to avoid loops) */ -#define MAXTAGLOOP 2000 +/* +** By default, use jump tables in the main interpreter loop on gcc +** and compatible compilers. +*/ +#if !defined(LUA_USE_JUMPTABLE) +#if defined(__GNUC__) +#define LUA_USE_JUMPTABLE 1 +#else +#define LUA_USE_JUMPTABLE 0 +#endif +#endif + +/* limit for table tag-method chains (to avoid infinite loops) */ +#define MAXTAGLOOP 2000 + /* -** 'l_intfitsf' checks whether a given integer can be converted to a -** float without rounding. Used in comparisons. Left undefined if -** all integers fit in a float precisely. +** 'l_intfitsf' checks whether a given integer is in the range that +** can be converted to a float without rounding. Used in comparisons. */ -#if !defined(l_intfitsf) /* number of bits in the mantissa of a float */ -#define NBM (l_mathlim(MANT_DIG)) +#define NBM (l_floatatt(MANT_DIG)) /* -** Check whether some integers may not fit in a float, that is, whether -** (maxinteger >> NBM) > 0 (that implies (1 << NBM) <= maxinteger). -** (The shifts are done in parts to avoid shifting by more than the size +** Check whether some integers may not fit in a float, testing whether +** (maxinteger >> NBM) > 0. (That implies (1 << NBM) <= maxinteger.) +** (The shifts are done in parts, to avoid shifting by more than the size ** of an integer. In a worst case, NBM == 113 for long double and -** sizeof(integer) == 32.) +** sizeof(long) == 32.) */ #if ((((LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)) >> (NBM / 4)) \ >> (NBM - (3 * (NBM / 4)))) > 0 -#define l_intfitsf(i) \ - (-((lua_Integer)1 << NBM) <= (i) && (i) <= ((lua_Integer)1 << NBM)) +/* limit for integers that fit in a float */ +#define MAXINTFITSF ((lua_Unsigned)1 << NBM) -#endif +/* check whether 'i' is in the interval [-MAXINTFITSF, MAXINTFITSF] */ +#define l_intfitsf(i) ((MAXINTFITSF + l_castS2U(i)) <= (2 * MAXINTFITSF)) + +#else /* all integers fit in a float precisely */ + +#define l_intfitsf(i) 1 #endif +/* +** Try to convert a value from string to a number value. +** If the value is not a string or is a string not representing +** a valid numeral (or if coercions from strings to numbers +** are disabled via macro 'cvt2num'), do not modify 'result' +** and return 0. +*/ +static int l_strton (const TValue *obj, TValue *result) { + lua_assert(obj != result); + if (!cvt2num(obj)) /* is object not a string? */ + return 0; + else { + TString *st = tsvalue(obj); + return (luaO_str2num(getstr(st), result) == tsslen(st) + 1); + } +} + /* ** Try to convert a value to a float. The float case is already handled @@ -75,8 +108,7 @@ int luaV_tonumber_ (const TValue *obj, lua_Number *n) { *n = cast_num(ivalue(obj)); return 1; } - else if (cvt2num(obj) && /* string convertible to number? */ - luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) { + else if (l_strton(obj, &v)) { /* string coercible to number? */ *n = nvalue(&v); /* convert result of 'luaO_str2num' to a float */ return 1; } @@ -86,76 +118,173 @@ int luaV_tonumber_ (const TValue *obj, lua_Number *n) { /* -** try to convert a value to an integer, rounding according to 'mode': -** mode == 0: accepts only integral values -** mode == 1: takes the floor of the number -** mode == 2: takes the ceil of the number +** try to convert a float to an integer, rounding according to 'mode'. */ -int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode) { - TValue v; - again: - if (ttisfloat(obj)) { - lua_Number n = fltvalue(obj); - lua_Number f = l_floor(n); - if (n != f) { /* not an integral value? */ - if (mode == 0) return 0; /* fails if mode demands integral value */ - else if (mode > 1) /* needs ceil? */ - f += 1; /* convert floor to ceil (remember: n != f) */ - } - return lua_numbertointeger(f, p); +int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode) { + lua_Number f = l_floor(n); + if (n != f) { /* not an integral value? */ + if (mode == F2Ieq) return 0; /* fails if mode demands integral value */ + else if (mode == F2Iceil) /* needs ceil? */ + f += 1; /* convert floor to ceil (remember: n != f) */ } + return lua_numbertointeger(f, p); +} + + +/* +** try to convert a value to an integer, rounding according to 'mode', +** without string coercion. +** ("Fast track" handled by macro 'tointegerns'.) +*/ +int luaV_tointegerns (const TValue *obj, lua_Integer *p, F2Imod mode) { + if (ttisfloat(obj)) + return luaV_flttointeger(fltvalue(obj), p, mode); else if (ttisinteger(obj)) { *p = ivalue(obj); return 1; } - else if (cvt2num(obj) && - luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) { - obj = &v; - goto again; /* convert result from 'luaO_str2num' to an integer */ + else + return 0; +} + + +/* +** try to convert a value to an integer. +*/ +int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode) { + TValue v; + if (l_strton(obj, &v)) /* does 'obj' point to a numerical string? */ + obj = &v; /* change it to point to its corresponding number */ + return luaV_tointegerns(obj, p, mode); +} + + +/* +** Try to convert a 'for' limit to an integer, preserving the semantics +** of the loop. Return true if the loop must not run; otherwise, '*p' +** gets the integer limit. +** (The following explanation assumes a positive step; it is valid for +** negative steps mutatis mutandis.) +** If the limit is an integer or can be converted to an integer, +** rounding down, that is the limit. +** Otherwise, check whether the limit can be converted to a float. If +** the float is too large, clip it to LUA_MAXINTEGER. If the float +** is too negative, the loop should not run, because any initial +** integer value is greater than such limit; so, the function returns +** true to signal that. (For this latter case, no integer limit would be +** correct; even a limit of LUA_MININTEGER would run the loop once for +** an initial value equal to LUA_MININTEGER.) +*/ +static int forlimit (lua_State *L, lua_Integer init, const TValue *lim, + lua_Integer *p, lua_Integer step) { + if (!luaV_tointeger(lim, p, (step < 0 ? F2Iceil : F2Ifloor))) { + /* not coercible to in integer */ + lua_Number flim; /* try to convert to float */ + if (!tonumber(lim, &flim)) /* cannot convert to float? */ + luaG_forerror(L, lim, "limit"); + /* else 'flim' is a float out of integer bounds */ + if (luai_numlt(0, flim)) { /* if it is positive, it is too large */ + if (step < 0) return 1; /* initial value must be less than it */ + *p = LUA_MAXINTEGER; /* truncate */ + } + else { /* it is less than min integer */ + if (step > 0) return 1; /* initial value must be greater than it */ + *p = LUA_MININTEGER; /* truncate */ + } } - return 0; /* conversion failed */ + return (step > 0 ? init > *p : init < *p); /* not to run? */ } /* -** Try to convert a 'for' limit to an integer, preserving the -** semantics of the loop. -** (The following explanation assumes a non-negative step; it is valid -** for negative steps mutatis mutandis.) -** If the limit can be converted to an integer, rounding down, that is -** it. -** Otherwise, check whether the limit can be converted to a number. If -** the number is too large, it is OK to set the limit as LUA_MAXINTEGER, -** which means no limit. If the number is too negative, the loop -** should not run, because any initial integer value is larger than the -** limit. So, it sets the limit to LUA_MININTEGER. 'stopnow' corrects -** the extreme case when the initial value is LUA_MININTEGER, in which -** case the LUA_MININTEGER limit would still run the loop once. +** Prepare a numerical for loop (opcode OP_FORPREP). +** Return true to skip the loop. Otherwise, +** after preparation, stack will be as follows: +** ra : internal index (safe copy of the control variable) +** ra + 1 : loop counter (integer loops) or limit (float loops) +** ra + 2 : step +** ra + 3 : control variable */ -static int forlimit (const TValue *obj, lua_Integer *p, lua_Integer step, - int *stopnow) { - *stopnow = 0; /* usually, let loops run */ - if (!luaV_tointeger(obj, p, (step < 0 ? 2 : 1))) { /* not fit in integer? */ - lua_Number n; /* try to convert to float */ - if (!tonumber(obj, &n)) /* cannot convert to float? */ - return 0; /* not a number */ - if (luai_numlt(0, n)) { /* if true, float is larger than max integer */ - *p = LUA_MAXINTEGER; - if (step < 0) *stopnow = 1; +static int forprep (lua_State *L, StkId ra) { + TValue *pinit = s2v(ra); + TValue *plimit = s2v(ra + 1); + TValue *pstep = s2v(ra + 2); + if (ttisinteger(pinit) && ttisinteger(pstep)) { /* integer loop? */ + lua_Integer init = ivalue(pinit); + lua_Integer step = ivalue(pstep); + lua_Integer limit; + if (step == 0) + luaG_runerror(L, "'for' step is zero"); + setivalue(s2v(ra + 3), init); /* control variable */ + if (forlimit(L, init, plimit, &limit, step)) + return 1; /* skip the loop */ + else { /* prepare loop counter */ + lua_Unsigned count; + if (step > 0) { /* ascending loop? */ + count = l_castS2U(limit) - l_castS2U(init); + if (step != 1) /* avoid division in the too common case */ + count /= l_castS2U(step); + } + else { /* step < 0; descending loop */ + count = l_castS2U(init) - l_castS2U(limit); + /* 'step+1' avoids negating 'mininteger' */ + count /= l_castS2U(-(step + 1)) + 1u; + } + /* store the counter in place of the limit (which won't be + needed anymore) */ + setivalue(plimit, l_castU2S(count)); } - else { /* float is smaller than min integer */ - *p = LUA_MININTEGER; - if (step >= 0) *stopnow = 1; + } + else { /* try making all values floats */ + lua_Number init; lua_Number limit; lua_Number step; + if (l_unlikely(!tonumber(plimit, &limit))) + luaG_forerror(L, plimit, "limit"); + if (l_unlikely(!tonumber(pstep, &step))) + luaG_forerror(L, pstep, "step"); + if (l_unlikely(!tonumber(pinit, &init))) + luaG_forerror(L, pinit, "initial value"); + if (step == 0) + luaG_runerror(L, "'for' step is zero"); + if (luai_numlt(0, step) ? luai_numlt(limit, init) + : luai_numlt(init, limit)) + return 1; /* skip the loop */ + else { + /* make sure internal values are all floats */ + setfltvalue(plimit, limit); + setfltvalue(pstep, step); + setfltvalue(s2v(ra), init); /* internal index */ + setfltvalue(s2v(ra + 3), init); /* control variable */ } } - return 1; + return 0; +} + + +/* +** Execute a step of a float numerical for loop, returning +** true iff the loop must continue. (The integer case is +** written online with opcode OP_FORLOOP, for performance.) +*/ +static int floatforloop (StkId ra) { + lua_Number step = fltvalue(s2v(ra + 2)); + lua_Number limit = fltvalue(s2v(ra + 1)); + lua_Number idx = fltvalue(s2v(ra)); /* internal index */ + idx = luai_numadd(L, idx, step); /* increment index */ + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + chgfltvalue(s2v(ra), idx); /* update internal index */ + setfltvalue(s2v(ra + 3), idx); /* and control variable */ + return 1; /* jump back */ + } + else + return 0; /* finish the loop */ } /* ** Finish the table access 'val = t[key]'. ** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to -** t[k] entry (which must be nil). +** t[k] entry (which must be empty). */ void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot) { @@ -165,25 +294,25 @@ void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, if (slot == NULL) { /* 't' is not a table? */ lua_assert(!ttistable(t)); tm = luaT_gettmbyobj(L, t, TM_INDEX); - if (ttisnil(tm)) + if (l_unlikely(notm(tm))) luaG_typeerror(L, t, "index"); /* no metamethod */ /* else will try the metamethod */ } else { /* 't' is a table */ - lua_assert(ttisnil(slot)); + lua_assert(isempty(slot)); tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */ if (tm == NULL) { /* no metamethod? */ - setnilvalue(val); /* result is nil */ + setnilvalue(s2v(val)); /* result is nil */ return; } /* else will try the metamethod */ } if (ttisfunction(tm)) { /* is metamethod a function? */ - luaT_callTM(L, tm, t, key, val, 1); /* call it */ + luaT_callTMres(L, tm, t, key, val); /* call it */ return; } t = tm; /* else try to access 'tm[key]' */ - if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */ + if (luaV_fastget(L, t, key, slot, luaH_get)) { /* fast track? */ setobj2s(L, val, slot); /* done */ return; } @@ -196,73 +325,75 @@ void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, /* ** Finish a table assignment 't[key] = val'. ** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points -** to the entry 't[key]', or to 'luaO_nilobject' if there is no such -** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset' -** would have done the job.) +** to the entry 't[key]', or to a value with an absent key if there +** is no such entry. (The value at 'slot' must be empty, otherwise +** 'luaV_fastget' would have done the job.) */ void luaV_finishset (lua_State *L, const TValue *t, TValue *key, - StkId val, const TValue *slot) { + TValue *val, const TValue *slot) { int loop; /* counter to avoid infinite loops */ for (loop = 0; loop < MAXTAGLOOP; loop++) { const TValue *tm; /* '__newindex' metamethod */ if (slot != NULL) { /* is 't' a table? */ Table *h = hvalue(t); /* save 't' table */ - lua_assert(ttisnil(slot)); /* old value must be nil */ + lua_assert(isempty(slot)); /* slot must be empty */ tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ if (tm == NULL) { /* no metamethod? */ - if (slot == luaO_nilobject) /* no previous entry? */ - slot = luaH_newkey(L, h, key); /* create one */ - /* no metamethod and (now) there is an entry with given key */ - setobj2t(L, cast(TValue *, slot), val); /* set its new value */ + luaH_finishset(L, h, key, slot, val); /* set new value */ invalidateTMcache(h); - luaC_barrierback(L, h, val); + luaC_barrierback(L, obj2gco(h), val); return; } /* else will try the metamethod */ } else { /* not a table; check metamethod */ - if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + tm = luaT_gettmbyobj(L, t, TM_NEWINDEX); + if (l_unlikely(notm(tm))) luaG_typeerror(L, t, "index"); } /* try the metamethod */ if (ttisfunction(tm)) { - luaT_callTM(L, tm, t, key, val, 0); + luaT_callTM(L, tm, t, key, val); return; } t = tm; /* else repeat assignment over 'tm' */ - if (luaV_fastset(L, t, key, slot, luaH_get, val)) + if (luaV_fastget(L, t, key, slot, luaH_get)) { + luaV_finishfastset(L, t, slot, val); return; /* done */ - /* else loop */ + } + /* else 'return luaV_finishset(L, t, key, val, slot)' (loop) */ } luaG_runerror(L, "'__newindex' chain too long; possible loop"); } /* -** Compare two strings 'ls' x 'rs', returning an integer smaller-equal- -** -larger than zero if 'ls' is smaller-equal-larger than 'rs'. +** Compare two strings 'ts1' x 'ts2', returning an integer less-equal- +** -greater than zero if 'ts1' is less-equal-greater than 'ts2'. ** The code is a little tricky because it allows '\0' in the strings -** and it uses 'strcoll' (to respect locales) for each segments -** of the strings. +** and it uses 'strcoll' (to respect locales) for each segment +** of the strings. Note that segments can compare equal but still +** have different lengths. */ -static int l_strcmp (const TString *ls, const TString *rs) { - const char *l = getstr(ls); - size_t ll = tsslen(ls); - const char *r = getstr(rs); - size_t lr = tsslen(rs); +static int l_strcmp (const TString *ts1, const TString *ts2) { + const char *s1 = getstr(ts1); + size_t rl1 = tsslen(ts1); /* real length */ + const char *s2 = getstr(ts2); + size_t rl2 = tsslen(ts2); for (;;) { /* for each segment */ - int temp = strcoll(l, r); + int temp = strcoll(s1, s2); if (temp != 0) /* not equal? */ return temp; /* done */ else { /* strings are equal up to a '\0' */ - size_t len = strlen(l); /* index of first '\0' in both strings */ - if (len == lr) /* 'rs' is finished? */ - return (len == ll) ? 0 : 1; /* check 'ls' */ - else if (len == ll) /* 'ls' is finished? */ - return -1; /* 'ls' is smaller than 'rs' ('rs' is not finished) */ - /* both strings longer than 'len'; go on comparing after the '\0' */ - len++; - l += len; ll -= len; r += len; lr -= len; + size_t zl1 = strlen(s1); /* index of first '\0' in 's1' */ + size_t zl2 = strlen(s2); /* index of first '\0' in 's2' */ + if (zl2 == rl2) /* 's2' is finished? */ + return (zl1 == rl1) ? 0 : 1; /* check 's1' */ + else if (zl1 == rl1) /* 's1' is finished? */ + return -1; /* 's1' is less than 's2' ('s2' is not finished) */ + /* both strings longer than 'zl'; go on comparing after the '\0' */ + zl1++; zl2++; + s1 += zl1; rl1 -= zl1; s2 += zl2; rl2 -= zl2; } } } @@ -271,25 +402,24 @@ static int l_strcmp (const TString *ls, const TString *rs) { /* ** Check whether integer 'i' is less than float 'f'. If 'i' has an ** exact representation as a float ('l_intfitsf'), compare numbers as -** floats. Otherwise, if 'f' is outside the range for integers, result -** is trivial. Otherwise, compare them as integers. (When 'i' has no -** float representation, either 'f' is "far away" from 'i' or 'f' has -** no precision left for a fractional part; either way, how 'f' is -** truncated is irrelevant.) When 'f' is NaN, comparisons must result -** in false. +** floats. Otherwise, use the equivalence 'i < f <=> i < ceil(f)'. +** If 'ceil(f)' is out of integer range, either 'f' is greater than +** all integers or less than all integers. +** (The test with 'l_intfitsf' is only for performance; the else +** case is correct for all values, but it is slow due to the conversion +** from float to int.) +** When 'f' is NaN, comparisons must result in false. */ -static int LTintfloat (lua_Integer i, lua_Number f) { -#if defined(l_intfitsf) - if (!l_intfitsf(i)) { - if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */ - return 1; /* f >= maxint + 1 > i */ - else if (f > cast_num(LUA_MININTEGER)) /* minint < f <= maxint ? */ - return (i < cast(lua_Integer, f)); /* compare them as integers */ - else /* f <= minint <= i (or 'f' is NaN) --> not(i < f) */ - return 0; +l_sinline int LTintfloat (lua_Integer i, lua_Number f) { + if (l_intfitsf(i)) + return luai_numlt(cast_num(i), f); /* compare them as floats */ + else { /* i < f <=> i < ceil(f) */ + lua_Integer fi; + if (luaV_flttointeger(f, &fi, F2Iceil)) /* fi = ceil(f) */ + return i < fi; /* compare them as integers */ + else /* 'f' is either greater or less than all integers */ + return f > 0; /* greater? */ } -#endif - return luai_numlt(cast_num(i), f); /* compare them as floats */ } @@ -297,25 +427,58 @@ static int LTintfloat (lua_Integer i, lua_Number f) { ** Check whether integer 'i' is less than or equal to float 'f'. ** See comments on previous function. */ -static int LEintfloat (lua_Integer i, lua_Number f) { -#if defined(l_intfitsf) - if (!l_intfitsf(i)) { - if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */ - return 1; /* f >= maxint + 1 > i */ - else if (f >= cast_num(LUA_MININTEGER)) /* minint <= f <= maxint ? */ - return (i <= cast(lua_Integer, f)); /* compare them as integers */ - else /* f < minint <= i (or 'f' is NaN) --> not(i <= f) */ - return 0; +l_sinline int LEintfloat (lua_Integer i, lua_Number f) { + if (l_intfitsf(i)) + return luai_numle(cast_num(i), f); /* compare them as floats */ + else { /* i <= f <=> i <= floor(f) */ + lua_Integer fi; + if (luaV_flttointeger(f, &fi, F2Ifloor)) /* fi = floor(f) */ + return i <= fi; /* compare them as integers */ + else /* 'f' is either greater or less than all integers */ + return f > 0; /* greater? */ + } +} + + +/* +** Check whether float 'f' is less than integer 'i'. +** See comments on previous function. +*/ +l_sinline int LTfloatint (lua_Number f, lua_Integer i) { + if (l_intfitsf(i)) + return luai_numlt(f, cast_num(i)); /* compare them as floats */ + else { /* f < i <=> floor(f) < i */ + lua_Integer fi; + if (luaV_flttointeger(f, &fi, F2Ifloor)) /* fi = floor(f) */ + return fi < i; /* compare them as integers */ + else /* 'f' is either greater or less than all integers */ + return f < 0; /* less? */ + } +} + + +/* +** Check whether float 'f' is less than or equal to integer 'i'. +** See comments on previous function. +*/ +l_sinline int LEfloatint (lua_Number f, lua_Integer i) { + if (l_intfitsf(i)) + return luai_numle(f, cast_num(i)); /* compare them as floats */ + else { /* f <= i <=> ceil(f) <= i */ + lua_Integer fi; + if (luaV_flttointeger(f, &fi, F2Iceil)) /* fi = ceil(f) */ + return fi <= i; /* compare them as integers */ + else /* 'f' is either greater or less than all integers */ + return f < 0; /* less? */ } -#endif - return luai_numle(cast_num(i), f); /* compare them as floats */ } /* ** Return 'l < r', for numbers. */ -static int LTnum (const TValue *l, const TValue *r) { +l_sinline int LTnum (const TValue *l, const TValue *r) { + lua_assert(ttisnumber(l) && ttisnumber(r)); if (ttisinteger(l)) { lua_Integer li = ivalue(l); if (ttisinteger(r)) @@ -327,10 +490,8 @@ static int LTnum (const TValue *l, const TValue *r) { lua_Number lf = fltvalue(l); /* 'l' must be float */ if (ttisfloat(r)) return luai_numlt(lf, fltvalue(r)); /* both are float */ - else if (luai_numisnan(lf)) /* 'r' is int and 'l' is float */ - return 0; /* NaN < i is always false */ - else /* without NaN, (l < r) <--> not(r <= l) */ - return !LEintfloat(ivalue(r), lf); /* not (r <= l) ? */ + else /* 'l' is float and 'r' is int */ + return LTfloatint(lf, ivalue(r)); } } @@ -338,7 +499,8 @@ static int LTnum (const TValue *l, const TValue *r) { /* ** Return 'l <= r', for numbers. */ -static int LEnum (const TValue *l, const TValue *r) { +l_sinline int LEnum (const TValue *l, const TValue *r) { + lua_assert(ttisnumber(l) && ttisnumber(r)); if (ttisinteger(l)) { lua_Integer li = ivalue(l); if (ttisinteger(r)) @@ -350,53 +512,53 @@ static int LEnum (const TValue *l, const TValue *r) { lua_Number lf = fltvalue(l); /* 'l' must be float */ if (ttisfloat(r)) return luai_numle(lf, fltvalue(r)); /* both are float */ - else if (luai_numisnan(lf)) /* 'r' is int and 'l' is float */ - return 0; /* NaN <= i is always false */ - else /* without NaN, (l <= r) <--> not(r < l) */ - return !LTintfloat(ivalue(r), lf); /* not (r < l) ? */ + else /* 'l' is float and 'r' is int */ + return LEfloatint(lf, ivalue(r)); } } +/* +** return 'l < r' for non-numbers. +*/ +static int lessthanothers (lua_State *L, const TValue *l, const TValue *r) { + lua_assert(!ttisnumber(l) || !ttisnumber(r)); + if (ttisstring(l) && ttisstring(r)) /* both are strings? */ + return l_strcmp(tsvalue(l), tsvalue(r)) < 0; + else + return luaT_callorderTM(L, l, r, TM_LT); +} + + /* ** Main operation less than; return 'l < r'. */ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { - int res; if (ttisnumber(l) && ttisnumber(r)) /* both operands are numbers? */ return LTnum(l, r); - else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ - return l_strcmp(tsvalue(l), tsvalue(r)) < 0; - else if ((res = luaT_callorderTM(L, l, r, TM_LT)) < 0) /* no metamethod? */ - luaG_ordererror(L, l, r); /* error */ - return res; + else return lessthanothers(L, l, r); +} + + +/* +** return 'l <= r' for non-numbers. +*/ +static int lessequalothers (lua_State *L, const TValue *l, const TValue *r) { + lua_assert(!ttisnumber(l) || !ttisnumber(r)); + if (ttisstring(l) && ttisstring(r)) /* both are strings? */ + return l_strcmp(tsvalue(l), tsvalue(r)) <= 0; + else + return luaT_callorderTM(L, l, r, TM_LE); } /* -** Main operation less than or equal to; return 'l <= r'. If it needs -** a metamethod and there is no '__le', try '__lt', based on -** l <= r iff !(r < l) (assuming a total order). If the metamethod -** yields during this substitution, the continuation has to know -** about it (to negate the result of r= 0) /* try 'le' */ - return res; - else { /* try 'lt': */ - L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ - res = luaT_callorderTM(L, r, l, TM_LT); - L->ci->callstatus ^= CIST_LEQ; /* clear mark */ - if (res < 0) - luaG_ordererror(L, l, r); - return !res; /* result is negated */ - } + else return lessequalothers(L, l, r); } @@ -406,25 +568,29 @@ int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { */ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { const TValue *tm; - if (ttype(t1) != ttype(t2)) { /* not the same variant? */ - if (ttnov(t1) != ttnov(t2) || ttnov(t1) != LUA_TNUMBER) + if (ttypetag(t1) != ttypetag(t2)) { /* not the same variant? */ + if (ttype(t1) != ttype(t2) || ttype(t1) != LUA_TNUMBER) return 0; /* only numbers can be equal with different variants */ else { /* two numbers with different variants */ - lua_Integer i1, i2; /* compare them as integers */ - return (tointeger(t1, &i1) && tointeger(t2, &i2) && i1 == i2); + /* One of them is an integer. If the other does not have an + integer value, they cannot be equal; otherwise, compare their + integer values. */ + lua_Integer i1, i2; + return (luaV_tointegerns(t1, &i1, F2Ieq) && + luaV_tointegerns(t2, &i2, F2Ieq) && + i1 == i2); } } /* values have same type and same variant */ - switch (ttype(t1)) { - case LUA_TNIL: return 1; - case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2)); - case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2)); - case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ - case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); - case LUA_TLCF: return fvalue(t1) == fvalue(t2); - case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); - case LUA_TLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2)); - case LUA_TUSERDATA: { + switch (ttypetag(t1)) { + case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE: return 1; + case LUA_VNUMINT: return (ivalue(t1) == ivalue(t2)); + case LUA_VNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2)); + case LUA_VLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_VLCF: return fvalue(t1) == fvalue(t2); + case LUA_VSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); + case LUA_VLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2)); + case LUA_VUSERDATA: { if (uvalue(t1) == uvalue(t2)) return 1; else if (L == NULL) return 0; tm = fasttm(L, uvalue(t1)->metatable, TM_EQ); @@ -432,7 +598,7 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { tm = fasttm(L, uvalue(t2)->metatable, TM_EQ); break; /* will try TM */ } - case LUA_TTABLE: { + case LUA_VTABLE: { if (hvalue(t1) == hvalue(t2)) return 1; else if (L == NULL) return 0; tm = fasttm(L, hvalue(t1)->metatable, TM_EQ); @@ -445,8 +611,10 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { } if (tm == NULL) /* no TM? */ return 0; /* objects are different */ - luaT_callTM(L, tm, t1, t2, L->top, 1); /* call TM */ - return !l_isfalse(L->top); + else { + luaT_callTMres(L, tm, t1, t2, L->top.p); /* call TM */ + return !l_isfalse(s2v(L->top.p)); + } } @@ -460,8 +628,9 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { static void copy2buff (StkId top, int n, char *buff) { size_t tl = 0; /* size already copied */ do { - size_t l = vslen(top - n); /* length of string being copied */ - memcpy(buff + tl, svalue(top - n), l * sizeof(char)); + TString *st = tsvalue(s2v(top - n)); + size_t l = tsslen(st); /* length of string being copied */ + memcpy(buff + tl, getstr(st), l * sizeof(char)); tl += l; } while (--n > 0); } @@ -469,29 +638,33 @@ static void copy2buff (StkId top, int n, char *buff) { /* ** Main operation for concatenation: concat 'total' values in the stack, -** from 'L->top - total' up to 'L->top - 1'. +** from 'L->top.p - total' up to 'L->top.p - 1'. */ void luaV_concat (lua_State *L, int total) { - lua_assert(total >= 2); + if (total == 1) + return; /* "all" values already concatenated */ do { - StkId top = L->top; + StkId top = L->top.p; int n = 2; /* number of elements handled in this pass (at least 2) */ - if (!(ttisstring(top-2) || cvt2str(top-2)) || !tostring(L, top-1)) - luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT); - else if (isemptystr(top - 1)) /* second operand is empty? */ - cast_void(tostring(L, top - 2)); /* result is first operand */ - else if (isemptystr(top - 2)) { /* first operand is an empty string? */ + if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) || + !tostring(L, s2v(top - 1))) + luaT_tryconcatTM(L); /* may invalidate 'top' */ + else if (isemptystr(s2v(top - 1))) /* second operand is empty? */ + cast_void(tostring(L, s2v(top - 2))); /* result is first operand */ + else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */ setobjs2s(L, top - 2, top - 1); /* result is second op. */ } else { /* at least two non-empty string values; get as many as possible */ - size_t tl = vslen(top - 1); + size_t tl = tsslen(tsvalue(s2v(top - 1))); TString *ts; /* collect total length and number of strings */ - for (n = 1; n < total && tostring(L, top - n - 1); n++) { - size_t l = vslen(top - n - 1); - if (l >= (MAX_SIZE/sizeof(char)) - tl) + for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { + size_t l = tsslen(tsvalue(s2v(top - n - 1))); + if (l_unlikely(l >= MAX_SIZE - sizeof(TString) - tl)) { + L->top.p = top - total; /* pop strings to avoid wasting stack */ luaG_runerror(L, "string length overflow"); + } tl += l; } if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */ @@ -501,45 +674,45 @@ void luaV_concat (lua_State *L, int total) { } else { /* long string; copy strings directly to final result */ ts = luaS_createlngstrobj(L, tl); - copy2buff(top, n, getstr(ts)); + copy2buff(top, n, getlngstr(ts)); } setsvalue2s(L, top - n, ts); /* create result */ } - total -= n-1; /* got 'n' strings to create 1 new */ - L->top -= n-1; /* popped 'n' strings and pushed one */ + total -= n - 1; /* got 'n' strings to create one new */ + L->top.p -= n - 1; /* popped 'n' strings and pushed one */ } while (total > 1); /* repeat until only 1 result left */ } /* -** Main operation 'ra' = #rb'. +** Main operation 'ra = #rb'. */ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { const TValue *tm; - switch (ttype(rb)) { - case LUA_TTABLE: { + switch (ttypetag(rb)) { + case LUA_VTABLE: { Table *h = hvalue(rb); tm = fasttm(L, h->metatable, TM_LEN); if (tm) break; /* metamethod? break switch to call it */ - setivalue(ra, luaH_getn(h)); /* else primitive len */ + setivalue(s2v(ra), luaH_getn(h)); /* else primitive len */ return; } - case LUA_TSHRSTR: { - setivalue(ra, tsvalue(rb)->shrlen); + case LUA_VSHRSTR: { + setivalue(s2v(ra), tsvalue(rb)->shrlen); return; } - case LUA_TLNGSTR: { - setivalue(ra, tsvalue(rb)->u.lnglen); + case LUA_VLNGSTR: { + setivalue(s2v(ra), tsvalue(rb)->u.lnglen); return; } default: { /* try metamethod */ tm = luaT_gettmbyobj(L, rb, TM_LEN); - if (ttisnil(tm)) /* no metamethod? */ + if (l_unlikely(notm(tm))) /* no metamethod? */ luaG_typeerror(L, rb, "get length of"); break; } } - luaT_callTM(L, tm, rb, rb, ra, 1); + luaT_callTMres(L, tm, rb, rb, ra); } @@ -549,8 +722,8 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { ** 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, ** otherwise 'floor(q) == trunc(q) - 1'. */ -lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) { - if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ +lua_Integer luaV_idiv (lua_State *L, lua_Integer m, lua_Integer n) { + if (l_unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */ if (n == 0) luaG_runerror(L, "attempt to divide by zero"); return intop(-, 0, m); /* n==-1; avoid overflow with 0x80000...//-1 */ @@ -567,26 +740,37 @@ lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) { /* ** Integer modulus; return 'm % n'. (Assume that C '%' with ** negative operands follows C99 behavior. See previous comment -** about luaV_div.) +** about luaV_idiv.) */ lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) { - if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ + if (l_unlikely(l_castS2U(n) + 1u <= 1u)) { /* special cases: -1 or 0 */ if (n == 0) luaG_runerror(L, "attempt to perform 'n%%0'"); return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */ } else { lua_Integer r = m % n; - if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */ + if (r != 0 && (r ^ n) < 0) /* 'm/n' would be non-integer negative? */ r += n; /* correct result for different rounding */ return r; } } +/* +** Float modulus +*/ +lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) { + lua_Number r; + luai_nummod(L, m, n, r); + return r; +} + + /* number of bits in an integer */ #define NBITS cast_int(sizeof(lua_Integer) * CHAR_BIT) + /* ** Shift left operation. (Shift right just negates 'y'.) */ @@ -602,32 +786,9 @@ lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { } -/* -** check whether cached closure in prototype 'p' may be reused, that is, -** whether there is a cached closure with the same upvalues needed by -** new closure to be created. -*/ -static LClosure *getcached (Proto *p, UpVal **encup, StkId base) { - LClosure *c = p->cache; - if (c != NULL) { /* is there a cached closure? */ - int nup = p->sizeupvalues; - Upvaldesc *uv = p->upvalues; - int i; - for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ - TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; - if (c->upvals[i]->v != v) - return NULL; /* wrong upvalue; cannot reuse closure */ - } - } - return c; /* return cached closure (or NULL if no cached closure) */ -} - - /* ** create a new Lua closure, push it in the stack, and initialize -** its upvalues. Note that the closure is not cached if prototype is -** already black (which means that 'cache' was already cleared by the -** GC). +** its upvalues. */ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra) { @@ -636,77 +797,82 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, int i; LClosure *ncl = luaF_newLclosure(L, nup); ncl->p = p; - setclLvalue(L, ra, ncl); /* anchor new closure in stack */ + setclLvalue2s(L, ra, ncl); /* anchor new closure in stack */ for (i = 0; i < nup; i++) { /* fill in its upvalues */ if (uv[i].instack) /* upvalue refers to local variable? */ ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx); else /* get upvalue from enclosing function */ ncl->upvals[i] = encup[uv[i].idx]; - ncl->upvals[i]->refcount++; - /* new closure is white, so we do not need a barrier here */ + luaC_objbarrier(L, ncl, ncl->upvals[i]); } - if (!isblack(p)) /* cache will not break GC invariant? */ - p->cache = ncl; /* save it on cache for reuse */ } /* -** finish execution of an opcode interrupted by an yield +** finish execution of an opcode interrupted by a yield */ void luaV_finishOp (lua_State *L) { CallInfo *ci = L->ci; - StkId base = ci->u.l.base; + StkId base = ci->func.p + 1; Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ OpCode op = GET_OPCODE(inst); switch (op) { /* finish its execution */ - case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_IDIV: - case OP_BAND: case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: - case OP_MOD: case OP_POW: + case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: { + setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top.p); + break; + } case OP_UNM: case OP_BNOT: case OP_LEN: - case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { - setobjs2s(L, base + GETARG_A(inst), --L->top); + case OP_GETTABUP: case OP_GETTABLE: case OP_GETI: + case OP_GETFIELD: case OP_SELF: { + setobjs2s(L, base + GETARG_A(inst), --L->top.p); break; } - case OP_LE: case OP_LT: case OP_EQ: { - int res = !l_isfalse(L->top - 1); - L->top--; + case OP_LT: case OP_LE: + case OP_LTI: case OP_LEI: + case OP_GTI: case OP_GEI: + case OP_EQ: { /* note that 'OP_EQI'/'OP_EQK' cannot yield */ + int res = !l_isfalse(s2v(L->top.p - 1)); + L->top.p--; +#if defined(LUA_COMPAT_LT_LE) if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ - lua_assert(op == OP_LE); ci->callstatus ^= CIST_LEQ; /* clear mark */ res = !res; /* negate result */ } +#endif lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); - if (res != GETARG_A(inst)) /* condition failed? */ + if (res != GETARG_k(inst)) /* condition failed? */ ci->u.l.savedpc++; /* skip jump instruction */ break; } case OP_CONCAT: { - StkId top = L->top - 1; /* top when 'luaT_trybinTM' was called */ - int b = GETARG_B(inst); /* first element to concatenate */ - int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ - setobj2s(L, top - 2, top); /* put TM result in proper position */ - if (total > 1) { /* are there elements to concat? */ - L->top = top - 1; /* top is one after last element (at top-2) */ - luaV_concat(L, total); /* concat them (may yield again) */ - } - /* move final result to final position */ - setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); - L->top = ci->top; /* restore top */ + StkId top = L->top.p - 1; /* top when 'luaT_tryconcatTM' was called */ + int a = GETARG_A(inst); /* first element to concatenate */ + int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */ + setobjs2s(L, top - 2, top); /* put TM result in proper position */ + L->top.p = top - 1; /* top is one after last element (at top-2) */ + luaV_concat(L, total); /* concat them (may yield again) */ break; } - case OP_TFORCALL: { - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP); - L->top = ci->top; /* correct top */ + case OP_CLOSE: { /* yielded closing variables */ + ci->u.l.savedpc--; /* repeat instruction to close other vars. */ break; } - case OP_CALL: { - if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */ - L->top = ci->top; /* adjust results */ + case OP_RETURN: { /* yielded closing variables */ + StkId ra = base + GETARG_A(inst); + /* adjust top to signal correct number of returns, in case the + return is "up to top" ('isIT') */ + L->top.p = ra + ci->u2.nres; + /* repeat instruction to close other vars. and complete the return */ + ci->u.l.savedpc--; break; } - case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: + default: { + /* only these other opcodes can yield */ + lua_assert(op == OP_TFORCALL || op == OP_CALL || + op == OP_TAILCALL || op == OP_SETTABUP || op == OP_SETTABLE || + op == OP_SETI || op == OP_SETFIELD); break; - default: lua_assert(0); + } } } @@ -715,10 +881,180 @@ void luaV_finishOp (lua_State *L) { /* ** {================================================================== -** Function 'luaV_execute': main interpreter loop +** Macros for arithmetic/bitwise/comparison opcodes in 'luaV_execute' ** =================================================================== */ +#define l_addi(L,a,b) intop(+, a, b) +#define l_subi(L,a,b) intop(-, a, b) +#define l_muli(L,a,b) intop(*, a, b) +#define l_band(a,b) intop(&, a, b) +#define l_bor(a,b) intop(|, a, b) +#define l_bxor(a,b) intop(^, a, b) + +#define l_lti(a,b) (a < b) +#define l_lei(a,b) (a <= b) +#define l_gti(a,b) (a > b) +#define l_gei(a,b) (a >= b) + + +/* +** Arithmetic operations with immediate operands. 'iop' is the integer +** operation, 'fop' is the float operation. +*/ +#define op_arithI(L,iop,fop) { \ + StkId ra = RA(i); \ + TValue *v1 = vRB(i); \ + int imm = GETARG_sC(i); \ + if (ttisinteger(v1)) { \ + lua_Integer iv1 = ivalue(v1); \ + pc++; setivalue(s2v(ra), iop(L, iv1, imm)); \ + } \ + else if (ttisfloat(v1)) { \ + lua_Number nb = fltvalue(v1); \ + lua_Number fimm = cast_num(imm); \ + pc++; setfltvalue(s2v(ra), fop(L, nb, fimm)); \ + }} + + +/* +** Auxiliary function for arithmetic operations over floats and others +** with two register operands. +*/ +#define op_arithf_aux(L,v1,v2,fop) { \ + lua_Number n1; lua_Number n2; \ + if (tonumberns(v1, n1) && tonumberns(v2, n2)) { \ + pc++; setfltvalue(s2v(ra), fop(L, n1, n2)); \ + }} + + +/* +** Arithmetic operations over floats and others with register operands. +*/ +#define op_arithf(L,fop) { \ + StkId ra = RA(i); \ + TValue *v1 = vRB(i); \ + TValue *v2 = vRC(i); \ + op_arithf_aux(L, v1, v2, fop); } + + +/* +** Arithmetic operations with K operands for floats. +*/ +#define op_arithfK(L,fop) { \ + StkId ra = RA(i); \ + TValue *v1 = vRB(i); \ + TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \ + op_arithf_aux(L, v1, v2, fop); } + + +/* +** Arithmetic operations over integers and floats. +*/ +#define op_arith_aux(L,v1,v2,iop,fop) { \ + StkId ra = RA(i); \ + if (ttisinteger(v1) && ttisinteger(v2)) { \ + lua_Integer i1 = ivalue(v1); lua_Integer i2 = ivalue(v2); \ + pc++; setivalue(s2v(ra), iop(L, i1, i2)); \ + } \ + else op_arithf_aux(L, v1, v2, fop); } + + +/* +** Arithmetic operations with register operands. +*/ +#define op_arith(L,iop,fop) { \ + TValue *v1 = vRB(i); \ + TValue *v2 = vRC(i); \ + op_arith_aux(L, v1, v2, iop, fop); } + + +/* +** Arithmetic operations with K operands. +*/ +#define op_arithK(L,iop,fop) { \ + TValue *v1 = vRB(i); \ + TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \ + op_arith_aux(L, v1, v2, iop, fop); } + + +/* +** Bitwise operations with constant operand. +*/ +#define op_bitwiseK(L,op) { \ + StkId ra = RA(i); \ + TValue *v1 = vRB(i); \ + TValue *v2 = KC(i); \ + lua_Integer i1; \ + lua_Integer i2 = ivalue(v2); \ + if (tointegerns(v1, &i1)) { \ + pc++; setivalue(s2v(ra), op(i1, i2)); \ + }} + + +/* +** Bitwise operations with register operands. +*/ +#define op_bitwise(L,op) { \ + StkId ra = RA(i); \ + TValue *v1 = vRB(i); \ + TValue *v2 = vRC(i); \ + lua_Integer i1; lua_Integer i2; \ + if (tointegerns(v1, &i1) && tointegerns(v2, &i2)) { \ + pc++; setivalue(s2v(ra), op(i1, i2)); \ + }} + + +/* +** Order operations with register operands. 'opn' actually works +** for all numbers, but the fast track improves performance for +** integers. +*/ +#define op_order(L,opi,opn,other) { \ + StkId ra = RA(i); \ + int cond; \ + TValue *rb = vRB(i); \ + if (ttisinteger(s2v(ra)) && ttisinteger(rb)) { \ + lua_Integer ia = ivalue(s2v(ra)); \ + lua_Integer ib = ivalue(rb); \ + cond = opi(ia, ib); \ + } \ + else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) \ + cond = opn(s2v(ra), rb); \ + else \ + Protect(cond = other(L, s2v(ra), rb)); \ + docondjump(); } + + +/* +** Order operations with immediate operand. (Immediate operand is +** always small enough to have an exact representation as a float.) +*/ +#define op_orderI(L,opi,opf,inv,tm) { \ + StkId ra = RA(i); \ + int cond; \ + int im = GETARG_sB(i); \ + if (ttisinteger(s2v(ra))) \ + cond = opi(ivalue(s2v(ra)), im); \ + else if (ttisfloat(s2v(ra))) { \ + lua_Number fa = fltvalue(s2v(ra)); \ + lua_Number fim = cast_num(im); \ + cond = opf(fa, fim); \ + } \ + else { \ + int isf = GETARG_C(i); \ + Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm)); \ + } \ + docondjump(); } + +/* }================================================================== */ + + +/* +** {================================================================== +** Function 'luaV_execute': main interpreter loop +** =================================================================== +*/ /* ** some macros for common tasks in 'luaV_execute' @@ -726,40 +1062,85 @@ void luaV_finishOp (lua_State *L) { #define RA(i) (base+GETARG_A(i)) -#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) -#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) -#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ - ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) -#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ - ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define RB(i) (base+GETARG_B(i)) +#define vRB(i) s2v(RB(i)) +#define KB(i) (k+GETARG_B(i)) +#define RC(i) (base+GETARG_C(i)) +#define vRC(i) s2v(RC(i)) +#define KC(i) (k+GETARG_C(i)) +#define RKC(i) ((TESTARG_k(i)) ? k + GETARG_C(i) : s2v(base + GETARG_C(i))) + + + +#define updatetrap(ci) (trap = ci->u.l.trap) +#define updatebase(ci) (base = ci->func.p + 1) + + +#define updatestack(ci) \ + { if (l_unlikely(trap)) { updatebase(ci); ra = RA(i); } } + + +/* +** Execute a jump instruction. The 'updatetrap' allows signals to stop +** tight loops. (Without it, the local copy of 'trap' could never change.) +*/ +#define dojump(ci,i,e) { pc += GETARG_sJ(i) + e; updatetrap(ci); } -/* execute a jump instruction */ -#define dojump(ci,i,e) \ - { int a = GETARG_A(i); \ - if (a != 0) luaF_close(L, ci->u.l.base + a - 1); \ - ci->u.l.savedpc += GETARG_sBx(i) + e; } /* for test instructions, execute the jump instruction that follows it */ -#define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); } +#define donextjump(ci) { Instruction ni = *pc; dojump(ci, ni, 1); } + +/* +** do a conditional jump: skip next instruction if 'cond' is not what +** was expected (parameter 'k'), else do next instruction, which must +** be a jump. +*/ +#define docondjump() if (cond != GETARG_k(i)) pc++; else donextjump(ci); + + +/* +** Correct global 'pc'. +*/ +#define savepc(L) (ci->u.l.savedpc = pc) + + +/* +** Whenever code can raise errors, the global 'pc' and the global +** 'top' must be correct to report occasional errors. +*/ +#define savestate(L,ci) (savepc(L), L->top.p = ci->top.p) -#define Protect(x) { {x;}; base = ci->u.l.base; } +/* +** Protect code that, in general, can raise errors, reallocate the +** stack, and change the hooks. +*/ +#define Protect(exp) (savestate(L,ci), (exp), updatetrap(ci)) + +/* special version that does not change the top */ +#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci)) + +/* +** Protect code that can only raise errors. (That is, it cannot change +** the stack or hooks.) +*/ +#define halfProtect(exp) (savestate(L,ci), (exp)) +/* 'c' is the limit of live values in the stack */ #define checkGC(L,c) \ - { luaC_condGC(L, L->top = (c), /* limit of live values */ \ - Protect(L->top = ci->top)); /* restore top */ \ + { luaC_condGC(L, (savepc(L), L->top.p = (c)), \ + updatetrap(ci)); \ luai_threadyield(L); } /* fetch an instruction and prepare its execution */ #define vmfetch() { \ - i = *(ci->u.l.savedpc++); \ - if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) \ - Protect(luaG_traceexec(L)); \ - ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \ - lua_assert(base == ci->u.l.base); \ - lua_assert(base <= L->top && L->top < L->stack + L->stacksize); \ + if (l_unlikely(trap)) { /* stack reallocation or hooks? */ \ + trap = luaG_traceexec(L, pc); /* handle hooks */ \ + updatebase(ci); /* correct stack */ \ + } \ + i = *(pc++); \ } #define vmdispatch(o) switch(o) @@ -767,314 +1148,452 @@ void luaV_finishOp (lua_State *L) { #define vmbreak break -/* -** copy of 'luaV_gettable', but protecting the call to potential -** metamethod (which can reallocate the stack) -*/ -#define gettableProtected(L,t,k,v) { const TValue *slot; \ - if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ - else Protect(luaV_finishget(L,t,k,v,slot)); } - - -/* same for 'luaV_settable' */ -#define settableProtected(L,t,k,v) { const TValue *slot; \ - if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ - Protect(luaV_finishset(L,t,k,v,slot)); } - - - -void luaV_execute (lua_State *L) { - CallInfo *ci = L->ci; +void luaV_execute (lua_State *L, CallInfo *ci) { LClosure *cl; TValue *k; StkId base; - ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */ - newframe: /* reentry point when frame changes (call/return) */ - lua_assert(ci == L->ci); - cl = clLvalue(ci->func); /* local reference to function's closure */ - k = cl->p->k; /* local reference to function's constant table */ - base = ci->u.l.base; /* local copy of function's base */ + const Instruction *pc; + int trap; +#if LUA_USE_JUMPTABLE +#include "ljumptab.h" +#endif + startfunc: + trap = L->hookmask; + returning: /* trap already set */ + cl = ci_func(ci); + k = cl->p->k; + pc = ci->u.l.savedpc; + if (l_unlikely(trap)) + trap = luaG_tracecall(L); + base = ci->func.p + 1; /* main loop of interpreter */ for (;;) { - Instruction i; - StkId ra; + Instruction i; /* instruction being executed */ vmfetch(); + #if 0 + /* low-level line tracing for debugging Lua */ + printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); + #endif + lua_assert(base == ci->func.p + 1); + lua_assert(base <= L->top.p && L->top.p <= L->stack_last.p); + /* invalidate top for instructions not expecting it */ + lua_assert(isIT(i) || (cast_void(L->top.p = base), 1)); vmdispatch (GET_OPCODE(i)) { vmcase(OP_MOVE) { + StkId ra = RA(i); setobjs2s(L, ra, RB(i)); vmbreak; } + vmcase(OP_LOADI) { + StkId ra = RA(i); + lua_Integer b = GETARG_sBx(i); + setivalue(s2v(ra), b); + vmbreak; + } + vmcase(OP_LOADF) { + StkId ra = RA(i); + int b = GETARG_sBx(i); + setfltvalue(s2v(ra), cast_num(b)); + vmbreak; + } vmcase(OP_LOADK) { + StkId ra = RA(i); TValue *rb = k + GETARG_Bx(i); setobj2s(L, ra, rb); vmbreak; } vmcase(OP_LOADKX) { + StkId ra = RA(i); TValue *rb; - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); - rb = k + GETARG_Ax(*ci->u.l.savedpc++); + rb = k + GETARG_Ax(*pc); pc++; setobj2s(L, ra, rb); vmbreak; } - vmcase(OP_LOADBOOL) { - setbvalue(ra, GETARG_B(i)); - if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ + vmcase(OP_LOADFALSE) { + StkId ra = RA(i); + setbfvalue(s2v(ra)); + vmbreak; + } + vmcase(OP_LFALSESKIP) { + StkId ra = RA(i); + setbfvalue(s2v(ra)); + pc++; /* skip next instruction */ + vmbreak; + } + vmcase(OP_LOADTRUE) { + StkId ra = RA(i); + setbtvalue(s2v(ra)); vmbreak; } vmcase(OP_LOADNIL) { + StkId ra = RA(i); int b = GETARG_B(i); do { - setnilvalue(ra++); + setnilvalue(s2v(ra++)); } while (b--); vmbreak; } vmcase(OP_GETUPVAL) { + StkId ra = RA(i); int b = GETARG_B(i); - setobj2s(L, ra, cl->upvals[b]->v); + setobj2s(L, ra, cl->upvals[b]->v.p); + vmbreak; + } + vmcase(OP_SETUPVAL) { + StkId ra = RA(i); + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v.p, s2v(ra)); + luaC_barrier(L, uv, s2v(ra)); vmbreak; } vmcase(OP_GETTABUP) { - TValue *upval = cl->upvals[GETARG_B(i)]->v; - TValue *rc = RKC(i); - gettableProtected(L, upval, rc, ra); + StkId ra = RA(i); + const TValue *slot; + TValue *upval = cl->upvals[GETARG_B(i)]->v.p; + TValue *rc = KC(i); + TString *key = tsvalue(rc); /* key must be a short string */ + if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { + setobj2s(L, ra, slot); + } + else + Protect(luaV_finishget(L, upval, rc, ra, slot)); vmbreak; } vmcase(OP_GETTABLE) { - StkId rb = RB(i); - TValue *rc = RKC(i); - gettableProtected(L, rb, rc, ra); + StkId ra = RA(i); + const TValue *slot; + TValue *rb = vRB(i); + TValue *rc = vRC(i); + lua_Unsigned n; + if (ttisinteger(rc) /* fast track for integers? */ + ? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot)) + : luaV_fastget(L, rb, rc, slot, luaH_get)) { + setobj2s(L, ra, slot); + } + else + Protect(luaV_finishget(L, rb, rc, ra, slot)); + vmbreak; + } + vmcase(OP_GETI) { + StkId ra = RA(i); + const TValue *slot; + TValue *rb = vRB(i); + int c = GETARG_C(i); + if (luaV_fastgeti(L, rb, c, slot)) { + setobj2s(L, ra, slot); + } + else { + TValue key; + setivalue(&key, c); + Protect(luaV_finishget(L, rb, &key, ra, slot)); + } + vmbreak; + } + vmcase(OP_GETFIELD) { + StkId ra = RA(i); + const TValue *slot; + TValue *rb = vRB(i); + TValue *rc = KC(i); + TString *key = tsvalue(rc); /* key must be a short string */ + if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) { + setobj2s(L, ra, slot); + } + else + Protect(luaV_finishget(L, rb, rc, ra, slot)); vmbreak; } vmcase(OP_SETTABUP) { - TValue *upval = cl->upvals[GETARG_A(i)]->v; - TValue *rb = RKB(i); + const TValue *slot; + TValue *upval = cl->upvals[GETARG_A(i)]->v.p; + TValue *rb = KB(i); TValue *rc = RKC(i); - settableProtected(L, upval, rb, rc); + TString *key = tsvalue(rb); /* key must be a short string */ + if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { + luaV_finishfastset(L, upval, slot, rc); + } + else + Protect(luaV_finishset(L, upval, rb, rc, slot)); vmbreak; } - vmcase(OP_SETUPVAL) { - UpVal *uv = cl->upvals[GETARG_B(i)]; - setobj(L, uv->v, ra); - luaC_upvalbarrier(L, uv); + vmcase(OP_SETTABLE) { + StkId ra = RA(i); + const TValue *slot; + TValue *rb = vRB(i); /* key (table is in 'ra') */ + TValue *rc = RKC(i); /* value */ + lua_Unsigned n; + if (ttisinteger(rb) /* fast track for integers? */ + ? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot)) + : luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) { + luaV_finishfastset(L, s2v(ra), slot, rc); + } + else + Protect(luaV_finishset(L, s2v(ra), rb, rc, slot)); vmbreak; } - vmcase(OP_SETTABLE) { - TValue *rb = RKB(i); + vmcase(OP_SETI) { + StkId ra = RA(i); + const TValue *slot; + int c = GETARG_B(i); TValue *rc = RKC(i); - settableProtected(L, ra, rb, rc); + if (luaV_fastgeti(L, s2v(ra), c, slot)) { + luaV_finishfastset(L, s2v(ra), slot, rc); + } + else { + TValue key; + setivalue(&key, c); + Protect(luaV_finishset(L, s2v(ra), &key, rc, slot)); + } + vmbreak; + } + vmcase(OP_SETFIELD) { + StkId ra = RA(i); + const TValue *slot; + TValue *rb = KB(i); + TValue *rc = RKC(i); + TString *key = tsvalue(rb); /* key must be a short string */ + if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) { + luaV_finishfastset(L, s2v(ra), slot, rc); + } + else + Protect(luaV_finishset(L, s2v(ra), rb, rc, slot)); vmbreak; } vmcase(OP_NEWTABLE) { - int b = GETARG_B(i); - int c = GETARG_C(i); - Table *t = luaH_new(L); - sethvalue(L, ra, t); + StkId ra = RA(i); + int b = GETARG_B(i); /* log2(hash size) + 1 */ + int c = GETARG_C(i); /* array size */ + Table *t; + if (b > 0) + b = 1 << (b - 1); /* size is 2^(b - 1) */ + lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0)); + if (TESTARG_k(i)) /* non-zero extra argument? */ + c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */ + pc++; /* skip extra argument */ + L->top.p = ra + 1; /* correct top in case of emergency GC */ + t = luaH_new(L); /* memory allocation */ + sethvalue2s(L, ra, t); if (b != 0 || c != 0) - luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); + luaH_resize(L, t, c, b); /* idem */ checkGC(L, ra + 1); vmbreak; } vmcase(OP_SELF) { - const TValue *aux; - StkId rb = RB(i); + StkId ra = RA(i); + const TValue *slot; + TValue *rb = vRB(i); TValue *rc = RKC(i); TString *key = tsvalue(rc); /* key must be a string */ - setobjs2s(L, ra + 1, rb); - if (luaV_fastget(L, rb, key, aux, luaH_getstr)) { - setobj2s(L, ra, aux); + setobj2s(L, ra + 1, rb); + if (luaV_fastget(L, rb, key, slot, luaH_getstr)) { + setobj2s(L, ra, slot); } - else Protect(luaV_finishget(L, rb, rc, ra, aux)); + else + Protect(luaV_finishget(L, rb, rc, ra, slot)); vmbreak; } - vmcase(OP_ADD) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, intop(+, ib, ic)); + vmcase(OP_ADDI) { + op_arithI(L, l_addi, luai_numadd); + vmbreak; + } + vmcase(OP_ADDK) { + op_arithK(L, l_addi, luai_numadd); + vmbreak; + } + vmcase(OP_SUBK) { + op_arithK(L, l_subi, luai_numsub); + vmbreak; + } + vmcase(OP_MULK) { + op_arithK(L, l_muli, luai_nummul); + vmbreak; + } + vmcase(OP_MODK) { + savestate(L, ci); /* in case of division by 0 */ + op_arithK(L, luaV_mod, luaV_modf); + vmbreak; + } + vmcase(OP_POWK) { + op_arithfK(L, luai_numpow); + vmbreak; + } + vmcase(OP_DIVK) { + op_arithfK(L, luai_numdiv); + vmbreak; + } + vmcase(OP_IDIVK) { + savestate(L, ci); /* in case of division by 0 */ + op_arithK(L, luaV_idiv, luai_numidiv); + vmbreak; + } + vmcase(OP_BANDK) { + op_bitwiseK(L, l_band); + vmbreak; + } + vmcase(OP_BORK) { + op_bitwiseK(L, l_bor); + vmbreak; + } + vmcase(OP_BXORK) { + op_bitwiseK(L, l_bxor); + vmbreak; + } + vmcase(OP_SHRI) { + StkId ra = RA(i); + TValue *rb = vRB(i); + int ic = GETARG_sC(i); + lua_Integer ib; + if (tointegerns(rb, &ib)) { + pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic)); } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numadd(L, nb, nc)); + vmbreak; + } + vmcase(OP_SHLI) { + StkId ra = RA(i); + TValue *rb = vRB(i); + int ic = GETARG_sC(i); + lua_Integer ib; + if (tointegerns(rb, &ib)) { + pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib)); } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } + vmbreak; + } + vmcase(OP_ADD) { + op_arith(L, l_addi, luai_numadd); vmbreak; } vmcase(OP_SUB) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, intop(-, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numsub(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } + op_arith(L, l_subi, luai_numsub); vmbreak; } vmcase(OP_MUL) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, intop(*, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_nummul(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } + op_arith(L, l_muli, luai_nummul); + vmbreak; + } + vmcase(OP_MOD) { + savestate(L, ci); /* in case of division by 0 */ + op_arith(L, luaV_mod, luaV_modf); + vmbreak; + } + vmcase(OP_POW) { + op_arithf(L, luai_numpow); vmbreak; } vmcase(OP_DIV) { /* float division (always with floats) */ - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numdiv(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } + op_arithf(L, luai_numdiv); + vmbreak; + } + vmcase(OP_IDIV) { /* floor division */ + savestate(L, ci); /* in case of division by 0 */ + op_arith(L, luaV_idiv, luai_numidiv); vmbreak; } vmcase(OP_BAND) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, intop(&, ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); } + op_bitwise(L, l_band); vmbreak; } vmcase(OP_BOR) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, intop(|, ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); } + op_bitwise(L, l_bor); vmbreak; } vmcase(OP_BXOR) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, intop(^, ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); } + op_bitwise(L, l_bxor); vmbreak; } - vmcase(OP_SHL) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, luaV_shiftl(ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); } + vmcase(OP_SHR) { + op_bitwise(L, luaV_shiftr); vmbreak; } - vmcase(OP_SHR) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, luaV_shiftl(ib, -ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); } + vmcase(OP_SHL) { + op_bitwise(L, luaV_shiftl); vmbreak; } - vmcase(OP_MOD) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, luaV_mod(L, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - lua_Number m; - luai_nummod(L, nb, nc, m); - setfltvalue(ra, m); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } + vmcase(OP_MMBIN) { + StkId ra = RA(i); + Instruction pi = *(pc - 2); /* original arith. expression */ + TValue *rb = vRB(i); + TMS tm = (TMS)GETARG_C(i); + StkId result = RA(pi); + lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR); + Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm)); vmbreak; } - vmcase(OP_IDIV) { /* floor division */ - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, luaV_div(L, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numidiv(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); } + vmcase(OP_MMBINI) { + StkId ra = RA(i); + Instruction pi = *(pc - 2); /* original arith. expression */ + int imm = GETARG_sB(i); + TMS tm = (TMS)GETARG_C(i); + int flip = GETARG_k(i); + StkId result = RA(pi); + Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm)); vmbreak; } - vmcase(OP_POW) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numpow(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } + vmcase(OP_MMBINK) { + StkId ra = RA(i); + Instruction pi = *(pc - 2); /* original arith. expression */ + TValue *imm = KB(i); + TMS tm = (TMS)GETARG_C(i); + int flip = GETARG_k(i); + StkId result = RA(pi); + Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm)); vmbreak; } vmcase(OP_UNM) { - TValue *rb = RB(i); + StkId ra = RA(i); + TValue *rb = vRB(i); lua_Number nb; if (ttisinteger(rb)) { lua_Integer ib = ivalue(rb); - setivalue(ra, intop(-, 0, ib)); + setivalue(s2v(ra), intop(-, 0, ib)); } - else if (tonumber(rb, &nb)) { - setfltvalue(ra, luai_numunm(L, nb)); + else if (tonumberns(rb, nb)) { + setfltvalue(s2v(ra), luai_numunm(L, nb)); } - else { + else Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); - } vmbreak; } vmcase(OP_BNOT) { - TValue *rb = RB(i); + StkId ra = RA(i); + TValue *rb = vRB(i); lua_Integer ib; - if (tointeger(rb, &ib)) { - setivalue(ra, intop(^, ~l_castS2U(0), ib)); + if (tointegerns(rb, &ib)) { + setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib)); } - else { + else Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); - } vmbreak; } vmcase(OP_NOT) { - TValue *rb = RB(i); - int res = l_isfalse(rb); /* next assignment may change this value */ - setbvalue(ra, res); + StkId ra = RA(i); + TValue *rb = vRB(i); + if (l_isfalse(rb)) + setbtvalue(s2v(ra)); + else + setbfvalue(s2v(ra)); vmbreak; } vmcase(OP_LEN) { - Protect(luaV_objlen(L, ra, RB(i))); + StkId ra = RA(i); + Protect(luaV_objlen(L, ra, vRB(i))); vmbreak; } vmcase(OP_CONCAT) { - int b = GETARG_B(i); - int c = GETARG_C(i); - StkId rb; - L->top = base + c + 1; /* mark the end of concat operands */ - Protect(luaV_concat(L, c - b + 1)); - ra = RA(i); /* 'luaV_concat' may invoke TMs and move the stack */ - rb = base + b; - setobjs2s(L, ra, rb); - checkGC(L, (ra >= rb ? ra + 1 : rb)); - L->top = ci->top; /* restore top */ + StkId ra = RA(i); + int n = GETARG_B(i); /* number of elements to concatenate */ + L->top.p = ra + n; /* mark the end of concat operands */ + ProtectNT(luaV_concat(L, n)); + checkGC(L, L->top.p); /* 'luaV_concat' ensures correct top */ + vmbreak; + } + vmcase(OP_CLOSE) { + StkId ra = RA(i); + Protect(luaF_close(L, ra, LUA_OK, 1)); + vmbreak; + } + vmcase(OP_TBC) { + StkId ra = RA(i); + /* create new to-be-closed upvalue */ + halfProtect(luaF_newtbcupval(L, ra)); vmbreak; } vmcase(OP_JMP) { @@ -1082,232 +1601,291 @@ void luaV_execute (lua_State *L) { vmbreak; } vmcase(OP_EQ) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - Protect( - if (luaV_equalobj(L, rb, rc) != GETARG_A(i)) - ci->u.l.savedpc++; - else - donextjump(ci); - ) + StkId ra = RA(i); + int cond; + TValue *rb = vRB(i); + Protect(cond = luaV_equalobj(L, s2v(ra), rb)); + docondjump(); vmbreak; } vmcase(OP_LT) { - Protect( - if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) - ci->u.l.savedpc++; - else - donextjump(ci); - ) + op_order(L, l_lti, LTnum, lessthanothers); vmbreak; } vmcase(OP_LE) { - Protect( - if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) - ci->u.l.savedpc++; - else - donextjump(ci); - ) + op_order(L, l_lei, LEnum, lessequalothers); + vmbreak; + } + vmcase(OP_EQK) { + StkId ra = RA(i); + TValue *rb = KB(i); + /* basic types do not use '__eq'; we can use raw equality */ + int cond = luaV_rawequalobj(s2v(ra), rb); + docondjump(); + vmbreak; + } + vmcase(OP_EQI) { + StkId ra = RA(i); + int cond; + int im = GETARG_sB(i); + if (ttisinteger(s2v(ra))) + cond = (ivalue(s2v(ra)) == im); + else if (ttisfloat(s2v(ra))) + cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im)); + else + cond = 0; /* other types cannot be equal to a number */ + docondjump(); + vmbreak; + } + vmcase(OP_LTI) { + op_orderI(L, l_lti, luai_numlt, 0, TM_LT); + vmbreak; + } + vmcase(OP_LEI) { + op_orderI(L, l_lei, luai_numle, 0, TM_LE); + vmbreak; + } + vmcase(OP_GTI) { + op_orderI(L, l_gti, luai_numgt, 1, TM_LT); + vmbreak; + } + vmcase(OP_GEI) { + op_orderI(L, l_gei, luai_numge, 1, TM_LE); vmbreak; } vmcase(OP_TEST) { - if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) - ci->u.l.savedpc++; - else - donextjump(ci); + StkId ra = RA(i); + int cond = !l_isfalse(s2v(ra)); + docondjump(); vmbreak; } vmcase(OP_TESTSET) { - TValue *rb = RB(i); - if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) - ci->u.l.savedpc++; + StkId ra = RA(i); + TValue *rb = vRB(i); + if (l_isfalse(rb) == GETARG_k(i)) + pc++; else { - setobjs2s(L, ra, rb); + setobj2s(L, ra, rb); donextjump(ci); } vmbreak; } vmcase(OP_CALL) { + StkId ra = RA(i); + CallInfo *newci; int b = GETARG_B(i); int nresults = GETARG_C(i) - 1; - if (b != 0) L->top = ra+b; /* else previous instruction set top */ - if (luaD_precall(L, ra, nresults)) { /* C function? */ - if (nresults >= 0) - L->top = ci->top; /* adjust results */ - Protect((void)0); /* update 'base' */ - } - else { /* Lua function */ - ci = L->ci; - goto newframe; /* restart luaV_execute over new Lua function */ + if (b != 0) /* fixed number of arguments? */ + L->top.p = ra + b; /* top signals number of arguments */ + /* else previous instruction set top */ + savepc(L); /* in case of errors */ + if ((newci = luaD_precall(L, ra, nresults)) == NULL) + updatetrap(ci); /* C call; nothing else to be done */ + else { /* Lua call: run function in this same C frame */ + ci = newci; + goto startfunc; } vmbreak; } vmcase(OP_TAILCALL) { - int b = GETARG_B(i); - if (b != 0) L->top = ra+b; /* else previous instruction set top */ - lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); - if (luaD_precall(L, ra, LUA_MULTRET)) { /* C function? */ - Protect((void)0); /* update 'base' */ + StkId ra = RA(i); + int b = GETARG_B(i); /* number of arguments + 1 (function) */ + int n; /* number of results when calling a C function */ + int nparams1 = GETARG_C(i); + /* delta is virtual 'func' - real 'func' (vararg functions) */ + int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; + if (b != 0) + L->top.p = ra + b; + else /* previous instruction set top */ + b = cast_int(L->top.p - ra); + savepc(ci); /* several calls here can raise errors */ + if (TESTARG_k(i)) { + luaF_closeupval(L, base); /* close upvalues from current call */ + lua_assert(L->tbclist.p < base); /* no pending tbc variables */ + lua_assert(base == ci->func.p + 1); } - else { - /* tail call: put called frame (n) in place of caller one (o) */ - CallInfo *nci = L->ci; /* called frame */ - CallInfo *oci = nci->previous; /* caller frame */ - StkId nfunc = nci->func; /* called function */ - StkId ofunc = oci->func; /* caller function */ - /* last stack slot filled by 'precall' */ - StkId lim = nci->u.l.base + getproto(nfunc)->numparams; - int aux; - /* close all upvalues from previous call */ - if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); - /* move new frame into old one */ - for (aux = 0; nfunc + aux < lim; aux++) - setobjs2s(L, ofunc + aux, nfunc + aux); - oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */ - oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ - oci->u.l.savedpc = nci->u.l.savedpc; - oci->callstatus |= CIST_TAIL; /* function was tail called */ - ci = L->ci = oci; /* remove new frame */ - lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); - goto newframe; /* restart luaV_execute over new Lua function */ + if ((n = luaD_pretailcall(L, ci, ra, b, delta)) < 0) /* Lua function? */ + goto startfunc; /* execute the callee */ + else { /* C function? */ + ci->func.p -= delta; /* restore 'func' (if vararg) */ + luaD_poscall(L, ci, n); /* finish caller */ + updatetrap(ci); /* 'luaD_poscall' can change hooks */ + goto ret; /* caller returns after the tail call */ } - vmbreak; } vmcase(OP_RETURN) { - int b = GETARG_B(i); - if (cl->p->sizep > 0) luaF_close(L, base); - b = luaD_poscall(L, ci, ra, (b != 0 ? b - 1 : cast_int(L->top - ra))); - if (ci->callstatus & CIST_FRESH) /* local 'ci' still from callee */ - return; /* external invocation: return */ - else { /* invocation via reentry: continue execution */ - ci = L->ci; - if (b) L->top = ci->top; - lua_assert(isLua(ci)); - lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); - goto newframe; /* restart luaV_execute over new Lua function */ + StkId ra = RA(i); + int n = GETARG_B(i) - 1; /* number of results */ + int nparams1 = GETARG_C(i); + if (n < 0) /* not fixed? */ + n = cast_int(L->top.p - ra); /* get what is available */ + savepc(ci); + if (TESTARG_k(i)) { /* may there be open upvalues? */ + ci->u2.nres = n; /* save number of returns */ + if (L->top.p < ci->top.p) + L->top.p = ci->top.p; + luaF_close(L, base, CLOSEKTOP, 1); + updatetrap(ci); + updatestack(ci); } + if (nparams1) /* vararg function? */ + ci->func.p -= ci->u.l.nextraargs + nparams1; + L->top.p = ra + n; /* set call for 'luaD_poscall' */ + luaD_poscall(L, ci, n); + updatetrap(ci); /* 'luaD_poscall' can change hooks */ + goto ret; } - vmcase(OP_FORLOOP) { - if (ttisinteger(ra)) { /* integer loop? */ - lua_Integer step = ivalue(ra + 2); - lua_Integer idx = intop(+, ivalue(ra), step); /* increment index */ - lua_Integer limit = ivalue(ra + 1); - if ((0 < step) ? (idx <= limit) : (limit <= idx)) { - ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ - chgivalue(ra, idx); /* update internal index... */ - setivalue(ra + 3, idx); /* ...and external index */ + vmcase(OP_RETURN0) { + if (l_unlikely(L->hookmask)) { + StkId ra = RA(i); + L->top.p = ra; + savepc(ci); + luaD_poscall(L, ci, 0); /* no hurry... */ + trap = 1; + } + else { /* do the 'poscall' here */ + int nres; + L->ci = ci->previous; /* back to caller */ + L->top.p = base - 1; + for (nres = ci->nresults; l_unlikely(nres > 0); nres--) + setnilvalue(s2v(L->top.p++)); /* all results are nil */ + } + goto ret; + } + vmcase(OP_RETURN1) { + if (l_unlikely(L->hookmask)) { + StkId ra = RA(i); + L->top.p = ra + 1; + savepc(ci); + luaD_poscall(L, ci, 1); /* no hurry... */ + trap = 1; + } + else { /* do the 'poscall' here */ + int nres = ci->nresults; + L->ci = ci->previous; /* back to caller */ + if (nres == 0) + L->top.p = base - 1; /* asked for no results */ + else { + StkId ra = RA(i); + setobjs2s(L, base - 1, ra); /* at least this result */ + L->top.p = base; + for (; l_unlikely(nres > 1); nres--) + setnilvalue(s2v(L->top.p++)); /* complete missing results */ } } - else { /* floating loop */ - lua_Number step = fltvalue(ra + 2); - lua_Number idx = luai_numadd(L, fltvalue(ra), step); /* inc. index */ - lua_Number limit = fltvalue(ra + 1); - if (luai_numlt(0, step) ? luai_numle(idx, limit) - : luai_numle(limit, idx)) { - ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ - chgfltvalue(ra, idx); /* update internal index... */ - setfltvalue(ra + 3, idx); /* ...and external index */ + ret: /* return from a Lua function */ + if (ci->callstatus & CIST_FRESH) + return; /* end this frame */ + else { + ci = ci->previous; + goto returning; /* continue running caller in this frame */ + } + } + vmcase(OP_FORLOOP) { + StkId ra = RA(i); + if (ttisinteger(s2v(ra + 2))) { /* integer loop? */ + lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1))); + if (count > 0) { /* still more iterations? */ + lua_Integer step = ivalue(s2v(ra + 2)); + lua_Integer idx = ivalue(s2v(ra)); /* internal index */ + chgivalue(s2v(ra + 1), count - 1); /* update counter */ + idx = intop(+, idx, step); /* add step to index */ + chgivalue(s2v(ra), idx); /* update internal index */ + setivalue(s2v(ra + 3), idx); /* and control variable */ + pc -= GETARG_Bx(i); /* jump back */ } } + else if (floatforloop(ra)) /* float loop */ + pc -= GETARG_Bx(i); /* jump back */ + updatetrap(ci); /* allows a signal to break the loop */ vmbreak; } vmcase(OP_FORPREP) { - TValue *init = ra; - TValue *plimit = ra + 1; - TValue *pstep = ra + 2; - lua_Integer ilimit; - int stopnow; - if (ttisinteger(init) && ttisinteger(pstep) && - forlimit(plimit, &ilimit, ivalue(pstep), &stopnow)) { - /* all values are integer */ - lua_Integer initv = (stopnow ? 0 : ivalue(init)); - setivalue(plimit, ilimit); - setivalue(init, intop(-, initv, ivalue(pstep))); - } - else { /* try making all values floats */ - lua_Number ninit; lua_Number nlimit; lua_Number nstep; - if (!tonumber(plimit, &nlimit)) - luaG_runerror(L, "'for' limit must be a number"); - setfltvalue(plimit, nlimit); - if (!tonumber(pstep, &nstep)) - luaG_runerror(L, "'for' step must be a number"); - setfltvalue(pstep, nstep); - if (!tonumber(init, &ninit)) - luaG_runerror(L, "'for' initial value must be a number"); - setfltvalue(init, luai_numsub(L, ninit, nstep)); - } - ci->u.l.savedpc += GETARG_sBx(i); + StkId ra = RA(i); + savestate(L, ci); /* in case of errors */ + if (forprep(L, ra)) + pc += GETARG_Bx(i) + 1; /* skip the loop */ vmbreak; } + vmcase(OP_TFORPREP) { + StkId ra = RA(i); + /* create to-be-closed upvalue (if needed) */ + halfProtect(luaF_newtbcupval(L, ra + 3)); + pc += GETARG_Bx(i); + i = *(pc++); /* go to next instruction */ + lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i)); + goto l_tforcall; + } vmcase(OP_TFORCALL) { - StkId cb = ra + 3; /* call base */ - setobjs2s(L, cb+2, ra+2); - setobjs2s(L, cb+1, ra+1); - setobjs2s(L, cb, ra); - L->top = cb + 3; /* func. + 2 args (state and index) */ - Protect(luaD_call(L, cb, GETARG_C(i))); - L->top = ci->top; - i = *(ci->u.l.savedpc++); /* go to next instruction */ - ra = RA(i); - lua_assert(GET_OPCODE(i) == OP_TFORLOOP); + l_tforcall: { + StkId ra = RA(i); + /* 'ra' has the iterator function, 'ra + 1' has the state, + 'ra + 2' has the control variable, and 'ra + 3' has the + to-be-closed variable. The call will use the stack after + these values (starting at 'ra + 4') + */ + /* push function, state, and control variable */ + memcpy(ra + 4, ra, 3 * sizeof(*ra)); + L->top.p = ra + 4 + 3; + ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */ + updatestack(ci); /* stack may have changed */ + i = *(pc++); /* go to next instruction */ + lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i)); goto l_tforloop; - } + }} vmcase(OP_TFORLOOP) { - l_tforloop: - if (!ttisnil(ra + 1)) { /* continue loop? */ - setobjs2s(L, ra, ra + 1); /* save control variable */ - ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ + l_tforloop: { + StkId ra = RA(i); + if (!ttisnil(s2v(ra + 4))) { /* continue loop? */ + setobjs2s(L, ra + 2, ra + 4); /* save control variable */ + pc -= GETARG_Bx(i); /* jump back */ } vmbreak; - } + }} vmcase(OP_SETLIST) { + StkId ra = RA(i); int n = GETARG_B(i); - int c = GETARG_C(i); - unsigned int last; - Table *h; - if (n == 0) n = cast_int(L->top - ra) - 1; - if (c == 0) { - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); - c = GETARG_Ax(*ci->u.l.savedpc++); + unsigned int last = GETARG_C(i); + Table *h = hvalue(s2v(ra)); + if (n == 0) + n = cast_int(L->top.p - ra) - 1; /* get up to the top */ + else + L->top.p = ci->top.p; /* correct top in case of emergency GC */ + last += n; + if (TESTARG_k(i)) { + last += GETARG_Ax(*pc) * (MAXARG_C + 1); + pc++; } - h = hvalue(ra); - last = ((c-1)*LFIELDS_PER_FLUSH) + n; - if (last > h->sizearray) /* needs more space? */ + if (last > luaH_realasize(h)) /* needs more space? */ luaH_resizearray(L, h, last); /* preallocate it at once */ for (; n > 0; n--) { - TValue *val = ra+n; - luaH_setint(L, h, last--, val); - luaC_barrierback(L, h, val); + TValue *val = s2v(ra + n); + setobj2t(L, &h->array[last - 1], val); + last--; + luaC_barrierback(L, obj2gco(h), val); } - L->top = ci->top; /* correct top (in case of previous open call) */ vmbreak; } vmcase(OP_CLOSURE) { + StkId ra = RA(i); Proto *p = cl->p->p[GETARG_Bx(i)]; - LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ - if (ncl == NULL) /* no match? */ - pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ - else - setclLvalue(L, ra, ncl); /* push cashed closure */ + halfProtect(pushclosure(L, p, cl->upvals, base, ra)); checkGC(L, ra + 1); vmbreak; } vmcase(OP_VARARG) { - int b = GETARG_B(i) - 1; /* required results */ - int j; - int n = cast_int(base - ci->func) - cl->p->numparams - 1; - if (n < 0) /* less arguments than parameters? */ - n = 0; /* no vararg arguments */ - if (b < 0) { /* B == 0? */ - b = n; /* get all var. arguments */ - Protect(luaD_checkstack(L, n)); - ra = RA(i); /* previous call may change the stack */ - L->top = ra + n; + StkId ra = RA(i); + int n = GETARG_C(i) - 1; /* required results */ + Protect(luaT_getvarargs(L, ci, ra, n)); + vmbreak; + } + vmcase(OP_VARARGPREP) { + ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p)); + if (l_unlikely(trap)) { /* previous "Protect" updated trap */ + luaD_hookcall(L, ci); + L->oldpc = 1; /* next opcode will be seen as a "new" line */ } - for (j = 0; j < b && j < n; j++) - setobjs2s(L, ra + j, base - n + j); - for (; j < b; j++) /* complete required results with nil */ - setnilvalue(ra + j); + updatebase(ci); /* function has new base after adjustment */ vmbreak; } vmcase(OP_EXTRAARG) { @@ -1319,4 +1897,3 @@ void luaV_execute (lua_State *L) { } /* }================================================================== */ - diff --git a/liblua/lvm.h b/liblua/lvm.h index a8f954f0..dba1ad27 100644 --- a/liblua/lvm.h +++ b/liblua/lvm.h @@ -1,5 +1,5 @@ /* -** $Id: lvm.h,v 2.41.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lvm.h $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -33,15 +33,42 @@ ** integral values) */ #if !defined(LUA_FLOORN2I) -#define LUA_FLOORN2I 0 +#define LUA_FLOORN2I F2Ieq #endif +/* +** Rounding modes for float->integer coercion + */ +typedef enum { + F2Ieq, /* no rounding; accepts only integral values */ + F2Ifloor, /* takes the floor of the number */ + F2Iceil /* takes the ceil of the number */ +} F2Imod; + + +/* convert an object to a float (including string coercion) */ #define tonumber(o,n) \ (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) + +/* convert an object to a float (without string coercion) */ +#define tonumberns(o,n) \ + (ttisfloat(o) ? ((n) = fltvalue(o), 1) : \ + (ttisinteger(o) ? ((n) = cast_num(ivalue(o)), 1) : 0)) + + +/* convert an object to an integer (including string coercion) */ #define tointeger(o,i) \ - (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) + (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \ + : luaV_tointeger(o,i,LUA_FLOORN2I)) + + +/* convert an object to an integer (without string coercion) */ +#define tointegerns(o,i) \ + (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \ + : luaV_tointegerns(o,i,LUA_FLOORN2I)) + #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) @@ -49,47 +76,44 @@ /* -** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, -** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, -** return 0 (meaning it will have to check metamethod) with 'slot' -** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). -** 'f' is the raw get function to use. +** fast track for 'gettable': if 't' is a table and 't[k]' is present, +** return 1 with 'slot' pointing to 't[k]' (position of final result). +** Otherwise, return 0 (meaning it will have to check metamethod) +** with 'slot' pointing to an empty 't[k]' (if 't' is a table) or NULL +** (otherwise). 'f' is the raw get function to use. */ #define luaV_fastget(L,t,k,slot,f) \ (!ttistable(t) \ ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ : (slot = f(hvalue(t), k), /* else, do raw access */ \ - !ttisnil(slot))) /* result not nil? */ + !isempty(slot))) /* result not empty? */ + /* -** standard implementation for 'gettable' +** Special case of 'luaV_fastget' for integers, inlining the fast case +** of 'luaH_getint'. */ -#define luaV_gettable(L,t,k,v) { const TValue *slot; \ - if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ - else luaV_finishget(L,t,k,v,slot); } +#define luaV_fastgeti(L,t,k,slot) \ + (!ttistable(t) \ + ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ + : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \ + ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ + !isempty(slot))) /* result not empty? */ /* -** Fast track for set table. If 't' is a table and 't[k]' is not nil, -** call GC barrier, do a raw 't[k]=v', and return true; otherwise, -** return false with 'slot' equal to NULL (if 't' is not a table) or -** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro -** returns true, there is no need to 'invalidateTMcache', because the -** call is not creating a new entry. +** Finish a fast set operation (when fast get succeeds). In that case, +** 'slot' points to the place to put the value. */ -#define luaV_fastset(L,t,k,slot,f,v) \ - (!ttistable(t) \ - ? (slot = NULL, 0) \ - : (slot = f(hvalue(t), k), \ - ttisnil(slot) ? 0 \ - : (luaC_barrierback(L, hvalue(t), v), \ - setobj2t(L, cast(TValue *,slot), v), \ - 1))) +#define luaV_finishfastset(L,t,slot,v) \ + { setobj2t(L, cast(TValue *,slot), v); \ + luaC_barrierback(L, gcvalue(t), v); } -#define luaV_settable(L,t,k,v) { const TValue *slot; \ - if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ - luaV_finishset(L,t,k,v,slot); } +/* +** Shift right is the same as shift left with a negative 'y' +*/ +#define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y)) @@ -97,16 +121,20 @@ LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); -LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); +LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode); +LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, + F2Imod mode); +LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot); LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, - StkId val, const TValue *slot); + TValue *val, const TValue *slot); LUAI_FUNC void luaV_finishOp (lua_State *L); -LUAI_FUNC void luaV_execute (lua_State *L); +LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); LUAI_FUNC void luaV_concat (lua_State *L, int total); -LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); +LUAI_FUNC lua_Integer luaV_idiv (lua_State *L, lua_Integer x, lua_Integer y); LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); +LUAI_FUNC lua_Number luaV_modf (lua_State *L, lua_Number x, lua_Number y); LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); diff --git a/liblua/lzio.c b/liblua/lzio.c index 6f790944..cd0a02d5 100644 --- a/liblua/lzio.c +++ b/liblua/lzio.c @@ -1,5 +1,5 @@ /* -** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lzio.c $ ** Buffered streams ** See Copyright Notice in lua.h */ diff --git a/liblua/lzio.h b/liblua/lzio.h index d8978708..38f397fd 100644 --- a/liblua/lzio.h +++ b/liblua/lzio.h @@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.31.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lzio.h $ ** Buffered streams ** See Copyright Notice in lua.h */ diff --git a/libz/stdafx.c b/liblua/pch.c similarity index 100% rename from libz/stdafx.c rename to liblua/pch.c diff --git a/lua/stdafx.h b/liblua/pch.h similarity index 100% rename from lua/stdafx.h rename to liblua/pch.h diff --git a/liblua/stdafx.c b/liblua/stdafx.c deleted file mode 100644 index dc564467..00000000 --- a/liblua/stdafx.c +++ /dev/null @@ -1,2 +0,0 @@ - -/* nothing */ diff --git a/libz/adler32.c b/libz/adler32.c index d0be4380..04b81d29 100644 --- a/libz/adler32.c +++ b/libz/adler32.c @@ -7,8 +7,6 @@ #include "zutil.h" -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - #define BASE 65521U /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); #endif /* ========================================================================= */ -uLong ZEXPORT adler32_z(adler, buf, len) - uLong adler; - const Bytef *buf; - z_size_t len; -{ +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { unsigned long sum2; unsigned n; @@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len) } /* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { return adler32_z(adler, buf, len); } /* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { unsigned long sum1; unsigned long sum2; unsigned rem; @@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2) } /* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ +uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { return adler32_combine_(adler1, adler2, len2); } -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { return adler32_combine_(adler1, adler2, len2); } diff --git a/libz/compress.c b/libz/compress.c index e2db404a..f43bacf7 100644 --- a/libz/compress.c +++ b/libz/compress.c @@ -19,13 +19,8 @@ memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ +int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen, int level) { z_stream stream; int err; const uInt max = (uInt)-1; @@ -65,12 +60,8 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) /* =========================================================================== */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } @@ -78,9 +69,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen) If the default memLevel or windowBits for deflateInit() is changed, then this function needs to be updated. */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ +uLong ZEXPORT compressBound(uLong sourceLen) { return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13; } diff --git a/libz/crc32.c b/libz/crc32.c index 9580440c..6c38f5c0 100644 --- a/libz/crc32.c +++ b/libz/crc32.c @@ -1,12 +1,10 @@ /* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler + * Copyright (C) 1995-2022 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + * This interleaved implementation of a CRC makes use of pipelined multiple + * arithmetic-logic units, commonly found in modern CPU cores. It is due to + * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution. */ /* @(#) $Id$ */ @@ -14,11 +12,12 @@ /* Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). - DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. + MAKECRCH can be #defined to write out crc32.h. A main() routine is also + produced, so that this one source file can be compiled to an executable. */ #ifdef MAKECRCH @@ -28,415 +27,1023 @@ # endif /* !DYNAMIC_CRC_TABLE */ #endif /* MAKECRCH */ -#include "zutil.h" /* for STDC and FAR definitions */ +#include "zutil.h" /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */ -/* Definitions for doing the crc four data bytes at a time. */ -#if !defined(NOBYFOUR) && defined(Z_U4) -# define BYFOUR + /* + A CRC of a message is computed on N braids of words in the message, where + each word consists of W bytes (4 or 8). If N is 3, for example, then three + running sparse CRCs are calculated respectively on each braid, at these + indices in the array of words: 0, 3, 6, ..., 1, 4, 7, ..., and 2, 5, 8, ... + This is done starting at a word boundary, and continues until as many blocks + of N * W bytes as are available have been processed. The results are combined + into a single CRC at the end. For this code, N must be in the range 1..6 and + W must be 4 or 8. The upper limit on N can be increased if desired by adding + more #if blocks, extending the patterns apparent in the code. In addition, + crc32.h would need to be regenerated, if the maximum N value is increased. + + N and W are chosen empirically by benchmarking the execution time on a given + processor. The choices for N and W below were based on testing on Intel Kaby + Lake i7, AMD Ryzen 7, ARM Cortex-A57, Sparc64-VII, PowerPC POWER9, and MIPS64 + Octeon II processors. The Intel, AMD, and ARM processors were all fastest + with N=5, W=8. The Sparc, PowerPC, and MIPS64 were all fastest at N=5, W=4. + They were all tested with either gcc or clang, all using the -O3 optimization + level. Your mileage may vary. + */ + +/* Define N */ +#ifdef Z_TESTN +# define N Z_TESTN +#else +# define N 5 +#endif +#if N < 1 || N > 6 +# error N must be in 1..6 #endif -#ifdef BYFOUR - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, z_size_t)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, z_size_t)); -# define TBLS 8 + +/* + z_crc_t must be at least 32 bits. z_word_t must be at least as long as + z_crc_t. It is assumed here that z_word_t is either 32 bits or 64 bits, and + that bytes are eight bits. + */ + +/* + Define W and the associated z_word_t type. If W is not defined, then a + braided calculation is not used, and the associated tables and code are not + compiled. + */ +#ifdef Z_TESTW +# if Z_TESTW-1 != -1 +# define W Z_TESTW +# endif #else -# define TBLS 1 -#endif /* BYFOUR */ +# ifdef MAKECRCH +# define W 8 /* required for MAKECRCH */ +# else +# if defined(__x86_64__) || defined(__aarch64__) +# define W 8 +# else +# define W 4 +# endif +# endif +#endif +#ifdef W +# if W == 8 && defined(Z_U8) + typedef Z_U8 z_word_t; +# elif defined(Z_U4) +# undef W +# define W 4 + typedef Z_U4 z_word_t; +# else +# undef W +# endif +#endif -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); +/* If available, use the ARM processor CRC32 instruction. */ +#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 +# define ARMCRC32 +#endif +#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) +/* + Swap the bytes in a z_word_t to convert between little and big endian. Any + self-respecting compiler will optimize this to a single machine byte-swap + instruction, if one is available. This assumes that word_t is either 32 bits + or 64 bits. + */ +local z_word_t byte_swap(z_word_t word) { +# if W == 8 + return + (word & 0xff00000000000000) >> 56 | + (word & 0xff000000000000) >> 40 | + (word & 0xff0000000000) >> 24 | + (word & 0xff00000000) >> 8 | + (word & 0xff000000) << 8 | + (word & 0xff0000) << 24 | + (word & 0xff00) << 40 | + (word & 0xff) << 56; +# else /* W == 4 */ + return + (word & 0xff000000) >> 24 | + (word & 0xff0000) >> 8 | + (word & 0xff00) << 8 | + (word & 0xff) << 24; +# endif +} +#endif #ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Table of powers of x for combining CRC-32s, filled in by make_crc_table() + * below. + */ + local z_crc_t FAR x2n_table[32]; +#else +/* ========================================================================= + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers + * of x for combining CRC-32s, all made by make_crc_table(). + */ +# include "crc32.h" +#endif + +/* CRC polynomial. */ +#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ -local volatile int crc_table_empty = 1; -local z_crc_t FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); +/* + Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, + reflected. For speed, this requires that a not be zero. + */ +local z_crc_t multmodp(z_crc_t a, z_crc_t b) { + z_crc_t m, p; + + m = (z_crc_t)1 << 31; + p = 0; + for (;;) { + if (a & m) { + p ^= b; + if ((a & (m - 1)) == 0) + break; + } + m >>= 1; + b = b & 1 ? (b >> 1) ^ POLY : b >> 1; + } + return p; +} + +/* + Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been + initialized. + */ +local z_crc_t x2nmodp(z_off64_t n, unsigned k) { + z_crc_t p; + + p = (z_crc_t)1 << 31; /* x^0 == 1 */ + while (n) { + if (n & 1) + p = multmodp(x2n_table[k & 31], p); + n >>= 1; + k++; + } + return p; +} + +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Build the tables for byte-wise and braided CRC-32 calculations, and a table + * of powers of x for combining CRC-32s. + */ +local z_crc_t FAR crc_table[256]; +#ifdef W + local z_word_t FAR crc_big_table[256]; + local z_crc_t FAR crc_braid_table[W][256]; + local z_word_t FAR crc_braid_big_table[W][256]; + local void braid(z_crc_t [][256], z_word_t [][256], int, int); +#endif #ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *)); + local void write_table(FILE *, const z_crc_t FAR *, int); + local void write_table32hi(FILE *, const z_word_t FAR *, int); + local void write_table64(FILE *, const z_word_t FAR *, int); #endif /* MAKECRCH */ + +/* + Define a once() function depending on the availability of atomics. If this is + compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in + multiple threads, and if atomics are not available, then get_crc_table() must + be called to initialize the tables and must return before any threads are + allowed to compute or combine CRCs. + */ + +/* Definition of once functionality. */ +typedef struct once_s once_t; + +/* Check for the availability of atomics. */ +#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ + !defined(__STDC_NO_ATOMICS__) + +#include + +/* Structure for once(), which must be initialized with ONCE_INIT. */ +struct once_s { + atomic_flag begun; + atomic_int done; +}; +#define ONCE_INIT {ATOMIC_FLAG_INIT, 0} + +/* + Run the provided init() function exactly once, even if multiple threads + invoke once() at the same time. The state must be a once_t initialized with + ONCE_INIT. + */ +local void once(once_t *state, void (*init)(void)) { + if (!atomic_load(&state->done)) { + if (atomic_flag_test_and_set(&state->begun)) + while (!atomic_load(&state->done)) + ; + else { + init(); + atomic_store(&state->done, 1); + } + } +} + +#else /* no atomics */ + +/* Structure for once(), which must be initialized with ONCE_INIT. */ +struct once_s { + volatile int begun; + volatile int done; +}; +#define ONCE_INIT {0, 0} + +/* Test and set. Alas, not atomic, but tries to minimize the period of + vulnerability. */ +local int test_and_set(int volatile *flag) { + int was; + + was = *flag; + *flag = 1; + return was; +} + +/* Run the provided init() function once. This is not thread-safe. */ +local void once(once_t *state, void (*init)(void)) { + if (!state->done) { + if (test_and_set(&state->begun)) + while (!state->done) + ; + else { + init(); + state->done = 1; + } + } +} + +#endif + +/* State for once(). */ +local once_t made = ONCE_INIT; + /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials + with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the + one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + byte 0xb1 is the polynomial x^7+x^3+x^2+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b. This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each + taking the remainder. The register is initialized to zero, and for each incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - z_crc_t c; - int n, k; - z_crc_t poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0; - for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) - poly |= (z_crc_t)1 << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (z_crc_t)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x + (which is shifting right by one and adding x^32 mod p if the bit shifted out + is a one). We start with the highest power (least significant bit) of q and + repeat for all eight bits of q. -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = ZSWAP32(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = ZSWAP32(c); - } - } -#endif /* BYFOUR */ + The table is simply the CRC of all possible eight bit values. This is all the + information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. + */ - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; +local void make_crc_table(void) { + unsigned i, j, n; + z_crc_t p; + + /* initialize the CRC of bytes tables */ + for (i = 0; i < 256; i++) { + p = i; + for (j = 0; j < 8; j++) + p = p & 1 ? (p >> 1) ^ POLY : p >> 1; + crc_table[i] = p; +#ifdef W + crc_big_table[i] = byte_swap(p); +#endif } + /* initialize the x^2^n mod p(x) table */ + p = (z_crc_t)1 << 30; /* x^1 */ + x2n_table[0] = p; + for (n = 1; n < 32; n++) + x2n_table[n] = p = multmodp(p, p); + +#ifdef W + /* initialize the braiding tables -- needs x2n_table[] */ + braid(crc_braid_table, crc_braid_big_table, N, W); +#endif + #ifdef MAKECRCH - /* write out CRC tables to crc32.h */ { + /* + The crc32.h header file contains tables for both 32-bit and 64-bit + z_word_t's, and so requires a 64-bit type be available. In that case, + z_word_t must be defined to be 64-bits. This code then also generates + and writes out the tables for the case that z_word_t is 32 bits. + */ +#if !defined(W) || W != 8 +# error Need a 64-bit integer type in order to generate crc32.h. +#endif FILE *out; + int k, n; + z_crc_t ltl[8][256]; + z_word_t big[8][256]; out = fopen("crc32.h", "w"); if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const z_crc_t FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); + + /* write out little-endian CRC table to crc32.h */ + fprintf(out, + "/* crc32.h -- tables for rapid CRC calculation\n" + " * Generated automatically by crc32.c\n */\n" + "\n" + "local const z_crc_t FAR crc_table[] = {\n" + " "); + write_table(out, crc_table, 256); + fprintf(out, + "};\n"); + + /* write out big-endian CRC table for 64-bit z_word_t to crc32.h */ + fprintf(out, + "\n" + "#ifdef W\n" + "\n" + "#if W == 8\n" + "\n" + "local const z_word_t FAR crc_big_table[] = {\n" + " "); + write_table64(out, crc_big_table, 256); + fprintf(out, + "};\n"); + + /* write out big-endian CRC table for 32-bit z_word_t to crc32.h */ + fprintf(out, + "\n" + "#else /* W == 4 */\n" + "\n" + "local const z_word_t FAR crc_big_table[] = {\n" + " "); + write_table32hi(out, crc_big_table, 256); + fprintf(out, + "};\n" + "\n" + "#endif\n"); + + /* write out braid tables for each value of N */ + for (n = 1; n <= 6; n++) { + fprintf(out, + "\n" + "#if N == %d\n", n); + + /* compute braid tables for this N and 64-bit word_t */ + braid(ltl, big, n, 8); + + /* write out braid tables for 64-bit z_word_t to crc32.h */ + fprintf(out, + "\n" + "#if W == 8\n" + "\n" + "local const z_crc_t FAR crc_braid_table[][256] = {\n"); + for (k = 0; k < 8; k++) { + fprintf(out, " {"); + write_table(out, ltl[k], 256); + fprintf(out, "}%s", k < 7 ? ",\n" : ""); + } + fprintf(out, + "};\n" + "\n" + "local const z_word_t FAR crc_braid_big_table[][256] = {\n"); + for (k = 0; k < 8; k++) { + fprintf(out, " {"); + write_table64(out, big[k], 256); + fprintf(out, "}%s", k < 7 ? ",\n" : ""); + } + fprintf(out, + "};\n"); + + /* compute braid tables for this N and 32-bit word_t */ + braid(ltl, big, n, 4); + + /* write out braid tables for 32-bit z_word_t to crc32.h */ + fprintf(out, + "\n" + "#else /* W == 4 */\n" + "\n" + "local const z_crc_t FAR crc_braid_table[][256] = {\n"); + for (k = 0; k < 4; k++) { + fprintf(out, " {"); + write_table(out, ltl[k], 256); + fprintf(out, "}%s", k < 3 ? ",\n" : ""); + } + fprintf(out, + "};\n" + "\n" + "local const z_word_t FAR crc_braid_big_table[][256] = {\n"); + for (k = 0; k < 4; k++) { + fprintf(out, " {"); + write_table32hi(out, big[k], 256); + fprintf(out, "}%s", k < 3 ? ",\n" : ""); + } + fprintf(out, + "};\n" + "\n" + "#endif\n" + "\n" + "#endif\n"); } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); + fprintf(out, + "\n" + "#endif\n"); + + /* write out zeros operator table to crc32.h */ + fprintf(out, + "\n" + "local const z_crc_t FAR x2n_table[] = {\n" + " "); + write_table(out, x2n_table, 32); + fprintf(out, + "};\n"); fclose(out); } #endif /* MAKECRCH */ } #ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const z_crc_t FAR *table; -{ + +/* + Write the 32-bit values in table[0..k-1] to out, five per line in + hexadecimal separated by commas. + */ +local void write_table(FILE *out, const z_crc_t FAR *table, int k) { int n; - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", + for (n = 0; n < k; n++) + fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", (unsigned long)(table[n]), - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); + n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); +} + +/* + Write the high 32-bits of each value in table[0..k-1] to out, five per line + in hexadecimal separated by commas. + */ +local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { + int n; + + for (n = 0; n < k; n++) + fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", + (unsigned long)(table[n] >> 32), + n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); +} + +/* + Write the 64-bit values in table[0..k-1] to out, three per line in + hexadecimal separated by commas. This assumes that if there is a 64-bit + type, then there is also a long long integer type, and it is at least 64 + bits. If not, then the type cast and format string can be adjusted + accordingly. + */ +local void write_table64(FILE *out, const z_word_t FAR *table, int k) { + int n; + + for (n = 0; n < k; n++) + fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", + (unsigned long long)(table[n]), + n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); +} + +/* Actually do the deed. */ +int main(void) { + make_crc_table(); + return 0; } + #endif /* MAKECRCH */ -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). +#ifdef W +/* + Generate the little and big-endian braid tables for the given n and z_word_t + size w. Each array must have room for w blocks of 256 elements. */ -#include "crc32.h" +local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { + int k; + z_crc_t i, p, q; + for (k = 0; k < w; k++) { + p = x2nmodp((n * w + 3 - k) << 3, 0); + ltl[k][0] = 0; + big[w - 1 - k][0] = 0; + for (i = 1; i < 256; i++) { + ltl[k][i] = q = multmodp(i << 24, p); + big[w - 1 - k][i] = byte_swap(q); + } + } +} +#endif + #endif /* DYNAMIC_CRC_TABLE */ /* ========================================================================= - * This function can be used by asm versions of crc32() + * This function can be used by asm versions of crc32(), and to force the + * generation of the CRC tables in a threaded application. */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ +const z_crc_t FAR * ZEXPORT get_crc_table(void) { #ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); + once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return (const z_crc_t FAR *)crc_table; } -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 +/* ========================================================================= + * Use ARM machine instructions if available. This will compute the CRC about + * ten times faster than the braided calculation. This code does not check for + * the presence of the CRC instruction at run time. __ARM_FEATURE_CRC32 will + * only be defined if the compilation specifies an ARM processor architecture + * that has the instructions. For example, compiling with -march=armv8.1-a or + * -march=armv8-a+crc, or -march=native if the compile machine has the crc32 + * instructions. + */ +#ifdef ARMCRC32 -/* ========================================================================= */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - if (buf == Z_NULL) return 0UL; +/* + Constants empirically determined to maximize speed. These values are from + measurements on a Cortex-A57. Your mileage may vary. + */ +#define Z_BATCH 3990 /* number of words in a batch */ +#define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ +#define Z_BATCH_MIN 800 /* fewest words in a final batch */ + +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { + z_crc_t val; + z_word_t crc1, crc2; + const z_word_t *word; + z_word_t val0, val1, val2; + z_size_t last, last2, i; + z_size_t num; + + /* Return initial CRC, if requested. */ + if (buf == Z_NULL) return 0; #ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); + once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - z_crc_t endian; + /* Pre-condition the CRC */ + crc = (~crc) & 0xffffffff; - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); + /* Compute the CRC up to a word boundary. */ + while (len && ((z_size_t)buf & 7) != 0) { + len--; + val = *buf++; + __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; + + /* Prepare to compute the CRC on full 64-bit words word[0..num-1]. */ + word = (z_word_t const *)buf; + num = len >> 3; + len &= 7; + + /* Do three interleaved CRCs to realize the throughput of one crc32x + instruction per cycle. Each CRC is calculated on Z_BATCH words. The + three CRCs are combined into a single CRC after each set of batches. */ + while (num >= 3 * Z_BATCH) { + crc1 = 0; + crc2 = 0; + for (i = 0; i < Z_BATCH; i++) { + val0 = word[i]; + val1 = word[i + Z_BATCH]; + val2 = word[i + 2 * Z_BATCH]; + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1)); + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2)); + } + word += 3 * Z_BATCH; + num -= 3 * Z_BATCH; + crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc1; + crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc2; } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ - return crc32_z(crc, buf, len); + /* Do one last smaller batch with the remaining words, if there are enough + to pay for the combination of CRCs. */ + last = num / 3; + if (last >= Z_BATCH_MIN) { + last2 = last << 1; + crc1 = 0; + crc2 = 0; + for (i = 0; i < last; i++) { + val0 = word[i]; + val1 = word[i + last]; + val2 = word[i + last2]; + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1)); + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2)); + } + word += 3 * last; + num -= 3 * last; + val = x2nmodp(last, 6); + crc = multmodp(val, crc) ^ crc1; + crc = multmodp(val, crc) ^ crc2; + } + + /* Compute the CRC on any remaining words. */ + for (i = 0; i < num; i++) { + val0 = word[i]; + __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); + } + word += num; + + /* Complete the CRC on any remaining bytes. */ + buf = (const unsigned char FAR *)word; + while (len) { + len--; + val = *buf++; + __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); + } + + /* Return the CRC, post-conditioned. */ + return crc ^ 0xffffffff; } -#ifdef BYFOUR +#else + +#ifdef W /* - This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit - integer pointer type. This violates the strict aliasing rule, where a - compiler can assume, for optimization purposes, that two pointers to - fundamentally different types won't ever point to the same memory. This can - manifest as a problem only if one of the pointers is written to. This code - only reads from those pointers. So long as this code remains isolated in - this compilation unit, there won't be a problem. For this reason, this code - should not be copied and pasted into a compilation unit in which other code - writes to the buffer that is passed to these routines. + Return the CRC of the W bytes in the word_t data, taking the + least-significant byte of the word as the first byte of data, without any pre + or post conditioning. This is used to combine the CRCs of each braid. */ +local z_crc_t crc_word(z_word_t data) { + int k; + for (k = 0; k < W; k++) + data = (data >> 8) ^ crc_table[data & 0xff]; + return (z_crc_t)data; +} -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 +local z_word_t crc_word_big(z_word_t data) { + int k; + for (k = 0; k < W; k++) + data = (data << 8) ^ + crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; + return data; +} + +#endif /* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - register z_crc_t c; - register const z_crc_t FAR *buf4; - - c = (z_crc_t)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { + /* Return initial CRC, if requested. */ + if (buf == Z_NULL) return 0; - buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; +#ifdef DYNAMIC_CRC_TABLE + once(&made, make_crc_table); +#endif /* DYNAMIC_CRC_TABLE */ - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} + /* Pre-condition the CRC */ + crc = (~crc) & 0xffffffff; -/* ========================================================================= */ -#define DOBIG4 c ^= *buf4++; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 +#ifdef W -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - register z_crc_t c; - register const z_crc_t FAR *buf4; - - c = ZSWAP32((z_crc_t)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; + /* If provided enough bytes, do a braided CRC calculation. */ + if (len >= N * W + W - 1) { + z_size_t blks; + z_word_t const *words; + unsigned endian; + int k; + + /* Compute the CRC up to a z_word_t boundary. */ + while (len && ((z_size_t)buf & (W - 1)) != 0) { + len--; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + } + + /* Compute the CRC on as many N z_word_t blocks as are available. */ + blks = len / (N * W); + len -= blks * N * W; + words = (z_word_t const *)buf; + + /* Do endian check at execution time instead of compile time, since ARM + processors can change the endianness at execution time. If the + compiler knows what the endianness will be, it can optimize out the + check and the unused branch. */ + endian = 1; + if (*(unsigned char *)&endian) { + /* Little endian. */ + + z_crc_t crc0; + z_word_t word0; +#if N > 1 + z_crc_t crc1; + z_word_t word1; +#if N > 2 + z_crc_t crc2; + z_word_t word2; +#if N > 3 + z_crc_t crc3; + z_word_t word3; +#if N > 4 + z_crc_t crc4; + z_word_t word4; +#if N > 5 + z_crc_t crc5; + z_word_t word5; +#endif +#endif +#endif +#endif +#endif + + /* Initialize the CRC for each braid. */ + crc0 = crc; +#if N > 1 + crc1 = 0; +#if N > 2 + crc2 = 0; +#if N > 3 + crc3 = 0; +#if N > 4 + crc4 = 0; +#if N > 5 + crc5 = 0; +#endif +#endif +#endif +#endif +#endif + + /* + Process the first blks-1 blocks, computing the CRCs on each braid + independently. + */ + while (--blks) { + /* Load the word for each braid into registers. */ + word0 = crc0 ^ words[0]; +#if N > 1 + word1 = crc1 ^ words[1]; +#if N > 2 + word2 = crc2 ^ words[2]; +#if N > 3 + word3 = crc3 ^ words[3]; +#if N > 4 + word4 = crc4 ^ words[4]; +#if N > 5 + word5 = crc5 ^ words[5]; +#endif +#endif +#endif +#endif +#endif + words += N; + + /* Compute and update the CRC for each word. The loop should + get unrolled. */ + crc0 = crc_braid_table[0][word0 & 0xff]; +#if N > 1 + crc1 = crc_braid_table[0][word1 & 0xff]; +#if N > 2 + crc2 = crc_braid_table[0][word2 & 0xff]; +#if N > 3 + crc3 = crc_braid_table[0][word3 & 0xff]; +#if N > 4 + crc4 = crc_braid_table[0][word4 & 0xff]; +#if N > 5 + crc5 = crc_braid_table[0][word5 & 0xff]; +#endif +#endif +#endif +#endif +#endif + for (k = 1; k < W; k++) { + crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff]; +#if N > 1 + crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff]; +#if N > 2 + crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff]; +#if N > 3 + crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff]; +#if N > 4 + crc4 ^= crc_braid_table[k][(word4 >> (k << 3)) & 0xff]; +#if N > 5 + crc5 ^= crc_braid_table[k][(word5 >> (k << 3)) & 0xff]; +#endif +#endif +#endif +#endif +#endif + } + } + + /* + Process the last block, combining the CRCs of the N braids at the + same time. + */ + crc = crc_word(crc0 ^ words[0]); +#if N > 1 + crc = crc_word(crc1 ^ words[1] ^ crc); +#if N > 2 + crc = crc_word(crc2 ^ words[2] ^ crc); +#if N > 3 + crc = crc_word(crc3 ^ words[3] ^ crc); +#if N > 4 + crc = crc_word(crc4 ^ words[4] ^ crc); +#if N > 5 + crc = crc_word(crc5 ^ words[5] ^ crc); +#endif +#endif +#endif +#endif +#endif + words += N; + } + else { + /* Big endian. */ + + z_word_t crc0, word0, comb; +#if N > 1 + z_word_t crc1, word1; +#if N > 2 + z_word_t crc2, word2; +#if N > 3 + z_word_t crc3, word3; +#if N > 4 + z_word_t crc4, word4; +#if N > 5 + z_word_t crc5, word5; +#endif +#endif +#endif +#endif +#endif + + /* Initialize the CRC for each braid. */ + crc0 = byte_swap(crc); +#if N > 1 + crc1 = 0; +#if N > 2 + crc2 = 0; +#if N > 3 + crc3 = 0; +#if N > 4 + crc4 = 0; +#if N > 5 + crc5 = 0; +#endif +#endif +#endif +#endif +#endif + + /* + Process the first blks-1 blocks, computing the CRCs on each braid + independently. + */ + while (--blks) { + /* Load the word for each braid into registers. */ + word0 = crc0 ^ words[0]; +#if N > 1 + word1 = crc1 ^ words[1]; +#if N > 2 + word2 = crc2 ^ words[2]; +#if N > 3 + word3 = crc3 ^ words[3]; +#if N > 4 + word4 = crc4 ^ words[4]; +#if N > 5 + word5 = crc5 ^ words[5]; +#endif +#endif +#endif +#endif +#endif + words += N; + + /* Compute and update the CRC for each word. The loop should + get unrolled. */ + crc0 = crc_braid_big_table[0][word0 & 0xff]; +#if N > 1 + crc1 = crc_braid_big_table[0][word1 & 0xff]; +#if N > 2 + crc2 = crc_braid_big_table[0][word2 & 0xff]; +#if N > 3 + crc3 = crc_braid_big_table[0][word3 & 0xff]; +#if N > 4 + crc4 = crc_braid_big_table[0][word4 & 0xff]; +#if N > 5 + crc5 = crc_braid_big_table[0][word5 & 0xff]; +#endif +#endif +#endif +#endif +#endif + for (k = 1; k < W; k++) { + crc0 ^= crc_braid_big_table[k][(word0 >> (k << 3)) & 0xff]; +#if N > 1 + crc1 ^= crc_braid_big_table[k][(word1 >> (k << 3)) & 0xff]; +#if N > 2 + crc2 ^= crc_braid_big_table[k][(word2 >> (k << 3)) & 0xff]; +#if N > 3 + crc3 ^= crc_braid_big_table[k][(word3 >> (k << 3)) & 0xff]; +#if N > 4 + crc4 ^= crc_braid_big_table[k][(word4 >> (k << 3)) & 0xff]; +#if N > 5 + crc5 ^= crc_braid_big_table[k][(word5 >> (k << 3)) & 0xff]; +#endif +#endif +#endif +#endif +#endif + } + } + + /* + Process the last block, combining the CRCs of the N braids at the + same time. + */ + comb = crc_word_big(crc0 ^ words[0]); +#if N > 1 + comb = crc_word_big(crc1 ^ words[1] ^ comb); +#if N > 2 + comb = crc_word_big(crc2 ^ words[2] ^ comb); +#if N > 3 + comb = crc_word_big(crc3 ^ words[3] ^ comb); +#if N > 4 + comb = crc_word_big(crc4 ^ words[4] ^ comb); +#if N > 5 + comb = crc_word_big(crc5 ^ words[5] ^ comb); +#endif +#endif +#endif +#endif +#endif + words += N; + crc = byte_swap(comb); + } + + /* + Update the pointer to the remaining bytes to process. + */ + buf = (unsigned char const *)words; } - buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - while (len >= 32) { - DOBIG32; - len -= 32; +#endif /* W */ + + /* Complete the computation of the CRC on any remaining bytes. */ + while (len >= 8) { + len -= 8; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } - while (len >= 4) { - DOBIG4; - len -= 4; + while (len) { + len--; + crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } - buf = (const unsigned char FAR *)buf4; - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(ZSWAP32(c)); + /* Return the CRC, post-conditioned. */ + return crc ^ 0xffffffff; } -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ +#endif /* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; +unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, + uInt len) { + return crc32_z(crc, buf, len); } /* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); +uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { +#ifdef DYNAMIC_CRC_TABLE + once(&made, make_crc_table); +#endif /* DYNAMIC_CRC_TABLE */ + return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff); } /* ========================================================================= */ -local uLong crc32_combine_(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case (also disallow negative lengths) */ - if (len2 <= 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } +uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { + return crc32_combine64(crc1, crc2, (z_off64_t)len2); +} - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; +/* ========================================================================= */ +uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { +#ifdef DYNAMIC_CRC_TABLE + once(&made, make_crc_table); +#endif /* DYNAMIC_CRC_TABLE */ + return x2nmodp(len2, 3); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - return crc32_combine_(crc1, crc2, len2); +uLong ZEXPORT crc32_combine_gen(z_off_t len2) { + return crc32_combine_gen64((z_off64_t)len2); } -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - return crc32_combine_(crc1, crc2, len2); +/* ========================================================================= */ +uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { + return multmodp(op, crc1) ^ (crc2 & 0xffffffff); } diff --git a/libz/crc32.h b/libz/crc32.h index 9e0c7781..137df68d 100644 --- a/libz/crc32.h +++ b/libz/crc32.h @@ -2,440 +2,9445 @@ * Generated automatically by crc32.c */ -local const z_crc_t FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL +local const z_crc_t FAR crc_table[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d}; + +#ifdef W + +#if W == 8 + +local const z_word_t FAR crc_big_table[] = { + 0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, + 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, + 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, + 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, + 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, + 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, + 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, + 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, + 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, + 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, + 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, + 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, + 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, + 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, + 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, + 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, + 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, + 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, + 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, + 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, + 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, + 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, + 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, + 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, + 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, + 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, + 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, + 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, + 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, + 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, + 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, + 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, + 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, + 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, + 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, + 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, + 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, + 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, + 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, + 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, + 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, + 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, + 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, + 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, + 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, + 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, + 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, + 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, + 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, + 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, + 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, + 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, + 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, + 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, + 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, + 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, + 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, + 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, + 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, + 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, + 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, + 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, + 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, + 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, + 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, + 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, + 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, + 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, + 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, + 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, + 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, + 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, + 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, + 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, + 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, + 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, + 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, + 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, + 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, + 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, + 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, + 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, + 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, + 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, + 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, + 0x8def022d00000000}; + +#else /* W == 4 */ + +local const z_word_t FAR crc_big_table[] = { + 0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, + 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, + 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, + 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, + 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, + 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, + 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, + 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, + 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, + 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, + 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, + 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, + 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, + 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, + 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, + 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, + 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, + 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, + 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, + 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, + 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, + 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, + 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, + 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, + 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, + 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, + 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, + 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, + 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, + 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, + 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, + 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, + 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, + 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, + 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, + 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, + 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, + 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, + 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, + 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, + 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, + 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, + 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, + 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, + 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, + 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, + 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, + 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, + 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, + 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, + 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, + 0x8def022d}; + +#endif + +#if N == 1 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, + 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, + 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, + 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, + 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, + 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, + 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, + 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, + 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, + 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, + 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, + 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, + 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, + 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, + 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, + 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, + 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, + 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, + 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, + 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, + 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, + 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, + 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, + 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, + 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, + 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, + 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, + 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, + 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, + 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, + 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, + 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, + 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, + 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, + 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, + 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, + 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, + 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, + 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, + 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, + 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, + 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, + 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, + 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, + 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, + 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, + 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, + 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, + 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, + 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, + 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, + 0x264b06e6}, + {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, + 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, + 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, + 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, + 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, + 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, + 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, + 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, + 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, + 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, + 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, + 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, + 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, + 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, + 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, + 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, + 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, + 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, + 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, + 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, + 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, + 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, + 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, + 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, + 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, + 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, + 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, + 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, + 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, + 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, + 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, + 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, + 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, + 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, + 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, + 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, + 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, + 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, + 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, + 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, + 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, + 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, + 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, + 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, + 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, + 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, + 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, + 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, + 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, + 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, + 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, + 0x92364a30}, + {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, + 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, + 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, + 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, + 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, + 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, + 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, + 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, + 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, + 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, + 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, + 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, + 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, + 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, + 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, + 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, + 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, + 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, + 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, + 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, + 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, + 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, + 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, + 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, + 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, + 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, + 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, + 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, + 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, + 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, + 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, + 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, + 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, + 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, + 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, + 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, + 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, + 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, + 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, + 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, + 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, + 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, + 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, + 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, + 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, + 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, + 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, + 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, + 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, + 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, + 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, + 0xe4c4abcc}, + {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, + 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, + 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, + 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, + 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, + 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, + 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, + 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, + 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, + 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, + 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, + 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, + 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, + 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, + 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, + 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, + 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, + 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, + 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, + 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, + 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, + 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, + 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, + 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, + 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, + 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, + 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, + 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, + 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, + 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, + 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, + 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, + 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, + 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, + 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, + 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, + 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, + 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, + 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, + 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, + 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, + 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, + 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, + 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, + 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, + 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, + 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, + 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, + 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, + 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, + 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, + 0xca64c78c}, + {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, + 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, + 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, + 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, + 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, + 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, + 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, + 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, + 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, + 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, + 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, + 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, + 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, + 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, + 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, + 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, + 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, + 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, + 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, + 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, + 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, + 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, + 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, + 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, + 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, + 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, + 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, + 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, + 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, + 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, + 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, + 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, + 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, + 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, + 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, + 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, + 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, + 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, + 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, + 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, + 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, + 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, + 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, + 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, + 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, + 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, + 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, + 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, + 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, + 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, + 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, + 0xde0506f1}, + {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, + 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, + 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, + 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, + 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, + 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, + 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, + 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, + 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, + 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, + 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, + 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, + 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, + 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, + 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, + 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, + 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, + 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, + 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, + 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, + 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, + 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, + 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, + 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, + 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, + 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, + 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, + 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, + 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, + 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, + 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, + 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, + 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, + 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, + 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, + 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, + 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, + 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, + 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, + 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, + 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, + 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, + 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, + 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, + 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, + 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, + 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, + 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, + 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, + 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, + 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, + 0xbe9834ed}, + {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, + 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, + 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, + 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, + 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, + 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, + 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, + 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, + 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, + 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, + 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, + 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, + 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, + 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, + 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, + 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, + 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, + 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, + 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, + 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, + 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, + 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, + 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, + 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, + 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, + 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, + 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, + 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, + 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, + 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, + 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, + 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, + 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, + 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, + 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, + 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, + 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, + 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, + 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, + 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, + 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, + 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, + 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, + 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, + 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, + 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, + 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, + 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, + 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, + 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, + 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, + 0x9324fd72}, + {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, + 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, + 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, + 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, + 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, + 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, + 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, + 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, + 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, + 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, + 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, + 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, + 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, + 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, + 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, + 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, + 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, + 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, + 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, + 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, + 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, + 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, + 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, + 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, + 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, + 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, + 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, + 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, + 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, + 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, + 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, + 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, + 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, + 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, + 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, + 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, + 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, + 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, + 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, + 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, + 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, + 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, + 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, + 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, + 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, + 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, + 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, + 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, + 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, + 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, + 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, + 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, + 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, + 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, + 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, + 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, + 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, + 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, + 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, + 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, + 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, + 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, + 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, + 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, + 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, + 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, + 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, + 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, + 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, + 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, + 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, + 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, + 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, + 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, + 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, + 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, + 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, + 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, + 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, + 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, + 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, + 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, + 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, + 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, + 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, + 0x8def022d00000000}, + {0x0000000000000000, 0x41311b1900000000, 0x8262363200000000, + 0xc3532d2b00000000, 0x04c56c6400000000, 0x45f4777d00000000, + 0x86a75a5600000000, 0xc796414f00000000, 0x088ad9c800000000, + 0x49bbc2d100000000, 0x8ae8effa00000000, 0xcbd9f4e300000000, + 0x0c4fb5ac00000000, 0x4d7eaeb500000000, 0x8e2d839e00000000, + 0xcf1c988700000000, 0x5112c24a00000000, 0x1023d95300000000, + 0xd370f47800000000, 0x9241ef6100000000, 0x55d7ae2e00000000, + 0x14e6b53700000000, 0xd7b5981c00000000, 0x9684830500000000, + 0x59981b8200000000, 0x18a9009b00000000, 0xdbfa2db000000000, + 0x9acb36a900000000, 0x5d5d77e600000000, 0x1c6c6cff00000000, + 0xdf3f41d400000000, 0x9e0e5acd00000000, 0xa224849500000000, + 0xe3159f8c00000000, 0x2046b2a700000000, 0x6177a9be00000000, + 0xa6e1e8f100000000, 0xe7d0f3e800000000, 0x2483dec300000000, + 0x65b2c5da00000000, 0xaaae5d5d00000000, 0xeb9f464400000000, + 0x28cc6b6f00000000, 0x69fd707600000000, 0xae6b313900000000, + 0xef5a2a2000000000, 0x2c09070b00000000, 0x6d381c1200000000, + 0xf33646df00000000, 0xb2075dc600000000, 0x715470ed00000000, + 0x30656bf400000000, 0xf7f32abb00000000, 0xb6c231a200000000, + 0x75911c8900000000, 0x34a0079000000000, 0xfbbc9f1700000000, + 0xba8d840e00000000, 0x79dea92500000000, 0x38efb23c00000000, + 0xff79f37300000000, 0xbe48e86a00000000, 0x7d1bc54100000000, + 0x3c2ade5800000000, 0x054f79f000000000, 0x447e62e900000000, + 0x872d4fc200000000, 0xc61c54db00000000, 0x018a159400000000, + 0x40bb0e8d00000000, 0x83e823a600000000, 0xc2d938bf00000000, + 0x0dc5a03800000000, 0x4cf4bb2100000000, 0x8fa7960a00000000, + 0xce968d1300000000, 0x0900cc5c00000000, 0x4831d74500000000, + 0x8b62fa6e00000000, 0xca53e17700000000, 0x545dbbba00000000, + 0x156ca0a300000000, 0xd63f8d8800000000, 0x970e969100000000, + 0x5098d7de00000000, 0x11a9ccc700000000, 0xd2fae1ec00000000, + 0x93cbfaf500000000, 0x5cd7627200000000, 0x1de6796b00000000, + 0xdeb5544000000000, 0x9f844f5900000000, 0x58120e1600000000, + 0x1923150f00000000, 0xda70382400000000, 0x9b41233d00000000, + 0xa76bfd6500000000, 0xe65ae67c00000000, 0x2509cb5700000000, + 0x6438d04e00000000, 0xa3ae910100000000, 0xe29f8a1800000000, + 0x21cca73300000000, 0x60fdbc2a00000000, 0xafe124ad00000000, + 0xeed03fb400000000, 0x2d83129f00000000, 0x6cb2098600000000, + 0xab2448c900000000, 0xea1553d000000000, 0x29467efb00000000, + 0x687765e200000000, 0xf6793f2f00000000, 0xb748243600000000, + 0x741b091d00000000, 0x352a120400000000, 0xf2bc534b00000000, + 0xb38d485200000000, 0x70de657900000000, 0x31ef7e6000000000, + 0xfef3e6e700000000, 0xbfc2fdfe00000000, 0x7c91d0d500000000, + 0x3da0cbcc00000000, 0xfa368a8300000000, 0xbb07919a00000000, + 0x7854bcb100000000, 0x3965a7a800000000, 0x4b98833b00000000, + 0x0aa9982200000000, 0xc9fab50900000000, 0x88cbae1000000000, + 0x4f5def5f00000000, 0x0e6cf44600000000, 0xcd3fd96d00000000, + 0x8c0ec27400000000, 0x43125af300000000, 0x022341ea00000000, + 0xc1706cc100000000, 0x804177d800000000, 0x47d7369700000000, + 0x06e62d8e00000000, 0xc5b500a500000000, 0x84841bbc00000000, + 0x1a8a417100000000, 0x5bbb5a6800000000, 0x98e8774300000000, + 0xd9d96c5a00000000, 0x1e4f2d1500000000, 0x5f7e360c00000000, + 0x9c2d1b2700000000, 0xdd1c003e00000000, 0x120098b900000000, + 0x533183a000000000, 0x9062ae8b00000000, 0xd153b59200000000, + 0x16c5f4dd00000000, 0x57f4efc400000000, 0x94a7c2ef00000000, + 0xd596d9f600000000, 0xe9bc07ae00000000, 0xa88d1cb700000000, + 0x6bde319c00000000, 0x2aef2a8500000000, 0xed796bca00000000, + 0xac4870d300000000, 0x6f1b5df800000000, 0x2e2a46e100000000, + 0xe136de6600000000, 0xa007c57f00000000, 0x6354e85400000000, + 0x2265f34d00000000, 0xe5f3b20200000000, 0xa4c2a91b00000000, + 0x6791843000000000, 0x26a09f2900000000, 0xb8aec5e400000000, + 0xf99fdefd00000000, 0x3accf3d600000000, 0x7bfde8cf00000000, + 0xbc6ba98000000000, 0xfd5ab29900000000, 0x3e099fb200000000, + 0x7f3884ab00000000, 0xb0241c2c00000000, 0xf115073500000000, + 0x32462a1e00000000, 0x7377310700000000, 0xb4e1704800000000, + 0xf5d06b5100000000, 0x3683467a00000000, 0x77b25d6300000000, + 0x4ed7facb00000000, 0x0fe6e1d200000000, 0xccb5ccf900000000, + 0x8d84d7e000000000, 0x4a1296af00000000, 0x0b238db600000000, + 0xc870a09d00000000, 0x8941bb8400000000, 0x465d230300000000, + 0x076c381a00000000, 0xc43f153100000000, 0x850e0e2800000000, + 0x42984f6700000000, 0x03a9547e00000000, 0xc0fa795500000000, + 0x81cb624c00000000, 0x1fc5388100000000, 0x5ef4239800000000, + 0x9da70eb300000000, 0xdc9615aa00000000, 0x1b0054e500000000, + 0x5a314ffc00000000, 0x996262d700000000, 0xd85379ce00000000, + 0x174fe14900000000, 0x567efa5000000000, 0x952dd77b00000000, + 0xd41ccc6200000000, 0x138a8d2d00000000, 0x52bb963400000000, + 0x91e8bb1f00000000, 0xd0d9a00600000000, 0xecf37e5e00000000, + 0xadc2654700000000, 0x6e91486c00000000, 0x2fa0537500000000, + 0xe836123a00000000, 0xa907092300000000, 0x6a54240800000000, + 0x2b653f1100000000, 0xe479a79600000000, 0xa548bc8f00000000, + 0x661b91a400000000, 0x272a8abd00000000, 0xe0bccbf200000000, + 0xa18dd0eb00000000, 0x62defdc000000000, 0x23efe6d900000000, + 0xbde1bc1400000000, 0xfcd0a70d00000000, 0x3f838a2600000000, + 0x7eb2913f00000000, 0xb924d07000000000, 0xf815cb6900000000, + 0x3b46e64200000000, 0x7a77fd5b00000000, 0xb56b65dc00000000, + 0xf45a7ec500000000, 0x370953ee00000000, 0x763848f700000000, + 0xb1ae09b800000000, 0xf09f12a100000000, 0x33cc3f8a00000000, + 0x72fd249300000000}, + {0x0000000000000000, 0x376ac20100000000, 0x6ed4840300000000, + 0x59be460200000000, 0xdca8090700000000, 0xebc2cb0600000000, + 0xb27c8d0400000000, 0x85164f0500000000, 0xb851130e00000000, + 0x8f3bd10f00000000, 0xd685970d00000000, 0xe1ef550c00000000, + 0x64f91a0900000000, 0x5393d80800000000, 0x0a2d9e0a00000000, + 0x3d475c0b00000000, 0x70a3261c00000000, 0x47c9e41d00000000, + 0x1e77a21f00000000, 0x291d601e00000000, 0xac0b2f1b00000000, + 0x9b61ed1a00000000, 0xc2dfab1800000000, 0xf5b5691900000000, + 0xc8f2351200000000, 0xff98f71300000000, 0xa626b11100000000, + 0x914c731000000000, 0x145a3c1500000000, 0x2330fe1400000000, + 0x7a8eb81600000000, 0x4de47a1700000000, 0xe0464d3800000000, + 0xd72c8f3900000000, 0x8e92c93b00000000, 0xb9f80b3a00000000, + 0x3cee443f00000000, 0x0b84863e00000000, 0x523ac03c00000000, + 0x6550023d00000000, 0x58175e3600000000, 0x6f7d9c3700000000, + 0x36c3da3500000000, 0x01a9183400000000, 0x84bf573100000000, + 0xb3d5953000000000, 0xea6bd33200000000, 0xdd01113300000000, + 0x90e56b2400000000, 0xa78fa92500000000, 0xfe31ef2700000000, + 0xc95b2d2600000000, 0x4c4d622300000000, 0x7b27a02200000000, + 0x2299e62000000000, 0x15f3242100000000, 0x28b4782a00000000, + 0x1fdeba2b00000000, 0x4660fc2900000000, 0x710a3e2800000000, + 0xf41c712d00000000, 0xc376b32c00000000, 0x9ac8f52e00000000, + 0xada2372f00000000, 0xc08d9a7000000000, 0xf7e7587100000000, + 0xae591e7300000000, 0x9933dc7200000000, 0x1c25937700000000, + 0x2b4f517600000000, 0x72f1177400000000, 0x459bd57500000000, + 0x78dc897e00000000, 0x4fb64b7f00000000, 0x16080d7d00000000, + 0x2162cf7c00000000, 0xa474807900000000, 0x931e427800000000, + 0xcaa0047a00000000, 0xfdcac67b00000000, 0xb02ebc6c00000000, + 0x87447e6d00000000, 0xdefa386f00000000, 0xe990fa6e00000000, + 0x6c86b56b00000000, 0x5bec776a00000000, 0x0252316800000000, + 0x3538f36900000000, 0x087faf6200000000, 0x3f156d6300000000, + 0x66ab2b6100000000, 0x51c1e96000000000, 0xd4d7a66500000000, + 0xe3bd646400000000, 0xba03226600000000, 0x8d69e06700000000, + 0x20cbd74800000000, 0x17a1154900000000, 0x4e1f534b00000000, + 0x7975914a00000000, 0xfc63de4f00000000, 0xcb091c4e00000000, + 0x92b75a4c00000000, 0xa5dd984d00000000, 0x989ac44600000000, + 0xaff0064700000000, 0xf64e404500000000, 0xc124824400000000, + 0x4432cd4100000000, 0x73580f4000000000, 0x2ae6494200000000, + 0x1d8c8b4300000000, 0x5068f15400000000, 0x6702335500000000, + 0x3ebc755700000000, 0x09d6b75600000000, 0x8cc0f85300000000, + 0xbbaa3a5200000000, 0xe2147c5000000000, 0xd57ebe5100000000, + 0xe839e25a00000000, 0xdf53205b00000000, 0x86ed665900000000, + 0xb187a45800000000, 0x3491eb5d00000000, 0x03fb295c00000000, + 0x5a456f5e00000000, 0x6d2fad5f00000000, 0x801b35e100000000, + 0xb771f7e000000000, 0xeecfb1e200000000, 0xd9a573e300000000, + 0x5cb33ce600000000, 0x6bd9fee700000000, 0x3267b8e500000000, + 0x050d7ae400000000, 0x384a26ef00000000, 0x0f20e4ee00000000, + 0x569ea2ec00000000, 0x61f460ed00000000, 0xe4e22fe800000000, + 0xd388ede900000000, 0x8a36abeb00000000, 0xbd5c69ea00000000, + 0xf0b813fd00000000, 0xc7d2d1fc00000000, 0x9e6c97fe00000000, + 0xa90655ff00000000, 0x2c101afa00000000, 0x1b7ad8fb00000000, + 0x42c49ef900000000, 0x75ae5cf800000000, 0x48e900f300000000, + 0x7f83c2f200000000, 0x263d84f000000000, 0x115746f100000000, + 0x944109f400000000, 0xa32bcbf500000000, 0xfa958df700000000, + 0xcdff4ff600000000, 0x605d78d900000000, 0x5737bad800000000, + 0x0e89fcda00000000, 0x39e33edb00000000, 0xbcf571de00000000, + 0x8b9fb3df00000000, 0xd221f5dd00000000, 0xe54b37dc00000000, + 0xd80c6bd700000000, 0xef66a9d600000000, 0xb6d8efd400000000, + 0x81b22dd500000000, 0x04a462d000000000, 0x33cea0d100000000, + 0x6a70e6d300000000, 0x5d1a24d200000000, 0x10fe5ec500000000, + 0x27949cc400000000, 0x7e2adac600000000, 0x494018c700000000, + 0xcc5657c200000000, 0xfb3c95c300000000, 0xa282d3c100000000, + 0x95e811c000000000, 0xa8af4dcb00000000, 0x9fc58fca00000000, + 0xc67bc9c800000000, 0xf1110bc900000000, 0x740744cc00000000, + 0x436d86cd00000000, 0x1ad3c0cf00000000, 0x2db902ce00000000, + 0x4096af9100000000, 0x77fc6d9000000000, 0x2e422b9200000000, + 0x1928e99300000000, 0x9c3ea69600000000, 0xab54649700000000, + 0xf2ea229500000000, 0xc580e09400000000, 0xf8c7bc9f00000000, + 0xcfad7e9e00000000, 0x9613389c00000000, 0xa179fa9d00000000, + 0x246fb59800000000, 0x1305779900000000, 0x4abb319b00000000, + 0x7dd1f39a00000000, 0x3035898d00000000, 0x075f4b8c00000000, + 0x5ee10d8e00000000, 0x698bcf8f00000000, 0xec9d808a00000000, + 0xdbf7428b00000000, 0x8249048900000000, 0xb523c68800000000, + 0x88649a8300000000, 0xbf0e588200000000, 0xe6b01e8000000000, + 0xd1dadc8100000000, 0x54cc938400000000, 0x63a6518500000000, + 0x3a18178700000000, 0x0d72d58600000000, 0xa0d0e2a900000000, + 0x97ba20a800000000, 0xce0466aa00000000, 0xf96ea4ab00000000, + 0x7c78ebae00000000, 0x4b1229af00000000, 0x12ac6fad00000000, + 0x25c6adac00000000, 0x1881f1a700000000, 0x2feb33a600000000, + 0x765575a400000000, 0x413fb7a500000000, 0xc429f8a000000000, + 0xf3433aa100000000, 0xaafd7ca300000000, 0x9d97bea200000000, + 0xd073c4b500000000, 0xe71906b400000000, 0xbea740b600000000, + 0x89cd82b700000000, 0x0cdbcdb200000000, 0x3bb10fb300000000, + 0x620f49b100000000, 0x55658bb000000000, 0x6822d7bb00000000, + 0x5f4815ba00000000, 0x06f653b800000000, 0x319c91b900000000, + 0xb48adebc00000000, 0x83e01cbd00000000, 0xda5e5abf00000000, + 0xed3498be00000000}, + {0x0000000000000000, 0x6567bcb800000000, 0x8bc809aa00000000, + 0xeeafb51200000000, 0x5797628f00000000, 0x32f0de3700000000, + 0xdc5f6b2500000000, 0xb938d79d00000000, 0xef28b4c500000000, + 0x8a4f087d00000000, 0x64e0bd6f00000000, 0x018701d700000000, + 0xb8bfd64a00000000, 0xddd86af200000000, 0x3377dfe000000000, + 0x5610635800000000, 0x9f57195000000000, 0xfa30a5e800000000, + 0x149f10fa00000000, 0x71f8ac4200000000, 0xc8c07bdf00000000, + 0xada7c76700000000, 0x4308727500000000, 0x266fcecd00000000, + 0x707fad9500000000, 0x1518112d00000000, 0xfbb7a43f00000000, + 0x9ed0188700000000, 0x27e8cf1a00000000, 0x428f73a200000000, + 0xac20c6b000000000, 0xc9477a0800000000, 0x3eaf32a000000000, + 0x5bc88e1800000000, 0xb5673b0a00000000, 0xd00087b200000000, + 0x6938502f00000000, 0x0c5fec9700000000, 0xe2f0598500000000, + 0x8797e53d00000000, 0xd187866500000000, 0xb4e03add00000000, + 0x5a4f8fcf00000000, 0x3f28337700000000, 0x8610e4ea00000000, + 0xe377585200000000, 0x0dd8ed4000000000, 0x68bf51f800000000, + 0xa1f82bf000000000, 0xc49f974800000000, 0x2a30225a00000000, + 0x4f579ee200000000, 0xf66f497f00000000, 0x9308f5c700000000, + 0x7da740d500000000, 0x18c0fc6d00000000, 0x4ed09f3500000000, + 0x2bb7238d00000000, 0xc518969f00000000, 0xa07f2a2700000000, + 0x1947fdba00000000, 0x7c20410200000000, 0x928ff41000000000, + 0xf7e848a800000000, 0x3d58149b00000000, 0x583fa82300000000, + 0xb6901d3100000000, 0xd3f7a18900000000, 0x6acf761400000000, + 0x0fa8caac00000000, 0xe1077fbe00000000, 0x8460c30600000000, + 0xd270a05e00000000, 0xb7171ce600000000, 0x59b8a9f400000000, + 0x3cdf154c00000000, 0x85e7c2d100000000, 0xe0807e6900000000, + 0x0e2fcb7b00000000, 0x6b4877c300000000, 0xa20f0dcb00000000, + 0xc768b17300000000, 0x29c7046100000000, 0x4ca0b8d900000000, + 0xf5986f4400000000, 0x90ffd3fc00000000, 0x7e5066ee00000000, + 0x1b37da5600000000, 0x4d27b90e00000000, 0x284005b600000000, + 0xc6efb0a400000000, 0xa3880c1c00000000, 0x1ab0db8100000000, + 0x7fd7673900000000, 0x9178d22b00000000, 0xf41f6e9300000000, + 0x03f7263b00000000, 0x66909a8300000000, 0x883f2f9100000000, + 0xed58932900000000, 0x546044b400000000, 0x3107f80c00000000, + 0xdfa84d1e00000000, 0xbacff1a600000000, 0xecdf92fe00000000, + 0x89b82e4600000000, 0x67179b5400000000, 0x027027ec00000000, + 0xbb48f07100000000, 0xde2f4cc900000000, 0x3080f9db00000000, + 0x55e7456300000000, 0x9ca03f6b00000000, 0xf9c783d300000000, + 0x176836c100000000, 0x720f8a7900000000, 0xcb375de400000000, + 0xae50e15c00000000, 0x40ff544e00000000, 0x2598e8f600000000, + 0x73888bae00000000, 0x16ef371600000000, 0xf840820400000000, + 0x9d273ebc00000000, 0x241fe92100000000, 0x4178559900000000, + 0xafd7e08b00000000, 0xcab05c3300000000, 0x3bb659ed00000000, + 0x5ed1e55500000000, 0xb07e504700000000, 0xd519ecff00000000, + 0x6c213b6200000000, 0x094687da00000000, 0xe7e932c800000000, + 0x828e8e7000000000, 0xd49eed2800000000, 0xb1f9519000000000, + 0x5f56e48200000000, 0x3a31583a00000000, 0x83098fa700000000, + 0xe66e331f00000000, 0x08c1860d00000000, 0x6da63ab500000000, + 0xa4e140bd00000000, 0xc186fc0500000000, 0x2f29491700000000, + 0x4a4ef5af00000000, 0xf376223200000000, 0x96119e8a00000000, + 0x78be2b9800000000, 0x1dd9972000000000, 0x4bc9f47800000000, + 0x2eae48c000000000, 0xc001fdd200000000, 0xa566416a00000000, + 0x1c5e96f700000000, 0x79392a4f00000000, 0x97969f5d00000000, + 0xf2f123e500000000, 0x05196b4d00000000, 0x607ed7f500000000, + 0x8ed162e700000000, 0xebb6de5f00000000, 0x528e09c200000000, + 0x37e9b57a00000000, 0xd946006800000000, 0xbc21bcd000000000, + 0xea31df8800000000, 0x8f56633000000000, 0x61f9d62200000000, + 0x049e6a9a00000000, 0xbda6bd0700000000, 0xd8c101bf00000000, + 0x366eb4ad00000000, 0x5309081500000000, 0x9a4e721d00000000, + 0xff29cea500000000, 0x11867bb700000000, 0x74e1c70f00000000, + 0xcdd9109200000000, 0xa8beac2a00000000, 0x4611193800000000, + 0x2376a58000000000, 0x7566c6d800000000, 0x10017a6000000000, + 0xfeaecf7200000000, 0x9bc973ca00000000, 0x22f1a45700000000, + 0x479618ef00000000, 0xa939adfd00000000, 0xcc5e114500000000, + 0x06ee4d7600000000, 0x6389f1ce00000000, 0x8d2644dc00000000, + 0xe841f86400000000, 0x51792ff900000000, 0x341e934100000000, + 0xdab1265300000000, 0xbfd69aeb00000000, 0xe9c6f9b300000000, + 0x8ca1450b00000000, 0x620ef01900000000, 0x07694ca100000000, + 0xbe519b3c00000000, 0xdb36278400000000, 0x3599929600000000, + 0x50fe2e2e00000000, 0x99b9542600000000, 0xfcdee89e00000000, + 0x12715d8c00000000, 0x7716e13400000000, 0xce2e36a900000000, + 0xab498a1100000000, 0x45e63f0300000000, 0x208183bb00000000, + 0x7691e0e300000000, 0x13f65c5b00000000, 0xfd59e94900000000, + 0x983e55f100000000, 0x2106826c00000000, 0x44613ed400000000, + 0xaace8bc600000000, 0xcfa9377e00000000, 0x38417fd600000000, + 0x5d26c36e00000000, 0xb389767c00000000, 0xd6eecac400000000, + 0x6fd61d5900000000, 0x0ab1a1e100000000, 0xe41e14f300000000, + 0x8179a84b00000000, 0xd769cb1300000000, 0xb20e77ab00000000, + 0x5ca1c2b900000000, 0x39c67e0100000000, 0x80fea99c00000000, + 0xe599152400000000, 0x0b36a03600000000, 0x6e511c8e00000000, + 0xa716668600000000, 0xc271da3e00000000, 0x2cde6f2c00000000, + 0x49b9d39400000000, 0xf081040900000000, 0x95e6b8b100000000, + 0x7b490da300000000, 0x1e2eb11b00000000, 0x483ed24300000000, + 0x2d596efb00000000, 0xc3f6dbe900000000, 0xa691675100000000, + 0x1fa9b0cc00000000, 0x7ace0c7400000000, 0x9461b96600000000, + 0xf10605de00000000}, + {0x0000000000000000, 0xb029603d00000000, 0x6053c07a00000000, + 0xd07aa04700000000, 0xc0a680f500000000, 0x708fe0c800000000, + 0xa0f5408f00000000, 0x10dc20b200000000, 0xc14b703000000000, + 0x7162100d00000000, 0xa118b04a00000000, 0x1131d07700000000, + 0x01edf0c500000000, 0xb1c490f800000000, 0x61be30bf00000000, + 0xd197508200000000, 0x8297e06000000000, 0x32be805d00000000, + 0xe2c4201a00000000, 0x52ed402700000000, 0x4231609500000000, + 0xf21800a800000000, 0x2262a0ef00000000, 0x924bc0d200000000, + 0x43dc905000000000, 0xf3f5f06d00000000, 0x238f502a00000000, + 0x93a6301700000000, 0x837a10a500000000, 0x3353709800000000, + 0xe329d0df00000000, 0x5300b0e200000000, 0x042fc1c100000000, + 0xb406a1fc00000000, 0x647c01bb00000000, 0xd455618600000000, + 0xc489413400000000, 0x74a0210900000000, 0xa4da814e00000000, + 0x14f3e17300000000, 0xc564b1f100000000, 0x754dd1cc00000000, + 0xa537718b00000000, 0x151e11b600000000, 0x05c2310400000000, + 0xb5eb513900000000, 0x6591f17e00000000, 0xd5b8914300000000, + 0x86b821a100000000, 0x3691419c00000000, 0xe6ebe1db00000000, + 0x56c281e600000000, 0x461ea15400000000, 0xf637c16900000000, + 0x264d612e00000000, 0x9664011300000000, 0x47f3519100000000, + 0xf7da31ac00000000, 0x27a091eb00000000, 0x9789f1d600000000, + 0x8755d16400000000, 0x377cb15900000000, 0xe706111e00000000, + 0x572f712300000000, 0x4958f35800000000, 0xf971936500000000, + 0x290b332200000000, 0x9922531f00000000, 0x89fe73ad00000000, + 0x39d7139000000000, 0xe9adb3d700000000, 0x5984d3ea00000000, + 0x8813836800000000, 0x383ae35500000000, 0xe840431200000000, + 0x5869232f00000000, 0x48b5039d00000000, 0xf89c63a000000000, + 0x28e6c3e700000000, 0x98cfa3da00000000, 0xcbcf133800000000, + 0x7be6730500000000, 0xab9cd34200000000, 0x1bb5b37f00000000, + 0x0b6993cd00000000, 0xbb40f3f000000000, 0x6b3a53b700000000, + 0xdb13338a00000000, 0x0a84630800000000, 0xbaad033500000000, + 0x6ad7a37200000000, 0xdafec34f00000000, 0xca22e3fd00000000, + 0x7a0b83c000000000, 0xaa71238700000000, 0x1a5843ba00000000, + 0x4d77329900000000, 0xfd5e52a400000000, 0x2d24f2e300000000, + 0x9d0d92de00000000, 0x8dd1b26c00000000, 0x3df8d25100000000, + 0xed82721600000000, 0x5dab122b00000000, 0x8c3c42a900000000, + 0x3c15229400000000, 0xec6f82d300000000, 0x5c46e2ee00000000, + 0x4c9ac25c00000000, 0xfcb3a26100000000, 0x2cc9022600000000, + 0x9ce0621b00000000, 0xcfe0d2f900000000, 0x7fc9b2c400000000, + 0xafb3128300000000, 0x1f9a72be00000000, 0x0f46520c00000000, + 0xbf6f323100000000, 0x6f15927600000000, 0xdf3cf24b00000000, + 0x0eaba2c900000000, 0xbe82c2f400000000, 0x6ef862b300000000, + 0xded1028e00000000, 0xce0d223c00000000, 0x7e24420100000000, + 0xae5ee24600000000, 0x1e77827b00000000, 0x92b0e6b100000000, + 0x2299868c00000000, 0xf2e326cb00000000, 0x42ca46f600000000, + 0x5216664400000000, 0xe23f067900000000, 0x3245a63e00000000, + 0x826cc60300000000, 0x53fb968100000000, 0xe3d2f6bc00000000, + 0x33a856fb00000000, 0x838136c600000000, 0x935d167400000000, + 0x2374764900000000, 0xf30ed60e00000000, 0x4327b63300000000, + 0x102706d100000000, 0xa00e66ec00000000, 0x7074c6ab00000000, + 0xc05da69600000000, 0xd081862400000000, 0x60a8e61900000000, + 0xb0d2465e00000000, 0x00fb266300000000, 0xd16c76e100000000, + 0x614516dc00000000, 0xb13fb69b00000000, 0x0116d6a600000000, + 0x11caf61400000000, 0xa1e3962900000000, 0x7199366e00000000, + 0xc1b0565300000000, 0x969f277000000000, 0x26b6474d00000000, + 0xf6cce70a00000000, 0x46e5873700000000, 0x5639a78500000000, + 0xe610c7b800000000, 0x366a67ff00000000, 0x864307c200000000, + 0x57d4574000000000, 0xe7fd377d00000000, 0x3787973a00000000, + 0x87aef70700000000, 0x9772d7b500000000, 0x275bb78800000000, + 0xf72117cf00000000, 0x470877f200000000, 0x1408c71000000000, + 0xa421a72d00000000, 0x745b076a00000000, 0xc472675700000000, + 0xd4ae47e500000000, 0x648727d800000000, 0xb4fd879f00000000, + 0x04d4e7a200000000, 0xd543b72000000000, 0x656ad71d00000000, + 0xb510775a00000000, 0x0539176700000000, 0x15e537d500000000, + 0xa5cc57e800000000, 0x75b6f7af00000000, 0xc59f979200000000, + 0xdbe815e900000000, 0x6bc175d400000000, 0xbbbbd59300000000, + 0x0b92b5ae00000000, 0x1b4e951c00000000, 0xab67f52100000000, + 0x7b1d556600000000, 0xcb34355b00000000, 0x1aa365d900000000, + 0xaa8a05e400000000, 0x7af0a5a300000000, 0xcad9c59e00000000, + 0xda05e52c00000000, 0x6a2c851100000000, 0xba56255600000000, + 0x0a7f456b00000000, 0x597ff58900000000, 0xe95695b400000000, + 0x392c35f300000000, 0x890555ce00000000, 0x99d9757c00000000, + 0x29f0154100000000, 0xf98ab50600000000, 0x49a3d53b00000000, + 0x983485b900000000, 0x281de58400000000, 0xf86745c300000000, + 0x484e25fe00000000, 0x5892054c00000000, 0xe8bb657100000000, + 0x38c1c53600000000, 0x88e8a50b00000000, 0xdfc7d42800000000, + 0x6feeb41500000000, 0xbf94145200000000, 0x0fbd746f00000000, + 0x1f6154dd00000000, 0xaf4834e000000000, 0x7f3294a700000000, + 0xcf1bf49a00000000, 0x1e8ca41800000000, 0xaea5c42500000000, + 0x7edf646200000000, 0xcef6045f00000000, 0xde2a24ed00000000, + 0x6e0344d000000000, 0xbe79e49700000000, 0x0e5084aa00000000, + 0x5d50344800000000, 0xed79547500000000, 0x3d03f43200000000, + 0x8d2a940f00000000, 0x9df6b4bd00000000, 0x2ddfd48000000000, + 0xfda574c700000000, 0x4d8c14fa00000000, 0x9c1b447800000000, + 0x2c32244500000000, 0xfc48840200000000, 0x4c61e43f00000000, + 0x5cbdc48d00000000, 0xec94a4b000000000, 0x3cee04f700000000, + 0x8cc764ca00000000}, + {0x0000000000000000, 0xa5d35ccb00000000, 0x0ba1c84d00000000, + 0xae72948600000000, 0x1642919b00000000, 0xb391cd5000000000, + 0x1de359d600000000, 0xb830051d00000000, 0x6d8253ec00000000, + 0xc8510f2700000000, 0x66239ba100000000, 0xc3f0c76a00000000, + 0x7bc0c27700000000, 0xde139ebc00000000, 0x70610a3a00000000, + 0xd5b256f100000000, 0x9b02d60300000000, 0x3ed18ac800000000, + 0x90a31e4e00000000, 0x3570428500000000, 0x8d40479800000000, + 0x28931b5300000000, 0x86e18fd500000000, 0x2332d31e00000000, + 0xf68085ef00000000, 0x5353d92400000000, 0xfd214da200000000, + 0x58f2116900000000, 0xe0c2147400000000, 0x451148bf00000000, + 0xeb63dc3900000000, 0x4eb080f200000000, 0x3605ac0700000000, + 0x93d6f0cc00000000, 0x3da4644a00000000, 0x9877388100000000, + 0x20473d9c00000000, 0x8594615700000000, 0x2be6f5d100000000, + 0x8e35a91a00000000, 0x5b87ffeb00000000, 0xfe54a32000000000, + 0x502637a600000000, 0xf5f56b6d00000000, 0x4dc56e7000000000, + 0xe81632bb00000000, 0x4664a63d00000000, 0xe3b7faf600000000, + 0xad077a0400000000, 0x08d426cf00000000, 0xa6a6b24900000000, + 0x0375ee8200000000, 0xbb45eb9f00000000, 0x1e96b75400000000, + 0xb0e423d200000000, 0x15377f1900000000, 0xc08529e800000000, + 0x6556752300000000, 0xcb24e1a500000000, 0x6ef7bd6e00000000, + 0xd6c7b87300000000, 0x7314e4b800000000, 0xdd66703e00000000, + 0x78b52cf500000000, 0x6c0a580f00000000, 0xc9d904c400000000, + 0x67ab904200000000, 0xc278cc8900000000, 0x7a48c99400000000, + 0xdf9b955f00000000, 0x71e901d900000000, 0xd43a5d1200000000, + 0x01880be300000000, 0xa45b572800000000, 0x0a29c3ae00000000, + 0xaffa9f6500000000, 0x17ca9a7800000000, 0xb219c6b300000000, + 0x1c6b523500000000, 0xb9b80efe00000000, 0xf7088e0c00000000, + 0x52dbd2c700000000, 0xfca9464100000000, 0x597a1a8a00000000, + 0xe14a1f9700000000, 0x4499435c00000000, 0xeaebd7da00000000, + 0x4f388b1100000000, 0x9a8adde000000000, 0x3f59812b00000000, + 0x912b15ad00000000, 0x34f8496600000000, 0x8cc84c7b00000000, + 0x291b10b000000000, 0x8769843600000000, 0x22bad8fd00000000, + 0x5a0ff40800000000, 0xffdca8c300000000, 0x51ae3c4500000000, + 0xf47d608e00000000, 0x4c4d659300000000, 0xe99e395800000000, + 0x47ecadde00000000, 0xe23ff11500000000, 0x378da7e400000000, + 0x925efb2f00000000, 0x3c2c6fa900000000, 0x99ff336200000000, + 0x21cf367f00000000, 0x841c6ab400000000, 0x2a6efe3200000000, + 0x8fbda2f900000000, 0xc10d220b00000000, 0x64de7ec000000000, + 0xcaacea4600000000, 0x6f7fb68d00000000, 0xd74fb39000000000, + 0x729cef5b00000000, 0xdcee7bdd00000000, 0x793d271600000000, + 0xac8f71e700000000, 0x095c2d2c00000000, 0xa72eb9aa00000000, + 0x02fde56100000000, 0xbacde07c00000000, 0x1f1ebcb700000000, + 0xb16c283100000000, 0x14bf74fa00000000, 0xd814b01e00000000, + 0x7dc7ecd500000000, 0xd3b5785300000000, 0x7666249800000000, + 0xce56218500000000, 0x6b857d4e00000000, 0xc5f7e9c800000000, + 0x6024b50300000000, 0xb596e3f200000000, 0x1045bf3900000000, + 0xbe372bbf00000000, 0x1be4777400000000, 0xa3d4726900000000, + 0x06072ea200000000, 0xa875ba2400000000, 0x0da6e6ef00000000, + 0x4316661d00000000, 0xe6c53ad600000000, 0x48b7ae5000000000, + 0xed64f29b00000000, 0x5554f78600000000, 0xf087ab4d00000000, + 0x5ef53fcb00000000, 0xfb26630000000000, 0x2e9435f100000000, + 0x8b47693a00000000, 0x2535fdbc00000000, 0x80e6a17700000000, + 0x38d6a46a00000000, 0x9d05f8a100000000, 0x33776c2700000000, + 0x96a430ec00000000, 0xee111c1900000000, 0x4bc240d200000000, + 0xe5b0d45400000000, 0x4063889f00000000, 0xf8538d8200000000, + 0x5d80d14900000000, 0xf3f245cf00000000, 0x5621190400000000, + 0x83934ff500000000, 0x2640133e00000000, 0x883287b800000000, + 0x2de1db7300000000, 0x95d1de6e00000000, 0x300282a500000000, + 0x9e70162300000000, 0x3ba34ae800000000, 0x7513ca1a00000000, + 0xd0c096d100000000, 0x7eb2025700000000, 0xdb615e9c00000000, + 0x63515b8100000000, 0xc682074a00000000, 0x68f093cc00000000, + 0xcd23cf0700000000, 0x189199f600000000, 0xbd42c53d00000000, + 0x133051bb00000000, 0xb6e30d7000000000, 0x0ed3086d00000000, + 0xab0054a600000000, 0x0572c02000000000, 0xa0a19ceb00000000, + 0xb41ee81100000000, 0x11cdb4da00000000, 0xbfbf205c00000000, + 0x1a6c7c9700000000, 0xa25c798a00000000, 0x078f254100000000, + 0xa9fdb1c700000000, 0x0c2eed0c00000000, 0xd99cbbfd00000000, + 0x7c4fe73600000000, 0xd23d73b000000000, 0x77ee2f7b00000000, + 0xcfde2a6600000000, 0x6a0d76ad00000000, 0xc47fe22b00000000, + 0x61acbee000000000, 0x2f1c3e1200000000, 0x8acf62d900000000, + 0x24bdf65f00000000, 0x816eaa9400000000, 0x395eaf8900000000, + 0x9c8df34200000000, 0x32ff67c400000000, 0x972c3b0f00000000, + 0x429e6dfe00000000, 0xe74d313500000000, 0x493fa5b300000000, + 0xececf97800000000, 0x54dcfc6500000000, 0xf10fa0ae00000000, + 0x5f7d342800000000, 0xfaae68e300000000, 0x821b441600000000, + 0x27c818dd00000000, 0x89ba8c5b00000000, 0x2c69d09000000000, + 0x9459d58d00000000, 0x318a894600000000, 0x9ff81dc000000000, + 0x3a2b410b00000000, 0xef9917fa00000000, 0x4a4a4b3100000000, + 0xe438dfb700000000, 0x41eb837c00000000, 0xf9db866100000000, + 0x5c08daaa00000000, 0xf27a4e2c00000000, 0x57a912e700000000, + 0x1919921500000000, 0xbccacede00000000, 0x12b85a5800000000, + 0xb76b069300000000, 0x0f5b038e00000000, 0xaa885f4500000000, + 0x04facbc300000000, 0xa129970800000000, 0x749bc1f900000000, + 0xd1489d3200000000, 0x7f3a09b400000000, 0xdae9557f00000000, + 0x62d9506200000000, 0xc70a0ca900000000, 0x6978982f00000000, + 0xccabc4e400000000}, + {0x0000000000000000, 0xb40b77a600000000, 0x29119f9700000000, + 0x9d1ae83100000000, 0x13244ff400000000, 0xa72f385200000000, + 0x3a35d06300000000, 0x8e3ea7c500000000, 0x674eef3300000000, + 0xd345989500000000, 0x4e5f70a400000000, 0xfa54070200000000, + 0x746aa0c700000000, 0xc061d76100000000, 0x5d7b3f5000000000, + 0xe97048f600000000, 0xce9cde6700000000, 0x7a97a9c100000000, + 0xe78d41f000000000, 0x5386365600000000, 0xddb8919300000000, + 0x69b3e63500000000, 0xf4a90e0400000000, 0x40a279a200000000, + 0xa9d2315400000000, 0x1dd946f200000000, 0x80c3aec300000000, + 0x34c8d96500000000, 0xbaf67ea000000000, 0x0efd090600000000, + 0x93e7e13700000000, 0x27ec969100000000, 0x9c39bdcf00000000, + 0x2832ca6900000000, 0xb528225800000000, 0x012355fe00000000, + 0x8f1df23b00000000, 0x3b16859d00000000, 0xa60c6dac00000000, + 0x12071a0a00000000, 0xfb7752fc00000000, 0x4f7c255a00000000, + 0xd266cd6b00000000, 0x666dbacd00000000, 0xe8531d0800000000, + 0x5c586aae00000000, 0xc142829f00000000, 0x7549f53900000000, + 0x52a563a800000000, 0xe6ae140e00000000, 0x7bb4fc3f00000000, + 0xcfbf8b9900000000, 0x41812c5c00000000, 0xf58a5bfa00000000, + 0x6890b3cb00000000, 0xdc9bc46d00000000, 0x35eb8c9b00000000, + 0x81e0fb3d00000000, 0x1cfa130c00000000, 0xa8f164aa00000000, + 0x26cfc36f00000000, 0x92c4b4c900000000, 0x0fde5cf800000000, + 0xbbd52b5e00000000, 0x79750b4400000000, 0xcd7e7ce200000000, + 0x506494d300000000, 0xe46fe37500000000, 0x6a5144b000000000, + 0xde5a331600000000, 0x4340db2700000000, 0xf74bac8100000000, + 0x1e3be47700000000, 0xaa3093d100000000, 0x372a7be000000000, + 0x83210c4600000000, 0x0d1fab8300000000, 0xb914dc2500000000, + 0x240e341400000000, 0x900543b200000000, 0xb7e9d52300000000, + 0x03e2a28500000000, 0x9ef84ab400000000, 0x2af33d1200000000, + 0xa4cd9ad700000000, 0x10c6ed7100000000, 0x8ddc054000000000, + 0x39d772e600000000, 0xd0a73a1000000000, 0x64ac4db600000000, + 0xf9b6a58700000000, 0x4dbdd22100000000, 0xc38375e400000000, + 0x7788024200000000, 0xea92ea7300000000, 0x5e999dd500000000, + 0xe54cb68b00000000, 0x5147c12d00000000, 0xcc5d291c00000000, + 0x78565eba00000000, 0xf668f97f00000000, 0x42638ed900000000, + 0xdf7966e800000000, 0x6b72114e00000000, 0x820259b800000000, + 0x36092e1e00000000, 0xab13c62f00000000, 0x1f18b18900000000, + 0x9126164c00000000, 0x252d61ea00000000, 0xb83789db00000000, + 0x0c3cfe7d00000000, 0x2bd068ec00000000, 0x9fdb1f4a00000000, + 0x02c1f77b00000000, 0xb6ca80dd00000000, 0x38f4271800000000, + 0x8cff50be00000000, 0x11e5b88f00000000, 0xa5eecf2900000000, + 0x4c9e87df00000000, 0xf895f07900000000, 0x658f184800000000, + 0xd1846fee00000000, 0x5fbac82b00000000, 0xebb1bf8d00000000, + 0x76ab57bc00000000, 0xc2a0201a00000000, 0xf2ea168800000000, + 0x46e1612e00000000, 0xdbfb891f00000000, 0x6ff0feb900000000, + 0xe1ce597c00000000, 0x55c52eda00000000, 0xc8dfc6eb00000000, + 0x7cd4b14d00000000, 0x95a4f9bb00000000, 0x21af8e1d00000000, + 0xbcb5662c00000000, 0x08be118a00000000, 0x8680b64f00000000, + 0x328bc1e900000000, 0xaf9129d800000000, 0x1b9a5e7e00000000, + 0x3c76c8ef00000000, 0x887dbf4900000000, 0x1567577800000000, + 0xa16c20de00000000, 0x2f52871b00000000, 0x9b59f0bd00000000, + 0x0643188c00000000, 0xb2486f2a00000000, 0x5b3827dc00000000, + 0xef33507a00000000, 0x7229b84b00000000, 0xc622cfed00000000, + 0x481c682800000000, 0xfc171f8e00000000, 0x610df7bf00000000, + 0xd506801900000000, 0x6ed3ab4700000000, 0xdad8dce100000000, + 0x47c234d000000000, 0xf3c9437600000000, 0x7df7e4b300000000, + 0xc9fc931500000000, 0x54e67b2400000000, 0xe0ed0c8200000000, + 0x099d447400000000, 0xbd9633d200000000, 0x208cdbe300000000, + 0x9487ac4500000000, 0x1ab90b8000000000, 0xaeb27c2600000000, + 0x33a8941700000000, 0x87a3e3b100000000, 0xa04f752000000000, + 0x1444028600000000, 0x895eeab700000000, 0x3d559d1100000000, + 0xb36b3ad400000000, 0x07604d7200000000, 0x9a7aa54300000000, + 0x2e71d2e500000000, 0xc7019a1300000000, 0x730aedb500000000, + 0xee10058400000000, 0x5a1b722200000000, 0xd425d5e700000000, + 0x602ea24100000000, 0xfd344a7000000000, 0x493f3dd600000000, + 0x8b9f1dcc00000000, 0x3f946a6a00000000, 0xa28e825b00000000, + 0x1685f5fd00000000, 0x98bb523800000000, 0x2cb0259e00000000, + 0xb1aacdaf00000000, 0x05a1ba0900000000, 0xecd1f2ff00000000, + 0x58da855900000000, 0xc5c06d6800000000, 0x71cb1ace00000000, + 0xfff5bd0b00000000, 0x4bfecaad00000000, 0xd6e4229c00000000, + 0x62ef553a00000000, 0x4503c3ab00000000, 0xf108b40d00000000, + 0x6c125c3c00000000, 0xd8192b9a00000000, 0x56278c5f00000000, + 0xe22cfbf900000000, 0x7f3613c800000000, 0xcb3d646e00000000, + 0x224d2c9800000000, 0x96465b3e00000000, 0x0b5cb30f00000000, + 0xbf57c4a900000000, 0x3169636c00000000, 0x856214ca00000000, + 0x1878fcfb00000000, 0xac738b5d00000000, 0x17a6a00300000000, + 0xa3add7a500000000, 0x3eb73f9400000000, 0x8abc483200000000, + 0x0482eff700000000, 0xb089985100000000, 0x2d93706000000000, + 0x999807c600000000, 0x70e84f3000000000, 0xc4e3389600000000, + 0x59f9d0a700000000, 0xedf2a70100000000, 0x63cc00c400000000, + 0xd7c7776200000000, 0x4add9f5300000000, 0xfed6e8f500000000, + 0xd93a7e6400000000, 0x6d3109c200000000, 0xf02be1f300000000, + 0x4420965500000000, 0xca1e319000000000, 0x7e15463600000000, + 0xe30fae0700000000, 0x5704d9a100000000, 0xbe74915700000000, + 0x0a7fe6f100000000, 0x97650ec000000000, 0x236e796600000000, + 0xad50dea300000000, 0x195ba90500000000, 0x8441413400000000, + 0x304a369200000000}, + {0x0000000000000000, 0x9e00aacc00000000, 0x7d07254200000000, + 0xe3078f8e00000000, 0xfa0e4a8400000000, 0x640ee04800000000, + 0x87096fc600000000, 0x1909c50a00000000, 0xb51be5d300000000, + 0x2b1b4f1f00000000, 0xc81cc09100000000, 0x561c6a5d00000000, + 0x4f15af5700000000, 0xd115059b00000000, 0x32128a1500000000, + 0xac1220d900000000, 0x2b31bb7c00000000, 0xb53111b000000000, + 0x56369e3e00000000, 0xc83634f200000000, 0xd13ff1f800000000, + 0x4f3f5b3400000000, 0xac38d4ba00000000, 0x32387e7600000000, + 0x9e2a5eaf00000000, 0x002af46300000000, 0xe32d7bed00000000, + 0x7d2dd12100000000, 0x6424142b00000000, 0xfa24bee700000000, + 0x1923316900000000, 0x87239ba500000000, 0x566276f900000000, + 0xc862dc3500000000, 0x2b6553bb00000000, 0xb565f97700000000, + 0xac6c3c7d00000000, 0x326c96b100000000, 0xd16b193f00000000, + 0x4f6bb3f300000000, 0xe379932a00000000, 0x7d7939e600000000, + 0x9e7eb66800000000, 0x007e1ca400000000, 0x1977d9ae00000000, + 0x8777736200000000, 0x6470fcec00000000, 0xfa70562000000000, + 0x7d53cd8500000000, 0xe353674900000000, 0x0054e8c700000000, + 0x9e54420b00000000, 0x875d870100000000, 0x195d2dcd00000000, + 0xfa5aa24300000000, 0x645a088f00000000, 0xc848285600000000, + 0x5648829a00000000, 0xb54f0d1400000000, 0x2b4fa7d800000000, + 0x324662d200000000, 0xac46c81e00000000, 0x4f41479000000000, + 0xd141ed5c00000000, 0xedc29d2900000000, 0x73c237e500000000, + 0x90c5b86b00000000, 0x0ec512a700000000, 0x17ccd7ad00000000, + 0x89cc7d6100000000, 0x6acbf2ef00000000, 0xf4cb582300000000, + 0x58d978fa00000000, 0xc6d9d23600000000, 0x25de5db800000000, + 0xbbdef77400000000, 0xa2d7327e00000000, 0x3cd798b200000000, + 0xdfd0173c00000000, 0x41d0bdf000000000, 0xc6f3265500000000, + 0x58f38c9900000000, 0xbbf4031700000000, 0x25f4a9db00000000, + 0x3cfd6cd100000000, 0xa2fdc61d00000000, 0x41fa499300000000, + 0xdffae35f00000000, 0x73e8c38600000000, 0xede8694a00000000, + 0x0eefe6c400000000, 0x90ef4c0800000000, 0x89e6890200000000, + 0x17e623ce00000000, 0xf4e1ac4000000000, 0x6ae1068c00000000, + 0xbba0ebd000000000, 0x25a0411c00000000, 0xc6a7ce9200000000, + 0x58a7645e00000000, 0x41aea15400000000, 0xdfae0b9800000000, + 0x3ca9841600000000, 0xa2a92eda00000000, 0x0ebb0e0300000000, + 0x90bba4cf00000000, 0x73bc2b4100000000, 0xedbc818d00000000, + 0xf4b5448700000000, 0x6ab5ee4b00000000, 0x89b261c500000000, + 0x17b2cb0900000000, 0x909150ac00000000, 0x0e91fa6000000000, + 0xed9675ee00000000, 0x7396df2200000000, 0x6a9f1a2800000000, + 0xf49fb0e400000000, 0x17983f6a00000000, 0x899895a600000000, + 0x258ab57f00000000, 0xbb8a1fb300000000, 0x588d903d00000000, + 0xc68d3af100000000, 0xdf84fffb00000000, 0x4184553700000000, + 0xa283dab900000000, 0x3c83707500000000, 0xda853b5300000000, + 0x4485919f00000000, 0xa7821e1100000000, 0x3982b4dd00000000, + 0x208b71d700000000, 0xbe8bdb1b00000000, 0x5d8c549500000000, + 0xc38cfe5900000000, 0x6f9ede8000000000, 0xf19e744c00000000, + 0x1299fbc200000000, 0x8c99510e00000000, 0x9590940400000000, + 0x0b903ec800000000, 0xe897b14600000000, 0x76971b8a00000000, + 0xf1b4802f00000000, 0x6fb42ae300000000, 0x8cb3a56d00000000, + 0x12b30fa100000000, 0x0bbacaab00000000, 0x95ba606700000000, + 0x76bdefe900000000, 0xe8bd452500000000, 0x44af65fc00000000, + 0xdaafcf3000000000, 0x39a840be00000000, 0xa7a8ea7200000000, + 0xbea12f7800000000, 0x20a185b400000000, 0xc3a60a3a00000000, + 0x5da6a0f600000000, 0x8ce74daa00000000, 0x12e7e76600000000, + 0xf1e068e800000000, 0x6fe0c22400000000, 0x76e9072e00000000, + 0xe8e9ade200000000, 0x0bee226c00000000, 0x95ee88a000000000, + 0x39fca87900000000, 0xa7fc02b500000000, 0x44fb8d3b00000000, + 0xdafb27f700000000, 0xc3f2e2fd00000000, 0x5df2483100000000, + 0xbef5c7bf00000000, 0x20f56d7300000000, 0xa7d6f6d600000000, + 0x39d65c1a00000000, 0xdad1d39400000000, 0x44d1795800000000, + 0x5dd8bc5200000000, 0xc3d8169e00000000, 0x20df991000000000, + 0xbedf33dc00000000, 0x12cd130500000000, 0x8ccdb9c900000000, + 0x6fca364700000000, 0xf1ca9c8b00000000, 0xe8c3598100000000, + 0x76c3f34d00000000, 0x95c47cc300000000, 0x0bc4d60f00000000, + 0x3747a67a00000000, 0xa9470cb600000000, 0x4a40833800000000, + 0xd44029f400000000, 0xcd49ecfe00000000, 0x5349463200000000, + 0xb04ec9bc00000000, 0x2e4e637000000000, 0x825c43a900000000, + 0x1c5ce96500000000, 0xff5b66eb00000000, 0x615bcc2700000000, + 0x7852092d00000000, 0xe652a3e100000000, 0x05552c6f00000000, + 0x9b5586a300000000, 0x1c761d0600000000, 0x8276b7ca00000000, + 0x6171384400000000, 0xff71928800000000, 0xe678578200000000, + 0x7878fd4e00000000, 0x9b7f72c000000000, 0x057fd80c00000000, + 0xa96df8d500000000, 0x376d521900000000, 0xd46add9700000000, + 0x4a6a775b00000000, 0x5363b25100000000, 0xcd63189d00000000, + 0x2e64971300000000, 0xb0643ddf00000000, 0x6125d08300000000, + 0xff257a4f00000000, 0x1c22f5c100000000, 0x82225f0d00000000, + 0x9b2b9a0700000000, 0x052b30cb00000000, 0xe62cbf4500000000, + 0x782c158900000000, 0xd43e355000000000, 0x4a3e9f9c00000000, + 0xa939101200000000, 0x3739bade00000000, 0x2e307fd400000000, + 0xb030d51800000000, 0x53375a9600000000, 0xcd37f05a00000000, + 0x4a146bff00000000, 0xd414c13300000000, 0x37134ebd00000000, + 0xa913e47100000000, 0xb01a217b00000000, 0x2e1a8bb700000000, + 0xcd1d043900000000, 0x531daef500000000, 0xff0f8e2c00000000, + 0x610f24e000000000, 0x8208ab6e00000000, 0x1c0801a200000000, + 0x0501c4a800000000, 0x9b016e6400000000, 0x7806e1ea00000000, + 0xe6064b2600000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, + 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, + 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, + 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, + 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, + 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, + 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, + 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, + 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, + 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, + 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, + 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, + 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, + 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, + 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, + 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, + 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, + 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, + 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, + 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, + 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, + 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, + 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, + 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, + 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, + 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, + 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, + 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, + 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, + 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, + 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, + 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, + 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, + 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, + 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, + 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, + 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, + 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, + 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, + 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, + 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, + 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, + 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, + 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, + 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, + 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, + 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, + 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, + 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, + 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, + 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, + 0xde0506f1}, + {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, + 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, + 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, + 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, + 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, + 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, + 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, + 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, + 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, + 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, + 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, + 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, + 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, + 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, + 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, + 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, + 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, + 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, + 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, + 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, + 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, + 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, + 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, + 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, + 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, + 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, + 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, + 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, + 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, + 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, + 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, + 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, + 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, + 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, + 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, + 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, + 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, + 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, + 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, + 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, + 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, + 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, + 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, + 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, + 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, + 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, + 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, + 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, + 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, + 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, + 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, + 0xbe9834ed}, + {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, + 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, + 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, + 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, + 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, + 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, + 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, + 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, + 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, + 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, + 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, + 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, + 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, + 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, + 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, + 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, + 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, + 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, + 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, + 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, + 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, + 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, + 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, + 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, + 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, + 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, + 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, + 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, + 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, + 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, + 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, + 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, + 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, + 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, + 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, + 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, + 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, + 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, + 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, + 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, + 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, + 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, + 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, + 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, + 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, + 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, + 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, + 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, + 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, + 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, + 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, + 0x9324fd72}, + {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, + 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, + 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, + 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, + 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, + 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, + 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, + 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, + 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, + 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, + 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, + 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, + 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, + 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, + 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, + 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, + 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, + 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, + 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, + 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, + 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, + 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, + 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, + 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, + 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, + 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, + 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, + 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, + 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, + 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, + 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, + 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, + 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, + 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, + 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, + 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, + 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, + 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, + 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, + 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, + 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, + 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, + 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, + 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, + 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, + 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, + 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, + 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, + 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, + 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, + 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, + 0x8def022d}, + {0x00000000, 0x41311b19, 0x82623632, 0xc3532d2b, 0x04c56c64, + 0x45f4777d, 0x86a75a56, 0xc796414f, 0x088ad9c8, 0x49bbc2d1, + 0x8ae8effa, 0xcbd9f4e3, 0x0c4fb5ac, 0x4d7eaeb5, 0x8e2d839e, + 0xcf1c9887, 0x5112c24a, 0x1023d953, 0xd370f478, 0x9241ef61, + 0x55d7ae2e, 0x14e6b537, 0xd7b5981c, 0x96848305, 0x59981b82, + 0x18a9009b, 0xdbfa2db0, 0x9acb36a9, 0x5d5d77e6, 0x1c6c6cff, + 0xdf3f41d4, 0x9e0e5acd, 0xa2248495, 0xe3159f8c, 0x2046b2a7, + 0x6177a9be, 0xa6e1e8f1, 0xe7d0f3e8, 0x2483dec3, 0x65b2c5da, + 0xaaae5d5d, 0xeb9f4644, 0x28cc6b6f, 0x69fd7076, 0xae6b3139, + 0xef5a2a20, 0x2c09070b, 0x6d381c12, 0xf33646df, 0xb2075dc6, + 0x715470ed, 0x30656bf4, 0xf7f32abb, 0xb6c231a2, 0x75911c89, + 0x34a00790, 0xfbbc9f17, 0xba8d840e, 0x79dea925, 0x38efb23c, + 0xff79f373, 0xbe48e86a, 0x7d1bc541, 0x3c2ade58, 0x054f79f0, + 0x447e62e9, 0x872d4fc2, 0xc61c54db, 0x018a1594, 0x40bb0e8d, + 0x83e823a6, 0xc2d938bf, 0x0dc5a038, 0x4cf4bb21, 0x8fa7960a, + 0xce968d13, 0x0900cc5c, 0x4831d745, 0x8b62fa6e, 0xca53e177, + 0x545dbbba, 0x156ca0a3, 0xd63f8d88, 0x970e9691, 0x5098d7de, + 0x11a9ccc7, 0xd2fae1ec, 0x93cbfaf5, 0x5cd76272, 0x1de6796b, + 0xdeb55440, 0x9f844f59, 0x58120e16, 0x1923150f, 0xda703824, + 0x9b41233d, 0xa76bfd65, 0xe65ae67c, 0x2509cb57, 0x6438d04e, + 0xa3ae9101, 0xe29f8a18, 0x21cca733, 0x60fdbc2a, 0xafe124ad, + 0xeed03fb4, 0x2d83129f, 0x6cb20986, 0xab2448c9, 0xea1553d0, + 0x29467efb, 0x687765e2, 0xf6793f2f, 0xb7482436, 0x741b091d, + 0x352a1204, 0xf2bc534b, 0xb38d4852, 0x70de6579, 0x31ef7e60, + 0xfef3e6e7, 0xbfc2fdfe, 0x7c91d0d5, 0x3da0cbcc, 0xfa368a83, + 0xbb07919a, 0x7854bcb1, 0x3965a7a8, 0x4b98833b, 0x0aa99822, + 0xc9fab509, 0x88cbae10, 0x4f5def5f, 0x0e6cf446, 0xcd3fd96d, + 0x8c0ec274, 0x43125af3, 0x022341ea, 0xc1706cc1, 0x804177d8, + 0x47d73697, 0x06e62d8e, 0xc5b500a5, 0x84841bbc, 0x1a8a4171, + 0x5bbb5a68, 0x98e87743, 0xd9d96c5a, 0x1e4f2d15, 0x5f7e360c, + 0x9c2d1b27, 0xdd1c003e, 0x120098b9, 0x533183a0, 0x9062ae8b, + 0xd153b592, 0x16c5f4dd, 0x57f4efc4, 0x94a7c2ef, 0xd596d9f6, + 0xe9bc07ae, 0xa88d1cb7, 0x6bde319c, 0x2aef2a85, 0xed796bca, + 0xac4870d3, 0x6f1b5df8, 0x2e2a46e1, 0xe136de66, 0xa007c57f, + 0x6354e854, 0x2265f34d, 0xe5f3b202, 0xa4c2a91b, 0x67918430, + 0x26a09f29, 0xb8aec5e4, 0xf99fdefd, 0x3accf3d6, 0x7bfde8cf, + 0xbc6ba980, 0xfd5ab299, 0x3e099fb2, 0x7f3884ab, 0xb0241c2c, + 0xf1150735, 0x32462a1e, 0x73773107, 0xb4e17048, 0xf5d06b51, + 0x3683467a, 0x77b25d63, 0x4ed7facb, 0x0fe6e1d2, 0xccb5ccf9, + 0x8d84d7e0, 0x4a1296af, 0x0b238db6, 0xc870a09d, 0x8941bb84, + 0x465d2303, 0x076c381a, 0xc43f1531, 0x850e0e28, 0x42984f67, + 0x03a9547e, 0xc0fa7955, 0x81cb624c, 0x1fc53881, 0x5ef42398, + 0x9da70eb3, 0xdc9615aa, 0x1b0054e5, 0x5a314ffc, 0x996262d7, + 0xd85379ce, 0x174fe149, 0x567efa50, 0x952dd77b, 0xd41ccc62, + 0x138a8d2d, 0x52bb9634, 0x91e8bb1f, 0xd0d9a006, 0xecf37e5e, + 0xadc26547, 0x6e91486c, 0x2fa05375, 0xe836123a, 0xa9070923, + 0x6a542408, 0x2b653f11, 0xe479a796, 0xa548bc8f, 0x661b91a4, + 0x272a8abd, 0xe0bccbf2, 0xa18dd0eb, 0x62defdc0, 0x23efe6d9, + 0xbde1bc14, 0xfcd0a70d, 0x3f838a26, 0x7eb2913f, 0xb924d070, + 0xf815cb69, 0x3b46e642, 0x7a77fd5b, 0xb56b65dc, 0xf45a7ec5, + 0x370953ee, 0x763848f7, 0xb1ae09b8, 0xf09f12a1, 0x33cc3f8a, + 0x72fd2493}, + {0x00000000, 0x376ac201, 0x6ed48403, 0x59be4602, 0xdca80907, + 0xebc2cb06, 0xb27c8d04, 0x85164f05, 0xb851130e, 0x8f3bd10f, + 0xd685970d, 0xe1ef550c, 0x64f91a09, 0x5393d808, 0x0a2d9e0a, + 0x3d475c0b, 0x70a3261c, 0x47c9e41d, 0x1e77a21f, 0x291d601e, + 0xac0b2f1b, 0x9b61ed1a, 0xc2dfab18, 0xf5b56919, 0xc8f23512, + 0xff98f713, 0xa626b111, 0x914c7310, 0x145a3c15, 0x2330fe14, + 0x7a8eb816, 0x4de47a17, 0xe0464d38, 0xd72c8f39, 0x8e92c93b, + 0xb9f80b3a, 0x3cee443f, 0x0b84863e, 0x523ac03c, 0x6550023d, + 0x58175e36, 0x6f7d9c37, 0x36c3da35, 0x01a91834, 0x84bf5731, + 0xb3d59530, 0xea6bd332, 0xdd011133, 0x90e56b24, 0xa78fa925, + 0xfe31ef27, 0xc95b2d26, 0x4c4d6223, 0x7b27a022, 0x2299e620, + 0x15f32421, 0x28b4782a, 0x1fdeba2b, 0x4660fc29, 0x710a3e28, + 0xf41c712d, 0xc376b32c, 0x9ac8f52e, 0xada2372f, 0xc08d9a70, + 0xf7e75871, 0xae591e73, 0x9933dc72, 0x1c259377, 0x2b4f5176, + 0x72f11774, 0x459bd575, 0x78dc897e, 0x4fb64b7f, 0x16080d7d, + 0x2162cf7c, 0xa4748079, 0x931e4278, 0xcaa0047a, 0xfdcac67b, + 0xb02ebc6c, 0x87447e6d, 0xdefa386f, 0xe990fa6e, 0x6c86b56b, + 0x5bec776a, 0x02523168, 0x3538f369, 0x087faf62, 0x3f156d63, + 0x66ab2b61, 0x51c1e960, 0xd4d7a665, 0xe3bd6464, 0xba032266, + 0x8d69e067, 0x20cbd748, 0x17a11549, 0x4e1f534b, 0x7975914a, + 0xfc63de4f, 0xcb091c4e, 0x92b75a4c, 0xa5dd984d, 0x989ac446, + 0xaff00647, 0xf64e4045, 0xc1248244, 0x4432cd41, 0x73580f40, + 0x2ae64942, 0x1d8c8b43, 0x5068f154, 0x67023355, 0x3ebc7557, + 0x09d6b756, 0x8cc0f853, 0xbbaa3a52, 0xe2147c50, 0xd57ebe51, + 0xe839e25a, 0xdf53205b, 0x86ed6659, 0xb187a458, 0x3491eb5d, + 0x03fb295c, 0x5a456f5e, 0x6d2fad5f, 0x801b35e1, 0xb771f7e0, + 0xeecfb1e2, 0xd9a573e3, 0x5cb33ce6, 0x6bd9fee7, 0x3267b8e5, + 0x050d7ae4, 0x384a26ef, 0x0f20e4ee, 0x569ea2ec, 0x61f460ed, + 0xe4e22fe8, 0xd388ede9, 0x8a36abeb, 0xbd5c69ea, 0xf0b813fd, + 0xc7d2d1fc, 0x9e6c97fe, 0xa90655ff, 0x2c101afa, 0x1b7ad8fb, + 0x42c49ef9, 0x75ae5cf8, 0x48e900f3, 0x7f83c2f2, 0x263d84f0, + 0x115746f1, 0x944109f4, 0xa32bcbf5, 0xfa958df7, 0xcdff4ff6, + 0x605d78d9, 0x5737bad8, 0x0e89fcda, 0x39e33edb, 0xbcf571de, + 0x8b9fb3df, 0xd221f5dd, 0xe54b37dc, 0xd80c6bd7, 0xef66a9d6, + 0xb6d8efd4, 0x81b22dd5, 0x04a462d0, 0x33cea0d1, 0x6a70e6d3, + 0x5d1a24d2, 0x10fe5ec5, 0x27949cc4, 0x7e2adac6, 0x494018c7, + 0xcc5657c2, 0xfb3c95c3, 0xa282d3c1, 0x95e811c0, 0xa8af4dcb, + 0x9fc58fca, 0xc67bc9c8, 0xf1110bc9, 0x740744cc, 0x436d86cd, + 0x1ad3c0cf, 0x2db902ce, 0x4096af91, 0x77fc6d90, 0x2e422b92, + 0x1928e993, 0x9c3ea696, 0xab546497, 0xf2ea2295, 0xc580e094, + 0xf8c7bc9f, 0xcfad7e9e, 0x9613389c, 0xa179fa9d, 0x246fb598, + 0x13057799, 0x4abb319b, 0x7dd1f39a, 0x3035898d, 0x075f4b8c, + 0x5ee10d8e, 0x698bcf8f, 0xec9d808a, 0xdbf7428b, 0x82490489, + 0xb523c688, 0x88649a83, 0xbf0e5882, 0xe6b01e80, 0xd1dadc81, + 0x54cc9384, 0x63a65185, 0x3a181787, 0x0d72d586, 0xa0d0e2a9, + 0x97ba20a8, 0xce0466aa, 0xf96ea4ab, 0x7c78ebae, 0x4b1229af, + 0x12ac6fad, 0x25c6adac, 0x1881f1a7, 0x2feb33a6, 0x765575a4, + 0x413fb7a5, 0xc429f8a0, 0xf3433aa1, 0xaafd7ca3, 0x9d97bea2, + 0xd073c4b5, 0xe71906b4, 0xbea740b6, 0x89cd82b7, 0x0cdbcdb2, + 0x3bb10fb3, 0x620f49b1, 0x55658bb0, 0x6822d7bb, 0x5f4815ba, + 0x06f653b8, 0x319c91b9, 0xb48adebc, 0x83e01cbd, 0xda5e5abf, + 0xed3498be}, + {0x00000000, 0x6567bcb8, 0x8bc809aa, 0xeeafb512, 0x5797628f, + 0x32f0de37, 0xdc5f6b25, 0xb938d79d, 0xef28b4c5, 0x8a4f087d, + 0x64e0bd6f, 0x018701d7, 0xb8bfd64a, 0xddd86af2, 0x3377dfe0, + 0x56106358, 0x9f571950, 0xfa30a5e8, 0x149f10fa, 0x71f8ac42, + 0xc8c07bdf, 0xada7c767, 0x43087275, 0x266fcecd, 0x707fad95, + 0x1518112d, 0xfbb7a43f, 0x9ed01887, 0x27e8cf1a, 0x428f73a2, + 0xac20c6b0, 0xc9477a08, 0x3eaf32a0, 0x5bc88e18, 0xb5673b0a, + 0xd00087b2, 0x6938502f, 0x0c5fec97, 0xe2f05985, 0x8797e53d, + 0xd1878665, 0xb4e03add, 0x5a4f8fcf, 0x3f283377, 0x8610e4ea, + 0xe3775852, 0x0dd8ed40, 0x68bf51f8, 0xa1f82bf0, 0xc49f9748, + 0x2a30225a, 0x4f579ee2, 0xf66f497f, 0x9308f5c7, 0x7da740d5, + 0x18c0fc6d, 0x4ed09f35, 0x2bb7238d, 0xc518969f, 0xa07f2a27, + 0x1947fdba, 0x7c204102, 0x928ff410, 0xf7e848a8, 0x3d58149b, + 0x583fa823, 0xb6901d31, 0xd3f7a189, 0x6acf7614, 0x0fa8caac, + 0xe1077fbe, 0x8460c306, 0xd270a05e, 0xb7171ce6, 0x59b8a9f4, + 0x3cdf154c, 0x85e7c2d1, 0xe0807e69, 0x0e2fcb7b, 0x6b4877c3, + 0xa20f0dcb, 0xc768b173, 0x29c70461, 0x4ca0b8d9, 0xf5986f44, + 0x90ffd3fc, 0x7e5066ee, 0x1b37da56, 0x4d27b90e, 0x284005b6, + 0xc6efb0a4, 0xa3880c1c, 0x1ab0db81, 0x7fd76739, 0x9178d22b, + 0xf41f6e93, 0x03f7263b, 0x66909a83, 0x883f2f91, 0xed589329, + 0x546044b4, 0x3107f80c, 0xdfa84d1e, 0xbacff1a6, 0xecdf92fe, + 0x89b82e46, 0x67179b54, 0x027027ec, 0xbb48f071, 0xde2f4cc9, + 0x3080f9db, 0x55e74563, 0x9ca03f6b, 0xf9c783d3, 0x176836c1, + 0x720f8a79, 0xcb375de4, 0xae50e15c, 0x40ff544e, 0x2598e8f6, + 0x73888bae, 0x16ef3716, 0xf8408204, 0x9d273ebc, 0x241fe921, + 0x41785599, 0xafd7e08b, 0xcab05c33, 0x3bb659ed, 0x5ed1e555, + 0xb07e5047, 0xd519ecff, 0x6c213b62, 0x094687da, 0xe7e932c8, + 0x828e8e70, 0xd49eed28, 0xb1f95190, 0x5f56e482, 0x3a31583a, + 0x83098fa7, 0xe66e331f, 0x08c1860d, 0x6da63ab5, 0xa4e140bd, + 0xc186fc05, 0x2f294917, 0x4a4ef5af, 0xf3762232, 0x96119e8a, + 0x78be2b98, 0x1dd99720, 0x4bc9f478, 0x2eae48c0, 0xc001fdd2, + 0xa566416a, 0x1c5e96f7, 0x79392a4f, 0x97969f5d, 0xf2f123e5, + 0x05196b4d, 0x607ed7f5, 0x8ed162e7, 0xebb6de5f, 0x528e09c2, + 0x37e9b57a, 0xd9460068, 0xbc21bcd0, 0xea31df88, 0x8f566330, + 0x61f9d622, 0x049e6a9a, 0xbda6bd07, 0xd8c101bf, 0x366eb4ad, + 0x53090815, 0x9a4e721d, 0xff29cea5, 0x11867bb7, 0x74e1c70f, + 0xcdd91092, 0xa8beac2a, 0x46111938, 0x2376a580, 0x7566c6d8, + 0x10017a60, 0xfeaecf72, 0x9bc973ca, 0x22f1a457, 0x479618ef, + 0xa939adfd, 0xcc5e1145, 0x06ee4d76, 0x6389f1ce, 0x8d2644dc, + 0xe841f864, 0x51792ff9, 0x341e9341, 0xdab12653, 0xbfd69aeb, + 0xe9c6f9b3, 0x8ca1450b, 0x620ef019, 0x07694ca1, 0xbe519b3c, + 0xdb362784, 0x35999296, 0x50fe2e2e, 0x99b95426, 0xfcdee89e, + 0x12715d8c, 0x7716e134, 0xce2e36a9, 0xab498a11, 0x45e63f03, + 0x208183bb, 0x7691e0e3, 0x13f65c5b, 0xfd59e949, 0x983e55f1, + 0x2106826c, 0x44613ed4, 0xaace8bc6, 0xcfa9377e, 0x38417fd6, + 0x5d26c36e, 0xb389767c, 0xd6eecac4, 0x6fd61d59, 0x0ab1a1e1, + 0xe41e14f3, 0x8179a84b, 0xd769cb13, 0xb20e77ab, 0x5ca1c2b9, + 0x39c67e01, 0x80fea99c, 0xe5991524, 0x0b36a036, 0x6e511c8e, + 0xa7166686, 0xc271da3e, 0x2cde6f2c, 0x49b9d394, 0xf0810409, + 0x95e6b8b1, 0x7b490da3, 0x1e2eb11b, 0x483ed243, 0x2d596efb, + 0xc3f6dbe9, 0xa6916751, 0x1fa9b0cc, 0x7ace0c74, 0x9461b966, + 0xf10605de}}; + +#endif + +#endif + +#if N == 2 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, + 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, + 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, + 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, + 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, + 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, + 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, + 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, + 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, + 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, + 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, + 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, + 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, + 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, + 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, + 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, + 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, + 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, + 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, + 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, + 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, + 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, + 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, + 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, + 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, + 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, + 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, + 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, + 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, + 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, + 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, + 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, + 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, + 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, + 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, + 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, + 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, + 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, + 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, + 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, + 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, + 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, + 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, + 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, + 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, + 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, + 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, + 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, + 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, + 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, + 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, + 0x0d7139d7}, + {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, + 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, + 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, + 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, + 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, + 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, + 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, + 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, + 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, + 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, + 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, + 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, + 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, + 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, + 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, + 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, + 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, + 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, + 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, + 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, + 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, + 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, + 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, + 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, + 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, + 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, + 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, + 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, + 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, + 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, + 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, + 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, + 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, + 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, + 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, + 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, + 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, + 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, + 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, + 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, + 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, + 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, + 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, + 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, + 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, + 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, + 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, + 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, + 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, + 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, + 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, + 0x1c53e98a}, + {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, + 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, + 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, + 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, + 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, + 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, + 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, + 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, + 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, + 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, + 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, + 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, + 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, + 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, + 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, + 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, + 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, + 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, + 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, + 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, + 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, + 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, + 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, + 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, + 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, + 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, + 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, + 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, + 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, + 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, + 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, + 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, + 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, + 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, + 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, + 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, + 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, + 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, + 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, + 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, + 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, + 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, + 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, + 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, + 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, + 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, + 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, + 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, + 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, + 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, + 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, + 0x3f88e851}, + {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, + 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, + 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, + 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, + 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, + 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, + 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, + 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, + 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, + 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, + 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, + 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, + 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, + 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, + 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, + 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, + 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, + 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, + 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, + 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, + 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, + 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, + 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, + 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, + 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, + 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, + 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, + 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, + 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, + 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, + 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, + 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, + 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, + 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, + 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, + 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, + 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, + 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, + 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, + 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, + 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, + 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, + 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, + 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, + 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, + 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, + 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, + 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, + 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, + 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, + 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, + 0x3dee8ca6}, + {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, + 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, + 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, + 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, + 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, + 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, + 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, + 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, + 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, + 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, + 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, + 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, + 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, + 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, + 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, + 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, + 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, + 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, + 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, + 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, + 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, + 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, + 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, + 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, + 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, + 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, + 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, + 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, + 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, + 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, + 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, + 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, + 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, + 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, + 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, + 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, + 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, + 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, + 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, + 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, + 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, + 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, + 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, + 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, + 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, + 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, + 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, + 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, + 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, + 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, + 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, + 0x36197165}, + {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, + 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, + 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, + 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, + 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, + 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, + 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, + 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, + 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, + 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, + 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, + 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, + 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, + 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, + 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, + 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, + 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, + 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, + 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, + 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, + 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, + 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, + 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, + 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, + 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, + 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, + 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, + 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, + 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, + 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, + 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, + 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, + 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, + 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, + 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, + 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, + 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, + 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, + 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, + 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, + 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, + 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, + 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, + 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, + 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, + 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, + 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, + 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, + 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, + 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, + 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, + 0x1a3b93aa}, + {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, + 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, + 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, + 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, + 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, + 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, + 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, + 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, + 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, + 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, + 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, + 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, + 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, + 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, + 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, + 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, + 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, + 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, + 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, + 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, + 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, + 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, + 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, + 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, + 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, + 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, + 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, + 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, + 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, + 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, + 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, + 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, + 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, + 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, + 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, + 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, + 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, + 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, + 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, + 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, + 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, + 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, + 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, + 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, + 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, + 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, + 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, + 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, + 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, + 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, + 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, + 0xe147d714}, + {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, + 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, + 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, + 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, + 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, + 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, + 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, + 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, + 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, + 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, + 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, + 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, + 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, + 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, + 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, + 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, + 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, + 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, + 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, + 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, + 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, + 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, + 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, + 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, + 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, + 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, + 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, + 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, + 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, + 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, + 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, + 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, + 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, + 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, + 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, + 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, + 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, + 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, + 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, + 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, + 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, + 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, + 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, + 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, + 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, + 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, + 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, + 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, + 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, + 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, + 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, + 0x494f0c4b}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x43147b1700000000, 0x8628f62e00000000, + 0xc53c8d3900000000, 0x0c51ec5d00000000, 0x4f45974a00000000, + 0x8a791a7300000000, 0xc96d616400000000, 0x18a2d8bb00000000, + 0x5bb6a3ac00000000, 0x9e8a2e9500000000, 0xdd9e558200000000, + 0x14f334e600000000, 0x57e74ff100000000, 0x92dbc2c800000000, + 0xd1cfb9df00000000, 0x7142c0ac00000000, 0x3256bbbb00000000, + 0xf76a368200000000, 0xb47e4d9500000000, 0x7d132cf100000000, + 0x3e0757e600000000, 0xfb3bdadf00000000, 0xb82fa1c800000000, + 0x69e0181700000000, 0x2af4630000000000, 0xefc8ee3900000000, + 0xacdc952e00000000, 0x65b1f44a00000000, 0x26a58f5d00000000, + 0xe399026400000000, 0xa08d797300000000, 0xa382f18200000000, + 0xe0968a9500000000, 0x25aa07ac00000000, 0x66be7cbb00000000, + 0xafd31ddf00000000, 0xecc766c800000000, 0x29fbebf100000000, + 0x6aef90e600000000, 0xbb20293900000000, 0xf834522e00000000, + 0x3d08df1700000000, 0x7e1ca40000000000, 0xb771c56400000000, + 0xf465be7300000000, 0x3159334a00000000, 0x724d485d00000000, + 0xd2c0312e00000000, 0x91d44a3900000000, 0x54e8c70000000000, + 0x17fcbc1700000000, 0xde91dd7300000000, 0x9d85a66400000000, + 0x58b92b5d00000000, 0x1bad504a00000000, 0xca62e99500000000, + 0x8976928200000000, 0x4c4a1fbb00000000, 0x0f5e64ac00000000, + 0xc63305c800000000, 0x85277edf00000000, 0x401bf3e600000000, + 0x030f88f100000000, 0x070392de00000000, 0x4417e9c900000000, + 0x812b64f000000000, 0xc23f1fe700000000, 0x0b527e8300000000, + 0x4846059400000000, 0x8d7a88ad00000000, 0xce6ef3ba00000000, + 0x1fa14a6500000000, 0x5cb5317200000000, 0x9989bc4b00000000, + 0xda9dc75c00000000, 0x13f0a63800000000, 0x50e4dd2f00000000, + 0x95d8501600000000, 0xd6cc2b0100000000, 0x7641527200000000, + 0x3555296500000000, 0xf069a45c00000000, 0xb37ddf4b00000000, + 0x7a10be2f00000000, 0x3904c53800000000, 0xfc38480100000000, + 0xbf2c331600000000, 0x6ee38ac900000000, 0x2df7f1de00000000, + 0xe8cb7ce700000000, 0xabdf07f000000000, 0x62b2669400000000, + 0x21a61d8300000000, 0xe49a90ba00000000, 0xa78eebad00000000, + 0xa481635c00000000, 0xe795184b00000000, 0x22a9957200000000, + 0x61bdee6500000000, 0xa8d08f0100000000, 0xebc4f41600000000, + 0x2ef8792f00000000, 0x6dec023800000000, 0xbc23bbe700000000, + 0xff37c0f000000000, 0x3a0b4dc900000000, 0x791f36de00000000, + 0xb07257ba00000000, 0xf3662cad00000000, 0x365aa19400000000, + 0x754eda8300000000, 0xd5c3a3f000000000, 0x96d7d8e700000000, + 0x53eb55de00000000, 0x10ff2ec900000000, 0xd9924fad00000000, + 0x9a8634ba00000000, 0x5fbab98300000000, 0x1caec29400000000, + 0xcd617b4b00000000, 0x8e75005c00000000, 0x4b498d6500000000, + 0x085df67200000000, 0xc130971600000000, 0x8224ec0100000000, + 0x4718613800000000, 0x040c1a2f00000000, 0x4f00556600000000, + 0x0c142e7100000000, 0xc928a34800000000, 0x8a3cd85f00000000, + 0x4351b93b00000000, 0x0045c22c00000000, 0xc5794f1500000000, + 0x866d340200000000, 0x57a28ddd00000000, 0x14b6f6ca00000000, + 0xd18a7bf300000000, 0x929e00e400000000, 0x5bf3618000000000, + 0x18e71a9700000000, 0xdddb97ae00000000, 0x9ecfecb900000000, + 0x3e4295ca00000000, 0x7d56eedd00000000, 0xb86a63e400000000, + 0xfb7e18f300000000, 0x3213799700000000, 0x7107028000000000, + 0xb43b8fb900000000, 0xf72ff4ae00000000, 0x26e04d7100000000, + 0x65f4366600000000, 0xa0c8bb5f00000000, 0xe3dcc04800000000, + 0x2ab1a12c00000000, 0x69a5da3b00000000, 0xac99570200000000, + 0xef8d2c1500000000, 0xec82a4e400000000, 0xaf96dff300000000, + 0x6aaa52ca00000000, 0x29be29dd00000000, 0xe0d348b900000000, + 0xa3c733ae00000000, 0x66fbbe9700000000, 0x25efc58000000000, + 0xf4207c5f00000000, 0xb734074800000000, 0x72088a7100000000, + 0x311cf16600000000, 0xf871900200000000, 0xbb65eb1500000000, + 0x7e59662c00000000, 0x3d4d1d3b00000000, 0x9dc0644800000000, + 0xded41f5f00000000, 0x1be8926600000000, 0x58fce97100000000, + 0x9191881500000000, 0xd285f30200000000, 0x17b97e3b00000000, + 0x54ad052c00000000, 0x8562bcf300000000, 0xc676c7e400000000, + 0x034a4add00000000, 0x405e31ca00000000, 0x893350ae00000000, + 0xca272bb900000000, 0x0f1ba68000000000, 0x4c0fdd9700000000, + 0x4803c7b800000000, 0x0b17bcaf00000000, 0xce2b319600000000, + 0x8d3f4a8100000000, 0x44522be500000000, 0x074650f200000000, + 0xc27addcb00000000, 0x816ea6dc00000000, 0x50a11f0300000000, + 0x13b5641400000000, 0xd689e92d00000000, 0x959d923a00000000, + 0x5cf0f35e00000000, 0x1fe4884900000000, 0xdad8057000000000, + 0x99cc7e6700000000, 0x3941071400000000, 0x7a557c0300000000, + 0xbf69f13a00000000, 0xfc7d8a2d00000000, 0x3510eb4900000000, + 0x7604905e00000000, 0xb3381d6700000000, 0xf02c667000000000, + 0x21e3dfaf00000000, 0x62f7a4b800000000, 0xa7cb298100000000, + 0xe4df529600000000, 0x2db233f200000000, 0x6ea648e500000000, + 0xab9ac5dc00000000, 0xe88ebecb00000000, 0xeb81363a00000000, + 0xa8954d2d00000000, 0x6da9c01400000000, 0x2ebdbb0300000000, + 0xe7d0da6700000000, 0xa4c4a17000000000, 0x61f82c4900000000, + 0x22ec575e00000000, 0xf323ee8100000000, 0xb037959600000000, + 0x750b18af00000000, 0x361f63b800000000, 0xff7202dc00000000, + 0xbc6679cb00000000, 0x795af4f200000000, 0x3a4e8fe500000000, + 0x9ac3f69600000000, 0xd9d78d8100000000, 0x1ceb00b800000000, + 0x5fff7baf00000000, 0x96921acb00000000, 0xd58661dc00000000, + 0x10baece500000000, 0x53ae97f200000000, 0x82612e2d00000000, + 0xc175553a00000000, 0x0449d80300000000, 0x475da31400000000, + 0x8e30c27000000000, 0xcd24b96700000000, 0x0818345e00000000, + 0x4b0c4f4900000000}, + {0x0000000000000000, 0x3e6bc2ef00000000, 0x3dd0f50400000000, + 0x03bb37eb00000000, 0x7aa0eb0900000000, 0x44cb29e600000000, + 0x47701e0d00000000, 0x791bdce200000000, 0xf440d71300000000, + 0xca2b15fc00000000, 0xc990221700000000, 0xf7fbe0f800000000, + 0x8ee03c1a00000000, 0xb08bfef500000000, 0xb330c91e00000000, + 0x8d5b0bf100000000, 0xe881ae2700000000, 0xd6ea6cc800000000, + 0xd5515b2300000000, 0xeb3a99cc00000000, 0x9221452e00000000, + 0xac4a87c100000000, 0xaff1b02a00000000, 0x919a72c500000000, + 0x1cc1793400000000, 0x22aabbdb00000000, 0x21118c3000000000, + 0x1f7a4edf00000000, 0x6661923d00000000, 0x580a50d200000000, + 0x5bb1673900000000, 0x65daa5d600000000, 0xd0035d4f00000000, + 0xee689fa000000000, 0xedd3a84b00000000, 0xd3b86aa400000000, + 0xaaa3b64600000000, 0x94c874a900000000, 0x9773434200000000, + 0xa91881ad00000000, 0x24438a5c00000000, 0x1a2848b300000000, + 0x19937f5800000000, 0x27f8bdb700000000, 0x5ee3615500000000, + 0x6088a3ba00000000, 0x6333945100000000, 0x5d5856be00000000, + 0x3882f36800000000, 0x06e9318700000000, 0x0552066c00000000, + 0x3b39c48300000000, 0x4222186100000000, 0x7c49da8e00000000, + 0x7ff2ed6500000000, 0x41992f8a00000000, 0xccc2247b00000000, + 0xf2a9e69400000000, 0xf112d17f00000000, 0xcf79139000000000, + 0xb662cf7200000000, 0x88090d9d00000000, 0x8bb23a7600000000, + 0xb5d9f89900000000, 0xa007ba9e00000000, 0x9e6c787100000000, + 0x9dd74f9a00000000, 0xa3bc8d7500000000, 0xdaa7519700000000, + 0xe4cc937800000000, 0xe777a49300000000, 0xd91c667c00000000, + 0x54476d8d00000000, 0x6a2caf6200000000, 0x6997988900000000, + 0x57fc5a6600000000, 0x2ee7868400000000, 0x108c446b00000000, + 0x1337738000000000, 0x2d5cb16f00000000, 0x488614b900000000, + 0x76edd65600000000, 0x7556e1bd00000000, 0x4b3d235200000000, + 0x3226ffb000000000, 0x0c4d3d5f00000000, 0x0ff60ab400000000, + 0x319dc85b00000000, 0xbcc6c3aa00000000, 0x82ad014500000000, + 0x811636ae00000000, 0xbf7df44100000000, 0xc66628a300000000, + 0xf80dea4c00000000, 0xfbb6dda700000000, 0xc5dd1f4800000000, + 0x7004e7d100000000, 0x4e6f253e00000000, 0x4dd412d500000000, + 0x73bfd03a00000000, 0x0aa40cd800000000, 0x34cfce3700000000, + 0x3774f9dc00000000, 0x091f3b3300000000, 0x844430c200000000, + 0xba2ff22d00000000, 0xb994c5c600000000, 0x87ff072900000000, + 0xfee4dbcb00000000, 0xc08f192400000000, 0xc3342ecf00000000, + 0xfd5fec2000000000, 0x988549f600000000, 0xa6ee8b1900000000, + 0xa555bcf200000000, 0x9b3e7e1d00000000, 0xe225a2ff00000000, + 0xdc4e601000000000, 0xdff557fb00000000, 0xe19e951400000000, + 0x6cc59ee500000000, 0x52ae5c0a00000000, 0x51156be100000000, + 0x6f7ea90e00000000, 0x166575ec00000000, 0x280eb70300000000, + 0x2bb580e800000000, 0x15de420700000000, 0x010905e600000000, + 0x3f62c70900000000, 0x3cd9f0e200000000, 0x02b2320d00000000, + 0x7ba9eeef00000000, 0x45c22c0000000000, 0x46791beb00000000, + 0x7812d90400000000, 0xf549d2f500000000, 0xcb22101a00000000, + 0xc89927f100000000, 0xf6f2e51e00000000, 0x8fe939fc00000000, + 0xb182fb1300000000, 0xb239ccf800000000, 0x8c520e1700000000, + 0xe988abc100000000, 0xd7e3692e00000000, 0xd4585ec500000000, + 0xea339c2a00000000, 0x932840c800000000, 0xad43822700000000, + 0xaef8b5cc00000000, 0x9093772300000000, 0x1dc87cd200000000, + 0x23a3be3d00000000, 0x201889d600000000, 0x1e734b3900000000, + 0x676897db00000000, 0x5903553400000000, 0x5ab862df00000000, + 0x64d3a03000000000, 0xd10a58a900000000, 0xef619a4600000000, + 0xecdaadad00000000, 0xd2b16f4200000000, 0xabaab3a000000000, + 0x95c1714f00000000, 0x967a46a400000000, 0xa811844b00000000, + 0x254a8fba00000000, 0x1b214d5500000000, 0x189a7abe00000000, + 0x26f1b85100000000, 0x5fea64b300000000, 0x6181a65c00000000, + 0x623a91b700000000, 0x5c51535800000000, 0x398bf68e00000000, + 0x07e0346100000000, 0x045b038a00000000, 0x3a30c16500000000, + 0x432b1d8700000000, 0x7d40df6800000000, 0x7efbe88300000000, + 0x40902a6c00000000, 0xcdcb219d00000000, 0xf3a0e37200000000, + 0xf01bd49900000000, 0xce70167600000000, 0xb76bca9400000000, + 0x8900087b00000000, 0x8abb3f9000000000, 0xb4d0fd7f00000000, + 0xa10ebf7800000000, 0x9f657d9700000000, 0x9cde4a7c00000000, + 0xa2b5889300000000, 0xdbae547100000000, 0xe5c5969e00000000, + 0xe67ea17500000000, 0xd815639a00000000, 0x554e686b00000000, + 0x6b25aa8400000000, 0x689e9d6f00000000, 0x56f55f8000000000, + 0x2fee836200000000, 0x1185418d00000000, 0x123e766600000000, + 0x2c55b48900000000, 0x498f115f00000000, 0x77e4d3b000000000, + 0x745fe45b00000000, 0x4a3426b400000000, 0x332ffa5600000000, + 0x0d4438b900000000, 0x0eff0f5200000000, 0x3094cdbd00000000, + 0xbdcfc64c00000000, 0x83a404a300000000, 0x801f334800000000, + 0xbe74f1a700000000, 0xc76f2d4500000000, 0xf904efaa00000000, + 0xfabfd84100000000, 0xc4d41aae00000000, 0x710de23700000000, + 0x4f6620d800000000, 0x4cdd173300000000, 0x72b6d5dc00000000, + 0x0bad093e00000000, 0x35c6cbd100000000, 0x367dfc3a00000000, + 0x08163ed500000000, 0x854d352400000000, 0xbb26f7cb00000000, + 0xb89dc02000000000, 0x86f602cf00000000, 0xffedde2d00000000, + 0xc1861cc200000000, 0xc23d2b2900000000, 0xfc56e9c600000000, + 0x998c4c1000000000, 0xa7e78eff00000000, 0xa45cb91400000000, + 0x9a377bfb00000000, 0xe32ca71900000000, 0xdd4765f600000000, + 0xdefc521d00000000, 0xe09790f200000000, 0x6dcc9b0300000000, + 0x53a759ec00000000, 0x501c6e0700000000, 0x6e77ace800000000, + 0x176c700a00000000, 0x2907b2e500000000, 0x2abc850e00000000, + 0x14d747e100000000}, + {0x0000000000000000, 0xc0df8ec100000000, 0xc1b96c5800000000, + 0x0166e29900000000, 0x8273d9b000000000, 0x42ac577100000000, + 0x43cab5e800000000, 0x83153b2900000000, 0x45e1c3ba00000000, + 0x853e4d7b00000000, 0x8458afe200000000, 0x4487212300000000, + 0xc7921a0a00000000, 0x074d94cb00000000, 0x062b765200000000, + 0xc6f4f89300000000, 0xcbc4f6ae00000000, 0x0b1b786f00000000, + 0x0a7d9af600000000, 0xcaa2143700000000, 0x49b72f1e00000000, + 0x8968a1df00000000, 0x880e434600000000, 0x48d1cd8700000000, + 0x8e25351400000000, 0x4efabbd500000000, 0x4f9c594c00000000, + 0x8f43d78d00000000, 0x0c56eca400000000, 0xcc89626500000000, + 0xcdef80fc00000000, 0x0d300e3d00000000, 0xd78f9c8600000000, + 0x1750124700000000, 0x1636f0de00000000, 0xd6e97e1f00000000, + 0x55fc453600000000, 0x9523cbf700000000, 0x9445296e00000000, + 0x549aa7af00000000, 0x926e5f3c00000000, 0x52b1d1fd00000000, + 0x53d7336400000000, 0x9308bda500000000, 0x101d868c00000000, + 0xd0c2084d00000000, 0xd1a4ead400000000, 0x117b641500000000, + 0x1c4b6a2800000000, 0xdc94e4e900000000, 0xddf2067000000000, + 0x1d2d88b100000000, 0x9e38b39800000000, 0x5ee73d5900000000, + 0x5f81dfc000000000, 0x9f5e510100000000, 0x59aaa99200000000, + 0x9975275300000000, 0x9813c5ca00000000, 0x58cc4b0b00000000, + 0xdbd9702200000000, 0x1b06fee300000000, 0x1a601c7a00000000, + 0xdabf92bb00000000, 0xef1948d600000000, 0x2fc6c61700000000, + 0x2ea0248e00000000, 0xee7faa4f00000000, 0x6d6a916600000000, + 0xadb51fa700000000, 0xacd3fd3e00000000, 0x6c0c73ff00000000, + 0xaaf88b6c00000000, 0x6a2705ad00000000, 0x6b41e73400000000, + 0xab9e69f500000000, 0x288b52dc00000000, 0xe854dc1d00000000, + 0xe9323e8400000000, 0x29edb04500000000, 0x24ddbe7800000000, + 0xe40230b900000000, 0xe564d22000000000, 0x25bb5ce100000000, + 0xa6ae67c800000000, 0x6671e90900000000, 0x67170b9000000000, + 0xa7c8855100000000, 0x613c7dc200000000, 0xa1e3f30300000000, + 0xa085119a00000000, 0x605a9f5b00000000, 0xe34fa47200000000, + 0x23902ab300000000, 0x22f6c82a00000000, 0xe22946eb00000000, + 0x3896d45000000000, 0xf8495a9100000000, 0xf92fb80800000000, + 0x39f036c900000000, 0xbae50de000000000, 0x7a3a832100000000, + 0x7b5c61b800000000, 0xbb83ef7900000000, 0x7d7717ea00000000, + 0xbda8992b00000000, 0xbcce7bb200000000, 0x7c11f57300000000, + 0xff04ce5a00000000, 0x3fdb409b00000000, 0x3ebda20200000000, + 0xfe622cc300000000, 0xf35222fe00000000, 0x338dac3f00000000, + 0x32eb4ea600000000, 0xf234c06700000000, 0x7121fb4e00000000, + 0xb1fe758f00000000, 0xb098971600000000, 0x704719d700000000, + 0xb6b3e14400000000, 0x766c6f8500000000, 0x770a8d1c00000000, + 0xb7d503dd00000000, 0x34c038f400000000, 0xf41fb63500000000, + 0xf57954ac00000000, 0x35a6da6d00000000, 0x9f35e17700000000, + 0x5fea6fb600000000, 0x5e8c8d2f00000000, 0x9e5303ee00000000, + 0x1d4638c700000000, 0xdd99b60600000000, 0xdcff549f00000000, + 0x1c20da5e00000000, 0xdad422cd00000000, 0x1a0bac0c00000000, + 0x1b6d4e9500000000, 0xdbb2c05400000000, 0x58a7fb7d00000000, + 0x987875bc00000000, 0x991e972500000000, 0x59c119e400000000, + 0x54f117d900000000, 0x942e991800000000, 0x95487b8100000000, + 0x5597f54000000000, 0xd682ce6900000000, 0x165d40a800000000, + 0x173ba23100000000, 0xd7e42cf000000000, 0x1110d46300000000, + 0xd1cf5aa200000000, 0xd0a9b83b00000000, 0x107636fa00000000, + 0x93630dd300000000, 0x53bc831200000000, 0x52da618b00000000, + 0x9205ef4a00000000, 0x48ba7df100000000, 0x8865f33000000000, + 0x890311a900000000, 0x49dc9f6800000000, 0xcac9a44100000000, + 0x0a162a8000000000, 0x0b70c81900000000, 0xcbaf46d800000000, + 0x0d5bbe4b00000000, 0xcd84308a00000000, 0xcce2d21300000000, + 0x0c3d5cd200000000, 0x8f2867fb00000000, 0x4ff7e93a00000000, + 0x4e910ba300000000, 0x8e4e856200000000, 0x837e8b5f00000000, + 0x43a1059e00000000, 0x42c7e70700000000, 0x821869c600000000, + 0x010d52ef00000000, 0xc1d2dc2e00000000, 0xc0b43eb700000000, + 0x006bb07600000000, 0xc69f48e500000000, 0x0640c62400000000, + 0x072624bd00000000, 0xc7f9aa7c00000000, 0x44ec915500000000, + 0x84331f9400000000, 0x8555fd0d00000000, 0x458a73cc00000000, + 0x702ca9a100000000, 0xb0f3276000000000, 0xb195c5f900000000, + 0x714a4b3800000000, 0xf25f701100000000, 0x3280fed000000000, + 0x33e61c4900000000, 0xf339928800000000, 0x35cd6a1b00000000, + 0xf512e4da00000000, 0xf474064300000000, 0x34ab888200000000, + 0xb7beb3ab00000000, 0x77613d6a00000000, 0x7607dff300000000, + 0xb6d8513200000000, 0xbbe85f0f00000000, 0x7b37d1ce00000000, + 0x7a51335700000000, 0xba8ebd9600000000, 0x399b86bf00000000, + 0xf944087e00000000, 0xf822eae700000000, 0x38fd642600000000, + 0xfe099cb500000000, 0x3ed6127400000000, 0x3fb0f0ed00000000, + 0xff6f7e2c00000000, 0x7c7a450500000000, 0xbca5cbc400000000, + 0xbdc3295d00000000, 0x7d1ca79c00000000, 0xa7a3352700000000, + 0x677cbbe600000000, 0x661a597f00000000, 0xa6c5d7be00000000, + 0x25d0ec9700000000, 0xe50f625600000000, 0xe46980cf00000000, + 0x24b60e0e00000000, 0xe242f69d00000000, 0x229d785c00000000, + 0x23fb9ac500000000, 0xe324140400000000, 0x60312f2d00000000, + 0xa0eea1ec00000000, 0xa188437500000000, 0x6157cdb400000000, + 0x6c67c38900000000, 0xacb84d4800000000, 0xaddeafd100000000, + 0x6d01211000000000, 0xee141a3900000000, 0x2ecb94f800000000, + 0x2fad766100000000, 0xef72f8a000000000, 0x2986003300000000, + 0xe9598ef200000000, 0xe83f6c6b00000000, 0x28e0e2aa00000000, + 0xabf5d98300000000, 0x6b2a574200000000, 0x6a4cb5db00000000, + 0xaa933b1a00000000}, + {0x0000000000000000, 0x6f4ca59b00000000, 0x9f9e3bec00000000, + 0xf0d29e7700000000, 0x7f3b060300000000, 0x1077a39800000000, + 0xe0a53def00000000, 0x8fe9987400000000, 0xfe760c0600000000, + 0x913aa99d00000000, 0x61e837ea00000000, 0x0ea4927100000000, + 0x814d0a0500000000, 0xee01af9e00000000, 0x1ed331e900000000, + 0x719f947200000000, 0xfced180c00000000, 0x93a1bd9700000000, + 0x637323e000000000, 0x0c3f867b00000000, 0x83d61e0f00000000, + 0xec9abb9400000000, 0x1c4825e300000000, 0x7304807800000000, + 0x029b140a00000000, 0x6dd7b19100000000, 0x9d052fe600000000, + 0xf2498a7d00000000, 0x7da0120900000000, 0x12ecb79200000000, + 0xe23e29e500000000, 0x8d728c7e00000000, 0xf8db311800000000, + 0x9797948300000000, 0x67450af400000000, 0x0809af6f00000000, + 0x87e0371b00000000, 0xe8ac928000000000, 0x187e0cf700000000, + 0x7732a96c00000000, 0x06ad3d1e00000000, 0x69e1988500000000, + 0x993306f200000000, 0xf67fa36900000000, 0x79963b1d00000000, + 0x16da9e8600000000, 0xe60800f100000000, 0x8944a56a00000000, + 0x0436291400000000, 0x6b7a8c8f00000000, 0x9ba812f800000000, + 0xf4e4b76300000000, 0x7b0d2f1700000000, 0x14418a8c00000000, + 0xe49314fb00000000, 0x8bdfb16000000000, 0xfa40251200000000, + 0x950c808900000000, 0x65de1efe00000000, 0x0a92bb6500000000, + 0x857b231100000000, 0xea37868a00000000, 0x1ae518fd00000000, + 0x75a9bd6600000000, 0xf0b7633000000000, 0x9ffbc6ab00000000, + 0x6f2958dc00000000, 0x0065fd4700000000, 0x8f8c653300000000, + 0xe0c0c0a800000000, 0x10125edf00000000, 0x7f5efb4400000000, + 0x0ec16f3600000000, 0x618dcaad00000000, 0x915f54da00000000, + 0xfe13f14100000000, 0x71fa693500000000, 0x1eb6ccae00000000, + 0xee6452d900000000, 0x8128f74200000000, 0x0c5a7b3c00000000, + 0x6316dea700000000, 0x93c440d000000000, 0xfc88e54b00000000, + 0x73617d3f00000000, 0x1c2dd8a400000000, 0xecff46d300000000, + 0x83b3e34800000000, 0xf22c773a00000000, 0x9d60d2a100000000, + 0x6db24cd600000000, 0x02fee94d00000000, 0x8d17713900000000, + 0xe25bd4a200000000, 0x12894ad500000000, 0x7dc5ef4e00000000, + 0x086c522800000000, 0x6720f7b300000000, 0x97f269c400000000, + 0xf8becc5f00000000, 0x7757542b00000000, 0x181bf1b000000000, + 0xe8c96fc700000000, 0x8785ca5c00000000, 0xf61a5e2e00000000, + 0x9956fbb500000000, 0x698465c200000000, 0x06c8c05900000000, + 0x8921582d00000000, 0xe66dfdb600000000, 0x16bf63c100000000, + 0x79f3c65a00000000, 0xf4814a2400000000, 0x9bcdefbf00000000, + 0x6b1f71c800000000, 0x0453d45300000000, 0x8bba4c2700000000, + 0xe4f6e9bc00000000, 0x142477cb00000000, 0x7b68d25000000000, + 0x0af7462200000000, 0x65bbe3b900000000, 0x95697dce00000000, + 0xfa25d85500000000, 0x75cc402100000000, 0x1a80e5ba00000000, + 0xea527bcd00000000, 0x851ede5600000000, 0xe06fc76000000000, + 0x8f2362fb00000000, 0x7ff1fc8c00000000, 0x10bd591700000000, + 0x9f54c16300000000, 0xf01864f800000000, 0x00cafa8f00000000, + 0x6f865f1400000000, 0x1e19cb6600000000, 0x71556efd00000000, + 0x8187f08a00000000, 0xeecb551100000000, 0x6122cd6500000000, + 0x0e6e68fe00000000, 0xfebcf68900000000, 0x91f0531200000000, + 0x1c82df6c00000000, 0x73ce7af700000000, 0x831ce48000000000, + 0xec50411b00000000, 0x63b9d96f00000000, 0x0cf57cf400000000, + 0xfc27e28300000000, 0x936b471800000000, 0xe2f4d36a00000000, + 0x8db876f100000000, 0x7d6ae88600000000, 0x12264d1d00000000, + 0x9dcfd56900000000, 0xf28370f200000000, 0x0251ee8500000000, + 0x6d1d4b1e00000000, 0x18b4f67800000000, 0x77f853e300000000, + 0x872acd9400000000, 0xe866680f00000000, 0x678ff07b00000000, + 0x08c355e000000000, 0xf811cb9700000000, 0x975d6e0c00000000, + 0xe6c2fa7e00000000, 0x898e5fe500000000, 0x795cc19200000000, + 0x1610640900000000, 0x99f9fc7d00000000, 0xf6b559e600000000, + 0x0667c79100000000, 0x692b620a00000000, 0xe459ee7400000000, + 0x8b154bef00000000, 0x7bc7d59800000000, 0x148b700300000000, + 0x9b62e87700000000, 0xf42e4dec00000000, 0x04fcd39b00000000, + 0x6bb0760000000000, 0x1a2fe27200000000, 0x756347e900000000, + 0x85b1d99e00000000, 0xeafd7c0500000000, 0x6514e47100000000, + 0x0a5841ea00000000, 0xfa8adf9d00000000, 0x95c67a0600000000, + 0x10d8a45000000000, 0x7f9401cb00000000, 0x8f469fbc00000000, + 0xe00a3a2700000000, 0x6fe3a25300000000, 0x00af07c800000000, + 0xf07d99bf00000000, 0x9f313c2400000000, 0xeeaea85600000000, + 0x81e20dcd00000000, 0x713093ba00000000, 0x1e7c362100000000, + 0x9195ae5500000000, 0xfed90bce00000000, 0x0e0b95b900000000, + 0x6147302200000000, 0xec35bc5c00000000, 0x837919c700000000, + 0x73ab87b000000000, 0x1ce7222b00000000, 0x930eba5f00000000, + 0xfc421fc400000000, 0x0c9081b300000000, 0x63dc242800000000, + 0x1243b05a00000000, 0x7d0f15c100000000, 0x8ddd8bb600000000, + 0xe2912e2d00000000, 0x6d78b65900000000, 0x023413c200000000, + 0xf2e68db500000000, 0x9daa282e00000000, 0xe803954800000000, + 0x874f30d300000000, 0x779daea400000000, 0x18d10b3f00000000, + 0x9738934b00000000, 0xf87436d000000000, 0x08a6a8a700000000, + 0x67ea0d3c00000000, 0x1675994e00000000, 0x79393cd500000000, + 0x89eba2a200000000, 0xe6a7073900000000, 0x694e9f4d00000000, + 0x06023ad600000000, 0xf6d0a4a100000000, 0x999c013a00000000, + 0x14ee8d4400000000, 0x7ba228df00000000, 0x8b70b6a800000000, + 0xe43c133300000000, 0x6bd58b4700000000, 0x04992edc00000000, + 0xf44bb0ab00000000, 0x9b07153000000000, 0xea98814200000000, + 0x85d424d900000000, 0x7506baae00000000, 0x1a4a1f3500000000, + 0x95a3874100000000, 0xfaef22da00000000, 0x0a3dbcad00000000, + 0x6571193600000000}, + {0x0000000000000000, 0x85d996dd00000000, 0x4bb55c6000000000, + 0xce6ccabd00000000, 0x966ab9c000000000, 0x13b32f1d00000000, + 0xdddfe5a000000000, 0x5806737d00000000, 0x6dd3035a00000000, + 0xe80a958700000000, 0x26665f3a00000000, 0xa3bfc9e700000000, + 0xfbb9ba9a00000000, 0x7e602c4700000000, 0xb00ce6fa00000000, + 0x35d5702700000000, 0xdaa607b400000000, 0x5f7f916900000000, + 0x91135bd400000000, 0x14cacd0900000000, 0x4cccbe7400000000, + 0xc91528a900000000, 0x0779e21400000000, 0x82a074c900000000, + 0xb77504ee00000000, 0x32ac923300000000, 0xfcc0588e00000000, + 0x7919ce5300000000, 0x211fbd2e00000000, 0xa4c62bf300000000, + 0x6aaae14e00000000, 0xef73779300000000, 0xf54b7eb300000000, + 0x7092e86e00000000, 0xbefe22d300000000, 0x3b27b40e00000000, + 0x6321c77300000000, 0xe6f851ae00000000, 0x28949b1300000000, + 0xad4d0dce00000000, 0x98987de900000000, 0x1d41eb3400000000, + 0xd32d218900000000, 0x56f4b75400000000, 0x0ef2c42900000000, + 0x8b2b52f400000000, 0x4547984900000000, 0xc09e0e9400000000, + 0x2fed790700000000, 0xaa34efda00000000, 0x6458256700000000, + 0xe181b3ba00000000, 0xb987c0c700000000, 0x3c5e561a00000000, + 0xf2329ca700000000, 0x77eb0a7a00000000, 0x423e7a5d00000000, + 0xc7e7ec8000000000, 0x098b263d00000000, 0x8c52b0e000000000, + 0xd454c39d00000000, 0x518d554000000000, 0x9fe19ffd00000000, + 0x1a38092000000000, 0xab918dbd00000000, 0x2e481b6000000000, + 0xe024d1dd00000000, 0x65fd470000000000, 0x3dfb347d00000000, + 0xb822a2a000000000, 0x764e681d00000000, 0xf397fec000000000, + 0xc6428ee700000000, 0x439b183a00000000, 0x8df7d28700000000, + 0x082e445a00000000, 0x5028372700000000, 0xd5f1a1fa00000000, + 0x1b9d6b4700000000, 0x9e44fd9a00000000, 0x71378a0900000000, + 0xf4ee1cd400000000, 0x3a82d66900000000, 0xbf5b40b400000000, + 0xe75d33c900000000, 0x6284a51400000000, 0xace86fa900000000, + 0x2931f97400000000, 0x1ce4895300000000, 0x993d1f8e00000000, + 0x5751d53300000000, 0xd28843ee00000000, 0x8a8e309300000000, + 0x0f57a64e00000000, 0xc13b6cf300000000, 0x44e2fa2e00000000, + 0x5edaf30e00000000, 0xdb0365d300000000, 0x156faf6e00000000, + 0x90b639b300000000, 0xc8b04ace00000000, 0x4d69dc1300000000, + 0x830516ae00000000, 0x06dc807300000000, 0x3309f05400000000, + 0xb6d0668900000000, 0x78bcac3400000000, 0xfd653ae900000000, + 0xa563499400000000, 0x20badf4900000000, 0xeed615f400000000, + 0x6b0f832900000000, 0x847cf4ba00000000, 0x01a5626700000000, + 0xcfc9a8da00000000, 0x4a103e0700000000, 0x12164d7a00000000, + 0x97cfdba700000000, 0x59a3111a00000000, 0xdc7a87c700000000, + 0xe9aff7e000000000, 0x6c76613d00000000, 0xa21aab8000000000, + 0x27c33d5d00000000, 0x7fc54e2000000000, 0xfa1cd8fd00000000, + 0x3470124000000000, 0xb1a9849d00000000, 0x17256aa000000000, + 0x92fcfc7d00000000, 0x5c9036c000000000, 0xd949a01d00000000, + 0x814fd36000000000, 0x049645bd00000000, 0xcafa8f0000000000, + 0x4f2319dd00000000, 0x7af669fa00000000, 0xff2fff2700000000, + 0x3143359a00000000, 0xb49aa34700000000, 0xec9cd03a00000000, + 0x694546e700000000, 0xa7298c5a00000000, 0x22f01a8700000000, + 0xcd836d1400000000, 0x485afbc900000000, 0x8636317400000000, + 0x03efa7a900000000, 0x5be9d4d400000000, 0xde30420900000000, + 0x105c88b400000000, 0x95851e6900000000, 0xa0506e4e00000000, + 0x2589f89300000000, 0xebe5322e00000000, 0x6e3ca4f300000000, + 0x363ad78e00000000, 0xb3e3415300000000, 0x7d8f8bee00000000, + 0xf8561d3300000000, 0xe26e141300000000, 0x67b782ce00000000, + 0xa9db487300000000, 0x2c02deae00000000, 0x7404add300000000, + 0xf1dd3b0e00000000, 0x3fb1f1b300000000, 0xba68676e00000000, + 0x8fbd174900000000, 0x0a64819400000000, 0xc4084b2900000000, + 0x41d1ddf400000000, 0x19d7ae8900000000, 0x9c0e385400000000, + 0x5262f2e900000000, 0xd7bb643400000000, 0x38c813a700000000, + 0xbd11857a00000000, 0x737d4fc700000000, 0xf6a4d91a00000000, + 0xaea2aa6700000000, 0x2b7b3cba00000000, 0xe517f60700000000, + 0x60ce60da00000000, 0x551b10fd00000000, 0xd0c2862000000000, + 0x1eae4c9d00000000, 0x9b77da4000000000, 0xc371a93d00000000, + 0x46a83fe000000000, 0x88c4f55d00000000, 0x0d1d638000000000, + 0xbcb4e71d00000000, 0x396d71c000000000, 0xf701bb7d00000000, + 0x72d82da000000000, 0x2ade5edd00000000, 0xaf07c80000000000, + 0x616b02bd00000000, 0xe4b2946000000000, 0xd167e44700000000, + 0x54be729a00000000, 0x9ad2b82700000000, 0x1f0b2efa00000000, + 0x470d5d8700000000, 0xc2d4cb5a00000000, 0x0cb801e700000000, + 0x8961973a00000000, 0x6612e0a900000000, 0xe3cb767400000000, + 0x2da7bcc900000000, 0xa87e2a1400000000, 0xf078596900000000, + 0x75a1cfb400000000, 0xbbcd050900000000, 0x3e1493d400000000, + 0x0bc1e3f300000000, 0x8e18752e00000000, 0x4074bf9300000000, + 0xc5ad294e00000000, 0x9dab5a3300000000, 0x1872ccee00000000, + 0xd61e065300000000, 0x53c7908e00000000, 0x49ff99ae00000000, + 0xcc260f7300000000, 0x024ac5ce00000000, 0x8793531300000000, + 0xdf95206e00000000, 0x5a4cb6b300000000, 0x94207c0e00000000, + 0x11f9ead300000000, 0x242c9af400000000, 0xa1f50c2900000000, + 0x6f99c69400000000, 0xea40504900000000, 0xb246233400000000, + 0x379fb5e900000000, 0xf9f37f5400000000, 0x7c2ae98900000000, + 0x93599e1a00000000, 0x168008c700000000, 0xd8ecc27a00000000, + 0x5d3554a700000000, 0x053327da00000000, 0x80eab10700000000, + 0x4e867bba00000000, 0xcb5fed6700000000, 0xfe8a9d4000000000, + 0x7b530b9d00000000, 0xb53fc12000000000, 0x30e657fd00000000, + 0x68e0248000000000, 0xed39b25d00000000, 0x235578e000000000, + 0xa68cee3d00000000}, + {0x0000000000000000, 0x76e10f9d00000000, 0xadc46ee100000000, + 0xdb25617c00000000, 0x1b8fac1900000000, 0x6d6ea38400000000, + 0xb64bc2f800000000, 0xc0aacd6500000000, 0x361e593300000000, + 0x40ff56ae00000000, 0x9bda37d200000000, 0xed3b384f00000000, + 0x2d91f52a00000000, 0x5b70fab700000000, 0x80559bcb00000000, + 0xf6b4945600000000, 0x6c3cb26600000000, 0x1addbdfb00000000, + 0xc1f8dc8700000000, 0xb719d31a00000000, 0x77b31e7f00000000, + 0x015211e200000000, 0xda77709e00000000, 0xac967f0300000000, + 0x5a22eb5500000000, 0x2cc3e4c800000000, 0xf7e685b400000000, + 0x81078a2900000000, 0x41ad474c00000000, 0x374c48d100000000, + 0xec6929ad00000000, 0x9a88263000000000, 0xd87864cd00000000, + 0xae996b5000000000, 0x75bc0a2c00000000, 0x035d05b100000000, + 0xc3f7c8d400000000, 0xb516c74900000000, 0x6e33a63500000000, + 0x18d2a9a800000000, 0xee663dfe00000000, 0x9887326300000000, + 0x43a2531f00000000, 0x35435c8200000000, 0xf5e991e700000000, + 0x83089e7a00000000, 0x582dff0600000000, 0x2eccf09b00000000, + 0xb444d6ab00000000, 0xc2a5d93600000000, 0x1980b84a00000000, + 0x6f61b7d700000000, 0xafcb7ab200000000, 0xd92a752f00000000, + 0x020f145300000000, 0x74ee1bce00000000, 0x825a8f9800000000, + 0xf4bb800500000000, 0x2f9ee17900000000, 0x597feee400000000, + 0x99d5238100000000, 0xef342c1c00000000, 0x34114d6000000000, + 0x42f042fd00000000, 0xf1f7b94100000000, 0x8716b6dc00000000, + 0x5c33d7a000000000, 0x2ad2d83d00000000, 0xea78155800000000, + 0x9c991ac500000000, 0x47bc7bb900000000, 0x315d742400000000, + 0xc7e9e07200000000, 0xb108efef00000000, 0x6a2d8e9300000000, + 0x1ccc810e00000000, 0xdc664c6b00000000, 0xaa8743f600000000, + 0x71a2228a00000000, 0x07432d1700000000, 0x9dcb0b2700000000, + 0xeb2a04ba00000000, 0x300f65c600000000, 0x46ee6a5b00000000, + 0x8644a73e00000000, 0xf0a5a8a300000000, 0x2b80c9df00000000, + 0x5d61c64200000000, 0xabd5521400000000, 0xdd345d8900000000, + 0x06113cf500000000, 0x70f0336800000000, 0xb05afe0d00000000, + 0xc6bbf19000000000, 0x1d9e90ec00000000, 0x6b7f9f7100000000, + 0x298fdd8c00000000, 0x5f6ed21100000000, 0x844bb36d00000000, + 0xf2aabcf000000000, 0x3200719500000000, 0x44e17e0800000000, + 0x9fc41f7400000000, 0xe92510e900000000, 0x1f9184bf00000000, + 0x69708b2200000000, 0xb255ea5e00000000, 0xc4b4e5c300000000, + 0x041e28a600000000, 0x72ff273b00000000, 0xa9da464700000000, + 0xdf3b49da00000000, 0x45b36fea00000000, 0x3352607700000000, + 0xe877010b00000000, 0x9e960e9600000000, 0x5e3cc3f300000000, + 0x28ddcc6e00000000, 0xf3f8ad1200000000, 0x8519a28f00000000, + 0x73ad36d900000000, 0x054c394400000000, 0xde69583800000000, + 0xa88857a500000000, 0x68229ac000000000, 0x1ec3955d00000000, + 0xc5e6f42100000000, 0xb307fbbc00000000, 0xe2ef738300000000, + 0x940e7c1e00000000, 0x4f2b1d6200000000, 0x39ca12ff00000000, + 0xf960df9a00000000, 0x8f81d00700000000, 0x54a4b17b00000000, + 0x2245bee600000000, 0xd4f12ab000000000, 0xa210252d00000000, + 0x7935445100000000, 0x0fd44bcc00000000, 0xcf7e86a900000000, + 0xb99f893400000000, 0x62bae84800000000, 0x145be7d500000000, + 0x8ed3c1e500000000, 0xf832ce7800000000, 0x2317af0400000000, + 0x55f6a09900000000, 0x955c6dfc00000000, 0xe3bd626100000000, + 0x3898031d00000000, 0x4e790c8000000000, 0xb8cd98d600000000, + 0xce2c974b00000000, 0x1509f63700000000, 0x63e8f9aa00000000, + 0xa34234cf00000000, 0xd5a33b5200000000, 0x0e865a2e00000000, + 0x786755b300000000, 0x3a97174e00000000, 0x4c7618d300000000, + 0x975379af00000000, 0xe1b2763200000000, 0x2118bb5700000000, + 0x57f9b4ca00000000, 0x8cdcd5b600000000, 0xfa3dda2b00000000, + 0x0c894e7d00000000, 0x7a6841e000000000, 0xa14d209c00000000, + 0xd7ac2f0100000000, 0x1706e26400000000, 0x61e7edf900000000, + 0xbac28c8500000000, 0xcc23831800000000, 0x56aba52800000000, + 0x204aaab500000000, 0xfb6fcbc900000000, 0x8d8ec45400000000, + 0x4d24093100000000, 0x3bc506ac00000000, 0xe0e067d000000000, + 0x9601684d00000000, 0x60b5fc1b00000000, 0x1654f38600000000, + 0xcd7192fa00000000, 0xbb909d6700000000, 0x7b3a500200000000, + 0x0ddb5f9f00000000, 0xd6fe3ee300000000, 0xa01f317e00000000, + 0x1318cac200000000, 0x65f9c55f00000000, 0xbedca42300000000, + 0xc83dabbe00000000, 0x089766db00000000, 0x7e76694600000000, + 0xa553083a00000000, 0xd3b207a700000000, 0x250693f100000000, + 0x53e79c6c00000000, 0x88c2fd1000000000, 0xfe23f28d00000000, + 0x3e893fe800000000, 0x4868307500000000, 0x934d510900000000, + 0xe5ac5e9400000000, 0x7f2478a400000000, 0x09c5773900000000, + 0xd2e0164500000000, 0xa40119d800000000, 0x64abd4bd00000000, + 0x124adb2000000000, 0xc96fba5c00000000, 0xbf8eb5c100000000, + 0x493a219700000000, 0x3fdb2e0a00000000, 0xe4fe4f7600000000, + 0x921f40eb00000000, 0x52b58d8e00000000, 0x2454821300000000, + 0xff71e36f00000000, 0x8990ecf200000000, 0xcb60ae0f00000000, + 0xbd81a19200000000, 0x66a4c0ee00000000, 0x1045cf7300000000, + 0xd0ef021600000000, 0xa60e0d8b00000000, 0x7d2b6cf700000000, + 0x0bca636a00000000, 0xfd7ef73c00000000, 0x8b9ff8a100000000, + 0x50ba99dd00000000, 0x265b964000000000, 0xe6f15b2500000000, + 0x901054b800000000, 0x4b3535c400000000, 0x3dd43a5900000000, + 0xa75c1c6900000000, 0xd1bd13f400000000, 0x0a98728800000000, + 0x7c797d1500000000, 0xbcd3b07000000000, 0xca32bfed00000000, + 0x1117de9100000000, 0x67f6d10c00000000, 0x9142455a00000000, + 0xe7a34ac700000000, 0x3c862bbb00000000, 0x4a67242600000000, + 0x8acde94300000000, 0xfc2ce6de00000000, 0x270987a200000000, + 0x51e8883f00000000}, + {0x0000000000000000, 0xe8dbfbb900000000, 0x91b186a800000000, + 0x796a7d1100000000, 0x63657c8a00000000, 0x8bbe873300000000, + 0xf2d4fa2200000000, 0x1a0f019b00000000, 0x87cc89cf00000000, + 0x6f17727600000000, 0x167d0f6700000000, 0xfea6f4de00000000, + 0xe4a9f54500000000, 0x0c720efc00000000, 0x751873ed00000000, + 0x9dc3885400000000, 0x4f9f624400000000, 0xa74499fd00000000, + 0xde2ee4ec00000000, 0x36f51f5500000000, 0x2cfa1ece00000000, + 0xc421e57700000000, 0xbd4b986600000000, 0x559063df00000000, + 0xc853eb8b00000000, 0x2088103200000000, 0x59e26d2300000000, + 0xb139969a00000000, 0xab36970100000000, 0x43ed6cb800000000, + 0x3a8711a900000000, 0xd25cea1000000000, 0x9e3ec58800000000, + 0x76e53e3100000000, 0x0f8f432000000000, 0xe754b89900000000, + 0xfd5bb90200000000, 0x158042bb00000000, 0x6cea3faa00000000, + 0x8431c41300000000, 0x19f24c4700000000, 0xf129b7fe00000000, + 0x8843caef00000000, 0x6098315600000000, 0x7a9730cd00000000, + 0x924ccb7400000000, 0xeb26b66500000000, 0x03fd4ddc00000000, + 0xd1a1a7cc00000000, 0x397a5c7500000000, 0x4010216400000000, + 0xa8cbdadd00000000, 0xb2c4db4600000000, 0x5a1f20ff00000000, + 0x23755dee00000000, 0xcbaea65700000000, 0x566d2e0300000000, + 0xbeb6d5ba00000000, 0xc7dca8ab00000000, 0x2f07531200000000, + 0x3508528900000000, 0xddd3a93000000000, 0xa4b9d42100000000, + 0x4c622f9800000000, 0x7d7bfbca00000000, 0x95a0007300000000, + 0xecca7d6200000000, 0x041186db00000000, 0x1e1e874000000000, + 0xf6c57cf900000000, 0x8faf01e800000000, 0x6774fa5100000000, + 0xfab7720500000000, 0x126c89bc00000000, 0x6b06f4ad00000000, + 0x83dd0f1400000000, 0x99d20e8f00000000, 0x7109f53600000000, + 0x0863882700000000, 0xe0b8739e00000000, 0x32e4998e00000000, + 0xda3f623700000000, 0xa3551f2600000000, 0x4b8ee49f00000000, + 0x5181e50400000000, 0xb95a1ebd00000000, 0xc03063ac00000000, + 0x28eb981500000000, 0xb528104100000000, 0x5df3ebf800000000, + 0x249996e900000000, 0xcc426d5000000000, 0xd64d6ccb00000000, + 0x3e96977200000000, 0x47fcea6300000000, 0xaf2711da00000000, + 0xe3453e4200000000, 0x0b9ec5fb00000000, 0x72f4b8ea00000000, + 0x9a2f435300000000, 0x802042c800000000, 0x68fbb97100000000, + 0x1191c46000000000, 0xf94a3fd900000000, 0x6489b78d00000000, + 0x8c524c3400000000, 0xf538312500000000, 0x1de3ca9c00000000, + 0x07eccb0700000000, 0xef3730be00000000, 0x965d4daf00000000, + 0x7e86b61600000000, 0xacda5c0600000000, 0x4401a7bf00000000, + 0x3d6bdaae00000000, 0xd5b0211700000000, 0xcfbf208c00000000, + 0x2764db3500000000, 0x5e0ea62400000000, 0xb6d55d9d00000000, + 0x2b16d5c900000000, 0xc3cd2e7000000000, 0xbaa7536100000000, + 0x527ca8d800000000, 0x4873a94300000000, 0xa0a852fa00000000, + 0xd9c22feb00000000, 0x3119d45200000000, 0xbbf0874e00000000, + 0x532b7cf700000000, 0x2a4101e600000000, 0xc29afa5f00000000, + 0xd895fbc400000000, 0x304e007d00000000, 0x49247d6c00000000, + 0xa1ff86d500000000, 0x3c3c0e8100000000, 0xd4e7f53800000000, + 0xad8d882900000000, 0x4556739000000000, 0x5f59720b00000000, + 0xb78289b200000000, 0xcee8f4a300000000, 0x26330f1a00000000, + 0xf46fe50a00000000, 0x1cb41eb300000000, 0x65de63a200000000, + 0x8d05981b00000000, 0x970a998000000000, 0x7fd1623900000000, + 0x06bb1f2800000000, 0xee60e49100000000, 0x73a36cc500000000, + 0x9b78977c00000000, 0xe212ea6d00000000, 0x0ac911d400000000, + 0x10c6104f00000000, 0xf81debf600000000, 0x817796e700000000, + 0x69ac6d5e00000000, 0x25ce42c600000000, 0xcd15b97f00000000, + 0xb47fc46e00000000, 0x5ca43fd700000000, 0x46ab3e4c00000000, + 0xae70c5f500000000, 0xd71ab8e400000000, 0x3fc1435d00000000, + 0xa202cb0900000000, 0x4ad930b000000000, 0x33b34da100000000, + 0xdb68b61800000000, 0xc167b78300000000, 0x29bc4c3a00000000, + 0x50d6312b00000000, 0xb80dca9200000000, 0x6a51208200000000, + 0x828adb3b00000000, 0xfbe0a62a00000000, 0x133b5d9300000000, + 0x09345c0800000000, 0xe1efa7b100000000, 0x9885daa000000000, + 0x705e211900000000, 0xed9da94d00000000, 0x054652f400000000, + 0x7c2c2fe500000000, 0x94f7d45c00000000, 0x8ef8d5c700000000, + 0x66232e7e00000000, 0x1f49536f00000000, 0xf792a8d600000000, + 0xc68b7c8400000000, 0x2e50873d00000000, 0x573afa2c00000000, + 0xbfe1019500000000, 0xa5ee000e00000000, 0x4d35fbb700000000, + 0x345f86a600000000, 0xdc847d1f00000000, 0x4147f54b00000000, + 0xa99c0ef200000000, 0xd0f673e300000000, 0x382d885a00000000, + 0x222289c100000000, 0xcaf9727800000000, 0xb3930f6900000000, + 0x5b48f4d000000000, 0x89141ec000000000, 0x61cfe57900000000, + 0x18a5986800000000, 0xf07e63d100000000, 0xea71624a00000000, + 0x02aa99f300000000, 0x7bc0e4e200000000, 0x931b1f5b00000000, + 0x0ed8970f00000000, 0xe6036cb600000000, 0x9f6911a700000000, + 0x77b2ea1e00000000, 0x6dbdeb8500000000, 0x8566103c00000000, + 0xfc0c6d2d00000000, 0x14d7969400000000, 0x58b5b90c00000000, + 0xb06e42b500000000, 0xc9043fa400000000, 0x21dfc41d00000000, + 0x3bd0c58600000000, 0xd30b3e3f00000000, 0xaa61432e00000000, + 0x42bab89700000000, 0xdf7930c300000000, 0x37a2cb7a00000000, + 0x4ec8b66b00000000, 0xa6134dd200000000, 0xbc1c4c4900000000, + 0x54c7b7f000000000, 0x2dadcae100000000, 0xc576315800000000, + 0x172adb4800000000, 0xfff120f100000000, 0x869b5de000000000, + 0x6e40a65900000000, 0x744fa7c200000000, 0x9c945c7b00000000, + 0xe5fe216a00000000, 0x0d25dad300000000, 0x90e6528700000000, + 0x783da93e00000000, 0x0157d42f00000000, 0xe98c2f9600000000, + 0xf3832e0d00000000, 0x1b58d5b400000000, 0x6232a8a500000000, + 0x8ae9531c00000000}, + {0x0000000000000000, 0x919168ae00000000, 0x6325a08700000000, + 0xf2b4c82900000000, 0x874c31d400000000, 0x16dd597a00000000, + 0xe469915300000000, 0x75f8f9fd00000000, 0x4f9f137300000000, + 0xde0e7bdd00000000, 0x2cbab3f400000000, 0xbd2bdb5a00000000, + 0xc8d322a700000000, 0x59424a0900000000, 0xabf6822000000000, + 0x3a67ea8e00000000, 0x9e3e27e600000000, 0x0faf4f4800000000, + 0xfd1b876100000000, 0x6c8aefcf00000000, 0x1972163200000000, + 0x88e37e9c00000000, 0x7a57b6b500000000, 0xebc6de1b00000000, + 0xd1a1349500000000, 0x40305c3b00000000, 0xb284941200000000, + 0x2315fcbc00000000, 0x56ed054100000000, 0xc77c6def00000000, + 0x35c8a5c600000000, 0xa459cd6800000000, 0x7d7b3f1700000000, + 0xecea57b900000000, 0x1e5e9f9000000000, 0x8fcff73e00000000, + 0xfa370ec300000000, 0x6ba6666d00000000, 0x9912ae4400000000, + 0x0883c6ea00000000, 0x32e42c6400000000, 0xa37544ca00000000, + 0x51c18ce300000000, 0xc050e44d00000000, 0xb5a81db000000000, + 0x2439751e00000000, 0xd68dbd3700000000, 0x471cd59900000000, + 0xe34518f100000000, 0x72d4705f00000000, 0x8060b87600000000, + 0x11f1d0d800000000, 0x6409292500000000, 0xf598418b00000000, + 0x072c89a200000000, 0x96bde10c00000000, 0xacda0b8200000000, + 0x3d4b632c00000000, 0xcfffab0500000000, 0x5e6ec3ab00000000, + 0x2b963a5600000000, 0xba0752f800000000, 0x48b39ad100000000, + 0xd922f27f00000000, 0xfaf67e2e00000000, 0x6b67168000000000, + 0x99d3dea900000000, 0x0842b60700000000, 0x7dba4ffa00000000, + 0xec2b275400000000, 0x1e9fef7d00000000, 0x8f0e87d300000000, + 0xb5696d5d00000000, 0x24f805f300000000, 0xd64ccdda00000000, + 0x47dda57400000000, 0x32255c8900000000, 0xa3b4342700000000, + 0x5100fc0e00000000, 0xc09194a000000000, 0x64c859c800000000, + 0xf559316600000000, 0x07edf94f00000000, 0x967c91e100000000, + 0xe384681c00000000, 0x721500b200000000, 0x80a1c89b00000000, + 0x1130a03500000000, 0x2b574abb00000000, 0xbac6221500000000, + 0x4872ea3c00000000, 0xd9e3829200000000, 0xac1b7b6f00000000, + 0x3d8a13c100000000, 0xcf3edbe800000000, 0x5eafb34600000000, + 0x878d413900000000, 0x161c299700000000, 0xe4a8e1be00000000, + 0x7539891000000000, 0x00c170ed00000000, 0x9150184300000000, + 0x63e4d06a00000000, 0xf275b8c400000000, 0xc812524a00000000, + 0x59833ae400000000, 0xab37f2cd00000000, 0x3aa69a6300000000, + 0x4f5e639e00000000, 0xdecf0b3000000000, 0x2c7bc31900000000, + 0xbdeaabb700000000, 0x19b366df00000000, 0x88220e7100000000, + 0x7a96c65800000000, 0xeb07aef600000000, 0x9eff570b00000000, + 0x0f6e3fa500000000, 0xfddaf78c00000000, 0x6c4b9f2200000000, + 0x562c75ac00000000, 0xc7bd1d0200000000, 0x3509d52b00000000, + 0xa498bd8500000000, 0xd160447800000000, 0x40f12cd600000000, + 0xb245e4ff00000000, 0x23d48c5100000000, 0xf4edfd5c00000000, + 0x657c95f200000000, 0x97c85ddb00000000, 0x0659357500000000, + 0x73a1cc8800000000, 0xe230a42600000000, 0x10846c0f00000000, + 0x811504a100000000, 0xbb72ee2f00000000, 0x2ae3868100000000, + 0xd8574ea800000000, 0x49c6260600000000, 0x3c3edffb00000000, + 0xadafb75500000000, 0x5f1b7f7c00000000, 0xce8a17d200000000, + 0x6ad3daba00000000, 0xfb42b21400000000, 0x09f67a3d00000000, + 0x9867129300000000, 0xed9feb6e00000000, 0x7c0e83c000000000, + 0x8eba4be900000000, 0x1f2b234700000000, 0x254cc9c900000000, + 0xb4dda16700000000, 0x4669694e00000000, 0xd7f801e000000000, + 0xa200f81d00000000, 0x339190b300000000, 0xc125589a00000000, + 0x50b4303400000000, 0x8996c24b00000000, 0x1807aae500000000, + 0xeab362cc00000000, 0x7b220a6200000000, 0x0edaf39f00000000, + 0x9f4b9b3100000000, 0x6dff531800000000, 0xfc6e3bb600000000, + 0xc609d13800000000, 0x5798b99600000000, 0xa52c71bf00000000, + 0x34bd191100000000, 0x4145e0ec00000000, 0xd0d4884200000000, + 0x2260406b00000000, 0xb3f128c500000000, 0x17a8e5ad00000000, + 0x86398d0300000000, 0x748d452a00000000, 0xe51c2d8400000000, + 0x90e4d47900000000, 0x0175bcd700000000, 0xf3c174fe00000000, + 0x62501c5000000000, 0x5837f6de00000000, 0xc9a69e7000000000, + 0x3b12565900000000, 0xaa833ef700000000, 0xdf7bc70a00000000, + 0x4eeaafa400000000, 0xbc5e678d00000000, 0x2dcf0f2300000000, + 0x0e1b837200000000, 0x9f8aebdc00000000, 0x6d3e23f500000000, + 0xfcaf4b5b00000000, 0x8957b2a600000000, 0x18c6da0800000000, + 0xea72122100000000, 0x7be37a8f00000000, 0x4184900100000000, + 0xd015f8af00000000, 0x22a1308600000000, 0xb330582800000000, + 0xc6c8a1d500000000, 0x5759c97b00000000, 0xa5ed015200000000, + 0x347c69fc00000000, 0x9025a49400000000, 0x01b4cc3a00000000, + 0xf300041300000000, 0x62916cbd00000000, 0x1769954000000000, + 0x86f8fdee00000000, 0x744c35c700000000, 0xe5dd5d6900000000, + 0xdfbab7e700000000, 0x4e2bdf4900000000, 0xbc9f176000000000, + 0x2d0e7fce00000000, 0x58f6863300000000, 0xc967ee9d00000000, + 0x3bd326b400000000, 0xaa424e1a00000000, 0x7360bc6500000000, + 0xe2f1d4cb00000000, 0x10451ce200000000, 0x81d4744c00000000, + 0xf42c8db100000000, 0x65bde51f00000000, 0x97092d3600000000, + 0x0698459800000000, 0x3cffaf1600000000, 0xad6ec7b800000000, + 0x5fda0f9100000000, 0xce4b673f00000000, 0xbbb39ec200000000, + 0x2a22f66c00000000, 0xd8963e4500000000, 0x490756eb00000000, + 0xed5e9b8300000000, 0x7ccff32d00000000, 0x8e7b3b0400000000, + 0x1fea53aa00000000, 0x6a12aa5700000000, 0xfb83c2f900000000, + 0x09370ad000000000, 0x98a6627e00000000, 0xa2c188f000000000, + 0x3350e05e00000000, 0xc1e4287700000000, 0x507540d900000000, + 0x258db92400000000, 0xb41cd18a00000000, 0x46a819a300000000, + 0xd739710d00000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, + 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, + 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, + 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, + 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, + 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, + 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, + 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, + 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, + 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, + 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, + 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, + 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, + 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, + 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, + 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, + 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, + 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, + 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, + 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, + 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, + 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, + 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, + 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, + 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, + 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, + 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, + 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, + 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, + 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, + 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, + 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, + 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, + 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, + 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, + 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, + 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, + 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, + 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, + 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, + 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, + 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, + 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, + 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, + 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, + 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, + 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, + 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, + 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, + 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, + 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, + 0x264b06e6}, + {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, + 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, + 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, + 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, + 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, + 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, + 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, + 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, + 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, + 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, + 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, + 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, + 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, + 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, + 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, + 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, + 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, + 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, + 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, + 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, + 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, + 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, + 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, + 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, + 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, + 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, + 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, + 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, + 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, + 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, + 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, + 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, + 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, + 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, + 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, + 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, + 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, + 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, + 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, + 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, + 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, + 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, + 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, + 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, + 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, + 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, + 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, + 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, + 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, + 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, + 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, + 0x92364a30}, + {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, + 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, + 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, + 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, + 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, + 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, + 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, + 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, + 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, + 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, + 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, + 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, + 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, + 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, + 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, + 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, + 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, + 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, + 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, + 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, + 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, + 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, + 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, + 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, + 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, + 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, + 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, + 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, + 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, + 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, + 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, + 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, + 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, + 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, + 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, + 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, + 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, + 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, + 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, + 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, + 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, + 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, + 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, + 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, + 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, + 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, + 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, + 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, + 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, + 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, + 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, + 0xe4c4abcc}, + {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, + 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, + 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, + 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, + 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, + 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, + 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, + 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, + 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, + 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, + 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, + 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, + 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, + 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, + 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, + 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, + 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, + 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, + 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, + 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, + 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, + 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, + 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, + 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, + 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, + 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, + 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, + 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, + 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, + 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, + 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, + 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, + 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, + 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, + 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, + 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, + 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, + 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, + 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, + 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, + 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, + 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, + 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, + 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, + 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, + 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, + 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, + 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, + 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, + 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, + 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, + 0xca64c78c}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0xb029603d, 0x6053c07a, 0xd07aa047, 0xc0a680f5, + 0x708fe0c8, 0xa0f5408f, 0x10dc20b2, 0xc14b7030, 0x7162100d, + 0xa118b04a, 0x1131d077, 0x01edf0c5, 0xb1c490f8, 0x61be30bf, + 0xd1975082, 0x8297e060, 0x32be805d, 0xe2c4201a, 0x52ed4027, + 0x42316095, 0xf21800a8, 0x2262a0ef, 0x924bc0d2, 0x43dc9050, + 0xf3f5f06d, 0x238f502a, 0x93a63017, 0x837a10a5, 0x33537098, + 0xe329d0df, 0x5300b0e2, 0x042fc1c1, 0xb406a1fc, 0x647c01bb, + 0xd4556186, 0xc4894134, 0x74a02109, 0xa4da814e, 0x14f3e173, + 0xc564b1f1, 0x754dd1cc, 0xa537718b, 0x151e11b6, 0x05c23104, + 0xb5eb5139, 0x6591f17e, 0xd5b89143, 0x86b821a1, 0x3691419c, + 0xe6ebe1db, 0x56c281e6, 0x461ea154, 0xf637c169, 0x264d612e, + 0x96640113, 0x47f35191, 0xf7da31ac, 0x27a091eb, 0x9789f1d6, + 0x8755d164, 0x377cb159, 0xe706111e, 0x572f7123, 0x4958f358, + 0xf9719365, 0x290b3322, 0x9922531f, 0x89fe73ad, 0x39d71390, + 0xe9adb3d7, 0x5984d3ea, 0x88138368, 0x383ae355, 0xe8404312, + 0x5869232f, 0x48b5039d, 0xf89c63a0, 0x28e6c3e7, 0x98cfa3da, + 0xcbcf1338, 0x7be67305, 0xab9cd342, 0x1bb5b37f, 0x0b6993cd, + 0xbb40f3f0, 0x6b3a53b7, 0xdb13338a, 0x0a846308, 0xbaad0335, + 0x6ad7a372, 0xdafec34f, 0xca22e3fd, 0x7a0b83c0, 0xaa712387, + 0x1a5843ba, 0x4d773299, 0xfd5e52a4, 0x2d24f2e3, 0x9d0d92de, + 0x8dd1b26c, 0x3df8d251, 0xed827216, 0x5dab122b, 0x8c3c42a9, + 0x3c152294, 0xec6f82d3, 0x5c46e2ee, 0x4c9ac25c, 0xfcb3a261, + 0x2cc90226, 0x9ce0621b, 0xcfe0d2f9, 0x7fc9b2c4, 0xafb31283, + 0x1f9a72be, 0x0f46520c, 0xbf6f3231, 0x6f159276, 0xdf3cf24b, + 0x0eaba2c9, 0xbe82c2f4, 0x6ef862b3, 0xded1028e, 0xce0d223c, + 0x7e244201, 0xae5ee246, 0x1e77827b, 0x92b0e6b1, 0x2299868c, + 0xf2e326cb, 0x42ca46f6, 0x52166644, 0xe23f0679, 0x3245a63e, + 0x826cc603, 0x53fb9681, 0xe3d2f6bc, 0x33a856fb, 0x838136c6, + 0x935d1674, 0x23747649, 0xf30ed60e, 0x4327b633, 0x102706d1, + 0xa00e66ec, 0x7074c6ab, 0xc05da696, 0xd0818624, 0x60a8e619, + 0xb0d2465e, 0x00fb2663, 0xd16c76e1, 0x614516dc, 0xb13fb69b, + 0x0116d6a6, 0x11caf614, 0xa1e39629, 0x7199366e, 0xc1b05653, + 0x969f2770, 0x26b6474d, 0xf6cce70a, 0x46e58737, 0x5639a785, + 0xe610c7b8, 0x366a67ff, 0x864307c2, 0x57d45740, 0xe7fd377d, + 0x3787973a, 0x87aef707, 0x9772d7b5, 0x275bb788, 0xf72117cf, + 0x470877f2, 0x1408c710, 0xa421a72d, 0x745b076a, 0xc4726757, + 0xd4ae47e5, 0x648727d8, 0xb4fd879f, 0x04d4e7a2, 0xd543b720, + 0x656ad71d, 0xb510775a, 0x05391767, 0x15e537d5, 0xa5cc57e8, + 0x75b6f7af, 0xc59f9792, 0xdbe815e9, 0x6bc175d4, 0xbbbbd593, + 0x0b92b5ae, 0x1b4e951c, 0xab67f521, 0x7b1d5566, 0xcb34355b, + 0x1aa365d9, 0xaa8a05e4, 0x7af0a5a3, 0xcad9c59e, 0xda05e52c, + 0x6a2c8511, 0xba562556, 0x0a7f456b, 0x597ff589, 0xe95695b4, + 0x392c35f3, 0x890555ce, 0x99d9757c, 0x29f01541, 0xf98ab506, + 0x49a3d53b, 0x983485b9, 0x281de584, 0xf86745c3, 0x484e25fe, + 0x5892054c, 0xe8bb6571, 0x38c1c536, 0x88e8a50b, 0xdfc7d428, + 0x6feeb415, 0xbf941452, 0x0fbd746f, 0x1f6154dd, 0xaf4834e0, + 0x7f3294a7, 0xcf1bf49a, 0x1e8ca418, 0xaea5c425, 0x7edf6462, + 0xcef6045f, 0xde2a24ed, 0x6e0344d0, 0xbe79e497, 0x0e5084aa, + 0x5d503448, 0xed795475, 0x3d03f432, 0x8d2a940f, 0x9df6b4bd, + 0x2ddfd480, 0xfda574c7, 0x4d8c14fa, 0x9c1b4478, 0x2c322445, + 0xfc488402, 0x4c61e43f, 0x5cbdc48d, 0xec94a4b0, 0x3cee04f7, + 0x8cc764ca}, + {0x00000000, 0xa5d35ccb, 0x0ba1c84d, 0xae729486, 0x1642919b, + 0xb391cd50, 0x1de359d6, 0xb830051d, 0x6d8253ec, 0xc8510f27, + 0x66239ba1, 0xc3f0c76a, 0x7bc0c277, 0xde139ebc, 0x70610a3a, + 0xd5b256f1, 0x9b02d603, 0x3ed18ac8, 0x90a31e4e, 0x35704285, + 0x8d404798, 0x28931b53, 0x86e18fd5, 0x2332d31e, 0xf68085ef, + 0x5353d924, 0xfd214da2, 0x58f21169, 0xe0c21474, 0x451148bf, + 0xeb63dc39, 0x4eb080f2, 0x3605ac07, 0x93d6f0cc, 0x3da4644a, + 0x98773881, 0x20473d9c, 0x85946157, 0x2be6f5d1, 0x8e35a91a, + 0x5b87ffeb, 0xfe54a320, 0x502637a6, 0xf5f56b6d, 0x4dc56e70, + 0xe81632bb, 0x4664a63d, 0xe3b7faf6, 0xad077a04, 0x08d426cf, + 0xa6a6b249, 0x0375ee82, 0xbb45eb9f, 0x1e96b754, 0xb0e423d2, + 0x15377f19, 0xc08529e8, 0x65567523, 0xcb24e1a5, 0x6ef7bd6e, + 0xd6c7b873, 0x7314e4b8, 0xdd66703e, 0x78b52cf5, 0x6c0a580f, + 0xc9d904c4, 0x67ab9042, 0xc278cc89, 0x7a48c994, 0xdf9b955f, + 0x71e901d9, 0xd43a5d12, 0x01880be3, 0xa45b5728, 0x0a29c3ae, + 0xaffa9f65, 0x17ca9a78, 0xb219c6b3, 0x1c6b5235, 0xb9b80efe, + 0xf7088e0c, 0x52dbd2c7, 0xfca94641, 0x597a1a8a, 0xe14a1f97, + 0x4499435c, 0xeaebd7da, 0x4f388b11, 0x9a8adde0, 0x3f59812b, + 0x912b15ad, 0x34f84966, 0x8cc84c7b, 0x291b10b0, 0x87698436, + 0x22bad8fd, 0x5a0ff408, 0xffdca8c3, 0x51ae3c45, 0xf47d608e, + 0x4c4d6593, 0xe99e3958, 0x47ecadde, 0xe23ff115, 0x378da7e4, + 0x925efb2f, 0x3c2c6fa9, 0x99ff3362, 0x21cf367f, 0x841c6ab4, + 0x2a6efe32, 0x8fbda2f9, 0xc10d220b, 0x64de7ec0, 0xcaacea46, + 0x6f7fb68d, 0xd74fb390, 0x729cef5b, 0xdcee7bdd, 0x793d2716, + 0xac8f71e7, 0x095c2d2c, 0xa72eb9aa, 0x02fde561, 0xbacde07c, + 0x1f1ebcb7, 0xb16c2831, 0x14bf74fa, 0xd814b01e, 0x7dc7ecd5, + 0xd3b57853, 0x76662498, 0xce562185, 0x6b857d4e, 0xc5f7e9c8, + 0x6024b503, 0xb596e3f2, 0x1045bf39, 0xbe372bbf, 0x1be47774, + 0xa3d47269, 0x06072ea2, 0xa875ba24, 0x0da6e6ef, 0x4316661d, + 0xe6c53ad6, 0x48b7ae50, 0xed64f29b, 0x5554f786, 0xf087ab4d, + 0x5ef53fcb, 0xfb266300, 0x2e9435f1, 0x8b47693a, 0x2535fdbc, + 0x80e6a177, 0x38d6a46a, 0x9d05f8a1, 0x33776c27, 0x96a430ec, + 0xee111c19, 0x4bc240d2, 0xe5b0d454, 0x4063889f, 0xf8538d82, + 0x5d80d149, 0xf3f245cf, 0x56211904, 0x83934ff5, 0x2640133e, + 0x883287b8, 0x2de1db73, 0x95d1de6e, 0x300282a5, 0x9e701623, + 0x3ba34ae8, 0x7513ca1a, 0xd0c096d1, 0x7eb20257, 0xdb615e9c, + 0x63515b81, 0xc682074a, 0x68f093cc, 0xcd23cf07, 0x189199f6, + 0xbd42c53d, 0x133051bb, 0xb6e30d70, 0x0ed3086d, 0xab0054a6, + 0x0572c020, 0xa0a19ceb, 0xb41ee811, 0x11cdb4da, 0xbfbf205c, + 0x1a6c7c97, 0xa25c798a, 0x078f2541, 0xa9fdb1c7, 0x0c2eed0c, + 0xd99cbbfd, 0x7c4fe736, 0xd23d73b0, 0x77ee2f7b, 0xcfde2a66, + 0x6a0d76ad, 0xc47fe22b, 0x61acbee0, 0x2f1c3e12, 0x8acf62d9, + 0x24bdf65f, 0x816eaa94, 0x395eaf89, 0x9c8df342, 0x32ff67c4, + 0x972c3b0f, 0x429e6dfe, 0xe74d3135, 0x493fa5b3, 0xececf978, + 0x54dcfc65, 0xf10fa0ae, 0x5f7d3428, 0xfaae68e3, 0x821b4416, + 0x27c818dd, 0x89ba8c5b, 0x2c69d090, 0x9459d58d, 0x318a8946, + 0x9ff81dc0, 0x3a2b410b, 0xef9917fa, 0x4a4a4b31, 0xe438dfb7, + 0x41eb837c, 0xf9db8661, 0x5c08daaa, 0xf27a4e2c, 0x57a912e7, + 0x19199215, 0xbccacede, 0x12b85a58, 0xb76b0693, 0x0f5b038e, + 0xaa885f45, 0x04facbc3, 0xa1299708, 0x749bc1f9, 0xd1489d32, + 0x7f3a09b4, 0xdae9557f, 0x62d95062, 0xc70a0ca9, 0x6978982f, + 0xccabc4e4}, + {0x00000000, 0xb40b77a6, 0x29119f97, 0x9d1ae831, 0x13244ff4, + 0xa72f3852, 0x3a35d063, 0x8e3ea7c5, 0x674eef33, 0xd3459895, + 0x4e5f70a4, 0xfa540702, 0x746aa0c7, 0xc061d761, 0x5d7b3f50, + 0xe97048f6, 0xce9cde67, 0x7a97a9c1, 0xe78d41f0, 0x53863656, + 0xddb89193, 0x69b3e635, 0xf4a90e04, 0x40a279a2, 0xa9d23154, + 0x1dd946f2, 0x80c3aec3, 0x34c8d965, 0xbaf67ea0, 0x0efd0906, + 0x93e7e137, 0x27ec9691, 0x9c39bdcf, 0x2832ca69, 0xb5282258, + 0x012355fe, 0x8f1df23b, 0x3b16859d, 0xa60c6dac, 0x12071a0a, + 0xfb7752fc, 0x4f7c255a, 0xd266cd6b, 0x666dbacd, 0xe8531d08, + 0x5c586aae, 0xc142829f, 0x7549f539, 0x52a563a8, 0xe6ae140e, + 0x7bb4fc3f, 0xcfbf8b99, 0x41812c5c, 0xf58a5bfa, 0x6890b3cb, + 0xdc9bc46d, 0x35eb8c9b, 0x81e0fb3d, 0x1cfa130c, 0xa8f164aa, + 0x26cfc36f, 0x92c4b4c9, 0x0fde5cf8, 0xbbd52b5e, 0x79750b44, + 0xcd7e7ce2, 0x506494d3, 0xe46fe375, 0x6a5144b0, 0xde5a3316, + 0x4340db27, 0xf74bac81, 0x1e3be477, 0xaa3093d1, 0x372a7be0, + 0x83210c46, 0x0d1fab83, 0xb914dc25, 0x240e3414, 0x900543b2, + 0xb7e9d523, 0x03e2a285, 0x9ef84ab4, 0x2af33d12, 0xa4cd9ad7, + 0x10c6ed71, 0x8ddc0540, 0x39d772e6, 0xd0a73a10, 0x64ac4db6, + 0xf9b6a587, 0x4dbdd221, 0xc38375e4, 0x77880242, 0xea92ea73, + 0x5e999dd5, 0xe54cb68b, 0x5147c12d, 0xcc5d291c, 0x78565eba, + 0xf668f97f, 0x42638ed9, 0xdf7966e8, 0x6b72114e, 0x820259b8, + 0x36092e1e, 0xab13c62f, 0x1f18b189, 0x9126164c, 0x252d61ea, + 0xb83789db, 0x0c3cfe7d, 0x2bd068ec, 0x9fdb1f4a, 0x02c1f77b, + 0xb6ca80dd, 0x38f42718, 0x8cff50be, 0x11e5b88f, 0xa5eecf29, + 0x4c9e87df, 0xf895f079, 0x658f1848, 0xd1846fee, 0x5fbac82b, + 0xebb1bf8d, 0x76ab57bc, 0xc2a0201a, 0xf2ea1688, 0x46e1612e, + 0xdbfb891f, 0x6ff0feb9, 0xe1ce597c, 0x55c52eda, 0xc8dfc6eb, + 0x7cd4b14d, 0x95a4f9bb, 0x21af8e1d, 0xbcb5662c, 0x08be118a, + 0x8680b64f, 0x328bc1e9, 0xaf9129d8, 0x1b9a5e7e, 0x3c76c8ef, + 0x887dbf49, 0x15675778, 0xa16c20de, 0x2f52871b, 0x9b59f0bd, + 0x0643188c, 0xb2486f2a, 0x5b3827dc, 0xef33507a, 0x7229b84b, + 0xc622cfed, 0x481c6828, 0xfc171f8e, 0x610df7bf, 0xd5068019, + 0x6ed3ab47, 0xdad8dce1, 0x47c234d0, 0xf3c94376, 0x7df7e4b3, + 0xc9fc9315, 0x54e67b24, 0xe0ed0c82, 0x099d4474, 0xbd9633d2, + 0x208cdbe3, 0x9487ac45, 0x1ab90b80, 0xaeb27c26, 0x33a89417, + 0x87a3e3b1, 0xa04f7520, 0x14440286, 0x895eeab7, 0x3d559d11, + 0xb36b3ad4, 0x07604d72, 0x9a7aa543, 0x2e71d2e5, 0xc7019a13, + 0x730aedb5, 0xee100584, 0x5a1b7222, 0xd425d5e7, 0x602ea241, + 0xfd344a70, 0x493f3dd6, 0x8b9f1dcc, 0x3f946a6a, 0xa28e825b, + 0x1685f5fd, 0x98bb5238, 0x2cb0259e, 0xb1aacdaf, 0x05a1ba09, + 0xecd1f2ff, 0x58da8559, 0xc5c06d68, 0x71cb1ace, 0xfff5bd0b, + 0x4bfecaad, 0xd6e4229c, 0x62ef553a, 0x4503c3ab, 0xf108b40d, + 0x6c125c3c, 0xd8192b9a, 0x56278c5f, 0xe22cfbf9, 0x7f3613c8, + 0xcb3d646e, 0x224d2c98, 0x96465b3e, 0x0b5cb30f, 0xbf57c4a9, + 0x3169636c, 0x856214ca, 0x1878fcfb, 0xac738b5d, 0x17a6a003, + 0xa3add7a5, 0x3eb73f94, 0x8abc4832, 0x0482eff7, 0xb0899851, + 0x2d937060, 0x999807c6, 0x70e84f30, 0xc4e33896, 0x59f9d0a7, + 0xedf2a701, 0x63cc00c4, 0xd7c77762, 0x4add9f53, 0xfed6e8f5, + 0xd93a7e64, 0x6d3109c2, 0xf02be1f3, 0x44209655, 0xca1e3190, + 0x7e154636, 0xe30fae07, 0x5704d9a1, 0xbe749157, 0x0a7fe6f1, + 0x97650ec0, 0x236e7966, 0xad50dea3, 0x195ba905, 0x84414134, + 0x304a3692}, + {0x00000000, 0x9e00aacc, 0x7d072542, 0xe3078f8e, 0xfa0e4a84, + 0x640ee048, 0x87096fc6, 0x1909c50a, 0xb51be5d3, 0x2b1b4f1f, + 0xc81cc091, 0x561c6a5d, 0x4f15af57, 0xd115059b, 0x32128a15, + 0xac1220d9, 0x2b31bb7c, 0xb53111b0, 0x56369e3e, 0xc83634f2, + 0xd13ff1f8, 0x4f3f5b34, 0xac38d4ba, 0x32387e76, 0x9e2a5eaf, + 0x002af463, 0xe32d7bed, 0x7d2dd121, 0x6424142b, 0xfa24bee7, + 0x19233169, 0x87239ba5, 0x566276f9, 0xc862dc35, 0x2b6553bb, + 0xb565f977, 0xac6c3c7d, 0x326c96b1, 0xd16b193f, 0x4f6bb3f3, + 0xe379932a, 0x7d7939e6, 0x9e7eb668, 0x007e1ca4, 0x1977d9ae, + 0x87777362, 0x6470fcec, 0xfa705620, 0x7d53cd85, 0xe3536749, + 0x0054e8c7, 0x9e54420b, 0x875d8701, 0x195d2dcd, 0xfa5aa243, + 0x645a088f, 0xc8482856, 0x5648829a, 0xb54f0d14, 0x2b4fa7d8, + 0x324662d2, 0xac46c81e, 0x4f414790, 0xd141ed5c, 0xedc29d29, + 0x73c237e5, 0x90c5b86b, 0x0ec512a7, 0x17ccd7ad, 0x89cc7d61, + 0x6acbf2ef, 0xf4cb5823, 0x58d978fa, 0xc6d9d236, 0x25de5db8, + 0xbbdef774, 0xa2d7327e, 0x3cd798b2, 0xdfd0173c, 0x41d0bdf0, + 0xc6f32655, 0x58f38c99, 0xbbf40317, 0x25f4a9db, 0x3cfd6cd1, + 0xa2fdc61d, 0x41fa4993, 0xdffae35f, 0x73e8c386, 0xede8694a, + 0x0eefe6c4, 0x90ef4c08, 0x89e68902, 0x17e623ce, 0xf4e1ac40, + 0x6ae1068c, 0xbba0ebd0, 0x25a0411c, 0xc6a7ce92, 0x58a7645e, + 0x41aea154, 0xdfae0b98, 0x3ca98416, 0xa2a92eda, 0x0ebb0e03, + 0x90bba4cf, 0x73bc2b41, 0xedbc818d, 0xf4b54487, 0x6ab5ee4b, + 0x89b261c5, 0x17b2cb09, 0x909150ac, 0x0e91fa60, 0xed9675ee, + 0x7396df22, 0x6a9f1a28, 0xf49fb0e4, 0x17983f6a, 0x899895a6, + 0x258ab57f, 0xbb8a1fb3, 0x588d903d, 0xc68d3af1, 0xdf84fffb, + 0x41845537, 0xa283dab9, 0x3c837075, 0xda853b53, 0x4485919f, + 0xa7821e11, 0x3982b4dd, 0x208b71d7, 0xbe8bdb1b, 0x5d8c5495, + 0xc38cfe59, 0x6f9ede80, 0xf19e744c, 0x1299fbc2, 0x8c99510e, + 0x95909404, 0x0b903ec8, 0xe897b146, 0x76971b8a, 0xf1b4802f, + 0x6fb42ae3, 0x8cb3a56d, 0x12b30fa1, 0x0bbacaab, 0x95ba6067, + 0x76bdefe9, 0xe8bd4525, 0x44af65fc, 0xdaafcf30, 0x39a840be, + 0xa7a8ea72, 0xbea12f78, 0x20a185b4, 0xc3a60a3a, 0x5da6a0f6, + 0x8ce74daa, 0x12e7e766, 0xf1e068e8, 0x6fe0c224, 0x76e9072e, + 0xe8e9ade2, 0x0bee226c, 0x95ee88a0, 0x39fca879, 0xa7fc02b5, + 0x44fb8d3b, 0xdafb27f7, 0xc3f2e2fd, 0x5df24831, 0xbef5c7bf, + 0x20f56d73, 0xa7d6f6d6, 0x39d65c1a, 0xdad1d394, 0x44d17958, + 0x5dd8bc52, 0xc3d8169e, 0x20df9910, 0xbedf33dc, 0x12cd1305, + 0x8ccdb9c9, 0x6fca3647, 0xf1ca9c8b, 0xe8c35981, 0x76c3f34d, + 0x95c47cc3, 0x0bc4d60f, 0x3747a67a, 0xa9470cb6, 0x4a408338, + 0xd44029f4, 0xcd49ecfe, 0x53494632, 0xb04ec9bc, 0x2e4e6370, + 0x825c43a9, 0x1c5ce965, 0xff5b66eb, 0x615bcc27, 0x7852092d, + 0xe652a3e1, 0x05552c6f, 0x9b5586a3, 0x1c761d06, 0x8276b7ca, + 0x61713844, 0xff719288, 0xe6785782, 0x7878fd4e, 0x9b7f72c0, + 0x057fd80c, 0xa96df8d5, 0x376d5219, 0xd46add97, 0x4a6a775b, + 0x5363b251, 0xcd63189d, 0x2e649713, 0xb0643ddf, 0x6125d083, + 0xff257a4f, 0x1c22f5c1, 0x82225f0d, 0x9b2b9a07, 0x052b30cb, + 0xe62cbf45, 0x782c1589, 0xd43e3550, 0x4a3e9f9c, 0xa9391012, + 0x3739bade, 0x2e307fd4, 0xb030d518, 0x53375a96, 0xcd37f05a, + 0x4a146bff, 0xd414c133, 0x37134ebd, 0xa913e471, 0xb01a217b, + 0x2e1a8bb7, 0xcd1d0439, 0x531daef5, 0xff0f8e2c, 0x610f24e0, + 0x8208ab6e, 0x1c0801a2, 0x0501c4a8, 0x9b016e64, 0x7806e1ea, + 0xe6064b26}}; + #endif - } -}; + +#endif + +#if N == 3 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, + 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, + 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, + 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, + 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, + 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, + 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, + 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, + 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, + 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, + 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, + 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, + 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, + 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, + 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, + 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, + 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, + 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, + 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, + 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, + 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, + 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, + 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, + 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, + 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, + 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, + 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, + 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, + 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, + 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, + 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, + 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, + 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, + 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, + 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, + 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, + 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, + 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, + 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, + 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, + 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, + 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, + 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, + 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, + 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, + 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, + 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, + 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, + 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, + 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, + 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, + 0x09cd8551}, + {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, + 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, + 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, + 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, + 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, + 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, + 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, + 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, + 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, + 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, + 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, + 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, + 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, + 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, + 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, + 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, + 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, + 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, + 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, + 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, + 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, + 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, + 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, + 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, + 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, + 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, + 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, + 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, + 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, + 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, + 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, + 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, + 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, + 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, + 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, + 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, + 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, + 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, + 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, + 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, + 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, + 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, + 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, + 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, + 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, + 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, + 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, + 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, + 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, + 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, + 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, + 0x7bc97a0c}, + {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, + 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, + 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, + 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, + 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, + 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, + 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, + 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, + 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, + 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, + 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, + 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, + 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, + 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, + 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, + 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, + 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, + 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, + 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, + 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, + 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, + 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, + 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, + 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, + 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, + 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, + 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, + 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, + 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, + 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, + 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, + 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, + 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, + 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, + 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, + 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, + 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, + 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, + 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, + 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, + 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, + 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, + 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, + 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, + 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, + 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, + 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, + 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, + 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, + 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, + 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, + 0x7851a2ca}, + {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, + 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, + 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, + 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, + 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, + 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, + 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, + 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, + 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, + 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, + 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, + 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, + 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, + 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, + 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, + 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, + 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, + 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, + 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, + 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, + 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, + 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, + 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, + 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, + 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, + 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, + 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, + 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, + 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, + 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, + 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, + 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, + 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, + 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, + 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, + 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, + 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, + 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, + 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, + 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, + 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, + 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, + 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, + 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, + 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, + 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, + 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, + 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, + 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, + 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, + 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, + 0x566b6848}, + {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, + 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, + 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, + 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, + 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, + 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, + 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, + 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, + 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, + 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, + 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, + 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, + 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, + 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, + 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, + 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, + 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, + 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, + 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, + 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, + 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, + 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, + 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, + 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, + 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, + 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, + 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, + 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, + 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, + 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, + 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, + 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, + 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, + 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, + 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, + 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, + 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, + 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, + 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, + 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, + 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, + 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, + 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, + 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, + 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, + 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, + 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, + 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, + 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, + 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, + 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, + 0xd8ac6b35}, + {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, + 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, + 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, + 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, + 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, + 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, + 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, + 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, + 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, + 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, + 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, + 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, + 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, + 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, + 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, + 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, + 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, + 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, + 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, + 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, + 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, + 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, + 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, + 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, + 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, + 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, + 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, + 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, + 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, + 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, + 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, + 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, + 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, + 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, + 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, + 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, + 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, + 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, + 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, + 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, + 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, + 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, + 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, + 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, + 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, + 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, + 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, + 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, + 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, + 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, + 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, + 0xa140efa8}, + {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, + 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, + 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, + 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, + 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, + 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, + 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, + 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, + 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, + 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, + 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, + 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, + 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, + 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, + 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, + 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, + 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, + 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, + 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, + 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, + 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, + 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, + 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, + 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, + 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, + 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, + 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, + 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, + 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, + 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, + 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, + 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, + 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, + 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, + 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, + 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, + 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, + 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, + 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, + 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, + 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, + 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, + 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, + 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, + 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, + 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, + 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, + 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, + 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, + 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, + 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, + 0x917cd6a1}, + {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, + 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, + 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, + 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, + 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, + 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, + 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, + 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, + 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, + 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, + 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, + 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, + 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, + 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, + 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, + 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, + 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, + 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, + 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, + 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, + 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, + 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, + 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, + 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, + 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, + 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, + 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, + 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, + 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, + 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, + 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, + 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, + 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, + 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, + 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, + 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, + 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, + 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, + 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, + 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, + 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, + 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, + 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, + 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, + 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, + 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, + 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, + 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, + 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, + 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, + 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, + 0x18ba364e}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x43cba68700000000, 0xc7903cd400000000, + 0x845b9a5300000000, 0xcf27087300000000, 0x8cecaef400000000, + 0x08b734a700000000, 0x4b7c922000000000, 0x9e4f10e600000000, + 0xdd84b66100000000, 0x59df2c3200000000, 0x1a148ab500000000, + 0x5168189500000000, 0x12a3be1200000000, 0x96f8244100000000, + 0xd53382c600000000, 0x7d99511700000000, 0x3e52f79000000000, + 0xba096dc300000000, 0xf9c2cb4400000000, 0xb2be596400000000, + 0xf175ffe300000000, 0x752e65b000000000, 0x36e5c33700000000, + 0xe3d641f100000000, 0xa01de77600000000, 0x24467d2500000000, + 0x678ddba200000000, 0x2cf1498200000000, 0x6f3aef0500000000, + 0xeb61755600000000, 0xa8aad3d100000000, 0xfa32a32e00000000, + 0xb9f905a900000000, 0x3da29ffa00000000, 0x7e69397d00000000, + 0x3515ab5d00000000, 0x76de0dda00000000, 0xf285978900000000, + 0xb14e310e00000000, 0x647db3c800000000, 0x27b6154f00000000, + 0xa3ed8f1c00000000, 0xe026299b00000000, 0xab5abbbb00000000, + 0xe8911d3c00000000, 0x6cca876f00000000, 0x2f0121e800000000, + 0x87abf23900000000, 0xc46054be00000000, 0x403bceed00000000, + 0x03f0686a00000000, 0x488cfa4a00000000, 0x0b475ccd00000000, + 0x8f1cc69e00000000, 0xccd7601900000000, 0x19e4e2df00000000, + 0x5a2f445800000000, 0xde74de0b00000000, 0x9dbf788c00000000, + 0xd6c3eaac00000000, 0x95084c2b00000000, 0x1153d67800000000, + 0x529870ff00000000, 0xf465465d00000000, 0xb7aee0da00000000, + 0x33f57a8900000000, 0x703edc0e00000000, 0x3b424e2e00000000, + 0x7889e8a900000000, 0xfcd272fa00000000, 0xbf19d47d00000000, + 0x6a2a56bb00000000, 0x29e1f03c00000000, 0xadba6a6f00000000, + 0xee71cce800000000, 0xa50d5ec800000000, 0xe6c6f84f00000000, + 0x629d621c00000000, 0x2156c49b00000000, 0x89fc174a00000000, + 0xca37b1cd00000000, 0x4e6c2b9e00000000, 0x0da78d1900000000, + 0x46db1f3900000000, 0x0510b9be00000000, 0x814b23ed00000000, + 0xc280856a00000000, 0x17b307ac00000000, 0x5478a12b00000000, + 0xd0233b7800000000, 0x93e89dff00000000, 0xd8940fdf00000000, + 0x9b5fa95800000000, 0x1f04330b00000000, 0x5ccf958c00000000, + 0x0e57e57300000000, 0x4d9c43f400000000, 0xc9c7d9a700000000, + 0x8a0c7f2000000000, 0xc170ed0000000000, 0x82bb4b8700000000, + 0x06e0d1d400000000, 0x452b775300000000, 0x9018f59500000000, + 0xd3d3531200000000, 0x5788c94100000000, 0x14436fc600000000, + 0x5f3ffde600000000, 0x1cf45b6100000000, 0x98afc13200000000, + 0xdb6467b500000000, 0x73ceb46400000000, 0x300512e300000000, + 0xb45e88b000000000, 0xf7952e3700000000, 0xbce9bc1700000000, + 0xff221a9000000000, 0x7b7980c300000000, 0x38b2264400000000, + 0xed81a48200000000, 0xae4a020500000000, 0x2a11985600000000, + 0x69da3ed100000000, 0x22a6acf100000000, 0x616d0a7600000000, + 0xe536902500000000, 0xa6fd36a200000000, 0xe8cb8cba00000000, + 0xab002a3d00000000, 0x2f5bb06e00000000, 0x6c9016e900000000, + 0x27ec84c900000000, 0x6427224e00000000, 0xe07cb81d00000000, + 0xa3b71e9a00000000, 0x76849c5c00000000, 0x354f3adb00000000, + 0xb114a08800000000, 0xf2df060f00000000, 0xb9a3942f00000000, + 0xfa6832a800000000, 0x7e33a8fb00000000, 0x3df80e7c00000000, + 0x9552ddad00000000, 0xd6997b2a00000000, 0x52c2e17900000000, + 0x110947fe00000000, 0x5a75d5de00000000, 0x19be735900000000, + 0x9de5e90a00000000, 0xde2e4f8d00000000, 0x0b1dcd4b00000000, + 0x48d66bcc00000000, 0xcc8df19f00000000, 0x8f46571800000000, + 0xc43ac53800000000, 0x87f163bf00000000, 0x03aaf9ec00000000, + 0x40615f6b00000000, 0x12f92f9400000000, 0x5132891300000000, + 0xd569134000000000, 0x96a2b5c700000000, 0xddde27e700000000, + 0x9e15816000000000, 0x1a4e1b3300000000, 0x5985bdb400000000, + 0x8cb63f7200000000, 0xcf7d99f500000000, 0x4b2603a600000000, + 0x08eda52100000000, 0x4391370100000000, 0x005a918600000000, + 0x84010bd500000000, 0xc7caad5200000000, 0x6f607e8300000000, + 0x2cabd80400000000, 0xa8f0425700000000, 0xeb3be4d000000000, + 0xa04776f000000000, 0xe38cd07700000000, 0x67d74a2400000000, + 0x241ceca300000000, 0xf12f6e6500000000, 0xb2e4c8e200000000, + 0x36bf52b100000000, 0x7574f43600000000, 0x3e08661600000000, + 0x7dc3c09100000000, 0xf9985ac200000000, 0xba53fc4500000000, + 0x1caecae700000000, 0x5f656c6000000000, 0xdb3ef63300000000, + 0x98f550b400000000, 0xd389c29400000000, 0x9042641300000000, + 0x1419fe4000000000, 0x57d258c700000000, 0x82e1da0100000000, + 0xc12a7c8600000000, 0x4571e6d500000000, 0x06ba405200000000, + 0x4dc6d27200000000, 0x0e0d74f500000000, 0x8a56eea600000000, + 0xc99d482100000000, 0x61379bf000000000, 0x22fc3d7700000000, + 0xa6a7a72400000000, 0xe56c01a300000000, 0xae10938300000000, + 0xeddb350400000000, 0x6980af5700000000, 0x2a4b09d000000000, + 0xff788b1600000000, 0xbcb32d9100000000, 0x38e8b7c200000000, + 0x7b23114500000000, 0x305f836500000000, 0x739425e200000000, + 0xf7cfbfb100000000, 0xb404193600000000, 0xe69c69c900000000, + 0xa557cf4e00000000, 0x210c551d00000000, 0x62c7f39a00000000, + 0x29bb61ba00000000, 0x6a70c73d00000000, 0xee2b5d6e00000000, + 0xade0fbe900000000, 0x78d3792f00000000, 0x3b18dfa800000000, + 0xbf4345fb00000000, 0xfc88e37c00000000, 0xb7f4715c00000000, + 0xf43fd7db00000000, 0x70644d8800000000, 0x33afeb0f00000000, + 0x9b0538de00000000, 0xd8ce9e5900000000, 0x5c95040a00000000, + 0x1f5ea28d00000000, 0x542230ad00000000, 0x17e9962a00000000, + 0x93b20c7900000000, 0xd079aafe00000000, 0x054a283800000000, + 0x46818ebf00000000, 0xc2da14ec00000000, 0x8111b26b00000000, + 0xca6d204b00000000, 0x89a686cc00000000, 0x0dfd1c9f00000000, + 0x4e36ba1800000000}, + {0x0000000000000000, 0xe1b652ef00000000, 0x836bd40500000000, + 0x62dd86ea00000000, 0x06d7a80b00000000, 0xe761fae400000000, + 0x85bc7c0e00000000, 0x640a2ee100000000, 0x0cae511700000000, + 0xed1803f800000000, 0x8fc5851200000000, 0x6e73d7fd00000000, + 0x0a79f91c00000000, 0xebcfabf300000000, 0x89122d1900000000, + 0x68a47ff600000000, 0x185ca32e00000000, 0xf9eaf1c100000000, + 0x9b37772b00000000, 0x7a8125c400000000, 0x1e8b0b2500000000, + 0xff3d59ca00000000, 0x9de0df2000000000, 0x7c568dcf00000000, + 0x14f2f23900000000, 0xf544a0d600000000, 0x9799263c00000000, + 0x762f74d300000000, 0x12255a3200000000, 0xf39308dd00000000, + 0x914e8e3700000000, 0x70f8dcd800000000, 0x30b8465d00000000, + 0xd10e14b200000000, 0xb3d3925800000000, 0x5265c0b700000000, + 0x366fee5600000000, 0xd7d9bcb900000000, 0xb5043a5300000000, + 0x54b268bc00000000, 0x3c16174a00000000, 0xdda045a500000000, + 0xbf7dc34f00000000, 0x5ecb91a000000000, 0x3ac1bf4100000000, + 0xdb77edae00000000, 0xb9aa6b4400000000, 0x581c39ab00000000, + 0x28e4e57300000000, 0xc952b79c00000000, 0xab8f317600000000, + 0x4a39639900000000, 0x2e334d7800000000, 0xcf851f9700000000, + 0xad58997d00000000, 0x4ceecb9200000000, 0x244ab46400000000, + 0xc5fce68b00000000, 0xa721606100000000, 0x4697328e00000000, + 0x229d1c6f00000000, 0xc32b4e8000000000, 0xa1f6c86a00000000, + 0x40409a8500000000, 0x60708dba00000000, 0x81c6df5500000000, + 0xe31b59bf00000000, 0x02ad0b5000000000, 0x66a725b100000000, + 0x8711775e00000000, 0xe5ccf1b400000000, 0x047aa35b00000000, + 0x6cdedcad00000000, 0x8d688e4200000000, 0xefb508a800000000, + 0x0e035a4700000000, 0x6a0974a600000000, 0x8bbf264900000000, + 0xe962a0a300000000, 0x08d4f24c00000000, 0x782c2e9400000000, + 0x999a7c7b00000000, 0xfb47fa9100000000, 0x1af1a87e00000000, + 0x7efb869f00000000, 0x9f4dd47000000000, 0xfd90529a00000000, + 0x1c26007500000000, 0x74827f8300000000, 0x95342d6c00000000, + 0xf7e9ab8600000000, 0x165ff96900000000, 0x7255d78800000000, + 0x93e3856700000000, 0xf13e038d00000000, 0x1088516200000000, + 0x50c8cbe700000000, 0xb17e990800000000, 0xd3a31fe200000000, + 0x32154d0d00000000, 0x561f63ec00000000, 0xb7a9310300000000, + 0xd574b7e900000000, 0x34c2e50600000000, 0x5c669af000000000, + 0xbdd0c81f00000000, 0xdf0d4ef500000000, 0x3ebb1c1a00000000, + 0x5ab132fb00000000, 0xbb07601400000000, 0xd9dae6fe00000000, + 0x386cb41100000000, 0x489468c900000000, 0xa9223a2600000000, + 0xcbffbccc00000000, 0x2a49ee2300000000, 0x4e43c0c200000000, + 0xaff5922d00000000, 0xcd2814c700000000, 0x2c9e462800000000, + 0x443a39de00000000, 0xa58c6b3100000000, 0xc751eddb00000000, + 0x26e7bf3400000000, 0x42ed91d500000000, 0xa35bc33a00000000, + 0xc18645d000000000, 0x2030173f00000000, 0x81e66bae00000000, + 0x6050394100000000, 0x028dbfab00000000, 0xe33bed4400000000, + 0x8731c3a500000000, 0x6687914a00000000, 0x045a17a000000000, + 0xe5ec454f00000000, 0x8d483ab900000000, 0x6cfe685600000000, + 0x0e23eebc00000000, 0xef95bc5300000000, 0x8b9f92b200000000, + 0x6a29c05d00000000, 0x08f446b700000000, 0xe942145800000000, + 0x99bac88000000000, 0x780c9a6f00000000, 0x1ad11c8500000000, + 0xfb674e6a00000000, 0x9f6d608b00000000, 0x7edb326400000000, + 0x1c06b48e00000000, 0xfdb0e66100000000, 0x9514999700000000, + 0x74a2cb7800000000, 0x167f4d9200000000, 0xf7c91f7d00000000, + 0x93c3319c00000000, 0x7275637300000000, 0x10a8e59900000000, + 0xf11eb77600000000, 0xb15e2df300000000, 0x50e87f1c00000000, + 0x3235f9f600000000, 0xd383ab1900000000, 0xb78985f800000000, + 0x563fd71700000000, 0x34e251fd00000000, 0xd554031200000000, + 0xbdf07ce400000000, 0x5c462e0b00000000, 0x3e9ba8e100000000, + 0xdf2dfa0e00000000, 0xbb27d4ef00000000, 0x5a91860000000000, + 0x384c00ea00000000, 0xd9fa520500000000, 0xa9028edd00000000, + 0x48b4dc3200000000, 0x2a695ad800000000, 0xcbdf083700000000, + 0xafd526d600000000, 0x4e63743900000000, 0x2cbef2d300000000, + 0xcd08a03c00000000, 0xa5acdfca00000000, 0x441a8d2500000000, + 0x26c70bcf00000000, 0xc771592000000000, 0xa37b77c100000000, + 0x42cd252e00000000, 0x2010a3c400000000, 0xc1a6f12b00000000, + 0xe196e61400000000, 0x0020b4fb00000000, 0x62fd321100000000, + 0x834b60fe00000000, 0xe7414e1f00000000, 0x06f71cf000000000, + 0x642a9a1a00000000, 0x859cc8f500000000, 0xed38b70300000000, + 0x0c8ee5ec00000000, 0x6e53630600000000, 0x8fe531e900000000, + 0xebef1f0800000000, 0x0a594de700000000, 0x6884cb0d00000000, + 0x893299e200000000, 0xf9ca453a00000000, 0x187c17d500000000, + 0x7aa1913f00000000, 0x9b17c3d000000000, 0xff1ded3100000000, + 0x1eabbfde00000000, 0x7c76393400000000, 0x9dc06bdb00000000, + 0xf564142d00000000, 0x14d246c200000000, 0x760fc02800000000, + 0x97b992c700000000, 0xf3b3bc2600000000, 0x1205eec900000000, + 0x70d8682300000000, 0x916e3acc00000000, 0xd12ea04900000000, + 0x3098f2a600000000, 0x5245744c00000000, 0xb3f326a300000000, + 0xd7f9084200000000, 0x364f5aad00000000, 0x5492dc4700000000, + 0xb5248ea800000000, 0xdd80f15e00000000, 0x3c36a3b100000000, + 0x5eeb255b00000000, 0xbf5d77b400000000, 0xdb57595500000000, + 0x3ae10bba00000000, 0x583c8d5000000000, 0xb98adfbf00000000, + 0xc972036700000000, 0x28c4518800000000, 0x4a19d76200000000, + 0xabaf858d00000000, 0xcfa5ab6c00000000, 0x2e13f98300000000, + 0x4cce7f6900000000, 0xad782d8600000000, 0xc5dc527000000000, + 0x246a009f00000000, 0x46b7867500000000, 0xa701d49a00000000, + 0xc30bfa7b00000000, 0x22bda89400000000, 0x40602e7e00000000, + 0xa1d67c9100000000}, + {0x0000000000000000, 0x5880e2d700000000, 0xf106b47400000000, + 0xa98656a300000000, 0xe20d68e900000000, 0xba8d8a3e00000000, + 0x130bdc9d00000000, 0x4b8b3e4a00000000, 0x851da10900000000, + 0xdd9d43de00000000, 0x741b157d00000000, 0x2c9bf7aa00000000, + 0x6710c9e000000000, 0x3f902b3700000000, 0x96167d9400000000, + 0xce969f4300000000, 0x0a3b421300000000, 0x52bba0c400000000, + 0xfb3df66700000000, 0xa3bd14b000000000, 0xe8362afa00000000, + 0xb0b6c82d00000000, 0x19309e8e00000000, 0x41b07c5900000000, + 0x8f26e31a00000000, 0xd7a601cd00000000, 0x7e20576e00000000, + 0x26a0b5b900000000, 0x6d2b8bf300000000, 0x35ab692400000000, + 0x9c2d3f8700000000, 0xc4addd5000000000, 0x1476842600000000, + 0x4cf666f100000000, 0xe570305200000000, 0xbdf0d28500000000, + 0xf67beccf00000000, 0xaefb0e1800000000, 0x077d58bb00000000, + 0x5ffdba6c00000000, 0x916b252f00000000, 0xc9ebc7f800000000, + 0x606d915b00000000, 0x38ed738c00000000, 0x73664dc600000000, + 0x2be6af1100000000, 0x8260f9b200000000, 0xdae01b6500000000, + 0x1e4dc63500000000, 0x46cd24e200000000, 0xef4b724100000000, + 0xb7cb909600000000, 0xfc40aedc00000000, 0xa4c04c0b00000000, + 0x0d461aa800000000, 0x55c6f87f00000000, 0x9b50673c00000000, + 0xc3d085eb00000000, 0x6a56d34800000000, 0x32d6319f00000000, + 0x795d0fd500000000, 0x21dded0200000000, 0x885bbba100000000, + 0xd0db597600000000, 0x28ec084d00000000, 0x706cea9a00000000, + 0xd9eabc3900000000, 0x816a5eee00000000, 0xcae160a400000000, + 0x9261827300000000, 0x3be7d4d000000000, 0x6367360700000000, + 0xadf1a94400000000, 0xf5714b9300000000, 0x5cf71d3000000000, + 0x0477ffe700000000, 0x4ffcc1ad00000000, 0x177c237a00000000, + 0xbefa75d900000000, 0xe67a970e00000000, 0x22d74a5e00000000, + 0x7a57a88900000000, 0xd3d1fe2a00000000, 0x8b511cfd00000000, + 0xc0da22b700000000, 0x985ac06000000000, 0x31dc96c300000000, + 0x695c741400000000, 0xa7caeb5700000000, 0xff4a098000000000, + 0x56cc5f2300000000, 0x0e4cbdf400000000, 0x45c783be00000000, + 0x1d47616900000000, 0xb4c137ca00000000, 0xec41d51d00000000, + 0x3c9a8c6b00000000, 0x641a6ebc00000000, 0xcd9c381f00000000, + 0x951cdac800000000, 0xde97e48200000000, 0x8617065500000000, + 0x2f9150f600000000, 0x7711b22100000000, 0xb9872d6200000000, + 0xe107cfb500000000, 0x4881991600000000, 0x10017bc100000000, + 0x5b8a458b00000000, 0x030aa75c00000000, 0xaa8cf1ff00000000, + 0xf20c132800000000, 0x36a1ce7800000000, 0x6e212caf00000000, + 0xc7a77a0c00000000, 0x9f2798db00000000, 0xd4aca69100000000, + 0x8c2c444600000000, 0x25aa12e500000000, 0x7d2af03200000000, + 0xb3bc6f7100000000, 0xeb3c8da600000000, 0x42badb0500000000, + 0x1a3a39d200000000, 0x51b1079800000000, 0x0931e54f00000000, + 0xa0b7b3ec00000000, 0xf837513b00000000, 0x50d8119a00000000, + 0x0858f34d00000000, 0xa1dea5ee00000000, 0xf95e473900000000, + 0xb2d5797300000000, 0xea559ba400000000, 0x43d3cd0700000000, + 0x1b532fd000000000, 0xd5c5b09300000000, 0x8d45524400000000, + 0x24c304e700000000, 0x7c43e63000000000, 0x37c8d87a00000000, + 0x6f483aad00000000, 0xc6ce6c0e00000000, 0x9e4e8ed900000000, + 0x5ae3538900000000, 0x0263b15e00000000, 0xabe5e7fd00000000, + 0xf365052a00000000, 0xb8ee3b6000000000, 0xe06ed9b700000000, + 0x49e88f1400000000, 0x11686dc300000000, 0xdffef28000000000, + 0x877e105700000000, 0x2ef846f400000000, 0x7678a42300000000, + 0x3df39a6900000000, 0x657378be00000000, 0xccf52e1d00000000, + 0x9475ccca00000000, 0x44ae95bc00000000, 0x1c2e776b00000000, + 0xb5a821c800000000, 0xed28c31f00000000, 0xa6a3fd5500000000, + 0xfe231f8200000000, 0x57a5492100000000, 0x0f25abf600000000, + 0xc1b334b500000000, 0x9933d66200000000, 0x30b580c100000000, + 0x6835621600000000, 0x23be5c5c00000000, 0x7b3ebe8b00000000, + 0xd2b8e82800000000, 0x8a380aff00000000, 0x4e95d7af00000000, + 0x1615357800000000, 0xbf9363db00000000, 0xe713810c00000000, + 0xac98bf4600000000, 0xf4185d9100000000, 0x5d9e0b3200000000, + 0x051ee9e500000000, 0xcb8876a600000000, 0x9308947100000000, + 0x3a8ec2d200000000, 0x620e200500000000, 0x29851e4f00000000, + 0x7105fc9800000000, 0xd883aa3b00000000, 0x800348ec00000000, + 0x783419d700000000, 0x20b4fb0000000000, 0x8932ada300000000, + 0xd1b24f7400000000, 0x9a39713e00000000, 0xc2b993e900000000, + 0x6b3fc54a00000000, 0x33bf279d00000000, 0xfd29b8de00000000, + 0xa5a95a0900000000, 0x0c2f0caa00000000, 0x54afee7d00000000, + 0x1f24d03700000000, 0x47a432e000000000, 0xee22644300000000, + 0xb6a2869400000000, 0x720f5bc400000000, 0x2a8fb91300000000, + 0x8309efb000000000, 0xdb890d6700000000, 0x9002332d00000000, + 0xc882d1fa00000000, 0x6104875900000000, 0x3984658e00000000, + 0xf712facd00000000, 0xaf92181a00000000, 0x06144eb900000000, + 0x5e94ac6e00000000, 0x151f922400000000, 0x4d9f70f300000000, + 0xe419265000000000, 0xbc99c48700000000, 0x6c429df100000000, + 0x34c27f2600000000, 0x9d44298500000000, 0xc5c4cb5200000000, + 0x8e4ff51800000000, 0xd6cf17cf00000000, 0x7f49416c00000000, + 0x27c9a3bb00000000, 0xe95f3cf800000000, 0xb1dfde2f00000000, + 0x1859888c00000000, 0x40d96a5b00000000, 0x0b52541100000000, + 0x53d2b6c600000000, 0xfa54e06500000000, 0xa2d402b200000000, + 0x6679dfe200000000, 0x3ef93d3500000000, 0x977f6b9600000000, + 0xcfff894100000000, 0x8474b70b00000000, 0xdcf455dc00000000, + 0x7572037f00000000, 0x2df2e1a800000000, 0xe3647eeb00000000, + 0xbbe49c3c00000000, 0x1262ca9f00000000, 0x4ae2284800000000, + 0x0169160200000000, 0x59e9f4d500000000, 0xf06fa27600000000, + 0xa8ef40a100000000}, + {0x0000000000000000, 0x463b676500000000, 0x8c76ceca00000000, + 0xca4da9af00000000, 0x59ebed4e00000000, 0x1fd08a2b00000000, + 0xd59d238400000000, 0x93a644e100000000, 0xb2d6db9d00000000, + 0xf4edbcf800000000, 0x3ea0155700000000, 0x789b723200000000, + 0xeb3d36d300000000, 0xad0651b600000000, 0x674bf81900000000, + 0x21709f7c00000000, 0x25abc6e000000000, 0x6390a18500000000, + 0xa9dd082a00000000, 0xefe66f4f00000000, 0x7c402bae00000000, + 0x3a7b4ccb00000000, 0xf036e56400000000, 0xb60d820100000000, + 0x977d1d7d00000000, 0xd1467a1800000000, 0x1b0bd3b700000000, + 0x5d30b4d200000000, 0xce96f03300000000, 0x88ad975600000000, + 0x42e03ef900000000, 0x04db599c00000000, 0x0b50fc1a00000000, + 0x4d6b9b7f00000000, 0x872632d000000000, 0xc11d55b500000000, + 0x52bb115400000000, 0x1480763100000000, 0xdecddf9e00000000, + 0x98f6b8fb00000000, 0xb986278700000000, 0xffbd40e200000000, + 0x35f0e94d00000000, 0x73cb8e2800000000, 0xe06dcac900000000, + 0xa656adac00000000, 0x6c1b040300000000, 0x2a20636600000000, + 0x2efb3afa00000000, 0x68c05d9f00000000, 0xa28df43000000000, + 0xe4b6935500000000, 0x7710d7b400000000, 0x312bb0d100000000, + 0xfb66197e00000000, 0xbd5d7e1b00000000, 0x9c2de16700000000, + 0xda16860200000000, 0x105b2fad00000000, 0x566048c800000000, + 0xc5c60c2900000000, 0x83fd6b4c00000000, 0x49b0c2e300000000, + 0x0f8ba58600000000, 0x16a0f83500000000, 0x509b9f5000000000, + 0x9ad636ff00000000, 0xdced519a00000000, 0x4f4b157b00000000, + 0x0970721e00000000, 0xc33ddbb100000000, 0x8506bcd400000000, + 0xa47623a800000000, 0xe24d44cd00000000, 0x2800ed6200000000, + 0x6e3b8a0700000000, 0xfd9dcee600000000, 0xbba6a98300000000, + 0x71eb002c00000000, 0x37d0674900000000, 0x330b3ed500000000, + 0x753059b000000000, 0xbf7df01f00000000, 0xf946977a00000000, + 0x6ae0d39b00000000, 0x2cdbb4fe00000000, 0xe6961d5100000000, + 0xa0ad7a3400000000, 0x81dde54800000000, 0xc7e6822d00000000, + 0x0dab2b8200000000, 0x4b904ce700000000, 0xd836080600000000, + 0x9e0d6f6300000000, 0x5440c6cc00000000, 0x127ba1a900000000, + 0x1df0042f00000000, 0x5bcb634a00000000, 0x9186cae500000000, + 0xd7bdad8000000000, 0x441be96100000000, 0x02208e0400000000, + 0xc86d27ab00000000, 0x8e5640ce00000000, 0xaf26dfb200000000, + 0xe91db8d700000000, 0x2350117800000000, 0x656b761d00000000, + 0xf6cd32fc00000000, 0xb0f6559900000000, 0x7abbfc3600000000, + 0x3c809b5300000000, 0x385bc2cf00000000, 0x7e60a5aa00000000, + 0xb42d0c0500000000, 0xf2166b6000000000, 0x61b02f8100000000, + 0x278b48e400000000, 0xedc6e14b00000000, 0xabfd862e00000000, + 0x8a8d195200000000, 0xccb67e3700000000, 0x06fbd79800000000, + 0x40c0b0fd00000000, 0xd366f41c00000000, 0x955d937900000000, + 0x5f103ad600000000, 0x192b5db300000000, 0x2c40f16b00000000, + 0x6a7b960e00000000, 0xa0363fa100000000, 0xe60d58c400000000, + 0x75ab1c2500000000, 0x33907b4000000000, 0xf9ddd2ef00000000, + 0xbfe6b58a00000000, 0x9e962af600000000, 0xd8ad4d9300000000, + 0x12e0e43c00000000, 0x54db835900000000, 0xc77dc7b800000000, + 0x8146a0dd00000000, 0x4b0b097200000000, 0x0d306e1700000000, + 0x09eb378b00000000, 0x4fd050ee00000000, 0x859df94100000000, + 0xc3a69e2400000000, 0x5000dac500000000, 0x163bbda000000000, + 0xdc76140f00000000, 0x9a4d736a00000000, 0xbb3dec1600000000, + 0xfd068b7300000000, 0x374b22dc00000000, 0x717045b900000000, + 0xe2d6015800000000, 0xa4ed663d00000000, 0x6ea0cf9200000000, + 0x289ba8f700000000, 0x27100d7100000000, 0x612b6a1400000000, + 0xab66c3bb00000000, 0xed5da4de00000000, 0x7efbe03f00000000, + 0x38c0875a00000000, 0xf28d2ef500000000, 0xb4b6499000000000, + 0x95c6d6ec00000000, 0xd3fdb18900000000, 0x19b0182600000000, + 0x5f8b7f4300000000, 0xcc2d3ba200000000, 0x8a165cc700000000, + 0x405bf56800000000, 0x0660920d00000000, 0x02bbcb9100000000, + 0x4480acf400000000, 0x8ecd055b00000000, 0xc8f6623e00000000, + 0x5b5026df00000000, 0x1d6b41ba00000000, 0xd726e81500000000, + 0x911d8f7000000000, 0xb06d100c00000000, 0xf656776900000000, + 0x3c1bdec600000000, 0x7a20b9a300000000, 0xe986fd4200000000, + 0xafbd9a2700000000, 0x65f0338800000000, 0x23cb54ed00000000, + 0x3ae0095e00000000, 0x7cdb6e3b00000000, 0xb696c79400000000, + 0xf0ada0f100000000, 0x630be41000000000, 0x2530837500000000, + 0xef7d2ada00000000, 0xa9464dbf00000000, 0x8836d2c300000000, + 0xce0db5a600000000, 0x04401c0900000000, 0x427b7b6c00000000, + 0xd1dd3f8d00000000, 0x97e658e800000000, 0x5dabf14700000000, + 0x1b90962200000000, 0x1f4bcfbe00000000, 0x5970a8db00000000, + 0x933d017400000000, 0xd506661100000000, 0x46a022f000000000, + 0x009b459500000000, 0xcad6ec3a00000000, 0x8ced8b5f00000000, + 0xad9d142300000000, 0xeba6734600000000, 0x21ebdae900000000, + 0x67d0bd8c00000000, 0xf476f96d00000000, 0xb24d9e0800000000, + 0x780037a700000000, 0x3e3b50c200000000, 0x31b0f54400000000, + 0x778b922100000000, 0xbdc63b8e00000000, 0xfbfd5ceb00000000, + 0x685b180a00000000, 0x2e607f6f00000000, 0xe42dd6c000000000, + 0xa216b1a500000000, 0x83662ed900000000, 0xc55d49bc00000000, + 0x0f10e01300000000, 0x492b877600000000, 0xda8dc39700000000, + 0x9cb6a4f200000000, 0x56fb0d5d00000000, 0x10c06a3800000000, + 0x141b33a400000000, 0x522054c100000000, 0x986dfd6e00000000, + 0xde569a0b00000000, 0x4df0deea00000000, 0x0bcbb98f00000000, + 0xc186102000000000, 0x87bd774500000000, 0xa6cde83900000000, + 0xe0f68f5c00000000, 0x2abb26f300000000, 0x6c80419600000000, + 0xff26057700000000, 0xb91d621200000000, 0x7350cbbd00000000, + 0x356bacd800000000}, + {0x0000000000000000, 0x9e83da9f00000000, 0x7d01c4e400000000, + 0xe3821e7b00000000, 0xbb04f91200000000, 0x2587238d00000000, + 0xc6053df600000000, 0x5886e76900000000, 0x7609f22500000000, + 0xe88a28ba00000000, 0x0b0836c100000000, 0x958bec5e00000000, + 0xcd0d0b3700000000, 0x538ed1a800000000, 0xb00ccfd300000000, + 0x2e8f154c00000000, 0xec12e44b00000000, 0x72913ed400000000, + 0x911320af00000000, 0x0f90fa3000000000, 0x57161d5900000000, + 0xc995c7c600000000, 0x2a17d9bd00000000, 0xb494032200000000, + 0x9a1b166e00000000, 0x0498ccf100000000, 0xe71ad28a00000000, + 0x7999081500000000, 0x211fef7c00000000, 0xbf9c35e300000000, + 0x5c1e2b9800000000, 0xc29df10700000000, 0xd825c89700000000, + 0x46a6120800000000, 0xa5240c7300000000, 0x3ba7d6ec00000000, + 0x6321318500000000, 0xfda2eb1a00000000, 0x1e20f56100000000, + 0x80a32ffe00000000, 0xae2c3ab200000000, 0x30afe02d00000000, + 0xd32dfe5600000000, 0x4dae24c900000000, 0x1528c3a000000000, + 0x8bab193f00000000, 0x6829074400000000, 0xf6aadddb00000000, + 0x34372cdc00000000, 0xaab4f64300000000, 0x4936e83800000000, + 0xd7b532a700000000, 0x8f33d5ce00000000, 0x11b00f5100000000, + 0xf232112a00000000, 0x6cb1cbb500000000, 0x423edef900000000, + 0xdcbd046600000000, 0x3f3f1a1d00000000, 0xa1bcc08200000000, + 0xf93a27eb00000000, 0x67b9fd7400000000, 0x843be30f00000000, + 0x1ab8399000000000, 0xf14de1f400000000, 0x6fce3b6b00000000, + 0x8c4c251000000000, 0x12cfff8f00000000, 0x4a4918e600000000, + 0xd4cac27900000000, 0x3748dc0200000000, 0xa9cb069d00000000, + 0x874413d100000000, 0x19c7c94e00000000, 0xfa45d73500000000, + 0x64c60daa00000000, 0x3c40eac300000000, 0xa2c3305c00000000, + 0x41412e2700000000, 0xdfc2f4b800000000, 0x1d5f05bf00000000, + 0x83dcdf2000000000, 0x605ec15b00000000, 0xfedd1bc400000000, + 0xa65bfcad00000000, 0x38d8263200000000, 0xdb5a384900000000, + 0x45d9e2d600000000, 0x6b56f79a00000000, 0xf5d52d0500000000, + 0x1657337e00000000, 0x88d4e9e100000000, 0xd0520e8800000000, + 0x4ed1d41700000000, 0xad53ca6c00000000, 0x33d010f300000000, + 0x2968296300000000, 0xb7ebf3fc00000000, 0x5469ed8700000000, + 0xcaea371800000000, 0x926cd07100000000, 0x0cef0aee00000000, + 0xef6d149500000000, 0x71eece0a00000000, 0x5f61db4600000000, + 0xc1e201d900000000, 0x22601fa200000000, 0xbce3c53d00000000, + 0xe465225400000000, 0x7ae6f8cb00000000, 0x9964e6b000000000, + 0x07e73c2f00000000, 0xc57acd2800000000, 0x5bf917b700000000, + 0xb87b09cc00000000, 0x26f8d35300000000, 0x7e7e343a00000000, + 0xe0fdeea500000000, 0x037ff0de00000000, 0x9dfc2a4100000000, + 0xb3733f0d00000000, 0x2df0e59200000000, 0xce72fbe900000000, + 0x50f1217600000000, 0x0877c61f00000000, 0x96f41c8000000000, + 0x757602fb00000000, 0xebf5d86400000000, 0xa39db33200000000, + 0x3d1e69ad00000000, 0xde9c77d600000000, 0x401fad4900000000, + 0x18994a2000000000, 0x861a90bf00000000, 0x65988ec400000000, + 0xfb1b545b00000000, 0xd594411700000000, 0x4b179b8800000000, + 0xa89585f300000000, 0x36165f6c00000000, 0x6e90b80500000000, + 0xf013629a00000000, 0x13917ce100000000, 0x8d12a67e00000000, + 0x4f8f577900000000, 0xd10c8de600000000, 0x328e939d00000000, + 0xac0d490200000000, 0xf48bae6b00000000, 0x6a0874f400000000, + 0x898a6a8f00000000, 0x1709b01000000000, 0x3986a55c00000000, + 0xa7057fc300000000, 0x448761b800000000, 0xda04bb2700000000, + 0x82825c4e00000000, 0x1c0186d100000000, 0xff8398aa00000000, + 0x6100423500000000, 0x7bb87ba500000000, 0xe53ba13a00000000, + 0x06b9bf4100000000, 0x983a65de00000000, 0xc0bc82b700000000, + 0x5e3f582800000000, 0xbdbd465300000000, 0x233e9ccc00000000, + 0x0db1898000000000, 0x9332531f00000000, 0x70b04d6400000000, + 0xee3397fb00000000, 0xb6b5709200000000, 0x2836aa0d00000000, + 0xcbb4b47600000000, 0x55376ee900000000, 0x97aa9fee00000000, + 0x0929457100000000, 0xeaab5b0a00000000, 0x7428819500000000, + 0x2cae66fc00000000, 0xb22dbc6300000000, 0x51afa21800000000, + 0xcf2c788700000000, 0xe1a36dcb00000000, 0x7f20b75400000000, + 0x9ca2a92f00000000, 0x022173b000000000, 0x5aa794d900000000, + 0xc4244e4600000000, 0x27a6503d00000000, 0xb9258aa200000000, + 0x52d052c600000000, 0xcc53885900000000, 0x2fd1962200000000, + 0xb1524cbd00000000, 0xe9d4abd400000000, 0x7757714b00000000, + 0x94d56f3000000000, 0x0a56b5af00000000, 0x24d9a0e300000000, + 0xba5a7a7c00000000, 0x59d8640700000000, 0xc75bbe9800000000, + 0x9fdd59f100000000, 0x015e836e00000000, 0xe2dc9d1500000000, + 0x7c5f478a00000000, 0xbec2b68d00000000, 0x20416c1200000000, + 0xc3c3726900000000, 0x5d40a8f600000000, 0x05c64f9f00000000, + 0x9b45950000000000, 0x78c78b7b00000000, 0xe64451e400000000, + 0xc8cb44a800000000, 0x56489e3700000000, 0xb5ca804c00000000, + 0x2b495ad300000000, 0x73cfbdba00000000, 0xed4c672500000000, + 0x0ece795e00000000, 0x904da3c100000000, 0x8af59a5100000000, + 0x147640ce00000000, 0xf7f45eb500000000, 0x6977842a00000000, + 0x31f1634300000000, 0xaf72b9dc00000000, 0x4cf0a7a700000000, + 0xd2737d3800000000, 0xfcfc687400000000, 0x627fb2eb00000000, + 0x81fdac9000000000, 0x1f7e760f00000000, 0x47f8916600000000, + 0xd97b4bf900000000, 0x3af9558200000000, 0xa47a8f1d00000000, + 0x66e77e1a00000000, 0xf864a48500000000, 0x1be6bafe00000000, + 0x8565606100000000, 0xdde3870800000000, 0x43605d9700000000, + 0xa0e243ec00000000, 0x3e61997300000000, 0x10ee8c3f00000000, + 0x8e6d56a000000000, 0x6def48db00000000, 0xf36c924400000000, + 0xabea752d00000000, 0x3569afb200000000, 0xd6ebb1c900000000, + 0x48686b5600000000}, + {0x0000000000000000, 0xc064281700000000, 0x80c9502e00000000, + 0x40ad783900000000, 0x0093a15c00000000, 0xc0f7894b00000000, + 0x805af17200000000, 0x403ed96500000000, 0x002643b900000000, + 0xc0426bae00000000, 0x80ef139700000000, 0x408b3b8000000000, + 0x00b5e2e500000000, 0xc0d1caf200000000, 0x807cb2cb00000000, + 0x40189adc00000000, 0x414af7a900000000, 0x812edfbe00000000, + 0xc183a78700000000, 0x01e78f9000000000, 0x41d956f500000000, + 0x81bd7ee200000000, 0xc11006db00000000, 0x01742ecc00000000, + 0x416cb41000000000, 0x81089c0700000000, 0xc1a5e43e00000000, + 0x01c1cc2900000000, 0x41ff154c00000000, 0x819b3d5b00000000, + 0xc136456200000000, 0x01526d7500000000, 0xc3929f8800000000, + 0x03f6b79f00000000, 0x435bcfa600000000, 0x833fe7b100000000, + 0xc3013ed400000000, 0x036516c300000000, 0x43c86efa00000000, + 0x83ac46ed00000000, 0xc3b4dc3100000000, 0x03d0f42600000000, + 0x437d8c1f00000000, 0x8319a40800000000, 0xc3277d6d00000000, + 0x0343557a00000000, 0x43ee2d4300000000, 0x838a055400000000, + 0x82d8682100000000, 0x42bc403600000000, 0x0211380f00000000, + 0xc275101800000000, 0x824bc97d00000000, 0x422fe16a00000000, + 0x0282995300000000, 0xc2e6b14400000000, 0x82fe2b9800000000, + 0x429a038f00000000, 0x02377bb600000000, 0xc25353a100000000, + 0x826d8ac400000000, 0x4209a2d300000000, 0x02a4daea00000000, + 0xc2c0f2fd00000000, 0xc7234eca00000000, 0x074766dd00000000, + 0x47ea1ee400000000, 0x878e36f300000000, 0xc7b0ef9600000000, + 0x07d4c78100000000, 0x4779bfb800000000, 0x871d97af00000000, + 0xc7050d7300000000, 0x0761256400000000, 0x47cc5d5d00000000, + 0x87a8754a00000000, 0xc796ac2f00000000, 0x07f2843800000000, + 0x475ffc0100000000, 0x873bd41600000000, 0x8669b96300000000, + 0x460d917400000000, 0x06a0e94d00000000, 0xc6c4c15a00000000, + 0x86fa183f00000000, 0x469e302800000000, 0x0633481100000000, + 0xc657600600000000, 0x864ffada00000000, 0x462bd2cd00000000, + 0x0686aaf400000000, 0xc6e282e300000000, 0x86dc5b8600000000, + 0x46b8739100000000, 0x06150ba800000000, 0xc67123bf00000000, + 0x04b1d14200000000, 0xc4d5f95500000000, 0x8478816c00000000, + 0x441ca97b00000000, 0x0422701e00000000, 0xc446580900000000, + 0x84eb203000000000, 0x448f082700000000, 0x049792fb00000000, + 0xc4f3baec00000000, 0x845ec2d500000000, 0x443aeac200000000, + 0x040433a700000000, 0xc4601bb000000000, 0x84cd638900000000, + 0x44a94b9e00000000, 0x45fb26eb00000000, 0x859f0efc00000000, + 0xc53276c500000000, 0x05565ed200000000, 0x456887b700000000, + 0x850cafa000000000, 0xc5a1d79900000000, 0x05c5ff8e00000000, + 0x45dd655200000000, 0x85b94d4500000000, 0xc514357c00000000, + 0x05701d6b00000000, 0x454ec40e00000000, 0x852aec1900000000, + 0xc587942000000000, 0x05e3bc3700000000, 0xcf41ed4f00000000, + 0x0f25c55800000000, 0x4f88bd6100000000, 0x8fec957600000000, + 0xcfd24c1300000000, 0x0fb6640400000000, 0x4f1b1c3d00000000, + 0x8f7f342a00000000, 0xcf67aef600000000, 0x0f0386e100000000, + 0x4faefed800000000, 0x8fcad6cf00000000, 0xcff40faa00000000, + 0x0f9027bd00000000, 0x4f3d5f8400000000, 0x8f59779300000000, + 0x8e0b1ae600000000, 0x4e6f32f100000000, 0x0ec24ac800000000, + 0xcea662df00000000, 0x8e98bbba00000000, 0x4efc93ad00000000, + 0x0e51eb9400000000, 0xce35c38300000000, 0x8e2d595f00000000, + 0x4e49714800000000, 0x0ee4097100000000, 0xce80216600000000, + 0x8ebef80300000000, 0x4edad01400000000, 0x0e77a82d00000000, + 0xce13803a00000000, 0x0cd372c700000000, 0xccb75ad000000000, + 0x8c1a22e900000000, 0x4c7e0afe00000000, 0x0c40d39b00000000, + 0xcc24fb8c00000000, 0x8c8983b500000000, 0x4cedaba200000000, + 0x0cf5317e00000000, 0xcc91196900000000, 0x8c3c615000000000, + 0x4c58494700000000, 0x0c66902200000000, 0xcc02b83500000000, + 0x8cafc00c00000000, 0x4ccbe81b00000000, 0x4d99856e00000000, + 0x8dfdad7900000000, 0xcd50d54000000000, 0x0d34fd5700000000, + 0x4d0a243200000000, 0x8d6e0c2500000000, 0xcdc3741c00000000, + 0x0da75c0b00000000, 0x4dbfc6d700000000, 0x8ddbeec000000000, + 0xcd7696f900000000, 0x0d12beee00000000, 0x4d2c678b00000000, + 0x8d484f9c00000000, 0xcde537a500000000, 0x0d811fb200000000, + 0x0862a38500000000, 0xc8068b9200000000, 0x88abf3ab00000000, + 0x48cfdbbc00000000, 0x08f102d900000000, 0xc8952ace00000000, + 0x883852f700000000, 0x485c7ae000000000, 0x0844e03c00000000, + 0xc820c82b00000000, 0x888db01200000000, 0x48e9980500000000, + 0x08d7416000000000, 0xc8b3697700000000, 0x881e114e00000000, + 0x487a395900000000, 0x4928542c00000000, 0x894c7c3b00000000, + 0xc9e1040200000000, 0x09852c1500000000, 0x49bbf57000000000, + 0x89dfdd6700000000, 0xc972a55e00000000, 0x09168d4900000000, + 0x490e179500000000, 0x896a3f8200000000, 0xc9c747bb00000000, + 0x09a36fac00000000, 0x499db6c900000000, 0x89f99ede00000000, + 0xc954e6e700000000, 0x0930cef000000000, 0xcbf03c0d00000000, + 0x0b94141a00000000, 0x4b396c2300000000, 0x8b5d443400000000, + 0xcb639d5100000000, 0x0b07b54600000000, 0x4baacd7f00000000, + 0x8bcee56800000000, 0xcbd67fb400000000, 0x0bb257a300000000, + 0x4b1f2f9a00000000, 0x8b7b078d00000000, 0xcb45dee800000000, + 0x0b21f6ff00000000, 0x4b8c8ec600000000, 0x8be8a6d100000000, + 0x8abacba400000000, 0x4adee3b300000000, 0x0a739b8a00000000, + 0xca17b39d00000000, 0x8a296af800000000, 0x4a4d42ef00000000, + 0x0ae03ad600000000, 0xca8412c100000000, 0x8a9c881d00000000, + 0x4af8a00a00000000, 0x0a55d83300000000, 0xca31f02400000000, + 0x8a0f294100000000, 0x4a6b015600000000, 0x0ac6796f00000000, + 0xcaa2517800000000}, + {0x0000000000000000, 0xd4ea739b00000000, 0xe9d396ed00000000, + 0x3d39e57600000000, 0x93a15c0000000000, 0x474b2f9b00000000, + 0x7a72caed00000000, 0xae98b97600000000, 0x2643b90000000000, + 0xf2a9ca9b00000000, 0xcf902fed00000000, 0x1b7a5c7600000000, + 0xb5e2e50000000000, 0x6108969b00000000, 0x5c3173ed00000000, + 0x88db007600000000, 0x4c86720100000000, 0x986c019a00000000, + 0xa555e4ec00000000, 0x71bf977700000000, 0xdf272e0100000000, + 0x0bcd5d9a00000000, 0x36f4b8ec00000000, 0xe21ecb7700000000, + 0x6ac5cb0100000000, 0xbe2fb89a00000000, 0x83165dec00000000, + 0x57fc2e7700000000, 0xf964970100000000, 0x2d8ee49a00000000, + 0x10b701ec00000000, 0xc45d727700000000, 0x980ce50200000000, + 0x4ce6969900000000, 0x71df73ef00000000, 0xa535007400000000, + 0x0badb90200000000, 0xdf47ca9900000000, 0xe27e2fef00000000, + 0x36945c7400000000, 0xbe4f5c0200000000, 0x6aa52f9900000000, + 0x579ccaef00000000, 0x8376b97400000000, 0x2dee000200000000, + 0xf904739900000000, 0xc43d96ef00000000, 0x10d7e57400000000, + 0xd48a970300000000, 0x0060e49800000000, 0x3d5901ee00000000, + 0xe9b3727500000000, 0x472bcb0300000000, 0x93c1b89800000000, + 0xaef85dee00000000, 0x7a122e7500000000, 0xf2c92e0300000000, + 0x26235d9800000000, 0x1b1ab8ee00000000, 0xcff0cb7500000000, + 0x6168720300000000, 0xb582019800000000, 0x88bbe4ee00000000, + 0x5c51977500000000, 0x3019ca0500000000, 0xe4f3b99e00000000, + 0xd9ca5ce800000000, 0x0d202f7300000000, 0xa3b8960500000000, + 0x7752e59e00000000, 0x4a6b00e800000000, 0x9e81737300000000, + 0x165a730500000000, 0xc2b0009e00000000, 0xff89e5e800000000, + 0x2b63967300000000, 0x85fb2f0500000000, 0x51115c9e00000000, + 0x6c28b9e800000000, 0xb8c2ca7300000000, 0x7c9fb80400000000, + 0xa875cb9f00000000, 0x954c2ee900000000, 0x41a65d7200000000, + 0xef3ee40400000000, 0x3bd4979f00000000, 0x06ed72e900000000, + 0xd207017200000000, 0x5adc010400000000, 0x8e36729f00000000, + 0xb30f97e900000000, 0x67e5e47200000000, 0xc97d5d0400000000, + 0x1d972e9f00000000, 0x20aecbe900000000, 0xf444b87200000000, + 0xa8152f0700000000, 0x7cff5c9c00000000, 0x41c6b9ea00000000, + 0x952cca7100000000, 0x3bb4730700000000, 0xef5e009c00000000, + 0xd267e5ea00000000, 0x068d967100000000, 0x8e56960700000000, + 0x5abce59c00000000, 0x678500ea00000000, 0xb36f737100000000, + 0x1df7ca0700000000, 0xc91db99c00000000, 0xf4245cea00000000, + 0x20ce2f7100000000, 0xe4935d0600000000, 0x30792e9d00000000, + 0x0d40cbeb00000000, 0xd9aab87000000000, 0x7732010600000000, + 0xa3d8729d00000000, 0x9ee197eb00000000, 0x4a0be47000000000, + 0xc2d0e40600000000, 0x163a979d00000000, 0x2b0372eb00000000, + 0xffe9017000000000, 0x5171b80600000000, 0x859bcb9d00000000, + 0xb8a22eeb00000000, 0x6c485d7000000000, 0x6032940b00000000, + 0xb4d8e79000000000, 0x89e102e600000000, 0x5d0b717d00000000, + 0xf393c80b00000000, 0x2779bb9000000000, 0x1a405ee600000000, + 0xceaa2d7d00000000, 0x46712d0b00000000, 0x929b5e9000000000, + 0xafa2bbe600000000, 0x7b48c87d00000000, 0xd5d0710b00000000, + 0x013a029000000000, 0x3c03e7e600000000, 0xe8e9947d00000000, + 0x2cb4e60a00000000, 0xf85e959100000000, 0xc56770e700000000, + 0x118d037c00000000, 0xbf15ba0a00000000, 0x6bffc99100000000, + 0x56c62ce700000000, 0x822c5f7c00000000, 0x0af75f0a00000000, + 0xde1d2c9100000000, 0xe324c9e700000000, 0x37ceba7c00000000, + 0x9956030a00000000, 0x4dbc709100000000, 0x708595e700000000, + 0xa46fe67c00000000, 0xf83e710900000000, 0x2cd4029200000000, + 0x11ede7e400000000, 0xc507947f00000000, 0x6b9f2d0900000000, + 0xbf755e9200000000, 0x824cbbe400000000, 0x56a6c87f00000000, + 0xde7dc80900000000, 0x0a97bb9200000000, 0x37ae5ee400000000, + 0xe3442d7f00000000, 0x4ddc940900000000, 0x9936e79200000000, + 0xa40f02e400000000, 0x70e5717f00000000, 0xb4b8030800000000, + 0x6052709300000000, 0x5d6b95e500000000, 0x8981e67e00000000, + 0x27195f0800000000, 0xf3f32c9300000000, 0xcecac9e500000000, + 0x1a20ba7e00000000, 0x92fbba0800000000, 0x4611c99300000000, + 0x7b282ce500000000, 0xafc25f7e00000000, 0x015ae60800000000, + 0xd5b0959300000000, 0xe88970e500000000, 0x3c63037e00000000, + 0x502b5e0e00000000, 0x84c12d9500000000, 0xb9f8c8e300000000, + 0x6d12bb7800000000, 0xc38a020e00000000, 0x1760719500000000, + 0x2a5994e300000000, 0xfeb3e77800000000, 0x7668e70e00000000, + 0xa282949500000000, 0x9fbb71e300000000, 0x4b51027800000000, + 0xe5c9bb0e00000000, 0x3123c89500000000, 0x0c1a2de300000000, + 0xd8f05e7800000000, 0x1cad2c0f00000000, 0xc8475f9400000000, + 0xf57ebae200000000, 0x2194c97900000000, 0x8f0c700f00000000, + 0x5be6039400000000, 0x66dfe6e200000000, 0xb235957900000000, + 0x3aee950f00000000, 0xee04e69400000000, 0xd33d03e200000000, + 0x07d7707900000000, 0xa94fc90f00000000, 0x7da5ba9400000000, + 0x409c5fe200000000, 0x94762c7900000000, 0xc827bb0c00000000, + 0x1ccdc89700000000, 0x21f42de100000000, 0xf51e5e7a00000000, + 0x5b86e70c00000000, 0x8f6c949700000000, 0xb25571e100000000, + 0x66bf027a00000000, 0xee64020c00000000, 0x3a8e719700000000, + 0x07b794e100000000, 0xd35de77a00000000, 0x7dc55e0c00000000, + 0xa92f2d9700000000, 0x9416c8e100000000, 0x40fcbb7a00000000, + 0x84a1c90d00000000, 0x504bba9600000000, 0x6d725fe000000000, + 0xb9982c7b00000000, 0x1700950d00000000, 0xc3eae69600000000, + 0xfed303e000000000, 0x2a39707b00000000, 0xa2e2700d00000000, + 0x7608039600000000, 0x4b31e6e000000000, 0x9fdb957b00000000, + 0x31432c0d00000000, 0xe5a95f9600000000, 0xd890bae000000000, + 0x0c7ac97b00000000}, + {0x0000000000000000, 0x2765258100000000, 0x0fcc3bd900000000, + 0x28a91e5800000000, 0x5f9e066900000000, 0x78fb23e800000000, + 0x50523db000000000, 0x7737183100000000, 0xbe3c0dd200000000, + 0x9959285300000000, 0xb1f0360b00000000, 0x9695138a00000000, + 0xe1a20bbb00000000, 0xc6c72e3a00000000, 0xee6e306200000000, + 0xc90b15e300000000, 0x3d7f6b7f00000000, 0x1a1a4efe00000000, + 0x32b350a600000000, 0x15d6752700000000, 0x62e16d1600000000, + 0x4584489700000000, 0x6d2d56cf00000000, 0x4a48734e00000000, + 0x834366ad00000000, 0xa426432c00000000, 0x8c8f5d7400000000, + 0xabea78f500000000, 0xdcdd60c400000000, 0xfbb8454500000000, + 0xd3115b1d00000000, 0xf4747e9c00000000, 0x7afed6fe00000000, + 0x5d9bf37f00000000, 0x7532ed2700000000, 0x5257c8a600000000, + 0x2560d09700000000, 0x0205f51600000000, 0x2aaceb4e00000000, + 0x0dc9cecf00000000, 0xc4c2db2c00000000, 0xe3a7fead00000000, + 0xcb0ee0f500000000, 0xec6bc57400000000, 0x9b5cdd4500000000, + 0xbc39f8c400000000, 0x9490e69c00000000, 0xb3f5c31d00000000, + 0x4781bd8100000000, 0x60e4980000000000, 0x484d865800000000, + 0x6f28a3d900000000, 0x181fbbe800000000, 0x3f7a9e6900000000, + 0x17d3803100000000, 0x30b6a5b000000000, 0xf9bdb05300000000, + 0xded895d200000000, 0xf6718b8a00000000, 0xd114ae0b00000000, + 0xa623b63a00000000, 0x814693bb00000000, 0xa9ef8de300000000, + 0x8e8aa86200000000, 0xb5fadc2600000000, 0x929ff9a700000000, + 0xba36e7ff00000000, 0x9d53c27e00000000, 0xea64da4f00000000, + 0xcd01ffce00000000, 0xe5a8e19600000000, 0xc2cdc41700000000, + 0x0bc6d1f400000000, 0x2ca3f47500000000, 0x040aea2d00000000, + 0x236fcfac00000000, 0x5458d79d00000000, 0x733df21c00000000, + 0x5b94ec4400000000, 0x7cf1c9c500000000, 0x8885b75900000000, + 0xafe092d800000000, 0x87498c8000000000, 0xa02ca90100000000, + 0xd71bb13000000000, 0xf07e94b100000000, 0xd8d78ae900000000, + 0xffb2af6800000000, 0x36b9ba8b00000000, 0x11dc9f0a00000000, + 0x3975815200000000, 0x1e10a4d300000000, 0x6927bce200000000, + 0x4e42996300000000, 0x66eb873b00000000, 0x418ea2ba00000000, + 0xcf040ad800000000, 0xe8612f5900000000, 0xc0c8310100000000, + 0xe7ad148000000000, 0x909a0cb100000000, 0xb7ff293000000000, + 0x9f56376800000000, 0xb83312e900000000, 0x7138070a00000000, + 0x565d228b00000000, 0x7ef43cd300000000, 0x5991195200000000, + 0x2ea6016300000000, 0x09c324e200000000, 0x216a3aba00000000, + 0x060f1f3b00000000, 0xf27b61a700000000, 0xd51e442600000000, + 0xfdb75a7e00000000, 0xdad27fff00000000, 0xade567ce00000000, + 0x8a80424f00000000, 0xa2295c1700000000, 0x854c799600000000, + 0x4c476c7500000000, 0x6b2249f400000000, 0x438b57ac00000000, + 0x64ee722d00000000, 0x13d96a1c00000000, 0x34bc4f9d00000000, + 0x1c1551c500000000, 0x3b70744400000000, 0x6af5b94d00000000, + 0x4d909ccc00000000, 0x6539829400000000, 0x425ca71500000000, + 0x356bbf2400000000, 0x120e9aa500000000, 0x3aa784fd00000000, + 0x1dc2a17c00000000, 0xd4c9b49f00000000, 0xf3ac911e00000000, + 0xdb058f4600000000, 0xfc60aac700000000, 0x8b57b2f600000000, + 0xac32977700000000, 0x849b892f00000000, 0xa3feacae00000000, + 0x578ad23200000000, 0x70eff7b300000000, 0x5846e9eb00000000, + 0x7f23cc6a00000000, 0x0814d45b00000000, 0x2f71f1da00000000, + 0x07d8ef8200000000, 0x20bdca0300000000, 0xe9b6dfe000000000, + 0xced3fa6100000000, 0xe67ae43900000000, 0xc11fc1b800000000, + 0xb628d98900000000, 0x914dfc0800000000, 0xb9e4e25000000000, + 0x9e81c7d100000000, 0x100b6fb300000000, 0x376e4a3200000000, + 0x1fc7546a00000000, 0x38a271eb00000000, 0x4f9569da00000000, + 0x68f04c5b00000000, 0x4059520300000000, 0x673c778200000000, + 0xae37626100000000, 0x895247e000000000, 0xa1fb59b800000000, + 0x869e7c3900000000, 0xf1a9640800000000, 0xd6cc418900000000, + 0xfe655fd100000000, 0xd9007a5000000000, 0x2d7404cc00000000, + 0x0a11214d00000000, 0x22b83f1500000000, 0x05dd1a9400000000, + 0x72ea02a500000000, 0x558f272400000000, 0x7d26397c00000000, + 0x5a431cfd00000000, 0x9348091e00000000, 0xb42d2c9f00000000, + 0x9c8432c700000000, 0xbbe1174600000000, 0xccd60f7700000000, + 0xebb32af600000000, 0xc31a34ae00000000, 0xe47f112f00000000, + 0xdf0f656b00000000, 0xf86a40ea00000000, 0xd0c35eb200000000, + 0xf7a67b3300000000, 0x8091630200000000, 0xa7f4468300000000, + 0x8f5d58db00000000, 0xa8387d5a00000000, 0x613368b900000000, + 0x46564d3800000000, 0x6eff536000000000, 0x499a76e100000000, + 0x3ead6ed000000000, 0x19c84b5100000000, 0x3161550900000000, + 0x1604708800000000, 0xe2700e1400000000, 0xc5152b9500000000, + 0xedbc35cd00000000, 0xcad9104c00000000, 0xbdee087d00000000, + 0x9a8b2dfc00000000, 0xb22233a400000000, 0x9547162500000000, + 0x5c4c03c600000000, 0x7b29264700000000, 0x5380381f00000000, + 0x74e51d9e00000000, 0x03d205af00000000, 0x24b7202e00000000, + 0x0c1e3e7600000000, 0x2b7b1bf700000000, 0xa5f1b39500000000, + 0x8294961400000000, 0xaa3d884c00000000, 0x8d58adcd00000000, + 0xfa6fb5fc00000000, 0xdd0a907d00000000, 0xf5a38e2500000000, + 0xd2c6aba400000000, 0x1bcdbe4700000000, 0x3ca89bc600000000, + 0x1401859e00000000, 0x3364a01f00000000, 0x4453b82e00000000, + 0x63369daf00000000, 0x4b9f83f700000000, 0x6cfaa67600000000, + 0x988ed8ea00000000, 0xbfebfd6b00000000, 0x9742e33300000000, + 0xb027c6b200000000, 0xc710de8300000000, 0xe075fb0200000000, + 0xc8dce55a00000000, 0xefb9c0db00000000, 0x26b2d53800000000, + 0x01d7f0b900000000, 0x297eeee100000000, 0x0e1bcb6000000000, + 0x792cd35100000000, 0x5e49f6d000000000, 0x76e0e88800000000, + 0x5185cd0900000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, + 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, + 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, + 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, + 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, + 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, + 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, + 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, + 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, + 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, + 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, + 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, + 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, + 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, + 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, + 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, + 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, + 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, + 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, + 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, + 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, + 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, + 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, + 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, + 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, + 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, + 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, + 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, + 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, + 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, + 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, + 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, + 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, + 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, + 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, + 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, + 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, + 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, + 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, + 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, + 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, + 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, + 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, + 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, + 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, + 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, + 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, + 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, + 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, + 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, + 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, + 0x36197165}, + {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, + 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, + 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, + 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, + 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, + 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, + 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, + 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, + 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, + 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, + 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, + 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, + 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, + 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, + 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, + 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, + 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, + 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, + 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, + 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, + 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, + 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, + 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, + 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, + 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, + 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, + 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, + 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, + 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, + 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, + 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, + 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, + 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, + 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, + 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, + 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, + 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, + 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, + 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, + 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, + 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, + 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, + 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, + 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, + 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, + 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, + 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, + 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, + 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, + 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, + 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, + 0x1a3b93aa}, + {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, + 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, + 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, + 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, + 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, + 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, + 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, + 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, + 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, + 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, + 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, + 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, + 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, + 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, + 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, + 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, + 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, + 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, + 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, + 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, + 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, + 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, + 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, + 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, + 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, + 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, + 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, + 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, + 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, + 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, + 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, + 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, + 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, + 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, + 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, + 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, + 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, + 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, + 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, + 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, + 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, + 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, + 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, + 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, + 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, + 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, + 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, + 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, + 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, + 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, + 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, + 0xe147d714}, + {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, + 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, + 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, + 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, + 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, + 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, + 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, + 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, + 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, + 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, + 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, + 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, + 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, + 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, + 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, + 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, + 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, + 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, + 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, + 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, + 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, + 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, + 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, + 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, + 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, + 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, + 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, + 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, + 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, + 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, + 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, + 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, + 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, + 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, + 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, + 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, + 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, + 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, + 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, + 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, + 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, + 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, + 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, + 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, + 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, + 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, + 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, + 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, + 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, + 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, + 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, + 0x494f0c4b}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x43147b17, 0x8628f62e, 0xc53c8d39, 0x0c51ec5d, + 0x4f45974a, 0x8a791a73, 0xc96d6164, 0x18a2d8bb, 0x5bb6a3ac, + 0x9e8a2e95, 0xdd9e5582, 0x14f334e6, 0x57e74ff1, 0x92dbc2c8, + 0xd1cfb9df, 0x7142c0ac, 0x3256bbbb, 0xf76a3682, 0xb47e4d95, + 0x7d132cf1, 0x3e0757e6, 0xfb3bdadf, 0xb82fa1c8, 0x69e01817, + 0x2af46300, 0xefc8ee39, 0xacdc952e, 0x65b1f44a, 0x26a58f5d, + 0xe3990264, 0xa08d7973, 0xa382f182, 0xe0968a95, 0x25aa07ac, + 0x66be7cbb, 0xafd31ddf, 0xecc766c8, 0x29fbebf1, 0x6aef90e6, + 0xbb202939, 0xf834522e, 0x3d08df17, 0x7e1ca400, 0xb771c564, + 0xf465be73, 0x3159334a, 0x724d485d, 0xd2c0312e, 0x91d44a39, + 0x54e8c700, 0x17fcbc17, 0xde91dd73, 0x9d85a664, 0x58b92b5d, + 0x1bad504a, 0xca62e995, 0x89769282, 0x4c4a1fbb, 0x0f5e64ac, + 0xc63305c8, 0x85277edf, 0x401bf3e6, 0x030f88f1, 0x070392de, + 0x4417e9c9, 0x812b64f0, 0xc23f1fe7, 0x0b527e83, 0x48460594, + 0x8d7a88ad, 0xce6ef3ba, 0x1fa14a65, 0x5cb53172, 0x9989bc4b, + 0xda9dc75c, 0x13f0a638, 0x50e4dd2f, 0x95d85016, 0xd6cc2b01, + 0x76415272, 0x35552965, 0xf069a45c, 0xb37ddf4b, 0x7a10be2f, + 0x3904c538, 0xfc384801, 0xbf2c3316, 0x6ee38ac9, 0x2df7f1de, + 0xe8cb7ce7, 0xabdf07f0, 0x62b26694, 0x21a61d83, 0xe49a90ba, + 0xa78eebad, 0xa481635c, 0xe795184b, 0x22a99572, 0x61bdee65, + 0xa8d08f01, 0xebc4f416, 0x2ef8792f, 0x6dec0238, 0xbc23bbe7, + 0xff37c0f0, 0x3a0b4dc9, 0x791f36de, 0xb07257ba, 0xf3662cad, + 0x365aa194, 0x754eda83, 0xd5c3a3f0, 0x96d7d8e7, 0x53eb55de, + 0x10ff2ec9, 0xd9924fad, 0x9a8634ba, 0x5fbab983, 0x1caec294, + 0xcd617b4b, 0x8e75005c, 0x4b498d65, 0x085df672, 0xc1309716, + 0x8224ec01, 0x47186138, 0x040c1a2f, 0x4f005566, 0x0c142e71, + 0xc928a348, 0x8a3cd85f, 0x4351b93b, 0x0045c22c, 0xc5794f15, + 0x866d3402, 0x57a28ddd, 0x14b6f6ca, 0xd18a7bf3, 0x929e00e4, + 0x5bf36180, 0x18e71a97, 0xdddb97ae, 0x9ecfecb9, 0x3e4295ca, + 0x7d56eedd, 0xb86a63e4, 0xfb7e18f3, 0x32137997, 0x71070280, + 0xb43b8fb9, 0xf72ff4ae, 0x26e04d71, 0x65f43666, 0xa0c8bb5f, + 0xe3dcc048, 0x2ab1a12c, 0x69a5da3b, 0xac995702, 0xef8d2c15, + 0xec82a4e4, 0xaf96dff3, 0x6aaa52ca, 0x29be29dd, 0xe0d348b9, + 0xa3c733ae, 0x66fbbe97, 0x25efc580, 0xf4207c5f, 0xb7340748, + 0x72088a71, 0x311cf166, 0xf8719002, 0xbb65eb15, 0x7e59662c, + 0x3d4d1d3b, 0x9dc06448, 0xded41f5f, 0x1be89266, 0x58fce971, + 0x91918815, 0xd285f302, 0x17b97e3b, 0x54ad052c, 0x8562bcf3, + 0xc676c7e4, 0x034a4add, 0x405e31ca, 0x893350ae, 0xca272bb9, + 0x0f1ba680, 0x4c0fdd97, 0x4803c7b8, 0x0b17bcaf, 0xce2b3196, + 0x8d3f4a81, 0x44522be5, 0x074650f2, 0xc27addcb, 0x816ea6dc, + 0x50a11f03, 0x13b56414, 0xd689e92d, 0x959d923a, 0x5cf0f35e, + 0x1fe48849, 0xdad80570, 0x99cc7e67, 0x39410714, 0x7a557c03, + 0xbf69f13a, 0xfc7d8a2d, 0x3510eb49, 0x7604905e, 0xb3381d67, + 0xf02c6670, 0x21e3dfaf, 0x62f7a4b8, 0xa7cb2981, 0xe4df5296, + 0x2db233f2, 0x6ea648e5, 0xab9ac5dc, 0xe88ebecb, 0xeb81363a, + 0xa8954d2d, 0x6da9c014, 0x2ebdbb03, 0xe7d0da67, 0xa4c4a170, + 0x61f82c49, 0x22ec575e, 0xf323ee81, 0xb0379596, 0x750b18af, + 0x361f63b8, 0xff7202dc, 0xbc6679cb, 0x795af4f2, 0x3a4e8fe5, + 0x9ac3f696, 0xd9d78d81, 0x1ceb00b8, 0x5fff7baf, 0x96921acb, + 0xd58661dc, 0x10baece5, 0x53ae97f2, 0x82612e2d, 0xc175553a, + 0x0449d803, 0x475da314, 0x8e30c270, 0xcd24b967, 0x0818345e, + 0x4b0c4f49}, + {0x00000000, 0x3e6bc2ef, 0x3dd0f504, 0x03bb37eb, 0x7aa0eb09, + 0x44cb29e6, 0x47701e0d, 0x791bdce2, 0xf440d713, 0xca2b15fc, + 0xc9902217, 0xf7fbe0f8, 0x8ee03c1a, 0xb08bfef5, 0xb330c91e, + 0x8d5b0bf1, 0xe881ae27, 0xd6ea6cc8, 0xd5515b23, 0xeb3a99cc, + 0x9221452e, 0xac4a87c1, 0xaff1b02a, 0x919a72c5, 0x1cc17934, + 0x22aabbdb, 0x21118c30, 0x1f7a4edf, 0x6661923d, 0x580a50d2, + 0x5bb16739, 0x65daa5d6, 0xd0035d4f, 0xee689fa0, 0xedd3a84b, + 0xd3b86aa4, 0xaaa3b646, 0x94c874a9, 0x97734342, 0xa91881ad, + 0x24438a5c, 0x1a2848b3, 0x19937f58, 0x27f8bdb7, 0x5ee36155, + 0x6088a3ba, 0x63339451, 0x5d5856be, 0x3882f368, 0x06e93187, + 0x0552066c, 0x3b39c483, 0x42221861, 0x7c49da8e, 0x7ff2ed65, + 0x41992f8a, 0xccc2247b, 0xf2a9e694, 0xf112d17f, 0xcf791390, + 0xb662cf72, 0x88090d9d, 0x8bb23a76, 0xb5d9f899, 0xa007ba9e, + 0x9e6c7871, 0x9dd74f9a, 0xa3bc8d75, 0xdaa75197, 0xe4cc9378, + 0xe777a493, 0xd91c667c, 0x54476d8d, 0x6a2caf62, 0x69979889, + 0x57fc5a66, 0x2ee78684, 0x108c446b, 0x13377380, 0x2d5cb16f, + 0x488614b9, 0x76edd656, 0x7556e1bd, 0x4b3d2352, 0x3226ffb0, + 0x0c4d3d5f, 0x0ff60ab4, 0x319dc85b, 0xbcc6c3aa, 0x82ad0145, + 0x811636ae, 0xbf7df441, 0xc66628a3, 0xf80dea4c, 0xfbb6dda7, + 0xc5dd1f48, 0x7004e7d1, 0x4e6f253e, 0x4dd412d5, 0x73bfd03a, + 0x0aa40cd8, 0x34cfce37, 0x3774f9dc, 0x091f3b33, 0x844430c2, + 0xba2ff22d, 0xb994c5c6, 0x87ff0729, 0xfee4dbcb, 0xc08f1924, + 0xc3342ecf, 0xfd5fec20, 0x988549f6, 0xa6ee8b19, 0xa555bcf2, + 0x9b3e7e1d, 0xe225a2ff, 0xdc4e6010, 0xdff557fb, 0xe19e9514, + 0x6cc59ee5, 0x52ae5c0a, 0x51156be1, 0x6f7ea90e, 0x166575ec, + 0x280eb703, 0x2bb580e8, 0x15de4207, 0x010905e6, 0x3f62c709, + 0x3cd9f0e2, 0x02b2320d, 0x7ba9eeef, 0x45c22c00, 0x46791beb, + 0x7812d904, 0xf549d2f5, 0xcb22101a, 0xc89927f1, 0xf6f2e51e, + 0x8fe939fc, 0xb182fb13, 0xb239ccf8, 0x8c520e17, 0xe988abc1, + 0xd7e3692e, 0xd4585ec5, 0xea339c2a, 0x932840c8, 0xad438227, + 0xaef8b5cc, 0x90937723, 0x1dc87cd2, 0x23a3be3d, 0x201889d6, + 0x1e734b39, 0x676897db, 0x59035534, 0x5ab862df, 0x64d3a030, + 0xd10a58a9, 0xef619a46, 0xecdaadad, 0xd2b16f42, 0xabaab3a0, + 0x95c1714f, 0x967a46a4, 0xa811844b, 0x254a8fba, 0x1b214d55, + 0x189a7abe, 0x26f1b851, 0x5fea64b3, 0x6181a65c, 0x623a91b7, + 0x5c515358, 0x398bf68e, 0x07e03461, 0x045b038a, 0x3a30c165, + 0x432b1d87, 0x7d40df68, 0x7efbe883, 0x40902a6c, 0xcdcb219d, + 0xf3a0e372, 0xf01bd499, 0xce701676, 0xb76bca94, 0x8900087b, + 0x8abb3f90, 0xb4d0fd7f, 0xa10ebf78, 0x9f657d97, 0x9cde4a7c, + 0xa2b58893, 0xdbae5471, 0xe5c5969e, 0xe67ea175, 0xd815639a, + 0x554e686b, 0x6b25aa84, 0x689e9d6f, 0x56f55f80, 0x2fee8362, + 0x1185418d, 0x123e7666, 0x2c55b489, 0x498f115f, 0x77e4d3b0, + 0x745fe45b, 0x4a3426b4, 0x332ffa56, 0x0d4438b9, 0x0eff0f52, + 0x3094cdbd, 0xbdcfc64c, 0x83a404a3, 0x801f3348, 0xbe74f1a7, + 0xc76f2d45, 0xf904efaa, 0xfabfd841, 0xc4d41aae, 0x710de237, + 0x4f6620d8, 0x4cdd1733, 0x72b6d5dc, 0x0bad093e, 0x35c6cbd1, + 0x367dfc3a, 0x08163ed5, 0x854d3524, 0xbb26f7cb, 0xb89dc020, + 0x86f602cf, 0xffedde2d, 0xc1861cc2, 0xc23d2b29, 0xfc56e9c6, + 0x998c4c10, 0xa7e78eff, 0xa45cb914, 0x9a377bfb, 0xe32ca719, + 0xdd4765f6, 0xdefc521d, 0xe09790f2, 0x6dcc9b03, 0x53a759ec, + 0x501c6e07, 0x6e77ace8, 0x176c700a, 0x2907b2e5, 0x2abc850e, + 0x14d747e1}, + {0x00000000, 0xc0df8ec1, 0xc1b96c58, 0x0166e299, 0x8273d9b0, + 0x42ac5771, 0x43cab5e8, 0x83153b29, 0x45e1c3ba, 0x853e4d7b, + 0x8458afe2, 0x44872123, 0xc7921a0a, 0x074d94cb, 0x062b7652, + 0xc6f4f893, 0xcbc4f6ae, 0x0b1b786f, 0x0a7d9af6, 0xcaa21437, + 0x49b72f1e, 0x8968a1df, 0x880e4346, 0x48d1cd87, 0x8e253514, + 0x4efabbd5, 0x4f9c594c, 0x8f43d78d, 0x0c56eca4, 0xcc896265, + 0xcdef80fc, 0x0d300e3d, 0xd78f9c86, 0x17501247, 0x1636f0de, + 0xd6e97e1f, 0x55fc4536, 0x9523cbf7, 0x9445296e, 0x549aa7af, + 0x926e5f3c, 0x52b1d1fd, 0x53d73364, 0x9308bda5, 0x101d868c, + 0xd0c2084d, 0xd1a4ead4, 0x117b6415, 0x1c4b6a28, 0xdc94e4e9, + 0xddf20670, 0x1d2d88b1, 0x9e38b398, 0x5ee73d59, 0x5f81dfc0, + 0x9f5e5101, 0x59aaa992, 0x99752753, 0x9813c5ca, 0x58cc4b0b, + 0xdbd97022, 0x1b06fee3, 0x1a601c7a, 0xdabf92bb, 0xef1948d6, + 0x2fc6c617, 0x2ea0248e, 0xee7faa4f, 0x6d6a9166, 0xadb51fa7, + 0xacd3fd3e, 0x6c0c73ff, 0xaaf88b6c, 0x6a2705ad, 0x6b41e734, + 0xab9e69f5, 0x288b52dc, 0xe854dc1d, 0xe9323e84, 0x29edb045, + 0x24ddbe78, 0xe40230b9, 0xe564d220, 0x25bb5ce1, 0xa6ae67c8, + 0x6671e909, 0x67170b90, 0xa7c88551, 0x613c7dc2, 0xa1e3f303, + 0xa085119a, 0x605a9f5b, 0xe34fa472, 0x23902ab3, 0x22f6c82a, + 0xe22946eb, 0x3896d450, 0xf8495a91, 0xf92fb808, 0x39f036c9, + 0xbae50de0, 0x7a3a8321, 0x7b5c61b8, 0xbb83ef79, 0x7d7717ea, + 0xbda8992b, 0xbcce7bb2, 0x7c11f573, 0xff04ce5a, 0x3fdb409b, + 0x3ebda202, 0xfe622cc3, 0xf35222fe, 0x338dac3f, 0x32eb4ea6, + 0xf234c067, 0x7121fb4e, 0xb1fe758f, 0xb0989716, 0x704719d7, + 0xb6b3e144, 0x766c6f85, 0x770a8d1c, 0xb7d503dd, 0x34c038f4, + 0xf41fb635, 0xf57954ac, 0x35a6da6d, 0x9f35e177, 0x5fea6fb6, + 0x5e8c8d2f, 0x9e5303ee, 0x1d4638c7, 0xdd99b606, 0xdcff549f, + 0x1c20da5e, 0xdad422cd, 0x1a0bac0c, 0x1b6d4e95, 0xdbb2c054, + 0x58a7fb7d, 0x987875bc, 0x991e9725, 0x59c119e4, 0x54f117d9, + 0x942e9918, 0x95487b81, 0x5597f540, 0xd682ce69, 0x165d40a8, + 0x173ba231, 0xd7e42cf0, 0x1110d463, 0xd1cf5aa2, 0xd0a9b83b, + 0x107636fa, 0x93630dd3, 0x53bc8312, 0x52da618b, 0x9205ef4a, + 0x48ba7df1, 0x8865f330, 0x890311a9, 0x49dc9f68, 0xcac9a441, + 0x0a162a80, 0x0b70c819, 0xcbaf46d8, 0x0d5bbe4b, 0xcd84308a, + 0xcce2d213, 0x0c3d5cd2, 0x8f2867fb, 0x4ff7e93a, 0x4e910ba3, + 0x8e4e8562, 0x837e8b5f, 0x43a1059e, 0x42c7e707, 0x821869c6, + 0x010d52ef, 0xc1d2dc2e, 0xc0b43eb7, 0x006bb076, 0xc69f48e5, + 0x0640c624, 0x072624bd, 0xc7f9aa7c, 0x44ec9155, 0x84331f94, + 0x8555fd0d, 0x458a73cc, 0x702ca9a1, 0xb0f32760, 0xb195c5f9, + 0x714a4b38, 0xf25f7011, 0x3280fed0, 0x33e61c49, 0xf3399288, + 0x35cd6a1b, 0xf512e4da, 0xf4740643, 0x34ab8882, 0xb7beb3ab, + 0x77613d6a, 0x7607dff3, 0xb6d85132, 0xbbe85f0f, 0x7b37d1ce, + 0x7a513357, 0xba8ebd96, 0x399b86bf, 0xf944087e, 0xf822eae7, + 0x38fd6426, 0xfe099cb5, 0x3ed61274, 0x3fb0f0ed, 0xff6f7e2c, + 0x7c7a4505, 0xbca5cbc4, 0xbdc3295d, 0x7d1ca79c, 0xa7a33527, + 0x677cbbe6, 0x661a597f, 0xa6c5d7be, 0x25d0ec97, 0xe50f6256, + 0xe46980cf, 0x24b60e0e, 0xe242f69d, 0x229d785c, 0x23fb9ac5, + 0xe3241404, 0x60312f2d, 0xa0eea1ec, 0xa1884375, 0x6157cdb4, + 0x6c67c389, 0xacb84d48, 0xaddeafd1, 0x6d012110, 0xee141a39, + 0x2ecb94f8, 0x2fad7661, 0xef72f8a0, 0x29860033, 0xe9598ef2, + 0xe83f6c6b, 0x28e0e2aa, 0xabf5d983, 0x6b2a5742, 0x6a4cb5db, + 0xaa933b1a}, + {0x00000000, 0x6f4ca59b, 0x9f9e3bec, 0xf0d29e77, 0x7f3b0603, + 0x1077a398, 0xe0a53def, 0x8fe99874, 0xfe760c06, 0x913aa99d, + 0x61e837ea, 0x0ea49271, 0x814d0a05, 0xee01af9e, 0x1ed331e9, + 0x719f9472, 0xfced180c, 0x93a1bd97, 0x637323e0, 0x0c3f867b, + 0x83d61e0f, 0xec9abb94, 0x1c4825e3, 0x73048078, 0x029b140a, + 0x6dd7b191, 0x9d052fe6, 0xf2498a7d, 0x7da01209, 0x12ecb792, + 0xe23e29e5, 0x8d728c7e, 0xf8db3118, 0x97979483, 0x67450af4, + 0x0809af6f, 0x87e0371b, 0xe8ac9280, 0x187e0cf7, 0x7732a96c, + 0x06ad3d1e, 0x69e19885, 0x993306f2, 0xf67fa369, 0x79963b1d, + 0x16da9e86, 0xe60800f1, 0x8944a56a, 0x04362914, 0x6b7a8c8f, + 0x9ba812f8, 0xf4e4b763, 0x7b0d2f17, 0x14418a8c, 0xe49314fb, + 0x8bdfb160, 0xfa402512, 0x950c8089, 0x65de1efe, 0x0a92bb65, + 0x857b2311, 0xea37868a, 0x1ae518fd, 0x75a9bd66, 0xf0b76330, + 0x9ffbc6ab, 0x6f2958dc, 0x0065fd47, 0x8f8c6533, 0xe0c0c0a8, + 0x10125edf, 0x7f5efb44, 0x0ec16f36, 0x618dcaad, 0x915f54da, + 0xfe13f141, 0x71fa6935, 0x1eb6ccae, 0xee6452d9, 0x8128f742, + 0x0c5a7b3c, 0x6316dea7, 0x93c440d0, 0xfc88e54b, 0x73617d3f, + 0x1c2dd8a4, 0xecff46d3, 0x83b3e348, 0xf22c773a, 0x9d60d2a1, + 0x6db24cd6, 0x02fee94d, 0x8d177139, 0xe25bd4a2, 0x12894ad5, + 0x7dc5ef4e, 0x086c5228, 0x6720f7b3, 0x97f269c4, 0xf8becc5f, + 0x7757542b, 0x181bf1b0, 0xe8c96fc7, 0x8785ca5c, 0xf61a5e2e, + 0x9956fbb5, 0x698465c2, 0x06c8c059, 0x8921582d, 0xe66dfdb6, + 0x16bf63c1, 0x79f3c65a, 0xf4814a24, 0x9bcdefbf, 0x6b1f71c8, + 0x0453d453, 0x8bba4c27, 0xe4f6e9bc, 0x142477cb, 0x7b68d250, + 0x0af74622, 0x65bbe3b9, 0x95697dce, 0xfa25d855, 0x75cc4021, + 0x1a80e5ba, 0xea527bcd, 0x851ede56, 0xe06fc760, 0x8f2362fb, + 0x7ff1fc8c, 0x10bd5917, 0x9f54c163, 0xf01864f8, 0x00cafa8f, + 0x6f865f14, 0x1e19cb66, 0x71556efd, 0x8187f08a, 0xeecb5511, + 0x6122cd65, 0x0e6e68fe, 0xfebcf689, 0x91f05312, 0x1c82df6c, + 0x73ce7af7, 0x831ce480, 0xec50411b, 0x63b9d96f, 0x0cf57cf4, + 0xfc27e283, 0x936b4718, 0xe2f4d36a, 0x8db876f1, 0x7d6ae886, + 0x12264d1d, 0x9dcfd569, 0xf28370f2, 0x0251ee85, 0x6d1d4b1e, + 0x18b4f678, 0x77f853e3, 0x872acd94, 0xe866680f, 0x678ff07b, + 0x08c355e0, 0xf811cb97, 0x975d6e0c, 0xe6c2fa7e, 0x898e5fe5, + 0x795cc192, 0x16106409, 0x99f9fc7d, 0xf6b559e6, 0x0667c791, + 0x692b620a, 0xe459ee74, 0x8b154bef, 0x7bc7d598, 0x148b7003, + 0x9b62e877, 0xf42e4dec, 0x04fcd39b, 0x6bb07600, 0x1a2fe272, + 0x756347e9, 0x85b1d99e, 0xeafd7c05, 0x6514e471, 0x0a5841ea, + 0xfa8adf9d, 0x95c67a06, 0x10d8a450, 0x7f9401cb, 0x8f469fbc, + 0xe00a3a27, 0x6fe3a253, 0x00af07c8, 0xf07d99bf, 0x9f313c24, + 0xeeaea856, 0x81e20dcd, 0x713093ba, 0x1e7c3621, 0x9195ae55, + 0xfed90bce, 0x0e0b95b9, 0x61473022, 0xec35bc5c, 0x837919c7, + 0x73ab87b0, 0x1ce7222b, 0x930eba5f, 0xfc421fc4, 0x0c9081b3, + 0x63dc2428, 0x1243b05a, 0x7d0f15c1, 0x8ddd8bb6, 0xe2912e2d, + 0x6d78b659, 0x023413c2, 0xf2e68db5, 0x9daa282e, 0xe8039548, + 0x874f30d3, 0x779daea4, 0x18d10b3f, 0x9738934b, 0xf87436d0, + 0x08a6a8a7, 0x67ea0d3c, 0x1675994e, 0x79393cd5, 0x89eba2a2, + 0xe6a70739, 0x694e9f4d, 0x06023ad6, 0xf6d0a4a1, 0x999c013a, + 0x14ee8d44, 0x7ba228df, 0x8b70b6a8, 0xe43c1333, 0x6bd58b47, + 0x04992edc, 0xf44bb0ab, 0x9b071530, 0xea988142, 0x85d424d9, + 0x7506baae, 0x1a4a1f35, 0x95a38741, 0xfaef22da, 0x0a3dbcad, + 0x65711936}}; + +#endif + +#endif + +#if N == 4 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xf1da05aa, 0x38c50d15, 0xc91f08bf, 0x718a1a2a, + 0x80501f80, 0x494f173f, 0xb8951295, 0xe3143454, 0x12ce31fe, + 0xdbd13941, 0x2a0b3ceb, 0x929e2e7e, 0x63442bd4, 0xaa5b236b, + 0x5b8126c1, 0x1d596ee9, 0xec836b43, 0x259c63fc, 0xd4466656, + 0x6cd374c3, 0x9d097169, 0x541679d6, 0xa5cc7c7c, 0xfe4d5abd, + 0x0f975f17, 0xc68857a8, 0x37525202, 0x8fc74097, 0x7e1d453d, + 0xb7024d82, 0x46d84828, 0x3ab2ddd2, 0xcb68d878, 0x0277d0c7, + 0xf3add56d, 0x4b38c7f8, 0xbae2c252, 0x73fdcaed, 0x8227cf47, + 0xd9a6e986, 0x287cec2c, 0xe163e493, 0x10b9e139, 0xa82cf3ac, + 0x59f6f606, 0x90e9feb9, 0x6133fb13, 0x27ebb33b, 0xd631b691, + 0x1f2ebe2e, 0xeef4bb84, 0x5661a911, 0xa7bbacbb, 0x6ea4a404, + 0x9f7ea1ae, 0xc4ff876f, 0x352582c5, 0xfc3a8a7a, 0x0de08fd0, + 0xb5759d45, 0x44af98ef, 0x8db09050, 0x7c6a95fa, 0x7565bba4, + 0x84bfbe0e, 0x4da0b6b1, 0xbc7ab31b, 0x04efa18e, 0xf535a424, + 0x3c2aac9b, 0xcdf0a931, 0x96718ff0, 0x67ab8a5a, 0xaeb482e5, + 0x5f6e874f, 0xe7fb95da, 0x16219070, 0xdf3e98cf, 0x2ee49d65, + 0x683cd54d, 0x99e6d0e7, 0x50f9d858, 0xa123ddf2, 0x19b6cf67, + 0xe86ccacd, 0x2173c272, 0xd0a9c7d8, 0x8b28e119, 0x7af2e4b3, + 0xb3edec0c, 0x4237e9a6, 0xfaa2fb33, 0x0b78fe99, 0xc267f626, + 0x33bdf38c, 0x4fd76676, 0xbe0d63dc, 0x77126b63, 0x86c86ec9, + 0x3e5d7c5c, 0xcf8779f6, 0x06987149, 0xf74274e3, 0xacc35222, + 0x5d195788, 0x94065f37, 0x65dc5a9d, 0xdd494808, 0x2c934da2, + 0xe58c451d, 0x145640b7, 0x528e089f, 0xa3540d35, 0x6a4b058a, + 0x9b910020, 0x230412b5, 0xd2de171f, 0x1bc11fa0, 0xea1b1a0a, + 0xb19a3ccb, 0x40403961, 0x895f31de, 0x78853474, 0xc01026e1, + 0x31ca234b, 0xf8d52bf4, 0x090f2e5e, 0xeacb7748, 0x1b1172e2, + 0xd20e7a5d, 0x23d47ff7, 0x9b416d62, 0x6a9b68c8, 0xa3846077, + 0x525e65dd, 0x09df431c, 0xf80546b6, 0x311a4e09, 0xc0c04ba3, + 0x78555936, 0x898f5c9c, 0x40905423, 0xb14a5189, 0xf79219a1, + 0x06481c0b, 0xcf5714b4, 0x3e8d111e, 0x8618038b, 0x77c20621, + 0xbedd0e9e, 0x4f070b34, 0x14862df5, 0xe55c285f, 0x2c4320e0, + 0xdd99254a, 0x650c37df, 0x94d63275, 0x5dc93aca, 0xac133f60, + 0xd079aa9a, 0x21a3af30, 0xe8bca78f, 0x1966a225, 0xa1f3b0b0, + 0x5029b51a, 0x9936bda5, 0x68ecb80f, 0x336d9ece, 0xc2b79b64, + 0x0ba893db, 0xfa729671, 0x42e784e4, 0xb33d814e, 0x7a2289f1, + 0x8bf88c5b, 0xcd20c473, 0x3cfac1d9, 0xf5e5c966, 0x043fcccc, + 0xbcaade59, 0x4d70dbf3, 0x846fd34c, 0x75b5d6e6, 0x2e34f027, + 0xdfeef58d, 0x16f1fd32, 0xe72bf898, 0x5fbeea0d, 0xae64efa7, + 0x677be718, 0x96a1e2b2, 0x9faeccec, 0x6e74c946, 0xa76bc1f9, + 0x56b1c453, 0xee24d6c6, 0x1ffed36c, 0xd6e1dbd3, 0x273bde79, + 0x7cbaf8b8, 0x8d60fd12, 0x447ff5ad, 0xb5a5f007, 0x0d30e292, + 0xfceae738, 0x35f5ef87, 0xc42fea2d, 0x82f7a205, 0x732da7af, + 0xba32af10, 0x4be8aaba, 0xf37db82f, 0x02a7bd85, 0xcbb8b53a, + 0x3a62b090, 0x61e39651, 0x903993fb, 0x59269b44, 0xa8fc9eee, + 0x10698c7b, 0xe1b389d1, 0x28ac816e, 0xd97684c4, 0xa51c113e, + 0x54c61494, 0x9dd91c2b, 0x6c031981, 0xd4960b14, 0x254c0ebe, + 0xec530601, 0x1d8903ab, 0x4608256a, 0xb7d220c0, 0x7ecd287f, + 0x8f172dd5, 0x37823f40, 0xc6583aea, 0x0f473255, 0xfe9d37ff, + 0xb8457fd7, 0x499f7a7d, 0x808072c2, 0x715a7768, 0xc9cf65fd, + 0x38156057, 0xf10a68e8, 0x00d06d42, 0x5b514b83, 0xaa8b4e29, + 0x63944696, 0x924e433c, 0x2adb51a9, 0xdb015403, 0x121e5cbc, + 0xe3c45916}, + {0x00000000, 0x0ee7e8d1, 0x1dcfd1a2, 0x13283973, 0x3b9fa344, + 0x35784b95, 0x265072e6, 0x28b79a37, 0x773f4688, 0x79d8ae59, + 0x6af0972a, 0x64177ffb, 0x4ca0e5cc, 0x42470d1d, 0x516f346e, + 0x5f88dcbf, 0xee7e8d10, 0xe09965c1, 0xf3b15cb2, 0xfd56b463, + 0xd5e12e54, 0xdb06c685, 0xc82efff6, 0xc6c91727, 0x9941cb98, + 0x97a62349, 0x848e1a3a, 0x8a69f2eb, 0xa2de68dc, 0xac39800d, + 0xbf11b97e, 0xb1f651af, 0x078c1c61, 0x096bf4b0, 0x1a43cdc3, + 0x14a42512, 0x3c13bf25, 0x32f457f4, 0x21dc6e87, 0x2f3b8656, + 0x70b35ae9, 0x7e54b238, 0x6d7c8b4b, 0x639b639a, 0x4b2cf9ad, + 0x45cb117c, 0x56e3280f, 0x5804c0de, 0xe9f29171, 0xe71579a0, + 0xf43d40d3, 0xfadaa802, 0xd26d3235, 0xdc8adae4, 0xcfa2e397, + 0xc1450b46, 0x9ecdd7f9, 0x902a3f28, 0x8302065b, 0x8de5ee8a, + 0xa55274bd, 0xabb59c6c, 0xb89da51f, 0xb67a4dce, 0x0f1838c2, + 0x01ffd013, 0x12d7e960, 0x1c3001b1, 0x34879b86, 0x3a607357, + 0x29484a24, 0x27afa2f5, 0x78277e4a, 0x76c0969b, 0x65e8afe8, + 0x6b0f4739, 0x43b8dd0e, 0x4d5f35df, 0x5e770cac, 0x5090e47d, + 0xe166b5d2, 0xef815d03, 0xfca96470, 0xf24e8ca1, 0xdaf91696, + 0xd41efe47, 0xc736c734, 0xc9d12fe5, 0x9659f35a, 0x98be1b8b, + 0x8b9622f8, 0x8571ca29, 0xadc6501e, 0xa321b8cf, 0xb00981bc, + 0xbeee696d, 0x089424a3, 0x0673cc72, 0x155bf501, 0x1bbc1dd0, + 0x330b87e7, 0x3dec6f36, 0x2ec45645, 0x2023be94, 0x7fab622b, + 0x714c8afa, 0x6264b389, 0x6c835b58, 0x4434c16f, 0x4ad329be, + 0x59fb10cd, 0x571cf81c, 0xe6eaa9b3, 0xe80d4162, 0xfb257811, + 0xf5c290c0, 0xdd750af7, 0xd392e226, 0xc0badb55, 0xce5d3384, + 0x91d5ef3b, 0x9f3207ea, 0x8c1a3e99, 0x82fdd648, 0xaa4a4c7f, + 0xa4ada4ae, 0xb7859ddd, 0xb962750c, 0x1e307184, 0x10d79955, + 0x03ffa026, 0x0d1848f7, 0x25afd2c0, 0x2b483a11, 0x38600362, + 0x3687ebb3, 0x690f370c, 0x67e8dfdd, 0x74c0e6ae, 0x7a270e7f, + 0x52909448, 0x5c777c99, 0x4f5f45ea, 0x41b8ad3b, 0xf04efc94, + 0xfea91445, 0xed812d36, 0xe366c5e7, 0xcbd15fd0, 0xc536b701, + 0xd61e8e72, 0xd8f966a3, 0x8771ba1c, 0x899652cd, 0x9abe6bbe, + 0x9459836f, 0xbcee1958, 0xb209f189, 0xa121c8fa, 0xafc6202b, + 0x19bc6de5, 0x175b8534, 0x0473bc47, 0x0a945496, 0x2223cea1, + 0x2cc42670, 0x3fec1f03, 0x310bf7d2, 0x6e832b6d, 0x6064c3bc, + 0x734cfacf, 0x7dab121e, 0x551c8829, 0x5bfb60f8, 0x48d3598b, + 0x4634b15a, 0xf7c2e0f5, 0xf9250824, 0xea0d3157, 0xe4ead986, + 0xcc5d43b1, 0xc2baab60, 0xd1929213, 0xdf757ac2, 0x80fda67d, + 0x8e1a4eac, 0x9d3277df, 0x93d59f0e, 0xbb620539, 0xb585ede8, + 0xa6add49b, 0xa84a3c4a, 0x11284946, 0x1fcfa197, 0x0ce798e4, + 0x02007035, 0x2ab7ea02, 0x245002d3, 0x37783ba0, 0x399fd371, + 0x66170fce, 0x68f0e71f, 0x7bd8de6c, 0x753f36bd, 0x5d88ac8a, + 0x536f445b, 0x40477d28, 0x4ea095f9, 0xff56c456, 0xf1b12c87, + 0xe29915f4, 0xec7efd25, 0xc4c96712, 0xca2e8fc3, 0xd906b6b0, + 0xd7e15e61, 0x886982de, 0x868e6a0f, 0x95a6537c, 0x9b41bbad, + 0xb3f6219a, 0xbd11c94b, 0xae39f038, 0xa0de18e9, 0x16a45527, + 0x1843bdf6, 0x0b6b8485, 0x058c6c54, 0x2d3bf663, 0x23dc1eb2, + 0x30f427c1, 0x3e13cf10, 0x619b13af, 0x6f7cfb7e, 0x7c54c20d, + 0x72b32adc, 0x5a04b0eb, 0x54e3583a, 0x47cb6149, 0x492c8998, + 0xf8dad837, 0xf63d30e6, 0xe5150995, 0xebf2e144, 0xc3457b73, + 0xcda293a2, 0xde8aaad1, 0xd06d4200, 0x8fe59ebf, 0x8102766e, + 0x922a4f1d, 0x9ccda7cc, 0xb47a3dfb, 0xba9dd52a, 0xa9b5ec59, + 0xa7520488}, + {0x00000000, 0x3c60e308, 0x78c1c610, 0x44a12518, 0xf1838c20, + 0xcde36f28, 0x89424a30, 0xb522a938, 0x38761e01, 0x0416fd09, + 0x40b7d811, 0x7cd73b19, 0xc9f59221, 0xf5957129, 0xb1345431, + 0x8d54b739, 0x70ec3c02, 0x4c8cdf0a, 0x082dfa12, 0x344d191a, + 0x816fb022, 0xbd0f532a, 0xf9ae7632, 0xc5ce953a, 0x489a2203, + 0x74fac10b, 0x305be413, 0x0c3b071b, 0xb919ae23, 0x85794d2b, + 0xc1d86833, 0xfdb88b3b, 0xe1d87804, 0xddb89b0c, 0x9919be14, + 0xa5795d1c, 0x105bf424, 0x2c3b172c, 0x689a3234, 0x54fad13c, + 0xd9ae6605, 0xe5ce850d, 0xa16fa015, 0x9d0f431d, 0x282dea25, + 0x144d092d, 0x50ec2c35, 0x6c8ccf3d, 0x91344406, 0xad54a70e, + 0xe9f58216, 0xd595611e, 0x60b7c826, 0x5cd72b2e, 0x18760e36, + 0x2416ed3e, 0xa9425a07, 0x9522b90f, 0xd1839c17, 0xede37f1f, + 0x58c1d627, 0x64a1352f, 0x20001037, 0x1c60f33f, 0x18c1f649, + 0x24a11541, 0x60003059, 0x5c60d351, 0xe9427a69, 0xd5229961, + 0x9183bc79, 0xade35f71, 0x20b7e848, 0x1cd70b40, 0x58762e58, + 0x6416cd50, 0xd1346468, 0xed548760, 0xa9f5a278, 0x95954170, + 0x682dca4b, 0x544d2943, 0x10ec0c5b, 0x2c8cef53, 0x99ae466b, + 0xa5cea563, 0xe16f807b, 0xdd0f6373, 0x505bd44a, 0x6c3b3742, + 0x289a125a, 0x14faf152, 0xa1d8586a, 0x9db8bb62, 0xd9199e7a, + 0xe5797d72, 0xf9198e4d, 0xc5796d45, 0x81d8485d, 0xbdb8ab55, + 0x089a026d, 0x34fae165, 0x705bc47d, 0x4c3b2775, 0xc16f904c, + 0xfd0f7344, 0xb9ae565c, 0x85ceb554, 0x30ec1c6c, 0x0c8cff64, + 0x482dda7c, 0x744d3974, 0x89f5b24f, 0xb5955147, 0xf134745f, + 0xcd549757, 0x78763e6f, 0x4416dd67, 0x00b7f87f, 0x3cd71b77, + 0xb183ac4e, 0x8de34f46, 0xc9426a5e, 0xf5228956, 0x4000206e, + 0x7c60c366, 0x38c1e67e, 0x04a10576, 0x3183ec92, 0x0de30f9a, + 0x49422a82, 0x7522c98a, 0xc00060b2, 0xfc6083ba, 0xb8c1a6a2, + 0x84a145aa, 0x09f5f293, 0x3595119b, 0x71343483, 0x4d54d78b, + 0xf8767eb3, 0xc4169dbb, 0x80b7b8a3, 0xbcd75bab, 0x416fd090, + 0x7d0f3398, 0x39ae1680, 0x05cef588, 0xb0ec5cb0, 0x8c8cbfb8, + 0xc82d9aa0, 0xf44d79a8, 0x7919ce91, 0x45792d99, 0x01d80881, + 0x3db8eb89, 0x889a42b1, 0xb4faa1b9, 0xf05b84a1, 0xcc3b67a9, + 0xd05b9496, 0xec3b779e, 0xa89a5286, 0x94fab18e, 0x21d818b6, + 0x1db8fbbe, 0x5919dea6, 0x65793dae, 0xe82d8a97, 0xd44d699f, + 0x90ec4c87, 0xac8caf8f, 0x19ae06b7, 0x25cee5bf, 0x616fc0a7, + 0x5d0f23af, 0xa0b7a894, 0x9cd74b9c, 0xd8766e84, 0xe4168d8c, + 0x513424b4, 0x6d54c7bc, 0x29f5e2a4, 0x159501ac, 0x98c1b695, + 0xa4a1559d, 0xe0007085, 0xdc60938d, 0x69423ab5, 0x5522d9bd, + 0x1183fca5, 0x2de31fad, 0x29421adb, 0x1522f9d3, 0x5183dccb, + 0x6de33fc3, 0xd8c196fb, 0xe4a175f3, 0xa00050eb, 0x9c60b3e3, + 0x113404da, 0x2d54e7d2, 0x69f5c2ca, 0x559521c2, 0xe0b788fa, + 0xdcd76bf2, 0x98764eea, 0xa416ade2, 0x59ae26d9, 0x65cec5d1, + 0x216fe0c9, 0x1d0f03c1, 0xa82daaf9, 0x944d49f1, 0xd0ec6ce9, + 0xec8c8fe1, 0x61d838d8, 0x5db8dbd0, 0x1919fec8, 0x25791dc0, + 0x905bb4f8, 0xac3b57f0, 0xe89a72e8, 0xd4fa91e0, 0xc89a62df, + 0xf4fa81d7, 0xb05ba4cf, 0x8c3b47c7, 0x3919eeff, 0x05790df7, + 0x41d828ef, 0x7db8cbe7, 0xf0ec7cde, 0xcc8c9fd6, 0x882dbace, + 0xb44d59c6, 0x016ff0fe, 0x3d0f13f6, 0x79ae36ee, 0x45ced5e6, + 0xb8765edd, 0x8416bdd5, 0xc0b798cd, 0xfcd77bc5, 0x49f5d2fd, + 0x759531f5, 0x313414ed, 0x0d54f7e5, 0x800040dc, 0xbc60a3d4, + 0xf8c186cc, 0xc4a165c4, 0x7183ccfc, 0x4de32ff4, 0x09420aec, + 0x3522e9e4}, + {0x00000000, 0x6307d924, 0xc60fb248, 0xa5086b6c, 0x576e62d1, + 0x3469bbf5, 0x9161d099, 0xf26609bd, 0xaedcc5a2, 0xcddb1c86, + 0x68d377ea, 0x0bd4aece, 0xf9b2a773, 0x9ab57e57, 0x3fbd153b, + 0x5cbacc1f, 0x86c88d05, 0xe5cf5421, 0x40c73f4d, 0x23c0e669, + 0xd1a6efd4, 0xb2a136f0, 0x17a95d9c, 0x74ae84b8, 0x281448a7, + 0x4b139183, 0xee1bfaef, 0x8d1c23cb, 0x7f7a2a76, 0x1c7df352, + 0xb975983e, 0xda72411a, 0xd6e01c4b, 0xb5e7c56f, 0x10efae03, + 0x73e87727, 0x818e7e9a, 0xe289a7be, 0x4781ccd2, 0x248615f6, + 0x783cd9e9, 0x1b3b00cd, 0xbe336ba1, 0xdd34b285, 0x2f52bb38, + 0x4c55621c, 0xe95d0970, 0x8a5ad054, 0x5028914e, 0x332f486a, + 0x96272306, 0xf520fa22, 0x0746f39f, 0x64412abb, 0xc14941d7, + 0xa24e98f3, 0xfef454ec, 0x9df38dc8, 0x38fbe6a4, 0x5bfc3f80, + 0xa99a363d, 0xca9def19, 0x6f958475, 0x0c925d51, 0x76b13ed7, + 0x15b6e7f3, 0xb0be8c9f, 0xd3b955bb, 0x21df5c06, 0x42d88522, + 0xe7d0ee4e, 0x84d7376a, 0xd86dfb75, 0xbb6a2251, 0x1e62493d, + 0x7d659019, 0x8f0399a4, 0xec044080, 0x490c2bec, 0x2a0bf2c8, + 0xf079b3d2, 0x937e6af6, 0x3676019a, 0x5571d8be, 0xa717d103, + 0xc4100827, 0x6118634b, 0x021fba6f, 0x5ea57670, 0x3da2af54, + 0x98aac438, 0xfbad1d1c, 0x09cb14a1, 0x6acccd85, 0xcfc4a6e9, + 0xacc37fcd, 0xa051229c, 0xc356fbb8, 0x665e90d4, 0x055949f0, + 0xf73f404d, 0x94389969, 0x3130f205, 0x52372b21, 0x0e8de73e, + 0x6d8a3e1a, 0xc8825576, 0xab858c52, 0x59e385ef, 0x3ae45ccb, + 0x9fec37a7, 0xfcebee83, 0x2699af99, 0x459e76bd, 0xe0961dd1, + 0x8391c4f5, 0x71f7cd48, 0x12f0146c, 0xb7f87f00, 0xd4ffa624, + 0x88456a3b, 0xeb42b31f, 0x4e4ad873, 0x2d4d0157, 0xdf2b08ea, + 0xbc2cd1ce, 0x1924baa2, 0x7a236386, 0xed627dae, 0x8e65a48a, + 0x2b6dcfe6, 0x486a16c2, 0xba0c1f7f, 0xd90bc65b, 0x7c03ad37, + 0x1f047413, 0x43beb80c, 0x20b96128, 0x85b10a44, 0xe6b6d360, + 0x14d0dadd, 0x77d703f9, 0xd2df6895, 0xb1d8b1b1, 0x6baaf0ab, + 0x08ad298f, 0xada542e3, 0xcea29bc7, 0x3cc4927a, 0x5fc34b5e, + 0xfacb2032, 0x99ccf916, 0xc5763509, 0xa671ec2d, 0x03798741, + 0x607e5e65, 0x921857d8, 0xf11f8efc, 0x5417e590, 0x37103cb4, + 0x3b8261e5, 0x5885b8c1, 0xfd8dd3ad, 0x9e8a0a89, 0x6cec0334, + 0x0febda10, 0xaae3b17c, 0xc9e46858, 0x955ea447, 0xf6597d63, + 0x5351160f, 0x3056cf2b, 0xc230c696, 0xa1371fb2, 0x043f74de, + 0x6738adfa, 0xbd4aece0, 0xde4d35c4, 0x7b455ea8, 0x1842878c, + 0xea248e31, 0x89235715, 0x2c2b3c79, 0x4f2ce55d, 0x13962942, + 0x7091f066, 0xd5999b0a, 0xb69e422e, 0x44f84b93, 0x27ff92b7, + 0x82f7f9db, 0xe1f020ff, 0x9bd34379, 0xf8d49a5d, 0x5ddcf131, + 0x3edb2815, 0xccbd21a8, 0xafbaf88c, 0x0ab293e0, 0x69b54ac4, + 0x350f86db, 0x56085fff, 0xf3003493, 0x9007edb7, 0x6261e40a, + 0x01663d2e, 0xa46e5642, 0xc7698f66, 0x1d1bce7c, 0x7e1c1758, + 0xdb147c34, 0xb813a510, 0x4a75acad, 0x29727589, 0x8c7a1ee5, + 0xef7dc7c1, 0xb3c70bde, 0xd0c0d2fa, 0x75c8b996, 0x16cf60b2, + 0xe4a9690f, 0x87aeb02b, 0x22a6db47, 0x41a10263, 0x4d335f32, + 0x2e348616, 0x8b3ced7a, 0xe83b345e, 0x1a5d3de3, 0x795ae4c7, + 0xdc528fab, 0xbf55568f, 0xe3ef9a90, 0x80e843b4, 0x25e028d8, + 0x46e7f1fc, 0xb481f841, 0xd7862165, 0x728e4a09, 0x1189932d, + 0xcbfbd237, 0xa8fc0b13, 0x0df4607f, 0x6ef3b95b, 0x9c95b0e6, + 0xff9269c2, 0x5a9a02ae, 0x399ddb8a, 0x65271795, 0x0620ceb1, + 0xa328a5dd, 0xc02f7cf9, 0x32497544, 0x514eac60, 0xf446c70c, + 0x97411e28}, + {0x00000000, 0x01b5fd1d, 0x036bfa3a, 0x02de0727, 0x06d7f474, + 0x07620969, 0x05bc0e4e, 0x0409f353, 0x0dafe8e8, 0x0c1a15f5, + 0x0ec412d2, 0x0f71efcf, 0x0b781c9c, 0x0acde181, 0x0813e6a6, + 0x09a61bbb, 0x1b5fd1d0, 0x1aea2ccd, 0x18342bea, 0x1981d6f7, + 0x1d8825a4, 0x1c3dd8b9, 0x1ee3df9e, 0x1f562283, 0x16f03938, + 0x1745c425, 0x159bc302, 0x142e3e1f, 0x1027cd4c, 0x11923051, + 0x134c3776, 0x12f9ca6b, 0x36bfa3a0, 0x370a5ebd, 0x35d4599a, + 0x3461a487, 0x306857d4, 0x31ddaac9, 0x3303adee, 0x32b650f3, + 0x3b104b48, 0x3aa5b655, 0x387bb172, 0x39ce4c6f, 0x3dc7bf3c, + 0x3c724221, 0x3eac4506, 0x3f19b81b, 0x2de07270, 0x2c558f6d, + 0x2e8b884a, 0x2f3e7557, 0x2b378604, 0x2a827b19, 0x285c7c3e, + 0x29e98123, 0x204f9a98, 0x21fa6785, 0x232460a2, 0x22919dbf, + 0x26986eec, 0x272d93f1, 0x25f394d6, 0x244669cb, 0x6d7f4740, + 0x6ccaba5d, 0x6e14bd7a, 0x6fa14067, 0x6ba8b334, 0x6a1d4e29, + 0x68c3490e, 0x6976b413, 0x60d0afa8, 0x616552b5, 0x63bb5592, + 0x620ea88f, 0x66075bdc, 0x67b2a6c1, 0x656ca1e6, 0x64d95cfb, + 0x76209690, 0x77956b8d, 0x754b6caa, 0x74fe91b7, 0x70f762e4, + 0x71429ff9, 0x739c98de, 0x722965c3, 0x7b8f7e78, 0x7a3a8365, + 0x78e48442, 0x7951795f, 0x7d588a0c, 0x7ced7711, 0x7e337036, + 0x7f868d2b, 0x5bc0e4e0, 0x5a7519fd, 0x58ab1eda, 0x591ee3c7, + 0x5d171094, 0x5ca2ed89, 0x5e7ceaae, 0x5fc917b3, 0x566f0c08, + 0x57daf115, 0x5504f632, 0x54b10b2f, 0x50b8f87c, 0x510d0561, + 0x53d30246, 0x5266ff5b, 0x409f3530, 0x412ac82d, 0x43f4cf0a, + 0x42413217, 0x4648c144, 0x47fd3c59, 0x45233b7e, 0x4496c663, + 0x4d30ddd8, 0x4c8520c5, 0x4e5b27e2, 0x4feedaff, 0x4be729ac, + 0x4a52d4b1, 0x488cd396, 0x49392e8b, 0xdafe8e80, 0xdb4b739d, + 0xd99574ba, 0xd82089a7, 0xdc297af4, 0xdd9c87e9, 0xdf4280ce, + 0xdef77dd3, 0xd7516668, 0xd6e49b75, 0xd43a9c52, 0xd58f614f, + 0xd186921c, 0xd0336f01, 0xd2ed6826, 0xd358953b, 0xc1a15f50, + 0xc014a24d, 0xc2caa56a, 0xc37f5877, 0xc776ab24, 0xc6c35639, + 0xc41d511e, 0xc5a8ac03, 0xcc0eb7b8, 0xcdbb4aa5, 0xcf654d82, + 0xced0b09f, 0xcad943cc, 0xcb6cbed1, 0xc9b2b9f6, 0xc80744eb, + 0xec412d20, 0xedf4d03d, 0xef2ad71a, 0xee9f2a07, 0xea96d954, + 0xeb232449, 0xe9fd236e, 0xe848de73, 0xe1eec5c8, 0xe05b38d5, + 0xe2853ff2, 0xe330c2ef, 0xe73931bc, 0xe68ccca1, 0xe452cb86, + 0xe5e7369b, 0xf71efcf0, 0xf6ab01ed, 0xf47506ca, 0xf5c0fbd7, + 0xf1c90884, 0xf07cf599, 0xf2a2f2be, 0xf3170fa3, 0xfab11418, + 0xfb04e905, 0xf9daee22, 0xf86f133f, 0xfc66e06c, 0xfdd31d71, + 0xff0d1a56, 0xfeb8e74b, 0xb781c9c0, 0xb63434dd, 0xb4ea33fa, + 0xb55fcee7, 0xb1563db4, 0xb0e3c0a9, 0xb23dc78e, 0xb3883a93, + 0xba2e2128, 0xbb9bdc35, 0xb945db12, 0xb8f0260f, 0xbcf9d55c, + 0xbd4c2841, 0xbf922f66, 0xbe27d27b, 0xacde1810, 0xad6be50d, + 0xafb5e22a, 0xae001f37, 0xaa09ec64, 0xabbc1179, 0xa962165e, + 0xa8d7eb43, 0xa171f0f8, 0xa0c40de5, 0xa21a0ac2, 0xa3aff7df, + 0xa7a6048c, 0xa613f991, 0xa4cdfeb6, 0xa57803ab, 0x813e6a60, + 0x808b977d, 0x8255905a, 0x83e06d47, 0x87e99e14, 0x865c6309, + 0x8482642e, 0x85379933, 0x8c918288, 0x8d247f95, 0x8ffa78b2, + 0x8e4f85af, 0x8a4676fc, 0x8bf38be1, 0x892d8cc6, 0x889871db, + 0x9a61bbb0, 0x9bd446ad, 0x990a418a, 0x98bfbc97, 0x9cb64fc4, + 0x9d03b2d9, 0x9fddb5fe, 0x9e6848e3, 0x97ce5358, 0x967bae45, + 0x94a5a962, 0x9510547f, 0x9119a72c, 0x90ac5a31, 0x92725d16, + 0x93c7a00b}, + {0x00000000, 0x6e8c1b41, 0xdd183682, 0xb3942dc3, 0x61416b45, + 0x0fcd7004, 0xbc595dc7, 0xd2d54686, 0xc282d68a, 0xac0ecdcb, + 0x1f9ae008, 0x7116fb49, 0xa3c3bdcf, 0xcd4fa68e, 0x7edb8b4d, + 0x1057900c, 0x5e74ab55, 0x30f8b014, 0x836c9dd7, 0xede08696, + 0x3f35c010, 0x51b9db51, 0xe22df692, 0x8ca1edd3, 0x9cf67ddf, + 0xf27a669e, 0x41ee4b5d, 0x2f62501c, 0xfdb7169a, 0x933b0ddb, + 0x20af2018, 0x4e233b59, 0xbce956aa, 0xd2654deb, 0x61f16028, + 0x0f7d7b69, 0xdda83def, 0xb32426ae, 0x00b00b6d, 0x6e3c102c, + 0x7e6b8020, 0x10e79b61, 0xa373b6a2, 0xcdffade3, 0x1f2aeb65, + 0x71a6f024, 0xc232dde7, 0xacbec6a6, 0xe29dfdff, 0x8c11e6be, + 0x3f85cb7d, 0x5109d03c, 0x83dc96ba, 0xed508dfb, 0x5ec4a038, + 0x3048bb79, 0x201f2b75, 0x4e933034, 0xfd071df7, 0x938b06b6, + 0x415e4030, 0x2fd25b71, 0x9c4676b2, 0xf2ca6df3, 0xa2a3ab15, + 0xcc2fb054, 0x7fbb9d97, 0x113786d6, 0xc3e2c050, 0xad6edb11, + 0x1efaf6d2, 0x7076ed93, 0x60217d9f, 0x0ead66de, 0xbd394b1d, + 0xd3b5505c, 0x016016da, 0x6fec0d9b, 0xdc782058, 0xb2f43b19, + 0xfcd70040, 0x925b1b01, 0x21cf36c2, 0x4f432d83, 0x9d966b05, + 0xf31a7044, 0x408e5d87, 0x2e0246c6, 0x3e55d6ca, 0x50d9cd8b, + 0xe34de048, 0x8dc1fb09, 0x5f14bd8f, 0x3198a6ce, 0x820c8b0d, + 0xec80904c, 0x1e4afdbf, 0x70c6e6fe, 0xc352cb3d, 0xadded07c, + 0x7f0b96fa, 0x11878dbb, 0xa213a078, 0xcc9fbb39, 0xdcc82b35, + 0xb2443074, 0x01d01db7, 0x6f5c06f6, 0xbd894070, 0xd3055b31, + 0x609176f2, 0x0e1d6db3, 0x403e56ea, 0x2eb24dab, 0x9d266068, + 0xf3aa7b29, 0x217f3daf, 0x4ff326ee, 0xfc670b2d, 0x92eb106c, + 0x82bc8060, 0xec309b21, 0x5fa4b6e2, 0x3128ada3, 0xe3fdeb25, + 0x8d71f064, 0x3ee5dda7, 0x5069c6e6, 0x9e36506b, 0xf0ba4b2a, + 0x432e66e9, 0x2da27da8, 0xff773b2e, 0x91fb206f, 0x226f0dac, + 0x4ce316ed, 0x5cb486e1, 0x32389da0, 0x81acb063, 0xef20ab22, + 0x3df5eda4, 0x5379f6e5, 0xe0eddb26, 0x8e61c067, 0xc042fb3e, + 0xaecee07f, 0x1d5acdbc, 0x73d6d6fd, 0xa103907b, 0xcf8f8b3a, + 0x7c1ba6f9, 0x1297bdb8, 0x02c02db4, 0x6c4c36f5, 0xdfd81b36, + 0xb1540077, 0x638146f1, 0x0d0d5db0, 0xbe997073, 0xd0156b32, + 0x22df06c1, 0x4c531d80, 0xffc73043, 0x914b2b02, 0x439e6d84, + 0x2d1276c5, 0x9e865b06, 0xf00a4047, 0xe05dd04b, 0x8ed1cb0a, + 0x3d45e6c9, 0x53c9fd88, 0x811cbb0e, 0xef90a04f, 0x5c048d8c, + 0x328896cd, 0x7cabad94, 0x1227b6d5, 0xa1b39b16, 0xcf3f8057, + 0x1deac6d1, 0x7366dd90, 0xc0f2f053, 0xae7eeb12, 0xbe297b1e, + 0xd0a5605f, 0x63314d9c, 0x0dbd56dd, 0xdf68105b, 0xb1e40b1a, + 0x027026d9, 0x6cfc3d98, 0x3c95fb7e, 0x5219e03f, 0xe18dcdfc, + 0x8f01d6bd, 0x5dd4903b, 0x33588b7a, 0x80cca6b9, 0xee40bdf8, + 0xfe172df4, 0x909b36b5, 0x230f1b76, 0x4d830037, 0x9f5646b1, + 0xf1da5df0, 0x424e7033, 0x2cc26b72, 0x62e1502b, 0x0c6d4b6a, + 0xbff966a9, 0xd1757de8, 0x03a03b6e, 0x6d2c202f, 0xdeb80dec, + 0xb03416ad, 0xa06386a1, 0xceef9de0, 0x7d7bb023, 0x13f7ab62, + 0xc122ede4, 0xafaef6a5, 0x1c3adb66, 0x72b6c027, 0x807cadd4, + 0xeef0b695, 0x5d649b56, 0x33e88017, 0xe13dc691, 0x8fb1ddd0, + 0x3c25f013, 0x52a9eb52, 0x42fe7b5e, 0x2c72601f, 0x9fe64ddc, + 0xf16a569d, 0x23bf101b, 0x4d330b5a, 0xfea72699, 0x902b3dd8, + 0xde080681, 0xb0841dc0, 0x03103003, 0x6d9c2b42, 0xbf496dc4, + 0xd1c57685, 0x62515b46, 0x0cdd4007, 0x1c8ad00b, 0x7206cb4a, + 0xc192e689, 0xaf1efdc8, 0x7dcbbb4e, 0x1347a00f, 0xa0d38dcc, + 0xce5f968d}, + {0x00000000, 0xe71da697, 0x154a4b6f, 0xf257edf8, 0x2a9496de, + 0xcd893049, 0x3fdeddb1, 0xd8c37b26, 0x55292dbc, 0xb2348b2b, + 0x406366d3, 0xa77ec044, 0x7fbdbb62, 0x98a01df5, 0x6af7f00d, + 0x8dea569a, 0xaa525b78, 0x4d4ffdef, 0xbf181017, 0x5805b680, + 0x80c6cda6, 0x67db6b31, 0x958c86c9, 0x7291205e, 0xff7b76c4, + 0x1866d053, 0xea313dab, 0x0d2c9b3c, 0xd5efe01a, 0x32f2468d, + 0xc0a5ab75, 0x27b80de2, 0x8fd5b0b1, 0x68c81626, 0x9a9ffbde, + 0x7d825d49, 0xa541266f, 0x425c80f8, 0xb00b6d00, 0x5716cb97, + 0xdafc9d0d, 0x3de13b9a, 0xcfb6d662, 0x28ab70f5, 0xf0680bd3, + 0x1775ad44, 0xe52240bc, 0x023fe62b, 0x2587ebc9, 0xc29a4d5e, + 0x30cda0a6, 0xd7d00631, 0x0f137d17, 0xe80edb80, 0x1a593678, + 0xfd4490ef, 0x70aec675, 0x97b360e2, 0x65e48d1a, 0x82f92b8d, + 0x5a3a50ab, 0xbd27f63c, 0x4f701bc4, 0xa86dbd53, 0xc4da6723, + 0x23c7c1b4, 0xd1902c4c, 0x368d8adb, 0xee4ef1fd, 0x0953576a, + 0xfb04ba92, 0x1c191c05, 0x91f34a9f, 0x76eeec08, 0x84b901f0, + 0x63a4a767, 0xbb67dc41, 0x5c7a7ad6, 0xae2d972e, 0x493031b9, + 0x6e883c5b, 0x89959acc, 0x7bc27734, 0x9cdfd1a3, 0x441caa85, + 0xa3010c12, 0x5156e1ea, 0xb64b477d, 0x3ba111e7, 0xdcbcb770, + 0x2eeb5a88, 0xc9f6fc1f, 0x11358739, 0xf62821ae, 0x047fcc56, + 0xe3626ac1, 0x4b0fd792, 0xac127105, 0x5e459cfd, 0xb9583a6a, + 0x619b414c, 0x8686e7db, 0x74d10a23, 0x93ccacb4, 0x1e26fa2e, + 0xf93b5cb9, 0x0b6cb141, 0xec7117d6, 0x34b26cf0, 0xd3afca67, + 0x21f8279f, 0xc6e58108, 0xe15d8cea, 0x06402a7d, 0xf417c785, + 0x130a6112, 0xcbc91a34, 0x2cd4bca3, 0xde83515b, 0x399ef7cc, + 0xb474a156, 0x536907c1, 0xa13eea39, 0x46234cae, 0x9ee03788, + 0x79fd911f, 0x8baa7ce7, 0x6cb7da70, 0x52c5c807, 0xb5d86e90, + 0x478f8368, 0xa09225ff, 0x78515ed9, 0x9f4cf84e, 0x6d1b15b6, + 0x8a06b321, 0x07ece5bb, 0xe0f1432c, 0x12a6aed4, 0xf5bb0843, + 0x2d787365, 0xca65d5f2, 0x3832380a, 0xdf2f9e9d, 0xf897937f, + 0x1f8a35e8, 0xedddd810, 0x0ac07e87, 0xd20305a1, 0x351ea336, + 0xc7494ece, 0x2054e859, 0xadbebec3, 0x4aa31854, 0xb8f4f5ac, + 0x5fe9533b, 0x872a281d, 0x60378e8a, 0x92606372, 0x757dc5e5, + 0xdd1078b6, 0x3a0dde21, 0xc85a33d9, 0x2f47954e, 0xf784ee68, + 0x109948ff, 0xe2cea507, 0x05d30390, 0x8839550a, 0x6f24f39d, + 0x9d731e65, 0x7a6eb8f2, 0xa2adc3d4, 0x45b06543, 0xb7e788bb, + 0x50fa2e2c, 0x774223ce, 0x905f8559, 0x620868a1, 0x8515ce36, + 0x5dd6b510, 0xbacb1387, 0x489cfe7f, 0xaf8158e8, 0x226b0e72, + 0xc576a8e5, 0x3721451d, 0xd03ce38a, 0x08ff98ac, 0xefe23e3b, + 0x1db5d3c3, 0xfaa87554, 0x961faf24, 0x710209b3, 0x8355e44b, + 0x644842dc, 0xbc8b39fa, 0x5b969f6d, 0xa9c17295, 0x4edcd402, + 0xc3368298, 0x242b240f, 0xd67cc9f7, 0x31616f60, 0xe9a21446, + 0x0ebfb2d1, 0xfce85f29, 0x1bf5f9be, 0x3c4df45c, 0xdb5052cb, + 0x2907bf33, 0xce1a19a4, 0x16d96282, 0xf1c4c415, 0x039329ed, + 0xe48e8f7a, 0x6964d9e0, 0x8e797f77, 0x7c2e928f, 0x9b333418, + 0x43f04f3e, 0xa4ede9a9, 0x56ba0451, 0xb1a7a2c6, 0x19ca1f95, + 0xfed7b902, 0x0c8054fa, 0xeb9df26d, 0x335e894b, 0xd4432fdc, + 0x2614c224, 0xc10964b3, 0x4ce33229, 0xabfe94be, 0x59a97946, + 0xbeb4dfd1, 0x6677a4f7, 0x816a0260, 0x733def98, 0x9420490f, + 0xb39844ed, 0x5485e27a, 0xa6d20f82, 0x41cfa915, 0x990cd233, + 0x7e1174a4, 0x8c46995c, 0x6b5b3fcb, 0xe6b16951, 0x01accfc6, + 0xf3fb223e, 0x14e684a9, 0xcc25ff8f, 0x2b385918, 0xd96fb4e0, + 0x3e721277}, + {0x00000000, 0xa58b900e, 0x9066265d, 0x35edb653, 0xfbbd4afb, + 0x5e36daf5, 0x6bdb6ca6, 0xce50fca8, 0x2c0b93b7, 0x898003b9, + 0xbc6db5ea, 0x19e625e4, 0xd7b6d94c, 0x723d4942, 0x47d0ff11, + 0xe25b6f1f, 0x5817276e, 0xfd9cb760, 0xc8710133, 0x6dfa913d, + 0xa3aa6d95, 0x0621fd9b, 0x33cc4bc8, 0x9647dbc6, 0x741cb4d9, + 0xd19724d7, 0xe47a9284, 0x41f1028a, 0x8fa1fe22, 0x2a2a6e2c, + 0x1fc7d87f, 0xba4c4871, 0xb02e4edc, 0x15a5ded2, 0x20486881, + 0x85c3f88f, 0x4b930427, 0xee189429, 0xdbf5227a, 0x7e7eb274, + 0x9c25dd6b, 0x39ae4d65, 0x0c43fb36, 0xa9c86b38, 0x67989790, + 0xc213079e, 0xf7feb1cd, 0x527521c3, 0xe83969b2, 0x4db2f9bc, + 0x785f4fef, 0xddd4dfe1, 0x13842349, 0xb60fb347, 0x83e20514, + 0x2669951a, 0xc432fa05, 0x61b96a0b, 0x5454dc58, 0xf1df4c56, + 0x3f8fb0fe, 0x9a0420f0, 0xafe996a3, 0x0a6206ad, 0xbb2d9bf9, + 0x1ea60bf7, 0x2b4bbda4, 0x8ec02daa, 0x4090d102, 0xe51b410c, + 0xd0f6f75f, 0x757d6751, 0x9726084e, 0x32ad9840, 0x07402e13, + 0xa2cbbe1d, 0x6c9b42b5, 0xc910d2bb, 0xfcfd64e8, 0x5976f4e6, + 0xe33abc97, 0x46b12c99, 0x735c9aca, 0xd6d70ac4, 0x1887f66c, + 0xbd0c6662, 0x88e1d031, 0x2d6a403f, 0xcf312f20, 0x6ababf2e, + 0x5f57097d, 0xfadc9973, 0x348c65db, 0x9107f5d5, 0xa4ea4386, + 0x0161d388, 0x0b03d525, 0xae88452b, 0x9b65f378, 0x3eee6376, + 0xf0be9fde, 0x55350fd0, 0x60d8b983, 0xc553298d, 0x27084692, + 0x8283d69c, 0xb76e60cf, 0x12e5f0c1, 0xdcb50c69, 0x793e9c67, + 0x4cd32a34, 0xe958ba3a, 0x5314f24b, 0xf69f6245, 0xc372d416, + 0x66f94418, 0xa8a9b8b0, 0x0d2228be, 0x38cf9eed, 0x9d440ee3, + 0x7f1f61fc, 0xda94f1f2, 0xef7947a1, 0x4af2d7af, 0x84a22b07, + 0x2129bb09, 0x14c40d5a, 0xb14f9d54, 0xad2a31b3, 0x08a1a1bd, + 0x3d4c17ee, 0x98c787e0, 0x56977b48, 0xf31ceb46, 0xc6f15d15, + 0x637acd1b, 0x8121a204, 0x24aa320a, 0x11478459, 0xb4cc1457, + 0x7a9ce8ff, 0xdf1778f1, 0xeafacea2, 0x4f715eac, 0xf53d16dd, + 0x50b686d3, 0x655b3080, 0xc0d0a08e, 0x0e805c26, 0xab0bcc28, + 0x9ee67a7b, 0x3b6dea75, 0xd936856a, 0x7cbd1564, 0x4950a337, + 0xecdb3339, 0x228bcf91, 0x87005f9f, 0xb2ede9cc, 0x176679c2, + 0x1d047f6f, 0xb88fef61, 0x8d625932, 0x28e9c93c, 0xe6b93594, + 0x4332a59a, 0x76df13c9, 0xd35483c7, 0x310fecd8, 0x94847cd6, + 0xa169ca85, 0x04e25a8b, 0xcab2a623, 0x6f39362d, 0x5ad4807e, + 0xff5f1070, 0x45135801, 0xe098c80f, 0xd5757e5c, 0x70feee52, + 0xbeae12fa, 0x1b2582f4, 0x2ec834a7, 0x8b43a4a9, 0x6918cbb6, + 0xcc935bb8, 0xf97eedeb, 0x5cf57de5, 0x92a5814d, 0x372e1143, + 0x02c3a710, 0xa748371e, 0x1607aa4a, 0xb38c3a44, 0x86618c17, + 0x23ea1c19, 0xedbae0b1, 0x483170bf, 0x7ddcc6ec, 0xd85756e2, + 0x3a0c39fd, 0x9f87a9f3, 0xaa6a1fa0, 0x0fe18fae, 0xc1b17306, + 0x643ae308, 0x51d7555b, 0xf45cc555, 0x4e108d24, 0xeb9b1d2a, + 0xde76ab79, 0x7bfd3b77, 0xb5adc7df, 0x102657d1, 0x25cbe182, + 0x8040718c, 0x621b1e93, 0xc7908e9d, 0xf27d38ce, 0x57f6a8c0, + 0x99a65468, 0x3c2dc466, 0x09c07235, 0xac4be23b, 0xa629e496, + 0x03a27498, 0x364fc2cb, 0x93c452c5, 0x5d94ae6d, 0xf81f3e63, + 0xcdf28830, 0x6879183e, 0x8a227721, 0x2fa9e72f, 0x1a44517c, + 0xbfcfc172, 0x719f3dda, 0xd414add4, 0xe1f91b87, 0x44728b89, + 0xfe3ec3f8, 0x5bb553f6, 0x6e58e5a5, 0xcbd375ab, 0x05838903, + 0xa008190d, 0x95e5af5e, 0x306e3f50, 0xd235504f, 0x77bec041, + 0x42537612, 0xe7d8e61c, 0x29881ab4, 0x8c038aba, 0xb9ee3ce9, + 0x1c65ace7}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0x0e908ba500000000, 0x5d26669000000000, + 0x53b6ed3500000000, 0xfb4abdfb00000000, 0xf5da365e00000000, + 0xa66cdb6b00000000, 0xa8fc50ce00000000, 0xb7930b2c00000000, + 0xb903808900000000, 0xeab56dbc00000000, 0xe425e61900000000, + 0x4cd9b6d700000000, 0x42493d7200000000, 0x11ffd04700000000, + 0x1f6f5be200000000, 0x6e27175800000000, 0x60b79cfd00000000, + 0x330171c800000000, 0x3d91fa6d00000000, 0x956daaa300000000, + 0x9bfd210600000000, 0xc84bcc3300000000, 0xc6db479600000000, + 0xd9b41c7400000000, 0xd72497d100000000, 0x84927ae400000000, + 0x8a02f14100000000, 0x22fea18f00000000, 0x2c6e2a2a00000000, + 0x7fd8c71f00000000, 0x71484cba00000000, 0xdc4e2eb000000000, + 0xd2dea51500000000, 0x8168482000000000, 0x8ff8c38500000000, + 0x2704934b00000000, 0x299418ee00000000, 0x7a22f5db00000000, + 0x74b27e7e00000000, 0x6bdd259c00000000, 0x654dae3900000000, + 0x36fb430c00000000, 0x386bc8a900000000, 0x9097986700000000, + 0x9e0713c200000000, 0xcdb1fef700000000, 0xc321755200000000, + 0xb26939e800000000, 0xbcf9b24d00000000, 0xef4f5f7800000000, + 0xe1dfd4dd00000000, 0x4923841300000000, 0x47b30fb600000000, + 0x1405e28300000000, 0x1a95692600000000, 0x05fa32c400000000, + 0x0b6ab96100000000, 0x58dc545400000000, 0x564cdff100000000, + 0xfeb08f3f00000000, 0xf020049a00000000, 0xa396e9af00000000, + 0xad06620a00000000, 0xf99b2dbb00000000, 0xf70ba61e00000000, + 0xa4bd4b2b00000000, 0xaa2dc08e00000000, 0x02d1904000000000, + 0x0c411be500000000, 0x5ff7f6d000000000, 0x51677d7500000000, + 0x4e08269700000000, 0x4098ad3200000000, 0x132e400700000000, + 0x1dbecba200000000, 0xb5429b6c00000000, 0xbbd210c900000000, + 0xe864fdfc00000000, 0xe6f4765900000000, 0x97bc3ae300000000, + 0x992cb14600000000, 0xca9a5c7300000000, 0xc40ad7d600000000, + 0x6cf6871800000000, 0x62660cbd00000000, 0x31d0e18800000000, + 0x3f406a2d00000000, 0x202f31cf00000000, 0x2ebfba6a00000000, + 0x7d09575f00000000, 0x7399dcfa00000000, 0xdb658c3400000000, + 0xd5f5079100000000, 0x8643eaa400000000, 0x88d3610100000000, + 0x25d5030b00000000, 0x2b4588ae00000000, 0x78f3659b00000000, + 0x7663ee3e00000000, 0xde9fbef000000000, 0xd00f355500000000, + 0x83b9d86000000000, 0x8d2953c500000000, 0x9246082700000000, + 0x9cd6838200000000, 0xcf606eb700000000, 0xc1f0e51200000000, + 0x690cb5dc00000000, 0x679c3e7900000000, 0x342ad34c00000000, + 0x3aba58e900000000, 0x4bf2145300000000, 0x45629ff600000000, + 0x16d472c300000000, 0x1844f96600000000, 0xb0b8a9a800000000, + 0xbe28220d00000000, 0xed9ecf3800000000, 0xe30e449d00000000, + 0xfc611f7f00000000, 0xf2f194da00000000, 0xa14779ef00000000, + 0xafd7f24a00000000, 0x072ba28400000000, 0x09bb292100000000, + 0x5a0dc41400000000, 0x549d4fb100000000, 0xb3312aad00000000, + 0xbda1a10800000000, 0xee174c3d00000000, 0xe087c79800000000, + 0x487b975600000000, 0x46eb1cf300000000, 0x155df1c600000000, + 0x1bcd7a6300000000, 0x04a2218100000000, 0x0a32aa2400000000, + 0x5984471100000000, 0x5714ccb400000000, 0xffe89c7a00000000, + 0xf17817df00000000, 0xa2cefaea00000000, 0xac5e714f00000000, + 0xdd163df500000000, 0xd386b65000000000, 0x80305b6500000000, + 0x8ea0d0c000000000, 0x265c800e00000000, 0x28cc0bab00000000, + 0x7b7ae69e00000000, 0x75ea6d3b00000000, 0x6a8536d900000000, + 0x6415bd7c00000000, 0x37a3504900000000, 0x3933dbec00000000, + 0x91cf8b2200000000, 0x9f5f008700000000, 0xcce9edb200000000, + 0xc279661700000000, 0x6f7f041d00000000, 0x61ef8fb800000000, + 0x3259628d00000000, 0x3cc9e92800000000, 0x9435b9e600000000, + 0x9aa5324300000000, 0xc913df7600000000, 0xc78354d300000000, + 0xd8ec0f3100000000, 0xd67c849400000000, 0x85ca69a100000000, + 0x8b5ae20400000000, 0x23a6b2ca00000000, 0x2d36396f00000000, + 0x7e80d45a00000000, 0x70105fff00000000, 0x0158134500000000, + 0x0fc898e000000000, 0x5c7e75d500000000, 0x52eefe7000000000, + 0xfa12aebe00000000, 0xf482251b00000000, 0xa734c82e00000000, + 0xa9a4438b00000000, 0xb6cb186900000000, 0xb85b93cc00000000, + 0xebed7ef900000000, 0xe57df55c00000000, 0x4d81a59200000000, + 0x43112e3700000000, 0x10a7c30200000000, 0x1e3748a700000000, + 0x4aaa071600000000, 0x443a8cb300000000, 0x178c618600000000, + 0x191cea2300000000, 0xb1e0baed00000000, 0xbf70314800000000, + 0xecc6dc7d00000000, 0xe25657d800000000, 0xfd390c3a00000000, + 0xf3a9879f00000000, 0xa01f6aaa00000000, 0xae8fe10f00000000, + 0x0673b1c100000000, 0x08e33a6400000000, 0x5b55d75100000000, + 0x55c55cf400000000, 0x248d104e00000000, 0x2a1d9beb00000000, + 0x79ab76de00000000, 0x773bfd7b00000000, 0xdfc7adb500000000, + 0xd157261000000000, 0x82e1cb2500000000, 0x8c71408000000000, + 0x931e1b6200000000, 0x9d8e90c700000000, 0xce387df200000000, + 0xc0a8f65700000000, 0x6854a69900000000, 0x66c42d3c00000000, + 0x3572c00900000000, 0x3be24bac00000000, 0x96e429a600000000, + 0x9874a20300000000, 0xcbc24f3600000000, 0xc552c49300000000, + 0x6dae945d00000000, 0x633e1ff800000000, 0x3088f2cd00000000, + 0x3e18796800000000, 0x2177228a00000000, 0x2fe7a92f00000000, + 0x7c51441a00000000, 0x72c1cfbf00000000, 0xda3d9f7100000000, + 0xd4ad14d400000000, 0x871bf9e100000000, 0x898b724400000000, + 0xf8c33efe00000000, 0xf653b55b00000000, 0xa5e5586e00000000, + 0xab75d3cb00000000, 0x0389830500000000, 0x0d1908a000000000, + 0x5eafe59500000000, 0x503f6e3000000000, 0x4f5035d200000000, + 0x41c0be7700000000, 0x1276534200000000, 0x1ce6d8e700000000, + 0xb41a882900000000, 0xba8a038c00000000, 0xe93ceeb900000000, + 0xe7ac651c00000000}, + {0x0000000000000000, 0x97a61de700000000, 0x6f4b4a1500000000, + 0xf8ed57f200000000, 0xde96942a00000000, 0x493089cd00000000, + 0xb1ddde3f00000000, 0x267bc3d800000000, 0xbc2d295500000000, + 0x2b8b34b200000000, 0xd366634000000000, 0x44c07ea700000000, + 0x62bbbd7f00000000, 0xf51da09800000000, 0x0df0f76a00000000, + 0x9a56ea8d00000000, 0x785b52aa00000000, 0xeffd4f4d00000000, + 0x171018bf00000000, 0x80b6055800000000, 0xa6cdc68000000000, + 0x316bdb6700000000, 0xc9868c9500000000, 0x5e20917200000000, + 0xc4767bff00000000, 0x53d0661800000000, 0xab3d31ea00000000, + 0x3c9b2c0d00000000, 0x1ae0efd500000000, 0x8d46f23200000000, + 0x75aba5c000000000, 0xe20db82700000000, 0xb1b0d58f00000000, + 0x2616c86800000000, 0xdefb9f9a00000000, 0x495d827d00000000, + 0x6f2641a500000000, 0xf8805c4200000000, 0x006d0bb000000000, + 0x97cb165700000000, 0x0d9dfcda00000000, 0x9a3be13d00000000, + 0x62d6b6cf00000000, 0xf570ab2800000000, 0xd30b68f000000000, + 0x44ad751700000000, 0xbc4022e500000000, 0x2be63f0200000000, + 0xc9eb872500000000, 0x5e4d9ac200000000, 0xa6a0cd3000000000, + 0x3106d0d700000000, 0x177d130f00000000, 0x80db0ee800000000, + 0x7836591a00000000, 0xef9044fd00000000, 0x75c6ae7000000000, + 0xe260b39700000000, 0x1a8de46500000000, 0x8d2bf98200000000, + 0xab503a5a00000000, 0x3cf627bd00000000, 0xc41b704f00000000, + 0x53bd6da800000000, 0x2367dac400000000, 0xb4c1c72300000000, + 0x4c2c90d100000000, 0xdb8a8d3600000000, 0xfdf14eee00000000, + 0x6a57530900000000, 0x92ba04fb00000000, 0x051c191c00000000, + 0x9f4af39100000000, 0x08ecee7600000000, 0xf001b98400000000, + 0x67a7a46300000000, 0x41dc67bb00000000, 0xd67a7a5c00000000, + 0x2e972dae00000000, 0xb931304900000000, 0x5b3c886e00000000, + 0xcc9a958900000000, 0x3477c27b00000000, 0xa3d1df9c00000000, + 0x85aa1c4400000000, 0x120c01a300000000, 0xeae1565100000000, + 0x7d474bb600000000, 0xe711a13b00000000, 0x70b7bcdc00000000, + 0x885aeb2e00000000, 0x1ffcf6c900000000, 0x3987351100000000, + 0xae2128f600000000, 0x56cc7f0400000000, 0xc16a62e300000000, + 0x92d70f4b00000000, 0x057112ac00000000, 0xfd9c455e00000000, + 0x6a3a58b900000000, 0x4c419b6100000000, 0xdbe7868600000000, + 0x230ad17400000000, 0xb4accc9300000000, 0x2efa261e00000000, + 0xb95c3bf900000000, 0x41b16c0b00000000, 0xd61771ec00000000, + 0xf06cb23400000000, 0x67caafd300000000, 0x9f27f82100000000, + 0x0881e5c600000000, 0xea8c5de100000000, 0x7d2a400600000000, + 0x85c717f400000000, 0x12610a1300000000, 0x341ac9cb00000000, + 0xa3bcd42c00000000, 0x5b5183de00000000, 0xccf79e3900000000, + 0x56a174b400000000, 0xc107695300000000, 0x39ea3ea100000000, + 0xae4c234600000000, 0x8837e09e00000000, 0x1f91fd7900000000, + 0xe77caa8b00000000, 0x70dab76c00000000, 0x07c8c55200000000, + 0x906ed8b500000000, 0x68838f4700000000, 0xff2592a000000000, + 0xd95e517800000000, 0x4ef84c9f00000000, 0xb6151b6d00000000, + 0x21b3068a00000000, 0xbbe5ec0700000000, 0x2c43f1e000000000, + 0xd4aea61200000000, 0x4308bbf500000000, 0x6573782d00000000, + 0xf2d565ca00000000, 0x0a38323800000000, 0x9d9e2fdf00000000, + 0x7f9397f800000000, 0xe8358a1f00000000, 0x10d8dded00000000, + 0x877ec00a00000000, 0xa10503d200000000, 0x36a31e3500000000, + 0xce4e49c700000000, 0x59e8542000000000, 0xc3bebead00000000, + 0x5418a34a00000000, 0xacf5f4b800000000, 0x3b53e95f00000000, + 0x1d282a8700000000, 0x8a8e376000000000, 0x7263609200000000, + 0xe5c57d7500000000, 0xb67810dd00000000, 0x21de0d3a00000000, + 0xd9335ac800000000, 0x4e95472f00000000, 0x68ee84f700000000, + 0xff48991000000000, 0x07a5cee200000000, 0x9003d30500000000, + 0x0a55398800000000, 0x9df3246f00000000, 0x651e739d00000000, + 0xf2b86e7a00000000, 0xd4c3ada200000000, 0x4365b04500000000, + 0xbb88e7b700000000, 0x2c2efa5000000000, 0xce23427700000000, + 0x59855f9000000000, 0xa168086200000000, 0x36ce158500000000, + 0x10b5d65d00000000, 0x8713cbba00000000, 0x7ffe9c4800000000, + 0xe85881af00000000, 0x720e6b2200000000, 0xe5a876c500000000, + 0x1d45213700000000, 0x8ae33cd000000000, 0xac98ff0800000000, + 0x3b3ee2ef00000000, 0xc3d3b51d00000000, 0x5475a8fa00000000, + 0x24af1f9600000000, 0xb309027100000000, 0x4be4558300000000, + 0xdc42486400000000, 0xfa398bbc00000000, 0x6d9f965b00000000, + 0x9572c1a900000000, 0x02d4dc4e00000000, 0x988236c300000000, + 0x0f242b2400000000, 0xf7c97cd600000000, 0x606f613100000000, + 0x4614a2e900000000, 0xd1b2bf0e00000000, 0x295fe8fc00000000, + 0xbef9f51b00000000, 0x5cf44d3c00000000, 0xcb5250db00000000, + 0x33bf072900000000, 0xa4191ace00000000, 0x8262d91600000000, + 0x15c4c4f100000000, 0xed29930300000000, 0x7a8f8ee400000000, + 0xe0d9646900000000, 0x777f798e00000000, 0x8f922e7c00000000, + 0x1834339b00000000, 0x3e4ff04300000000, 0xa9e9eda400000000, + 0x5104ba5600000000, 0xc6a2a7b100000000, 0x951fca1900000000, + 0x02b9d7fe00000000, 0xfa54800c00000000, 0x6df29deb00000000, + 0x4b895e3300000000, 0xdc2f43d400000000, 0x24c2142600000000, + 0xb36409c100000000, 0x2932e34c00000000, 0xbe94feab00000000, + 0x4679a95900000000, 0xd1dfb4be00000000, 0xf7a4776600000000, + 0x60026a8100000000, 0x98ef3d7300000000, 0x0f49209400000000, + 0xed4498b300000000, 0x7ae2855400000000, 0x820fd2a600000000, + 0x15a9cf4100000000, 0x33d20c9900000000, 0xa474117e00000000, + 0x5c99468c00000000, 0xcb3f5b6b00000000, 0x5169b1e600000000, + 0xc6cfac0100000000, 0x3e22fbf300000000, 0xa984e61400000000, + 0x8fff25cc00000000, 0x1859382b00000000, 0xe0b46fd900000000, + 0x7712723e00000000}, + {0x0000000000000000, 0x411b8c6e00000000, 0x823618dd00000000, + 0xc32d94b300000000, 0x456b416100000000, 0x0470cd0f00000000, + 0xc75d59bc00000000, 0x8646d5d200000000, 0x8ad682c200000000, + 0xcbcd0eac00000000, 0x08e09a1f00000000, 0x49fb167100000000, + 0xcfbdc3a300000000, 0x8ea64fcd00000000, 0x4d8bdb7e00000000, + 0x0c90571000000000, 0x55ab745e00000000, 0x14b0f83000000000, + 0xd79d6c8300000000, 0x9686e0ed00000000, 0x10c0353f00000000, + 0x51dbb95100000000, 0x92f62de200000000, 0xd3eda18c00000000, + 0xdf7df69c00000000, 0x9e667af200000000, 0x5d4bee4100000000, + 0x1c50622f00000000, 0x9a16b7fd00000000, 0xdb0d3b9300000000, + 0x1820af2000000000, 0x593b234e00000000, 0xaa56e9bc00000000, + 0xeb4d65d200000000, 0x2860f16100000000, 0x697b7d0f00000000, + 0xef3da8dd00000000, 0xae2624b300000000, 0x6d0bb00000000000, + 0x2c103c6e00000000, 0x20806b7e00000000, 0x619be71000000000, + 0xa2b673a300000000, 0xe3adffcd00000000, 0x65eb2a1f00000000, + 0x24f0a67100000000, 0xe7dd32c200000000, 0xa6c6beac00000000, + 0xfffd9de200000000, 0xbee6118c00000000, 0x7dcb853f00000000, + 0x3cd0095100000000, 0xba96dc8300000000, 0xfb8d50ed00000000, + 0x38a0c45e00000000, 0x79bb483000000000, 0x752b1f2000000000, + 0x3430934e00000000, 0xf71d07fd00000000, 0xb6068b9300000000, + 0x30405e4100000000, 0x715bd22f00000000, 0xb276469c00000000, + 0xf36dcaf200000000, 0x15aba3a200000000, 0x54b02fcc00000000, + 0x979dbb7f00000000, 0xd686371100000000, 0x50c0e2c300000000, + 0x11db6ead00000000, 0xd2f6fa1e00000000, 0x93ed767000000000, + 0x9f7d216000000000, 0xde66ad0e00000000, 0x1d4b39bd00000000, + 0x5c50b5d300000000, 0xda16600100000000, 0x9b0dec6f00000000, + 0x582078dc00000000, 0x193bf4b200000000, 0x4000d7fc00000000, + 0x011b5b9200000000, 0xc236cf2100000000, 0x832d434f00000000, + 0x056b969d00000000, 0x44701af300000000, 0x875d8e4000000000, + 0xc646022e00000000, 0xcad6553e00000000, 0x8bcdd95000000000, + 0x48e04de300000000, 0x09fbc18d00000000, 0x8fbd145f00000000, + 0xcea6983100000000, 0x0d8b0c8200000000, 0x4c9080ec00000000, + 0xbffd4a1e00000000, 0xfee6c67000000000, 0x3dcb52c300000000, + 0x7cd0dead00000000, 0xfa960b7f00000000, 0xbb8d871100000000, + 0x78a013a200000000, 0x39bb9fcc00000000, 0x352bc8dc00000000, + 0x743044b200000000, 0xb71dd00100000000, 0xf6065c6f00000000, + 0x704089bd00000000, 0x315b05d300000000, 0xf276916000000000, + 0xb36d1d0e00000000, 0xea563e4000000000, 0xab4db22e00000000, + 0x6860269d00000000, 0x297baaf300000000, 0xaf3d7f2100000000, + 0xee26f34f00000000, 0x2d0b67fc00000000, 0x6c10eb9200000000, + 0x6080bc8200000000, 0x219b30ec00000000, 0xe2b6a45f00000000, + 0xa3ad283100000000, 0x25ebfde300000000, 0x64f0718d00000000, + 0xa7dde53e00000000, 0xe6c6695000000000, 0x6b50369e00000000, + 0x2a4bbaf000000000, 0xe9662e4300000000, 0xa87da22d00000000, + 0x2e3b77ff00000000, 0x6f20fb9100000000, 0xac0d6f2200000000, + 0xed16e34c00000000, 0xe186b45c00000000, 0xa09d383200000000, + 0x63b0ac8100000000, 0x22ab20ef00000000, 0xa4edf53d00000000, + 0xe5f6795300000000, 0x26dbede000000000, 0x67c0618e00000000, + 0x3efb42c000000000, 0x7fe0ceae00000000, 0xbccd5a1d00000000, + 0xfdd6d67300000000, 0x7b9003a100000000, 0x3a8b8fcf00000000, + 0xf9a61b7c00000000, 0xb8bd971200000000, 0xb42dc00200000000, + 0xf5364c6c00000000, 0x361bd8df00000000, 0x770054b100000000, + 0xf146816300000000, 0xb05d0d0d00000000, 0x737099be00000000, + 0x326b15d000000000, 0xc106df2200000000, 0x801d534c00000000, + 0x4330c7ff00000000, 0x022b4b9100000000, 0x846d9e4300000000, + 0xc576122d00000000, 0x065b869e00000000, 0x47400af000000000, + 0x4bd05de000000000, 0x0acbd18e00000000, 0xc9e6453d00000000, + 0x88fdc95300000000, 0x0ebb1c8100000000, 0x4fa090ef00000000, + 0x8c8d045c00000000, 0xcd96883200000000, 0x94adab7c00000000, + 0xd5b6271200000000, 0x169bb3a100000000, 0x57803fcf00000000, + 0xd1c6ea1d00000000, 0x90dd667300000000, 0x53f0f2c000000000, + 0x12eb7eae00000000, 0x1e7b29be00000000, 0x5f60a5d000000000, + 0x9c4d316300000000, 0xdd56bd0d00000000, 0x5b1068df00000000, + 0x1a0be4b100000000, 0xd926700200000000, 0x983dfc6c00000000, + 0x7efb953c00000000, 0x3fe0195200000000, 0xfccd8de100000000, + 0xbdd6018f00000000, 0x3b90d45d00000000, 0x7a8b583300000000, + 0xb9a6cc8000000000, 0xf8bd40ee00000000, 0xf42d17fe00000000, + 0xb5369b9000000000, 0x761b0f2300000000, 0x3700834d00000000, + 0xb146569f00000000, 0xf05ddaf100000000, 0x33704e4200000000, + 0x726bc22c00000000, 0x2b50e16200000000, 0x6a4b6d0c00000000, + 0xa966f9bf00000000, 0xe87d75d100000000, 0x6e3ba00300000000, + 0x2f202c6d00000000, 0xec0db8de00000000, 0xad1634b000000000, + 0xa18663a000000000, 0xe09defce00000000, 0x23b07b7d00000000, + 0x62abf71300000000, 0xe4ed22c100000000, 0xa5f6aeaf00000000, + 0x66db3a1c00000000, 0x27c0b67200000000, 0xd4ad7c8000000000, + 0x95b6f0ee00000000, 0x569b645d00000000, 0x1780e83300000000, + 0x91c63de100000000, 0xd0ddb18f00000000, 0x13f0253c00000000, + 0x52eba95200000000, 0x5e7bfe4200000000, 0x1f60722c00000000, + 0xdc4de69f00000000, 0x9d566af100000000, 0x1b10bf2300000000, + 0x5a0b334d00000000, 0x9926a7fe00000000, 0xd83d2b9000000000, + 0x810608de00000000, 0xc01d84b000000000, 0x0330100300000000, + 0x422b9c6d00000000, 0xc46d49bf00000000, 0x8576c5d100000000, + 0x465b516200000000, 0x0740dd0c00000000, 0x0bd08a1c00000000, + 0x4acb067200000000, 0x89e692c100000000, 0xc8fd1eaf00000000, + 0x4ebbcb7d00000000, 0x0fa0471300000000, 0xcc8dd3a000000000, + 0x8d965fce00000000}, + {0x0000000000000000, 0x1dfdb50100000000, 0x3afa6b0300000000, + 0x2707de0200000000, 0x74f4d70600000000, 0x6909620700000000, + 0x4e0ebc0500000000, 0x53f3090400000000, 0xe8e8af0d00000000, + 0xf5151a0c00000000, 0xd212c40e00000000, 0xcfef710f00000000, + 0x9c1c780b00000000, 0x81e1cd0a00000000, 0xa6e6130800000000, + 0xbb1ba60900000000, 0xd0d15f1b00000000, 0xcd2cea1a00000000, + 0xea2b341800000000, 0xf7d6811900000000, 0xa425881d00000000, + 0xb9d83d1c00000000, 0x9edfe31e00000000, 0x8322561f00000000, + 0x3839f01600000000, 0x25c4451700000000, 0x02c39b1500000000, + 0x1f3e2e1400000000, 0x4ccd271000000000, 0x5130921100000000, + 0x76374c1300000000, 0x6bcaf91200000000, 0xa0a3bf3600000000, + 0xbd5e0a3700000000, 0x9a59d43500000000, 0x87a4613400000000, + 0xd457683000000000, 0xc9aadd3100000000, 0xeead033300000000, + 0xf350b63200000000, 0x484b103b00000000, 0x55b6a53a00000000, + 0x72b17b3800000000, 0x6f4cce3900000000, 0x3cbfc73d00000000, + 0x2142723c00000000, 0x0645ac3e00000000, 0x1bb8193f00000000, + 0x7072e02d00000000, 0x6d8f552c00000000, 0x4a888b2e00000000, + 0x57753e2f00000000, 0x0486372b00000000, 0x197b822a00000000, + 0x3e7c5c2800000000, 0x2381e92900000000, 0x989a4f2000000000, + 0x8567fa2100000000, 0xa260242300000000, 0xbf9d912200000000, + 0xec6e982600000000, 0xf1932d2700000000, 0xd694f32500000000, + 0xcb69462400000000, 0x40477f6d00000000, 0x5dbaca6c00000000, + 0x7abd146e00000000, 0x6740a16f00000000, 0x34b3a86b00000000, + 0x294e1d6a00000000, 0x0e49c36800000000, 0x13b4766900000000, + 0xa8afd06000000000, 0xb552656100000000, 0x9255bb6300000000, + 0x8fa80e6200000000, 0xdc5b076600000000, 0xc1a6b26700000000, + 0xe6a16c6500000000, 0xfb5cd96400000000, 0x9096207600000000, + 0x8d6b957700000000, 0xaa6c4b7500000000, 0xb791fe7400000000, + 0xe462f77000000000, 0xf99f427100000000, 0xde989c7300000000, + 0xc365297200000000, 0x787e8f7b00000000, 0x65833a7a00000000, + 0x4284e47800000000, 0x5f79517900000000, 0x0c8a587d00000000, + 0x1177ed7c00000000, 0x3670337e00000000, 0x2b8d867f00000000, + 0xe0e4c05b00000000, 0xfd19755a00000000, 0xda1eab5800000000, + 0xc7e31e5900000000, 0x9410175d00000000, 0x89eda25c00000000, + 0xaeea7c5e00000000, 0xb317c95f00000000, 0x080c6f5600000000, + 0x15f1da5700000000, 0x32f6045500000000, 0x2f0bb15400000000, + 0x7cf8b85000000000, 0x61050d5100000000, 0x4602d35300000000, + 0x5bff665200000000, 0x30359f4000000000, 0x2dc82a4100000000, + 0x0acff44300000000, 0x1732414200000000, 0x44c1484600000000, + 0x593cfd4700000000, 0x7e3b234500000000, 0x63c6964400000000, + 0xd8dd304d00000000, 0xc520854c00000000, 0xe2275b4e00000000, + 0xffdaee4f00000000, 0xac29e74b00000000, 0xb1d4524a00000000, + 0x96d38c4800000000, 0x8b2e394900000000, 0x808efeda00000000, + 0x9d734bdb00000000, 0xba7495d900000000, 0xa78920d800000000, + 0xf47a29dc00000000, 0xe9879cdd00000000, 0xce8042df00000000, + 0xd37df7de00000000, 0x686651d700000000, 0x759be4d600000000, + 0x529c3ad400000000, 0x4f618fd500000000, 0x1c9286d100000000, + 0x016f33d000000000, 0x2668edd200000000, 0x3b9558d300000000, + 0x505fa1c100000000, 0x4da214c000000000, 0x6aa5cac200000000, + 0x77587fc300000000, 0x24ab76c700000000, 0x3956c3c600000000, + 0x1e511dc400000000, 0x03aca8c500000000, 0xb8b70ecc00000000, + 0xa54abbcd00000000, 0x824d65cf00000000, 0x9fb0d0ce00000000, + 0xcc43d9ca00000000, 0xd1be6ccb00000000, 0xf6b9b2c900000000, + 0xeb4407c800000000, 0x202d41ec00000000, 0x3dd0f4ed00000000, + 0x1ad72aef00000000, 0x072a9fee00000000, 0x54d996ea00000000, + 0x492423eb00000000, 0x6e23fde900000000, 0x73de48e800000000, + 0xc8c5eee100000000, 0xd5385be000000000, 0xf23f85e200000000, + 0xefc230e300000000, 0xbc3139e700000000, 0xa1cc8ce600000000, + 0x86cb52e400000000, 0x9b36e7e500000000, 0xf0fc1ef700000000, + 0xed01abf600000000, 0xca0675f400000000, 0xd7fbc0f500000000, + 0x8408c9f100000000, 0x99f57cf000000000, 0xbef2a2f200000000, + 0xa30f17f300000000, 0x1814b1fa00000000, 0x05e904fb00000000, + 0x22eedaf900000000, 0x3f136ff800000000, 0x6ce066fc00000000, + 0x711dd3fd00000000, 0x561a0dff00000000, 0x4be7b8fe00000000, + 0xc0c981b700000000, 0xdd3434b600000000, 0xfa33eab400000000, + 0xe7ce5fb500000000, 0xb43d56b100000000, 0xa9c0e3b000000000, + 0x8ec73db200000000, 0x933a88b300000000, 0x28212eba00000000, + 0x35dc9bbb00000000, 0x12db45b900000000, 0x0f26f0b800000000, + 0x5cd5f9bc00000000, 0x41284cbd00000000, 0x662f92bf00000000, + 0x7bd227be00000000, 0x1018deac00000000, 0x0de56bad00000000, + 0x2ae2b5af00000000, 0x371f00ae00000000, 0x64ec09aa00000000, + 0x7911bcab00000000, 0x5e1662a900000000, 0x43ebd7a800000000, + 0xf8f071a100000000, 0xe50dc4a000000000, 0xc20a1aa200000000, + 0xdff7afa300000000, 0x8c04a6a700000000, 0x91f913a600000000, + 0xb6fecda400000000, 0xab0378a500000000, 0x606a3e8100000000, + 0x7d978b8000000000, 0x5a90558200000000, 0x476de08300000000, + 0x149ee98700000000, 0x09635c8600000000, 0x2e64828400000000, + 0x3399378500000000, 0x8882918c00000000, 0x957f248d00000000, + 0xb278fa8f00000000, 0xaf854f8e00000000, 0xfc76468a00000000, + 0xe18bf38b00000000, 0xc68c2d8900000000, 0xdb71988800000000, + 0xb0bb619a00000000, 0xad46d49b00000000, 0x8a410a9900000000, + 0x97bcbf9800000000, 0xc44fb69c00000000, 0xd9b2039d00000000, + 0xfeb5dd9f00000000, 0xe348689e00000000, 0x5853ce9700000000, + 0x45ae7b9600000000, 0x62a9a59400000000, 0x7f54109500000000, + 0x2ca7199100000000, 0x315aac9000000000, 0x165d729200000000, + 0x0ba0c79300000000}, + {0x0000000000000000, 0x24d9076300000000, 0x48b20fc600000000, + 0x6c6b08a500000000, 0xd1626e5700000000, 0xf5bb693400000000, + 0x99d0619100000000, 0xbd0966f200000000, 0xa2c5dcae00000000, + 0x861cdbcd00000000, 0xea77d36800000000, 0xceaed40b00000000, + 0x73a7b2f900000000, 0x577eb59a00000000, 0x3b15bd3f00000000, + 0x1fccba5c00000000, 0x058dc88600000000, 0x2154cfe500000000, + 0x4d3fc74000000000, 0x69e6c02300000000, 0xd4efa6d100000000, + 0xf036a1b200000000, 0x9c5da91700000000, 0xb884ae7400000000, + 0xa748142800000000, 0x8391134b00000000, 0xeffa1bee00000000, + 0xcb231c8d00000000, 0x762a7a7f00000000, 0x52f37d1c00000000, + 0x3e9875b900000000, 0x1a4172da00000000, 0x4b1ce0d600000000, + 0x6fc5e7b500000000, 0x03aeef1000000000, 0x2777e87300000000, + 0x9a7e8e8100000000, 0xbea789e200000000, 0xd2cc814700000000, + 0xf615862400000000, 0xe9d93c7800000000, 0xcd003b1b00000000, + 0xa16b33be00000000, 0x85b234dd00000000, 0x38bb522f00000000, + 0x1c62554c00000000, 0x70095de900000000, 0x54d05a8a00000000, + 0x4e91285000000000, 0x6a482f3300000000, 0x0623279600000000, + 0x22fa20f500000000, 0x9ff3460700000000, 0xbb2a416400000000, + 0xd74149c100000000, 0xf3984ea200000000, 0xec54f4fe00000000, + 0xc88df39d00000000, 0xa4e6fb3800000000, 0x803ffc5b00000000, + 0x3d369aa900000000, 0x19ef9dca00000000, 0x7584956f00000000, + 0x515d920c00000000, 0xd73eb17600000000, 0xf3e7b61500000000, + 0x9f8cbeb000000000, 0xbb55b9d300000000, 0x065cdf2100000000, + 0x2285d84200000000, 0x4eeed0e700000000, 0x6a37d78400000000, + 0x75fb6dd800000000, 0x51226abb00000000, 0x3d49621e00000000, + 0x1990657d00000000, 0xa499038f00000000, 0x804004ec00000000, + 0xec2b0c4900000000, 0xc8f20b2a00000000, 0xd2b379f000000000, + 0xf66a7e9300000000, 0x9a01763600000000, 0xbed8715500000000, + 0x03d117a700000000, 0x270810c400000000, 0x4b63186100000000, + 0x6fba1f0200000000, 0x7076a55e00000000, 0x54afa23d00000000, + 0x38c4aa9800000000, 0x1c1dadfb00000000, 0xa114cb0900000000, + 0x85cdcc6a00000000, 0xe9a6c4cf00000000, 0xcd7fc3ac00000000, + 0x9c2251a000000000, 0xb8fb56c300000000, 0xd4905e6600000000, + 0xf049590500000000, 0x4d403ff700000000, 0x6999389400000000, + 0x05f2303100000000, 0x212b375200000000, 0x3ee78d0e00000000, + 0x1a3e8a6d00000000, 0x765582c800000000, 0x528c85ab00000000, + 0xef85e35900000000, 0xcb5ce43a00000000, 0xa737ec9f00000000, + 0x83eeebfc00000000, 0x99af992600000000, 0xbd769e4500000000, + 0xd11d96e000000000, 0xf5c4918300000000, 0x48cdf77100000000, + 0x6c14f01200000000, 0x007ff8b700000000, 0x24a6ffd400000000, + 0x3b6a458800000000, 0x1fb342eb00000000, 0x73d84a4e00000000, + 0x57014d2d00000000, 0xea082bdf00000000, 0xced12cbc00000000, + 0xa2ba241900000000, 0x8663237a00000000, 0xae7d62ed00000000, + 0x8aa4658e00000000, 0xe6cf6d2b00000000, 0xc2166a4800000000, + 0x7f1f0cba00000000, 0x5bc60bd900000000, 0x37ad037c00000000, + 0x1374041f00000000, 0x0cb8be4300000000, 0x2861b92000000000, + 0x440ab18500000000, 0x60d3b6e600000000, 0xdddad01400000000, + 0xf903d77700000000, 0x9568dfd200000000, 0xb1b1d8b100000000, + 0xabf0aa6b00000000, 0x8f29ad0800000000, 0xe342a5ad00000000, + 0xc79ba2ce00000000, 0x7a92c43c00000000, 0x5e4bc35f00000000, + 0x3220cbfa00000000, 0x16f9cc9900000000, 0x093576c500000000, + 0x2dec71a600000000, 0x4187790300000000, 0x655e7e6000000000, + 0xd857189200000000, 0xfc8e1ff100000000, 0x90e5175400000000, + 0xb43c103700000000, 0xe561823b00000000, 0xc1b8855800000000, + 0xadd38dfd00000000, 0x890a8a9e00000000, 0x3403ec6c00000000, + 0x10daeb0f00000000, 0x7cb1e3aa00000000, 0x5868e4c900000000, + 0x47a45e9500000000, 0x637d59f600000000, 0x0f16515300000000, + 0x2bcf563000000000, 0x96c630c200000000, 0xb21f37a100000000, + 0xde743f0400000000, 0xfaad386700000000, 0xe0ec4abd00000000, + 0xc4354dde00000000, 0xa85e457b00000000, 0x8c87421800000000, + 0x318e24ea00000000, 0x1557238900000000, 0x793c2b2c00000000, + 0x5de52c4f00000000, 0x4229961300000000, 0x66f0917000000000, + 0x0a9b99d500000000, 0x2e429eb600000000, 0x934bf84400000000, + 0xb792ff2700000000, 0xdbf9f78200000000, 0xff20f0e100000000, + 0x7943d39b00000000, 0x5d9ad4f800000000, 0x31f1dc5d00000000, + 0x1528db3e00000000, 0xa821bdcc00000000, 0x8cf8baaf00000000, + 0xe093b20a00000000, 0xc44ab56900000000, 0xdb860f3500000000, + 0xff5f085600000000, 0x933400f300000000, 0xb7ed079000000000, + 0x0ae4616200000000, 0x2e3d660100000000, 0x42566ea400000000, + 0x668f69c700000000, 0x7cce1b1d00000000, 0x58171c7e00000000, + 0x347c14db00000000, 0x10a513b800000000, 0xadac754a00000000, + 0x8975722900000000, 0xe51e7a8c00000000, 0xc1c77def00000000, + 0xde0bc7b300000000, 0xfad2c0d000000000, 0x96b9c87500000000, + 0xb260cf1600000000, 0x0f69a9e400000000, 0x2bb0ae8700000000, + 0x47dba62200000000, 0x6302a14100000000, 0x325f334d00000000, + 0x1686342e00000000, 0x7aed3c8b00000000, 0x5e343be800000000, + 0xe33d5d1a00000000, 0xc7e45a7900000000, 0xab8f52dc00000000, + 0x8f5655bf00000000, 0x909aefe300000000, 0xb443e88000000000, + 0xd828e02500000000, 0xfcf1e74600000000, 0x41f881b400000000, + 0x652186d700000000, 0x094a8e7200000000, 0x2d93891100000000, + 0x37d2fbcb00000000, 0x130bfca800000000, 0x7f60f40d00000000, + 0x5bb9f36e00000000, 0xe6b0959c00000000, 0xc26992ff00000000, + 0xae029a5a00000000, 0x8adb9d3900000000, 0x9517276500000000, + 0xb1ce200600000000, 0xdda528a300000000, 0xf97c2fc000000000, + 0x4475493200000000, 0x60ac4e5100000000, 0x0cc746f400000000, + 0x281e419700000000}, + {0x0000000000000000, 0x08e3603c00000000, 0x10c6c17800000000, + 0x1825a14400000000, 0x208c83f100000000, 0x286fe3cd00000000, + 0x304a428900000000, 0x38a922b500000000, 0x011e763800000000, + 0x09fd160400000000, 0x11d8b74000000000, 0x193bd77c00000000, + 0x2192f5c900000000, 0x297195f500000000, 0x315434b100000000, + 0x39b7548d00000000, 0x023cec7000000000, 0x0adf8c4c00000000, + 0x12fa2d0800000000, 0x1a194d3400000000, 0x22b06f8100000000, + 0x2a530fbd00000000, 0x3276aef900000000, 0x3a95cec500000000, + 0x03229a4800000000, 0x0bc1fa7400000000, 0x13e45b3000000000, + 0x1b073b0c00000000, 0x23ae19b900000000, 0x2b4d798500000000, + 0x3368d8c100000000, 0x3b8bb8fd00000000, 0x0478d8e100000000, + 0x0c9bb8dd00000000, 0x14be199900000000, 0x1c5d79a500000000, + 0x24f45b1000000000, 0x2c173b2c00000000, 0x34329a6800000000, + 0x3cd1fa5400000000, 0x0566aed900000000, 0x0d85cee500000000, + 0x15a06fa100000000, 0x1d430f9d00000000, 0x25ea2d2800000000, + 0x2d094d1400000000, 0x352cec5000000000, 0x3dcf8c6c00000000, + 0x0644349100000000, 0x0ea754ad00000000, 0x1682f5e900000000, + 0x1e6195d500000000, 0x26c8b76000000000, 0x2e2bd75c00000000, + 0x360e761800000000, 0x3eed162400000000, 0x075a42a900000000, + 0x0fb9229500000000, 0x179c83d100000000, 0x1f7fe3ed00000000, + 0x27d6c15800000000, 0x2f35a16400000000, 0x3710002000000000, + 0x3ff3601c00000000, 0x49f6c11800000000, 0x4115a12400000000, + 0x5930006000000000, 0x51d3605c00000000, 0x697a42e900000000, + 0x619922d500000000, 0x79bc839100000000, 0x715fe3ad00000000, + 0x48e8b72000000000, 0x400bd71c00000000, 0x582e765800000000, + 0x50cd166400000000, 0x686434d100000000, 0x608754ed00000000, + 0x78a2f5a900000000, 0x7041959500000000, 0x4bca2d6800000000, + 0x43294d5400000000, 0x5b0cec1000000000, 0x53ef8c2c00000000, + 0x6b46ae9900000000, 0x63a5cea500000000, 0x7b806fe100000000, + 0x73630fdd00000000, 0x4ad45b5000000000, 0x42373b6c00000000, + 0x5a129a2800000000, 0x52f1fa1400000000, 0x6a58d8a100000000, + 0x62bbb89d00000000, 0x7a9e19d900000000, 0x727d79e500000000, + 0x4d8e19f900000000, 0x456d79c500000000, 0x5d48d88100000000, + 0x55abb8bd00000000, 0x6d029a0800000000, 0x65e1fa3400000000, + 0x7dc45b7000000000, 0x75273b4c00000000, 0x4c906fc100000000, + 0x44730ffd00000000, 0x5c56aeb900000000, 0x54b5ce8500000000, + 0x6c1cec3000000000, 0x64ff8c0c00000000, 0x7cda2d4800000000, + 0x74394d7400000000, 0x4fb2f58900000000, 0x475195b500000000, + 0x5f7434f100000000, 0x579754cd00000000, 0x6f3e767800000000, + 0x67dd164400000000, 0x7ff8b70000000000, 0x771bd73c00000000, + 0x4eac83b100000000, 0x464fe38d00000000, 0x5e6a42c900000000, + 0x568922f500000000, 0x6e20004000000000, 0x66c3607c00000000, + 0x7ee6c13800000000, 0x7605a10400000000, 0x92ec833100000000, + 0x9a0fe30d00000000, 0x822a424900000000, 0x8ac9227500000000, + 0xb26000c000000000, 0xba8360fc00000000, 0xa2a6c1b800000000, + 0xaa45a18400000000, 0x93f2f50900000000, 0x9b11953500000000, + 0x8334347100000000, 0x8bd7544d00000000, 0xb37e76f800000000, + 0xbb9d16c400000000, 0xa3b8b78000000000, 0xab5bd7bc00000000, + 0x90d06f4100000000, 0x98330f7d00000000, 0x8016ae3900000000, + 0x88f5ce0500000000, 0xb05cecb000000000, 0xb8bf8c8c00000000, + 0xa09a2dc800000000, 0xa8794df400000000, 0x91ce197900000000, + 0x992d794500000000, 0x8108d80100000000, 0x89ebb83d00000000, + 0xb1429a8800000000, 0xb9a1fab400000000, 0xa1845bf000000000, + 0xa9673bcc00000000, 0x96945bd000000000, 0x9e773bec00000000, + 0x86529aa800000000, 0x8eb1fa9400000000, 0xb618d82100000000, + 0xbefbb81d00000000, 0xa6de195900000000, 0xae3d796500000000, + 0x978a2de800000000, 0x9f694dd400000000, 0x874cec9000000000, + 0x8faf8cac00000000, 0xb706ae1900000000, 0xbfe5ce2500000000, + 0xa7c06f6100000000, 0xaf230f5d00000000, 0x94a8b7a000000000, + 0x9c4bd79c00000000, 0x846e76d800000000, 0x8c8d16e400000000, + 0xb424345100000000, 0xbcc7546d00000000, 0xa4e2f52900000000, + 0xac01951500000000, 0x95b6c19800000000, 0x9d55a1a400000000, + 0x857000e000000000, 0x8d9360dc00000000, 0xb53a426900000000, + 0xbdd9225500000000, 0xa5fc831100000000, 0xad1fe32d00000000, + 0xdb1a422900000000, 0xd3f9221500000000, 0xcbdc835100000000, + 0xc33fe36d00000000, 0xfb96c1d800000000, 0xf375a1e400000000, + 0xeb5000a000000000, 0xe3b3609c00000000, 0xda04341100000000, + 0xd2e7542d00000000, 0xcac2f56900000000, 0xc221955500000000, + 0xfa88b7e000000000, 0xf26bd7dc00000000, 0xea4e769800000000, + 0xe2ad16a400000000, 0xd926ae5900000000, 0xd1c5ce6500000000, + 0xc9e06f2100000000, 0xc1030f1d00000000, 0xf9aa2da800000000, + 0xf1494d9400000000, 0xe96cecd000000000, 0xe18f8cec00000000, + 0xd838d86100000000, 0xd0dbb85d00000000, 0xc8fe191900000000, + 0xc01d792500000000, 0xf8b45b9000000000, 0xf0573bac00000000, + 0xe8729ae800000000, 0xe091fad400000000, 0xdf629ac800000000, + 0xd781faf400000000, 0xcfa45bb000000000, 0xc7473b8c00000000, + 0xffee193900000000, 0xf70d790500000000, 0xef28d84100000000, + 0xe7cbb87d00000000, 0xde7cecf000000000, 0xd69f8ccc00000000, + 0xceba2d8800000000, 0xc6594db400000000, 0xfef06f0100000000, + 0xf6130f3d00000000, 0xee36ae7900000000, 0xe6d5ce4500000000, + 0xdd5e76b800000000, 0xd5bd168400000000, 0xcd98b7c000000000, + 0xc57bd7fc00000000, 0xfdd2f54900000000, 0xf531957500000000, + 0xed14343100000000, 0xe5f7540d00000000, 0xdc40008000000000, + 0xd4a360bc00000000, 0xcc86c1f800000000, 0xc465a1c400000000, + 0xfccc837100000000, 0xf42fe34d00000000, 0xec0a420900000000, + 0xe4e9223500000000}, + {0x0000000000000000, 0xd1e8e70e00000000, 0xa2d1cf1d00000000, + 0x7339281300000000, 0x44a39f3b00000000, 0x954b783500000000, + 0xe672502600000000, 0x379ab72800000000, 0x88463f7700000000, + 0x59aed87900000000, 0x2a97f06a00000000, 0xfb7f176400000000, + 0xcce5a04c00000000, 0x1d0d474200000000, 0x6e346f5100000000, + 0xbfdc885f00000000, 0x108d7eee00000000, 0xc16599e000000000, + 0xb25cb1f300000000, 0x63b456fd00000000, 0x542ee1d500000000, + 0x85c606db00000000, 0xf6ff2ec800000000, 0x2717c9c600000000, + 0x98cb419900000000, 0x4923a69700000000, 0x3a1a8e8400000000, + 0xebf2698a00000000, 0xdc68dea200000000, 0x0d8039ac00000000, + 0x7eb911bf00000000, 0xaf51f6b100000000, 0x611c8c0700000000, + 0xb0f46b0900000000, 0xc3cd431a00000000, 0x1225a41400000000, + 0x25bf133c00000000, 0xf457f43200000000, 0x876edc2100000000, + 0x56863b2f00000000, 0xe95ab37000000000, 0x38b2547e00000000, + 0x4b8b7c6d00000000, 0x9a639b6300000000, 0xadf92c4b00000000, + 0x7c11cb4500000000, 0x0f28e35600000000, 0xdec0045800000000, + 0x7191f2e900000000, 0xa07915e700000000, 0xd3403df400000000, + 0x02a8dafa00000000, 0x35326dd200000000, 0xe4da8adc00000000, + 0x97e3a2cf00000000, 0x460b45c100000000, 0xf9d7cd9e00000000, + 0x283f2a9000000000, 0x5b06028300000000, 0x8aeee58d00000000, + 0xbd7452a500000000, 0x6c9cb5ab00000000, 0x1fa59db800000000, + 0xce4d7ab600000000, 0xc238180f00000000, 0x13d0ff0100000000, + 0x60e9d71200000000, 0xb101301c00000000, 0x869b873400000000, + 0x5773603a00000000, 0x244a482900000000, 0xf5a2af2700000000, + 0x4a7e277800000000, 0x9b96c07600000000, 0xe8afe86500000000, + 0x39470f6b00000000, 0x0eddb84300000000, 0xdf355f4d00000000, + 0xac0c775e00000000, 0x7de4905000000000, 0xd2b566e100000000, + 0x035d81ef00000000, 0x7064a9fc00000000, 0xa18c4ef200000000, + 0x9616f9da00000000, 0x47fe1ed400000000, 0x34c736c700000000, + 0xe52fd1c900000000, 0x5af3599600000000, 0x8b1bbe9800000000, + 0xf822968b00000000, 0x29ca718500000000, 0x1e50c6ad00000000, + 0xcfb821a300000000, 0xbc8109b000000000, 0x6d69eebe00000000, + 0xa324940800000000, 0x72cc730600000000, 0x01f55b1500000000, + 0xd01dbc1b00000000, 0xe7870b3300000000, 0x366fec3d00000000, + 0x4556c42e00000000, 0x94be232000000000, 0x2b62ab7f00000000, + 0xfa8a4c7100000000, 0x89b3646200000000, 0x585b836c00000000, + 0x6fc1344400000000, 0xbe29d34a00000000, 0xcd10fb5900000000, + 0x1cf81c5700000000, 0xb3a9eae600000000, 0x62410de800000000, + 0x117825fb00000000, 0xc090c2f500000000, 0xf70a75dd00000000, + 0x26e292d300000000, 0x55dbbac000000000, 0x84335dce00000000, + 0x3befd59100000000, 0xea07329f00000000, 0x993e1a8c00000000, + 0x48d6fd8200000000, 0x7f4c4aaa00000000, 0xaea4ada400000000, + 0xdd9d85b700000000, 0x0c7562b900000000, 0x8471301e00000000, + 0x5599d71000000000, 0x26a0ff0300000000, 0xf748180d00000000, + 0xc0d2af2500000000, 0x113a482b00000000, 0x6203603800000000, + 0xb3eb873600000000, 0x0c370f6900000000, 0xdddfe86700000000, + 0xaee6c07400000000, 0x7f0e277a00000000, 0x4894905200000000, + 0x997c775c00000000, 0xea455f4f00000000, 0x3badb84100000000, + 0x94fc4ef000000000, 0x4514a9fe00000000, 0x362d81ed00000000, + 0xe7c566e300000000, 0xd05fd1cb00000000, 0x01b736c500000000, + 0x728e1ed600000000, 0xa366f9d800000000, 0x1cba718700000000, + 0xcd52968900000000, 0xbe6bbe9a00000000, 0x6f83599400000000, + 0x5819eebc00000000, 0x89f109b200000000, 0xfac821a100000000, + 0x2b20c6af00000000, 0xe56dbc1900000000, 0x34855b1700000000, + 0x47bc730400000000, 0x9654940a00000000, 0xa1ce232200000000, + 0x7026c42c00000000, 0x031fec3f00000000, 0xd2f70b3100000000, + 0x6d2b836e00000000, 0xbcc3646000000000, 0xcffa4c7300000000, + 0x1e12ab7d00000000, 0x29881c5500000000, 0xf860fb5b00000000, + 0x8b59d34800000000, 0x5ab1344600000000, 0xf5e0c2f700000000, + 0x240825f900000000, 0x57310dea00000000, 0x86d9eae400000000, + 0xb1435dcc00000000, 0x60abbac200000000, 0x139292d100000000, + 0xc27a75df00000000, 0x7da6fd8000000000, 0xac4e1a8e00000000, + 0xdf77329d00000000, 0x0e9fd59300000000, 0x390562bb00000000, + 0xe8ed85b500000000, 0x9bd4ada600000000, 0x4a3c4aa800000000, + 0x4649281100000000, 0x97a1cf1f00000000, 0xe498e70c00000000, + 0x3570000200000000, 0x02eab72a00000000, 0xd302502400000000, + 0xa03b783700000000, 0x71d39f3900000000, 0xce0f176600000000, + 0x1fe7f06800000000, 0x6cded87b00000000, 0xbd363f7500000000, + 0x8aac885d00000000, 0x5b446f5300000000, 0x287d474000000000, + 0xf995a04e00000000, 0x56c456ff00000000, 0x872cb1f100000000, + 0xf41599e200000000, 0x25fd7eec00000000, 0x1267c9c400000000, + 0xc38f2eca00000000, 0xb0b606d900000000, 0x615ee1d700000000, + 0xde82698800000000, 0x0f6a8e8600000000, 0x7c53a69500000000, + 0xadbb419b00000000, 0x9a21f6b300000000, 0x4bc911bd00000000, + 0x38f039ae00000000, 0xe918dea000000000, 0x2755a41600000000, + 0xf6bd431800000000, 0x85846b0b00000000, 0x546c8c0500000000, + 0x63f63b2d00000000, 0xb21edc2300000000, 0xc127f43000000000, + 0x10cf133e00000000, 0xaf139b6100000000, 0x7efb7c6f00000000, + 0x0dc2547c00000000, 0xdc2ab37200000000, 0xebb0045a00000000, + 0x3a58e35400000000, 0x4961cb4700000000, 0x98892c4900000000, + 0x37d8daf800000000, 0xe6303df600000000, 0x950915e500000000, + 0x44e1f2eb00000000, 0x737b45c300000000, 0xa293a2cd00000000, + 0xd1aa8ade00000000, 0x00426dd000000000, 0xbf9ee58f00000000, + 0x6e76028100000000, 0x1d4f2a9200000000, 0xcca7cd9c00000000, + 0xfb3d7ab400000000, 0x2ad59dba00000000, 0x59ecb5a900000000, + 0x880452a700000000}, + {0x0000000000000000, 0xaa05daf100000000, 0x150dc53800000000, + 0xbf081fc900000000, 0x2a1a8a7100000000, 0x801f508000000000, + 0x3f174f4900000000, 0x951295b800000000, 0x543414e300000000, + 0xfe31ce1200000000, 0x4139d1db00000000, 0xeb3c0b2a00000000, + 0x7e2e9e9200000000, 0xd42b446300000000, 0x6b235baa00000000, + 0xc126815b00000000, 0xe96e591d00000000, 0x436b83ec00000000, + 0xfc639c2500000000, 0x566646d400000000, 0xc374d36c00000000, + 0x6971099d00000000, 0xd679165400000000, 0x7c7ccca500000000, + 0xbd5a4dfe00000000, 0x175f970f00000000, 0xa85788c600000000, + 0x0252523700000000, 0x9740c78f00000000, 0x3d451d7e00000000, + 0x824d02b700000000, 0x2848d84600000000, 0xd2ddb23a00000000, + 0x78d868cb00000000, 0xc7d0770200000000, 0x6dd5adf300000000, + 0xf8c7384b00000000, 0x52c2e2ba00000000, 0xedcafd7300000000, + 0x47cf278200000000, 0x86e9a6d900000000, 0x2cec7c2800000000, + 0x93e463e100000000, 0x39e1b91000000000, 0xacf32ca800000000, + 0x06f6f65900000000, 0xb9fee99000000000, 0x13fb336100000000, + 0x3bb3eb2700000000, 0x91b631d600000000, 0x2ebe2e1f00000000, + 0x84bbf4ee00000000, 0x11a9615600000000, 0xbbacbba700000000, + 0x04a4a46e00000000, 0xaea17e9f00000000, 0x6f87ffc400000000, + 0xc582253500000000, 0x7a8a3afc00000000, 0xd08fe00d00000000, + 0x459d75b500000000, 0xef98af4400000000, 0x5090b08d00000000, + 0xfa956a7c00000000, 0xa4bb657500000000, 0x0ebebf8400000000, + 0xb1b6a04d00000000, 0x1bb37abc00000000, 0x8ea1ef0400000000, + 0x24a435f500000000, 0x9bac2a3c00000000, 0x31a9f0cd00000000, + 0xf08f719600000000, 0x5a8aab6700000000, 0xe582b4ae00000000, + 0x4f876e5f00000000, 0xda95fbe700000000, 0x7090211600000000, + 0xcf983edf00000000, 0x659de42e00000000, 0x4dd53c6800000000, + 0xe7d0e69900000000, 0x58d8f95000000000, 0xf2dd23a100000000, + 0x67cfb61900000000, 0xcdca6ce800000000, 0x72c2732100000000, + 0xd8c7a9d000000000, 0x19e1288b00000000, 0xb3e4f27a00000000, + 0x0cecedb300000000, 0xa6e9374200000000, 0x33fba2fa00000000, + 0x99fe780b00000000, 0x26f667c200000000, 0x8cf3bd3300000000, + 0x7666d74f00000000, 0xdc630dbe00000000, 0x636b127700000000, + 0xc96ec88600000000, 0x5c7c5d3e00000000, 0xf67987cf00000000, + 0x4971980600000000, 0xe37442f700000000, 0x2252c3ac00000000, + 0x8857195d00000000, 0x375f069400000000, 0x9d5adc6500000000, + 0x084849dd00000000, 0xa24d932c00000000, 0x1d458ce500000000, + 0xb740561400000000, 0x9f088e5200000000, 0x350d54a300000000, + 0x8a054b6a00000000, 0x2000919b00000000, 0xb512042300000000, + 0x1f17ded200000000, 0xa01fc11b00000000, 0x0a1a1bea00000000, + 0xcb3c9ab100000000, 0x6139404000000000, 0xde315f8900000000, + 0x7434857800000000, 0xe12610c000000000, 0x4b23ca3100000000, + 0xf42bd5f800000000, 0x5e2e0f0900000000, 0x4877cbea00000000, + 0xe272111b00000000, 0x5d7a0ed200000000, 0xf77fd42300000000, + 0x626d419b00000000, 0xc8689b6a00000000, 0x776084a300000000, + 0xdd655e5200000000, 0x1c43df0900000000, 0xb64605f800000000, + 0x094e1a3100000000, 0xa34bc0c000000000, 0x3659557800000000, + 0x9c5c8f8900000000, 0x2354904000000000, 0x89514ab100000000, + 0xa11992f700000000, 0x0b1c480600000000, 0xb41457cf00000000, + 0x1e118d3e00000000, 0x8b03188600000000, 0x2106c27700000000, + 0x9e0eddbe00000000, 0x340b074f00000000, 0xf52d861400000000, + 0x5f285ce500000000, 0xe020432c00000000, 0x4a2599dd00000000, + 0xdf370c6500000000, 0x7532d69400000000, 0xca3ac95d00000000, + 0x603f13ac00000000, 0x9aaa79d000000000, 0x30afa32100000000, + 0x8fa7bce800000000, 0x25a2661900000000, 0xb0b0f3a100000000, + 0x1ab5295000000000, 0xa5bd369900000000, 0x0fb8ec6800000000, + 0xce9e6d3300000000, 0x649bb7c200000000, 0xdb93a80b00000000, + 0x719672fa00000000, 0xe484e74200000000, 0x4e813db300000000, + 0xf189227a00000000, 0x5b8cf88b00000000, 0x73c420cd00000000, + 0xd9c1fa3c00000000, 0x66c9e5f500000000, 0xcccc3f0400000000, + 0x59deaabc00000000, 0xf3db704d00000000, 0x4cd36f8400000000, + 0xe6d6b57500000000, 0x27f0342e00000000, 0x8df5eedf00000000, + 0x32fdf11600000000, 0x98f82be700000000, 0x0deabe5f00000000, + 0xa7ef64ae00000000, 0x18e77b6700000000, 0xb2e2a19600000000, + 0xecccae9f00000000, 0x46c9746e00000000, 0xf9c16ba700000000, + 0x53c4b15600000000, 0xc6d624ee00000000, 0x6cd3fe1f00000000, + 0xd3dbe1d600000000, 0x79de3b2700000000, 0xb8f8ba7c00000000, + 0x12fd608d00000000, 0xadf57f4400000000, 0x07f0a5b500000000, + 0x92e2300d00000000, 0x38e7eafc00000000, 0x87eff53500000000, + 0x2dea2fc400000000, 0x05a2f78200000000, 0xafa72d7300000000, + 0x10af32ba00000000, 0xbaaae84b00000000, 0x2fb87df300000000, + 0x85bda70200000000, 0x3ab5b8cb00000000, 0x90b0623a00000000, + 0x5196e36100000000, 0xfb93399000000000, 0x449b265900000000, + 0xee9efca800000000, 0x7b8c691000000000, 0xd189b3e100000000, + 0x6e81ac2800000000, 0xc48476d900000000, 0x3e111ca500000000, + 0x9414c65400000000, 0x2b1cd99d00000000, 0x8119036c00000000, + 0x140b96d400000000, 0xbe0e4c2500000000, 0x010653ec00000000, + 0xab03891d00000000, 0x6a25084600000000, 0xc020d2b700000000, + 0x7f28cd7e00000000, 0xd52d178f00000000, 0x403f823700000000, + 0xea3a58c600000000, 0x5532470f00000000, 0xff379dfe00000000, + 0xd77f45b800000000, 0x7d7a9f4900000000, 0xc272808000000000, + 0x68775a7100000000, 0xfd65cfc900000000, 0x5760153800000000, + 0xe8680af100000000, 0x426dd00000000000, 0x834b515b00000000, + 0x294e8baa00000000, 0x9646946300000000, 0x3c434e9200000000, + 0xa951db2a00000000, 0x035401db00000000, 0xbc5c1e1200000000, + 0x1659c4e300000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, + 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, + 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, + 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, + 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, + 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, + 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, + 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, + 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, + 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, + 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, + 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, + 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, + 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, + 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, + 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, + 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, + 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, + 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, + 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, + 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, + 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, + 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, + 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, + 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, + 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, + 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, + 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, + 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, + 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, + 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, + 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, + 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, + 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, + 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, + 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, + 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, + 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, + 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, + 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, + 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, + 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, + 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, + 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, + 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, + 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, + 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, + 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, + 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, + 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, + 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, + 0x0d7139d7}, + {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, + 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, + 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, + 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, + 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, + 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, + 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, + 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, + 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, + 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, + 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, + 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, + 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, + 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, + 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, + 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, + 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, + 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, + 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, + 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, + 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, + 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, + 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, + 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, + 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, + 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, + 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, + 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, + 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, + 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, + 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, + 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, + 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, + 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, + 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, + 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, + 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, + 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, + 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, + 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, + 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, + 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, + 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, + 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, + 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, + 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, + 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, + 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, + 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, + 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, + 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, + 0x1c53e98a}, + {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, + 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, + 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, + 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, + 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, + 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, + 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, + 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, + 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, + 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, + 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, + 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, + 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, + 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, + 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, + 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, + 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, + 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, + 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, + 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, + 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, + 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, + 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, + 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, + 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, + 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, + 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, + 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, + 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, + 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, + 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, + 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, + 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, + 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, + 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, + 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, + 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, + 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, + 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, + 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, + 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, + 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, + 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, + 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, + 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, + 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, + 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, + 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, + 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, + 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, + 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, + 0x3f88e851}, + {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, + 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, + 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, + 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, + 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, + 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, + 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, + 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, + 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, + 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, + 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, + 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, + 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, + 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, + 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, + 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, + 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, + 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, + 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, + 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, + 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, + 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, + 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, + 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, + 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, + 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, + 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, + 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, + 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, + 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, + 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, + 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, + 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, + 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, + 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, + 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, + 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, + 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, + 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, + 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, + 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, + 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, + 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, + 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, + 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, + 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, + 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, + 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, + 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, + 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, + 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, + 0x3dee8ca6}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x85d996dd, 0x4bb55c60, 0xce6ccabd, 0x966ab9c0, + 0x13b32f1d, 0xdddfe5a0, 0x5806737d, 0x6dd3035a, 0xe80a9587, + 0x26665f3a, 0xa3bfc9e7, 0xfbb9ba9a, 0x7e602c47, 0xb00ce6fa, + 0x35d57027, 0xdaa607b4, 0x5f7f9169, 0x91135bd4, 0x14cacd09, + 0x4cccbe74, 0xc91528a9, 0x0779e214, 0x82a074c9, 0xb77504ee, + 0x32ac9233, 0xfcc0588e, 0x7919ce53, 0x211fbd2e, 0xa4c62bf3, + 0x6aaae14e, 0xef737793, 0xf54b7eb3, 0x7092e86e, 0xbefe22d3, + 0x3b27b40e, 0x6321c773, 0xe6f851ae, 0x28949b13, 0xad4d0dce, + 0x98987de9, 0x1d41eb34, 0xd32d2189, 0x56f4b754, 0x0ef2c429, + 0x8b2b52f4, 0x45479849, 0xc09e0e94, 0x2fed7907, 0xaa34efda, + 0x64582567, 0xe181b3ba, 0xb987c0c7, 0x3c5e561a, 0xf2329ca7, + 0x77eb0a7a, 0x423e7a5d, 0xc7e7ec80, 0x098b263d, 0x8c52b0e0, + 0xd454c39d, 0x518d5540, 0x9fe19ffd, 0x1a380920, 0xab918dbd, + 0x2e481b60, 0xe024d1dd, 0x65fd4700, 0x3dfb347d, 0xb822a2a0, + 0x764e681d, 0xf397fec0, 0xc6428ee7, 0x439b183a, 0x8df7d287, + 0x082e445a, 0x50283727, 0xd5f1a1fa, 0x1b9d6b47, 0x9e44fd9a, + 0x71378a09, 0xf4ee1cd4, 0x3a82d669, 0xbf5b40b4, 0xe75d33c9, + 0x6284a514, 0xace86fa9, 0x2931f974, 0x1ce48953, 0x993d1f8e, + 0x5751d533, 0xd28843ee, 0x8a8e3093, 0x0f57a64e, 0xc13b6cf3, + 0x44e2fa2e, 0x5edaf30e, 0xdb0365d3, 0x156faf6e, 0x90b639b3, + 0xc8b04ace, 0x4d69dc13, 0x830516ae, 0x06dc8073, 0x3309f054, + 0xb6d06689, 0x78bcac34, 0xfd653ae9, 0xa5634994, 0x20badf49, + 0xeed615f4, 0x6b0f8329, 0x847cf4ba, 0x01a56267, 0xcfc9a8da, + 0x4a103e07, 0x12164d7a, 0x97cfdba7, 0x59a3111a, 0xdc7a87c7, + 0xe9aff7e0, 0x6c76613d, 0xa21aab80, 0x27c33d5d, 0x7fc54e20, + 0xfa1cd8fd, 0x34701240, 0xb1a9849d, 0x17256aa0, 0x92fcfc7d, + 0x5c9036c0, 0xd949a01d, 0x814fd360, 0x049645bd, 0xcafa8f00, + 0x4f2319dd, 0x7af669fa, 0xff2fff27, 0x3143359a, 0xb49aa347, + 0xec9cd03a, 0x694546e7, 0xa7298c5a, 0x22f01a87, 0xcd836d14, + 0x485afbc9, 0x86363174, 0x03efa7a9, 0x5be9d4d4, 0xde304209, + 0x105c88b4, 0x95851e69, 0xa0506e4e, 0x2589f893, 0xebe5322e, + 0x6e3ca4f3, 0x363ad78e, 0xb3e34153, 0x7d8f8bee, 0xf8561d33, + 0xe26e1413, 0x67b782ce, 0xa9db4873, 0x2c02deae, 0x7404add3, + 0xf1dd3b0e, 0x3fb1f1b3, 0xba68676e, 0x8fbd1749, 0x0a648194, + 0xc4084b29, 0x41d1ddf4, 0x19d7ae89, 0x9c0e3854, 0x5262f2e9, + 0xd7bb6434, 0x38c813a7, 0xbd11857a, 0x737d4fc7, 0xf6a4d91a, + 0xaea2aa67, 0x2b7b3cba, 0xe517f607, 0x60ce60da, 0x551b10fd, + 0xd0c28620, 0x1eae4c9d, 0x9b77da40, 0xc371a93d, 0x46a83fe0, + 0x88c4f55d, 0x0d1d6380, 0xbcb4e71d, 0x396d71c0, 0xf701bb7d, + 0x72d82da0, 0x2ade5edd, 0xaf07c800, 0x616b02bd, 0xe4b29460, + 0xd167e447, 0x54be729a, 0x9ad2b827, 0x1f0b2efa, 0x470d5d87, + 0xc2d4cb5a, 0x0cb801e7, 0x8961973a, 0x6612e0a9, 0xe3cb7674, + 0x2da7bcc9, 0xa87e2a14, 0xf0785969, 0x75a1cfb4, 0xbbcd0509, + 0x3e1493d4, 0x0bc1e3f3, 0x8e18752e, 0x4074bf93, 0xc5ad294e, + 0x9dab5a33, 0x1872ccee, 0xd61e0653, 0x53c7908e, 0x49ff99ae, + 0xcc260f73, 0x024ac5ce, 0x87935313, 0xdf95206e, 0x5a4cb6b3, + 0x94207c0e, 0x11f9ead3, 0x242c9af4, 0xa1f50c29, 0x6f99c694, + 0xea405049, 0xb2462334, 0x379fb5e9, 0xf9f37f54, 0x7c2ae989, + 0x93599e1a, 0x168008c7, 0xd8ecc27a, 0x5d3554a7, 0x053327da, + 0x80eab107, 0x4e867bba, 0xcb5fed67, 0xfe8a9d40, 0x7b530b9d, + 0xb53fc120, 0x30e657fd, 0x68e02480, 0xed39b25d, 0x235578e0, + 0xa68cee3d}, + {0x00000000, 0x76e10f9d, 0xadc46ee1, 0xdb25617c, 0x1b8fac19, + 0x6d6ea384, 0xb64bc2f8, 0xc0aacd65, 0x361e5933, 0x40ff56ae, + 0x9bda37d2, 0xed3b384f, 0x2d91f52a, 0x5b70fab7, 0x80559bcb, + 0xf6b49456, 0x6c3cb266, 0x1addbdfb, 0xc1f8dc87, 0xb719d31a, + 0x77b31e7f, 0x015211e2, 0xda77709e, 0xac967f03, 0x5a22eb55, + 0x2cc3e4c8, 0xf7e685b4, 0x81078a29, 0x41ad474c, 0x374c48d1, + 0xec6929ad, 0x9a882630, 0xd87864cd, 0xae996b50, 0x75bc0a2c, + 0x035d05b1, 0xc3f7c8d4, 0xb516c749, 0x6e33a635, 0x18d2a9a8, + 0xee663dfe, 0x98873263, 0x43a2531f, 0x35435c82, 0xf5e991e7, + 0x83089e7a, 0x582dff06, 0x2eccf09b, 0xb444d6ab, 0xc2a5d936, + 0x1980b84a, 0x6f61b7d7, 0xafcb7ab2, 0xd92a752f, 0x020f1453, + 0x74ee1bce, 0x825a8f98, 0xf4bb8005, 0x2f9ee179, 0x597feee4, + 0x99d52381, 0xef342c1c, 0x34114d60, 0x42f042fd, 0xf1f7b941, + 0x8716b6dc, 0x5c33d7a0, 0x2ad2d83d, 0xea781558, 0x9c991ac5, + 0x47bc7bb9, 0x315d7424, 0xc7e9e072, 0xb108efef, 0x6a2d8e93, + 0x1ccc810e, 0xdc664c6b, 0xaa8743f6, 0x71a2228a, 0x07432d17, + 0x9dcb0b27, 0xeb2a04ba, 0x300f65c6, 0x46ee6a5b, 0x8644a73e, + 0xf0a5a8a3, 0x2b80c9df, 0x5d61c642, 0xabd55214, 0xdd345d89, + 0x06113cf5, 0x70f03368, 0xb05afe0d, 0xc6bbf190, 0x1d9e90ec, + 0x6b7f9f71, 0x298fdd8c, 0x5f6ed211, 0x844bb36d, 0xf2aabcf0, + 0x32007195, 0x44e17e08, 0x9fc41f74, 0xe92510e9, 0x1f9184bf, + 0x69708b22, 0xb255ea5e, 0xc4b4e5c3, 0x041e28a6, 0x72ff273b, + 0xa9da4647, 0xdf3b49da, 0x45b36fea, 0x33526077, 0xe877010b, + 0x9e960e96, 0x5e3cc3f3, 0x28ddcc6e, 0xf3f8ad12, 0x8519a28f, + 0x73ad36d9, 0x054c3944, 0xde695838, 0xa88857a5, 0x68229ac0, + 0x1ec3955d, 0xc5e6f421, 0xb307fbbc, 0xe2ef7383, 0x940e7c1e, + 0x4f2b1d62, 0x39ca12ff, 0xf960df9a, 0x8f81d007, 0x54a4b17b, + 0x2245bee6, 0xd4f12ab0, 0xa210252d, 0x79354451, 0x0fd44bcc, + 0xcf7e86a9, 0xb99f8934, 0x62bae848, 0x145be7d5, 0x8ed3c1e5, + 0xf832ce78, 0x2317af04, 0x55f6a099, 0x955c6dfc, 0xe3bd6261, + 0x3898031d, 0x4e790c80, 0xb8cd98d6, 0xce2c974b, 0x1509f637, + 0x63e8f9aa, 0xa34234cf, 0xd5a33b52, 0x0e865a2e, 0x786755b3, + 0x3a97174e, 0x4c7618d3, 0x975379af, 0xe1b27632, 0x2118bb57, + 0x57f9b4ca, 0x8cdcd5b6, 0xfa3dda2b, 0x0c894e7d, 0x7a6841e0, + 0xa14d209c, 0xd7ac2f01, 0x1706e264, 0x61e7edf9, 0xbac28c85, + 0xcc238318, 0x56aba528, 0x204aaab5, 0xfb6fcbc9, 0x8d8ec454, + 0x4d240931, 0x3bc506ac, 0xe0e067d0, 0x9601684d, 0x60b5fc1b, + 0x1654f386, 0xcd7192fa, 0xbb909d67, 0x7b3a5002, 0x0ddb5f9f, + 0xd6fe3ee3, 0xa01f317e, 0x1318cac2, 0x65f9c55f, 0xbedca423, + 0xc83dabbe, 0x089766db, 0x7e766946, 0xa553083a, 0xd3b207a7, + 0x250693f1, 0x53e79c6c, 0x88c2fd10, 0xfe23f28d, 0x3e893fe8, + 0x48683075, 0x934d5109, 0xe5ac5e94, 0x7f2478a4, 0x09c57739, + 0xd2e01645, 0xa40119d8, 0x64abd4bd, 0x124adb20, 0xc96fba5c, + 0xbf8eb5c1, 0x493a2197, 0x3fdb2e0a, 0xe4fe4f76, 0x921f40eb, + 0x52b58d8e, 0x24548213, 0xff71e36f, 0x8990ecf2, 0xcb60ae0f, + 0xbd81a192, 0x66a4c0ee, 0x1045cf73, 0xd0ef0216, 0xa60e0d8b, + 0x7d2b6cf7, 0x0bca636a, 0xfd7ef73c, 0x8b9ff8a1, 0x50ba99dd, + 0x265b9640, 0xe6f15b25, 0x901054b8, 0x4b3535c4, 0x3dd43a59, + 0xa75c1c69, 0xd1bd13f4, 0x0a987288, 0x7c797d15, 0xbcd3b070, + 0xca32bfed, 0x1117de91, 0x67f6d10c, 0x9142455a, 0xe7a34ac7, + 0x3c862bbb, 0x4a672426, 0x8acde943, 0xfc2ce6de, 0x270987a2, + 0x51e8883f}, + {0x00000000, 0xe8dbfbb9, 0x91b186a8, 0x796a7d11, 0x63657c8a, + 0x8bbe8733, 0xf2d4fa22, 0x1a0f019b, 0x87cc89cf, 0x6f177276, + 0x167d0f67, 0xfea6f4de, 0xe4a9f545, 0x0c720efc, 0x751873ed, + 0x9dc38854, 0x4f9f6244, 0xa74499fd, 0xde2ee4ec, 0x36f51f55, + 0x2cfa1ece, 0xc421e577, 0xbd4b9866, 0x559063df, 0xc853eb8b, + 0x20881032, 0x59e26d23, 0xb139969a, 0xab369701, 0x43ed6cb8, + 0x3a8711a9, 0xd25cea10, 0x9e3ec588, 0x76e53e31, 0x0f8f4320, + 0xe754b899, 0xfd5bb902, 0x158042bb, 0x6cea3faa, 0x8431c413, + 0x19f24c47, 0xf129b7fe, 0x8843caef, 0x60983156, 0x7a9730cd, + 0x924ccb74, 0xeb26b665, 0x03fd4ddc, 0xd1a1a7cc, 0x397a5c75, + 0x40102164, 0xa8cbdadd, 0xb2c4db46, 0x5a1f20ff, 0x23755dee, + 0xcbaea657, 0x566d2e03, 0xbeb6d5ba, 0xc7dca8ab, 0x2f075312, + 0x35085289, 0xddd3a930, 0xa4b9d421, 0x4c622f98, 0x7d7bfbca, + 0x95a00073, 0xecca7d62, 0x041186db, 0x1e1e8740, 0xf6c57cf9, + 0x8faf01e8, 0x6774fa51, 0xfab77205, 0x126c89bc, 0x6b06f4ad, + 0x83dd0f14, 0x99d20e8f, 0x7109f536, 0x08638827, 0xe0b8739e, + 0x32e4998e, 0xda3f6237, 0xa3551f26, 0x4b8ee49f, 0x5181e504, + 0xb95a1ebd, 0xc03063ac, 0x28eb9815, 0xb5281041, 0x5df3ebf8, + 0x249996e9, 0xcc426d50, 0xd64d6ccb, 0x3e969772, 0x47fcea63, + 0xaf2711da, 0xe3453e42, 0x0b9ec5fb, 0x72f4b8ea, 0x9a2f4353, + 0x802042c8, 0x68fbb971, 0x1191c460, 0xf94a3fd9, 0x6489b78d, + 0x8c524c34, 0xf5383125, 0x1de3ca9c, 0x07eccb07, 0xef3730be, + 0x965d4daf, 0x7e86b616, 0xacda5c06, 0x4401a7bf, 0x3d6bdaae, + 0xd5b02117, 0xcfbf208c, 0x2764db35, 0x5e0ea624, 0xb6d55d9d, + 0x2b16d5c9, 0xc3cd2e70, 0xbaa75361, 0x527ca8d8, 0x4873a943, + 0xa0a852fa, 0xd9c22feb, 0x3119d452, 0xbbf0874e, 0x532b7cf7, + 0x2a4101e6, 0xc29afa5f, 0xd895fbc4, 0x304e007d, 0x49247d6c, + 0xa1ff86d5, 0x3c3c0e81, 0xd4e7f538, 0xad8d8829, 0x45567390, + 0x5f59720b, 0xb78289b2, 0xcee8f4a3, 0x26330f1a, 0xf46fe50a, + 0x1cb41eb3, 0x65de63a2, 0x8d05981b, 0x970a9980, 0x7fd16239, + 0x06bb1f28, 0xee60e491, 0x73a36cc5, 0x9b78977c, 0xe212ea6d, + 0x0ac911d4, 0x10c6104f, 0xf81debf6, 0x817796e7, 0x69ac6d5e, + 0x25ce42c6, 0xcd15b97f, 0xb47fc46e, 0x5ca43fd7, 0x46ab3e4c, + 0xae70c5f5, 0xd71ab8e4, 0x3fc1435d, 0xa202cb09, 0x4ad930b0, + 0x33b34da1, 0xdb68b618, 0xc167b783, 0x29bc4c3a, 0x50d6312b, + 0xb80dca92, 0x6a512082, 0x828adb3b, 0xfbe0a62a, 0x133b5d93, + 0x09345c08, 0xe1efa7b1, 0x9885daa0, 0x705e2119, 0xed9da94d, + 0x054652f4, 0x7c2c2fe5, 0x94f7d45c, 0x8ef8d5c7, 0x66232e7e, + 0x1f49536f, 0xf792a8d6, 0xc68b7c84, 0x2e50873d, 0x573afa2c, + 0xbfe10195, 0xa5ee000e, 0x4d35fbb7, 0x345f86a6, 0xdc847d1f, + 0x4147f54b, 0xa99c0ef2, 0xd0f673e3, 0x382d885a, 0x222289c1, + 0xcaf97278, 0xb3930f69, 0x5b48f4d0, 0x89141ec0, 0x61cfe579, + 0x18a59868, 0xf07e63d1, 0xea71624a, 0x02aa99f3, 0x7bc0e4e2, + 0x931b1f5b, 0x0ed8970f, 0xe6036cb6, 0x9f6911a7, 0x77b2ea1e, + 0x6dbdeb85, 0x8566103c, 0xfc0c6d2d, 0x14d79694, 0x58b5b90c, + 0xb06e42b5, 0xc9043fa4, 0x21dfc41d, 0x3bd0c586, 0xd30b3e3f, + 0xaa61432e, 0x42bab897, 0xdf7930c3, 0x37a2cb7a, 0x4ec8b66b, + 0xa6134dd2, 0xbc1c4c49, 0x54c7b7f0, 0x2dadcae1, 0xc5763158, + 0x172adb48, 0xfff120f1, 0x869b5de0, 0x6e40a659, 0x744fa7c2, + 0x9c945c7b, 0xe5fe216a, 0x0d25dad3, 0x90e65287, 0x783da93e, + 0x0157d42f, 0xe98c2f96, 0xf3832e0d, 0x1b58d5b4, 0x6232a8a5, + 0x8ae9531c}, + {0x00000000, 0x919168ae, 0x6325a087, 0xf2b4c829, 0x874c31d4, + 0x16dd597a, 0xe4699153, 0x75f8f9fd, 0x4f9f1373, 0xde0e7bdd, + 0x2cbab3f4, 0xbd2bdb5a, 0xc8d322a7, 0x59424a09, 0xabf68220, + 0x3a67ea8e, 0x9e3e27e6, 0x0faf4f48, 0xfd1b8761, 0x6c8aefcf, + 0x19721632, 0x88e37e9c, 0x7a57b6b5, 0xebc6de1b, 0xd1a13495, + 0x40305c3b, 0xb2849412, 0x2315fcbc, 0x56ed0541, 0xc77c6def, + 0x35c8a5c6, 0xa459cd68, 0x7d7b3f17, 0xecea57b9, 0x1e5e9f90, + 0x8fcff73e, 0xfa370ec3, 0x6ba6666d, 0x9912ae44, 0x0883c6ea, + 0x32e42c64, 0xa37544ca, 0x51c18ce3, 0xc050e44d, 0xb5a81db0, + 0x2439751e, 0xd68dbd37, 0x471cd599, 0xe34518f1, 0x72d4705f, + 0x8060b876, 0x11f1d0d8, 0x64092925, 0xf598418b, 0x072c89a2, + 0x96bde10c, 0xacda0b82, 0x3d4b632c, 0xcfffab05, 0x5e6ec3ab, + 0x2b963a56, 0xba0752f8, 0x48b39ad1, 0xd922f27f, 0xfaf67e2e, + 0x6b671680, 0x99d3dea9, 0x0842b607, 0x7dba4ffa, 0xec2b2754, + 0x1e9fef7d, 0x8f0e87d3, 0xb5696d5d, 0x24f805f3, 0xd64ccdda, + 0x47dda574, 0x32255c89, 0xa3b43427, 0x5100fc0e, 0xc09194a0, + 0x64c859c8, 0xf5593166, 0x07edf94f, 0x967c91e1, 0xe384681c, + 0x721500b2, 0x80a1c89b, 0x1130a035, 0x2b574abb, 0xbac62215, + 0x4872ea3c, 0xd9e38292, 0xac1b7b6f, 0x3d8a13c1, 0xcf3edbe8, + 0x5eafb346, 0x878d4139, 0x161c2997, 0xe4a8e1be, 0x75398910, + 0x00c170ed, 0x91501843, 0x63e4d06a, 0xf275b8c4, 0xc812524a, + 0x59833ae4, 0xab37f2cd, 0x3aa69a63, 0x4f5e639e, 0xdecf0b30, + 0x2c7bc319, 0xbdeaabb7, 0x19b366df, 0x88220e71, 0x7a96c658, + 0xeb07aef6, 0x9eff570b, 0x0f6e3fa5, 0xfddaf78c, 0x6c4b9f22, + 0x562c75ac, 0xc7bd1d02, 0x3509d52b, 0xa498bd85, 0xd1604478, + 0x40f12cd6, 0xb245e4ff, 0x23d48c51, 0xf4edfd5c, 0x657c95f2, + 0x97c85ddb, 0x06593575, 0x73a1cc88, 0xe230a426, 0x10846c0f, + 0x811504a1, 0xbb72ee2f, 0x2ae38681, 0xd8574ea8, 0x49c62606, + 0x3c3edffb, 0xadafb755, 0x5f1b7f7c, 0xce8a17d2, 0x6ad3daba, + 0xfb42b214, 0x09f67a3d, 0x98671293, 0xed9feb6e, 0x7c0e83c0, + 0x8eba4be9, 0x1f2b2347, 0x254cc9c9, 0xb4dda167, 0x4669694e, + 0xd7f801e0, 0xa200f81d, 0x339190b3, 0xc125589a, 0x50b43034, + 0x8996c24b, 0x1807aae5, 0xeab362cc, 0x7b220a62, 0x0edaf39f, + 0x9f4b9b31, 0x6dff5318, 0xfc6e3bb6, 0xc609d138, 0x5798b996, + 0xa52c71bf, 0x34bd1911, 0x4145e0ec, 0xd0d48842, 0x2260406b, + 0xb3f128c5, 0x17a8e5ad, 0x86398d03, 0x748d452a, 0xe51c2d84, + 0x90e4d479, 0x0175bcd7, 0xf3c174fe, 0x62501c50, 0x5837f6de, + 0xc9a69e70, 0x3b125659, 0xaa833ef7, 0xdf7bc70a, 0x4eeaafa4, + 0xbc5e678d, 0x2dcf0f23, 0x0e1b8372, 0x9f8aebdc, 0x6d3e23f5, + 0xfcaf4b5b, 0x8957b2a6, 0x18c6da08, 0xea721221, 0x7be37a8f, + 0x41849001, 0xd015f8af, 0x22a13086, 0xb3305828, 0xc6c8a1d5, + 0x5759c97b, 0xa5ed0152, 0x347c69fc, 0x9025a494, 0x01b4cc3a, + 0xf3000413, 0x62916cbd, 0x17699540, 0x86f8fdee, 0x744c35c7, + 0xe5dd5d69, 0xdfbab7e7, 0x4e2bdf49, 0xbc9f1760, 0x2d0e7fce, + 0x58f68633, 0xc967ee9d, 0x3bd326b4, 0xaa424e1a, 0x7360bc65, + 0xe2f1d4cb, 0x10451ce2, 0x81d4744c, 0xf42c8db1, 0x65bde51f, + 0x97092d36, 0x06984598, 0x3cffaf16, 0xad6ec7b8, 0x5fda0f91, + 0xce4b673f, 0xbbb39ec2, 0x2a22f66c, 0xd8963e45, 0x490756eb, + 0xed5e9b83, 0x7ccff32d, 0x8e7b3b04, 0x1fea53aa, 0x6a12aa57, + 0xfb83c2f9, 0x09370ad0, 0x98a6627e, 0xa2c188f0, 0x3350e05e, + 0xc1e42877, 0x507540d9, 0x258db924, 0xb41cd18a, 0x46a819a3, + 0xd739710d}}; + +#endif + +#endif + +#if N == 5 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0xaf449247, 0x85f822cf, 0x2abcb088, 0xd08143df, + 0x7fc5d198, 0x55796110, 0xfa3df357, 0x7a7381ff, 0xd53713b8, + 0xff8ba330, 0x50cf3177, 0xaaf2c220, 0x05b65067, 0x2f0ae0ef, + 0x804e72a8, 0xf4e703fe, 0x5ba391b9, 0x711f2131, 0xde5bb376, + 0x24664021, 0x8b22d266, 0xa19e62ee, 0x0edaf0a9, 0x8e948201, + 0x21d01046, 0x0b6ca0ce, 0xa4283289, 0x5e15c1de, 0xf1515399, + 0xdbede311, 0x74a97156, 0x32bf01bd, 0x9dfb93fa, 0xb7472372, + 0x1803b135, 0xe23e4262, 0x4d7ad025, 0x67c660ad, 0xc882f2ea, + 0x48cc8042, 0xe7881205, 0xcd34a28d, 0x627030ca, 0x984dc39d, + 0x370951da, 0x1db5e152, 0xb2f17315, 0xc6580243, 0x691c9004, + 0x43a0208c, 0xece4b2cb, 0x16d9419c, 0xb99dd3db, 0x93216353, + 0x3c65f114, 0xbc2b83bc, 0x136f11fb, 0x39d3a173, 0x96973334, + 0x6caac063, 0xc3ee5224, 0xe952e2ac, 0x461670eb, 0x657e037a, + 0xca3a913d, 0xe08621b5, 0x4fc2b3f2, 0xb5ff40a5, 0x1abbd2e2, + 0x3007626a, 0x9f43f02d, 0x1f0d8285, 0xb04910c2, 0x9af5a04a, + 0x35b1320d, 0xcf8cc15a, 0x60c8531d, 0x4a74e395, 0xe53071d2, + 0x91990084, 0x3edd92c3, 0x1461224b, 0xbb25b00c, 0x4118435b, + 0xee5cd11c, 0xc4e06194, 0x6ba4f3d3, 0xebea817b, 0x44ae133c, + 0x6e12a3b4, 0xc15631f3, 0x3b6bc2a4, 0x942f50e3, 0xbe93e06b, + 0x11d7722c, 0x57c102c7, 0xf8859080, 0xd2392008, 0x7d7db24f, + 0x87404118, 0x2804d35f, 0x02b863d7, 0xadfcf190, 0x2db28338, + 0x82f6117f, 0xa84aa1f7, 0x070e33b0, 0xfd33c0e7, 0x527752a0, + 0x78cbe228, 0xd78f706f, 0xa3260139, 0x0c62937e, 0x26de23f6, + 0x899ab1b1, 0x73a742e6, 0xdce3d0a1, 0xf65f6029, 0x591bf26e, + 0xd95580c6, 0x76111281, 0x5cada209, 0xf3e9304e, 0x09d4c319, + 0xa690515e, 0x8c2ce1d6, 0x23687391, 0xcafc06f4, 0x65b894b3, + 0x4f04243b, 0xe040b67c, 0x1a7d452b, 0xb539d76c, 0x9f8567e4, + 0x30c1f5a3, 0xb08f870b, 0x1fcb154c, 0x3577a5c4, 0x9a333783, + 0x600ec4d4, 0xcf4a5693, 0xe5f6e61b, 0x4ab2745c, 0x3e1b050a, + 0x915f974d, 0xbbe327c5, 0x14a7b582, 0xee9a46d5, 0x41ded492, + 0x6b62641a, 0xc426f65d, 0x446884f5, 0xeb2c16b2, 0xc190a63a, + 0x6ed4347d, 0x94e9c72a, 0x3bad556d, 0x1111e5e5, 0xbe5577a2, + 0xf8430749, 0x5707950e, 0x7dbb2586, 0xd2ffb7c1, 0x28c24496, + 0x8786d6d1, 0xad3a6659, 0x027ef41e, 0x823086b6, 0x2d7414f1, + 0x07c8a479, 0xa88c363e, 0x52b1c569, 0xfdf5572e, 0xd749e7a6, + 0x780d75e1, 0x0ca404b7, 0xa3e096f0, 0x895c2678, 0x2618b43f, + 0xdc254768, 0x7361d52f, 0x59dd65a7, 0xf699f7e0, 0x76d78548, + 0xd993170f, 0xf32fa787, 0x5c6b35c0, 0xa656c697, 0x091254d0, + 0x23aee458, 0x8cea761f, 0xaf82058e, 0x00c697c9, 0x2a7a2741, + 0x853eb506, 0x7f034651, 0xd047d416, 0xfafb649e, 0x55bff6d9, + 0xd5f18471, 0x7ab51636, 0x5009a6be, 0xff4d34f9, 0x0570c7ae, + 0xaa3455e9, 0x8088e561, 0x2fcc7726, 0x5b650670, 0xf4219437, + 0xde9d24bf, 0x71d9b6f8, 0x8be445af, 0x24a0d7e8, 0x0e1c6760, + 0xa158f527, 0x2116878f, 0x8e5215c8, 0xa4eea540, 0x0baa3707, + 0xf197c450, 0x5ed35617, 0x746fe69f, 0xdb2b74d8, 0x9d3d0433, + 0x32799674, 0x18c526fc, 0xb781b4bb, 0x4dbc47ec, 0xe2f8d5ab, + 0xc8446523, 0x6700f764, 0xe74e85cc, 0x480a178b, 0x62b6a703, + 0xcdf23544, 0x37cfc613, 0x988b5454, 0xb237e4dc, 0x1d73769b, + 0x69da07cd, 0xc69e958a, 0xec222502, 0x4366b745, 0xb95b4412, + 0x161fd655, 0x3ca366dd, 0x93e7f49a, 0x13a98632, 0xbced1475, + 0x9651a4fd, 0x391536ba, 0xc328c5ed, 0x6c6c57aa, 0x46d0e722, + 0xe9947565}, + {0x00000000, 0x4e890ba9, 0x9d121752, 0xd39b1cfb, 0xe15528e5, + 0xafdc234c, 0x7c473fb7, 0x32ce341e, 0x19db578b, 0x57525c22, + 0x84c940d9, 0xca404b70, 0xf88e7f6e, 0xb60774c7, 0x659c683c, + 0x2b156395, 0x33b6af16, 0x7d3fa4bf, 0xaea4b844, 0xe02db3ed, + 0xd2e387f3, 0x9c6a8c5a, 0x4ff190a1, 0x01789b08, 0x2a6df89d, + 0x64e4f334, 0xb77fefcf, 0xf9f6e466, 0xcb38d078, 0x85b1dbd1, + 0x562ac72a, 0x18a3cc83, 0x676d5e2c, 0x29e45585, 0xfa7f497e, + 0xb4f642d7, 0x863876c9, 0xc8b17d60, 0x1b2a619b, 0x55a36a32, + 0x7eb609a7, 0x303f020e, 0xe3a41ef5, 0xad2d155c, 0x9fe32142, + 0xd16a2aeb, 0x02f13610, 0x4c783db9, 0x54dbf13a, 0x1a52fa93, + 0xc9c9e668, 0x8740edc1, 0xb58ed9df, 0xfb07d276, 0x289cce8d, + 0x6615c524, 0x4d00a6b1, 0x0389ad18, 0xd012b1e3, 0x9e9bba4a, + 0xac558e54, 0xe2dc85fd, 0x31479906, 0x7fce92af, 0xcedabc58, + 0x8053b7f1, 0x53c8ab0a, 0x1d41a0a3, 0x2f8f94bd, 0x61069f14, + 0xb29d83ef, 0xfc148846, 0xd701ebd3, 0x9988e07a, 0x4a13fc81, + 0x049af728, 0x3654c336, 0x78ddc89f, 0xab46d464, 0xe5cfdfcd, + 0xfd6c134e, 0xb3e518e7, 0x607e041c, 0x2ef70fb5, 0x1c393bab, + 0x52b03002, 0x812b2cf9, 0xcfa22750, 0xe4b744c5, 0xaa3e4f6c, + 0x79a55397, 0x372c583e, 0x05e26c20, 0x4b6b6789, 0x98f07b72, + 0xd67970db, 0xa9b7e274, 0xe73ee9dd, 0x34a5f526, 0x7a2cfe8f, + 0x48e2ca91, 0x066bc138, 0xd5f0ddc3, 0x9b79d66a, 0xb06cb5ff, + 0xfee5be56, 0x2d7ea2ad, 0x63f7a904, 0x51399d1a, 0x1fb096b3, + 0xcc2b8a48, 0x82a281e1, 0x9a014d62, 0xd48846cb, 0x07135a30, + 0x499a5199, 0x7b546587, 0x35dd6e2e, 0xe64672d5, 0xa8cf797c, + 0x83da1ae9, 0xcd531140, 0x1ec80dbb, 0x50410612, 0x628f320c, + 0x2c0639a5, 0xff9d255e, 0xb1142ef7, 0x46c47ef1, 0x084d7558, + 0xdbd669a3, 0x955f620a, 0xa7915614, 0xe9185dbd, 0x3a834146, + 0x740a4aef, 0x5f1f297a, 0x119622d3, 0xc20d3e28, 0x8c843581, + 0xbe4a019f, 0xf0c30a36, 0x235816cd, 0x6dd11d64, 0x7572d1e7, + 0x3bfbda4e, 0xe860c6b5, 0xa6e9cd1c, 0x9427f902, 0xdaaef2ab, + 0x0935ee50, 0x47bce5f9, 0x6ca9866c, 0x22208dc5, 0xf1bb913e, + 0xbf329a97, 0x8dfcae89, 0xc375a520, 0x10eeb9db, 0x5e67b272, + 0x21a920dd, 0x6f202b74, 0xbcbb378f, 0xf2323c26, 0xc0fc0838, + 0x8e750391, 0x5dee1f6a, 0x136714c3, 0x38727756, 0x76fb7cff, + 0xa5606004, 0xebe96bad, 0xd9275fb3, 0x97ae541a, 0x443548e1, + 0x0abc4348, 0x121f8fcb, 0x5c968462, 0x8f0d9899, 0xc1849330, + 0xf34aa72e, 0xbdc3ac87, 0x6e58b07c, 0x20d1bbd5, 0x0bc4d840, + 0x454dd3e9, 0x96d6cf12, 0xd85fc4bb, 0xea91f0a5, 0xa418fb0c, + 0x7783e7f7, 0x390aec5e, 0x881ec2a9, 0xc697c900, 0x150cd5fb, + 0x5b85de52, 0x694bea4c, 0x27c2e1e5, 0xf459fd1e, 0xbad0f6b7, + 0x91c59522, 0xdf4c9e8b, 0x0cd78270, 0x425e89d9, 0x7090bdc7, + 0x3e19b66e, 0xed82aa95, 0xa30ba13c, 0xbba86dbf, 0xf5216616, + 0x26ba7aed, 0x68337144, 0x5afd455a, 0x14744ef3, 0xc7ef5208, + 0x896659a1, 0xa2733a34, 0xecfa319d, 0x3f612d66, 0x71e826cf, + 0x432612d1, 0x0daf1978, 0xde340583, 0x90bd0e2a, 0xef739c85, + 0xa1fa972c, 0x72618bd7, 0x3ce8807e, 0x0e26b460, 0x40afbfc9, + 0x9334a332, 0xddbda89b, 0xf6a8cb0e, 0xb821c0a7, 0x6bbadc5c, + 0x2533d7f5, 0x17fde3eb, 0x5974e842, 0x8aeff4b9, 0xc466ff10, + 0xdcc53393, 0x924c383a, 0x41d724c1, 0x0f5e2f68, 0x3d901b76, + 0x731910df, 0xa0820c24, 0xee0b078d, 0xc51e6418, 0x8b976fb1, + 0x580c734a, 0x168578e3, 0x244b4cfd, 0x6ac24754, 0xb9595baf, + 0xf7d05006}, + {0x00000000, 0x8d88fde2, 0xc060fd85, 0x4de80067, 0x5bb0fd4b, + 0xd63800a9, 0x9bd000ce, 0x1658fd2c, 0xb761fa96, 0x3ae90774, + 0x77010713, 0xfa89faf1, 0xecd107dd, 0x6159fa3f, 0x2cb1fa58, + 0xa13907ba, 0xb5b2f36d, 0x383a0e8f, 0x75d20ee8, 0xf85af30a, + 0xee020e26, 0x638af3c4, 0x2e62f3a3, 0xa3ea0e41, 0x02d309fb, + 0x8f5bf419, 0xc2b3f47e, 0x4f3b099c, 0x5963f4b0, 0xd4eb0952, + 0x99030935, 0x148bf4d7, 0xb014e09b, 0x3d9c1d79, 0x70741d1e, + 0xfdfce0fc, 0xeba41dd0, 0x662ce032, 0x2bc4e055, 0xa64c1db7, + 0x07751a0d, 0x8afde7ef, 0xc715e788, 0x4a9d1a6a, 0x5cc5e746, + 0xd14d1aa4, 0x9ca51ac3, 0x112de721, 0x05a613f6, 0x882eee14, + 0xc5c6ee73, 0x484e1391, 0x5e16eebd, 0xd39e135f, 0x9e761338, + 0x13feeeda, 0xb2c7e960, 0x3f4f1482, 0x72a714e5, 0xff2fe907, + 0xe977142b, 0x64ffe9c9, 0x2917e9ae, 0xa49f144c, 0xbb58c777, + 0x36d03a95, 0x7b383af2, 0xf6b0c710, 0xe0e83a3c, 0x6d60c7de, + 0x2088c7b9, 0xad003a5b, 0x0c393de1, 0x81b1c003, 0xcc59c064, + 0x41d13d86, 0x5789c0aa, 0xda013d48, 0x97e93d2f, 0x1a61c0cd, + 0x0eea341a, 0x8362c9f8, 0xce8ac99f, 0x4302347d, 0x555ac951, + 0xd8d234b3, 0x953a34d4, 0x18b2c936, 0xb98bce8c, 0x3403336e, + 0x79eb3309, 0xf463ceeb, 0xe23b33c7, 0x6fb3ce25, 0x225bce42, + 0xafd333a0, 0x0b4c27ec, 0x86c4da0e, 0xcb2cda69, 0x46a4278b, + 0x50fcdaa7, 0xdd742745, 0x909c2722, 0x1d14dac0, 0xbc2ddd7a, + 0x31a52098, 0x7c4d20ff, 0xf1c5dd1d, 0xe79d2031, 0x6a15ddd3, + 0x27fdddb4, 0xaa752056, 0xbefed481, 0x33762963, 0x7e9e2904, + 0xf316d4e6, 0xe54e29ca, 0x68c6d428, 0x252ed44f, 0xa8a629ad, + 0x099f2e17, 0x8417d3f5, 0xc9ffd392, 0x44772e70, 0x522fd35c, + 0xdfa72ebe, 0x924f2ed9, 0x1fc7d33b, 0xadc088af, 0x2048754d, + 0x6da0752a, 0xe02888c8, 0xf67075e4, 0x7bf88806, 0x36108861, + 0xbb987583, 0x1aa17239, 0x97298fdb, 0xdac18fbc, 0x5749725e, + 0x41118f72, 0xcc997290, 0x817172f7, 0x0cf98f15, 0x18727bc2, + 0x95fa8620, 0xd8128647, 0x559a7ba5, 0x43c28689, 0xce4a7b6b, + 0x83a27b0c, 0x0e2a86ee, 0xaf138154, 0x229b7cb6, 0x6f737cd1, + 0xe2fb8133, 0xf4a37c1f, 0x792b81fd, 0x34c3819a, 0xb94b7c78, + 0x1dd46834, 0x905c95d6, 0xddb495b1, 0x503c6853, 0x4664957f, + 0xcbec689d, 0x860468fa, 0x0b8c9518, 0xaab592a2, 0x273d6f40, + 0x6ad56f27, 0xe75d92c5, 0xf1056fe9, 0x7c8d920b, 0x3165926c, + 0xbced6f8e, 0xa8669b59, 0x25ee66bb, 0x680666dc, 0xe58e9b3e, + 0xf3d66612, 0x7e5e9bf0, 0x33b69b97, 0xbe3e6675, 0x1f0761cf, + 0x928f9c2d, 0xdf679c4a, 0x52ef61a8, 0x44b79c84, 0xc93f6166, + 0x84d76101, 0x095f9ce3, 0x16984fd8, 0x9b10b23a, 0xd6f8b25d, + 0x5b704fbf, 0x4d28b293, 0xc0a04f71, 0x8d484f16, 0x00c0b2f4, + 0xa1f9b54e, 0x2c7148ac, 0x619948cb, 0xec11b529, 0xfa494805, + 0x77c1b5e7, 0x3a29b580, 0xb7a14862, 0xa32abcb5, 0x2ea24157, + 0x634a4130, 0xeec2bcd2, 0xf89a41fe, 0x7512bc1c, 0x38fabc7b, + 0xb5724199, 0x144b4623, 0x99c3bbc1, 0xd42bbba6, 0x59a34644, + 0x4ffbbb68, 0xc273468a, 0x8f9b46ed, 0x0213bb0f, 0xa68caf43, + 0x2b0452a1, 0x66ec52c6, 0xeb64af24, 0xfd3c5208, 0x70b4afea, + 0x3d5caf8d, 0xb0d4526f, 0x11ed55d5, 0x9c65a837, 0xd18da850, + 0x5c0555b2, 0x4a5da89e, 0xc7d5557c, 0x8a3d551b, 0x07b5a8f9, + 0x133e5c2e, 0x9eb6a1cc, 0xd35ea1ab, 0x5ed65c49, 0x488ea165, + 0xc5065c87, 0x88ee5ce0, 0x0566a102, 0xa45fa6b8, 0x29d75b5a, + 0x643f5b3d, 0xe9b7a6df, 0xffef5bf3, 0x7267a611, 0x3f8fa676, + 0xb2075b94}, + {0x00000000, 0x80f0171f, 0xda91287f, 0x5a613f60, 0x6e5356bf, + 0xeea341a0, 0xb4c27ec0, 0x343269df, 0xdca6ad7e, 0x5c56ba61, + 0x06378501, 0x86c7921e, 0xb2f5fbc1, 0x3205ecde, 0x6864d3be, + 0xe894c4a1, 0x623c5cbd, 0xe2cc4ba2, 0xb8ad74c2, 0x385d63dd, + 0x0c6f0a02, 0x8c9f1d1d, 0xd6fe227d, 0x560e3562, 0xbe9af1c3, + 0x3e6ae6dc, 0x640bd9bc, 0xe4fbcea3, 0xd0c9a77c, 0x5039b063, + 0x0a588f03, 0x8aa8981c, 0xc478b97a, 0x4488ae65, 0x1ee99105, + 0x9e19861a, 0xaa2befc5, 0x2adbf8da, 0x70bac7ba, 0xf04ad0a5, + 0x18de1404, 0x982e031b, 0xc24f3c7b, 0x42bf2b64, 0x768d42bb, + 0xf67d55a4, 0xac1c6ac4, 0x2cec7ddb, 0xa644e5c7, 0x26b4f2d8, + 0x7cd5cdb8, 0xfc25daa7, 0xc817b378, 0x48e7a467, 0x12869b07, + 0x92768c18, 0x7ae248b9, 0xfa125fa6, 0xa07360c6, 0x208377d9, + 0x14b11e06, 0x94410919, 0xce203679, 0x4ed02166, 0x538074b5, + 0xd37063aa, 0x89115cca, 0x09e14bd5, 0x3dd3220a, 0xbd233515, + 0xe7420a75, 0x67b21d6a, 0x8f26d9cb, 0x0fd6ced4, 0x55b7f1b4, + 0xd547e6ab, 0xe1758f74, 0x6185986b, 0x3be4a70b, 0xbb14b014, + 0x31bc2808, 0xb14c3f17, 0xeb2d0077, 0x6bdd1768, 0x5fef7eb7, + 0xdf1f69a8, 0x857e56c8, 0x058e41d7, 0xed1a8576, 0x6dea9269, + 0x378bad09, 0xb77bba16, 0x8349d3c9, 0x03b9c4d6, 0x59d8fbb6, + 0xd928eca9, 0x97f8cdcf, 0x1708dad0, 0x4d69e5b0, 0xcd99f2af, + 0xf9ab9b70, 0x795b8c6f, 0x233ab30f, 0xa3caa410, 0x4b5e60b1, + 0xcbae77ae, 0x91cf48ce, 0x113f5fd1, 0x250d360e, 0xa5fd2111, + 0xff9c1e71, 0x7f6c096e, 0xf5c49172, 0x7534866d, 0x2f55b90d, + 0xafa5ae12, 0x9b97c7cd, 0x1b67d0d2, 0x4106efb2, 0xc1f6f8ad, + 0x29623c0c, 0xa9922b13, 0xf3f31473, 0x7303036c, 0x47316ab3, + 0xc7c17dac, 0x9da042cc, 0x1d5055d3, 0xa700e96a, 0x27f0fe75, + 0x7d91c115, 0xfd61d60a, 0xc953bfd5, 0x49a3a8ca, 0x13c297aa, + 0x933280b5, 0x7ba64414, 0xfb56530b, 0xa1376c6b, 0x21c77b74, + 0x15f512ab, 0x950505b4, 0xcf643ad4, 0x4f942dcb, 0xc53cb5d7, + 0x45cca2c8, 0x1fad9da8, 0x9f5d8ab7, 0xab6fe368, 0x2b9ff477, + 0x71fecb17, 0xf10edc08, 0x199a18a9, 0x996a0fb6, 0xc30b30d6, + 0x43fb27c9, 0x77c94e16, 0xf7395909, 0xad586669, 0x2da87176, + 0x63785010, 0xe388470f, 0xb9e9786f, 0x39196f70, 0x0d2b06af, + 0x8ddb11b0, 0xd7ba2ed0, 0x574a39cf, 0xbfdefd6e, 0x3f2eea71, + 0x654fd511, 0xe5bfc20e, 0xd18dabd1, 0x517dbcce, 0x0b1c83ae, + 0x8bec94b1, 0x01440cad, 0x81b41bb2, 0xdbd524d2, 0x5b2533cd, + 0x6f175a12, 0xefe74d0d, 0xb586726d, 0x35766572, 0xdde2a1d3, + 0x5d12b6cc, 0x077389ac, 0x87839eb3, 0xb3b1f76c, 0x3341e073, + 0x6920df13, 0xe9d0c80c, 0xf4809ddf, 0x74708ac0, 0x2e11b5a0, + 0xaee1a2bf, 0x9ad3cb60, 0x1a23dc7f, 0x4042e31f, 0xc0b2f400, + 0x282630a1, 0xa8d627be, 0xf2b718de, 0x72470fc1, 0x4675661e, + 0xc6857101, 0x9ce44e61, 0x1c14597e, 0x96bcc162, 0x164cd67d, + 0x4c2de91d, 0xccddfe02, 0xf8ef97dd, 0x781f80c2, 0x227ebfa2, + 0xa28ea8bd, 0x4a1a6c1c, 0xcaea7b03, 0x908b4463, 0x107b537c, + 0x24493aa3, 0xa4b92dbc, 0xfed812dc, 0x7e2805c3, 0x30f824a5, + 0xb00833ba, 0xea690cda, 0x6a991bc5, 0x5eab721a, 0xde5b6505, + 0x843a5a65, 0x04ca4d7a, 0xec5e89db, 0x6cae9ec4, 0x36cfa1a4, + 0xb63fb6bb, 0x820ddf64, 0x02fdc87b, 0x589cf71b, 0xd86ce004, + 0x52c47818, 0xd2346f07, 0x88555067, 0x08a54778, 0x3c972ea7, + 0xbc6739b8, 0xe60606d8, 0x66f611c7, 0x8e62d566, 0x0e92c279, + 0x54f3fd19, 0xd403ea06, 0xe03183d9, 0x60c194c6, 0x3aa0aba6, + 0xba50bcb9}, + {0x00000000, 0x9570d495, 0xf190af6b, 0x64e07bfe, 0x38505897, + 0xad208c02, 0xc9c0f7fc, 0x5cb02369, 0x70a0b12e, 0xe5d065bb, + 0x81301e45, 0x1440cad0, 0x48f0e9b9, 0xdd803d2c, 0xb96046d2, + 0x2c109247, 0xe141625c, 0x7431b6c9, 0x10d1cd37, 0x85a119a2, + 0xd9113acb, 0x4c61ee5e, 0x288195a0, 0xbdf14135, 0x91e1d372, + 0x049107e7, 0x60717c19, 0xf501a88c, 0xa9b18be5, 0x3cc15f70, + 0x5821248e, 0xcd51f01b, 0x19f3c2f9, 0x8c83166c, 0xe8636d92, + 0x7d13b907, 0x21a39a6e, 0xb4d34efb, 0xd0333505, 0x4543e190, + 0x695373d7, 0xfc23a742, 0x98c3dcbc, 0x0db30829, 0x51032b40, + 0xc473ffd5, 0xa093842b, 0x35e350be, 0xf8b2a0a5, 0x6dc27430, + 0x09220fce, 0x9c52db5b, 0xc0e2f832, 0x55922ca7, 0x31725759, + 0xa40283cc, 0x8812118b, 0x1d62c51e, 0x7982bee0, 0xecf26a75, + 0xb042491c, 0x25329d89, 0x41d2e677, 0xd4a232e2, 0x33e785f2, + 0xa6975167, 0xc2772a99, 0x5707fe0c, 0x0bb7dd65, 0x9ec709f0, + 0xfa27720e, 0x6f57a69b, 0x434734dc, 0xd637e049, 0xb2d79bb7, + 0x27a74f22, 0x7b176c4b, 0xee67b8de, 0x8a87c320, 0x1ff717b5, + 0xd2a6e7ae, 0x47d6333b, 0x233648c5, 0xb6469c50, 0xeaf6bf39, + 0x7f866bac, 0x1b661052, 0x8e16c4c7, 0xa2065680, 0x37768215, + 0x5396f9eb, 0xc6e62d7e, 0x9a560e17, 0x0f26da82, 0x6bc6a17c, + 0xfeb675e9, 0x2a14470b, 0xbf64939e, 0xdb84e860, 0x4ef43cf5, + 0x12441f9c, 0x8734cb09, 0xe3d4b0f7, 0x76a46462, 0x5ab4f625, + 0xcfc422b0, 0xab24594e, 0x3e548ddb, 0x62e4aeb2, 0xf7947a27, + 0x937401d9, 0x0604d54c, 0xcb552557, 0x5e25f1c2, 0x3ac58a3c, + 0xafb55ea9, 0xf3057dc0, 0x6675a955, 0x0295d2ab, 0x97e5063e, + 0xbbf59479, 0x2e8540ec, 0x4a653b12, 0xdf15ef87, 0x83a5ccee, + 0x16d5187b, 0x72356385, 0xe745b710, 0x67cf0be4, 0xf2bfdf71, + 0x965fa48f, 0x032f701a, 0x5f9f5373, 0xcaef87e6, 0xae0ffc18, + 0x3b7f288d, 0x176fbaca, 0x821f6e5f, 0xe6ff15a1, 0x738fc134, + 0x2f3fe25d, 0xba4f36c8, 0xdeaf4d36, 0x4bdf99a3, 0x868e69b8, + 0x13febd2d, 0x771ec6d3, 0xe26e1246, 0xbede312f, 0x2baee5ba, + 0x4f4e9e44, 0xda3e4ad1, 0xf62ed896, 0x635e0c03, 0x07be77fd, + 0x92cea368, 0xce7e8001, 0x5b0e5494, 0x3fee2f6a, 0xaa9efbff, + 0x7e3cc91d, 0xeb4c1d88, 0x8fac6676, 0x1adcb2e3, 0x466c918a, + 0xd31c451f, 0xb7fc3ee1, 0x228cea74, 0x0e9c7833, 0x9becaca6, + 0xff0cd758, 0x6a7c03cd, 0x36cc20a4, 0xa3bcf431, 0xc75c8fcf, + 0x522c5b5a, 0x9f7dab41, 0x0a0d7fd4, 0x6eed042a, 0xfb9dd0bf, + 0xa72df3d6, 0x325d2743, 0x56bd5cbd, 0xc3cd8828, 0xefdd1a6f, + 0x7aadcefa, 0x1e4db504, 0x8b3d6191, 0xd78d42f8, 0x42fd966d, + 0x261ded93, 0xb36d3906, 0x54288e16, 0xc1585a83, 0xa5b8217d, + 0x30c8f5e8, 0x6c78d681, 0xf9080214, 0x9de879ea, 0x0898ad7f, + 0x24883f38, 0xb1f8ebad, 0xd5189053, 0x406844c6, 0x1cd867af, + 0x89a8b33a, 0xed48c8c4, 0x78381c51, 0xb569ec4a, 0x201938df, + 0x44f94321, 0xd18997b4, 0x8d39b4dd, 0x18496048, 0x7ca91bb6, + 0xe9d9cf23, 0xc5c95d64, 0x50b989f1, 0x3459f20f, 0xa129269a, + 0xfd9905f3, 0x68e9d166, 0x0c09aa98, 0x99797e0d, 0x4ddb4cef, + 0xd8ab987a, 0xbc4be384, 0x293b3711, 0x758b1478, 0xe0fbc0ed, + 0x841bbb13, 0x116b6f86, 0x3d7bfdc1, 0xa80b2954, 0xcceb52aa, + 0x599b863f, 0x052ba556, 0x905b71c3, 0xf4bb0a3d, 0x61cbdea8, + 0xac9a2eb3, 0x39eafa26, 0x5d0a81d8, 0xc87a554d, 0x94ca7624, + 0x01baa2b1, 0x655ad94f, 0xf02a0dda, 0xdc3a9f9d, 0x494a4b08, + 0x2daa30f6, 0xb8dae463, 0xe46ac70a, 0x711a139f, 0x15fa6861, + 0x808abcf4}, + {0x00000000, 0xcf9e17c8, 0x444d29d1, 0x8bd33e19, 0x889a53a2, + 0x4704446a, 0xccd77a73, 0x03496dbb, 0xca45a105, 0x05dbb6cd, + 0x8e0888d4, 0x41969f1c, 0x42dff2a7, 0x8d41e56f, 0x0692db76, + 0xc90cccbe, 0x4ffa444b, 0x80645383, 0x0bb76d9a, 0xc4297a52, + 0xc76017e9, 0x08fe0021, 0x832d3e38, 0x4cb329f0, 0x85bfe54e, + 0x4a21f286, 0xc1f2cc9f, 0x0e6cdb57, 0x0d25b6ec, 0xc2bba124, + 0x49689f3d, 0x86f688f5, 0x9ff48896, 0x506a9f5e, 0xdbb9a147, + 0x1427b68f, 0x176edb34, 0xd8f0ccfc, 0x5323f2e5, 0x9cbde52d, + 0x55b12993, 0x9a2f3e5b, 0x11fc0042, 0xde62178a, 0xdd2b7a31, + 0x12b56df9, 0x996653e0, 0x56f84428, 0xd00eccdd, 0x1f90db15, + 0x9443e50c, 0x5bddf2c4, 0x58949f7f, 0x970a88b7, 0x1cd9b6ae, + 0xd347a166, 0x1a4b6dd8, 0xd5d57a10, 0x5e064409, 0x919853c1, + 0x92d13e7a, 0x5d4f29b2, 0xd69c17ab, 0x19020063, 0xe498176d, + 0x2b0600a5, 0xa0d53ebc, 0x6f4b2974, 0x6c0244cf, 0xa39c5307, + 0x284f6d1e, 0xe7d17ad6, 0x2eddb668, 0xe143a1a0, 0x6a909fb9, + 0xa50e8871, 0xa647e5ca, 0x69d9f202, 0xe20acc1b, 0x2d94dbd3, + 0xab625326, 0x64fc44ee, 0xef2f7af7, 0x20b16d3f, 0x23f80084, + 0xec66174c, 0x67b52955, 0xa82b3e9d, 0x6127f223, 0xaeb9e5eb, + 0x256adbf2, 0xeaf4cc3a, 0xe9bda181, 0x2623b649, 0xadf08850, + 0x626e9f98, 0x7b6c9ffb, 0xb4f28833, 0x3f21b62a, 0xf0bfa1e2, + 0xf3f6cc59, 0x3c68db91, 0xb7bbe588, 0x7825f240, 0xb1293efe, + 0x7eb72936, 0xf564172f, 0x3afa00e7, 0x39b36d5c, 0xf62d7a94, + 0x7dfe448d, 0xb2605345, 0x3496dbb0, 0xfb08cc78, 0x70dbf261, + 0xbf45e5a9, 0xbc0c8812, 0x73929fda, 0xf841a1c3, 0x37dfb60b, + 0xfed37ab5, 0x314d6d7d, 0xba9e5364, 0x750044ac, 0x76492917, + 0xb9d73edf, 0x320400c6, 0xfd9a170e, 0x1241289b, 0xdddf3f53, + 0x560c014a, 0x99921682, 0x9adb7b39, 0x55456cf1, 0xde9652e8, + 0x11084520, 0xd804899e, 0x179a9e56, 0x9c49a04f, 0x53d7b787, + 0x509eda3c, 0x9f00cdf4, 0x14d3f3ed, 0xdb4de425, 0x5dbb6cd0, + 0x92257b18, 0x19f64501, 0xd66852c9, 0xd5213f72, 0x1abf28ba, + 0x916c16a3, 0x5ef2016b, 0x97fecdd5, 0x5860da1d, 0xd3b3e404, + 0x1c2df3cc, 0x1f649e77, 0xd0fa89bf, 0x5b29b7a6, 0x94b7a06e, + 0x8db5a00d, 0x422bb7c5, 0xc9f889dc, 0x06669e14, 0x052ff3af, + 0xcab1e467, 0x4162da7e, 0x8efccdb6, 0x47f00108, 0x886e16c0, + 0x03bd28d9, 0xcc233f11, 0xcf6a52aa, 0x00f44562, 0x8b277b7b, + 0x44b96cb3, 0xc24fe446, 0x0dd1f38e, 0x8602cd97, 0x499cda5f, + 0x4ad5b7e4, 0x854ba02c, 0x0e989e35, 0xc10689fd, 0x080a4543, + 0xc794528b, 0x4c476c92, 0x83d97b5a, 0x809016e1, 0x4f0e0129, + 0xc4dd3f30, 0x0b4328f8, 0xf6d93ff6, 0x3947283e, 0xb2941627, + 0x7d0a01ef, 0x7e436c54, 0xb1dd7b9c, 0x3a0e4585, 0xf590524d, + 0x3c9c9ef3, 0xf302893b, 0x78d1b722, 0xb74fa0ea, 0xb406cd51, + 0x7b98da99, 0xf04be480, 0x3fd5f348, 0xb9237bbd, 0x76bd6c75, + 0xfd6e526c, 0x32f045a4, 0x31b9281f, 0xfe273fd7, 0x75f401ce, + 0xba6a1606, 0x7366dab8, 0xbcf8cd70, 0x372bf369, 0xf8b5e4a1, + 0xfbfc891a, 0x34629ed2, 0xbfb1a0cb, 0x702fb703, 0x692db760, + 0xa6b3a0a8, 0x2d609eb1, 0xe2fe8979, 0xe1b7e4c2, 0x2e29f30a, + 0xa5facd13, 0x6a64dadb, 0xa3681665, 0x6cf601ad, 0xe7253fb4, + 0x28bb287c, 0x2bf245c7, 0xe46c520f, 0x6fbf6c16, 0xa0217bde, + 0x26d7f32b, 0xe949e4e3, 0x629adafa, 0xad04cd32, 0xae4da089, + 0x61d3b741, 0xea008958, 0x259e9e90, 0xec92522e, 0x230c45e6, + 0xa8df7bff, 0x67416c37, 0x6408018c, 0xab961644, 0x2045285d, + 0xefdb3f95}, + {0x00000000, 0x24825136, 0x4904a26c, 0x6d86f35a, 0x920944d8, + 0xb68b15ee, 0xdb0de6b4, 0xff8fb782, 0xff638ff1, 0xdbe1dec7, + 0xb6672d9d, 0x92e57cab, 0x6d6acb29, 0x49e89a1f, 0x246e6945, + 0x00ec3873, 0x25b619a3, 0x01344895, 0x6cb2bbcf, 0x4830eaf9, + 0xb7bf5d7b, 0x933d0c4d, 0xfebbff17, 0xda39ae21, 0xdad59652, + 0xfe57c764, 0x93d1343e, 0xb7536508, 0x48dcd28a, 0x6c5e83bc, + 0x01d870e6, 0x255a21d0, 0x4b6c3346, 0x6fee6270, 0x0268912a, + 0x26eac01c, 0xd965779e, 0xfde726a8, 0x9061d5f2, 0xb4e384c4, + 0xb40fbcb7, 0x908ded81, 0xfd0b1edb, 0xd9894fed, 0x2606f86f, + 0x0284a959, 0x6f025a03, 0x4b800b35, 0x6eda2ae5, 0x4a587bd3, + 0x27de8889, 0x035cd9bf, 0xfcd36e3d, 0xd8513f0b, 0xb5d7cc51, + 0x91559d67, 0x91b9a514, 0xb53bf422, 0xd8bd0778, 0xfc3f564e, + 0x03b0e1cc, 0x2732b0fa, 0x4ab443a0, 0x6e361296, 0x96d8668c, + 0xb25a37ba, 0xdfdcc4e0, 0xfb5e95d6, 0x04d12254, 0x20537362, + 0x4dd58038, 0x6957d10e, 0x69bbe97d, 0x4d39b84b, 0x20bf4b11, + 0x043d1a27, 0xfbb2ada5, 0xdf30fc93, 0xb2b60fc9, 0x96345eff, + 0xb36e7f2f, 0x97ec2e19, 0xfa6add43, 0xdee88c75, 0x21673bf7, + 0x05e56ac1, 0x6863999b, 0x4ce1c8ad, 0x4c0df0de, 0x688fa1e8, + 0x050952b2, 0x218b0384, 0xde04b406, 0xfa86e530, 0x9700166a, + 0xb382475c, 0xddb455ca, 0xf93604fc, 0x94b0f7a6, 0xb032a690, + 0x4fbd1112, 0x6b3f4024, 0x06b9b37e, 0x223be248, 0x22d7da3b, + 0x06558b0d, 0x6bd37857, 0x4f512961, 0xb0de9ee3, 0x945ccfd5, + 0xf9da3c8f, 0xdd586db9, 0xf8024c69, 0xdc801d5f, 0xb106ee05, + 0x9584bf33, 0x6a0b08b1, 0x4e895987, 0x230faadd, 0x078dfbeb, + 0x0761c398, 0x23e392ae, 0x4e6561f4, 0x6ae730c2, 0x95688740, + 0xb1ead676, 0xdc6c252c, 0xf8ee741a, 0xf6c1cb59, 0xd2439a6f, + 0xbfc56935, 0x9b473803, 0x64c88f81, 0x404adeb7, 0x2dcc2ded, + 0x094e7cdb, 0x09a244a8, 0x2d20159e, 0x40a6e6c4, 0x6424b7f2, + 0x9bab0070, 0xbf295146, 0xd2afa21c, 0xf62df32a, 0xd377d2fa, + 0xf7f583cc, 0x9a737096, 0xbef121a0, 0x417e9622, 0x65fcc714, + 0x087a344e, 0x2cf86578, 0x2c145d0b, 0x08960c3d, 0x6510ff67, + 0x4192ae51, 0xbe1d19d3, 0x9a9f48e5, 0xf719bbbf, 0xd39bea89, + 0xbdadf81f, 0x992fa929, 0xf4a95a73, 0xd02b0b45, 0x2fa4bcc7, + 0x0b26edf1, 0x66a01eab, 0x42224f9d, 0x42ce77ee, 0x664c26d8, + 0x0bcad582, 0x2f4884b4, 0xd0c73336, 0xf4456200, 0x99c3915a, + 0xbd41c06c, 0x981be1bc, 0xbc99b08a, 0xd11f43d0, 0xf59d12e6, + 0x0a12a564, 0x2e90f452, 0x43160708, 0x6794563e, 0x67786e4d, + 0x43fa3f7b, 0x2e7ccc21, 0x0afe9d17, 0xf5712a95, 0xd1f37ba3, + 0xbc7588f9, 0x98f7d9cf, 0x6019add5, 0x449bfce3, 0x291d0fb9, + 0x0d9f5e8f, 0xf210e90d, 0xd692b83b, 0xbb144b61, 0x9f961a57, + 0x9f7a2224, 0xbbf87312, 0xd67e8048, 0xf2fcd17e, 0x0d7366fc, + 0x29f137ca, 0x4477c490, 0x60f595a6, 0x45afb476, 0x612de540, + 0x0cab161a, 0x2829472c, 0xd7a6f0ae, 0xf324a198, 0x9ea252c2, + 0xba2003f4, 0xbacc3b87, 0x9e4e6ab1, 0xf3c899eb, 0xd74ac8dd, + 0x28c57f5f, 0x0c472e69, 0x61c1dd33, 0x45438c05, 0x2b759e93, + 0x0ff7cfa5, 0x62713cff, 0x46f36dc9, 0xb97cda4b, 0x9dfe8b7d, + 0xf0787827, 0xd4fa2911, 0xd4161162, 0xf0944054, 0x9d12b30e, + 0xb990e238, 0x461f55ba, 0x629d048c, 0x0f1bf7d6, 0x2b99a6e0, + 0x0ec38730, 0x2a41d606, 0x47c7255c, 0x6345746a, 0x9ccac3e8, + 0xb84892de, 0xd5ce6184, 0xf14c30b2, 0xf1a008c1, 0xd52259f7, + 0xb8a4aaad, 0x9c26fb9b, 0x63a94c19, 0x472b1d2f, 0x2aadee75, + 0x0e2fbf43}, + {0x00000000, 0x36f290f3, 0x6de521e6, 0x5b17b115, 0xdbca43cc, + 0xed38d33f, 0xb62f622a, 0x80ddf2d9, 0x6ce581d9, 0x5a17112a, + 0x0100a03f, 0x37f230cc, 0xb72fc215, 0x81dd52e6, 0xdacae3f3, + 0xec387300, 0xd9cb03b2, 0xef399341, 0xb42e2254, 0x82dcb2a7, + 0x0201407e, 0x34f3d08d, 0x6fe46198, 0x5916f16b, 0xb52e826b, + 0x83dc1298, 0xd8cba38d, 0xee39337e, 0x6ee4c1a7, 0x58165154, + 0x0301e041, 0x35f370b2, 0x68e70125, 0x5e1591d6, 0x050220c3, + 0x33f0b030, 0xb32d42e9, 0x85dfd21a, 0xdec8630f, 0xe83af3fc, + 0x040280fc, 0x32f0100f, 0x69e7a11a, 0x5f1531e9, 0xdfc8c330, + 0xe93a53c3, 0xb22de2d6, 0x84df7225, 0xb12c0297, 0x87de9264, + 0xdcc92371, 0xea3bb382, 0x6ae6415b, 0x5c14d1a8, 0x070360bd, + 0x31f1f04e, 0xddc9834e, 0xeb3b13bd, 0xb02ca2a8, 0x86de325b, + 0x0603c082, 0x30f15071, 0x6be6e164, 0x5d147197, 0xd1ce024a, + 0xe73c92b9, 0xbc2b23ac, 0x8ad9b35f, 0x0a044186, 0x3cf6d175, + 0x67e16060, 0x5113f093, 0xbd2b8393, 0x8bd91360, 0xd0cea275, + 0xe63c3286, 0x66e1c05f, 0x501350ac, 0x0b04e1b9, 0x3df6714a, + 0x080501f8, 0x3ef7910b, 0x65e0201e, 0x5312b0ed, 0xd3cf4234, + 0xe53dd2c7, 0xbe2a63d2, 0x88d8f321, 0x64e08021, 0x521210d2, + 0x0905a1c7, 0x3ff73134, 0xbf2ac3ed, 0x89d8531e, 0xd2cfe20b, + 0xe43d72f8, 0xb929036f, 0x8fdb939c, 0xd4cc2289, 0xe23eb27a, + 0x62e340a3, 0x5411d050, 0x0f066145, 0x39f4f1b6, 0xd5cc82b6, + 0xe33e1245, 0xb829a350, 0x8edb33a3, 0x0e06c17a, 0x38f45189, + 0x63e3e09c, 0x5511706f, 0x60e200dd, 0x5610902e, 0x0d07213b, + 0x3bf5b1c8, 0xbb284311, 0x8ddad3e2, 0xd6cd62f7, 0xe03ff204, + 0x0c078104, 0x3af511f7, 0x61e2a0e2, 0x57103011, 0xd7cdc2c8, + 0xe13f523b, 0xba28e32e, 0x8cda73dd, 0x78ed02d5, 0x4e1f9226, + 0x15082333, 0x23fab3c0, 0xa3274119, 0x95d5d1ea, 0xcec260ff, + 0xf830f00c, 0x1408830c, 0x22fa13ff, 0x79eda2ea, 0x4f1f3219, + 0xcfc2c0c0, 0xf9305033, 0xa227e126, 0x94d571d5, 0xa1260167, + 0x97d49194, 0xccc32081, 0xfa31b072, 0x7aec42ab, 0x4c1ed258, + 0x1709634d, 0x21fbf3be, 0xcdc380be, 0xfb31104d, 0xa026a158, + 0x96d431ab, 0x1609c372, 0x20fb5381, 0x7bece294, 0x4d1e7267, + 0x100a03f0, 0x26f89303, 0x7def2216, 0x4b1db2e5, 0xcbc0403c, + 0xfd32d0cf, 0xa62561da, 0x90d7f129, 0x7cef8229, 0x4a1d12da, + 0x110aa3cf, 0x27f8333c, 0xa725c1e5, 0x91d75116, 0xcac0e003, + 0xfc3270f0, 0xc9c10042, 0xff3390b1, 0xa42421a4, 0x92d6b157, + 0x120b438e, 0x24f9d37d, 0x7fee6268, 0x491cf29b, 0xa524819b, + 0x93d61168, 0xc8c1a07d, 0xfe33308e, 0x7eeec257, 0x481c52a4, + 0x130be3b1, 0x25f97342, 0xa923009f, 0x9fd1906c, 0xc4c62179, + 0xf234b18a, 0x72e94353, 0x441bd3a0, 0x1f0c62b5, 0x29fef246, + 0xc5c68146, 0xf33411b5, 0xa823a0a0, 0x9ed13053, 0x1e0cc28a, + 0x28fe5279, 0x73e9e36c, 0x451b739f, 0x70e8032d, 0x461a93de, + 0x1d0d22cb, 0x2bffb238, 0xab2240e1, 0x9dd0d012, 0xc6c76107, + 0xf035f1f4, 0x1c0d82f4, 0x2aff1207, 0x71e8a312, 0x471a33e1, + 0xc7c7c138, 0xf13551cb, 0xaa22e0de, 0x9cd0702d, 0xc1c401ba, + 0xf7369149, 0xac21205c, 0x9ad3b0af, 0x1a0e4276, 0x2cfcd285, + 0x77eb6390, 0x4119f363, 0xad218063, 0x9bd31090, 0xc0c4a185, + 0xf6363176, 0x76ebc3af, 0x4019535c, 0x1b0ee249, 0x2dfc72ba, + 0x180f0208, 0x2efd92fb, 0x75ea23ee, 0x4318b31d, 0xc3c541c4, + 0xf537d137, 0xae206022, 0x98d2f0d1, 0x74ea83d1, 0x42181322, + 0x190fa237, 0x2ffd32c4, 0xaf20c01d, 0x99d250ee, 0xc2c5e1fb, + 0xf4377108}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0xf390f23600000000, 0xe621e56d00000000, + 0x15b1175b00000000, 0xcc43cadb00000000, 0x3fd338ed00000000, + 0x2a622fb600000000, 0xd9f2dd8000000000, 0xd981e56c00000000, + 0x2a11175a00000000, 0x3fa0000100000000, 0xcc30f23700000000, + 0x15c22fb700000000, 0xe652dd8100000000, 0xf3e3cada00000000, + 0x007338ec00000000, 0xb203cbd900000000, 0x419339ef00000000, + 0x54222eb400000000, 0xa7b2dc8200000000, 0x7e40010200000000, + 0x8dd0f33400000000, 0x9861e46f00000000, 0x6bf1165900000000, + 0x6b822eb500000000, 0x9812dc8300000000, 0x8da3cbd800000000, + 0x7e3339ee00000000, 0xa7c1e46e00000000, 0x5451165800000000, + 0x41e0010300000000, 0xb270f33500000000, 0x2501e76800000000, + 0xd691155e00000000, 0xc320020500000000, 0x30b0f03300000000, + 0xe9422db300000000, 0x1ad2df8500000000, 0x0f63c8de00000000, + 0xfcf33ae800000000, 0xfc80020400000000, 0x0f10f03200000000, + 0x1aa1e76900000000, 0xe931155f00000000, 0x30c3c8df00000000, + 0xc3533ae900000000, 0xd6e22db200000000, 0x2572df8400000000, + 0x97022cb100000000, 0x6492de8700000000, 0x7123c9dc00000000, + 0x82b33bea00000000, 0x5b41e66a00000000, 0xa8d1145c00000000, + 0xbd60030700000000, 0x4ef0f13100000000, 0x4e83c9dd00000000, + 0xbd133beb00000000, 0xa8a22cb000000000, 0x5b32de8600000000, + 0x82c0030600000000, 0x7150f13000000000, 0x64e1e66b00000000, + 0x9771145d00000000, 0x4a02ced100000000, 0xb9923ce700000000, + 0xac232bbc00000000, 0x5fb3d98a00000000, 0x8641040a00000000, + 0x75d1f63c00000000, 0x6060e16700000000, 0x93f0135100000000, + 0x93832bbd00000000, 0x6013d98b00000000, 0x75a2ced000000000, + 0x86323ce600000000, 0x5fc0e16600000000, 0xac50135000000000, + 0xb9e1040b00000000, 0x4a71f63d00000000, 0xf801050800000000, + 0x0b91f73e00000000, 0x1e20e06500000000, 0xedb0125300000000, + 0x3442cfd300000000, 0xc7d23de500000000, 0xd2632abe00000000, + 0x21f3d88800000000, 0x2180e06400000000, 0xd210125200000000, + 0xc7a1050900000000, 0x3431f73f00000000, 0xedc32abf00000000, + 0x1e53d88900000000, 0x0be2cfd200000000, 0xf8723de400000000, + 0x6f0329b900000000, 0x9c93db8f00000000, 0x8922ccd400000000, + 0x7ab23ee200000000, 0xa340e36200000000, 0x50d0115400000000, + 0x4561060f00000000, 0xb6f1f43900000000, 0xb682ccd500000000, + 0x45123ee300000000, 0x50a329b800000000, 0xa333db8e00000000, + 0x7ac1060e00000000, 0x8951f43800000000, 0x9ce0e36300000000, + 0x6f70115500000000, 0xdd00e26000000000, 0x2e90105600000000, + 0x3b21070d00000000, 0xc8b1f53b00000000, 0x114328bb00000000, + 0xe2d3da8d00000000, 0xf762cdd600000000, 0x04f23fe000000000, + 0x0481070c00000000, 0xf711f53a00000000, 0xe2a0e26100000000, + 0x1130105700000000, 0xc8c2cdd700000000, 0x3b523fe100000000, + 0x2ee328ba00000000, 0xdd73da8c00000000, 0xd502ed7800000000, + 0x26921f4e00000000, 0x3323081500000000, 0xc0b3fa2300000000, + 0x194127a300000000, 0xead1d59500000000, 0xff60c2ce00000000, + 0x0cf030f800000000, 0x0c83081400000000, 0xff13fa2200000000, + 0xeaa2ed7900000000, 0x19321f4f00000000, 0xc0c0c2cf00000000, + 0x335030f900000000, 0x26e127a200000000, 0xd571d59400000000, + 0x670126a100000000, 0x9491d49700000000, 0x8120c3cc00000000, + 0x72b031fa00000000, 0xab42ec7a00000000, 0x58d21e4c00000000, + 0x4d63091700000000, 0xbef3fb2100000000, 0xbe80c3cd00000000, + 0x4d1031fb00000000, 0x58a126a000000000, 0xab31d49600000000, + 0x72c3091600000000, 0x8153fb2000000000, 0x94e2ec7b00000000, + 0x67721e4d00000000, 0xf0030a1000000000, 0x0393f82600000000, + 0x1622ef7d00000000, 0xe5b21d4b00000000, 0x3c40c0cb00000000, + 0xcfd032fd00000000, 0xda6125a600000000, 0x29f1d79000000000, + 0x2982ef7c00000000, 0xda121d4a00000000, 0xcfa30a1100000000, + 0x3c33f82700000000, 0xe5c125a700000000, 0x1651d79100000000, + 0x03e0c0ca00000000, 0xf07032fc00000000, 0x4200c1c900000000, + 0xb19033ff00000000, 0xa42124a400000000, 0x57b1d69200000000, + 0x8e430b1200000000, 0x7dd3f92400000000, 0x6862ee7f00000000, + 0x9bf21c4900000000, 0x9b8124a500000000, 0x6811d69300000000, + 0x7da0c1c800000000, 0x8e3033fe00000000, 0x57c2ee7e00000000, + 0xa4521c4800000000, 0xb1e30b1300000000, 0x4273f92500000000, + 0x9f0023a900000000, 0x6c90d19f00000000, 0x7921c6c400000000, + 0x8ab134f200000000, 0x5343e97200000000, 0xa0d31b4400000000, + 0xb5620c1f00000000, 0x46f2fe2900000000, 0x4681c6c500000000, + 0xb51134f300000000, 0xa0a023a800000000, 0x5330d19e00000000, + 0x8ac20c1e00000000, 0x7952fe2800000000, 0x6ce3e97300000000, + 0x9f731b4500000000, 0x2d03e87000000000, 0xde931a4600000000, + 0xcb220d1d00000000, 0x38b2ff2b00000000, 0xe14022ab00000000, + 0x12d0d09d00000000, 0x0761c7c600000000, 0xf4f135f000000000, + 0xf4820d1c00000000, 0x0712ff2a00000000, 0x12a3e87100000000, + 0xe1331a4700000000, 0x38c1c7c700000000, 0xcb5135f100000000, + 0xdee022aa00000000, 0x2d70d09c00000000, 0xba01c4c100000000, + 0x499136f700000000, 0x5c2021ac00000000, 0xafb0d39a00000000, + 0x76420e1a00000000, 0x85d2fc2c00000000, 0x9063eb7700000000, + 0x63f3194100000000, 0x638021ad00000000, 0x9010d39b00000000, + 0x85a1c4c000000000, 0x763136f600000000, 0xafc3eb7600000000, + 0x5c53194000000000, 0x49e20e1b00000000, 0xba72fc2d00000000, + 0x08020f1800000000, 0xfb92fd2e00000000, 0xee23ea7500000000, + 0x1db3184300000000, 0xc441c5c300000000, 0x37d137f500000000, + 0x226020ae00000000, 0xd1f0d29800000000, 0xd183ea7400000000, + 0x2213184200000000, 0x37a20f1900000000, 0xc432fd2f00000000, + 0x1dc020af00000000, 0xee50d29900000000, 0xfbe1c5c200000000, + 0x087137f400000000}, + {0x0000000000000000, 0x3651822400000000, 0x6ca2044900000000, + 0x5af3866d00000000, 0xd844099200000000, 0xee158bb600000000, + 0xb4e60ddb00000000, 0x82b78fff00000000, 0xf18f63ff00000000, + 0xc7dee1db00000000, 0x9d2d67b600000000, 0xab7ce59200000000, + 0x29cb6a6d00000000, 0x1f9ae84900000000, 0x45696e2400000000, + 0x7338ec0000000000, 0xa319b62500000000, 0x9548340100000000, + 0xcfbbb26c00000000, 0xf9ea304800000000, 0x7b5dbfb700000000, + 0x4d0c3d9300000000, 0x17ffbbfe00000000, 0x21ae39da00000000, + 0x5296d5da00000000, 0x64c757fe00000000, 0x3e34d19300000000, + 0x086553b700000000, 0x8ad2dc4800000000, 0xbc835e6c00000000, + 0xe670d80100000000, 0xd0215a2500000000, 0x46336c4b00000000, + 0x7062ee6f00000000, 0x2a91680200000000, 0x1cc0ea2600000000, + 0x9e7765d900000000, 0xa826e7fd00000000, 0xf2d5619000000000, + 0xc484e3b400000000, 0xb7bc0fb400000000, 0x81ed8d9000000000, + 0xdb1e0bfd00000000, 0xed4f89d900000000, 0x6ff8062600000000, + 0x59a9840200000000, 0x035a026f00000000, 0x350b804b00000000, + 0xe52ada6e00000000, 0xd37b584a00000000, 0x8988de2700000000, + 0xbfd95c0300000000, 0x3d6ed3fc00000000, 0x0b3f51d800000000, + 0x51ccd7b500000000, 0x679d559100000000, 0x14a5b99100000000, + 0x22f43bb500000000, 0x7807bdd800000000, 0x4e563ffc00000000, + 0xcce1b00300000000, 0xfab0322700000000, 0xa043b44a00000000, + 0x9612366e00000000, 0x8c66d89600000000, 0xba375ab200000000, + 0xe0c4dcdf00000000, 0xd6955efb00000000, 0x5422d10400000000, + 0x6273532000000000, 0x3880d54d00000000, 0x0ed1576900000000, + 0x7de9bb6900000000, 0x4bb8394d00000000, 0x114bbf2000000000, + 0x271a3d0400000000, 0xa5adb2fb00000000, 0x93fc30df00000000, + 0xc90fb6b200000000, 0xff5e349600000000, 0x2f7f6eb300000000, + 0x192eec9700000000, 0x43dd6afa00000000, 0x758ce8de00000000, + 0xf73b672100000000, 0xc16ae50500000000, 0x9b99636800000000, + 0xadc8e14c00000000, 0xdef00d4c00000000, 0xe8a18f6800000000, + 0xb252090500000000, 0x84038b2100000000, 0x06b404de00000000, + 0x30e586fa00000000, 0x6a16009700000000, 0x5c4782b300000000, + 0xca55b4dd00000000, 0xfc0436f900000000, 0xa6f7b09400000000, + 0x90a632b000000000, 0x1211bd4f00000000, 0x24403f6b00000000, + 0x7eb3b90600000000, 0x48e23b2200000000, 0x3bdad72200000000, + 0x0d8b550600000000, 0x5778d36b00000000, 0x6129514f00000000, + 0xe39edeb000000000, 0xd5cf5c9400000000, 0x8f3cdaf900000000, + 0xb96d58dd00000000, 0x694c02f800000000, 0x5f1d80dc00000000, + 0x05ee06b100000000, 0x33bf849500000000, 0xb1080b6a00000000, + 0x8759894e00000000, 0xddaa0f2300000000, 0xebfb8d0700000000, + 0x98c3610700000000, 0xae92e32300000000, 0xf461654e00000000, + 0xc230e76a00000000, 0x4087689500000000, 0x76d6eab100000000, + 0x2c256cdc00000000, 0x1a74eef800000000, 0x59cbc1f600000000, + 0x6f9a43d200000000, 0x3569c5bf00000000, 0x0338479b00000000, + 0x818fc86400000000, 0xb7de4a4000000000, 0xed2dcc2d00000000, + 0xdb7c4e0900000000, 0xa844a20900000000, 0x9e15202d00000000, + 0xc4e6a64000000000, 0xf2b7246400000000, 0x7000ab9b00000000, + 0x465129bf00000000, 0x1ca2afd200000000, 0x2af32df600000000, + 0xfad277d300000000, 0xcc83f5f700000000, 0x9670739a00000000, + 0xa021f1be00000000, 0x22967e4100000000, 0x14c7fc6500000000, + 0x4e347a0800000000, 0x7865f82c00000000, 0x0b5d142c00000000, + 0x3d0c960800000000, 0x67ff106500000000, 0x51ae924100000000, + 0xd3191dbe00000000, 0xe5489f9a00000000, 0xbfbb19f700000000, + 0x89ea9bd300000000, 0x1ff8adbd00000000, 0x29a92f9900000000, + 0x735aa9f400000000, 0x450b2bd000000000, 0xc7bca42f00000000, + 0xf1ed260b00000000, 0xab1ea06600000000, 0x9d4f224200000000, + 0xee77ce4200000000, 0xd8264c6600000000, 0x82d5ca0b00000000, + 0xb484482f00000000, 0x3633c7d000000000, 0x006245f400000000, + 0x5a91c39900000000, 0x6cc041bd00000000, 0xbce11b9800000000, + 0x8ab099bc00000000, 0xd0431fd100000000, 0xe6129df500000000, + 0x64a5120a00000000, 0x52f4902e00000000, 0x0807164300000000, + 0x3e56946700000000, 0x4d6e786700000000, 0x7b3ffa4300000000, + 0x21cc7c2e00000000, 0x179dfe0a00000000, 0x952a71f500000000, + 0xa37bf3d100000000, 0xf98875bc00000000, 0xcfd9f79800000000, + 0xd5ad196000000000, 0xe3fc9b4400000000, 0xb90f1d2900000000, + 0x8f5e9f0d00000000, 0x0de910f200000000, 0x3bb892d600000000, + 0x614b14bb00000000, 0x571a969f00000000, 0x24227a9f00000000, + 0x1273f8bb00000000, 0x48807ed600000000, 0x7ed1fcf200000000, + 0xfc66730d00000000, 0xca37f12900000000, 0x90c4774400000000, + 0xa695f56000000000, 0x76b4af4500000000, 0x40e52d6100000000, + 0x1a16ab0c00000000, 0x2c47292800000000, 0xaef0a6d700000000, + 0x98a124f300000000, 0xc252a29e00000000, 0xf40320ba00000000, + 0x873bccba00000000, 0xb16a4e9e00000000, 0xeb99c8f300000000, + 0xddc84ad700000000, 0x5f7fc52800000000, 0x692e470c00000000, + 0x33ddc16100000000, 0x058c434500000000, 0x939e752b00000000, + 0xa5cff70f00000000, 0xff3c716200000000, 0xc96df34600000000, + 0x4bda7cb900000000, 0x7d8bfe9d00000000, 0x277878f000000000, + 0x1129fad400000000, 0x621116d400000000, 0x544094f000000000, + 0x0eb3129d00000000, 0x38e290b900000000, 0xba551f4600000000, + 0x8c049d6200000000, 0xd6f71b0f00000000, 0xe0a6992b00000000, + 0x3087c30e00000000, 0x06d6412a00000000, 0x5c25c74700000000, + 0x6a74456300000000, 0xe8c3ca9c00000000, 0xde9248b800000000, + 0x8461ced500000000, 0xb2304cf100000000, 0xc108a0f100000000, + 0xf75922d500000000, 0xadaaa4b800000000, 0x9bfb269c00000000, + 0x194ca96300000000, 0x2f1d2b4700000000, 0x75eead2a00000000, + 0x43bf2f0e00000000}, + {0x0000000000000000, 0xc8179ecf00000000, 0xd1294d4400000000, + 0x193ed38b00000000, 0xa2539a8800000000, 0x6a44044700000000, + 0x737ad7cc00000000, 0xbb6d490300000000, 0x05a145ca00000000, + 0xcdb6db0500000000, 0xd488088e00000000, 0x1c9f964100000000, + 0xa7f2df4200000000, 0x6fe5418d00000000, 0x76db920600000000, + 0xbecc0cc900000000, 0x4b44fa4f00000000, 0x8353648000000000, + 0x9a6db70b00000000, 0x527a29c400000000, 0xe91760c700000000, + 0x2100fe0800000000, 0x383e2d8300000000, 0xf029b34c00000000, + 0x4ee5bf8500000000, 0x86f2214a00000000, 0x9fccf2c100000000, + 0x57db6c0e00000000, 0xecb6250d00000000, 0x24a1bbc200000000, + 0x3d9f684900000000, 0xf588f68600000000, 0x9688f49f00000000, + 0x5e9f6a5000000000, 0x47a1b9db00000000, 0x8fb6271400000000, + 0x34db6e1700000000, 0xfcccf0d800000000, 0xe5f2235300000000, + 0x2de5bd9c00000000, 0x9329b15500000000, 0x5b3e2f9a00000000, + 0x4200fc1100000000, 0x8a1762de00000000, 0x317a2bdd00000000, + 0xf96db51200000000, 0xe053669900000000, 0x2844f85600000000, + 0xddcc0ed000000000, 0x15db901f00000000, 0x0ce5439400000000, + 0xc4f2dd5b00000000, 0x7f9f945800000000, 0xb7880a9700000000, + 0xaeb6d91c00000000, 0x66a147d300000000, 0xd86d4b1a00000000, + 0x107ad5d500000000, 0x0944065e00000000, 0xc153989100000000, + 0x7a3ed19200000000, 0xb2294f5d00000000, 0xab179cd600000000, + 0x6300021900000000, 0x6d1798e400000000, 0xa500062b00000000, + 0xbc3ed5a000000000, 0x74294b6f00000000, 0xcf44026c00000000, + 0x07539ca300000000, 0x1e6d4f2800000000, 0xd67ad1e700000000, + 0x68b6dd2e00000000, 0xa0a143e100000000, 0xb99f906a00000000, + 0x71880ea500000000, 0xcae547a600000000, 0x02f2d96900000000, + 0x1bcc0ae200000000, 0xd3db942d00000000, 0x265362ab00000000, + 0xee44fc6400000000, 0xf77a2fef00000000, 0x3f6db12000000000, + 0x8400f82300000000, 0x4c1766ec00000000, 0x5529b56700000000, + 0x9d3e2ba800000000, 0x23f2276100000000, 0xebe5b9ae00000000, + 0xf2db6a2500000000, 0x3accf4ea00000000, 0x81a1bde900000000, + 0x49b6232600000000, 0x5088f0ad00000000, 0x989f6e6200000000, + 0xfb9f6c7b00000000, 0x3388f2b400000000, 0x2ab6213f00000000, + 0xe2a1bff000000000, 0x59ccf6f300000000, 0x91db683c00000000, + 0x88e5bbb700000000, 0x40f2257800000000, 0xfe3e29b100000000, + 0x3629b77e00000000, 0x2f1764f500000000, 0xe700fa3a00000000, + 0x5c6db33900000000, 0x947a2df600000000, 0x8d44fe7d00000000, + 0x455360b200000000, 0xb0db963400000000, 0x78cc08fb00000000, + 0x61f2db7000000000, 0xa9e545bf00000000, 0x12880cbc00000000, + 0xda9f927300000000, 0xc3a141f800000000, 0x0bb6df3700000000, + 0xb57ad3fe00000000, 0x7d6d4d3100000000, 0x64539eba00000000, + 0xac44007500000000, 0x1729497600000000, 0xdf3ed7b900000000, + 0xc600043200000000, 0x0e179afd00000000, 0x9b28411200000000, + 0x533fdfdd00000000, 0x4a010c5600000000, 0x8216929900000000, + 0x397bdb9a00000000, 0xf16c455500000000, 0xe85296de00000000, + 0x2045081100000000, 0x9e8904d800000000, 0x569e9a1700000000, + 0x4fa0499c00000000, 0x87b7d75300000000, 0x3cda9e5000000000, + 0xf4cd009f00000000, 0xedf3d31400000000, 0x25e44ddb00000000, + 0xd06cbb5d00000000, 0x187b259200000000, 0x0145f61900000000, + 0xc95268d600000000, 0x723f21d500000000, 0xba28bf1a00000000, + 0xa3166c9100000000, 0x6b01f25e00000000, 0xd5cdfe9700000000, + 0x1dda605800000000, 0x04e4b3d300000000, 0xccf32d1c00000000, + 0x779e641f00000000, 0xbf89fad000000000, 0xa6b7295b00000000, + 0x6ea0b79400000000, 0x0da0b58d00000000, 0xc5b72b4200000000, + 0xdc89f8c900000000, 0x149e660600000000, 0xaff32f0500000000, + 0x67e4b1ca00000000, 0x7eda624100000000, 0xb6cdfc8e00000000, + 0x0801f04700000000, 0xc0166e8800000000, 0xd928bd0300000000, + 0x113f23cc00000000, 0xaa526acf00000000, 0x6245f40000000000, + 0x7b7b278b00000000, 0xb36cb94400000000, 0x46e44fc200000000, + 0x8ef3d10d00000000, 0x97cd028600000000, 0x5fda9c4900000000, + 0xe4b7d54a00000000, 0x2ca04b8500000000, 0x359e980e00000000, + 0xfd8906c100000000, 0x43450a0800000000, 0x8b5294c700000000, + 0x926c474c00000000, 0x5a7bd98300000000, 0xe116908000000000, + 0x29010e4f00000000, 0x303fddc400000000, 0xf828430b00000000, + 0xf63fd9f600000000, 0x3e28473900000000, 0x271694b200000000, + 0xef010a7d00000000, 0x546c437e00000000, 0x9c7bddb100000000, + 0x85450e3a00000000, 0x4d5290f500000000, 0xf39e9c3c00000000, + 0x3b8902f300000000, 0x22b7d17800000000, 0xeaa04fb700000000, + 0x51cd06b400000000, 0x99da987b00000000, 0x80e44bf000000000, + 0x48f3d53f00000000, 0xbd7b23b900000000, 0x756cbd7600000000, + 0x6c526efd00000000, 0xa445f03200000000, 0x1f28b93100000000, + 0xd73f27fe00000000, 0xce01f47500000000, 0x06166aba00000000, + 0xb8da667300000000, 0x70cdf8bc00000000, 0x69f32b3700000000, + 0xa1e4b5f800000000, 0x1a89fcfb00000000, 0xd29e623400000000, + 0xcba0b1bf00000000, 0x03b72f7000000000, 0x60b72d6900000000, + 0xa8a0b3a600000000, 0xb19e602d00000000, 0x7989fee200000000, + 0xc2e4b7e100000000, 0x0af3292e00000000, 0x13cdfaa500000000, + 0xdbda646a00000000, 0x651668a300000000, 0xad01f66c00000000, + 0xb43f25e700000000, 0x7c28bb2800000000, 0xc745f22b00000000, + 0x0f526ce400000000, 0x166cbf6f00000000, 0xde7b21a000000000, + 0x2bf3d72600000000, 0xe3e449e900000000, 0xfada9a6200000000, + 0x32cd04ad00000000, 0x89a04dae00000000, 0x41b7d36100000000, + 0x588900ea00000000, 0x909e9e2500000000, 0x2e5292ec00000000, + 0xe6450c2300000000, 0xff7bdfa800000000, 0x376c416700000000, + 0x8c01086400000000, 0x441696ab00000000, 0x5d28452000000000, + 0x953fdbef00000000}, + {0x0000000000000000, 0x95d4709500000000, 0x6baf90f100000000, + 0xfe7be06400000000, 0x9758503800000000, 0x028c20ad00000000, + 0xfcf7c0c900000000, 0x6923b05c00000000, 0x2eb1a07000000000, + 0xbb65d0e500000000, 0x451e308100000000, 0xd0ca401400000000, + 0xb9e9f04800000000, 0x2c3d80dd00000000, 0xd24660b900000000, + 0x4792102c00000000, 0x5c6241e100000000, 0xc9b6317400000000, + 0x37cdd11000000000, 0xa219a18500000000, 0xcb3a11d900000000, + 0x5eee614c00000000, 0xa095812800000000, 0x3541f1bd00000000, + 0x72d3e19100000000, 0xe707910400000000, 0x197c716000000000, + 0x8ca801f500000000, 0xe58bb1a900000000, 0x705fc13c00000000, + 0x8e24215800000000, 0x1bf051cd00000000, 0xf9c2f31900000000, + 0x6c16838c00000000, 0x926d63e800000000, 0x07b9137d00000000, + 0x6e9aa32100000000, 0xfb4ed3b400000000, 0x053533d000000000, + 0x90e1434500000000, 0xd773536900000000, 0x42a723fc00000000, + 0xbcdcc39800000000, 0x2908b30d00000000, 0x402b035100000000, + 0xd5ff73c400000000, 0x2b8493a000000000, 0xbe50e33500000000, + 0xa5a0b2f800000000, 0x3074c26d00000000, 0xce0f220900000000, + 0x5bdb529c00000000, 0x32f8e2c000000000, 0xa72c925500000000, + 0x5957723100000000, 0xcc8302a400000000, 0x8b11128800000000, + 0x1ec5621d00000000, 0xe0be827900000000, 0x756af2ec00000000, + 0x1c4942b000000000, 0x899d322500000000, 0x77e6d24100000000, + 0xe232a2d400000000, 0xf285e73300000000, 0x675197a600000000, + 0x992a77c200000000, 0x0cfe075700000000, 0x65ddb70b00000000, + 0xf009c79e00000000, 0x0e7227fa00000000, 0x9ba6576f00000000, + 0xdc34474300000000, 0x49e037d600000000, 0xb79bd7b200000000, + 0x224fa72700000000, 0x4b6c177b00000000, 0xdeb867ee00000000, + 0x20c3878a00000000, 0xb517f71f00000000, 0xaee7a6d200000000, + 0x3b33d64700000000, 0xc548362300000000, 0x509c46b600000000, + 0x39bff6ea00000000, 0xac6b867f00000000, 0x5210661b00000000, + 0xc7c4168e00000000, 0x805606a200000000, 0x1582763700000000, + 0xebf9965300000000, 0x7e2de6c600000000, 0x170e569a00000000, + 0x82da260f00000000, 0x7ca1c66b00000000, 0xe975b6fe00000000, + 0x0b47142a00000000, 0x9e9364bf00000000, 0x60e884db00000000, + 0xf53cf44e00000000, 0x9c1f441200000000, 0x09cb348700000000, + 0xf7b0d4e300000000, 0x6264a47600000000, 0x25f6b45a00000000, + 0xb022c4cf00000000, 0x4e5924ab00000000, 0xdb8d543e00000000, + 0xb2aee46200000000, 0x277a94f700000000, 0xd901749300000000, + 0x4cd5040600000000, 0x572555cb00000000, 0xc2f1255e00000000, + 0x3c8ac53a00000000, 0xa95eb5af00000000, 0xc07d05f300000000, + 0x55a9756600000000, 0xabd2950200000000, 0x3e06e59700000000, + 0x7994f5bb00000000, 0xec40852e00000000, 0x123b654a00000000, + 0x87ef15df00000000, 0xeecca58300000000, 0x7b18d51600000000, + 0x8563357200000000, 0x10b745e700000000, 0xe40bcf6700000000, + 0x71dfbff200000000, 0x8fa45f9600000000, 0x1a702f0300000000, + 0x73539f5f00000000, 0xe687efca00000000, 0x18fc0fae00000000, + 0x8d287f3b00000000, 0xcaba6f1700000000, 0x5f6e1f8200000000, + 0xa115ffe600000000, 0x34c18f7300000000, 0x5de23f2f00000000, + 0xc8364fba00000000, 0x364dafde00000000, 0xa399df4b00000000, + 0xb8698e8600000000, 0x2dbdfe1300000000, 0xd3c61e7700000000, + 0x46126ee200000000, 0x2f31debe00000000, 0xbae5ae2b00000000, + 0x449e4e4f00000000, 0xd14a3eda00000000, 0x96d82ef600000000, + 0x030c5e6300000000, 0xfd77be0700000000, 0x68a3ce9200000000, + 0x01807ece00000000, 0x94540e5b00000000, 0x6a2fee3f00000000, + 0xfffb9eaa00000000, 0x1dc93c7e00000000, 0x881d4ceb00000000, + 0x7666ac8f00000000, 0xe3b2dc1a00000000, 0x8a916c4600000000, + 0x1f451cd300000000, 0xe13efcb700000000, 0x74ea8c2200000000, + 0x33789c0e00000000, 0xa6acec9b00000000, 0x58d70cff00000000, + 0xcd037c6a00000000, 0xa420cc3600000000, 0x31f4bca300000000, + 0xcf8f5cc700000000, 0x5a5b2c5200000000, 0x41ab7d9f00000000, + 0xd47f0d0a00000000, 0x2a04ed6e00000000, 0xbfd09dfb00000000, + 0xd6f32da700000000, 0x43275d3200000000, 0xbd5cbd5600000000, + 0x2888cdc300000000, 0x6f1addef00000000, 0xfacead7a00000000, + 0x04b54d1e00000000, 0x91613d8b00000000, 0xf8428dd700000000, + 0x6d96fd4200000000, 0x93ed1d2600000000, 0x06396db300000000, + 0x168e285400000000, 0x835a58c100000000, 0x7d21b8a500000000, + 0xe8f5c83000000000, 0x81d6786c00000000, 0x140208f900000000, + 0xea79e89d00000000, 0x7fad980800000000, 0x383f882400000000, + 0xadebf8b100000000, 0x539018d500000000, 0xc644684000000000, + 0xaf67d81c00000000, 0x3ab3a88900000000, 0xc4c848ed00000000, + 0x511c387800000000, 0x4aec69b500000000, 0xdf38192000000000, + 0x2143f94400000000, 0xb49789d100000000, 0xddb4398d00000000, + 0x4860491800000000, 0xb61ba97c00000000, 0x23cfd9e900000000, + 0x645dc9c500000000, 0xf189b95000000000, 0x0ff2593400000000, + 0x9a2629a100000000, 0xf30599fd00000000, 0x66d1e96800000000, + 0x98aa090c00000000, 0x0d7e799900000000, 0xef4cdb4d00000000, + 0x7a98abd800000000, 0x84e34bbc00000000, 0x11373b2900000000, + 0x78148b7500000000, 0xedc0fbe000000000, 0x13bb1b8400000000, + 0x866f6b1100000000, 0xc1fd7b3d00000000, 0x54290ba800000000, + 0xaa52ebcc00000000, 0x3f869b5900000000, 0x56a52b0500000000, + 0xc3715b9000000000, 0x3d0abbf400000000, 0xa8decb6100000000, + 0xb32e9aac00000000, 0x26faea3900000000, 0xd8810a5d00000000, + 0x4d557ac800000000, 0x2476ca9400000000, 0xb1a2ba0100000000, + 0x4fd95a6500000000, 0xda0d2af000000000, 0x9d9f3adc00000000, + 0x084b4a4900000000, 0xf630aa2d00000000, 0x63e4dab800000000, + 0x0ac76ae400000000, 0x9f131a7100000000, 0x6168fa1500000000, + 0xf4bc8a8000000000}, + {0x0000000000000000, 0x1f17f08000000000, 0x7f2891da00000000, + 0x603f615a00000000, 0xbf56536e00000000, 0xa041a3ee00000000, + 0xc07ec2b400000000, 0xdf69323400000000, 0x7eada6dc00000000, + 0x61ba565c00000000, 0x0185370600000000, 0x1e92c78600000000, + 0xc1fbf5b200000000, 0xdeec053200000000, 0xbed3646800000000, + 0xa1c494e800000000, 0xbd5c3c6200000000, 0xa24bcce200000000, + 0xc274adb800000000, 0xdd635d3800000000, 0x020a6f0c00000000, + 0x1d1d9f8c00000000, 0x7d22fed600000000, 0x62350e5600000000, + 0xc3f19abe00000000, 0xdce66a3e00000000, 0xbcd90b6400000000, + 0xa3cefbe400000000, 0x7ca7c9d000000000, 0x63b0395000000000, + 0x038f580a00000000, 0x1c98a88a00000000, 0x7ab978c400000000, + 0x65ae884400000000, 0x0591e91e00000000, 0x1a86199e00000000, + 0xc5ef2baa00000000, 0xdaf8db2a00000000, 0xbac7ba7000000000, + 0xa5d04af000000000, 0x0414de1800000000, 0x1b032e9800000000, + 0x7b3c4fc200000000, 0x642bbf4200000000, 0xbb428d7600000000, + 0xa4557df600000000, 0xc46a1cac00000000, 0xdb7dec2c00000000, + 0xc7e544a600000000, 0xd8f2b42600000000, 0xb8cdd57c00000000, + 0xa7da25fc00000000, 0x78b317c800000000, 0x67a4e74800000000, + 0x079b861200000000, 0x188c769200000000, 0xb948e27a00000000, + 0xa65f12fa00000000, 0xc66073a000000000, 0xd977832000000000, + 0x061eb11400000000, 0x1909419400000000, 0x793620ce00000000, + 0x6621d04e00000000, 0xb574805300000000, 0xaa6370d300000000, + 0xca5c118900000000, 0xd54be10900000000, 0x0a22d33d00000000, + 0x153523bd00000000, 0x750a42e700000000, 0x6a1db26700000000, + 0xcbd9268f00000000, 0xd4ced60f00000000, 0xb4f1b75500000000, + 0xabe647d500000000, 0x748f75e100000000, 0x6b98856100000000, + 0x0ba7e43b00000000, 0x14b014bb00000000, 0x0828bc3100000000, + 0x173f4cb100000000, 0x77002deb00000000, 0x6817dd6b00000000, + 0xb77eef5f00000000, 0xa8691fdf00000000, 0xc8567e8500000000, + 0xd7418e0500000000, 0x76851aed00000000, 0x6992ea6d00000000, + 0x09ad8b3700000000, 0x16ba7bb700000000, 0xc9d3498300000000, + 0xd6c4b90300000000, 0xb6fbd85900000000, 0xa9ec28d900000000, + 0xcfcdf89700000000, 0xd0da081700000000, 0xb0e5694d00000000, + 0xaff299cd00000000, 0x709babf900000000, 0x6f8c5b7900000000, + 0x0fb33a2300000000, 0x10a4caa300000000, 0xb1605e4b00000000, + 0xae77aecb00000000, 0xce48cf9100000000, 0xd15f3f1100000000, + 0x0e360d2500000000, 0x1121fda500000000, 0x711e9cff00000000, + 0x6e096c7f00000000, 0x7291c4f500000000, 0x6d86347500000000, + 0x0db9552f00000000, 0x12aea5af00000000, 0xcdc7979b00000000, + 0xd2d0671b00000000, 0xb2ef064100000000, 0xadf8f6c100000000, + 0x0c3c622900000000, 0x132b92a900000000, 0x7314f3f300000000, + 0x6c03037300000000, 0xb36a314700000000, 0xac7dc1c700000000, + 0xcc42a09d00000000, 0xd355501d00000000, 0x6ae900a700000000, + 0x75fef02700000000, 0x15c1917d00000000, 0x0ad661fd00000000, + 0xd5bf53c900000000, 0xcaa8a34900000000, 0xaa97c21300000000, + 0xb580329300000000, 0x1444a67b00000000, 0x0b5356fb00000000, + 0x6b6c37a100000000, 0x747bc72100000000, 0xab12f51500000000, + 0xb405059500000000, 0xd43a64cf00000000, 0xcb2d944f00000000, + 0xd7b53cc500000000, 0xc8a2cc4500000000, 0xa89dad1f00000000, + 0xb78a5d9f00000000, 0x68e36fab00000000, 0x77f49f2b00000000, + 0x17cbfe7100000000, 0x08dc0ef100000000, 0xa9189a1900000000, + 0xb60f6a9900000000, 0xd6300bc300000000, 0xc927fb4300000000, + 0x164ec97700000000, 0x095939f700000000, 0x696658ad00000000, + 0x7671a82d00000000, 0x1050786300000000, 0x0f4788e300000000, + 0x6f78e9b900000000, 0x706f193900000000, 0xaf062b0d00000000, + 0xb011db8d00000000, 0xd02ebad700000000, 0xcf394a5700000000, + 0x6efddebf00000000, 0x71ea2e3f00000000, 0x11d54f6500000000, + 0x0ec2bfe500000000, 0xd1ab8dd100000000, 0xcebc7d5100000000, + 0xae831c0b00000000, 0xb194ec8b00000000, 0xad0c440100000000, + 0xb21bb48100000000, 0xd224d5db00000000, 0xcd33255b00000000, + 0x125a176f00000000, 0x0d4de7ef00000000, 0x6d7286b500000000, + 0x7265763500000000, 0xd3a1e2dd00000000, 0xccb6125d00000000, + 0xac89730700000000, 0xb39e838700000000, 0x6cf7b1b300000000, + 0x73e0413300000000, 0x13df206900000000, 0x0cc8d0e900000000, + 0xdf9d80f400000000, 0xc08a707400000000, 0xa0b5112e00000000, + 0xbfa2e1ae00000000, 0x60cbd39a00000000, 0x7fdc231a00000000, + 0x1fe3424000000000, 0x00f4b2c000000000, 0xa130262800000000, + 0xbe27d6a800000000, 0xde18b7f200000000, 0xc10f477200000000, + 0x1e66754600000000, 0x017185c600000000, 0x614ee49c00000000, + 0x7e59141c00000000, 0x62c1bc9600000000, 0x7dd64c1600000000, + 0x1de92d4c00000000, 0x02feddcc00000000, 0xdd97eff800000000, + 0xc2801f7800000000, 0xa2bf7e2200000000, 0xbda88ea200000000, + 0x1c6c1a4a00000000, 0x037beaca00000000, 0x63448b9000000000, + 0x7c537b1000000000, 0xa33a492400000000, 0xbc2db9a400000000, + 0xdc12d8fe00000000, 0xc305287e00000000, 0xa524f83000000000, + 0xba3308b000000000, 0xda0c69ea00000000, 0xc51b996a00000000, + 0x1a72ab5e00000000, 0x05655bde00000000, 0x655a3a8400000000, + 0x7a4dca0400000000, 0xdb895eec00000000, 0xc49eae6c00000000, + 0xa4a1cf3600000000, 0xbbb63fb600000000, 0x64df0d8200000000, + 0x7bc8fd0200000000, 0x1bf79c5800000000, 0x04e06cd800000000, + 0x1878c45200000000, 0x076f34d200000000, 0x6750558800000000, + 0x7847a50800000000, 0xa72e973c00000000, 0xb83967bc00000000, + 0xd80606e600000000, 0xc711f66600000000, 0x66d5628e00000000, + 0x79c2920e00000000, 0x19fdf35400000000, 0x06ea03d400000000, + 0xd98331e000000000, 0xc694c16000000000, 0xa6aba03a00000000, + 0xb9bc50ba00000000}, + {0x0000000000000000, 0xe2fd888d00000000, 0x85fd60c000000000, + 0x6700e84d00000000, 0x4bfdb05b00000000, 0xa90038d600000000, + 0xce00d09b00000000, 0x2cfd581600000000, 0x96fa61b700000000, + 0x7407e93a00000000, 0x1307017700000000, 0xf1fa89fa00000000, + 0xdd07d1ec00000000, 0x3ffa596100000000, 0x58fab12c00000000, + 0xba0739a100000000, 0x6df3b2b500000000, 0x8f0e3a3800000000, + 0xe80ed27500000000, 0x0af35af800000000, 0x260e02ee00000000, + 0xc4f38a6300000000, 0xa3f3622e00000000, 0x410eeaa300000000, + 0xfb09d30200000000, 0x19f45b8f00000000, 0x7ef4b3c200000000, + 0x9c093b4f00000000, 0xb0f4635900000000, 0x5209ebd400000000, + 0x3509039900000000, 0xd7f48b1400000000, 0x9be014b000000000, + 0x791d9c3d00000000, 0x1e1d747000000000, 0xfce0fcfd00000000, + 0xd01da4eb00000000, 0x32e02c6600000000, 0x55e0c42b00000000, + 0xb71d4ca600000000, 0x0d1a750700000000, 0xefe7fd8a00000000, + 0x88e715c700000000, 0x6a1a9d4a00000000, 0x46e7c55c00000000, + 0xa41a4dd100000000, 0xc31aa59c00000000, 0x21e72d1100000000, + 0xf613a60500000000, 0x14ee2e8800000000, 0x73eec6c500000000, + 0x91134e4800000000, 0xbdee165e00000000, 0x5f139ed300000000, + 0x3813769e00000000, 0xdaeefe1300000000, 0x60e9c7b200000000, + 0x82144f3f00000000, 0xe514a77200000000, 0x07e92fff00000000, + 0x2b1477e900000000, 0xc9e9ff6400000000, 0xaee9172900000000, + 0x4c149fa400000000, 0x77c758bb00000000, 0x953ad03600000000, + 0xf23a387b00000000, 0x10c7b0f600000000, 0x3c3ae8e000000000, + 0xdec7606d00000000, 0xb9c7882000000000, 0x5b3a00ad00000000, + 0xe13d390c00000000, 0x03c0b18100000000, 0x64c059cc00000000, + 0x863dd14100000000, 0xaac0895700000000, 0x483d01da00000000, + 0x2f3de99700000000, 0xcdc0611a00000000, 0x1a34ea0e00000000, + 0xf8c9628300000000, 0x9fc98ace00000000, 0x7d34024300000000, + 0x51c95a5500000000, 0xb334d2d800000000, 0xd4343a9500000000, + 0x36c9b21800000000, 0x8cce8bb900000000, 0x6e33033400000000, + 0x0933eb7900000000, 0xebce63f400000000, 0xc7333be200000000, + 0x25ceb36f00000000, 0x42ce5b2200000000, 0xa033d3af00000000, + 0xec274c0b00000000, 0x0edac48600000000, 0x69da2ccb00000000, + 0x8b27a44600000000, 0xa7dafc5000000000, 0x452774dd00000000, + 0x22279c9000000000, 0xc0da141d00000000, 0x7add2dbc00000000, + 0x9820a53100000000, 0xff204d7c00000000, 0x1dddc5f100000000, + 0x31209de700000000, 0xd3dd156a00000000, 0xb4ddfd2700000000, + 0x562075aa00000000, 0x81d4febe00000000, 0x6329763300000000, + 0x04299e7e00000000, 0xe6d416f300000000, 0xca294ee500000000, + 0x28d4c66800000000, 0x4fd42e2500000000, 0xad29a6a800000000, + 0x172e9f0900000000, 0xf5d3178400000000, 0x92d3ffc900000000, + 0x702e774400000000, 0x5cd32f5200000000, 0xbe2ea7df00000000, + 0xd92e4f9200000000, 0x3bd3c71f00000000, 0xaf88c0ad00000000, + 0x4d75482000000000, 0x2a75a06d00000000, 0xc88828e000000000, + 0xe47570f600000000, 0x0688f87b00000000, 0x6188103600000000, + 0x837598bb00000000, 0x3972a11a00000000, 0xdb8f299700000000, + 0xbc8fc1da00000000, 0x5e72495700000000, 0x728f114100000000, + 0x907299cc00000000, 0xf772718100000000, 0x158ff90c00000000, + 0xc27b721800000000, 0x2086fa9500000000, 0x478612d800000000, + 0xa57b9a5500000000, 0x8986c24300000000, 0x6b7b4ace00000000, + 0x0c7ba28300000000, 0xee862a0e00000000, 0x548113af00000000, + 0xb67c9b2200000000, 0xd17c736f00000000, 0x3381fbe200000000, + 0x1f7ca3f400000000, 0xfd812b7900000000, 0x9a81c33400000000, + 0x787c4bb900000000, 0x3468d41d00000000, 0xd6955c9000000000, + 0xb195b4dd00000000, 0x53683c5000000000, 0x7f95644600000000, + 0x9d68eccb00000000, 0xfa68048600000000, 0x18958c0b00000000, + 0xa292b5aa00000000, 0x406f3d2700000000, 0x276fd56a00000000, + 0xc5925de700000000, 0xe96f05f100000000, 0x0b928d7c00000000, + 0x6c92653100000000, 0x8e6fedbc00000000, 0x599b66a800000000, + 0xbb66ee2500000000, 0xdc66066800000000, 0x3e9b8ee500000000, + 0x1266d6f300000000, 0xf09b5e7e00000000, 0x979bb63300000000, + 0x75663ebe00000000, 0xcf61071f00000000, 0x2d9c8f9200000000, + 0x4a9c67df00000000, 0xa861ef5200000000, 0x849cb74400000000, + 0x66613fc900000000, 0x0161d78400000000, 0xe39c5f0900000000, + 0xd84f981600000000, 0x3ab2109b00000000, 0x5db2f8d600000000, + 0xbf4f705b00000000, 0x93b2284d00000000, 0x714fa0c000000000, + 0x164f488d00000000, 0xf4b2c00000000000, 0x4eb5f9a100000000, + 0xac48712c00000000, 0xcb48996100000000, 0x29b511ec00000000, + 0x054849fa00000000, 0xe7b5c17700000000, 0x80b5293a00000000, + 0x6248a1b700000000, 0xb5bc2aa300000000, 0x5741a22e00000000, + 0x30414a6300000000, 0xd2bcc2ee00000000, 0xfe419af800000000, + 0x1cbc127500000000, 0x7bbcfa3800000000, 0x994172b500000000, + 0x23464b1400000000, 0xc1bbc39900000000, 0xa6bb2bd400000000, + 0x4446a35900000000, 0x68bbfb4f00000000, 0x8a4673c200000000, + 0xed469b8f00000000, 0x0fbb130200000000, 0x43af8ca600000000, + 0xa152042b00000000, 0xc652ec6600000000, 0x24af64eb00000000, + 0x08523cfd00000000, 0xeaafb47000000000, 0x8daf5c3d00000000, + 0x6f52d4b000000000, 0xd555ed1100000000, 0x37a8659c00000000, + 0x50a88dd100000000, 0xb255055c00000000, 0x9ea85d4a00000000, + 0x7c55d5c700000000, 0x1b553d8a00000000, 0xf9a8b50700000000, + 0x2e5c3e1300000000, 0xcca1b69e00000000, 0xaba15ed300000000, + 0x495cd65e00000000, 0x65a18e4800000000, 0x875c06c500000000, + 0xe05cee8800000000, 0x02a1660500000000, 0xb8a65fa400000000, + 0x5a5bd72900000000, 0x3d5b3f6400000000, 0xdfa6b7e900000000, + 0xf35befff00000000, 0x11a6677200000000, 0x76a68f3f00000000, + 0x945b07b200000000}, + {0x0000000000000000, 0xa90b894e00000000, 0x5217129d00000000, + 0xfb1c9bd300000000, 0xe52855e100000000, 0x4c23dcaf00000000, + 0xb73f477c00000000, 0x1e34ce3200000000, 0x8b57db1900000000, + 0x225c525700000000, 0xd940c98400000000, 0x704b40ca00000000, + 0x6e7f8ef800000000, 0xc77407b600000000, 0x3c689c6500000000, + 0x9563152b00000000, 0x16afb63300000000, 0xbfa43f7d00000000, + 0x44b8a4ae00000000, 0xedb32de000000000, 0xf387e3d200000000, + 0x5a8c6a9c00000000, 0xa190f14f00000000, 0x089b780100000000, + 0x9df86d2a00000000, 0x34f3e46400000000, 0xcfef7fb700000000, + 0x66e4f6f900000000, 0x78d038cb00000000, 0xd1dbb18500000000, + 0x2ac72a5600000000, 0x83cca31800000000, 0x2c5e6d6700000000, + 0x8555e42900000000, 0x7e497ffa00000000, 0xd742f6b400000000, + 0xc976388600000000, 0x607db1c800000000, 0x9b612a1b00000000, + 0x326aa35500000000, 0xa709b67e00000000, 0x0e023f3000000000, + 0xf51ea4e300000000, 0x5c152dad00000000, 0x4221e39f00000000, + 0xeb2a6ad100000000, 0x1036f10200000000, 0xb93d784c00000000, + 0x3af1db5400000000, 0x93fa521a00000000, 0x68e6c9c900000000, + 0xc1ed408700000000, 0xdfd98eb500000000, 0x76d207fb00000000, + 0x8dce9c2800000000, 0x24c5156600000000, 0xb1a6004d00000000, + 0x18ad890300000000, 0xe3b112d000000000, 0x4aba9b9e00000000, + 0x548e55ac00000000, 0xfd85dce200000000, 0x0699473100000000, + 0xaf92ce7f00000000, 0x58bcdace00000000, 0xf1b7538000000000, + 0x0aabc85300000000, 0xa3a0411d00000000, 0xbd948f2f00000000, + 0x149f066100000000, 0xef839db200000000, 0x468814fc00000000, + 0xd3eb01d700000000, 0x7ae0889900000000, 0x81fc134a00000000, + 0x28f79a0400000000, 0x36c3543600000000, 0x9fc8dd7800000000, + 0x64d446ab00000000, 0xcddfcfe500000000, 0x4e136cfd00000000, + 0xe718e5b300000000, 0x1c047e6000000000, 0xb50ff72e00000000, + 0xab3b391c00000000, 0x0230b05200000000, 0xf92c2b8100000000, + 0x5027a2cf00000000, 0xc544b7e400000000, 0x6c4f3eaa00000000, + 0x9753a57900000000, 0x3e582c3700000000, 0x206ce20500000000, + 0x89676b4b00000000, 0x727bf09800000000, 0xdb7079d600000000, + 0x74e2b7a900000000, 0xdde93ee700000000, 0x26f5a53400000000, + 0x8ffe2c7a00000000, 0x91cae24800000000, 0x38c16b0600000000, + 0xc3ddf0d500000000, 0x6ad6799b00000000, 0xffb56cb000000000, + 0x56bee5fe00000000, 0xada27e2d00000000, 0x04a9f76300000000, + 0x1a9d395100000000, 0xb396b01f00000000, 0x488a2bcc00000000, + 0xe181a28200000000, 0x624d019a00000000, 0xcb4688d400000000, + 0x305a130700000000, 0x99519a4900000000, 0x8765547b00000000, + 0x2e6edd3500000000, 0xd57246e600000000, 0x7c79cfa800000000, + 0xe91ada8300000000, 0x401153cd00000000, 0xbb0dc81e00000000, + 0x1206415000000000, 0x0c328f6200000000, 0xa539062c00000000, + 0x5e259dff00000000, 0xf72e14b100000000, 0xf17ec44600000000, + 0x58754d0800000000, 0xa369d6db00000000, 0x0a625f9500000000, + 0x145691a700000000, 0xbd5d18e900000000, 0x4641833a00000000, + 0xef4a0a7400000000, 0x7a291f5f00000000, 0xd322961100000000, + 0x283e0dc200000000, 0x8135848c00000000, 0x9f014abe00000000, + 0x360ac3f000000000, 0xcd16582300000000, 0x641dd16d00000000, + 0xe7d1727500000000, 0x4edafb3b00000000, 0xb5c660e800000000, + 0x1ccde9a600000000, 0x02f9279400000000, 0xabf2aeda00000000, + 0x50ee350900000000, 0xf9e5bc4700000000, 0x6c86a96c00000000, + 0xc58d202200000000, 0x3e91bbf100000000, 0x979a32bf00000000, + 0x89aefc8d00000000, 0x20a575c300000000, 0xdbb9ee1000000000, + 0x72b2675e00000000, 0xdd20a92100000000, 0x742b206f00000000, + 0x8f37bbbc00000000, 0x263c32f200000000, 0x3808fcc000000000, + 0x9103758e00000000, 0x6a1fee5d00000000, 0xc314671300000000, + 0x5677723800000000, 0xff7cfb7600000000, 0x046060a500000000, + 0xad6be9eb00000000, 0xb35f27d900000000, 0x1a54ae9700000000, + 0xe148354400000000, 0x4843bc0a00000000, 0xcb8f1f1200000000, + 0x6284965c00000000, 0x99980d8f00000000, 0x309384c100000000, + 0x2ea74af300000000, 0x87acc3bd00000000, 0x7cb0586e00000000, + 0xd5bbd12000000000, 0x40d8c40b00000000, 0xe9d34d4500000000, + 0x12cfd69600000000, 0xbbc45fd800000000, 0xa5f091ea00000000, + 0x0cfb18a400000000, 0xf7e7837700000000, 0x5eec0a3900000000, + 0xa9c21e8800000000, 0x00c997c600000000, 0xfbd50c1500000000, + 0x52de855b00000000, 0x4cea4b6900000000, 0xe5e1c22700000000, + 0x1efd59f400000000, 0xb7f6d0ba00000000, 0x2295c59100000000, + 0x8b9e4cdf00000000, 0x7082d70c00000000, 0xd9895e4200000000, + 0xc7bd907000000000, 0x6eb6193e00000000, 0x95aa82ed00000000, + 0x3ca10ba300000000, 0xbf6da8bb00000000, 0x166621f500000000, + 0xed7aba2600000000, 0x4471336800000000, 0x5a45fd5a00000000, + 0xf34e741400000000, 0x0852efc700000000, 0xa159668900000000, + 0x343a73a200000000, 0x9d31faec00000000, 0x662d613f00000000, + 0xcf26e87100000000, 0xd112264300000000, 0x7819af0d00000000, + 0x830534de00000000, 0x2a0ebd9000000000, 0x859c73ef00000000, + 0x2c97faa100000000, 0xd78b617200000000, 0x7e80e83c00000000, + 0x60b4260e00000000, 0xc9bfaf4000000000, 0x32a3349300000000, + 0x9ba8bddd00000000, 0x0ecba8f600000000, 0xa7c021b800000000, + 0x5cdcba6b00000000, 0xf5d7332500000000, 0xebe3fd1700000000, + 0x42e8745900000000, 0xb9f4ef8a00000000, 0x10ff66c400000000, + 0x9333c5dc00000000, 0x3a384c9200000000, 0xc124d74100000000, + 0x682f5e0f00000000, 0x761b903d00000000, 0xdf10197300000000, + 0x240c82a000000000, 0x8d070bee00000000, 0x18641ec500000000, + 0xb16f978b00000000, 0x4a730c5800000000, 0xe378851600000000, + 0xfd4c4b2400000000, 0x5447c26a00000000, 0xaf5b59b900000000, + 0x0650d0f700000000}, + {0x0000000000000000, 0x479244af00000000, 0xcf22f88500000000, + 0x88b0bc2a00000000, 0xdf4381d000000000, 0x98d1c57f00000000, + 0x1061795500000000, 0x57f33dfa00000000, 0xff81737a00000000, + 0xb81337d500000000, 0x30a38bff00000000, 0x7731cf5000000000, + 0x20c2f2aa00000000, 0x6750b60500000000, 0xefe00a2f00000000, + 0xa8724e8000000000, 0xfe03e7f400000000, 0xb991a35b00000000, + 0x31211f7100000000, 0x76b35bde00000000, 0x2140662400000000, + 0x66d2228b00000000, 0xee629ea100000000, 0xa9f0da0e00000000, + 0x0182948e00000000, 0x4610d02100000000, 0xcea06c0b00000000, + 0x893228a400000000, 0xdec1155e00000000, 0x995351f100000000, + 0x11e3eddb00000000, 0x5671a97400000000, 0xbd01bf3200000000, + 0xfa93fb9d00000000, 0x722347b700000000, 0x35b1031800000000, + 0x62423ee200000000, 0x25d07a4d00000000, 0xad60c66700000000, + 0xeaf282c800000000, 0x4280cc4800000000, 0x051288e700000000, + 0x8da234cd00000000, 0xca30706200000000, 0x9dc34d9800000000, + 0xda51093700000000, 0x52e1b51d00000000, 0x1573f1b200000000, + 0x430258c600000000, 0x04901c6900000000, 0x8c20a04300000000, + 0xcbb2e4ec00000000, 0x9c41d91600000000, 0xdbd39db900000000, + 0x5363219300000000, 0x14f1653c00000000, 0xbc832bbc00000000, + 0xfb116f1300000000, 0x73a1d33900000000, 0x3433979600000000, + 0x63c0aa6c00000000, 0x2452eec300000000, 0xace252e900000000, + 0xeb70164600000000, 0x7a037e6500000000, 0x3d913aca00000000, + 0xb52186e000000000, 0xf2b3c24f00000000, 0xa540ffb500000000, + 0xe2d2bb1a00000000, 0x6a62073000000000, 0x2df0439f00000000, + 0x85820d1f00000000, 0xc21049b000000000, 0x4aa0f59a00000000, + 0x0d32b13500000000, 0x5ac18ccf00000000, 0x1d53c86000000000, + 0x95e3744a00000000, 0xd27130e500000000, 0x8400999100000000, + 0xc392dd3e00000000, 0x4b22611400000000, 0x0cb025bb00000000, + 0x5b43184100000000, 0x1cd15cee00000000, 0x9461e0c400000000, + 0xd3f3a46b00000000, 0x7b81eaeb00000000, 0x3c13ae4400000000, + 0xb4a3126e00000000, 0xf33156c100000000, 0xa4c26b3b00000000, + 0xe3502f9400000000, 0x6be093be00000000, 0x2c72d71100000000, + 0xc702c15700000000, 0x809085f800000000, 0x082039d200000000, + 0x4fb27d7d00000000, 0x1841408700000000, 0x5fd3042800000000, + 0xd763b80200000000, 0x90f1fcad00000000, 0x3883b22d00000000, + 0x7f11f68200000000, 0xf7a14aa800000000, 0xb0330e0700000000, + 0xe7c033fd00000000, 0xa052775200000000, 0x28e2cb7800000000, + 0x6f708fd700000000, 0x390126a300000000, 0x7e93620c00000000, + 0xf623de2600000000, 0xb1b19a8900000000, 0xe642a77300000000, + 0xa1d0e3dc00000000, 0x29605ff600000000, 0x6ef21b5900000000, + 0xc68055d900000000, 0x8112117600000000, 0x09a2ad5c00000000, + 0x4e30e9f300000000, 0x19c3d40900000000, 0x5e5190a600000000, + 0xd6e12c8c00000000, 0x9173682300000000, 0xf406fcca00000000, + 0xb394b86500000000, 0x3b24044f00000000, 0x7cb640e000000000, + 0x2b457d1a00000000, 0x6cd739b500000000, 0xe467859f00000000, + 0xa3f5c13000000000, 0x0b878fb000000000, 0x4c15cb1f00000000, + 0xc4a5773500000000, 0x8337339a00000000, 0xd4c40e6000000000, + 0x93564acf00000000, 0x1be6f6e500000000, 0x5c74b24a00000000, + 0x0a051b3e00000000, 0x4d975f9100000000, 0xc527e3bb00000000, + 0x82b5a71400000000, 0xd5469aee00000000, 0x92d4de4100000000, + 0x1a64626b00000000, 0x5df626c400000000, 0xf584684400000000, + 0xb2162ceb00000000, 0x3aa690c100000000, 0x7d34d46e00000000, + 0x2ac7e99400000000, 0x6d55ad3b00000000, 0xe5e5111100000000, + 0xa27755be00000000, 0x490743f800000000, 0x0e95075700000000, + 0x8625bb7d00000000, 0xc1b7ffd200000000, 0x9644c22800000000, + 0xd1d6868700000000, 0x59663aad00000000, 0x1ef47e0200000000, + 0xb686308200000000, 0xf114742d00000000, 0x79a4c80700000000, + 0x3e368ca800000000, 0x69c5b15200000000, 0x2e57f5fd00000000, + 0xa6e749d700000000, 0xe1750d7800000000, 0xb704a40c00000000, + 0xf096e0a300000000, 0x78265c8900000000, 0x3fb4182600000000, + 0x684725dc00000000, 0x2fd5617300000000, 0xa765dd5900000000, + 0xe0f799f600000000, 0x4885d77600000000, 0x0f1793d900000000, + 0x87a72ff300000000, 0xc0356b5c00000000, 0x97c656a600000000, + 0xd054120900000000, 0x58e4ae2300000000, 0x1f76ea8c00000000, + 0x8e0582af00000000, 0xc997c60000000000, 0x41277a2a00000000, + 0x06b53e8500000000, 0x5146037f00000000, 0x16d447d000000000, + 0x9e64fbfa00000000, 0xd9f6bf5500000000, 0x7184f1d500000000, + 0x3616b57a00000000, 0xbea6095000000000, 0xf9344dff00000000, + 0xaec7700500000000, 0xe95534aa00000000, 0x61e5888000000000, + 0x2677cc2f00000000, 0x7006655b00000000, 0x379421f400000000, + 0xbf249dde00000000, 0xf8b6d97100000000, 0xaf45e48b00000000, + 0xe8d7a02400000000, 0x60671c0e00000000, 0x27f558a100000000, + 0x8f87162100000000, 0xc815528e00000000, 0x40a5eea400000000, + 0x0737aa0b00000000, 0x50c497f100000000, 0x1756d35e00000000, + 0x9fe66f7400000000, 0xd8742bdb00000000, 0x33043d9d00000000, + 0x7496793200000000, 0xfc26c51800000000, 0xbbb481b700000000, + 0xec47bc4d00000000, 0xabd5f8e200000000, 0x236544c800000000, + 0x64f7006700000000, 0xcc854ee700000000, 0x8b170a4800000000, + 0x03a7b66200000000, 0x4435f2cd00000000, 0x13c6cf3700000000, + 0x54548b9800000000, 0xdce437b200000000, 0x9b76731d00000000, + 0xcd07da6900000000, 0x8a959ec600000000, 0x022522ec00000000, + 0x45b7664300000000, 0x12445bb900000000, 0x55d61f1600000000, + 0xdd66a33c00000000, 0x9af4e79300000000, 0x3286a91300000000, + 0x7514edbc00000000, 0xfda4519600000000, 0xba36153900000000, + 0xedc528c300000000, 0xaa576c6c00000000, 0x22e7d04600000000, + 0x657594e900000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, + 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, + 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, + 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, + 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, + 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, + 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, + 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, + 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, + 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, + 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, + 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, + 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, + 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, + 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, + 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, + 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, + 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, + 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, + 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, + 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, + 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, + 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, + 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, + 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, + 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, + 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, + 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, + 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, + 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, + 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, + 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, + 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, + 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, + 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, + 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, + 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, + 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, + 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, + 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, + 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, + 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, + 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, + 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, + 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, + 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, + 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, + 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, + 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, + 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, + 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, + 0xd8ac6b35}, + {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, + 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, + 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, + 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, + 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, + 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, + 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, + 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, + 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, + 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, + 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, + 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, + 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, + 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, + 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, + 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, + 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, + 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, + 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, + 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, + 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, + 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, + 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, + 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, + 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, + 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, + 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, + 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, + 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, + 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, + 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, + 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, + 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, + 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, + 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, + 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, + 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, + 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, + 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, + 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, + 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, + 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, + 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, + 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, + 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, + 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, + 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, + 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, + 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, + 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, + 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, + 0xa140efa8}, + {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, + 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, + 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, + 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, + 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, + 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, + 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, + 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, + 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, + 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, + 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, + 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, + 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, + 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, + 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, + 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, + 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, + 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, + 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, + 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, + 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, + 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, + 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, + 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, + 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, + 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, + 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, + 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, + 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, + 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, + 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, + 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, + 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, + 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, + 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, + 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, + 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, + 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, + 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, + 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, + 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, + 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, + 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, + 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, + 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, + 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, + 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, + 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, + 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, + 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, + 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, + 0x917cd6a1}, + {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, + 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, + 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, + 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, + 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, + 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, + 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, + 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, + 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, + 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, + 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, + 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, + 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, + 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, + 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, + 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, + 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, + 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, + 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, + 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, + 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, + 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, + 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, + 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, + 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, + 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, + 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, + 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, + 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, + 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, + 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, + 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, + 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, + 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, + 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, + 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, + 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, + 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, + 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, + 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, + 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, + 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, + 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, + 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, + 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, + 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, + 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, + 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, + 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, + 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, + 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, + 0x18ba364e}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x43cba687, 0xc7903cd4, 0x845b9a53, 0xcf270873, + 0x8cecaef4, 0x08b734a7, 0x4b7c9220, 0x9e4f10e6, 0xdd84b661, + 0x59df2c32, 0x1a148ab5, 0x51681895, 0x12a3be12, 0x96f82441, + 0xd53382c6, 0x7d995117, 0x3e52f790, 0xba096dc3, 0xf9c2cb44, + 0xb2be5964, 0xf175ffe3, 0x752e65b0, 0x36e5c337, 0xe3d641f1, + 0xa01de776, 0x24467d25, 0x678ddba2, 0x2cf14982, 0x6f3aef05, + 0xeb617556, 0xa8aad3d1, 0xfa32a32e, 0xb9f905a9, 0x3da29ffa, + 0x7e69397d, 0x3515ab5d, 0x76de0dda, 0xf2859789, 0xb14e310e, + 0x647db3c8, 0x27b6154f, 0xa3ed8f1c, 0xe026299b, 0xab5abbbb, + 0xe8911d3c, 0x6cca876f, 0x2f0121e8, 0x87abf239, 0xc46054be, + 0x403bceed, 0x03f0686a, 0x488cfa4a, 0x0b475ccd, 0x8f1cc69e, + 0xccd76019, 0x19e4e2df, 0x5a2f4458, 0xde74de0b, 0x9dbf788c, + 0xd6c3eaac, 0x95084c2b, 0x1153d678, 0x529870ff, 0xf465465d, + 0xb7aee0da, 0x33f57a89, 0x703edc0e, 0x3b424e2e, 0x7889e8a9, + 0xfcd272fa, 0xbf19d47d, 0x6a2a56bb, 0x29e1f03c, 0xadba6a6f, + 0xee71cce8, 0xa50d5ec8, 0xe6c6f84f, 0x629d621c, 0x2156c49b, + 0x89fc174a, 0xca37b1cd, 0x4e6c2b9e, 0x0da78d19, 0x46db1f39, + 0x0510b9be, 0x814b23ed, 0xc280856a, 0x17b307ac, 0x5478a12b, + 0xd0233b78, 0x93e89dff, 0xd8940fdf, 0x9b5fa958, 0x1f04330b, + 0x5ccf958c, 0x0e57e573, 0x4d9c43f4, 0xc9c7d9a7, 0x8a0c7f20, + 0xc170ed00, 0x82bb4b87, 0x06e0d1d4, 0x452b7753, 0x9018f595, + 0xd3d35312, 0x5788c941, 0x14436fc6, 0x5f3ffde6, 0x1cf45b61, + 0x98afc132, 0xdb6467b5, 0x73ceb464, 0x300512e3, 0xb45e88b0, + 0xf7952e37, 0xbce9bc17, 0xff221a90, 0x7b7980c3, 0x38b22644, + 0xed81a482, 0xae4a0205, 0x2a119856, 0x69da3ed1, 0x22a6acf1, + 0x616d0a76, 0xe5369025, 0xa6fd36a2, 0xe8cb8cba, 0xab002a3d, + 0x2f5bb06e, 0x6c9016e9, 0x27ec84c9, 0x6427224e, 0xe07cb81d, + 0xa3b71e9a, 0x76849c5c, 0x354f3adb, 0xb114a088, 0xf2df060f, + 0xb9a3942f, 0xfa6832a8, 0x7e33a8fb, 0x3df80e7c, 0x9552ddad, + 0xd6997b2a, 0x52c2e179, 0x110947fe, 0x5a75d5de, 0x19be7359, + 0x9de5e90a, 0xde2e4f8d, 0x0b1dcd4b, 0x48d66bcc, 0xcc8df19f, + 0x8f465718, 0xc43ac538, 0x87f163bf, 0x03aaf9ec, 0x40615f6b, + 0x12f92f94, 0x51328913, 0xd5691340, 0x96a2b5c7, 0xddde27e7, + 0x9e158160, 0x1a4e1b33, 0x5985bdb4, 0x8cb63f72, 0xcf7d99f5, + 0x4b2603a6, 0x08eda521, 0x43913701, 0x005a9186, 0x84010bd5, + 0xc7caad52, 0x6f607e83, 0x2cabd804, 0xa8f04257, 0xeb3be4d0, + 0xa04776f0, 0xe38cd077, 0x67d74a24, 0x241ceca3, 0xf12f6e65, + 0xb2e4c8e2, 0x36bf52b1, 0x7574f436, 0x3e086616, 0x7dc3c091, + 0xf9985ac2, 0xba53fc45, 0x1caecae7, 0x5f656c60, 0xdb3ef633, + 0x98f550b4, 0xd389c294, 0x90426413, 0x1419fe40, 0x57d258c7, + 0x82e1da01, 0xc12a7c86, 0x4571e6d5, 0x06ba4052, 0x4dc6d272, + 0x0e0d74f5, 0x8a56eea6, 0xc99d4821, 0x61379bf0, 0x22fc3d77, + 0xa6a7a724, 0xe56c01a3, 0xae109383, 0xeddb3504, 0x6980af57, + 0x2a4b09d0, 0xff788b16, 0xbcb32d91, 0x38e8b7c2, 0x7b231145, + 0x305f8365, 0x739425e2, 0xf7cfbfb1, 0xb4041936, 0xe69c69c9, + 0xa557cf4e, 0x210c551d, 0x62c7f39a, 0x29bb61ba, 0x6a70c73d, + 0xee2b5d6e, 0xade0fbe9, 0x78d3792f, 0x3b18dfa8, 0xbf4345fb, + 0xfc88e37c, 0xb7f4715c, 0xf43fd7db, 0x70644d88, 0x33afeb0f, + 0x9b0538de, 0xd8ce9e59, 0x5c95040a, 0x1f5ea28d, 0x542230ad, + 0x17e9962a, 0x93b20c79, 0xd079aafe, 0x054a2838, 0x46818ebf, + 0xc2da14ec, 0x8111b26b, 0xca6d204b, 0x89a686cc, 0x0dfd1c9f, + 0x4e36ba18}, + {0x00000000, 0xe1b652ef, 0x836bd405, 0x62dd86ea, 0x06d7a80b, + 0xe761fae4, 0x85bc7c0e, 0x640a2ee1, 0x0cae5117, 0xed1803f8, + 0x8fc58512, 0x6e73d7fd, 0x0a79f91c, 0xebcfabf3, 0x89122d19, + 0x68a47ff6, 0x185ca32e, 0xf9eaf1c1, 0x9b37772b, 0x7a8125c4, + 0x1e8b0b25, 0xff3d59ca, 0x9de0df20, 0x7c568dcf, 0x14f2f239, + 0xf544a0d6, 0x9799263c, 0x762f74d3, 0x12255a32, 0xf39308dd, + 0x914e8e37, 0x70f8dcd8, 0x30b8465d, 0xd10e14b2, 0xb3d39258, + 0x5265c0b7, 0x366fee56, 0xd7d9bcb9, 0xb5043a53, 0x54b268bc, + 0x3c16174a, 0xdda045a5, 0xbf7dc34f, 0x5ecb91a0, 0x3ac1bf41, + 0xdb77edae, 0xb9aa6b44, 0x581c39ab, 0x28e4e573, 0xc952b79c, + 0xab8f3176, 0x4a396399, 0x2e334d78, 0xcf851f97, 0xad58997d, + 0x4ceecb92, 0x244ab464, 0xc5fce68b, 0xa7216061, 0x4697328e, + 0x229d1c6f, 0xc32b4e80, 0xa1f6c86a, 0x40409a85, 0x60708dba, + 0x81c6df55, 0xe31b59bf, 0x02ad0b50, 0x66a725b1, 0x8711775e, + 0xe5ccf1b4, 0x047aa35b, 0x6cdedcad, 0x8d688e42, 0xefb508a8, + 0x0e035a47, 0x6a0974a6, 0x8bbf2649, 0xe962a0a3, 0x08d4f24c, + 0x782c2e94, 0x999a7c7b, 0xfb47fa91, 0x1af1a87e, 0x7efb869f, + 0x9f4dd470, 0xfd90529a, 0x1c260075, 0x74827f83, 0x95342d6c, + 0xf7e9ab86, 0x165ff969, 0x7255d788, 0x93e38567, 0xf13e038d, + 0x10885162, 0x50c8cbe7, 0xb17e9908, 0xd3a31fe2, 0x32154d0d, + 0x561f63ec, 0xb7a93103, 0xd574b7e9, 0x34c2e506, 0x5c669af0, + 0xbdd0c81f, 0xdf0d4ef5, 0x3ebb1c1a, 0x5ab132fb, 0xbb076014, + 0xd9dae6fe, 0x386cb411, 0x489468c9, 0xa9223a26, 0xcbffbccc, + 0x2a49ee23, 0x4e43c0c2, 0xaff5922d, 0xcd2814c7, 0x2c9e4628, + 0x443a39de, 0xa58c6b31, 0xc751eddb, 0x26e7bf34, 0x42ed91d5, + 0xa35bc33a, 0xc18645d0, 0x2030173f, 0x81e66bae, 0x60503941, + 0x028dbfab, 0xe33bed44, 0x8731c3a5, 0x6687914a, 0x045a17a0, + 0xe5ec454f, 0x8d483ab9, 0x6cfe6856, 0x0e23eebc, 0xef95bc53, + 0x8b9f92b2, 0x6a29c05d, 0x08f446b7, 0xe9421458, 0x99bac880, + 0x780c9a6f, 0x1ad11c85, 0xfb674e6a, 0x9f6d608b, 0x7edb3264, + 0x1c06b48e, 0xfdb0e661, 0x95149997, 0x74a2cb78, 0x167f4d92, + 0xf7c91f7d, 0x93c3319c, 0x72756373, 0x10a8e599, 0xf11eb776, + 0xb15e2df3, 0x50e87f1c, 0x3235f9f6, 0xd383ab19, 0xb78985f8, + 0x563fd717, 0x34e251fd, 0xd5540312, 0xbdf07ce4, 0x5c462e0b, + 0x3e9ba8e1, 0xdf2dfa0e, 0xbb27d4ef, 0x5a918600, 0x384c00ea, + 0xd9fa5205, 0xa9028edd, 0x48b4dc32, 0x2a695ad8, 0xcbdf0837, + 0xafd526d6, 0x4e637439, 0x2cbef2d3, 0xcd08a03c, 0xa5acdfca, + 0x441a8d25, 0x26c70bcf, 0xc7715920, 0xa37b77c1, 0x42cd252e, + 0x2010a3c4, 0xc1a6f12b, 0xe196e614, 0x0020b4fb, 0x62fd3211, + 0x834b60fe, 0xe7414e1f, 0x06f71cf0, 0x642a9a1a, 0x859cc8f5, + 0xed38b703, 0x0c8ee5ec, 0x6e536306, 0x8fe531e9, 0xebef1f08, + 0x0a594de7, 0x6884cb0d, 0x893299e2, 0xf9ca453a, 0x187c17d5, + 0x7aa1913f, 0x9b17c3d0, 0xff1ded31, 0x1eabbfde, 0x7c763934, + 0x9dc06bdb, 0xf564142d, 0x14d246c2, 0x760fc028, 0x97b992c7, + 0xf3b3bc26, 0x1205eec9, 0x70d86823, 0x916e3acc, 0xd12ea049, + 0x3098f2a6, 0x5245744c, 0xb3f326a3, 0xd7f90842, 0x364f5aad, + 0x5492dc47, 0xb5248ea8, 0xdd80f15e, 0x3c36a3b1, 0x5eeb255b, + 0xbf5d77b4, 0xdb575955, 0x3ae10bba, 0x583c8d50, 0xb98adfbf, + 0xc9720367, 0x28c45188, 0x4a19d762, 0xabaf858d, 0xcfa5ab6c, + 0x2e13f983, 0x4cce7f69, 0xad782d86, 0xc5dc5270, 0x246a009f, + 0x46b78675, 0xa701d49a, 0xc30bfa7b, 0x22bda894, 0x40602e7e, + 0xa1d67c91}, + {0x00000000, 0x5880e2d7, 0xf106b474, 0xa98656a3, 0xe20d68e9, + 0xba8d8a3e, 0x130bdc9d, 0x4b8b3e4a, 0x851da109, 0xdd9d43de, + 0x741b157d, 0x2c9bf7aa, 0x6710c9e0, 0x3f902b37, 0x96167d94, + 0xce969f43, 0x0a3b4213, 0x52bba0c4, 0xfb3df667, 0xa3bd14b0, + 0xe8362afa, 0xb0b6c82d, 0x19309e8e, 0x41b07c59, 0x8f26e31a, + 0xd7a601cd, 0x7e20576e, 0x26a0b5b9, 0x6d2b8bf3, 0x35ab6924, + 0x9c2d3f87, 0xc4addd50, 0x14768426, 0x4cf666f1, 0xe5703052, + 0xbdf0d285, 0xf67beccf, 0xaefb0e18, 0x077d58bb, 0x5ffdba6c, + 0x916b252f, 0xc9ebc7f8, 0x606d915b, 0x38ed738c, 0x73664dc6, + 0x2be6af11, 0x8260f9b2, 0xdae01b65, 0x1e4dc635, 0x46cd24e2, + 0xef4b7241, 0xb7cb9096, 0xfc40aedc, 0xa4c04c0b, 0x0d461aa8, + 0x55c6f87f, 0x9b50673c, 0xc3d085eb, 0x6a56d348, 0x32d6319f, + 0x795d0fd5, 0x21dded02, 0x885bbba1, 0xd0db5976, 0x28ec084d, + 0x706cea9a, 0xd9eabc39, 0x816a5eee, 0xcae160a4, 0x92618273, + 0x3be7d4d0, 0x63673607, 0xadf1a944, 0xf5714b93, 0x5cf71d30, + 0x0477ffe7, 0x4ffcc1ad, 0x177c237a, 0xbefa75d9, 0xe67a970e, + 0x22d74a5e, 0x7a57a889, 0xd3d1fe2a, 0x8b511cfd, 0xc0da22b7, + 0x985ac060, 0x31dc96c3, 0x695c7414, 0xa7caeb57, 0xff4a0980, + 0x56cc5f23, 0x0e4cbdf4, 0x45c783be, 0x1d476169, 0xb4c137ca, + 0xec41d51d, 0x3c9a8c6b, 0x641a6ebc, 0xcd9c381f, 0x951cdac8, + 0xde97e482, 0x86170655, 0x2f9150f6, 0x7711b221, 0xb9872d62, + 0xe107cfb5, 0x48819916, 0x10017bc1, 0x5b8a458b, 0x030aa75c, + 0xaa8cf1ff, 0xf20c1328, 0x36a1ce78, 0x6e212caf, 0xc7a77a0c, + 0x9f2798db, 0xd4aca691, 0x8c2c4446, 0x25aa12e5, 0x7d2af032, + 0xb3bc6f71, 0xeb3c8da6, 0x42badb05, 0x1a3a39d2, 0x51b10798, + 0x0931e54f, 0xa0b7b3ec, 0xf837513b, 0x50d8119a, 0x0858f34d, + 0xa1dea5ee, 0xf95e4739, 0xb2d57973, 0xea559ba4, 0x43d3cd07, + 0x1b532fd0, 0xd5c5b093, 0x8d455244, 0x24c304e7, 0x7c43e630, + 0x37c8d87a, 0x6f483aad, 0xc6ce6c0e, 0x9e4e8ed9, 0x5ae35389, + 0x0263b15e, 0xabe5e7fd, 0xf365052a, 0xb8ee3b60, 0xe06ed9b7, + 0x49e88f14, 0x11686dc3, 0xdffef280, 0x877e1057, 0x2ef846f4, + 0x7678a423, 0x3df39a69, 0x657378be, 0xccf52e1d, 0x9475ccca, + 0x44ae95bc, 0x1c2e776b, 0xb5a821c8, 0xed28c31f, 0xa6a3fd55, + 0xfe231f82, 0x57a54921, 0x0f25abf6, 0xc1b334b5, 0x9933d662, + 0x30b580c1, 0x68356216, 0x23be5c5c, 0x7b3ebe8b, 0xd2b8e828, + 0x8a380aff, 0x4e95d7af, 0x16153578, 0xbf9363db, 0xe713810c, + 0xac98bf46, 0xf4185d91, 0x5d9e0b32, 0x051ee9e5, 0xcb8876a6, + 0x93089471, 0x3a8ec2d2, 0x620e2005, 0x29851e4f, 0x7105fc98, + 0xd883aa3b, 0x800348ec, 0x783419d7, 0x20b4fb00, 0x8932ada3, + 0xd1b24f74, 0x9a39713e, 0xc2b993e9, 0x6b3fc54a, 0x33bf279d, + 0xfd29b8de, 0xa5a95a09, 0x0c2f0caa, 0x54afee7d, 0x1f24d037, + 0x47a432e0, 0xee226443, 0xb6a28694, 0x720f5bc4, 0x2a8fb913, + 0x8309efb0, 0xdb890d67, 0x9002332d, 0xc882d1fa, 0x61048759, + 0x3984658e, 0xf712facd, 0xaf92181a, 0x06144eb9, 0x5e94ac6e, + 0x151f9224, 0x4d9f70f3, 0xe4192650, 0xbc99c487, 0x6c429df1, + 0x34c27f26, 0x9d442985, 0xc5c4cb52, 0x8e4ff518, 0xd6cf17cf, + 0x7f49416c, 0x27c9a3bb, 0xe95f3cf8, 0xb1dfde2f, 0x1859888c, + 0x40d96a5b, 0x0b525411, 0x53d2b6c6, 0xfa54e065, 0xa2d402b2, + 0x6679dfe2, 0x3ef93d35, 0x977f6b96, 0xcfff8941, 0x8474b70b, + 0xdcf455dc, 0x7572037f, 0x2df2e1a8, 0xe3647eeb, 0xbbe49c3c, + 0x1262ca9f, 0x4ae22848, 0x01691602, 0x59e9f4d5, 0xf06fa276, + 0xa8ef40a1}, + {0x00000000, 0x463b6765, 0x8c76ceca, 0xca4da9af, 0x59ebed4e, + 0x1fd08a2b, 0xd59d2384, 0x93a644e1, 0xb2d6db9d, 0xf4edbcf8, + 0x3ea01557, 0x789b7232, 0xeb3d36d3, 0xad0651b6, 0x674bf819, + 0x21709f7c, 0x25abc6e0, 0x6390a185, 0xa9dd082a, 0xefe66f4f, + 0x7c402bae, 0x3a7b4ccb, 0xf036e564, 0xb60d8201, 0x977d1d7d, + 0xd1467a18, 0x1b0bd3b7, 0x5d30b4d2, 0xce96f033, 0x88ad9756, + 0x42e03ef9, 0x04db599c, 0x0b50fc1a, 0x4d6b9b7f, 0x872632d0, + 0xc11d55b5, 0x52bb1154, 0x14807631, 0xdecddf9e, 0x98f6b8fb, + 0xb9862787, 0xffbd40e2, 0x35f0e94d, 0x73cb8e28, 0xe06dcac9, + 0xa656adac, 0x6c1b0403, 0x2a206366, 0x2efb3afa, 0x68c05d9f, + 0xa28df430, 0xe4b69355, 0x7710d7b4, 0x312bb0d1, 0xfb66197e, + 0xbd5d7e1b, 0x9c2de167, 0xda168602, 0x105b2fad, 0x566048c8, + 0xc5c60c29, 0x83fd6b4c, 0x49b0c2e3, 0x0f8ba586, 0x16a0f835, + 0x509b9f50, 0x9ad636ff, 0xdced519a, 0x4f4b157b, 0x0970721e, + 0xc33ddbb1, 0x8506bcd4, 0xa47623a8, 0xe24d44cd, 0x2800ed62, + 0x6e3b8a07, 0xfd9dcee6, 0xbba6a983, 0x71eb002c, 0x37d06749, + 0x330b3ed5, 0x753059b0, 0xbf7df01f, 0xf946977a, 0x6ae0d39b, + 0x2cdbb4fe, 0xe6961d51, 0xa0ad7a34, 0x81dde548, 0xc7e6822d, + 0x0dab2b82, 0x4b904ce7, 0xd8360806, 0x9e0d6f63, 0x5440c6cc, + 0x127ba1a9, 0x1df0042f, 0x5bcb634a, 0x9186cae5, 0xd7bdad80, + 0x441be961, 0x02208e04, 0xc86d27ab, 0x8e5640ce, 0xaf26dfb2, + 0xe91db8d7, 0x23501178, 0x656b761d, 0xf6cd32fc, 0xb0f65599, + 0x7abbfc36, 0x3c809b53, 0x385bc2cf, 0x7e60a5aa, 0xb42d0c05, + 0xf2166b60, 0x61b02f81, 0x278b48e4, 0xedc6e14b, 0xabfd862e, + 0x8a8d1952, 0xccb67e37, 0x06fbd798, 0x40c0b0fd, 0xd366f41c, + 0x955d9379, 0x5f103ad6, 0x192b5db3, 0x2c40f16b, 0x6a7b960e, + 0xa0363fa1, 0xe60d58c4, 0x75ab1c25, 0x33907b40, 0xf9ddd2ef, + 0xbfe6b58a, 0x9e962af6, 0xd8ad4d93, 0x12e0e43c, 0x54db8359, + 0xc77dc7b8, 0x8146a0dd, 0x4b0b0972, 0x0d306e17, 0x09eb378b, + 0x4fd050ee, 0x859df941, 0xc3a69e24, 0x5000dac5, 0x163bbda0, + 0xdc76140f, 0x9a4d736a, 0xbb3dec16, 0xfd068b73, 0x374b22dc, + 0x717045b9, 0xe2d60158, 0xa4ed663d, 0x6ea0cf92, 0x289ba8f7, + 0x27100d71, 0x612b6a14, 0xab66c3bb, 0xed5da4de, 0x7efbe03f, + 0x38c0875a, 0xf28d2ef5, 0xb4b64990, 0x95c6d6ec, 0xd3fdb189, + 0x19b01826, 0x5f8b7f43, 0xcc2d3ba2, 0x8a165cc7, 0x405bf568, + 0x0660920d, 0x02bbcb91, 0x4480acf4, 0x8ecd055b, 0xc8f6623e, + 0x5b5026df, 0x1d6b41ba, 0xd726e815, 0x911d8f70, 0xb06d100c, + 0xf6567769, 0x3c1bdec6, 0x7a20b9a3, 0xe986fd42, 0xafbd9a27, + 0x65f03388, 0x23cb54ed, 0x3ae0095e, 0x7cdb6e3b, 0xb696c794, + 0xf0ada0f1, 0x630be410, 0x25308375, 0xef7d2ada, 0xa9464dbf, + 0x8836d2c3, 0xce0db5a6, 0x04401c09, 0x427b7b6c, 0xd1dd3f8d, + 0x97e658e8, 0x5dabf147, 0x1b909622, 0x1f4bcfbe, 0x5970a8db, + 0x933d0174, 0xd5066611, 0x46a022f0, 0x009b4595, 0xcad6ec3a, + 0x8ced8b5f, 0xad9d1423, 0xeba67346, 0x21ebdae9, 0x67d0bd8c, + 0xf476f96d, 0xb24d9e08, 0x780037a7, 0x3e3b50c2, 0x31b0f544, + 0x778b9221, 0xbdc63b8e, 0xfbfd5ceb, 0x685b180a, 0x2e607f6f, + 0xe42dd6c0, 0xa216b1a5, 0x83662ed9, 0xc55d49bc, 0x0f10e013, + 0x492b8776, 0xda8dc397, 0x9cb6a4f2, 0x56fb0d5d, 0x10c06a38, + 0x141b33a4, 0x522054c1, 0x986dfd6e, 0xde569a0b, 0x4df0deea, + 0x0bcbb98f, 0xc1861020, 0x87bd7745, 0xa6cde839, 0xe0f68f5c, + 0x2abb26f3, 0x6c804196, 0xff260577, 0xb91d6212, 0x7350cbbd, + 0x356bacd8}}; + +#endif + +#endif + +#if N == 6 + +#if W == 8 + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x3db1ecdc, 0x7b63d9b8, 0x46d23564, 0xf6c7b370, + 0xcb765fac, 0x8da46ac8, 0xb0158614, 0x36fe60a1, 0x0b4f8c7d, + 0x4d9db919, 0x702c55c5, 0xc039d3d1, 0xfd883f0d, 0xbb5a0a69, + 0x86ebe6b5, 0x6dfcc142, 0x504d2d9e, 0x169f18fa, 0x2b2ef426, + 0x9b3b7232, 0xa68a9eee, 0xe058ab8a, 0xdde94756, 0x5b02a1e3, + 0x66b34d3f, 0x2061785b, 0x1dd09487, 0xadc51293, 0x9074fe4f, + 0xd6a6cb2b, 0xeb1727f7, 0xdbf98284, 0xe6486e58, 0xa09a5b3c, + 0x9d2bb7e0, 0x2d3e31f4, 0x108fdd28, 0x565de84c, 0x6bec0490, + 0xed07e225, 0xd0b60ef9, 0x96643b9d, 0xabd5d741, 0x1bc05155, + 0x2671bd89, 0x60a388ed, 0x5d126431, 0xb60543c6, 0x8bb4af1a, + 0xcd669a7e, 0xf0d776a2, 0x40c2f0b6, 0x7d731c6a, 0x3ba1290e, + 0x0610c5d2, 0x80fb2367, 0xbd4acfbb, 0xfb98fadf, 0xc6291603, + 0x763c9017, 0x4b8d7ccb, 0x0d5f49af, 0x30eea573, 0x6c820349, + 0x5133ef95, 0x17e1daf1, 0x2a50362d, 0x9a45b039, 0xa7f45ce5, + 0xe1266981, 0xdc97855d, 0x5a7c63e8, 0x67cd8f34, 0x211fba50, + 0x1cae568c, 0xacbbd098, 0x910a3c44, 0xd7d80920, 0xea69e5fc, + 0x017ec20b, 0x3ccf2ed7, 0x7a1d1bb3, 0x47acf76f, 0xf7b9717b, + 0xca089da7, 0x8cdaa8c3, 0xb16b441f, 0x3780a2aa, 0x0a314e76, + 0x4ce37b12, 0x715297ce, 0xc14711da, 0xfcf6fd06, 0xba24c862, + 0x879524be, 0xb77b81cd, 0x8aca6d11, 0xcc185875, 0xf1a9b4a9, + 0x41bc32bd, 0x7c0dde61, 0x3adfeb05, 0x076e07d9, 0x8185e16c, + 0xbc340db0, 0xfae638d4, 0xc757d408, 0x7742521c, 0x4af3bec0, + 0x0c218ba4, 0x31906778, 0xda87408f, 0xe736ac53, 0xa1e49937, + 0x9c5575eb, 0x2c40f3ff, 0x11f11f23, 0x57232a47, 0x6a92c69b, + 0xec79202e, 0xd1c8ccf2, 0x971af996, 0xaaab154a, 0x1abe935e, + 0x270f7f82, 0x61dd4ae6, 0x5c6ca63a, 0xd9040692, 0xe4b5ea4e, + 0xa267df2a, 0x9fd633f6, 0x2fc3b5e2, 0x1272593e, 0x54a06c5a, + 0x69118086, 0xeffa6633, 0xd24b8aef, 0x9499bf8b, 0xa9285357, + 0x193dd543, 0x248c399f, 0x625e0cfb, 0x5fefe027, 0xb4f8c7d0, + 0x89492b0c, 0xcf9b1e68, 0xf22af2b4, 0x423f74a0, 0x7f8e987c, + 0x395cad18, 0x04ed41c4, 0x8206a771, 0xbfb74bad, 0xf9657ec9, + 0xc4d49215, 0x74c11401, 0x4970f8dd, 0x0fa2cdb9, 0x32132165, + 0x02fd8416, 0x3f4c68ca, 0x799e5dae, 0x442fb172, 0xf43a3766, + 0xc98bdbba, 0x8f59eede, 0xb2e80202, 0x3403e4b7, 0x09b2086b, + 0x4f603d0f, 0x72d1d1d3, 0xc2c457c7, 0xff75bb1b, 0xb9a78e7f, + 0x841662a3, 0x6f014554, 0x52b0a988, 0x14629cec, 0x29d37030, + 0x99c6f624, 0xa4771af8, 0xe2a52f9c, 0xdf14c340, 0x59ff25f5, + 0x644ec929, 0x229cfc4d, 0x1f2d1091, 0xaf389685, 0x92897a59, + 0xd45b4f3d, 0xe9eaa3e1, 0xb58605db, 0x8837e907, 0xcee5dc63, + 0xf35430bf, 0x4341b6ab, 0x7ef05a77, 0x38226f13, 0x059383cf, + 0x8378657a, 0xbec989a6, 0xf81bbcc2, 0xc5aa501e, 0x75bfd60a, + 0x480e3ad6, 0x0edc0fb2, 0x336de36e, 0xd87ac499, 0xe5cb2845, + 0xa3191d21, 0x9ea8f1fd, 0x2ebd77e9, 0x130c9b35, 0x55deae51, + 0x686f428d, 0xee84a438, 0xd33548e4, 0x95e77d80, 0xa856915c, + 0x18431748, 0x25f2fb94, 0x6320cef0, 0x5e91222c, 0x6e7f875f, + 0x53ce6b83, 0x151c5ee7, 0x28adb23b, 0x98b8342f, 0xa509d8f3, + 0xe3dbed97, 0xde6a014b, 0x5881e7fe, 0x65300b22, 0x23e23e46, + 0x1e53d29a, 0xae46548e, 0x93f7b852, 0xd5258d36, 0xe89461ea, + 0x0383461d, 0x3e32aac1, 0x78e09fa5, 0x45517379, 0xf544f56d, + 0xc8f519b1, 0x8e272cd5, 0xb396c009, 0x357d26bc, 0x08ccca60, + 0x4e1eff04, 0x73af13d8, 0xc3ba95cc, 0xfe0b7910, 0xb8d94c74, + 0x8568a0a8}, + {0x00000000, 0x69790b65, 0xd2f216ca, 0xbb8b1daf, 0x7e952bd5, + 0x17ec20b0, 0xac673d1f, 0xc51e367a, 0xfd2a57aa, 0x94535ccf, + 0x2fd84160, 0x46a14a05, 0x83bf7c7f, 0xeac6771a, 0x514d6ab5, + 0x383461d0, 0x2125a915, 0x485ca270, 0xf3d7bfdf, 0x9aaeb4ba, + 0x5fb082c0, 0x36c989a5, 0x8d42940a, 0xe43b9f6f, 0xdc0ffebf, + 0xb576f5da, 0x0efde875, 0x6784e310, 0xa29ad56a, 0xcbe3de0f, + 0x7068c3a0, 0x1911c8c5, 0x424b522a, 0x2b32594f, 0x90b944e0, + 0xf9c04f85, 0x3cde79ff, 0x55a7729a, 0xee2c6f35, 0x87556450, + 0xbf610580, 0xd6180ee5, 0x6d93134a, 0x04ea182f, 0xc1f42e55, + 0xa88d2530, 0x1306389f, 0x7a7f33fa, 0x636efb3f, 0x0a17f05a, + 0xb19cedf5, 0xd8e5e690, 0x1dfbd0ea, 0x7482db8f, 0xcf09c620, + 0xa670cd45, 0x9e44ac95, 0xf73da7f0, 0x4cb6ba5f, 0x25cfb13a, + 0xe0d18740, 0x89a88c25, 0x3223918a, 0x5b5a9aef, 0x8496a454, + 0xedefaf31, 0x5664b29e, 0x3f1db9fb, 0xfa038f81, 0x937a84e4, + 0x28f1994b, 0x4188922e, 0x79bcf3fe, 0x10c5f89b, 0xab4ee534, + 0xc237ee51, 0x0729d82b, 0x6e50d34e, 0xd5dbcee1, 0xbca2c584, + 0xa5b30d41, 0xccca0624, 0x77411b8b, 0x1e3810ee, 0xdb262694, + 0xb25f2df1, 0x09d4305e, 0x60ad3b3b, 0x58995aeb, 0x31e0518e, + 0x8a6b4c21, 0xe3124744, 0x260c713e, 0x4f757a5b, 0xf4fe67f4, + 0x9d876c91, 0xc6ddf67e, 0xafa4fd1b, 0x142fe0b4, 0x7d56ebd1, + 0xb848ddab, 0xd131d6ce, 0x6abacb61, 0x03c3c004, 0x3bf7a1d4, + 0x528eaab1, 0xe905b71e, 0x807cbc7b, 0x45628a01, 0x2c1b8164, + 0x97909ccb, 0xfee997ae, 0xe7f85f6b, 0x8e81540e, 0x350a49a1, + 0x5c7342c4, 0x996d74be, 0xf0147fdb, 0x4b9f6274, 0x22e66911, + 0x1ad208c1, 0x73ab03a4, 0xc8201e0b, 0xa159156e, 0x64472314, + 0x0d3e2871, 0xb6b535de, 0xdfcc3ebb, 0xd25c4ee9, 0xbb25458c, + 0x00ae5823, 0x69d75346, 0xacc9653c, 0xc5b06e59, 0x7e3b73f6, + 0x17427893, 0x2f761943, 0x460f1226, 0xfd840f89, 0x94fd04ec, + 0x51e33296, 0x389a39f3, 0x8311245c, 0xea682f39, 0xf379e7fc, + 0x9a00ec99, 0x218bf136, 0x48f2fa53, 0x8deccc29, 0xe495c74c, + 0x5f1edae3, 0x3667d186, 0x0e53b056, 0x672abb33, 0xdca1a69c, + 0xb5d8adf9, 0x70c69b83, 0x19bf90e6, 0xa2348d49, 0xcb4d862c, + 0x90171cc3, 0xf96e17a6, 0x42e50a09, 0x2b9c016c, 0xee823716, + 0x87fb3c73, 0x3c7021dc, 0x55092ab9, 0x6d3d4b69, 0x0444400c, + 0xbfcf5da3, 0xd6b656c6, 0x13a860bc, 0x7ad16bd9, 0xc15a7676, + 0xa8237d13, 0xb132b5d6, 0xd84bbeb3, 0x63c0a31c, 0x0ab9a879, + 0xcfa79e03, 0xa6de9566, 0x1d5588c9, 0x742c83ac, 0x4c18e27c, + 0x2561e919, 0x9eeaf4b6, 0xf793ffd3, 0x328dc9a9, 0x5bf4c2cc, + 0xe07fdf63, 0x8906d406, 0x56caeabd, 0x3fb3e1d8, 0x8438fc77, + 0xed41f712, 0x285fc168, 0x4126ca0d, 0xfaadd7a2, 0x93d4dcc7, + 0xabe0bd17, 0xc299b672, 0x7912abdd, 0x106ba0b8, 0xd57596c2, + 0xbc0c9da7, 0x07878008, 0x6efe8b6d, 0x77ef43a8, 0x1e9648cd, + 0xa51d5562, 0xcc645e07, 0x097a687d, 0x60036318, 0xdb887eb7, + 0xb2f175d2, 0x8ac51402, 0xe3bc1f67, 0x583702c8, 0x314e09ad, + 0xf4503fd7, 0x9d2934b2, 0x26a2291d, 0x4fdb2278, 0x1481b897, + 0x7df8b3f2, 0xc673ae5d, 0xaf0aa538, 0x6a149342, 0x036d9827, + 0xb8e68588, 0xd19f8eed, 0xe9abef3d, 0x80d2e458, 0x3b59f9f7, + 0x5220f292, 0x973ec4e8, 0xfe47cf8d, 0x45ccd222, 0x2cb5d947, + 0x35a41182, 0x5cdd1ae7, 0xe7560748, 0x8e2f0c2d, 0x4b313a57, + 0x22483132, 0x99c32c9d, 0xf0ba27f8, 0xc88e4628, 0xa1f74d4d, + 0x1a7c50e2, 0x73055b87, 0xb61b6dfd, 0xdf626698, 0x64e97b37, + 0x0d907052}, + {0x00000000, 0x7fc99b93, 0xff933726, 0x805aacb5, 0x2457680d, + 0x5b9ef39e, 0xdbc45f2b, 0xa40dc4b8, 0x48aed01a, 0x37674b89, + 0xb73de73c, 0xc8f47caf, 0x6cf9b817, 0x13302384, 0x936a8f31, + 0xeca314a2, 0x915da034, 0xee943ba7, 0x6ece9712, 0x11070c81, + 0xb50ac839, 0xcac353aa, 0x4a99ff1f, 0x3550648c, 0xd9f3702e, + 0xa63aebbd, 0x26604708, 0x59a9dc9b, 0xfda41823, 0x826d83b0, + 0x02372f05, 0x7dfeb496, 0xf9ca4629, 0x8603ddba, 0x0659710f, + 0x7990ea9c, 0xdd9d2e24, 0xa254b5b7, 0x220e1902, 0x5dc78291, + 0xb1649633, 0xcead0da0, 0x4ef7a115, 0x313e3a86, 0x9533fe3e, + 0xeafa65ad, 0x6aa0c918, 0x1569528b, 0x6897e61d, 0x175e7d8e, + 0x9704d13b, 0xe8cd4aa8, 0x4cc08e10, 0x33091583, 0xb353b936, + 0xcc9a22a5, 0x20393607, 0x5ff0ad94, 0xdfaa0121, 0xa0639ab2, + 0x046e5e0a, 0x7ba7c599, 0xfbfd692c, 0x8434f2bf, 0x28e58a13, + 0x572c1180, 0xd776bd35, 0xa8bf26a6, 0x0cb2e21e, 0x737b798d, + 0xf321d538, 0x8ce84eab, 0x604b5a09, 0x1f82c19a, 0x9fd86d2f, + 0xe011f6bc, 0x441c3204, 0x3bd5a997, 0xbb8f0522, 0xc4469eb1, + 0xb9b82a27, 0xc671b1b4, 0x462b1d01, 0x39e28692, 0x9def422a, + 0xe226d9b9, 0x627c750c, 0x1db5ee9f, 0xf116fa3d, 0x8edf61ae, + 0x0e85cd1b, 0x714c5688, 0xd5419230, 0xaa8809a3, 0x2ad2a516, + 0x551b3e85, 0xd12fcc3a, 0xaee657a9, 0x2ebcfb1c, 0x5175608f, + 0xf578a437, 0x8ab13fa4, 0x0aeb9311, 0x75220882, 0x99811c20, + 0xe64887b3, 0x66122b06, 0x19dbb095, 0xbdd6742d, 0xc21fefbe, + 0x4245430b, 0x3d8cd898, 0x40726c0e, 0x3fbbf79d, 0xbfe15b28, + 0xc028c0bb, 0x64250403, 0x1bec9f90, 0x9bb63325, 0xe47fa8b6, + 0x08dcbc14, 0x77152787, 0xf74f8b32, 0x888610a1, 0x2c8bd419, + 0x53424f8a, 0xd318e33f, 0xacd178ac, 0x51cb1426, 0x2e028fb5, + 0xae582300, 0xd191b893, 0x759c7c2b, 0x0a55e7b8, 0x8a0f4b0d, + 0xf5c6d09e, 0x1965c43c, 0x66ac5faf, 0xe6f6f31a, 0x993f6889, + 0x3d32ac31, 0x42fb37a2, 0xc2a19b17, 0xbd680084, 0xc096b412, + 0xbf5f2f81, 0x3f058334, 0x40cc18a7, 0xe4c1dc1f, 0x9b08478c, + 0x1b52eb39, 0x649b70aa, 0x88386408, 0xf7f1ff9b, 0x77ab532e, + 0x0862c8bd, 0xac6f0c05, 0xd3a69796, 0x53fc3b23, 0x2c35a0b0, + 0xa801520f, 0xd7c8c99c, 0x57926529, 0x285bfeba, 0x8c563a02, + 0xf39fa191, 0x73c50d24, 0x0c0c96b7, 0xe0af8215, 0x9f661986, + 0x1f3cb533, 0x60f52ea0, 0xc4f8ea18, 0xbb31718b, 0x3b6bdd3e, + 0x44a246ad, 0x395cf23b, 0x469569a8, 0xc6cfc51d, 0xb9065e8e, + 0x1d0b9a36, 0x62c201a5, 0xe298ad10, 0x9d513683, 0x71f22221, + 0x0e3bb9b2, 0x8e611507, 0xf1a88e94, 0x55a54a2c, 0x2a6cd1bf, + 0xaa367d0a, 0xd5ffe699, 0x792e9e35, 0x06e705a6, 0x86bda913, + 0xf9743280, 0x5d79f638, 0x22b06dab, 0xa2eac11e, 0xdd235a8d, + 0x31804e2f, 0x4e49d5bc, 0xce137909, 0xb1dae29a, 0x15d72622, + 0x6a1ebdb1, 0xea441104, 0x958d8a97, 0xe8733e01, 0x97baa592, + 0x17e00927, 0x682992b4, 0xcc24560c, 0xb3edcd9f, 0x33b7612a, + 0x4c7efab9, 0xa0ddee1b, 0xdf147588, 0x5f4ed93d, 0x208742ae, + 0x848a8616, 0xfb431d85, 0x7b19b130, 0x04d02aa3, 0x80e4d81c, + 0xff2d438f, 0x7f77ef3a, 0x00be74a9, 0xa4b3b011, 0xdb7a2b82, + 0x5b208737, 0x24e91ca4, 0xc84a0806, 0xb7839395, 0x37d93f20, + 0x4810a4b3, 0xec1d600b, 0x93d4fb98, 0x138e572d, 0x6c47ccbe, + 0x11b97828, 0x6e70e3bb, 0xee2a4f0e, 0x91e3d49d, 0x35ee1025, + 0x4a278bb6, 0xca7d2703, 0xb5b4bc90, 0x5917a832, 0x26de33a1, + 0xa6849f14, 0xd94d0487, 0x7d40c03f, 0x02895bac, 0x82d3f719, + 0xfd1a6c8a}, + {0x00000000, 0xa396284c, 0x9c5d56d9, 0x3fcb7e95, 0xe3cbabf3, + 0x405d83bf, 0x7f96fd2a, 0xdc00d566, 0x1ce651a7, 0xbf7079eb, + 0x80bb077e, 0x232d2f32, 0xff2dfa54, 0x5cbbd218, 0x6370ac8d, + 0xc0e684c1, 0x39cca34e, 0x9a5a8b02, 0xa591f597, 0x0607dddb, + 0xda0708bd, 0x799120f1, 0x465a5e64, 0xe5cc7628, 0x252af2e9, + 0x86bcdaa5, 0xb977a430, 0x1ae18c7c, 0xc6e1591a, 0x65777156, + 0x5abc0fc3, 0xf92a278f, 0x7399469c, 0xd00f6ed0, 0xefc41045, + 0x4c523809, 0x9052ed6f, 0x33c4c523, 0x0c0fbbb6, 0xaf9993fa, + 0x6f7f173b, 0xcce93f77, 0xf32241e2, 0x50b469ae, 0x8cb4bcc8, + 0x2f229484, 0x10e9ea11, 0xb37fc25d, 0x4a55e5d2, 0xe9c3cd9e, + 0xd608b30b, 0x759e9b47, 0xa99e4e21, 0x0a08666d, 0x35c318f8, + 0x965530b4, 0x56b3b475, 0xf5259c39, 0xcaeee2ac, 0x6978cae0, + 0xb5781f86, 0x16ee37ca, 0x2925495f, 0x8ab36113, 0xe7328d38, + 0x44a4a574, 0x7b6fdbe1, 0xd8f9f3ad, 0x04f926cb, 0xa76f0e87, + 0x98a47012, 0x3b32585e, 0xfbd4dc9f, 0x5842f4d3, 0x67898a46, + 0xc41fa20a, 0x181f776c, 0xbb895f20, 0x844221b5, 0x27d409f9, + 0xdefe2e76, 0x7d68063a, 0x42a378af, 0xe13550e3, 0x3d358585, + 0x9ea3adc9, 0xa168d35c, 0x02fefb10, 0xc2187fd1, 0x618e579d, + 0x5e452908, 0xfdd30144, 0x21d3d422, 0x8245fc6e, 0xbd8e82fb, + 0x1e18aab7, 0x94abcba4, 0x373de3e8, 0x08f69d7d, 0xab60b531, + 0x77606057, 0xd4f6481b, 0xeb3d368e, 0x48ab1ec2, 0x884d9a03, + 0x2bdbb24f, 0x1410ccda, 0xb786e496, 0x6b8631f0, 0xc81019bc, + 0xf7db6729, 0x544d4f65, 0xad6768ea, 0x0ef140a6, 0x313a3e33, + 0x92ac167f, 0x4eacc319, 0xed3aeb55, 0xd2f195c0, 0x7167bd8c, + 0xb181394d, 0x12171101, 0x2ddc6f94, 0x8e4a47d8, 0x524a92be, + 0xf1dcbaf2, 0xce17c467, 0x6d81ec2b, 0x15141c31, 0xb682347d, + 0x89494ae8, 0x2adf62a4, 0xf6dfb7c2, 0x55499f8e, 0x6a82e11b, + 0xc914c957, 0x09f24d96, 0xaa6465da, 0x95af1b4f, 0x36393303, + 0xea39e665, 0x49afce29, 0x7664b0bc, 0xd5f298f0, 0x2cd8bf7f, + 0x8f4e9733, 0xb085e9a6, 0x1313c1ea, 0xcf13148c, 0x6c853cc0, + 0x534e4255, 0xf0d86a19, 0x303eeed8, 0x93a8c694, 0xac63b801, + 0x0ff5904d, 0xd3f5452b, 0x70636d67, 0x4fa813f2, 0xec3e3bbe, + 0x668d5aad, 0xc51b72e1, 0xfad00c74, 0x59462438, 0x8546f15e, + 0x26d0d912, 0x191ba787, 0xba8d8fcb, 0x7a6b0b0a, 0xd9fd2346, + 0xe6365dd3, 0x45a0759f, 0x99a0a0f9, 0x3a3688b5, 0x05fdf620, + 0xa66bde6c, 0x5f41f9e3, 0xfcd7d1af, 0xc31caf3a, 0x608a8776, + 0xbc8a5210, 0x1f1c7a5c, 0x20d704c9, 0x83412c85, 0x43a7a844, + 0xe0318008, 0xdffafe9d, 0x7c6cd6d1, 0xa06c03b7, 0x03fa2bfb, + 0x3c31556e, 0x9fa77d22, 0xf2269109, 0x51b0b945, 0x6e7bc7d0, + 0xcdedef9c, 0x11ed3afa, 0xb27b12b6, 0x8db06c23, 0x2e26446f, + 0xeec0c0ae, 0x4d56e8e2, 0x729d9677, 0xd10bbe3b, 0x0d0b6b5d, + 0xae9d4311, 0x91563d84, 0x32c015c8, 0xcbea3247, 0x687c1a0b, + 0x57b7649e, 0xf4214cd2, 0x282199b4, 0x8bb7b1f8, 0xb47ccf6d, + 0x17eae721, 0xd70c63e0, 0x749a4bac, 0x4b513539, 0xe8c71d75, + 0x34c7c813, 0x9751e05f, 0xa89a9eca, 0x0b0cb686, 0x81bfd795, + 0x2229ffd9, 0x1de2814c, 0xbe74a900, 0x62747c66, 0xc1e2542a, + 0xfe292abf, 0x5dbf02f3, 0x9d598632, 0x3ecfae7e, 0x0104d0eb, + 0xa292f8a7, 0x7e922dc1, 0xdd04058d, 0xe2cf7b18, 0x41595354, + 0xb87374db, 0x1be55c97, 0x242e2202, 0x87b80a4e, 0x5bb8df28, + 0xf82ef764, 0xc7e589f1, 0x6473a1bd, 0xa495257c, 0x07030d30, + 0x38c873a5, 0x9b5e5be9, 0x475e8e8f, 0xe4c8a6c3, 0xdb03d856, + 0x7895f01a}, + {0x00000000, 0x2a283862, 0x545070c4, 0x7e7848a6, 0xa8a0e188, + 0x8288d9ea, 0xfcf0914c, 0xd6d8a92e, 0x8a30c551, 0xa018fd33, + 0xde60b595, 0xf4488df7, 0x229024d9, 0x08b81cbb, 0x76c0541d, + 0x5ce86c7f, 0xcf108ce3, 0xe538b481, 0x9b40fc27, 0xb168c445, + 0x67b06d6b, 0x4d985509, 0x33e01daf, 0x19c825cd, 0x452049b2, + 0x6f0871d0, 0x11703976, 0x3b580114, 0xed80a83a, 0xc7a89058, + 0xb9d0d8fe, 0x93f8e09c, 0x45501f87, 0x6f7827e5, 0x11006f43, + 0x3b285721, 0xedf0fe0f, 0xc7d8c66d, 0xb9a08ecb, 0x9388b6a9, + 0xcf60dad6, 0xe548e2b4, 0x9b30aa12, 0xb1189270, 0x67c03b5e, + 0x4de8033c, 0x33904b9a, 0x19b873f8, 0x8a409364, 0xa068ab06, + 0xde10e3a0, 0xf438dbc2, 0x22e072ec, 0x08c84a8e, 0x76b00228, + 0x5c983a4a, 0x00705635, 0x2a586e57, 0x542026f1, 0x7e081e93, + 0xa8d0b7bd, 0x82f88fdf, 0xfc80c779, 0xd6a8ff1b, 0x8aa03f0e, + 0xa088076c, 0xdef04fca, 0xf4d877a8, 0x2200de86, 0x0828e6e4, + 0x7650ae42, 0x5c789620, 0x0090fa5f, 0x2ab8c23d, 0x54c08a9b, + 0x7ee8b2f9, 0xa8301bd7, 0x821823b5, 0xfc606b13, 0xd6485371, + 0x45b0b3ed, 0x6f988b8f, 0x11e0c329, 0x3bc8fb4b, 0xed105265, + 0xc7386a07, 0xb94022a1, 0x93681ac3, 0xcf8076bc, 0xe5a84ede, + 0x9bd00678, 0xb1f83e1a, 0x67209734, 0x4d08af56, 0x3370e7f0, + 0x1958df92, 0xcff02089, 0xe5d818eb, 0x9ba0504d, 0xb188682f, + 0x6750c101, 0x4d78f963, 0x3300b1c5, 0x192889a7, 0x45c0e5d8, + 0x6fe8ddba, 0x1190951c, 0x3bb8ad7e, 0xed600450, 0xc7483c32, + 0xb9307494, 0x93184cf6, 0x00e0ac6a, 0x2ac89408, 0x54b0dcae, + 0x7e98e4cc, 0xa8404de2, 0x82687580, 0xfc103d26, 0xd6380544, + 0x8ad0693b, 0xa0f85159, 0xde8019ff, 0xf4a8219d, 0x227088b3, + 0x0858b0d1, 0x7620f877, 0x5c08c015, 0xce31785d, 0xe419403f, + 0x9a610899, 0xb04930fb, 0x669199d5, 0x4cb9a1b7, 0x32c1e911, + 0x18e9d173, 0x4401bd0c, 0x6e29856e, 0x1051cdc8, 0x3a79f5aa, + 0xeca15c84, 0xc68964e6, 0xb8f12c40, 0x92d91422, 0x0121f4be, + 0x2b09ccdc, 0x5571847a, 0x7f59bc18, 0xa9811536, 0x83a92d54, + 0xfdd165f2, 0xd7f95d90, 0x8b1131ef, 0xa139098d, 0xdf41412b, + 0xf5697949, 0x23b1d067, 0x0999e805, 0x77e1a0a3, 0x5dc998c1, + 0x8b6167da, 0xa1495fb8, 0xdf31171e, 0xf5192f7c, 0x23c18652, + 0x09e9be30, 0x7791f696, 0x5db9cef4, 0x0151a28b, 0x2b799ae9, + 0x5501d24f, 0x7f29ea2d, 0xa9f14303, 0x83d97b61, 0xfda133c7, + 0xd7890ba5, 0x4471eb39, 0x6e59d35b, 0x10219bfd, 0x3a09a39f, + 0xecd10ab1, 0xc6f932d3, 0xb8817a75, 0x92a94217, 0xce412e68, + 0xe469160a, 0x9a115eac, 0xb03966ce, 0x66e1cfe0, 0x4cc9f782, + 0x32b1bf24, 0x18998746, 0x44914753, 0x6eb97f31, 0x10c13797, + 0x3ae90ff5, 0xec31a6db, 0xc6199eb9, 0xb861d61f, 0x9249ee7d, + 0xcea18202, 0xe489ba60, 0x9af1f2c6, 0xb0d9caa4, 0x6601638a, + 0x4c295be8, 0x3251134e, 0x18792b2c, 0x8b81cbb0, 0xa1a9f3d2, + 0xdfd1bb74, 0xf5f98316, 0x23212a38, 0x0909125a, 0x77715afc, + 0x5d59629e, 0x01b10ee1, 0x2b993683, 0x55e17e25, 0x7fc94647, + 0xa911ef69, 0x8339d70b, 0xfd419fad, 0xd769a7cf, 0x01c158d4, + 0x2be960b6, 0x55912810, 0x7fb91072, 0xa961b95c, 0x8349813e, + 0xfd31c998, 0xd719f1fa, 0x8bf19d85, 0xa1d9a5e7, 0xdfa1ed41, + 0xf589d523, 0x23517c0d, 0x0979446f, 0x77010cc9, 0x5d2934ab, + 0xced1d437, 0xe4f9ec55, 0x9a81a4f3, 0xb0a99c91, 0x667135bf, + 0x4c590ddd, 0x3221457b, 0x18097d19, 0x44e11166, 0x6ec92904, + 0x10b161a2, 0x3a9959c0, 0xec41f0ee, 0xc669c88c, 0xb811802a, + 0x9239b848}, + {0x00000000, 0x4713f6fb, 0x8e27edf6, 0xc9341b0d, 0xc73eddad, + 0x802d2b56, 0x4919305b, 0x0e0ac6a0, 0x550cbd1b, 0x121f4be0, + 0xdb2b50ed, 0x9c38a616, 0x923260b6, 0xd521964d, 0x1c158d40, + 0x5b067bbb, 0xaa197a36, 0xed0a8ccd, 0x243e97c0, 0x632d613b, + 0x6d27a79b, 0x2a345160, 0xe3004a6d, 0xa413bc96, 0xff15c72d, + 0xb80631d6, 0x71322adb, 0x3621dc20, 0x382b1a80, 0x7f38ec7b, + 0xb60cf776, 0xf11f018d, 0x8f43f22d, 0xc85004d6, 0x01641fdb, + 0x4677e920, 0x487d2f80, 0x0f6ed97b, 0xc65ac276, 0x8149348d, + 0xda4f4f36, 0x9d5cb9cd, 0x5468a2c0, 0x137b543b, 0x1d71929b, + 0x5a626460, 0x93567f6d, 0xd4458996, 0x255a881b, 0x62497ee0, + 0xab7d65ed, 0xec6e9316, 0xe26455b6, 0xa577a34d, 0x6c43b840, + 0x2b504ebb, 0x70563500, 0x3745c3fb, 0xfe71d8f6, 0xb9622e0d, + 0xb768e8ad, 0xf07b1e56, 0x394f055b, 0x7e5cf3a0, 0xc5f6e21b, + 0x82e514e0, 0x4bd10fed, 0x0cc2f916, 0x02c83fb6, 0x45dbc94d, + 0x8cefd240, 0xcbfc24bb, 0x90fa5f00, 0xd7e9a9fb, 0x1eddb2f6, + 0x59ce440d, 0x57c482ad, 0x10d77456, 0xd9e36f5b, 0x9ef099a0, + 0x6fef982d, 0x28fc6ed6, 0xe1c875db, 0xa6db8320, 0xa8d14580, + 0xefc2b37b, 0x26f6a876, 0x61e55e8d, 0x3ae32536, 0x7df0d3cd, + 0xb4c4c8c0, 0xf3d73e3b, 0xfdddf89b, 0xbace0e60, 0x73fa156d, + 0x34e9e396, 0x4ab51036, 0x0da6e6cd, 0xc492fdc0, 0x83810b3b, + 0x8d8bcd9b, 0xca983b60, 0x03ac206d, 0x44bfd696, 0x1fb9ad2d, + 0x58aa5bd6, 0x919e40db, 0xd68db620, 0xd8877080, 0x9f94867b, + 0x56a09d76, 0x11b36b8d, 0xe0ac6a00, 0xa7bf9cfb, 0x6e8b87f6, + 0x2998710d, 0x2792b7ad, 0x60814156, 0xa9b55a5b, 0xeea6aca0, + 0xb5a0d71b, 0xf2b321e0, 0x3b873aed, 0x7c94cc16, 0x729e0ab6, + 0x358dfc4d, 0xfcb9e740, 0xbbaa11bb, 0x509cc277, 0x178f348c, + 0xdebb2f81, 0x99a8d97a, 0x97a21fda, 0xd0b1e921, 0x1985f22c, + 0x5e9604d7, 0x05907f6c, 0x42838997, 0x8bb7929a, 0xcca46461, + 0xc2aea2c1, 0x85bd543a, 0x4c894f37, 0x0b9ab9cc, 0xfa85b841, + 0xbd964eba, 0x74a255b7, 0x33b1a34c, 0x3dbb65ec, 0x7aa89317, + 0xb39c881a, 0xf48f7ee1, 0xaf89055a, 0xe89af3a1, 0x21aee8ac, + 0x66bd1e57, 0x68b7d8f7, 0x2fa42e0c, 0xe6903501, 0xa183c3fa, + 0xdfdf305a, 0x98ccc6a1, 0x51f8ddac, 0x16eb2b57, 0x18e1edf7, + 0x5ff21b0c, 0x96c60001, 0xd1d5f6fa, 0x8ad38d41, 0xcdc07bba, + 0x04f460b7, 0x43e7964c, 0x4ded50ec, 0x0afea617, 0xc3cabd1a, + 0x84d94be1, 0x75c64a6c, 0x32d5bc97, 0xfbe1a79a, 0xbcf25161, + 0xb2f897c1, 0xf5eb613a, 0x3cdf7a37, 0x7bcc8ccc, 0x20caf777, + 0x67d9018c, 0xaeed1a81, 0xe9feec7a, 0xe7f42ada, 0xa0e7dc21, + 0x69d3c72c, 0x2ec031d7, 0x956a206c, 0xd279d697, 0x1b4dcd9a, + 0x5c5e3b61, 0x5254fdc1, 0x15470b3a, 0xdc731037, 0x9b60e6cc, + 0xc0669d77, 0x87756b8c, 0x4e417081, 0x0952867a, 0x075840da, + 0x404bb621, 0x897fad2c, 0xce6c5bd7, 0x3f735a5a, 0x7860aca1, + 0xb154b7ac, 0xf6474157, 0xf84d87f7, 0xbf5e710c, 0x766a6a01, + 0x31799cfa, 0x6a7fe741, 0x2d6c11ba, 0xe4580ab7, 0xa34bfc4c, + 0xad413aec, 0xea52cc17, 0x2366d71a, 0x647521e1, 0x1a29d241, + 0x5d3a24ba, 0x940e3fb7, 0xd31dc94c, 0xdd170fec, 0x9a04f917, + 0x5330e21a, 0x142314e1, 0x4f256f5a, 0x083699a1, 0xc10282ac, + 0x86117457, 0x881bb2f7, 0xcf08440c, 0x063c5f01, 0x412fa9fa, + 0xb030a877, 0xf7235e8c, 0x3e174581, 0x7904b37a, 0x770e75da, + 0x301d8321, 0xf929982c, 0xbe3a6ed7, 0xe53c156c, 0xa22fe397, + 0x6b1bf89a, 0x2c080e61, 0x2202c8c1, 0x65113e3a, 0xac252537, + 0xeb36d3cc}, + {0x00000000, 0xa13984ee, 0x99020f9d, 0x383b8b73, 0xe975197b, + 0x484c9d95, 0x707716e6, 0xd14e9208, 0x099b34b7, 0xa8a2b059, + 0x90993b2a, 0x31a0bfc4, 0xe0ee2dcc, 0x41d7a922, 0x79ec2251, + 0xd8d5a6bf, 0x1336696e, 0xb20fed80, 0x8a3466f3, 0x2b0de21d, + 0xfa437015, 0x5b7af4fb, 0x63417f88, 0xc278fb66, 0x1aad5dd9, + 0xbb94d937, 0x83af5244, 0x2296d6aa, 0xf3d844a2, 0x52e1c04c, + 0x6ada4b3f, 0xcbe3cfd1, 0x266cd2dc, 0x87555632, 0xbf6edd41, + 0x1e5759af, 0xcf19cba7, 0x6e204f49, 0x561bc43a, 0xf72240d4, + 0x2ff7e66b, 0x8ece6285, 0xb6f5e9f6, 0x17cc6d18, 0xc682ff10, + 0x67bb7bfe, 0x5f80f08d, 0xfeb97463, 0x355abbb2, 0x94633f5c, + 0xac58b42f, 0x0d6130c1, 0xdc2fa2c9, 0x7d162627, 0x452dad54, + 0xe41429ba, 0x3cc18f05, 0x9df80beb, 0xa5c38098, 0x04fa0476, + 0xd5b4967e, 0x748d1290, 0x4cb699e3, 0xed8f1d0d, 0x4cd9a5b8, + 0xede02156, 0xd5dbaa25, 0x74e22ecb, 0xa5acbcc3, 0x0495382d, + 0x3caeb35e, 0x9d9737b0, 0x4542910f, 0xe47b15e1, 0xdc409e92, + 0x7d791a7c, 0xac378874, 0x0d0e0c9a, 0x353587e9, 0x940c0307, + 0x5fefccd6, 0xfed64838, 0xc6edc34b, 0x67d447a5, 0xb69ad5ad, + 0x17a35143, 0x2f98da30, 0x8ea15ede, 0x5674f861, 0xf74d7c8f, + 0xcf76f7fc, 0x6e4f7312, 0xbf01e11a, 0x1e3865f4, 0x2603ee87, + 0x873a6a69, 0x6ab57764, 0xcb8cf38a, 0xf3b778f9, 0x528efc17, + 0x83c06e1f, 0x22f9eaf1, 0x1ac26182, 0xbbfbe56c, 0x632e43d3, + 0xc217c73d, 0xfa2c4c4e, 0x5b15c8a0, 0x8a5b5aa8, 0x2b62de46, + 0x13595535, 0xb260d1db, 0x79831e0a, 0xd8ba9ae4, 0xe0811197, + 0x41b89579, 0x90f60771, 0x31cf839f, 0x09f408ec, 0xa8cd8c02, + 0x70182abd, 0xd121ae53, 0xe91a2520, 0x4823a1ce, 0x996d33c6, + 0x3854b728, 0x006f3c5b, 0xa156b8b5, 0x99b34b70, 0x388acf9e, + 0x00b144ed, 0xa188c003, 0x70c6520b, 0xd1ffd6e5, 0xe9c45d96, + 0x48fdd978, 0x90287fc7, 0x3111fb29, 0x092a705a, 0xa813f4b4, + 0x795d66bc, 0xd864e252, 0xe05f6921, 0x4166edcf, 0x8a85221e, + 0x2bbca6f0, 0x13872d83, 0xb2bea96d, 0x63f03b65, 0xc2c9bf8b, + 0xfaf234f8, 0x5bcbb016, 0x831e16a9, 0x22279247, 0x1a1c1934, + 0xbb259dda, 0x6a6b0fd2, 0xcb528b3c, 0xf369004f, 0x525084a1, + 0xbfdf99ac, 0x1ee61d42, 0x26dd9631, 0x87e412df, 0x56aa80d7, + 0xf7930439, 0xcfa88f4a, 0x6e910ba4, 0xb644ad1b, 0x177d29f5, + 0x2f46a286, 0x8e7f2668, 0x5f31b460, 0xfe08308e, 0xc633bbfd, + 0x670a3f13, 0xace9f0c2, 0x0dd0742c, 0x35ebff5f, 0x94d27bb1, + 0x459ce9b9, 0xe4a56d57, 0xdc9ee624, 0x7da762ca, 0xa572c475, + 0x044b409b, 0x3c70cbe8, 0x9d494f06, 0x4c07dd0e, 0xed3e59e0, + 0xd505d293, 0x743c567d, 0xd56aeec8, 0x74536a26, 0x4c68e155, + 0xed5165bb, 0x3c1ff7b3, 0x9d26735d, 0xa51df82e, 0x04247cc0, + 0xdcf1da7f, 0x7dc85e91, 0x45f3d5e2, 0xe4ca510c, 0x3584c304, + 0x94bd47ea, 0xac86cc99, 0x0dbf4877, 0xc65c87a6, 0x67650348, + 0x5f5e883b, 0xfe670cd5, 0x2f299edd, 0x8e101a33, 0xb62b9140, + 0x171215ae, 0xcfc7b311, 0x6efe37ff, 0x56c5bc8c, 0xf7fc3862, + 0x26b2aa6a, 0x878b2e84, 0xbfb0a5f7, 0x1e892119, 0xf3063c14, + 0x523fb8fa, 0x6a043389, 0xcb3db767, 0x1a73256f, 0xbb4aa181, + 0x83712af2, 0x2248ae1c, 0xfa9d08a3, 0x5ba48c4d, 0x639f073e, + 0xc2a683d0, 0x13e811d8, 0xb2d19536, 0x8aea1e45, 0x2bd39aab, + 0xe030557a, 0x4109d194, 0x79325ae7, 0xd80bde09, 0x09454c01, + 0xa87cc8ef, 0x9047439c, 0x317ec772, 0xe9ab61cd, 0x4892e523, + 0x70a96e50, 0xd190eabe, 0x00de78b6, 0xa1e7fc58, 0x99dc772b, + 0x38e5f3c5}, + {0x00000000, 0xe81790a1, 0x0b5e2703, 0xe349b7a2, 0x16bc4e06, + 0xfeabdea7, 0x1de26905, 0xf5f5f9a4, 0x2d789c0c, 0xc56f0cad, + 0x2626bb0f, 0xce312bae, 0x3bc4d20a, 0xd3d342ab, 0x309af509, + 0xd88d65a8, 0x5af13818, 0xb2e6a8b9, 0x51af1f1b, 0xb9b88fba, + 0x4c4d761e, 0xa45ae6bf, 0x4713511d, 0xaf04c1bc, 0x7789a414, + 0x9f9e34b5, 0x7cd78317, 0x94c013b6, 0x6135ea12, 0x89227ab3, + 0x6a6bcd11, 0x827c5db0, 0xb5e27030, 0x5df5e091, 0xbebc5733, + 0x56abc792, 0xa35e3e36, 0x4b49ae97, 0xa8001935, 0x40178994, + 0x989aec3c, 0x708d7c9d, 0x93c4cb3f, 0x7bd35b9e, 0x8e26a23a, + 0x6631329b, 0x85788539, 0x6d6f1598, 0xef134828, 0x0704d889, + 0xe44d6f2b, 0x0c5aff8a, 0xf9af062e, 0x11b8968f, 0xf2f1212d, + 0x1ae6b18c, 0xc26bd424, 0x2a7c4485, 0xc935f327, 0x21226386, + 0xd4d79a22, 0x3cc00a83, 0xdf89bd21, 0x379e2d80, 0xb0b5e621, + 0x58a27680, 0xbbebc122, 0x53fc5183, 0xa609a827, 0x4e1e3886, + 0xad578f24, 0x45401f85, 0x9dcd7a2d, 0x75daea8c, 0x96935d2e, + 0x7e84cd8f, 0x8b71342b, 0x6366a48a, 0x802f1328, 0x68388389, + 0xea44de39, 0x02534e98, 0xe11af93a, 0x090d699b, 0xfcf8903f, + 0x14ef009e, 0xf7a6b73c, 0x1fb1279d, 0xc73c4235, 0x2f2bd294, + 0xcc626536, 0x2475f597, 0xd1800c33, 0x39979c92, 0xdade2b30, + 0x32c9bb91, 0x05579611, 0xed4006b0, 0x0e09b112, 0xe61e21b3, + 0x13ebd817, 0xfbfc48b6, 0x18b5ff14, 0xf0a26fb5, 0x282f0a1d, + 0xc0389abc, 0x23712d1e, 0xcb66bdbf, 0x3e93441b, 0xd684d4ba, + 0x35cd6318, 0xdddaf3b9, 0x5fa6ae09, 0xb7b13ea8, 0x54f8890a, + 0xbcef19ab, 0x491ae00f, 0xa10d70ae, 0x4244c70c, 0xaa5357ad, + 0x72de3205, 0x9ac9a2a4, 0x79801506, 0x919785a7, 0x64627c03, + 0x8c75eca2, 0x6f3c5b00, 0x872bcba1, 0xba1aca03, 0x520d5aa2, + 0xb144ed00, 0x59537da1, 0xaca68405, 0x44b114a4, 0xa7f8a306, + 0x4fef33a7, 0x9762560f, 0x7f75c6ae, 0x9c3c710c, 0x742be1ad, + 0x81de1809, 0x69c988a8, 0x8a803f0a, 0x6297afab, 0xe0ebf21b, + 0x08fc62ba, 0xebb5d518, 0x03a245b9, 0xf657bc1d, 0x1e402cbc, + 0xfd099b1e, 0x151e0bbf, 0xcd936e17, 0x2584feb6, 0xc6cd4914, + 0x2edad9b5, 0xdb2f2011, 0x3338b0b0, 0xd0710712, 0x386697b3, + 0x0ff8ba33, 0xe7ef2a92, 0x04a69d30, 0xecb10d91, 0x1944f435, + 0xf1536494, 0x121ad336, 0xfa0d4397, 0x2280263f, 0xca97b69e, + 0x29de013c, 0xc1c9919d, 0x343c6839, 0xdc2bf898, 0x3f624f3a, + 0xd775df9b, 0x5509822b, 0xbd1e128a, 0x5e57a528, 0xb6403589, + 0x43b5cc2d, 0xaba25c8c, 0x48ebeb2e, 0xa0fc7b8f, 0x78711e27, + 0x90668e86, 0x732f3924, 0x9b38a985, 0x6ecd5021, 0x86dac080, + 0x65937722, 0x8d84e783, 0x0aaf2c22, 0xe2b8bc83, 0x01f10b21, + 0xe9e69b80, 0x1c136224, 0xf404f285, 0x174d4527, 0xff5ad586, + 0x27d7b02e, 0xcfc0208f, 0x2c89972d, 0xc49e078c, 0x316bfe28, + 0xd97c6e89, 0x3a35d92b, 0xd222498a, 0x505e143a, 0xb849849b, + 0x5b003339, 0xb317a398, 0x46e25a3c, 0xaef5ca9d, 0x4dbc7d3f, + 0xa5abed9e, 0x7d268836, 0x95311897, 0x7678af35, 0x9e6f3f94, + 0x6b9ac630, 0x838d5691, 0x60c4e133, 0x88d37192, 0xbf4d5c12, + 0x575accb3, 0xb4137b11, 0x5c04ebb0, 0xa9f11214, 0x41e682b5, + 0xa2af3517, 0x4ab8a5b6, 0x9235c01e, 0x7a2250bf, 0x996be71d, + 0x717c77bc, 0x84898e18, 0x6c9e1eb9, 0x8fd7a91b, 0x67c039ba, + 0xe5bc640a, 0x0dabf4ab, 0xeee24309, 0x06f5d3a8, 0xf3002a0c, + 0x1b17baad, 0xf85e0d0f, 0x10499dae, 0xc8c4f806, 0x20d368a7, + 0xc39adf05, 0x2b8d4fa4, 0xde78b600, 0x366f26a1, 0xd5269103, + 0x3d3101a2}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x0000000000000000, 0xa19017e800000000, 0x03275e0b00000000, + 0xa2b749e300000000, 0x064ebc1600000000, 0xa7deabfe00000000, + 0x0569e21d00000000, 0xa4f9f5f500000000, 0x0c9c782d00000000, + 0xad0c6fc500000000, 0x0fbb262600000000, 0xae2b31ce00000000, + 0x0ad2c43b00000000, 0xab42d3d300000000, 0x09f59a3000000000, + 0xa8658dd800000000, 0x1838f15a00000000, 0xb9a8e6b200000000, + 0x1b1faf5100000000, 0xba8fb8b900000000, 0x1e764d4c00000000, + 0xbfe65aa400000000, 0x1d51134700000000, 0xbcc104af00000000, + 0x14a4897700000000, 0xb5349e9f00000000, 0x1783d77c00000000, + 0xb613c09400000000, 0x12ea356100000000, 0xb37a228900000000, + 0x11cd6b6a00000000, 0xb05d7c8200000000, 0x3070e2b500000000, + 0x91e0f55d00000000, 0x3357bcbe00000000, 0x92c7ab5600000000, + 0x363e5ea300000000, 0x97ae494b00000000, 0x351900a800000000, + 0x9489174000000000, 0x3cec9a9800000000, 0x9d7c8d7000000000, + 0x3fcbc49300000000, 0x9e5bd37b00000000, 0x3aa2268e00000000, + 0x9b32316600000000, 0x3985788500000000, 0x98156f6d00000000, + 0x284813ef00000000, 0x89d8040700000000, 0x2b6f4de400000000, + 0x8aff5a0c00000000, 0x2e06aff900000000, 0x8f96b81100000000, + 0x2d21f1f200000000, 0x8cb1e61a00000000, 0x24d46bc200000000, + 0x85447c2a00000000, 0x27f335c900000000, 0x8663222100000000, + 0x229ad7d400000000, 0x830ac03c00000000, 0x21bd89df00000000, + 0x802d9e3700000000, 0x21e6b5b000000000, 0x8076a25800000000, + 0x22c1ebbb00000000, 0x8351fc5300000000, 0x27a809a600000000, + 0x86381e4e00000000, 0x248f57ad00000000, 0x851f404500000000, + 0x2d7acd9d00000000, 0x8ceada7500000000, 0x2e5d939600000000, + 0x8fcd847e00000000, 0x2b34718b00000000, 0x8aa4666300000000, + 0x28132f8000000000, 0x8983386800000000, 0x39de44ea00000000, + 0x984e530200000000, 0x3af91ae100000000, 0x9b690d0900000000, + 0x3f90f8fc00000000, 0x9e00ef1400000000, 0x3cb7a6f700000000, + 0x9d27b11f00000000, 0x35423cc700000000, 0x94d22b2f00000000, + 0x366562cc00000000, 0x97f5752400000000, 0x330c80d100000000, + 0x929c973900000000, 0x302bdeda00000000, 0x91bbc93200000000, + 0x1196570500000000, 0xb00640ed00000000, 0x12b1090e00000000, + 0xb3211ee600000000, 0x17d8eb1300000000, 0xb648fcfb00000000, + 0x14ffb51800000000, 0xb56fa2f000000000, 0x1d0a2f2800000000, + 0xbc9a38c000000000, 0x1e2d712300000000, 0xbfbd66cb00000000, + 0x1b44933e00000000, 0xbad484d600000000, 0x1863cd3500000000, + 0xb9f3dadd00000000, 0x09aea65f00000000, 0xa83eb1b700000000, + 0x0a89f85400000000, 0xab19efbc00000000, 0x0fe01a4900000000, + 0xae700da100000000, 0x0cc7444200000000, 0xad5753aa00000000, + 0x0532de7200000000, 0xa4a2c99a00000000, 0x0615807900000000, + 0xa785979100000000, 0x037c626400000000, 0xa2ec758c00000000, + 0x005b3c6f00000000, 0xa1cb2b8700000000, 0x03ca1aba00000000, + 0xa25a0d5200000000, 0x00ed44b100000000, 0xa17d535900000000, + 0x0584a6ac00000000, 0xa414b14400000000, 0x06a3f8a700000000, + 0xa733ef4f00000000, 0x0f56629700000000, 0xaec6757f00000000, + 0x0c713c9c00000000, 0xade12b7400000000, 0x0918de8100000000, + 0xa888c96900000000, 0x0a3f808a00000000, 0xabaf976200000000, + 0x1bf2ebe000000000, 0xba62fc0800000000, 0x18d5b5eb00000000, + 0xb945a20300000000, 0x1dbc57f600000000, 0xbc2c401e00000000, + 0x1e9b09fd00000000, 0xbf0b1e1500000000, 0x176e93cd00000000, + 0xb6fe842500000000, 0x1449cdc600000000, 0xb5d9da2e00000000, + 0x11202fdb00000000, 0xb0b0383300000000, 0x120771d000000000, + 0xb397663800000000, 0x33baf80f00000000, 0x922aefe700000000, + 0x309da60400000000, 0x910db1ec00000000, 0x35f4441900000000, + 0x946453f100000000, 0x36d31a1200000000, 0x97430dfa00000000, + 0x3f26802200000000, 0x9eb697ca00000000, 0x3c01de2900000000, + 0x9d91c9c100000000, 0x39683c3400000000, 0x98f82bdc00000000, + 0x3a4f623f00000000, 0x9bdf75d700000000, 0x2b82095500000000, + 0x8a121ebd00000000, 0x28a5575e00000000, 0x893540b600000000, + 0x2dccb54300000000, 0x8c5ca2ab00000000, 0x2eebeb4800000000, + 0x8f7bfca000000000, 0x271e717800000000, 0x868e669000000000, + 0x24392f7300000000, 0x85a9389b00000000, 0x2150cd6e00000000, + 0x80c0da8600000000, 0x2277936500000000, 0x83e7848d00000000, + 0x222caf0a00000000, 0x83bcb8e200000000, 0x210bf10100000000, + 0x809be6e900000000, 0x2462131c00000000, 0x85f204f400000000, + 0x27454d1700000000, 0x86d55aff00000000, 0x2eb0d72700000000, + 0x8f20c0cf00000000, 0x2d97892c00000000, 0x8c079ec400000000, + 0x28fe6b3100000000, 0x896e7cd900000000, 0x2bd9353a00000000, + 0x8a4922d200000000, 0x3a145e5000000000, 0x9b8449b800000000, + 0x3933005b00000000, 0x98a317b300000000, 0x3c5ae24600000000, + 0x9dcaf5ae00000000, 0x3f7dbc4d00000000, 0x9eedaba500000000, + 0x3688267d00000000, 0x9718319500000000, 0x35af787600000000, + 0x943f6f9e00000000, 0x30c69a6b00000000, 0x91568d8300000000, + 0x33e1c46000000000, 0x9271d38800000000, 0x125c4dbf00000000, + 0xb3cc5a5700000000, 0x117b13b400000000, 0xb0eb045c00000000, + 0x1412f1a900000000, 0xb582e64100000000, 0x1735afa200000000, + 0xb6a5b84a00000000, 0x1ec0359200000000, 0xbf50227a00000000, + 0x1de76b9900000000, 0xbc777c7100000000, 0x188e898400000000, + 0xb91e9e6c00000000, 0x1ba9d78f00000000, 0xba39c06700000000, + 0x0a64bce500000000, 0xabf4ab0d00000000, 0x0943e2ee00000000, + 0xa8d3f50600000000, 0x0c2a00f300000000, 0xadba171b00000000, + 0x0f0d5ef800000000, 0xae9d491000000000, 0x06f8c4c800000000, + 0xa768d32000000000, 0x05df9ac300000000, 0xa44f8d2b00000000, + 0x00b678de00000000, 0xa1266f3600000000, 0x039126d500000000, + 0xa201313d00000000}, + {0x0000000000000000, 0xee8439a100000000, 0x9d0f029900000000, + 0x738b3b3800000000, 0x7b1975e900000000, 0x959d4c4800000000, + 0xe616777000000000, 0x08924ed100000000, 0xb7349b0900000000, + 0x59b0a2a800000000, 0x2a3b999000000000, 0xc4bfa03100000000, + 0xcc2deee000000000, 0x22a9d74100000000, 0x5122ec7900000000, + 0xbfa6d5d800000000, 0x6e69361300000000, 0x80ed0fb200000000, + 0xf366348a00000000, 0x1de20d2b00000000, 0x157043fa00000000, + 0xfbf47a5b00000000, 0x887f416300000000, 0x66fb78c200000000, + 0xd95dad1a00000000, 0x37d994bb00000000, 0x4452af8300000000, + 0xaad6962200000000, 0xa244d8f300000000, 0x4cc0e15200000000, + 0x3f4bda6a00000000, 0xd1cfe3cb00000000, 0xdcd26c2600000000, + 0x3256558700000000, 0x41dd6ebf00000000, 0xaf59571e00000000, + 0xa7cb19cf00000000, 0x494f206e00000000, 0x3ac41b5600000000, + 0xd44022f700000000, 0x6be6f72f00000000, 0x8562ce8e00000000, + 0xf6e9f5b600000000, 0x186dcc1700000000, 0x10ff82c600000000, + 0xfe7bbb6700000000, 0x8df0805f00000000, 0x6374b9fe00000000, + 0xb2bb5a3500000000, 0x5c3f639400000000, 0x2fb458ac00000000, + 0xc130610d00000000, 0xc9a22fdc00000000, 0x2726167d00000000, + 0x54ad2d4500000000, 0xba2914e400000000, 0x058fc13c00000000, + 0xeb0bf89d00000000, 0x9880c3a500000000, 0x7604fa0400000000, + 0x7e96b4d500000000, 0x90128d7400000000, 0xe399b64c00000000, + 0x0d1d8fed00000000, 0xb8a5d94c00000000, 0x5621e0ed00000000, + 0x25aadbd500000000, 0xcb2ee27400000000, 0xc3bcaca500000000, + 0x2d38950400000000, 0x5eb3ae3c00000000, 0xb037979d00000000, + 0x0f91424500000000, 0xe1157be400000000, 0x929e40dc00000000, + 0x7c1a797d00000000, 0x748837ac00000000, 0x9a0c0e0d00000000, + 0xe987353500000000, 0x07030c9400000000, 0xd6ccef5f00000000, + 0x3848d6fe00000000, 0x4bc3edc600000000, 0xa547d46700000000, + 0xadd59ab600000000, 0x4351a31700000000, 0x30da982f00000000, + 0xde5ea18e00000000, 0x61f8745600000000, 0x8f7c4df700000000, + 0xfcf776cf00000000, 0x12734f6e00000000, 0x1ae101bf00000000, + 0xf465381e00000000, 0x87ee032600000000, 0x696a3a8700000000, + 0x6477b56a00000000, 0x8af38ccb00000000, 0xf978b7f300000000, + 0x17fc8e5200000000, 0x1f6ec08300000000, 0xf1eaf92200000000, + 0x8261c21a00000000, 0x6ce5fbbb00000000, 0xd3432e6300000000, + 0x3dc717c200000000, 0x4e4c2cfa00000000, 0xa0c8155b00000000, + 0xa85a5b8a00000000, 0x46de622b00000000, 0x3555591300000000, + 0xdbd160b200000000, 0x0a1e837900000000, 0xe49abad800000000, + 0x971181e000000000, 0x7995b84100000000, 0x7107f69000000000, + 0x9f83cf3100000000, 0xec08f40900000000, 0x028ccda800000000, + 0xbd2a187000000000, 0x53ae21d100000000, 0x20251ae900000000, + 0xcea1234800000000, 0xc6336d9900000000, 0x28b7543800000000, + 0x5b3c6f0000000000, 0xb5b856a100000000, 0x704bb39900000000, + 0x9ecf8a3800000000, 0xed44b10000000000, 0x03c088a100000000, + 0x0b52c67000000000, 0xe5d6ffd100000000, 0x965dc4e900000000, + 0x78d9fd4800000000, 0xc77f289000000000, 0x29fb113100000000, + 0x5a702a0900000000, 0xb4f413a800000000, 0xbc665d7900000000, + 0x52e264d800000000, 0x21695fe000000000, 0xcfed664100000000, + 0x1e22858a00000000, 0xf0a6bc2b00000000, 0x832d871300000000, + 0x6da9beb200000000, 0x653bf06300000000, 0x8bbfc9c200000000, + 0xf834f2fa00000000, 0x16b0cb5b00000000, 0xa9161e8300000000, + 0x4792272200000000, 0x34191c1a00000000, 0xda9d25bb00000000, + 0xd20f6b6a00000000, 0x3c8b52cb00000000, 0x4f0069f300000000, + 0xa184505200000000, 0xac99dfbf00000000, 0x421de61e00000000, + 0x3196dd2600000000, 0xdf12e48700000000, 0xd780aa5600000000, + 0x390493f700000000, 0x4a8fa8cf00000000, 0xa40b916e00000000, + 0x1bad44b600000000, 0xf5297d1700000000, 0x86a2462f00000000, + 0x68267f8e00000000, 0x60b4315f00000000, 0x8e3008fe00000000, + 0xfdbb33c600000000, 0x133f0a6700000000, 0xc2f0e9ac00000000, + 0x2c74d00d00000000, 0x5fffeb3500000000, 0xb17bd29400000000, + 0xb9e99c4500000000, 0x576da5e400000000, 0x24e69edc00000000, + 0xca62a77d00000000, 0x75c472a500000000, 0x9b404b0400000000, + 0xe8cb703c00000000, 0x064f499d00000000, 0x0edd074c00000000, + 0xe0593eed00000000, 0x93d205d500000000, 0x7d563c7400000000, + 0xc8ee6ad500000000, 0x266a537400000000, 0x55e1684c00000000, + 0xbb6551ed00000000, 0xb3f71f3c00000000, 0x5d73269d00000000, + 0x2ef81da500000000, 0xc07c240400000000, 0x7fdaf1dc00000000, + 0x915ec87d00000000, 0xe2d5f34500000000, 0x0c51cae400000000, + 0x04c3843500000000, 0xea47bd9400000000, 0x99cc86ac00000000, + 0x7748bf0d00000000, 0xa6875cc600000000, 0x4803656700000000, + 0x3b885e5f00000000, 0xd50c67fe00000000, 0xdd9e292f00000000, + 0x331a108e00000000, 0x40912bb600000000, 0xae15121700000000, + 0x11b3c7cf00000000, 0xff37fe6e00000000, 0x8cbcc55600000000, + 0x6238fcf700000000, 0x6aaab22600000000, 0x842e8b8700000000, + 0xf7a5b0bf00000000, 0x1921891e00000000, 0x143c06f300000000, + 0xfab83f5200000000, 0x8933046a00000000, 0x67b73dcb00000000, + 0x6f25731a00000000, 0x81a14abb00000000, 0xf22a718300000000, + 0x1cae482200000000, 0xa3089dfa00000000, 0x4d8ca45b00000000, + 0x3e079f6300000000, 0xd083a6c200000000, 0xd811e81300000000, + 0x3695d1b200000000, 0x451eea8a00000000, 0xab9ad32b00000000, + 0x7a5530e000000000, 0x94d1094100000000, 0xe75a327900000000, + 0x09de0bd800000000, 0x014c450900000000, 0xefc87ca800000000, + 0x9c43479000000000, 0x72c77e3100000000, 0xcd61abe900000000, + 0x23e5924800000000, 0x506ea97000000000, 0xbeea90d100000000, + 0xb678de0000000000, 0x58fce7a100000000, 0x2b77dc9900000000, + 0xc5f3e53800000000}, + {0x0000000000000000, 0xfbf6134700000000, 0xf6ed278e00000000, + 0x0d1b34c900000000, 0xaddd3ec700000000, 0x562b2d8000000000, + 0x5b30194900000000, 0xa0c60a0e00000000, 0x1bbd0c5500000000, + 0xe04b1f1200000000, 0xed502bdb00000000, 0x16a6389c00000000, + 0xb660329200000000, 0x4d9621d500000000, 0x408d151c00000000, + 0xbb7b065b00000000, 0x367a19aa00000000, 0xcd8c0aed00000000, + 0xc0973e2400000000, 0x3b612d6300000000, 0x9ba7276d00000000, + 0x6051342a00000000, 0x6d4a00e300000000, 0x96bc13a400000000, + 0x2dc715ff00000000, 0xd63106b800000000, 0xdb2a327100000000, + 0x20dc213600000000, 0x801a2b3800000000, 0x7bec387f00000000, + 0x76f70cb600000000, 0x8d011ff100000000, 0x2df2438f00000000, + 0xd60450c800000000, 0xdb1f640100000000, 0x20e9774600000000, + 0x802f7d4800000000, 0x7bd96e0f00000000, 0x76c25ac600000000, + 0x8d34498100000000, 0x364f4fda00000000, 0xcdb95c9d00000000, + 0xc0a2685400000000, 0x3b547b1300000000, 0x9b92711d00000000, + 0x6064625a00000000, 0x6d7f569300000000, 0x968945d400000000, + 0x1b885a2500000000, 0xe07e496200000000, 0xed657dab00000000, + 0x16936eec00000000, 0xb65564e200000000, 0x4da377a500000000, + 0x40b8436c00000000, 0xbb4e502b00000000, 0x0035567000000000, + 0xfbc3453700000000, 0xf6d871fe00000000, 0x0d2e62b900000000, + 0xade868b700000000, 0x561e7bf000000000, 0x5b054f3900000000, + 0xa0f35c7e00000000, 0x1be2f6c500000000, 0xe014e58200000000, + 0xed0fd14b00000000, 0x16f9c20c00000000, 0xb63fc80200000000, + 0x4dc9db4500000000, 0x40d2ef8c00000000, 0xbb24fccb00000000, + 0x005ffa9000000000, 0xfba9e9d700000000, 0xf6b2dd1e00000000, + 0x0d44ce5900000000, 0xad82c45700000000, 0x5674d71000000000, + 0x5b6fe3d900000000, 0xa099f09e00000000, 0x2d98ef6f00000000, + 0xd66efc2800000000, 0xdb75c8e100000000, 0x2083dba600000000, + 0x8045d1a800000000, 0x7bb3c2ef00000000, 0x76a8f62600000000, + 0x8d5ee56100000000, 0x3625e33a00000000, 0xcdd3f07d00000000, + 0xc0c8c4b400000000, 0x3b3ed7f300000000, 0x9bf8ddfd00000000, + 0x600eceba00000000, 0x6d15fa7300000000, 0x96e3e93400000000, + 0x3610b54a00000000, 0xcde6a60d00000000, 0xc0fd92c400000000, + 0x3b0b818300000000, 0x9bcd8b8d00000000, 0x603b98ca00000000, + 0x6d20ac0300000000, 0x96d6bf4400000000, 0x2dadb91f00000000, + 0xd65baa5800000000, 0xdb409e9100000000, 0x20b68dd600000000, + 0x807087d800000000, 0x7b86949f00000000, 0x769da05600000000, + 0x8d6bb31100000000, 0x006aace000000000, 0xfb9cbfa700000000, + 0xf6878b6e00000000, 0x0d71982900000000, 0xadb7922700000000, + 0x5641816000000000, 0x5b5ab5a900000000, 0xa0aca6ee00000000, + 0x1bd7a0b500000000, 0xe021b3f200000000, 0xed3a873b00000000, + 0x16cc947c00000000, 0xb60a9e7200000000, 0x4dfc8d3500000000, + 0x40e7b9fc00000000, 0xbb11aabb00000000, 0x77c29c5000000000, + 0x8c348f1700000000, 0x812fbbde00000000, 0x7ad9a89900000000, + 0xda1fa29700000000, 0x21e9b1d000000000, 0x2cf2851900000000, + 0xd704965e00000000, 0x6c7f900500000000, 0x9789834200000000, + 0x9a92b78b00000000, 0x6164a4cc00000000, 0xc1a2aec200000000, + 0x3a54bd8500000000, 0x374f894c00000000, 0xccb99a0b00000000, + 0x41b885fa00000000, 0xba4e96bd00000000, 0xb755a27400000000, + 0x4ca3b13300000000, 0xec65bb3d00000000, 0x1793a87a00000000, + 0x1a889cb300000000, 0xe17e8ff400000000, 0x5a0589af00000000, + 0xa1f39ae800000000, 0xace8ae2100000000, 0x571ebd6600000000, + 0xf7d8b76800000000, 0x0c2ea42f00000000, 0x013590e600000000, + 0xfac383a100000000, 0x5a30dfdf00000000, 0xa1c6cc9800000000, + 0xacddf85100000000, 0x572beb1600000000, 0xf7ede11800000000, + 0x0c1bf25f00000000, 0x0100c69600000000, 0xfaf6d5d100000000, + 0x418dd38a00000000, 0xba7bc0cd00000000, 0xb760f40400000000, + 0x4c96e74300000000, 0xec50ed4d00000000, 0x17a6fe0a00000000, + 0x1abdcac300000000, 0xe14bd98400000000, 0x6c4ac67500000000, + 0x97bcd53200000000, 0x9aa7e1fb00000000, 0x6151f2bc00000000, + 0xc197f8b200000000, 0x3a61ebf500000000, 0x377adf3c00000000, + 0xcc8ccc7b00000000, 0x77f7ca2000000000, 0x8c01d96700000000, + 0x811aedae00000000, 0x7aecfee900000000, 0xda2af4e700000000, + 0x21dce7a000000000, 0x2cc7d36900000000, 0xd731c02e00000000, + 0x6c206a9500000000, 0x97d679d200000000, 0x9acd4d1b00000000, + 0x613b5e5c00000000, 0xc1fd545200000000, 0x3a0b471500000000, + 0x371073dc00000000, 0xcce6609b00000000, 0x779d66c000000000, + 0x8c6b758700000000, 0x8170414e00000000, 0x7a86520900000000, + 0xda40580700000000, 0x21b64b4000000000, 0x2cad7f8900000000, + 0xd75b6cce00000000, 0x5a5a733f00000000, 0xa1ac607800000000, + 0xacb754b100000000, 0x574147f600000000, 0xf7874df800000000, + 0x0c715ebf00000000, 0x016a6a7600000000, 0xfa9c793100000000, + 0x41e77f6a00000000, 0xba116c2d00000000, 0xb70a58e400000000, + 0x4cfc4ba300000000, 0xec3a41ad00000000, 0x17cc52ea00000000, + 0x1ad7662300000000, 0xe121756400000000, 0x41d2291a00000000, + 0xba243a5d00000000, 0xb73f0e9400000000, 0x4cc91dd300000000, + 0xec0f17dd00000000, 0x17f9049a00000000, 0x1ae2305300000000, + 0xe114231400000000, 0x5a6f254f00000000, 0xa199360800000000, + 0xac8202c100000000, 0x5774118600000000, 0xf7b21b8800000000, + 0x0c4408cf00000000, 0x015f3c0600000000, 0xfaa92f4100000000, + 0x77a830b000000000, 0x8c5e23f700000000, 0x8145173e00000000, + 0x7ab3047900000000, 0xda750e7700000000, 0x21831d3000000000, + 0x2c9829f900000000, 0xd76e3abe00000000, 0x6c153ce500000000, + 0x97e32fa200000000, 0x9af81b6b00000000, 0x610e082c00000000, + 0xc1c8022200000000, 0x3a3e116500000000, 0x372525ac00000000, + 0xccd336eb00000000}, + {0x0000000000000000, 0x6238282a00000000, 0xc470505400000000, + 0xa648787e00000000, 0x88e1a0a800000000, 0xead9888200000000, + 0x4c91f0fc00000000, 0x2ea9d8d600000000, 0x51c5308a00000000, + 0x33fd18a000000000, 0x95b560de00000000, 0xf78d48f400000000, + 0xd924902200000000, 0xbb1cb80800000000, 0x1d54c07600000000, + 0x7f6ce85c00000000, 0xe38c10cf00000000, 0x81b438e500000000, + 0x27fc409b00000000, 0x45c468b100000000, 0x6b6db06700000000, + 0x0955984d00000000, 0xaf1de03300000000, 0xcd25c81900000000, + 0xb249204500000000, 0xd071086f00000000, 0x7639701100000000, + 0x1401583b00000000, 0x3aa880ed00000000, 0x5890a8c700000000, + 0xfed8d0b900000000, 0x9ce0f89300000000, 0x871f504500000000, + 0xe527786f00000000, 0x436f001100000000, 0x2157283b00000000, + 0x0ffef0ed00000000, 0x6dc6d8c700000000, 0xcb8ea0b900000000, + 0xa9b6889300000000, 0xd6da60cf00000000, 0xb4e248e500000000, + 0x12aa309b00000000, 0x709218b100000000, 0x5e3bc06700000000, + 0x3c03e84d00000000, 0x9a4b903300000000, 0xf873b81900000000, + 0x6493408a00000000, 0x06ab68a000000000, 0xa0e310de00000000, + 0xc2db38f400000000, 0xec72e02200000000, 0x8e4ac80800000000, + 0x2802b07600000000, 0x4a3a985c00000000, 0x3556700000000000, + 0x576e582a00000000, 0xf126205400000000, 0x931e087e00000000, + 0xbdb7d0a800000000, 0xdf8ff88200000000, 0x79c780fc00000000, + 0x1bffa8d600000000, 0x0e3fa08a00000000, 0x6c0788a000000000, + 0xca4ff0de00000000, 0xa877d8f400000000, 0x86de002200000000, + 0xe4e6280800000000, 0x42ae507600000000, 0x2096785c00000000, + 0x5ffa900000000000, 0x3dc2b82a00000000, 0x9b8ac05400000000, + 0xf9b2e87e00000000, 0xd71b30a800000000, 0xb523188200000000, + 0x136b60fc00000000, 0x715348d600000000, 0xedb3b04500000000, + 0x8f8b986f00000000, 0x29c3e01100000000, 0x4bfbc83b00000000, + 0x655210ed00000000, 0x076a38c700000000, 0xa12240b900000000, + 0xc31a689300000000, 0xbc7680cf00000000, 0xde4ea8e500000000, + 0x7806d09b00000000, 0x1a3ef8b100000000, 0x3497206700000000, + 0x56af084d00000000, 0xf0e7703300000000, 0x92df581900000000, + 0x8920f0cf00000000, 0xeb18d8e500000000, 0x4d50a09b00000000, + 0x2f6888b100000000, 0x01c1506700000000, 0x63f9784d00000000, + 0xc5b1003300000000, 0xa789281900000000, 0xd8e5c04500000000, + 0xbadde86f00000000, 0x1c95901100000000, 0x7eadb83b00000000, + 0x500460ed00000000, 0x323c48c700000000, 0x947430b900000000, + 0xf64c189300000000, 0x6aace00000000000, 0x0894c82a00000000, + 0xaedcb05400000000, 0xcce4987e00000000, 0xe24d40a800000000, + 0x8075688200000000, 0x263d10fc00000000, 0x440538d600000000, + 0x3b69d08a00000000, 0x5951f8a000000000, 0xff1980de00000000, + 0x9d21a8f400000000, 0xb388702200000000, 0xd1b0580800000000, + 0x77f8207600000000, 0x15c0085c00000000, 0x5d7831ce00000000, + 0x3f4019e400000000, 0x9908619a00000000, 0xfb3049b000000000, + 0xd599916600000000, 0xb7a1b94c00000000, 0x11e9c13200000000, + 0x73d1e91800000000, 0x0cbd014400000000, 0x6e85296e00000000, + 0xc8cd511000000000, 0xaaf5793a00000000, 0x845ca1ec00000000, + 0xe66489c600000000, 0x402cf1b800000000, 0x2214d99200000000, + 0xbef4210100000000, 0xdccc092b00000000, 0x7a84715500000000, + 0x18bc597f00000000, 0x361581a900000000, 0x542da98300000000, + 0xf265d1fd00000000, 0x905df9d700000000, 0xef31118b00000000, + 0x8d0939a100000000, 0x2b4141df00000000, 0x497969f500000000, + 0x67d0b12300000000, 0x05e8990900000000, 0xa3a0e17700000000, + 0xc198c95d00000000, 0xda67618b00000000, 0xb85f49a100000000, + 0x1e1731df00000000, 0x7c2f19f500000000, 0x5286c12300000000, + 0x30bee90900000000, 0x96f6917700000000, 0xf4ceb95d00000000, + 0x8ba2510100000000, 0xe99a792b00000000, 0x4fd2015500000000, + 0x2dea297f00000000, 0x0343f1a900000000, 0x617bd98300000000, + 0xc733a1fd00000000, 0xa50b89d700000000, 0x39eb714400000000, + 0x5bd3596e00000000, 0xfd9b211000000000, 0x9fa3093a00000000, + 0xb10ad1ec00000000, 0xd332f9c600000000, 0x757a81b800000000, + 0x1742a99200000000, 0x682e41ce00000000, 0x0a1669e400000000, + 0xac5e119a00000000, 0xce6639b000000000, 0xe0cfe16600000000, + 0x82f7c94c00000000, 0x24bfb13200000000, 0x4687991800000000, + 0x5347914400000000, 0x317fb96e00000000, 0x9737c11000000000, + 0xf50fe93a00000000, 0xdba631ec00000000, 0xb99e19c600000000, + 0x1fd661b800000000, 0x7dee499200000000, 0x0282a1ce00000000, + 0x60ba89e400000000, 0xc6f2f19a00000000, 0xa4cad9b000000000, + 0x8a63016600000000, 0xe85b294c00000000, 0x4e13513200000000, + 0x2c2b791800000000, 0xb0cb818b00000000, 0xd2f3a9a100000000, + 0x74bbd1df00000000, 0x1683f9f500000000, 0x382a212300000000, + 0x5a12090900000000, 0xfc5a717700000000, 0x9e62595d00000000, + 0xe10eb10100000000, 0x8336992b00000000, 0x257ee15500000000, + 0x4746c97f00000000, 0x69ef11a900000000, 0x0bd7398300000000, + 0xad9f41fd00000000, 0xcfa769d700000000, 0xd458c10100000000, + 0xb660e92b00000000, 0x1028915500000000, 0x7210b97f00000000, + 0x5cb961a900000000, 0x3e81498300000000, 0x98c931fd00000000, + 0xfaf119d700000000, 0x859df18b00000000, 0xe7a5d9a100000000, + 0x41eda1df00000000, 0x23d589f500000000, 0x0d7c512300000000, + 0x6f44790900000000, 0xc90c017700000000, 0xab34295d00000000, + 0x37d4d1ce00000000, 0x55ecf9e400000000, 0xf3a4819a00000000, + 0x919ca9b000000000, 0xbf35716600000000, 0xdd0d594c00000000, + 0x7b45213200000000, 0x197d091800000000, 0x6611e14400000000, + 0x0429c96e00000000, 0xa261b11000000000, 0xc059993a00000000, + 0xeef041ec00000000, 0x8cc869c600000000, 0x2a8011b800000000, + 0x48b8399200000000}, + {0x0000000000000000, 0x4c2896a300000000, 0xd9565d9c00000000, + 0x957ecb3f00000000, 0xf3abcbe300000000, 0xbf835d4000000000, + 0x2afd967f00000000, 0x66d500dc00000000, 0xa751e61c00000000, + 0xeb7970bf00000000, 0x7e07bb8000000000, 0x322f2d2300000000, + 0x54fa2dff00000000, 0x18d2bb5c00000000, 0x8dac706300000000, + 0xc184e6c000000000, 0x4ea3cc3900000000, 0x028b5a9a00000000, + 0x97f591a500000000, 0xdbdd070600000000, 0xbd0807da00000000, + 0xf120917900000000, 0x645e5a4600000000, 0x2876cce500000000, + 0xe9f22a2500000000, 0xa5dabc8600000000, 0x30a477b900000000, + 0x7c8ce11a00000000, 0x1a59e1c600000000, 0x5671776500000000, + 0xc30fbc5a00000000, 0x8f272af900000000, 0x9c46997300000000, + 0xd06e0fd000000000, 0x4510c4ef00000000, 0x0938524c00000000, + 0x6fed529000000000, 0x23c5c43300000000, 0xb6bb0f0c00000000, + 0xfa9399af00000000, 0x3b177f6f00000000, 0x773fe9cc00000000, + 0xe24122f300000000, 0xae69b45000000000, 0xc8bcb48c00000000, + 0x8494222f00000000, 0x11eae91000000000, 0x5dc27fb300000000, + 0xd2e5554a00000000, 0x9ecdc3e900000000, 0x0bb308d600000000, + 0x479b9e7500000000, 0x214e9ea900000000, 0x6d66080a00000000, + 0xf818c33500000000, 0xb430559600000000, 0x75b4b35600000000, + 0x399c25f500000000, 0xace2eeca00000000, 0xe0ca786900000000, + 0x861f78b500000000, 0xca37ee1600000000, 0x5f49252900000000, + 0x1361b38a00000000, 0x388d32e700000000, 0x74a5a44400000000, + 0xe1db6f7b00000000, 0xadf3f9d800000000, 0xcb26f90400000000, + 0x870e6fa700000000, 0x1270a49800000000, 0x5e58323b00000000, + 0x9fdcd4fb00000000, 0xd3f4425800000000, 0x468a896700000000, + 0x0aa21fc400000000, 0x6c771f1800000000, 0x205f89bb00000000, + 0xb521428400000000, 0xf909d42700000000, 0x762efede00000000, + 0x3a06687d00000000, 0xaf78a34200000000, 0xe35035e100000000, + 0x8585353d00000000, 0xc9ada39e00000000, 0x5cd368a100000000, + 0x10fbfe0200000000, 0xd17f18c200000000, 0x9d578e6100000000, + 0x0829455e00000000, 0x4401d3fd00000000, 0x22d4d32100000000, + 0x6efc458200000000, 0xfb828ebd00000000, 0xb7aa181e00000000, + 0xa4cbab9400000000, 0xe8e33d3700000000, 0x7d9df60800000000, + 0x31b560ab00000000, 0x5760607700000000, 0x1b48f6d400000000, + 0x8e363deb00000000, 0xc21eab4800000000, 0x039a4d8800000000, + 0x4fb2db2b00000000, 0xdacc101400000000, 0x96e486b700000000, + 0xf031866b00000000, 0xbc1910c800000000, 0x2967dbf700000000, + 0x654f4d5400000000, 0xea6867ad00000000, 0xa640f10e00000000, + 0x333e3a3100000000, 0x7f16ac9200000000, 0x19c3ac4e00000000, + 0x55eb3aed00000000, 0xc095f1d200000000, 0x8cbd677100000000, + 0x4d3981b100000000, 0x0111171200000000, 0x946fdc2d00000000, + 0xd8474a8e00000000, 0xbe924a5200000000, 0xf2badcf100000000, + 0x67c417ce00000000, 0x2bec816d00000000, 0x311c141500000000, + 0x7d3482b600000000, 0xe84a498900000000, 0xa462df2a00000000, + 0xc2b7dff600000000, 0x8e9f495500000000, 0x1be1826a00000000, + 0x57c914c900000000, 0x964df20900000000, 0xda6564aa00000000, + 0x4f1baf9500000000, 0x0333393600000000, 0x65e639ea00000000, + 0x29ceaf4900000000, 0xbcb0647600000000, 0xf098f2d500000000, + 0x7fbfd82c00000000, 0x33974e8f00000000, 0xa6e985b000000000, + 0xeac1131300000000, 0x8c1413cf00000000, 0xc03c856c00000000, + 0x55424e5300000000, 0x196ad8f000000000, 0xd8ee3e3000000000, + 0x94c6a89300000000, 0x01b863ac00000000, 0x4d90f50f00000000, + 0x2b45f5d300000000, 0x676d637000000000, 0xf213a84f00000000, + 0xbe3b3eec00000000, 0xad5a8d6600000000, 0xe1721bc500000000, + 0x740cd0fa00000000, 0x3824465900000000, 0x5ef1468500000000, + 0x12d9d02600000000, 0x87a71b1900000000, 0xcb8f8dba00000000, + 0x0a0b6b7a00000000, 0x4623fdd900000000, 0xd35d36e600000000, + 0x9f75a04500000000, 0xf9a0a09900000000, 0xb588363a00000000, + 0x20f6fd0500000000, 0x6cde6ba600000000, 0xe3f9415f00000000, + 0xafd1d7fc00000000, 0x3aaf1cc300000000, 0x76878a6000000000, + 0x10528abc00000000, 0x5c7a1c1f00000000, 0xc904d72000000000, + 0x852c418300000000, 0x44a8a74300000000, 0x088031e000000000, + 0x9dfefadf00000000, 0xd1d66c7c00000000, 0xb7036ca000000000, + 0xfb2bfa0300000000, 0x6e55313c00000000, 0x227da79f00000000, + 0x099126f200000000, 0x45b9b05100000000, 0xd0c77b6e00000000, + 0x9cefedcd00000000, 0xfa3aed1100000000, 0xb6127bb200000000, + 0x236cb08d00000000, 0x6f44262e00000000, 0xaec0c0ee00000000, + 0xe2e8564d00000000, 0x77969d7200000000, 0x3bbe0bd100000000, + 0x5d6b0b0d00000000, 0x11439dae00000000, 0x843d569100000000, + 0xc815c03200000000, 0x4732eacb00000000, 0x0b1a7c6800000000, + 0x9e64b75700000000, 0xd24c21f400000000, 0xb499212800000000, + 0xf8b1b78b00000000, 0x6dcf7cb400000000, 0x21e7ea1700000000, + 0xe0630cd700000000, 0xac4b9a7400000000, 0x3935514b00000000, + 0x751dc7e800000000, 0x13c8c73400000000, 0x5fe0519700000000, + 0xca9e9aa800000000, 0x86b60c0b00000000, 0x95d7bf8100000000, + 0xd9ff292200000000, 0x4c81e21d00000000, 0x00a974be00000000, + 0x667c746200000000, 0x2a54e2c100000000, 0xbf2a29fe00000000, + 0xf302bf5d00000000, 0x3286599d00000000, 0x7eaecf3e00000000, + 0xebd0040100000000, 0xa7f892a200000000, 0xc12d927e00000000, + 0x8d0504dd00000000, 0x187bcfe200000000, 0x5453594100000000, + 0xdb7473b800000000, 0x975ce51b00000000, 0x02222e2400000000, + 0x4e0ab88700000000, 0x28dfb85b00000000, 0x64f72ef800000000, + 0xf189e5c700000000, 0xbda1736400000000, 0x7c2595a400000000, + 0x300d030700000000, 0xa573c83800000000, 0xe95b5e9b00000000, + 0x8f8e5e4700000000, 0xc3a6c8e400000000, 0x56d803db00000000, + 0x1af0957800000000}, + {0x0000000000000000, 0x939bc97f00000000, 0x263793ff00000000, + 0xb5ac5a8000000000, 0x0d68572400000000, 0x9ef39e5b00000000, + 0x2b5fc4db00000000, 0xb8c40da400000000, 0x1ad0ae4800000000, + 0x894b673700000000, 0x3ce73db700000000, 0xaf7cf4c800000000, + 0x17b8f96c00000000, 0x8423301300000000, 0x318f6a9300000000, + 0xa214a3ec00000000, 0x34a05d9100000000, 0xa73b94ee00000000, + 0x1297ce6e00000000, 0x810c071100000000, 0x39c80ab500000000, + 0xaa53c3ca00000000, 0x1fff994a00000000, 0x8c64503500000000, + 0x2e70f3d900000000, 0xbdeb3aa600000000, 0x0847602600000000, + 0x9bdca95900000000, 0x2318a4fd00000000, 0xb0836d8200000000, + 0x052f370200000000, 0x96b4fe7d00000000, 0x2946caf900000000, + 0xbadd038600000000, 0x0f71590600000000, 0x9cea907900000000, + 0x242e9ddd00000000, 0xb7b554a200000000, 0x02190e2200000000, + 0x9182c75d00000000, 0x339664b100000000, 0xa00dadce00000000, + 0x15a1f74e00000000, 0x863a3e3100000000, 0x3efe339500000000, + 0xad65faea00000000, 0x18c9a06a00000000, 0x8b52691500000000, + 0x1de6976800000000, 0x8e7d5e1700000000, 0x3bd1049700000000, + 0xa84acde800000000, 0x108ec04c00000000, 0x8315093300000000, + 0x36b953b300000000, 0xa5229acc00000000, 0x0736392000000000, + 0x94adf05f00000000, 0x2101aadf00000000, 0xb29a63a000000000, + 0x0a5e6e0400000000, 0x99c5a77b00000000, 0x2c69fdfb00000000, + 0xbff2348400000000, 0x138ae52800000000, 0x80112c5700000000, + 0x35bd76d700000000, 0xa626bfa800000000, 0x1ee2b20c00000000, + 0x8d797b7300000000, 0x38d521f300000000, 0xab4ee88c00000000, + 0x095a4b6000000000, 0x9ac1821f00000000, 0x2f6dd89f00000000, + 0xbcf611e000000000, 0x04321c4400000000, 0x97a9d53b00000000, + 0x22058fbb00000000, 0xb19e46c400000000, 0x272ab8b900000000, + 0xb4b171c600000000, 0x011d2b4600000000, 0x9286e23900000000, + 0x2a42ef9d00000000, 0xb9d926e200000000, 0x0c757c6200000000, + 0x9feeb51d00000000, 0x3dfa16f100000000, 0xae61df8e00000000, + 0x1bcd850e00000000, 0x88564c7100000000, 0x309241d500000000, + 0xa30988aa00000000, 0x16a5d22a00000000, 0x853e1b5500000000, + 0x3acc2fd100000000, 0xa957e6ae00000000, 0x1cfbbc2e00000000, + 0x8f60755100000000, 0x37a478f500000000, 0xa43fb18a00000000, + 0x1193eb0a00000000, 0x8208227500000000, 0x201c819900000000, + 0xb38748e600000000, 0x062b126600000000, 0x95b0db1900000000, + 0x2d74d6bd00000000, 0xbeef1fc200000000, 0x0b43454200000000, + 0x98d88c3d00000000, 0x0e6c724000000000, 0x9df7bb3f00000000, + 0x285be1bf00000000, 0xbbc028c000000000, 0x0304256400000000, + 0x909fec1b00000000, 0x2533b69b00000000, 0xb6a87fe400000000, + 0x14bcdc0800000000, 0x8727157700000000, 0x328b4ff700000000, + 0xa110868800000000, 0x19d48b2c00000000, 0x8a4f425300000000, + 0x3fe318d300000000, 0xac78d1ac00000000, 0x2614cb5100000000, + 0xb58f022e00000000, 0x002358ae00000000, 0x93b891d100000000, + 0x2b7c9c7500000000, 0xb8e7550a00000000, 0x0d4b0f8a00000000, + 0x9ed0c6f500000000, 0x3cc4651900000000, 0xaf5fac6600000000, + 0x1af3f6e600000000, 0x89683f9900000000, 0x31ac323d00000000, + 0xa237fb4200000000, 0x179ba1c200000000, 0x840068bd00000000, + 0x12b496c000000000, 0x812f5fbf00000000, 0x3483053f00000000, + 0xa718cc4000000000, 0x1fdcc1e400000000, 0x8c47089b00000000, + 0x39eb521b00000000, 0xaa709b6400000000, 0x0864388800000000, + 0x9bfff1f700000000, 0x2e53ab7700000000, 0xbdc8620800000000, + 0x050c6fac00000000, 0x9697a6d300000000, 0x233bfc5300000000, + 0xb0a0352c00000000, 0x0f5201a800000000, 0x9cc9c8d700000000, + 0x2965925700000000, 0xbafe5b2800000000, 0x023a568c00000000, + 0x91a19ff300000000, 0x240dc57300000000, 0xb7960c0c00000000, + 0x1582afe000000000, 0x8619669f00000000, 0x33b53c1f00000000, + 0xa02ef56000000000, 0x18eaf8c400000000, 0x8b7131bb00000000, + 0x3edd6b3b00000000, 0xad46a24400000000, 0x3bf25c3900000000, + 0xa869954600000000, 0x1dc5cfc600000000, 0x8e5e06b900000000, + 0x369a0b1d00000000, 0xa501c26200000000, 0x10ad98e200000000, + 0x8336519d00000000, 0x2122f27100000000, 0xb2b93b0e00000000, + 0x0715618e00000000, 0x948ea8f100000000, 0x2c4aa55500000000, + 0xbfd16c2a00000000, 0x0a7d36aa00000000, 0x99e6ffd500000000, + 0x359e2e7900000000, 0xa605e70600000000, 0x13a9bd8600000000, + 0x803274f900000000, 0x38f6795d00000000, 0xab6db02200000000, + 0x1ec1eaa200000000, 0x8d5a23dd00000000, 0x2f4e803100000000, + 0xbcd5494e00000000, 0x097913ce00000000, 0x9ae2dab100000000, + 0x2226d71500000000, 0xb1bd1e6a00000000, 0x041144ea00000000, + 0x978a8d9500000000, 0x013e73e800000000, 0x92a5ba9700000000, + 0x2709e01700000000, 0xb492296800000000, 0x0c5624cc00000000, + 0x9fcdedb300000000, 0x2a61b73300000000, 0xb9fa7e4c00000000, + 0x1beedda000000000, 0x887514df00000000, 0x3dd94e5f00000000, + 0xae42872000000000, 0x16868a8400000000, 0x851d43fb00000000, + 0x30b1197b00000000, 0xa32ad00400000000, 0x1cd8e48000000000, + 0x8f432dff00000000, 0x3aef777f00000000, 0xa974be0000000000, + 0x11b0b3a400000000, 0x822b7adb00000000, 0x3787205b00000000, + 0xa41ce92400000000, 0x06084ac800000000, 0x959383b700000000, + 0x203fd93700000000, 0xb3a4104800000000, 0x0b601dec00000000, + 0x98fbd49300000000, 0x2d578e1300000000, 0xbecc476c00000000, + 0x2878b91100000000, 0xbbe3706e00000000, 0x0e4f2aee00000000, + 0x9dd4e39100000000, 0x2510ee3500000000, 0xb68b274a00000000, + 0x03277dca00000000, 0x90bcb4b500000000, 0x32a8175900000000, + 0xa133de2600000000, 0x149f84a600000000, 0x87044dd900000000, + 0x3fc0407d00000000, 0xac5b890200000000, 0x19f7d38200000000, + 0x8a6c1afd00000000}, + {0x0000000000000000, 0x650b796900000000, 0xca16f2d200000000, + 0xaf1d8bbb00000000, 0xd52b957e00000000, 0xb020ec1700000000, + 0x1f3d67ac00000000, 0x7a361ec500000000, 0xaa572afd00000000, + 0xcf5c539400000000, 0x6041d82f00000000, 0x054aa14600000000, + 0x7f7cbf8300000000, 0x1a77c6ea00000000, 0xb56a4d5100000000, + 0xd061343800000000, 0x15a9252100000000, 0x70a25c4800000000, + 0xdfbfd7f300000000, 0xbab4ae9a00000000, 0xc082b05f00000000, + 0xa589c93600000000, 0x0a94428d00000000, 0x6f9f3be400000000, + 0xbffe0fdc00000000, 0xdaf576b500000000, 0x75e8fd0e00000000, + 0x10e3846700000000, 0x6ad59aa200000000, 0x0fdee3cb00000000, + 0xa0c3687000000000, 0xc5c8111900000000, 0x2a524b4200000000, + 0x4f59322b00000000, 0xe044b99000000000, 0x854fc0f900000000, + 0xff79de3c00000000, 0x9a72a75500000000, 0x356f2cee00000000, + 0x5064558700000000, 0x800561bf00000000, 0xe50e18d600000000, + 0x4a13936d00000000, 0x2f18ea0400000000, 0x552ef4c100000000, + 0x30258da800000000, 0x9f38061300000000, 0xfa337f7a00000000, + 0x3ffb6e6300000000, 0x5af0170a00000000, 0xf5ed9cb100000000, + 0x90e6e5d800000000, 0xead0fb1d00000000, 0x8fdb827400000000, + 0x20c609cf00000000, 0x45cd70a600000000, 0x95ac449e00000000, + 0xf0a73df700000000, 0x5fbab64c00000000, 0x3ab1cf2500000000, + 0x4087d1e000000000, 0x258ca88900000000, 0x8a91233200000000, + 0xef9a5a5b00000000, 0x54a4968400000000, 0x31afefed00000000, + 0x9eb2645600000000, 0xfbb91d3f00000000, 0x818f03fa00000000, + 0xe4847a9300000000, 0x4b99f12800000000, 0x2e92884100000000, + 0xfef3bc7900000000, 0x9bf8c51000000000, 0x34e54eab00000000, + 0x51ee37c200000000, 0x2bd8290700000000, 0x4ed3506e00000000, + 0xe1cedbd500000000, 0x84c5a2bc00000000, 0x410db3a500000000, + 0x2406cacc00000000, 0x8b1b417700000000, 0xee10381e00000000, + 0x942626db00000000, 0xf12d5fb200000000, 0x5e30d40900000000, + 0x3b3bad6000000000, 0xeb5a995800000000, 0x8e51e03100000000, + 0x214c6b8a00000000, 0x444712e300000000, 0x3e710c2600000000, + 0x5b7a754f00000000, 0xf467fef400000000, 0x916c879d00000000, + 0x7ef6ddc600000000, 0x1bfda4af00000000, 0xb4e02f1400000000, + 0xd1eb567d00000000, 0xabdd48b800000000, 0xced631d100000000, + 0x61cbba6a00000000, 0x04c0c30300000000, 0xd4a1f73b00000000, + 0xb1aa8e5200000000, 0x1eb705e900000000, 0x7bbc7c8000000000, + 0x018a624500000000, 0x64811b2c00000000, 0xcb9c909700000000, + 0xae97e9fe00000000, 0x6b5ff8e700000000, 0x0e54818e00000000, + 0xa1490a3500000000, 0xc442735c00000000, 0xbe746d9900000000, + 0xdb7f14f000000000, 0x74629f4b00000000, 0x1169e62200000000, + 0xc108d21a00000000, 0xa403ab7300000000, 0x0b1e20c800000000, + 0x6e1559a100000000, 0x1423476400000000, 0x71283e0d00000000, + 0xde35b5b600000000, 0xbb3eccdf00000000, 0xe94e5cd200000000, + 0x8c4525bb00000000, 0x2358ae0000000000, 0x4653d76900000000, + 0x3c65c9ac00000000, 0x596eb0c500000000, 0xf6733b7e00000000, + 0x9378421700000000, 0x4319762f00000000, 0x26120f4600000000, + 0x890f84fd00000000, 0xec04fd9400000000, 0x9632e35100000000, + 0xf3399a3800000000, 0x5c24118300000000, 0x392f68ea00000000, + 0xfce779f300000000, 0x99ec009a00000000, 0x36f18b2100000000, + 0x53faf24800000000, 0x29ccec8d00000000, 0x4cc795e400000000, + 0xe3da1e5f00000000, 0x86d1673600000000, 0x56b0530e00000000, + 0x33bb2a6700000000, 0x9ca6a1dc00000000, 0xf9add8b500000000, + 0x839bc67000000000, 0xe690bf1900000000, 0x498d34a200000000, + 0x2c864dcb00000000, 0xc31c179000000000, 0xa6176ef900000000, + 0x090ae54200000000, 0x6c019c2b00000000, 0x163782ee00000000, + 0x733cfb8700000000, 0xdc21703c00000000, 0xb92a095500000000, + 0x694b3d6d00000000, 0x0c40440400000000, 0xa35dcfbf00000000, + 0xc656b6d600000000, 0xbc60a81300000000, 0xd96bd17a00000000, + 0x76765ac100000000, 0x137d23a800000000, 0xd6b532b100000000, + 0xb3be4bd800000000, 0x1ca3c06300000000, 0x79a8b90a00000000, + 0x039ea7cf00000000, 0x6695dea600000000, 0xc988551d00000000, + 0xac832c7400000000, 0x7ce2184c00000000, 0x19e9612500000000, + 0xb6f4ea9e00000000, 0xd3ff93f700000000, 0xa9c98d3200000000, + 0xccc2f45b00000000, 0x63df7fe000000000, 0x06d4068900000000, + 0xbdeaca5600000000, 0xd8e1b33f00000000, 0x77fc388400000000, + 0x12f741ed00000000, 0x68c15f2800000000, 0x0dca264100000000, + 0xa2d7adfa00000000, 0xc7dcd49300000000, 0x17bde0ab00000000, + 0x72b699c200000000, 0xddab127900000000, 0xb8a06b1000000000, + 0xc29675d500000000, 0xa79d0cbc00000000, 0x0880870700000000, + 0x6d8bfe6e00000000, 0xa843ef7700000000, 0xcd48961e00000000, + 0x62551da500000000, 0x075e64cc00000000, 0x7d687a0900000000, + 0x1863036000000000, 0xb77e88db00000000, 0xd275f1b200000000, + 0x0214c58a00000000, 0x671fbce300000000, 0xc802375800000000, + 0xad094e3100000000, 0xd73f50f400000000, 0xb234299d00000000, + 0x1d29a22600000000, 0x7822db4f00000000, 0x97b8811400000000, + 0xf2b3f87d00000000, 0x5dae73c600000000, 0x38a50aaf00000000, + 0x4293146a00000000, 0x27986d0300000000, 0x8885e6b800000000, + 0xed8e9fd100000000, 0x3defabe900000000, 0x58e4d28000000000, + 0xf7f9593b00000000, 0x92f2205200000000, 0xe8c43e9700000000, + 0x8dcf47fe00000000, 0x22d2cc4500000000, 0x47d9b52c00000000, + 0x8211a43500000000, 0xe71add5c00000000, 0x480756e700000000, + 0x2d0c2f8e00000000, 0x573a314b00000000, 0x3231482200000000, + 0x9d2cc39900000000, 0xf827baf000000000, 0x28468ec800000000, + 0x4d4df7a100000000, 0xe2507c1a00000000, 0x875b057300000000, + 0xfd6d1bb600000000, 0x986662df00000000, 0x377be96400000000, + 0x5270900d00000000}, + {0x0000000000000000, 0xdcecb13d00000000, 0xb8d9637b00000000, + 0x6435d24600000000, 0x70b3c7f600000000, 0xac5f76cb00000000, + 0xc86aa48d00000000, 0x148615b000000000, 0xa160fe3600000000, + 0x7d8c4f0b00000000, 0x19b99d4d00000000, 0xc5552c7000000000, + 0xd1d339c000000000, 0x0d3f88fd00000000, 0x690a5abb00000000, + 0xb5e6eb8600000000, 0x42c1fc6d00000000, 0x9e2d4d5000000000, + 0xfa189f1600000000, 0x26f42e2b00000000, 0x32723b9b00000000, + 0xee9e8aa600000000, 0x8aab58e000000000, 0x5647e9dd00000000, + 0xe3a1025b00000000, 0x3f4db36600000000, 0x5b78612000000000, + 0x8794d01d00000000, 0x9312c5ad00000000, 0x4ffe749000000000, + 0x2bcba6d600000000, 0xf72717eb00000000, 0x8482f9db00000000, + 0x586e48e600000000, 0x3c5b9aa000000000, 0xe0b72b9d00000000, + 0xf4313e2d00000000, 0x28dd8f1000000000, 0x4ce85d5600000000, + 0x9004ec6b00000000, 0x25e207ed00000000, 0xf90eb6d000000000, + 0x9d3b649600000000, 0x41d7d5ab00000000, 0x5551c01b00000000, + 0x89bd712600000000, 0xed88a36000000000, 0x3164125d00000000, + 0xc64305b600000000, 0x1aafb48b00000000, 0x7e9a66cd00000000, + 0xa276d7f000000000, 0xb6f0c24000000000, 0x6a1c737d00000000, + 0x0e29a13b00000000, 0xd2c5100600000000, 0x6723fb8000000000, + 0xbbcf4abd00000000, 0xdffa98fb00000000, 0x031629c600000000, + 0x17903c7600000000, 0xcb7c8d4b00000000, 0xaf495f0d00000000, + 0x73a5ee3000000000, 0x4903826c00000000, 0x95ef335100000000, + 0xf1dae11700000000, 0x2d36502a00000000, 0x39b0459a00000000, + 0xe55cf4a700000000, 0x816926e100000000, 0x5d8597dc00000000, + 0xe8637c5a00000000, 0x348fcd6700000000, 0x50ba1f2100000000, + 0x8c56ae1c00000000, 0x98d0bbac00000000, 0x443c0a9100000000, + 0x2009d8d700000000, 0xfce569ea00000000, 0x0bc27e0100000000, + 0xd72ecf3c00000000, 0xb31b1d7a00000000, 0x6ff7ac4700000000, + 0x7b71b9f700000000, 0xa79d08ca00000000, 0xc3a8da8c00000000, + 0x1f446bb100000000, 0xaaa2803700000000, 0x764e310a00000000, + 0x127be34c00000000, 0xce97527100000000, 0xda1147c100000000, + 0x06fdf6fc00000000, 0x62c824ba00000000, 0xbe24958700000000, + 0xcd817bb700000000, 0x116dca8a00000000, 0x755818cc00000000, + 0xa9b4a9f100000000, 0xbd32bc4100000000, 0x61de0d7c00000000, + 0x05ebdf3a00000000, 0xd9076e0700000000, 0x6ce1858100000000, + 0xb00d34bc00000000, 0xd438e6fa00000000, 0x08d457c700000000, + 0x1c52427700000000, 0xc0bef34a00000000, 0xa48b210c00000000, + 0x7867903100000000, 0x8f4087da00000000, 0x53ac36e700000000, + 0x3799e4a100000000, 0xeb75559c00000000, 0xfff3402c00000000, + 0x231ff11100000000, 0x472a235700000000, 0x9bc6926a00000000, + 0x2e2079ec00000000, 0xf2ccc8d100000000, 0x96f91a9700000000, + 0x4a15abaa00000000, 0x5e93be1a00000000, 0x827f0f2700000000, + 0xe64add6100000000, 0x3aa66c5c00000000, 0x920604d900000000, + 0x4eeab5e400000000, 0x2adf67a200000000, 0xf633d69f00000000, + 0xe2b5c32f00000000, 0x3e59721200000000, 0x5a6ca05400000000, + 0x8680116900000000, 0x3366faef00000000, 0xef8a4bd200000000, + 0x8bbf999400000000, 0x575328a900000000, 0x43d53d1900000000, + 0x9f398c2400000000, 0xfb0c5e6200000000, 0x27e0ef5f00000000, + 0xd0c7f8b400000000, 0x0c2b498900000000, 0x681e9bcf00000000, + 0xb4f22af200000000, 0xa0743f4200000000, 0x7c988e7f00000000, + 0x18ad5c3900000000, 0xc441ed0400000000, 0x71a7068200000000, + 0xad4bb7bf00000000, 0xc97e65f900000000, 0x1592d4c400000000, + 0x0114c17400000000, 0xddf8704900000000, 0xb9cda20f00000000, + 0x6521133200000000, 0x1684fd0200000000, 0xca684c3f00000000, + 0xae5d9e7900000000, 0x72b12f4400000000, 0x66373af400000000, + 0xbadb8bc900000000, 0xdeee598f00000000, 0x0202e8b200000000, + 0xb7e4033400000000, 0x6b08b20900000000, 0x0f3d604f00000000, + 0xd3d1d17200000000, 0xc757c4c200000000, 0x1bbb75ff00000000, + 0x7f8ea7b900000000, 0xa362168400000000, 0x5445016f00000000, + 0x88a9b05200000000, 0xec9c621400000000, 0x3070d32900000000, + 0x24f6c69900000000, 0xf81a77a400000000, 0x9c2fa5e200000000, + 0x40c314df00000000, 0xf525ff5900000000, 0x29c94e6400000000, + 0x4dfc9c2200000000, 0x91102d1f00000000, 0x859638af00000000, + 0x597a899200000000, 0x3d4f5bd400000000, 0xe1a3eae900000000, + 0xdb0586b500000000, 0x07e9378800000000, 0x63dce5ce00000000, + 0xbf3054f300000000, 0xabb6414300000000, 0x775af07e00000000, + 0x136f223800000000, 0xcf83930500000000, 0x7a65788300000000, + 0xa689c9be00000000, 0xc2bc1bf800000000, 0x1e50aac500000000, + 0x0ad6bf7500000000, 0xd63a0e4800000000, 0xb20fdc0e00000000, + 0x6ee36d3300000000, 0x99c47ad800000000, 0x4528cbe500000000, + 0x211d19a300000000, 0xfdf1a89e00000000, 0xe977bd2e00000000, + 0x359b0c1300000000, 0x51aede5500000000, 0x8d426f6800000000, + 0x38a484ee00000000, 0xe44835d300000000, 0x807de79500000000, + 0x5c9156a800000000, 0x4817431800000000, 0x94fbf22500000000, + 0xf0ce206300000000, 0x2c22915e00000000, 0x5f877f6e00000000, + 0x836bce5300000000, 0xe75e1c1500000000, 0x3bb2ad2800000000, + 0x2f34b89800000000, 0xf3d809a500000000, 0x97eddbe300000000, + 0x4b016ade00000000, 0xfee7815800000000, 0x220b306500000000, + 0x463ee22300000000, 0x9ad2531e00000000, 0x8e5446ae00000000, + 0x52b8f79300000000, 0x368d25d500000000, 0xea6194e800000000, + 0x1d46830300000000, 0xc1aa323e00000000, 0xa59fe07800000000, + 0x7973514500000000, 0x6df544f500000000, 0xb119f5c800000000, + 0xd52c278e00000000, 0x09c096b300000000, 0xbc267d3500000000, + 0x60cacc0800000000, 0x04ff1e4e00000000, 0xd813af7300000000, + 0xcc95bac300000000, 0x10790bfe00000000, 0x744cd9b800000000, + 0xa8a0688500000000}}; + +#else /* W == 4 */ + +local const z_crc_t FAR crc_braid_table[][256] = { + {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, + 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, + 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, + 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, + 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, + 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, + 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, + 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, + 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, + 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, + 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, + 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, + 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, + 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, + 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, + 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, + 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, + 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, + 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, + 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, + 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, + 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, + 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, + 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, + 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, + 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, + 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, + 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, + 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, + 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, + 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, + 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, + 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, + 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, + 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, + 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, + 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, + 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, + 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, + 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, + 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, + 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, + 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, + 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, + 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, + 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, + 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, + 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, + 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, + 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, + 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, + 0x09cd8551}, + {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, + 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, + 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, + 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, + 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, + 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, + 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, + 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, + 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, + 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, + 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, + 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, + 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, + 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, + 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, + 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, + 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, + 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, + 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, + 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, + 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, + 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, + 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, + 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, + 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, + 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, + 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, + 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, + 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, + 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, + 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, + 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, + 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, + 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, + 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, + 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, + 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, + 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, + 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, + 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, + 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, + 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, + 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, + 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, + 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, + 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, + 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, + 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, + 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, + 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, + 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, + 0x7bc97a0c}, + {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, + 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, + 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, + 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, + 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, + 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, + 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, + 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, + 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, + 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, + 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, + 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, + 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, + 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, + 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, + 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, + 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, + 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, + 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, + 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, + 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, + 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, + 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, + 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, + 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, + 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, + 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, + 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, + 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, + 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, + 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, + 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, + 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, + 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, + 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, + 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, + 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, + 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, + 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, + 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, + 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, + 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, + 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, + 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, + 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, + 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, + 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, + 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, + 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, + 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, + 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, + 0x7851a2ca}, + {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, + 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, + 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, + 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, + 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, + 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, + 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, + 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, + 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, + 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, + 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, + 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, + 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, + 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, + 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, + 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, + 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, + 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, + 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, + 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, + 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, + 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, + 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, + 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, + 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, + 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, + 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, + 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, + 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, + 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, + 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, + 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, + 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, + 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, + 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, + 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, + 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, + 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, + 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, + 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, + 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, + 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, + 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, + 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, + 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, + 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, + 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, + 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, + 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, + 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, + 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, + 0x566b6848}}; + +local const z_word_t FAR crc_braid_big_table[][256] = { + {0x00000000, 0x9e83da9f, 0x7d01c4e4, 0xe3821e7b, 0xbb04f912, + 0x2587238d, 0xc6053df6, 0x5886e769, 0x7609f225, 0xe88a28ba, + 0x0b0836c1, 0x958bec5e, 0xcd0d0b37, 0x538ed1a8, 0xb00ccfd3, + 0x2e8f154c, 0xec12e44b, 0x72913ed4, 0x911320af, 0x0f90fa30, + 0x57161d59, 0xc995c7c6, 0x2a17d9bd, 0xb4940322, 0x9a1b166e, + 0x0498ccf1, 0xe71ad28a, 0x79990815, 0x211fef7c, 0xbf9c35e3, + 0x5c1e2b98, 0xc29df107, 0xd825c897, 0x46a61208, 0xa5240c73, + 0x3ba7d6ec, 0x63213185, 0xfda2eb1a, 0x1e20f561, 0x80a32ffe, + 0xae2c3ab2, 0x30afe02d, 0xd32dfe56, 0x4dae24c9, 0x1528c3a0, + 0x8bab193f, 0x68290744, 0xf6aadddb, 0x34372cdc, 0xaab4f643, + 0x4936e838, 0xd7b532a7, 0x8f33d5ce, 0x11b00f51, 0xf232112a, + 0x6cb1cbb5, 0x423edef9, 0xdcbd0466, 0x3f3f1a1d, 0xa1bcc082, + 0xf93a27eb, 0x67b9fd74, 0x843be30f, 0x1ab83990, 0xf14de1f4, + 0x6fce3b6b, 0x8c4c2510, 0x12cfff8f, 0x4a4918e6, 0xd4cac279, + 0x3748dc02, 0xa9cb069d, 0x874413d1, 0x19c7c94e, 0xfa45d735, + 0x64c60daa, 0x3c40eac3, 0xa2c3305c, 0x41412e27, 0xdfc2f4b8, + 0x1d5f05bf, 0x83dcdf20, 0x605ec15b, 0xfedd1bc4, 0xa65bfcad, + 0x38d82632, 0xdb5a3849, 0x45d9e2d6, 0x6b56f79a, 0xf5d52d05, + 0x1657337e, 0x88d4e9e1, 0xd0520e88, 0x4ed1d417, 0xad53ca6c, + 0x33d010f3, 0x29682963, 0xb7ebf3fc, 0x5469ed87, 0xcaea3718, + 0x926cd071, 0x0cef0aee, 0xef6d1495, 0x71eece0a, 0x5f61db46, + 0xc1e201d9, 0x22601fa2, 0xbce3c53d, 0xe4652254, 0x7ae6f8cb, + 0x9964e6b0, 0x07e73c2f, 0xc57acd28, 0x5bf917b7, 0xb87b09cc, + 0x26f8d353, 0x7e7e343a, 0xe0fdeea5, 0x037ff0de, 0x9dfc2a41, + 0xb3733f0d, 0x2df0e592, 0xce72fbe9, 0x50f12176, 0x0877c61f, + 0x96f41c80, 0x757602fb, 0xebf5d864, 0xa39db332, 0x3d1e69ad, + 0xde9c77d6, 0x401fad49, 0x18994a20, 0x861a90bf, 0x65988ec4, + 0xfb1b545b, 0xd5944117, 0x4b179b88, 0xa89585f3, 0x36165f6c, + 0x6e90b805, 0xf013629a, 0x13917ce1, 0x8d12a67e, 0x4f8f5779, + 0xd10c8de6, 0x328e939d, 0xac0d4902, 0xf48bae6b, 0x6a0874f4, + 0x898a6a8f, 0x1709b010, 0x3986a55c, 0xa7057fc3, 0x448761b8, + 0xda04bb27, 0x82825c4e, 0x1c0186d1, 0xff8398aa, 0x61004235, + 0x7bb87ba5, 0xe53ba13a, 0x06b9bf41, 0x983a65de, 0xc0bc82b7, + 0x5e3f5828, 0xbdbd4653, 0x233e9ccc, 0x0db18980, 0x9332531f, + 0x70b04d64, 0xee3397fb, 0xb6b57092, 0x2836aa0d, 0xcbb4b476, + 0x55376ee9, 0x97aa9fee, 0x09294571, 0xeaab5b0a, 0x74288195, + 0x2cae66fc, 0xb22dbc63, 0x51afa218, 0xcf2c7887, 0xe1a36dcb, + 0x7f20b754, 0x9ca2a92f, 0x022173b0, 0x5aa794d9, 0xc4244e46, + 0x27a6503d, 0xb9258aa2, 0x52d052c6, 0xcc538859, 0x2fd19622, + 0xb1524cbd, 0xe9d4abd4, 0x7757714b, 0x94d56f30, 0x0a56b5af, + 0x24d9a0e3, 0xba5a7a7c, 0x59d86407, 0xc75bbe98, 0x9fdd59f1, + 0x015e836e, 0xe2dc9d15, 0x7c5f478a, 0xbec2b68d, 0x20416c12, + 0xc3c37269, 0x5d40a8f6, 0x05c64f9f, 0x9b459500, 0x78c78b7b, + 0xe64451e4, 0xc8cb44a8, 0x56489e37, 0xb5ca804c, 0x2b495ad3, + 0x73cfbdba, 0xed4c6725, 0x0ece795e, 0x904da3c1, 0x8af59a51, + 0x147640ce, 0xf7f45eb5, 0x6977842a, 0x31f16343, 0xaf72b9dc, + 0x4cf0a7a7, 0xd2737d38, 0xfcfc6874, 0x627fb2eb, 0x81fdac90, + 0x1f7e760f, 0x47f89166, 0xd97b4bf9, 0x3af95582, 0xa47a8f1d, + 0x66e77e1a, 0xf864a485, 0x1be6bafe, 0x85656061, 0xdde38708, + 0x43605d97, 0xa0e243ec, 0x3e619973, 0x10ee8c3f, 0x8e6d56a0, + 0x6def48db, 0xf36c9244, 0xabea752d, 0x3569afb2, 0xd6ebb1c9, + 0x48686b56}, + {0x00000000, 0xc0642817, 0x80c9502e, 0x40ad7839, 0x0093a15c, + 0xc0f7894b, 0x805af172, 0x403ed965, 0x002643b9, 0xc0426bae, + 0x80ef1397, 0x408b3b80, 0x00b5e2e5, 0xc0d1caf2, 0x807cb2cb, + 0x40189adc, 0x414af7a9, 0x812edfbe, 0xc183a787, 0x01e78f90, + 0x41d956f5, 0x81bd7ee2, 0xc11006db, 0x01742ecc, 0x416cb410, + 0x81089c07, 0xc1a5e43e, 0x01c1cc29, 0x41ff154c, 0x819b3d5b, + 0xc1364562, 0x01526d75, 0xc3929f88, 0x03f6b79f, 0x435bcfa6, + 0x833fe7b1, 0xc3013ed4, 0x036516c3, 0x43c86efa, 0x83ac46ed, + 0xc3b4dc31, 0x03d0f426, 0x437d8c1f, 0x8319a408, 0xc3277d6d, + 0x0343557a, 0x43ee2d43, 0x838a0554, 0x82d86821, 0x42bc4036, + 0x0211380f, 0xc2751018, 0x824bc97d, 0x422fe16a, 0x02829953, + 0xc2e6b144, 0x82fe2b98, 0x429a038f, 0x02377bb6, 0xc25353a1, + 0x826d8ac4, 0x4209a2d3, 0x02a4daea, 0xc2c0f2fd, 0xc7234eca, + 0x074766dd, 0x47ea1ee4, 0x878e36f3, 0xc7b0ef96, 0x07d4c781, + 0x4779bfb8, 0x871d97af, 0xc7050d73, 0x07612564, 0x47cc5d5d, + 0x87a8754a, 0xc796ac2f, 0x07f28438, 0x475ffc01, 0x873bd416, + 0x8669b963, 0x460d9174, 0x06a0e94d, 0xc6c4c15a, 0x86fa183f, + 0x469e3028, 0x06334811, 0xc6576006, 0x864ffada, 0x462bd2cd, + 0x0686aaf4, 0xc6e282e3, 0x86dc5b86, 0x46b87391, 0x06150ba8, + 0xc67123bf, 0x04b1d142, 0xc4d5f955, 0x8478816c, 0x441ca97b, + 0x0422701e, 0xc4465809, 0x84eb2030, 0x448f0827, 0x049792fb, + 0xc4f3baec, 0x845ec2d5, 0x443aeac2, 0x040433a7, 0xc4601bb0, + 0x84cd6389, 0x44a94b9e, 0x45fb26eb, 0x859f0efc, 0xc53276c5, + 0x05565ed2, 0x456887b7, 0x850cafa0, 0xc5a1d799, 0x05c5ff8e, + 0x45dd6552, 0x85b94d45, 0xc514357c, 0x05701d6b, 0x454ec40e, + 0x852aec19, 0xc5879420, 0x05e3bc37, 0xcf41ed4f, 0x0f25c558, + 0x4f88bd61, 0x8fec9576, 0xcfd24c13, 0x0fb66404, 0x4f1b1c3d, + 0x8f7f342a, 0xcf67aef6, 0x0f0386e1, 0x4faefed8, 0x8fcad6cf, + 0xcff40faa, 0x0f9027bd, 0x4f3d5f84, 0x8f597793, 0x8e0b1ae6, + 0x4e6f32f1, 0x0ec24ac8, 0xcea662df, 0x8e98bbba, 0x4efc93ad, + 0x0e51eb94, 0xce35c383, 0x8e2d595f, 0x4e497148, 0x0ee40971, + 0xce802166, 0x8ebef803, 0x4edad014, 0x0e77a82d, 0xce13803a, + 0x0cd372c7, 0xccb75ad0, 0x8c1a22e9, 0x4c7e0afe, 0x0c40d39b, + 0xcc24fb8c, 0x8c8983b5, 0x4cedaba2, 0x0cf5317e, 0xcc911969, + 0x8c3c6150, 0x4c584947, 0x0c669022, 0xcc02b835, 0x8cafc00c, + 0x4ccbe81b, 0x4d99856e, 0x8dfdad79, 0xcd50d540, 0x0d34fd57, + 0x4d0a2432, 0x8d6e0c25, 0xcdc3741c, 0x0da75c0b, 0x4dbfc6d7, + 0x8ddbeec0, 0xcd7696f9, 0x0d12beee, 0x4d2c678b, 0x8d484f9c, + 0xcde537a5, 0x0d811fb2, 0x0862a385, 0xc8068b92, 0x88abf3ab, + 0x48cfdbbc, 0x08f102d9, 0xc8952ace, 0x883852f7, 0x485c7ae0, + 0x0844e03c, 0xc820c82b, 0x888db012, 0x48e99805, 0x08d74160, + 0xc8b36977, 0x881e114e, 0x487a3959, 0x4928542c, 0x894c7c3b, + 0xc9e10402, 0x09852c15, 0x49bbf570, 0x89dfdd67, 0xc972a55e, + 0x09168d49, 0x490e1795, 0x896a3f82, 0xc9c747bb, 0x09a36fac, + 0x499db6c9, 0x89f99ede, 0xc954e6e7, 0x0930cef0, 0xcbf03c0d, + 0x0b94141a, 0x4b396c23, 0x8b5d4434, 0xcb639d51, 0x0b07b546, + 0x4baacd7f, 0x8bcee568, 0xcbd67fb4, 0x0bb257a3, 0x4b1f2f9a, + 0x8b7b078d, 0xcb45dee8, 0x0b21f6ff, 0x4b8c8ec6, 0x8be8a6d1, + 0x8abacba4, 0x4adee3b3, 0x0a739b8a, 0xca17b39d, 0x8a296af8, + 0x4a4d42ef, 0x0ae03ad6, 0xca8412c1, 0x8a9c881d, 0x4af8a00a, + 0x0a55d833, 0xca31f024, 0x8a0f2941, 0x4a6b0156, 0x0ac6796f, + 0xcaa25178}, + {0x00000000, 0xd4ea739b, 0xe9d396ed, 0x3d39e576, 0x93a15c00, + 0x474b2f9b, 0x7a72caed, 0xae98b976, 0x2643b900, 0xf2a9ca9b, + 0xcf902fed, 0x1b7a5c76, 0xb5e2e500, 0x6108969b, 0x5c3173ed, + 0x88db0076, 0x4c867201, 0x986c019a, 0xa555e4ec, 0x71bf9777, + 0xdf272e01, 0x0bcd5d9a, 0x36f4b8ec, 0xe21ecb77, 0x6ac5cb01, + 0xbe2fb89a, 0x83165dec, 0x57fc2e77, 0xf9649701, 0x2d8ee49a, + 0x10b701ec, 0xc45d7277, 0x980ce502, 0x4ce69699, 0x71df73ef, + 0xa5350074, 0x0badb902, 0xdf47ca99, 0xe27e2fef, 0x36945c74, + 0xbe4f5c02, 0x6aa52f99, 0x579ccaef, 0x8376b974, 0x2dee0002, + 0xf9047399, 0xc43d96ef, 0x10d7e574, 0xd48a9703, 0x0060e498, + 0x3d5901ee, 0xe9b37275, 0x472bcb03, 0x93c1b898, 0xaef85dee, + 0x7a122e75, 0xf2c92e03, 0x26235d98, 0x1b1ab8ee, 0xcff0cb75, + 0x61687203, 0xb5820198, 0x88bbe4ee, 0x5c519775, 0x3019ca05, + 0xe4f3b99e, 0xd9ca5ce8, 0x0d202f73, 0xa3b89605, 0x7752e59e, + 0x4a6b00e8, 0x9e817373, 0x165a7305, 0xc2b0009e, 0xff89e5e8, + 0x2b639673, 0x85fb2f05, 0x51115c9e, 0x6c28b9e8, 0xb8c2ca73, + 0x7c9fb804, 0xa875cb9f, 0x954c2ee9, 0x41a65d72, 0xef3ee404, + 0x3bd4979f, 0x06ed72e9, 0xd2070172, 0x5adc0104, 0x8e36729f, + 0xb30f97e9, 0x67e5e472, 0xc97d5d04, 0x1d972e9f, 0x20aecbe9, + 0xf444b872, 0xa8152f07, 0x7cff5c9c, 0x41c6b9ea, 0x952cca71, + 0x3bb47307, 0xef5e009c, 0xd267e5ea, 0x068d9671, 0x8e569607, + 0x5abce59c, 0x678500ea, 0xb36f7371, 0x1df7ca07, 0xc91db99c, + 0xf4245cea, 0x20ce2f71, 0xe4935d06, 0x30792e9d, 0x0d40cbeb, + 0xd9aab870, 0x77320106, 0xa3d8729d, 0x9ee197eb, 0x4a0be470, + 0xc2d0e406, 0x163a979d, 0x2b0372eb, 0xffe90170, 0x5171b806, + 0x859bcb9d, 0xb8a22eeb, 0x6c485d70, 0x6032940b, 0xb4d8e790, + 0x89e102e6, 0x5d0b717d, 0xf393c80b, 0x2779bb90, 0x1a405ee6, + 0xceaa2d7d, 0x46712d0b, 0x929b5e90, 0xafa2bbe6, 0x7b48c87d, + 0xd5d0710b, 0x013a0290, 0x3c03e7e6, 0xe8e9947d, 0x2cb4e60a, + 0xf85e9591, 0xc56770e7, 0x118d037c, 0xbf15ba0a, 0x6bffc991, + 0x56c62ce7, 0x822c5f7c, 0x0af75f0a, 0xde1d2c91, 0xe324c9e7, + 0x37ceba7c, 0x9956030a, 0x4dbc7091, 0x708595e7, 0xa46fe67c, + 0xf83e7109, 0x2cd40292, 0x11ede7e4, 0xc507947f, 0x6b9f2d09, + 0xbf755e92, 0x824cbbe4, 0x56a6c87f, 0xde7dc809, 0x0a97bb92, + 0x37ae5ee4, 0xe3442d7f, 0x4ddc9409, 0x9936e792, 0xa40f02e4, + 0x70e5717f, 0xb4b80308, 0x60527093, 0x5d6b95e5, 0x8981e67e, + 0x27195f08, 0xf3f32c93, 0xcecac9e5, 0x1a20ba7e, 0x92fbba08, + 0x4611c993, 0x7b282ce5, 0xafc25f7e, 0x015ae608, 0xd5b09593, + 0xe88970e5, 0x3c63037e, 0x502b5e0e, 0x84c12d95, 0xb9f8c8e3, + 0x6d12bb78, 0xc38a020e, 0x17607195, 0x2a5994e3, 0xfeb3e778, + 0x7668e70e, 0xa2829495, 0x9fbb71e3, 0x4b510278, 0xe5c9bb0e, + 0x3123c895, 0x0c1a2de3, 0xd8f05e78, 0x1cad2c0f, 0xc8475f94, + 0xf57ebae2, 0x2194c979, 0x8f0c700f, 0x5be60394, 0x66dfe6e2, + 0xb2359579, 0x3aee950f, 0xee04e694, 0xd33d03e2, 0x07d77079, + 0xa94fc90f, 0x7da5ba94, 0x409c5fe2, 0x94762c79, 0xc827bb0c, + 0x1ccdc897, 0x21f42de1, 0xf51e5e7a, 0x5b86e70c, 0x8f6c9497, + 0xb25571e1, 0x66bf027a, 0xee64020c, 0x3a8e7197, 0x07b794e1, + 0xd35de77a, 0x7dc55e0c, 0xa92f2d97, 0x9416c8e1, 0x40fcbb7a, + 0x84a1c90d, 0x504bba96, 0x6d725fe0, 0xb9982c7b, 0x1700950d, + 0xc3eae696, 0xfed303e0, 0x2a39707b, 0xa2e2700d, 0x76080396, + 0x4b31e6e0, 0x9fdb957b, 0x31432c0d, 0xe5a95f96, 0xd890bae0, + 0x0c7ac97b}, + {0x00000000, 0x27652581, 0x0fcc3bd9, 0x28a91e58, 0x5f9e0669, + 0x78fb23e8, 0x50523db0, 0x77371831, 0xbe3c0dd2, 0x99592853, + 0xb1f0360b, 0x9695138a, 0xe1a20bbb, 0xc6c72e3a, 0xee6e3062, + 0xc90b15e3, 0x3d7f6b7f, 0x1a1a4efe, 0x32b350a6, 0x15d67527, + 0x62e16d16, 0x45844897, 0x6d2d56cf, 0x4a48734e, 0x834366ad, + 0xa426432c, 0x8c8f5d74, 0xabea78f5, 0xdcdd60c4, 0xfbb84545, + 0xd3115b1d, 0xf4747e9c, 0x7afed6fe, 0x5d9bf37f, 0x7532ed27, + 0x5257c8a6, 0x2560d097, 0x0205f516, 0x2aaceb4e, 0x0dc9cecf, + 0xc4c2db2c, 0xe3a7fead, 0xcb0ee0f5, 0xec6bc574, 0x9b5cdd45, + 0xbc39f8c4, 0x9490e69c, 0xb3f5c31d, 0x4781bd81, 0x60e49800, + 0x484d8658, 0x6f28a3d9, 0x181fbbe8, 0x3f7a9e69, 0x17d38031, + 0x30b6a5b0, 0xf9bdb053, 0xded895d2, 0xf6718b8a, 0xd114ae0b, + 0xa623b63a, 0x814693bb, 0xa9ef8de3, 0x8e8aa862, 0xb5fadc26, + 0x929ff9a7, 0xba36e7ff, 0x9d53c27e, 0xea64da4f, 0xcd01ffce, + 0xe5a8e196, 0xc2cdc417, 0x0bc6d1f4, 0x2ca3f475, 0x040aea2d, + 0x236fcfac, 0x5458d79d, 0x733df21c, 0x5b94ec44, 0x7cf1c9c5, + 0x8885b759, 0xafe092d8, 0x87498c80, 0xa02ca901, 0xd71bb130, + 0xf07e94b1, 0xd8d78ae9, 0xffb2af68, 0x36b9ba8b, 0x11dc9f0a, + 0x39758152, 0x1e10a4d3, 0x6927bce2, 0x4e429963, 0x66eb873b, + 0x418ea2ba, 0xcf040ad8, 0xe8612f59, 0xc0c83101, 0xe7ad1480, + 0x909a0cb1, 0xb7ff2930, 0x9f563768, 0xb83312e9, 0x7138070a, + 0x565d228b, 0x7ef43cd3, 0x59911952, 0x2ea60163, 0x09c324e2, + 0x216a3aba, 0x060f1f3b, 0xf27b61a7, 0xd51e4426, 0xfdb75a7e, + 0xdad27fff, 0xade567ce, 0x8a80424f, 0xa2295c17, 0x854c7996, + 0x4c476c75, 0x6b2249f4, 0x438b57ac, 0x64ee722d, 0x13d96a1c, + 0x34bc4f9d, 0x1c1551c5, 0x3b707444, 0x6af5b94d, 0x4d909ccc, + 0x65398294, 0x425ca715, 0x356bbf24, 0x120e9aa5, 0x3aa784fd, + 0x1dc2a17c, 0xd4c9b49f, 0xf3ac911e, 0xdb058f46, 0xfc60aac7, + 0x8b57b2f6, 0xac329777, 0x849b892f, 0xa3feacae, 0x578ad232, + 0x70eff7b3, 0x5846e9eb, 0x7f23cc6a, 0x0814d45b, 0x2f71f1da, + 0x07d8ef82, 0x20bdca03, 0xe9b6dfe0, 0xced3fa61, 0xe67ae439, + 0xc11fc1b8, 0xb628d989, 0x914dfc08, 0xb9e4e250, 0x9e81c7d1, + 0x100b6fb3, 0x376e4a32, 0x1fc7546a, 0x38a271eb, 0x4f9569da, + 0x68f04c5b, 0x40595203, 0x673c7782, 0xae376261, 0x895247e0, + 0xa1fb59b8, 0x869e7c39, 0xf1a96408, 0xd6cc4189, 0xfe655fd1, + 0xd9007a50, 0x2d7404cc, 0x0a11214d, 0x22b83f15, 0x05dd1a94, + 0x72ea02a5, 0x558f2724, 0x7d26397c, 0x5a431cfd, 0x9348091e, + 0xb42d2c9f, 0x9c8432c7, 0xbbe11746, 0xccd60f77, 0xebb32af6, + 0xc31a34ae, 0xe47f112f, 0xdf0f656b, 0xf86a40ea, 0xd0c35eb2, + 0xf7a67b33, 0x80916302, 0xa7f44683, 0x8f5d58db, 0xa8387d5a, + 0x613368b9, 0x46564d38, 0x6eff5360, 0x499a76e1, 0x3ead6ed0, + 0x19c84b51, 0x31615509, 0x16047088, 0xe2700e14, 0xc5152b95, + 0xedbc35cd, 0xcad9104c, 0xbdee087d, 0x9a8b2dfc, 0xb22233a4, + 0x95471625, 0x5c4c03c6, 0x7b292647, 0x5380381f, 0x74e51d9e, + 0x03d205af, 0x24b7202e, 0x0c1e3e76, 0x2b7b1bf7, 0xa5f1b395, + 0x82949614, 0xaa3d884c, 0x8d58adcd, 0xfa6fb5fc, 0xdd0a907d, + 0xf5a38e25, 0xd2c6aba4, 0x1bcdbe47, 0x3ca89bc6, 0x1401859e, + 0x3364a01f, 0x4453b82e, 0x63369daf, 0x4b9f83f7, 0x6cfaa676, + 0x988ed8ea, 0xbfebfd6b, 0x9742e333, 0xb027c6b2, 0xc710de83, + 0xe075fb02, 0xc8dce55a, 0xefb9c0db, 0x26b2d538, 0x01d7f0b9, + 0x297eeee1, 0x0e1bcb60, 0x792cd351, 0x5e49f6d0, 0x76e0e888, + 0x5185cd09}}; + +#endif + +#endif + +#endif + +local const z_crc_t FAR x2n_table[] = { + 0x40000000, 0x20000000, 0x08000000, 0x00800000, 0x00008000, + 0xedb88320, 0xb1e6b092, 0xa06a2517, 0xed627dae, 0x88d14467, + 0xd7bbfe6a, 0xec447f11, 0x8e7ea170, 0x6427800e, 0x4d47bae0, + 0x09fe548f, 0x83852d0f, 0x30362f1a, 0x7b5a9cc3, 0x31fec169, + 0x9fec022a, 0x6c8dedc4, 0x15d6874d, 0x5fde7a4e, 0xbad90e37, + 0x2e4e5eef, 0x4eaba214, 0xa8a472c0, 0x429a969e, 0x148d302a, + 0xc40ba6d0, 0xc4e22c3c}; diff --git a/libz/deflate.c b/libz/deflate.c index 1ec76144..012ea814 100644 --- a/libz/deflate.c +++ b/libz/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; + " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -60,9 +60,6 @@ const char deflate_copyright[] = copyright string in the executable of your product. */ -/* =========================================================================== - * Function prototypes. - */ typedef enum { need_more, /* block not completed, need more input or more output */ block_done, /* block flush performed */ @@ -70,35 +67,16 @@ typedef enum { finish_done /* finish done, accept no more input or output */ } block_state; -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +typedef block_state (*compress_func)(deflate_state *s, int flush); /* Compression function. Returns the block state after the call. */ -local int deflateStateCheck OF((z_streamp strm)); -local void slide_hash OF((deflate_state *s)); -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); +local block_state deflate_stored(deflate_state *s, int flush); +local block_state deflate_fast(deflate_state *s, int flush); #ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifdef ASMV -# pragma message("Assembler code may have bugs -- use at your own risk") - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef ZLIB_DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); +local block_state deflate_slow(deflate_state *s, int flush); #endif +local block_state deflate_rle(deflate_state *s, int flush); +local block_state deflate_huff(deflate_state *s, int flush); /* =========================================================================== * Local data @@ -160,7 +138,7 @@ local const config configuration_table[10] = { * characters, so that a running hash key can be computed from the previous * key instead of complete recalculation each time. */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) +#define UPDATE_HASH(s,h,c) (h = (((h) << s->hash_shift) ^ (c)) & s->hash_mask) /* =========================================================================== @@ -190,17 +168,23 @@ local const config configuration_table[10] = { * prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + do { \ + s->head[s->hash_size - 1] = NIL; \ + zmemzero((Bytef *)s->head, \ + (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \ + } while (0) /* =========================================================================== * Slide the hash table when sliding the window down (could be avoided with 32 * bit values at the expense of memory usage). We slide even when level == 0 to * keep the hash table consistent if we switch back to level > 0 later. */ -local void slide_hash(s) - deflate_state *s; -{ +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) + __attribute__((no_sanitize("memory"))) +# endif +#endif +local void slide_hash(deflate_state *s) { unsigned n, m; Posf *p; uInt wsize = s->w_size; @@ -224,39 +208,181 @@ local void slide_hash(s) #endif } +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + zmemcpy(buf, strm->next_in, len); + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, buf, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, buf, len); + } +#endif + strm->next_in += len; + strm->total_in += len; + + return len; +} + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(deflate_state *s) { + unsigned n; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize + MAX_DIST(s)) { + + zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + if (s->insert > s->strstart) + s->insert = s->strstart; + slide_hash(s); + more += wsize; + } + if (s->strm->avail_in == 0) break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + uInt str = s->strstart - s->insert; + s->ins_h = s->window[str]; + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + while (s->insert) { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } + + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "not enough room for search"); +} + /* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, + int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, int strategy, + const char *version, int stream_size) { deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { return Z_VERSION_ERROR; @@ -287,6 +413,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (windowBits < 0) { /* suppress zlib wrapper */ wrap = 0; + if (windowBits < -15) + return Z_STREAM_ERROR; windowBits = -windowBits; } #ifdef GZIP @@ -316,7 +444,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, s->hash_bits = (uInt)memLevel + 7; s->hash_size = 1 << s->hash_bits; s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + s->hash_shift = ((s->hash_bits + MIN_MATCH-1) / MIN_MATCH); s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); @@ -326,9 +454,47 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + /* We overlay pending_buf and sym_buf. This works since the average size + * for length/distance pairs over any compressed block is assured to be 31 + * bits or less. + * + * Analysis: The longest fixed codes are a length code of 8 bits plus 5 + * extra bits, for lengths 131 to 257. The longest fixed distance codes are + * 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest + * possible fixed-codes length/distance pair is then 31 bits total. + * + * sym_buf starts one-fourth of the way into pending_buf. So there are + * three bytes in sym_buf for every four bytes in pending_buf. Each symbol + * in sym_buf is three bytes -- two for the distance and one for the + * literal/length. As each symbol is consumed, the pointer to the next + * sym_buf value to read moves forward three bytes. From that symbol, up to + * 31 bits are written to pending_buf. The closest the written pending_buf + * bits gets to the next sym_buf symbol to read is just before the last + * code is written. At that time, 31*(n - 2) bits have been written, just + * after 24*(n - 2) bits have been consumed from sym_buf. sym_buf starts at + * 8*n bits into pending_buf. (Note that the symbol buffer fills when n - 1 + * symbols are written.) The closest the writing gets to what is unread is + * then n + 14 bits. Here n is lit_bufsize, which is 16384 by default, and + * can range from 128 to 32768. + * + * Therefore, at a minimum, there are 142 bits of space between what is + * written and what is read in the overlain buffers, so the symbols cannot + * be overwritten by the compressed data. That space is actually 139 bits, + * due to the three-bit fixed-code block header. + * + * That covers the case where either Z_FIXED is specified, forcing fixed + * codes, or when the use of fixed codes is chosen, because that choice + * results in a smaller compressed block than dynamic codes. That latter + * condition then assures that the above analysis also covers all dynamic + * blocks. A dynamic-code block will only be chosen to be emitted if it has + * fewer bits than a fixed-code block would for the same set of symbols. + * Therefore its average symbol length is assured to be less than 31. So + * the compressed data for a dynamic block also cannot overwrite the + * symbols from which it is being constructed. + */ + + s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS); + s->pending_buf_size = (ulg)s->lit_bufsize * 4; if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { @@ -337,8 +503,18 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, deflateEnd (strm); return Z_MEM_ERROR; } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; +#ifdef LIT_MEM + s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); + s->l_buf = s->pending_buf + (s->lit_bufsize << 2); + s->sym_end = s->lit_bufsize - 1; +#else + s->sym_buf = s->pending_buf + s->lit_bufsize; + s->sym_end = (s->lit_bufsize - 1) * 3; +#endif + /* We avoid equality with lit_bufsize*3 because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ s->level = level; s->strategy = strategy; @@ -350,9 +526,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, /* ========================================================================= * Check for a valid deflate stream state. Return 0 if ok, 1 if not. */ -local int deflateStateCheck (strm) - z_streamp strm; -{ +local int deflateStateCheck(z_streamp strm) { deflate_state *s; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -373,11 +547,8 @@ local int deflateStateCheck (strm) } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ +int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { deflate_state *s; uInt str, n; int wrap; @@ -442,11 +613,8 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) - z_streamp strm; - Bytef *dictionary; - uInt *dictLength; -{ +int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { deflate_state *s; uInt len; @@ -464,9 +632,7 @@ int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateResetKeep (strm) - z_streamp strm; -{ +int ZEXPORT deflateResetKeep(z_streamp strm) { deflate_state *s; if (deflateStateCheck(strm)) { @@ -488,23 +654,45 @@ int ZEXPORT deflateResetKeep (strm) #ifdef GZIP s->wrap == 2 ? GZIP_STATE : #endif - s->wrap ? INIT_STATE : BUSY_STATE; + INIT_STATE; strm->adler = #ifdef GZIP s->wrap == 2 ? crc32(0L, Z_NULL, 0) : #endif adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; + s->last_flush = -2; _tr_init(s); return Z_OK; } +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init(deflate_state *s) { + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->insert = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +} + /* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ +int ZEXPORT deflateReset(z_streamp strm) { int ret; ret = deflateResetKeep(strm); @@ -514,10 +702,7 @@ int ZEXPORT deflateReset (strm) } /* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ +int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { if (deflateStateCheck(strm) || strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; @@ -525,11 +710,7 @@ int ZEXPORT deflateSetHeader (strm, head) } /* ========================================================================= */ -int ZEXPORT deflatePending (strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ +int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != Z_NULL) *pending = strm->state->pending; @@ -539,18 +720,21 @@ int ZEXPORT deflatePending (strm, pending, bits) } /* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ +int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { deflate_state *s; int put; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; - if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) +#ifdef LIT_MEM + if (bits < 0 || bits > 16 || + (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; +#else + if (bits < 0 || bits > 16 || + s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; +#endif do { put = Buf_size - s->bi_valid; if (put > bits) @@ -565,11 +749,7 @@ int ZEXPORT deflatePrime (strm, bits, value) } /* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; @@ -587,12 +767,12 @@ int ZEXPORT deflateParams(strm, level, strategy) func = configuration_table[s->level].func; if ((strategy != s->strategy || func != configuration_table[level].func) && - s->high_water) { + s->last_flush != -2) { /* Flush the last buffer: */ int err = deflate(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) return err; - if (strm->avail_out == 0) + if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) return Z_BUF_ERROR; } if (s->level != level) { @@ -614,13 +794,8 @@ int ZEXPORT deflateParams(strm, level, strategy) } /* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ +int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, + int nice_length, int max_chain) { deflate_state *s; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -633,36 +808,47 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) } /* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. + * For the default windowBits of 15 and memLevel of 8, this function returns a + * close to exact, as well as small, upper bound on the compressed size. This + * is an expansion of ~0.03%, plus a small constant. + * + * For any setting other than those defaults for windowBits and memLevel, one + * of two worst case bounds is returned. This is at most an expansion of ~4% or + * ~13%, plus a small constant. + * + * Both the 0.03% and 4% derive from the overhead of stored blocks. The first + * one is for stored blocks of 16383 bytes (memLevel == 8), whereas the second + * is for stored blocks of 127 bytes (the worst case memLevel == 1). The + * expansion results from five bytes of header for each stored block. * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. + * The larger expansion of 13% results from a window size less than or equal to + * the symbols buffer size (windowBits <= memLevel + 7). In that case some of + * the data being compressed may have slid out of the sliding window, impeding + * a stored block from being emitted. Then the only choice is a fixed or + * dynamic block, where a fixed block limits the maximum expansion to 9 bits + * per 8-bit byte, plus 10 bits for every block. The smallest block size for + * which this can occur is 255 (memLevel == 2). * - * This function could be more sophisticated to provide closer upper bounds for - * every combination of windowBits and memLevel. But even the conservative - * upper bound of about 14% expansion does not seem onerous for output buffer - * allocation. + * Shifts are used to approximate divisions, for speed. */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ +uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { deflate_state *s; - uLong complen, wraplen; + uLong fixedlen, storelen, wraplen; - /* conservative upper bound for compressed data */ - complen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; + /* upper bound for fixed blocks with 9-bit literals and length 255 + (memLevel == 2, which is the lowest that may not use stored blocks) -- + ~13% overhead plus a small constant */ + fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) + + (sourceLen >> 9) + 4; - /* if can't get parameters, return conservative bound plus zlib wrapper */ + /* upper bound for stored blocks with length 127 (memLevel == 1) -- + ~4% overhead plus a small constant */ + storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) + + (sourceLen >> 11) + 7; + + /* if can't get parameters, return larger bound plus a zlib wrapper */ if (deflateStateCheck(strm)) - return complen + 6; + return (fixedlen > storelen ? fixedlen : storelen) + 6; /* compute wrapper length */ s = strm->state; @@ -699,11 +885,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen) wraplen = 6; } - /* if not default parameters, return conservative bound */ + /* if not default parameters, return one of the conservative bounds */ if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return complen + wraplen; + return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + + wraplen; - /* default settings: return tight bound for that case */ + /* default settings: return tight bound for that case -- ~0.03% overhead + plus a small constant */ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13 - 6 + wraplen; } @@ -713,10 +901,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen) * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ +local void putShortMSB(deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); } @@ -727,9 +912,7 @@ local void putShortMSB (s, b) * applications may wish to modify it to avoid allocating a large * strm->next_out buffer and copying into it. (See also read_buf()). */ -local void flush_pending(strm) - z_streamp strm; -{ +local void flush_pending(z_streamp strm) { unsigned len; deflate_state *s = strm->state; @@ -760,10 +943,7 @@ local void flush_pending(strm) } while (0) /* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ +int ZEXPORT deflate(z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; @@ -811,9 +991,11 @@ int ZEXPORT deflate (strm, flush) } /* Write the header */ + if (s->status == INIT_STATE && s->wrap == 0) + s->status = BUSY_STATE; if (s->status == INIT_STATE) { /* zlib header */ - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt header = (Z_DEFLATED + ((s->w_bits - 8) << 4)) << 8; uInt level_flags; if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) @@ -1073,9 +1255,7 @@ int ZEXPORT deflate (strm, flush) } /* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ +int ZEXPORT deflateEnd(z_streamp strm) { int status; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1099,16 +1279,14 @@ int ZEXPORT deflateEnd (strm) * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ +int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K + (void)dest; + (void)source; return Z_STREAM_ERROR; #else deflate_state *ds; deflate_state *ss; - ushf *overlay; if (deflateStateCheck(source) || dest == Z_NULL) { @@ -1128,8 +1306,7 @@ int ZEXPORT deflateCopy (dest, source) ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; + ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS); if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { @@ -1140,11 +1317,15 @@ int ZEXPORT deflateCopy (dest, source) zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; +#ifdef LIT_MEM + ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1)); + ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2); +#else + ds->sym_buf = ds->pending_buf + ds->lit_bufsize; +#endif ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; @@ -1154,71 +1335,6 @@ int ZEXPORT deflateCopy (dest, source) #endif /* MAXSEG_64K */ } -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local unsigned read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - #ifndef FASTEST /* =========================================================================== * Set match_start to the longest match starting at the given string and @@ -1229,14 +1345,7 @@ local void lm_init (s) * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 * OUT assertion: the match length is not greater than s->lookahead. */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ @@ -1257,10 +1366,10 @@ local uInt longest_match(s, cur_match) */ register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); + register ush scan_end = *(ushf*)(scan + best_len - 1); #else register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end1 = scan[best_len - 1]; register Byte scan_end = scan[best_len]; #endif @@ -1278,7 +1387,8 @@ local uInt longest_match(s, cur_match) */ if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); @@ -1296,43 +1406,44 @@ local uInt longest_match(s, cur_match) /* This code assumes sizeof(unsigned short) == 2. Do not use * UNALIGNED_OK if your compiler uses a different size. */ - if (*(ushf*)(match+best_len-1) != scan_end || + if (*(ushf*)(match + best_len - 1) != scan_end || *(ushf*)match != scan_start) continue; /* It is not necessary to compare scan[2] and match[2] since they are * always equal when the other bytes match, given that the hash keys * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient + * strstart + 3, + 5, up to strstart + 257. We check for insufficient * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * at strstart + 257. If MAX_MATCH-2 is not a multiple of 8, it is * necessary to put more guard bytes at the end of the window, or * to check more often for insufficient lookahead. */ Assert(scan[2] == match[2], "scan[2]?"); scan++, match++; do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + } while (*(ushf*)(scan += 2) == *(ushf*)(match += 2) && + *(ushf*)(scan += 2) == *(ushf*)(match += 2) && + *(ushf*)(scan += 2) == *(ushf*)(match += 2) && + *(ushf*)(scan += 2) == *(ushf*)(match += 2) && scan < strend); /* The funny "do {}" generates better code on most compilers */ - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + /* Here, scan <= window + strstart + 257 */ + Assert(scan <= s->window + (unsigned)(s->window_size - 1), + "wild scan"); if (*scan == *match) scan++; - len = (MAX_MATCH - 1) - (int)(strend-scan); + len = (MAX_MATCH - 1) - (int)(strend - scan); scan = strend - (MAX_MATCH-1); #else /* UNALIGNED_OK */ - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; + if (match[best_len] != scan_end || + match[best_len - 1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; - /* The check at best_len-1 can be removed because it will be made + /* The check at best_len - 1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that @@ -1342,7 +1453,7 @@ local uInt longest_match(s, cur_match) Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. + * the 256th check will be made at strstart + 258. */ do { } while (*++scan == *++match && *++scan == *++match && @@ -1351,7 +1462,8 @@ local uInt longest_match(s, cur_match) *++scan == *++match && *++scan == *++match && scan < strend); - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + Assert(scan <= s->window + (unsigned)(s->window_size - 1), + "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; @@ -1363,9 +1475,9 @@ local uInt longest_match(s, cur_match) best_len = len; if (len >= nice_match) break; #ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); + scan_end = *(ushf*)(scan + best_len - 1); #else - scan_end1 = scan[best_len-1]; + scan_end1 = scan[best_len - 1]; scan_end = scan[best_len]; #endif } @@ -1375,17 +1487,13 @@ local uInt longest_match(s, cur_match) if ((uInt)best_len <= s->lookahead) return (uInt)best_len; return s->lookahead; } -#endif /* ASMV */ #else /* FASTEST */ /* --------------------------------------------------------------------------- * Optimized version for FASTEST only */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ @@ -1396,7 +1504,8 @@ local uInt longest_match(s, cur_match) */ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "need lookahead"); Assert(cur_match < s->strstart, "no future"); @@ -1406,7 +1515,7 @@ local uInt longest_match(s, cur_match) */ if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - /* The check at best_len-1 can be removed because it will be made + /* The check at best_len - 1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that @@ -1416,7 +1525,7 @@ local uInt longest_match(s, cur_match) Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. + * the 256th check will be made at strstart + 258. */ do { } while (*++scan == *++match && *++scan == *++match && @@ -1425,7 +1534,7 @@ local uInt longest_match(s, cur_match) *++scan == *++match && *++scan == *++match && scan < strend); - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + Assert(scan <= s->window + (unsigned)(s->window_size - 1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); @@ -1445,23 +1554,27 @@ local uInt longest_match(s, cur_match) /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ +local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); + fprintf(stderr,"\\[%d,%d]", start - match, length); do { putc(s->window[start++], stderr); } while (--length != 0); } } @@ -1469,135 +1582,6 @@ local void check_match(s, start, match, length) # define check_match(s, start, match, length) #endif /* ZLIB_DEBUG */ -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - unsigned n; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - slide_hash(s); - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. @@ -1638,12 +1622,9 @@ local void fill_window(s) * * deflate_stored() is written to minimize the number of times an input byte is * copied. It is most efficient with large input and output buffers, which - * maximizes the opportunites to have a single copy from next_in to next_out. + * maximizes the opportunities to have a single copy from next_in to next_out. */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_stored(deflate_state *s, int flush) { /* Smallest worthy block size when not flushing or finishing. By default * this is 32K. This can be as small as 507 bytes for memLevel == 1. For * large input and output buffers, the stored block size will be larger. @@ -1742,6 +1723,7 @@ local block_state deflate_stored(s, flush) s->matches = 2; /* clear hash */ zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); s->strstart = s->w_size; + s->insert = s->strstart; } else { if (s->window_size - s->strstart <= used) { @@ -1750,12 +1732,14 @@ local block_state deflate_stored(s, flush) zmemcpy(s->window, s->window + s->w_size, s->strstart); if (s->matches < 2) s->matches++; /* add a pending slide_hash() */ + if (s->insert > s->strstart) + s->insert = s->strstart; } zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); s->strstart += used; + s->insert += MIN(used, s->w_size - s->insert); } s->block_start = s->strstart; - s->insert += MIN(used, s->w_size - s->insert); } if (s->high_water < s->strstart) s->high_water = s->strstart; @@ -1770,7 +1754,7 @@ local block_state deflate_stored(s, flush) return block_done; /* Fill the window with any remaining input. */ - have = s->window_size - s->strstart - 1; + have = s->window_size - s->strstart; if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { /* Slide the window down. */ s->block_start -= s->w_size; @@ -1779,12 +1763,15 @@ local block_state deflate_stored(s, flush) if (s->matches < 2) s->matches++; /* add a pending slide_hash() */ have += s->w_size; /* more space now */ + if (s->insert > s->strstart) + s->insert = s->strstart; } if (have > s->strm->avail_in) have = s->strm->avail_in; if (have) { read_buf(s->strm, s->window + s->strstart, have); s->strstart += have; + s->insert += MIN(have, s->w_size - s->insert); } if (s->high_water < s->strstart) s->high_water = s->strstart; @@ -1821,10 +1808,7 @@ local block_state deflate_stored(s, flush) * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ @@ -1842,7 +1826,7 @@ local block_state deflate_fast(s, flush) if (s->lookahead == 0) break; /* flush the current block */ } - /* Insert the string window[strstart .. strstart+2] in the + /* Insert the string window[strstart .. strstart + 2] in the * dictionary, and set hash_head to the head of the hash chain: */ hash_head = NIL; @@ -1890,7 +1874,7 @@ local block_state deflate_fast(s, flush) s->strstart += s->match_length; s->match_length = 0; s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); + UPDATE_HASH(s, s->ins_h, s->window[s->strstart + 1]); #if MIN_MATCH != 3 Call UPDATE_HASH() MIN_MATCH-3 more times #endif @@ -1901,7 +1885,7 @@ local block_state deflate_fast(s, flush) } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); + _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } @@ -1912,7 +1896,7 @@ local block_state deflate_fast(s, flush) FLUSH_BLOCK(s, 1); return finish_done; } - if (s->last_lit) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } @@ -1923,10 +1907,7 @@ local block_state deflate_fast(s, flush) * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head; /* head of hash chain */ int bflush; /* set if current block must be flushed */ @@ -1945,7 +1926,7 @@ local block_state deflate_slow(s, flush) if (s->lookahead == 0) break; /* flush the current block */ } - /* Insert the string window[strstart .. strstart+2] in the + /* Insert the string window[strstart .. strstart + 2] in the * dictionary, and set hash_head to the head of the hash chain: */ hash_head = NIL; @@ -1987,17 +1968,17 @@ local block_state deflate_slow(s, flush) uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; /* Do not insert strings in hash table beyond this. */ - check_match(s, s->strstart-1, s->prev_match, s->prev_length); + check_match(s, s->strstart - 1, s->prev_match, s->prev_length); - _tr_tally_dist(s, s->strstart -1 - s->prev_match, + _tr_tally_dist(s, s->strstart - 1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not + * strstart - 1 and strstart are already inserted. If there is not * enough lookahead, the last two strings are not inserted in * the hash table. */ - s->lookahead -= s->prev_length-1; + s->lookahead -= s->prev_length - 1; s->prev_length -= 2; do { if (++s->strstart <= max_insert) { @@ -2015,8 +1996,8 @@ local block_state deflate_slow(s, flush) * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); + Tracevv((stderr,"%c", s->window[s->strstart - 1])); + _tr_tally_lit(s, s->window[s->strstart - 1], bflush); if (bflush) { FLUSH_BLOCK_ONLY(s, 0); } @@ -2034,8 +2015,8 @@ local block_state deflate_slow(s, flush) } Assert (flush != Z_NO_FLUSH, "no flush?"); if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); + Tracevv((stderr,"%c", s->window[s->strstart - 1])); + _tr_tally_lit(s, s->window[s->strstart - 1], bflush); s->match_available = 0; } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; @@ -2043,7 +2024,7 @@ local block_state deflate_slow(s, flush) FLUSH_BLOCK(s, 1); return finish_done; } - if (s->last_lit) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } @@ -2054,10 +2035,7 @@ local block_state deflate_slow(s, flush) * one. Do not maintain a hash table. (It will be regenerated if this run of * deflate switches away from Z_RLE.) */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_rle(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ uInt prev; /* byte at distance one to match */ Bytef *scan, *strend; /* scan goes up to strend for length of run */ @@ -2092,7 +2070,8 @@ local block_state deflate_rle(s, flush) if (s->match_length > s->lookahead) s->match_length = s->lookahead; } - Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); + Assert(scan <= s->window + (uInt)(s->window_size - 1), + "wild scan"); } /* Emit match if have run of MIN_MATCH or longer, else emit literal */ @@ -2107,7 +2086,7 @@ local block_state deflate_rle(s, flush) } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); + _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } @@ -2118,7 +2097,7 @@ local block_state deflate_rle(s, flush) FLUSH_BLOCK(s, 1); return finish_done; } - if (s->last_lit) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } @@ -2127,10 +2106,7 @@ local block_state deflate_rle(s, flush) * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. * (It will be regenerated if this run of deflate switches away from Huffman.) */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_huff(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ for (;;) { @@ -2147,7 +2123,7 @@ local block_state deflate_huff(s, flush) /* Output a literal byte */ s->match_length = 0; Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); + _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; if (bflush) FLUSH_BLOCK(s, 0); @@ -2157,7 +2133,7 @@ local block_state deflate_huff(s, flush) FLUSH_BLOCK(s, 1); return finish_done; } - if (s->last_lit) + if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } diff --git a/libz/deflate.h b/libz/deflate.h index 23ecdd31..300c6ada 100644 --- a/libz/deflate.h +++ b/libz/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2016 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -23,6 +23,10 @@ # define GZIP #endif +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at + the cost of a larger memory footprint */ +/* #define LIT_MEM */ + /* =========================================================================== * Internal compression state. */ @@ -217,7 +221,14 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ - uchf *l_buf; /* buffer for literals or lengths */ +#ifdef LIT_MEM +# define LIT_BUFS 5 + ushf *d_buf; /* buffer for distances */ + uchf *l_buf; /* buffer for literals/lengths */ +#else +# define LIT_BUFS 4 + uchf *sym_buf; /* buffer for distances and literals/lengths */ +#endif uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for @@ -239,13 +250,8 @@ typedef struct internal_state { * - I can't count above 4 */ - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ + uInt sym_next; /* running index in symbol buffer */ + uInt sym_end; /* symbol table full when sym_next reaches this */ ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ @@ -296,14 +302,14 @@ typedef struct internal_state { memory checker errors from longest match routines */ /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_init(deflate_state *s); +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last); +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL _tr_align(deflate_state *s); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last); #define d_code(dist) \ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) @@ -323,23 +329,45 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, extern const uch ZLIB_INTERNAL _dist_code[]; #endif +#ifdef LIT_MEM +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->sym_next] = 0; \ + s->l_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->sym_next] = dist; \ + s->l_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#else # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = 0; \ + s->sym_buf[s->sym_next++] = cc; \ s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ + flush = (s->sym_next == s->sym_end); \ } # define _tr_tally_dist(s, distance, length, flush) \ { uch len = (uch)(length); \ ush dist = (ush)(distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ + s->sym_buf[s->sym_next++] = (uch)dist; \ + s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \ + s->sym_buf[s->sym_next++] = len; \ dist--; \ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ + flush = (s->sym_next == s->sym_end); \ } +#endif #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ diff --git a/libz/gzclose.c b/libz/gzclose.c index caeb99a3..48d6a86f 100644 --- a/libz/gzclose.c +++ b/libz/gzclose.c @@ -8,9 +8,7 @@ /* gzclose() is in a separate file so that it is linked in only if it is used. That way the other gzclose functions can be used instead to avoid linking in unneeded compression or decompression routines. */ -int ZEXPORT gzclose(file) - gzFile file; -{ +int ZEXPORT gzclose(gzFile file) { #ifndef NO_GZCOMPRESS gz_statep state; diff --git a/libz/gzguts.h b/libz/gzguts.h index 990a4d25..eba72085 100644 --- a/libz/gzguts.h +++ b/libz/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -7,9 +7,8 @@ # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 # endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif +# undef _FILE_OFFSET_BITS +# undef _TIME_BITS #endif #ifdef HAVE_HIDDEN @@ -39,7 +38,7 @@ # include #endif -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) # define WIDECHAR #endif @@ -119,8 +118,8 @@ /* gz* functions always use library allocation functions */ #ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); + extern voidp malloc(uInt size); + extern void free(voidpf ptr); #endif /* get errno and strerror definition */ @@ -138,10 +137,10 @@ /* provide prototypes for these when building zlib without LFS */ #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); #endif /* default memLevel */ @@ -190,6 +189,7 @@ typedef struct { /* just for writing */ int level; /* compression level */ int strategy; /* compression strategy */ + int reset; /* true if a reset is pending after a Z_FINISH */ /* seek request */ z_off64_t skip; /* amount to skip (already rewound if backwards) */ int seek; /* true if seek request pending */ @@ -202,17 +202,13 @@ typedef struct { typedef gz_state FAR *gz_statep; /* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); #if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +char ZLIB_INTERNAL *gz_strwinerror(DWORD error); #endif /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif +unsigned ZLIB_INTERNAL gz_intmax(void); +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/libz/gzlib.c b/libz/gzlib.c index 4105e6af..983153cc 100644 --- a/libz/gzlib.c +++ b/libz/gzlib.c @@ -1,11 +1,11 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2017 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" -#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) +#if defined(_WIN32) && !defined(__BORLANDC__) # define LSEEK _lseeki64 #else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 @@ -15,10 +15,6 @@ #endif #endif -/* Local functions */ -local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const void *, int, const char *)); - #if defined UNDER_CE /* Map the Windows error number in ERROR to a locale-dependent error message @@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *)); The gz_strwinerror function does not change the current setting of GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror (error) - DWORD error; -{ +char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { static char buf[1024]; wchar_t *msgbuf; @@ -72,15 +66,15 @@ char ZLIB_INTERNAL *gz_strwinerror (error) #endif /* UNDER_CE */ /* Reset gzip file state */ -local void gz_reset(state) - gz_statep state; -{ +local void gz_reset(gz_statep state) { state->x.have = 0; /* no output data available */ if (state->mode == GZ_READ) { /* for reading ... */ state->eof = 0; /* not at end of file */ state->past = 0; /* have not read past end yet */ state->how = LOOK; /* look for gzip header */ } + else /* for writing ... */ + state->reset = 0; /* no deflateReset pending */ state->seek = 0; /* no seek request pending */ gz_error(state, Z_OK, NULL); /* clear error */ state->x.pos = 0; /* no uncompressed data yet */ @@ -88,11 +82,7 @@ local void gz_reset(state) } /* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(path, fd, mode) - const void *path; - int fd; - const char *mode; -{ +local gzFile gz_open(const void *path, int fd, const char *mode) { gz_statep state; z_size_t len; int oflag; @@ -267,26 +257,17 @@ local gzFile gz_open(path, fd, mode) } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen64(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(fd, mode) - int fd; - const char *mode; -{ +gzFile ZEXPORT gzdopen(int fd, const char *mode) { char *path; /* identifier for error messages */ gzFile gz; @@ -304,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode) /* -- see zlib.h -- */ #ifdef WIDECHAR -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ +gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { return gz_open(path, -2, mode); } #endif /* -- see zlib.h -- */ -int ZEXPORT gzbuffer(file, size) - gzFile file; - unsigned size; -{ +int ZEXPORT gzbuffer(gzFile file, unsigned size) { gz_statep state; /* get internal structure and check integrity */ @@ -333,16 +308,14 @@ int ZEXPORT gzbuffer(file, size) /* check and set requested size */ if ((size << 1) < size) return -1; /* need to be able to double it */ - if (size < 2) - size = 2; /* need two bytes to check magic header */ + if (size < 8) + size = 8; /* needed to behave well with flushing */ state->want = size; return 0; } /* -- see zlib.h -- */ -int ZEXPORT gzrewind(file) - gzFile file; -{ +int ZEXPORT gzrewind(gzFile file) { gz_statep state; /* get internal structure */ @@ -363,11 +336,7 @@ int ZEXPORT gzrewind(file) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(file, offset, whence) - gzFile file; - z_off64_t offset; - int whence; -{ +z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { unsigned n; z_off64_t ret; gz_statep state; @@ -397,7 +366,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) /* if within raw area while reading, just go there */ if (state->mode == GZ_READ && state->how == COPY && state->x.pos + offset >= 0) { - ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); + ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR); if (ret == -1) return -1; state->x.have = 0; @@ -440,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ +z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { z_off64_t ret; ret = gzseek64(file, (z_off64_t)offset, whence); @@ -452,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(file) - gzFile file; -{ +z_off64_t ZEXPORT gztell64(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -469,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(file) - gzFile file; -{ +z_off_t ZEXPORT gztell(gzFile file) { z_off64_t ret; ret = gztell64(file); @@ -479,9 +440,7 @@ z_off_t ZEXPORT gztell(file) } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(file) - gzFile file; -{ +z_off64_t ZEXPORT gzoffset64(gzFile file) { z_off64_t offset; gz_statep state; @@ -502,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file) } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(file) - gzFile file; -{ +z_off_t ZEXPORT gzoffset(gzFile file) { z_off64_t ret; ret = gzoffset64(file); @@ -512,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file) } /* -- see zlib.h -- */ -int ZEXPORT gzeof(file) - gzFile file; -{ +int ZEXPORT gzeof(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -529,10 +484,7 @@ int ZEXPORT gzeof(file) } /* -- see zlib.h -- */ -const char * ZEXPORT gzerror(file, errnum) - gzFile file; - int *errnum; -{ +const char * ZEXPORT gzerror(gzFile file, int *errnum) { gz_statep state; /* get internal structure and check integrity */ @@ -550,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum) } /* -- see zlib.h -- */ -void ZEXPORT gzclearerr(file) - gzFile file; -{ +void ZEXPORT gzclearerr(gzFile file) { gz_statep state; /* get internal structure and check integrity */ @@ -576,11 +526,7 @@ void ZEXPORT gzclearerr(file) memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory. */ -void ZLIB_INTERNAL gz_error(state, err, msg) - gz_statep state; - int err; - const char *msg; -{ +void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { /* free previously allocated message and clear */ if (state->msg != NULL) { if (state->err != Z_MEM_ERROR) @@ -617,21 +563,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg) #endif } -#ifndef INT_MAX /* portably return maximum value for an int (when limits.h presumed not available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax() -{ - unsigned p, q; - - p = 1; +unsigned ZLIB_INTERNAL gz_intmax(void) { +#ifdef INT_MAX + return INT_MAX; +#else + unsigned p = 1, q; do { q = p; p <<= 1; p++; } while (p > q); return q >> 1; -} #endif +} diff --git a/libz/gzread.c b/libz/gzread.c index 14c3d41f..4168cbc8 100644 --- a/libz/gzread.c +++ b/libz/gzread.c @@ -1,29 +1,16 @@ /* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" -/* Local functions */ -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); -local int gz_avail OF((gz_statep)); -local int gz_look OF((gz_statep)); -local int gz_decomp OF((gz_statep)); -local int gz_fetch OF((gz_statep)); -local int gz_skip OF((gz_statep, z_off64_t)); -local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); - /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. This function needs to loop on read(), since read() is not guaranteed to read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(state, buf, len, have) - gz_statep state; - unsigned char *buf; - unsigned len; - unsigned *have; -{ +local int gz_load(gz_statep state, unsigned char *buf, unsigned len, + unsigned *have) { int ret; unsigned get, max = ((unsigned)-1 >> 2) + 1; @@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have) If strm->avail_in != 0, then the current data is moved to the beginning of the input buffer, and then the remainder of the buffer is loaded with the available data from the input file. */ -local int gz_avail(state) - gz_statep state; -{ +local int gz_avail(gz_statep state) { unsigned got; z_streamp strm = &(state->strm); @@ -88,9 +73,7 @@ local int gz_avail(state) case, all further file reads will be directly to either the output buffer or a user buffer. If decompressing, the inflate state will be initialized. gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(state) - gz_statep state; -{ +local int gz_look(gz_statep state) { z_streamp strm = &(state->strm); /* allocate read buffers and inflate memory */ @@ -157,11 +140,9 @@ local int gz_look(state) the output buffer is larger than the input buffer, which also assures space for gzungetc() */ state->x.next = state->out; - if (strm->avail_in) { - memcpy(state->x.next, strm->next_in, strm->avail_in); - state->x.have = strm->avail_in; - strm->avail_in = 0; - } + memcpy(state->x.next, strm->next_in, strm->avail_in); + state->x.have = strm->avail_in; + strm->avail_in = 0; state->how = COPY; state->direct = 1; return 0; @@ -172,9 +153,7 @@ local int gz_look(state) data. If the gzip stream completes, state->how is reset to LOOK to look for the next gzip stream or raw data, once state->x.have is depleted. Returns 0 on success, -1 on failure. */ -local int gz_decomp(state) - gz_statep state; -{ +local int gz_decomp(gz_statep state) { int ret = Z_OK; unsigned had; z_streamp strm = &(state->strm); @@ -226,9 +205,7 @@ local int gz_decomp(state) looked for to determine whether to copy or decompress. Returns -1 on error, otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the end of the input file has been reached and all data has been processed. */ -local int gz_fetch(state) - gz_statep state; -{ +local int gz_fetch(gz_statep state) { z_streamp strm = &(state->strm); do { @@ -256,10 +233,7 @@ local int gz_fetch(state) } /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_skip(gz_statep state, z_off64_t len) { unsigned n; /* skip over len bytes or reach end-of-file, whichever comes first */ @@ -291,11 +265,7 @@ local int gz_skip(state, len) input. Return the number of bytes read. If zero is returned, either the end of file was reached, or there was an error. state->err must be consulted in that case to determine which. */ -local z_size_t gz_read(state, buf, len) - gz_statep state; - voidp buf; - z_size_t len; -{ +local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { z_size_t got; unsigned n; @@ -314,7 +284,7 @@ local z_size_t gz_read(state, buf, len) got = 0; do { /* set n to the maximum amount of len that fits in an unsigned int */ - n = -1; + n = (unsigned)-1; if (n > len) n = (unsigned)len; @@ -372,11 +342,7 @@ local z_size_t gz_read(state, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ +int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { gz_statep state; /* get internal structure */ @@ -408,12 +374,7 @@ int ZEXPORT gzread(file, buf, len) } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(buf, size, nitems, file) - voidp buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { z_size_t len; gz_statep state; @@ -444,10 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) #else # undef gzgetc #endif -int ZEXPORT gzgetc(file) - gzFile file; -{ - int ret; +int ZEXPORT gzgetc(gzFile file) { unsigned char buf[1]; gz_statep state; @@ -469,21 +427,15 @@ int ZEXPORT gzgetc(file) } /* nothing there -- try gz_read() */ - ret = (int)gz_read(state, buf, 1); - return ret < 1 ? -1 : buf[0]; + return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; } -int ZEXPORT gzgetc_(file) -gzFile file; -{ +int ZEXPORT gzgetc_(gzFile file) { return gzgetc(file); } /* -- see zlib.h -- */ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ +int ZEXPORT gzungetc(int c, gzFile file) { gz_statep state; /* get internal structure */ @@ -491,6 +443,10 @@ int ZEXPORT gzungetc(c, file) return -1; state = (gz_statep)file; + /* in case this was just opened, set up the input buffer */ + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) + (void)gz_look(state); + /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) @@ -540,11 +496,7 @@ int ZEXPORT gzungetc(c, file) } /* -- see zlib.h -- */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ +char * ZEXPORT gzgets(gzFile file, char *buf, int len) { unsigned left, n; char *str; unsigned char *eol; @@ -604,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzdirect(file) - gzFile file; -{ +int ZEXPORT gzdirect(gzFile file) { gz_statep state; /* get internal structure */ @@ -624,9 +574,7 @@ int ZEXPORT gzdirect(file) } /* -- see zlib.h -- */ -int ZEXPORT gzclose_r(file) - gzFile file; -{ +int ZEXPORT gzclose_r(gzFile file) { int ret, err; gz_statep state; diff --git a/libz/gzwrite.c b/libz/gzwrite.c index 706be56b..435b4621 100644 --- a/libz/gzwrite.c +++ b/libz/gzwrite.c @@ -1,22 +1,14 @@ /* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004-2017 Mark Adler + * Copyright (C) 2004-2019 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" -/* Local functions */ -local int gz_init OF((gz_statep)); -local int gz_comp OF((gz_statep, int)); -local int gz_zero OF((gz_statep, z_off64_t)); -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); - /* Initialize state for writing a gzip file. Mark initialization by setting state->size to non-zero. Return -1 on a memory allocation failure, or 0 on success. */ -local int gz_init(state) - gz_statep state; -{ +local int gz_init(gz_statep state) { int ret; z_streamp strm = &(state->strm); @@ -70,10 +62,7 @@ local int gz_init(state) deflate() flush value. If flush is Z_FINISH, then the deflate() state is reset to start a new gzip stream. If gz->direct is true, then simply write to the output file without compressing, and ignore flush. */ -local int gz_comp(state, flush) - gz_statep state; - int flush; -{ +local int gz_comp(gz_statep state, int flush) { int ret, writ; unsigned have, put, max = ((unsigned)-1 >> 2) + 1; z_streamp strm = &(state->strm); @@ -97,6 +86,15 @@ local int gz_comp(state, flush) return 0; } + /* check for a pending reset */ + if (state->reset) { + /* don't start a new gzip member unless there is data to write */ + if (strm->avail_in == 0) + return 0; + deflateReset(strm); + state->reset = 0; + } + /* run deflate() on provided input until it produces no more output */ ret = Z_OK; do { @@ -134,7 +132,7 @@ local int gz_comp(state, flush) /* if that completed a deflate stream, allow another to start */ if (flush == Z_FINISH) - deflateReset(strm); + state->reset = 1; /* all done, no errors */ return 0; @@ -142,10 +140,7 @@ local int gz_comp(state, flush) /* Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */ -local int gz_zero(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_zero(gz_statep state, z_off64_t len) { int first; unsigned n; z_streamp strm = &(state->strm); @@ -175,11 +170,7 @@ local int gz_zero(state, len) /* Write len bytes from buf to file. Return the number of bytes written. If the returned value is less than len, then there was an error. */ -local z_size_t gz_write(state, buf, len) - gz_statep state; - voidpc buf; - z_size_t len; -{ +local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { z_size_t put = len; /* if len is zero, avoid unnecessary operations */ @@ -243,11 +234,7 @@ local z_size_t gz_write(state, buf, len) } /* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ +int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { gz_statep state; /* get internal structure */ @@ -271,12 +258,8 @@ int ZEXPORT gzwrite(file, buf, len) } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) - voidpc buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, + gzFile file) { z_size_t len; gz_statep state; @@ -301,10 +284,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) } /* -- see zlib.h -- */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ +int ZEXPORT gzputc(gzFile file, int c) { unsigned have; unsigned char buf[1]; gz_statep state; @@ -349,12 +329,8 @@ int ZEXPORT gzputc(file, c) } /* -- see zlib.h -- */ -int ZEXPORT gzputs(file, str) - gzFile file; - const char *str; -{ - int ret; - z_size_t len; +int ZEXPORT gzputs(gzFile file, const char *s) { + z_size_t len, put; gz_statep state; /* get internal structure */ @@ -367,17 +343,20 @@ int ZEXPORT gzputs(file, str) return -1; /* write string */ - len = strlen(str); - ret = (int)gz_write(state, str, len); - return ret == 0 && len != 0 ? -1 : ret; + len = strlen(s); + if ((int)len < 0 || (unsigned)len != len) { + gz_error(state, Z_STREAM_ERROR, "string length does not fit in int"); + return -1; + } + put = gz_write(state, s, len); + return put < len ? -1 : (int)len; } #if defined(STDC) || defined(Z_HAVE_STDARG_H) #include /* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) -{ +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { int len; unsigned left; char *next; @@ -441,15 +420,14 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) strm->avail_in = state->size; if (gz_comp(state, Z_NO_FLUSH) == -1) return state->err; - memcpy(state->in, state->in + state->size, left); + memmove(state->in, state->in + state->size, left); strm->next_in = state->in; strm->avail_in = left; } return len; } -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { va_list va; int ret; @@ -462,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) #else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, + int a4, int a5, int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, int a15, int a16, + int a17, int a18, int a19, int a20) { unsigned len, left; char *next; gz_statep state; @@ -540,7 +515,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, strm->avail_in = state->size; if (gz_comp(state, Z_NO_FLUSH) == -1) return state->err; - memcpy(state->in, state->in + state->size, left); + memmove(state->in, state->in + state->size, left); strm->next_in = state->in; strm->avail_in = left; } @@ -550,10 +525,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, #endif /* -- see zlib.h -- */ -int ZEXPORT gzflush(file, flush) - gzFile file; - int flush; -{ +int ZEXPORT gzflush(gzFile file, int flush) { gz_statep state; /* get internal structure */ @@ -582,11 +554,7 @@ int ZEXPORT gzflush(file, flush) } /* -- see zlib.h -- */ -int ZEXPORT gzsetparams(file, level, strategy) - gzFile file; - int level; - int strategy; -{ +int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { gz_statep state; z_streamp strm; @@ -597,7 +565,7 @@ int ZEXPORT gzsetparams(file, level, strategy) strm = &(state->strm); /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) + if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) return Z_STREAM_ERROR; /* if no change is requested, then do nothing */ @@ -624,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy) } /* -- see zlib.h -- */ -int ZEXPORT gzclose_w(file) - gzFile file; -{ +int ZEXPORT gzclose_w(gzFile file) { int ret = Z_OK; gz_statep state; diff --git a/libz/infback.c b/libz/infback.c index 59679ecb..e7b25b30 100644 --- a/libz/infback.c +++ b/libz/infback.c @@ -1,5 +1,5 @@ /* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2016 Mark Adler + * Copyright (C) 1995-2022 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,9 +15,6 @@ #include "inflate.h" #include "inffast.h" -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. @@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state)); windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ +int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, const char *version, + int stream_size) { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || @@ -66,6 +59,7 @@ int stream_size; state->window = window; state->wnext = 0; state->whave = 0; + state->sane = 1; return Z_OK; } @@ -79,9 +73,7 @@ int stream_size; used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; @@ -247,13 +239,8 @@ struct inflate_state FAR *state; inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ +int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ @@ -477,6 +464,7 @@ void FAR *out_desc; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; + /* fallthrough */ case LEN: /* use inflate_fast() if we have enough input and output */ @@ -604,33 +592,33 @@ void FAR *out_desc; break; case DONE: - /* inflate stream terminated properly -- write leftover output */ + /* inflate stream terminated properly */ ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; - default: /* can't happen, but makes compilers happy */ + default: + /* can't happen, but makes compilers happy */ ret = Z_STREAM_ERROR; goto inf_leave; } - /* Return unused input */ + /* Write leftover output and return unused input */ inf_leave: + if (left < state->wsize) { + if (out(out_desc, state->window, state->wsize - left) && + ret == Z_STREAM_END) + ret = Z_BUF_ERROR; + } strm->next_in = next; strm->avail_in = have; return ret; } -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateBackEnd(z_streamp strm) { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); diff --git a/libz/inffast.c b/libz/inffast.c index 0dbd1dbc..9354676e 100644 --- a/libz/inffast.c +++ b/libz/inffast.c @@ -47,10 +47,7 @@ requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { struct inflate_state FAR *state; z_const unsigned char FAR *in; /* local strm->next_in */ z_const unsigned char FAR *last; /* have enough input while in < last */ @@ -70,7 +67,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ code const FAR *dcode; /* local strm->distcode */ unsigned lmask; /* mask for first level of length codes */ unsigned dmask; /* mask for first level of distance codes */ - code here; /* retrieved table entry */ + code const *here; /* retrieved table entry */ unsigned op; /* code bits, operation, extra bits, or */ /* window position, window bytes to copy */ unsigned len; /* match length, unused bytes */ @@ -107,20 +104,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ hold += (unsigned long)(*in++) << bits; bits += 8; } - here = lcode[hold & lmask]; + here = lcode + (hold & lmask); dolen: - op = (unsigned)(here.bits); + op = (unsigned)(here->bits); hold >>= op; bits -= op; - op = (unsigned)(here.op); + op = (unsigned)(here->op); if (op == 0) { /* literal */ - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ? "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - *out++ = (unsigned char)(here.val); + "inflate: literal 0x%02x\n", here->val)); + *out++ = (unsigned char)(here->val); } else if (op & 16) { /* length base */ - len = (unsigned)(here.val); + len = (unsigned)(here->val); op &= 15; /* number of extra bits */ if (op) { if (bits < op) { @@ -138,14 +135,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ hold += (unsigned long)(*in++) << bits; bits += 8; } - here = dcode[hold & dmask]; + here = dcode + (hold & dmask); dodist: - op = (unsigned)(here.bits); + op = (unsigned)(here->bits); hold >>= op; bits -= op; - op = (unsigned)(here.op); + op = (unsigned)(here->op); if (op & 16) { /* distance base */ - dist = (unsigned)(here.val); + dist = (unsigned)(here->val); op &= 15; /* number of extra bits */ if (bits < op) { hold += (unsigned long)(*in++) << bits; @@ -264,7 +261,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ } } else if ((op & 64) == 0) { /* 2nd level distance code */ - here = dcode[here.val + (hold & ((1U << op) - 1))]; + here = dcode + here->val + (hold & ((1U << op) - 1)); goto dodist; } else { @@ -274,7 +271,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ } } else if ((op & 64) == 0) { /* 2nd level length code */ - here = lcode[here.val + (hold & ((1U << op) - 1))]; + here = lcode + here->val + (hold & ((1U << op) - 1)); goto dolen; } else if (op & 32) { /* end-of-block */ diff --git a/libz/inffast.h b/libz/inffast.h index e5c1aa4c..49c6d156 100644 --- a/libz/inffast.h +++ b/libz/inffast.h @@ -8,4 +8,4 @@ subject to change. Applications should only use zlib.h. */ -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); diff --git a/libz/inflate.c b/libz/inflate.c index ac333e8c..94ecff01 100644 --- a/libz/inflate.c +++ b/libz/inflate.c @@ -1,5 +1,5 @@ /* inflate.c -- zlib decompression - * Copyright (C) 1995-2016 Mark Adler + * Copyright (C) 1995-2022 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -91,20 +91,7 @@ # endif #endif -/* function prototypes */ -local int inflateStateCheck OF((z_streamp strm)); -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -local int inflateStateCheck(strm) -z_streamp strm; -{ +local int inflateStateCheck(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -116,9 +103,7 @@ z_streamp strm; return 0; } -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ +int ZEXPORT inflateResetKeep(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -130,6 +115,7 @@ z_streamp strm; state->mode = HEAD; state->last = 0; state->havedict = 0; + state->flags = -1; state->dmax = 32768U; state->head = Z_NULL; state->hold = 0; @@ -141,9 +127,7 @@ z_streamp strm; return Z_OK; } -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ +int ZEXPORT inflateReset(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -154,10 +138,7 @@ z_streamp strm; return inflateResetKeep(strm); } -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ +int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { int wrap; struct inflate_state FAR *state; @@ -167,6 +148,8 @@ int windowBits; /* extract wrap request from windowBits parameter */ if (windowBits < 0) { + if (windowBits < -15) + return Z_STREAM_ERROR; wrap = 0; windowBits = -windowBits; } @@ -192,12 +175,8 @@ int windowBits; return inflateReset(strm); } -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size) { int ret; struct inflate_state FAR *state; @@ -236,22 +215,17 @@ int stream_size; return ret; } -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit_(z_streamp strm, const char *version, + int stream_size) { return inflateInit2_(strm, DEF_WBITS, version, stream_size); } -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ +int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + if (bits == 0) + return Z_OK; state = (struct inflate_state FAR *)strm->state; if (bits < 0) { state->hold = 0; @@ -275,9 +249,7 @@ int value; used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; @@ -339,7 +311,7 @@ struct inflate_state FAR *state; a.out > inffixed.h */ -void makefixed() +void makefixed(void) { unsigned low, size; struct inflate_state state; @@ -393,11 +365,7 @@ void makefixed() output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ +local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { struct inflate_state FAR *state; unsigned dist; @@ -447,10 +415,10 @@ unsigned copy; /* check function to use adler32() for zlib or crc32() for gzip */ #ifdef GUNZIP -# define UPDATE(check, buf, len) \ +# define UPDATE_CHECK(check, buf, len) \ (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) #else -# define UPDATE(check, buf, len) adler32(check, buf, len) +# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len) #endif /* check macros for header crc */ @@ -619,10 +587,7 @@ unsigned copy; will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ +int ZEXPORT inflate(z_streamp strm, int flush) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ @@ -670,7 +635,6 @@ int flush; state->mode = FLAGS; break; } - state->flags = 0; /* expect zlib header */ if (state->head != Z_NULL) state->head->done = -1; if (!(state->wrap & 1) || /* check if zlib header allowed */ @@ -697,6 +661,7 @@ int flush; break; } state->dmax = 1U << len; + state->flags = 0; /* indicate zlib header */ Tracev((stderr, "inflate: zlib header ok\n")); strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = hold & 0x200 ? DICTID : TYPE; @@ -722,6 +687,7 @@ int flush; CRC2(state->check, hold); INITBITS(); state->mode = TIME; + /* fallthrough */ case TIME: NEEDBITS(32); if (state->head != Z_NULL) @@ -730,6 +696,7 @@ int flush; CRC4(state->check, hold); INITBITS(); state->mode = OS; + /* fallthrough */ case OS: NEEDBITS(16); if (state->head != Z_NULL) { @@ -740,6 +707,7 @@ int flush; CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; + /* fallthrough */ case EXLEN: if (state->flags & 0x0400) { NEEDBITS(16); @@ -753,14 +721,16 @@ int flush; else if (state->head != Z_NULL) state->head->extra = Z_NULL; state->mode = EXTRA; + /* fallthrough */ case EXTRA: if (state->flags & 0x0400) { copy = state->length; if (copy > have) copy = have; if (copy) { if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; + state->head->extra != Z_NULL && + (len = state->head->extra_len - state->length) < + state->head->extra_max) { zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy); @@ -775,6 +745,7 @@ int flush; } state->length = 0; state->mode = NAME; + /* fallthrough */ case NAME: if (state->flags & 0x0800) { if (have == 0) goto inf_leave; @@ -796,6 +767,7 @@ int flush; state->head->name = Z_NULL; state->length = 0; state->mode = COMMENT; + /* fallthrough */ case COMMENT: if (state->flags & 0x1000) { if (have == 0) goto inf_leave; @@ -816,6 +788,7 @@ int flush; else if (state->head != Z_NULL) state->head->comment = Z_NULL; state->mode = HCRC; + /* fallthrough */ case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); @@ -839,6 +812,7 @@ int flush; strm->adler = state->check = ZSWAP32(hold); INITBITS(); state->mode = DICT; + /* fallthrough */ case DICT: if (state->havedict == 0) { RESTORE(); @@ -846,8 +820,10 @@ int flush; } strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = TYPE; + /* fallthrough */ case TYPE: if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; + /* fallthrough */ case TYPEDO: if (state->last) { BYTEBITS(); @@ -898,8 +874,10 @@ int flush; INITBITS(); state->mode = COPY_; if (flush == Z_TREES) goto inf_leave; + /* fallthrough */ case COPY_: state->mode = COPY; + /* fallthrough */ case COPY: copy = state->length; if (copy) { @@ -935,6 +913,7 @@ int flush; Tracev((stderr, "inflate: table sizes ok\n")); state->have = 0; state->mode = LENLENS; + /* fallthrough */ case LENLENS: while (state->have < state->ncode) { NEEDBITS(3); @@ -956,6 +935,7 @@ int flush; Tracev((stderr, "inflate: code lengths ok\n")); state->have = 0; state->mode = CODELENS; + /* fallthrough */ case CODELENS: while (state->have < state->nlen + state->ndist) { for (;;) { @@ -1039,8 +1019,10 @@ int flush; Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN_; if (flush == Z_TREES) goto inf_leave; + /* fallthrough */ case LEN_: state->mode = LEN; + /* fallthrough */ case LEN: if (have >= 6 && left >= 258) { RESTORE(); @@ -1090,6 +1072,7 @@ int flush; } state->extra = (unsigned)(here.op) & 15; state->mode = LENEXT; + /* fallthrough */ case LENEXT: if (state->extra) { NEEDBITS(state->extra); @@ -1100,6 +1083,7 @@ int flush; Tracevv((stderr, "inflate: length %u\n", state->length)); state->was = state->length; state->mode = DIST; + /* fallthrough */ case DIST: for (;;) { here = state->distcode[BITS(state->distbits)]; @@ -1127,6 +1111,7 @@ int flush; state->offset = (unsigned)here.val; state->extra = (unsigned)(here.op) & 15; state->mode = DISTEXT; + /* fallthrough */ case DISTEXT: if (state->extra) { NEEDBITS(state->extra); @@ -1143,6 +1128,7 @@ int flush; #endif Tracevv((stderr, "inflate: distance %u\n", state->offset)); state->mode = MATCH; + /* fallthrough */ case MATCH: if (left == 0) goto inf_leave; copy = out - left; @@ -1202,7 +1188,7 @@ int flush; state->total += out; if ((state->wrap & 4) && out) strm->adler = state->check = - UPDATE(state->check, put - out, out); + UPDATE_CHECK(state->check, put - out, out); out = left; if ((state->wrap & 4) && ( #ifdef GUNZIP @@ -1218,10 +1204,11 @@ int flush; } #ifdef GUNZIP state->mode = LENGTH; + /* fallthrough */ case LENGTH: if (state->wrap && state->flags) { NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { + if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { strm->msg = (char *)"incorrect length check"; state->mode = BAD; break; @@ -1231,6 +1218,7 @@ int flush; } #endif state->mode = DONE; + /* fallthrough */ case DONE: ret = Z_STREAM_END; goto inf_leave; @@ -1240,6 +1228,7 @@ int flush; case MEM: return Z_MEM_ERROR; case SYNC: + /* fallthrough */ default: return Z_STREAM_ERROR; } @@ -1265,7 +1254,7 @@ int flush; state->total += out; if ((state->wrap & 4) && out) strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); + UPDATE_CHECK(state->check, strm->next_out - out, out); strm->data_type = (int)state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); @@ -1274,9 +1263,7 @@ int flush; return ret; } -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateEnd(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1288,11 +1275,8 @@ z_streamp strm; return Z_OK; } -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { struct inflate_state FAR *state; /* check state */ @@ -1311,11 +1295,8 @@ uInt *dictLength; return Z_OK; } -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ +int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { struct inflate_state FAR *state; unsigned long dictid; int ret; @@ -1346,10 +1327,7 @@ uInt dictLength; return Z_OK; } -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ +int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { struct inflate_state FAR *state; /* check state */ @@ -1374,11 +1352,8 @@ gz_headerp head; called again with more data and the *have state. *have is initialized to zero for the first call. */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ +local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, + unsigned len) { unsigned got; unsigned next; @@ -1397,10 +1372,9 @@ unsigned len; return next; } -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ +int ZEXPORT inflateSync(z_streamp strm) { unsigned len; /* number of bytes to look at or looked at */ + int flags; /* temporary to save header status */ unsigned long in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state FAR *state; @@ -1413,7 +1387,7 @@ z_streamp strm; /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; - state->hold <<= state->bits & 7; + state->hold >>= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { @@ -1433,9 +1407,15 @@ z_streamp strm; /* return no joy or set up to restart inflate() on a new block */ if (state->have != 4) return Z_DATA_ERROR; + if (state->flags == -1) + state->wrap = 0; /* if no header yet, treat as raw */ + else + state->wrap &= ~4; /* no point in computing a check value now */ + flags = state->flags; in = strm->total_in; out = strm->total_out; inflateReset(strm); strm->total_in = in; strm->total_out = out; + state->flags = flags; state->mode = TYPE; return Z_OK; } @@ -1448,9 +1428,7 @@ z_streamp strm; block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ +int ZEXPORT inflateSyncPoint(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1458,10 +1436,7 @@ z_streamp strm; return state->mode == STORED && state->bits == 0; } -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ +int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { struct inflate_state FAR *state; struct inflate_state FAR *copy; unsigned char FAR *window; @@ -1505,10 +1480,7 @@ z_streamp source; return Z_OK; } -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ +int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1523,24 +1495,19 @@ int subvert; #endif } -int ZEXPORT inflateValidate(strm, check) -z_streamp strm; -int check; -{ +int ZEXPORT inflateValidate(z_streamp strm, int check) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; - if (check) + if (check && state->wrap) state->wrap |= 4; else state->wrap &= ~4; return Z_OK; } -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ +long ZEXPORT inflateMark(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) @@ -1551,9 +1518,7 @@ z_streamp strm; (state->mode == MATCH ? state->was - state->length : 0)); } -unsigned long ZEXPORT inflateCodesUsed(strm) -z_streamp strm; -{ +unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return (unsigned long)-1; state = (struct inflate_state FAR *)strm->state; diff --git a/libz/inflate.h b/libz/inflate.h index a46cce6b..f127b6b1 100644 --- a/libz/inflate.h +++ b/libz/inflate.h @@ -1,5 +1,5 @@ /* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2016 Mark Adler + * Copyright (C) 1995-2019 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -86,7 +86,8 @@ struct inflate_state { int wrap; /* bit 0 true for zlib, bit 1 true for gzip, bit 2 true to validate check value */ int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ + int flags; /* gzip header method and flags, 0 if zlib, or + -1 if raw or no header yet */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned long check; /* protected copy of check value */ unsigned long total; /* protected copy of output count */ diff --git a/libz/inftrees.c b/libz/inftrees.c index 2ea08fc1..98cfe164 100644 --- a/libz/inftrees.c +++ b/libz/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2017 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; + " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -29,14 +29,9 @@ const char inflate_copyright[] = table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ @@ -62,7 +57,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, diff --git a/libz/inftrees.h b/libz/inftrees.h index baa53a0b..396f74b5 100644 --- a/libz/inftrees.h +++ b/libz/inftrees.h @@ -38,11 +38,11 @@ typedef struct { /* Maximum size of the dynamic table. The maximum number of code structures is 1444, which is the sum of 852 for literal/length codes and 592 for distance codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that + examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the + returns 852, and "enough 30 6 15" for distance codes returns 592. The + initial root table size (9 or 6) is found in the fifth argument of the inflate_table() calls in inflate.c and infback.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and updated. */ @@ -57,6 +57,6 @@ typedef enum { DISTS } codetype; -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work); diff --git a/libz/libz.vcxproj b/libz/libz.vcxproj index 1cc46827..c10fa8df 100644 --- a/libz/libz.vcxproj +++ b/libz/libz.vcxproj @@ -1,14 +1,6 @@ - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + {AB342A30-9A85-497B-8C03-7A95AB3DC9AA} @@ -44,52 +36,39 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 - Unicode - - - DynamicLibrary - true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 - true - Unicode - - - DynamicLibrary - false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode @@ -98,78 +77,60 @@ - + - - - - + - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ zlib1 true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ zlib1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - true - zlib1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ true + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ zlib1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ zlib1 false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ zlib1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - false - zlib1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ zlib1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ @@ -178,9 +139,10 @@ Disabled true _DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -195,26 +157,10 @@ Disabled true _DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h - true - true - - - Windows - true - zlib.def - - - - - Use - Level3 - Disabled - true - _DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -229,9 +175,10 @@ Disabled true _DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Windows @@ -248,10 +195,11 @@ true true NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -260,6 +208,7 @@ false UseLinkTimeCodeGeneration zlib.def + true @@ -271,33 +220,11 @@ true true NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h - true - true - Guard - - - Windows - true - true - false - UseLinkTimeCodeGeneration - zlib.def - - - - - Use - Level3 - MaxSpeed - true - true - true - NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -306,6 +233,7 @@ false UseLinkTimeCodeGeneration zlib.def + true @@ -317,10 +245,11 @@ true true NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Windows @@ -339,7 +268,7 @@ - + @@ -358,14 +287,12 @@ - + Create Create - Create Create Create Create - Create Create diff --git a/libz/libz.vcxproj.filters b/libz/libz.vcxproj.filters index e207f8ad..db792cc5 100644 --- a/libz/libz.vcxproj.filters +++ b/libz/libz.vcxproj.filters @@ -15,7 +15,7 @@ - + Header Files @@ -53,7 +53,7 @@ - + Source Files @@ -102,14 +102,12 @@ Source Files - - - Resource Files - - Resource Files + + + \ No newline at end of file diff --git a/libz/pch.c b/libz/pch.c new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/libz/pch.c @@ -0,0 +1 @@ + diff --git a/libz/stdafx.h b/libz/pch.h similarity index 100% rename from libz/stdafx.h rename to libz/pch.h diff --git a/libz/trees.c b/libz/trees.c index 50cf4b45..6a523ef3 100644 --- a/libz/trees.c +++ b/libz/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2017 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -122,39 +122,116 @@ struct static_tree_desc_s { int max_length; /* max bit length for the codes */ }; -local const static_tree_desc static_l_desc = +#ifdef NO_INIT_GLOBAL_POINTERS +# define TCONST +#else +# define TCONST const +#endif + +local TCONST static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; -local const static_tree_desc static_d_desc = +local TCONST static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; -local const static_tree_desc static_bl_desc = +local TCONST static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== - * Local (static) routines in this file. + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 */ +local unsigned bi_reverse(unsigned code, int len) { + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(deflate_state *s) { + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(deflate_state *s) { + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->bits_sent = (s->bits_sent + 7) & ~7; +#endif +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + unsigned code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + code = (code + bl_count[bits - 1]) << 1; + next_code[bits] = (ush)code; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, + "inconsistent bit counts"); + Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); + + for (n = 0; n <= max_code; n++) { + int len = tree[n].Len; + if (len == 0) continue; + /* Now reverse the bits */ + tree[n].Code = (ush)bi_reverse(next_code[len]++, len); + + Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", + n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); + } +} #ifdef GEN_TREES_H -local void gen_trees_header OF((void)); +local void gen_trees_header(void); #endif #ifndef ZLIB_DEBUG @@ -167,33 +244,18 @@ local void gen_trees_header OF((void)); send_bits(s, tree[c].Code, tree[c].Len); } #endif -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef ZLIB_DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ +local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * (16 - bi_valid) bits from value, leaving (width - (16 - bi_valid)) * unused bits in value. */ if (s->bi_valid > (int)Buf_size - length) { @@ -229,8 +291,7 @@ local void send_bits(s, value, length) /* =========================================================================== * Initialize the various 'constant' tables. */ -local void tr_static_init() -{ +local void tr_static_init(void) { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ @@ -256,7 +317,7 @@ local void tr_static_init() length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ for ( ; code < D_CODES; code++) { base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { _dist_code[256 + dist++] = (uch)code; } } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); + Assert (dist == 256, "tr_static_init: 256 + dist != 512"); /* Construct the codes of the static literal tree */ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; @@ -312,7 +373,7 @@ local void tr_static_init() } /* =========================================================================== - * Genererate the file trees.h describing the static trees. + * Generate the file trees.h describing the static trees. */ #ifdef GEN_TREES_H # ifndef ZLIB_DEBUG @@ -321,10 +382,9 @@ local void tr_static_init() # define SEPARATOR(i, last, width) \ ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) + ((i) % (width) == (width) - 1 ? ",\n" : ", ")) -void gen_trees_header() -{ +void gen_trees_header(void) { FILE *header = fopen("trees.h", "w"); int i; @@ -373,12 +433,26 @@ void gen_trees_header() } #endif /* GEN_TREES_H */ +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(deflate_state *s) { + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->sym_next = s->matches = 0; +} + /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_init(deflate_state *s) { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; @@ -401,24 +475,6 @@ void ZLIB_INTERNAL _tr_init(s) init_block(s); } -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ @@ -448,17 +504,13 @@ local void init_block(s) * when the heap property is re-established (each father smaller than its * two sons). */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ +local void pqdownheap(deflate_state *s, ct_data *tree, int k) { int v = s->heap[k]; int j = k << 1; /* left son of k */ while (j <= s->heap_len) { /* Set j to the smallest of the two sons: */ if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + smaller(tree, s->heap[j + 1], s->heap[j], s->depth)) { j++; } /* Exit if v is smaller than both sons */ @@ -483,10 +535,7 @@ local void pqdownheap(s, tree, k) * The length opt_len is updated; static_len is also updated if stree is * not null. */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void gen_bitlen(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; const ct_data *stree = desc->stat_desc->static_tree; @@ -507,7 +556,7 @@ local void gen_bitlen(s, desc) */ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + for (h = s->heap_max + 1; h < HEAP_SIZE; h++) { n = s->heap[h]; bits = tree[tree[n].Dad].Len + 1; if (bits > max_length) bits = max_length, overflow++; @@ -518,7 +567,7 @@ local void gen_bitlen(s, desc) s->bl_count[bits]++; xbits = 0; - if (n >= base) xbits = extra[n-base]; + if (n >= base) xbits = extra[n - base]; f = tree[n].Freq; s->opt_len += (ulg)f * (unsigned)(bits + xbits); if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); @@ -530,10 +579,10 @@ local void gen_bitlen(s, desc) /* Find the first bit length which could increase: */ do { - bits = max_length-1; + bits = max_length - 1; while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits + 1] += 2; /* move one overflow item as its brother */ s->bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] @@ -561,48 +610,9 @@ local void gen_bitlen(s, desc) } } -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - unsigned code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits-1]) << 1; - next_code[bits] = (ush)code; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1< +#endif /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. @@ -612,10 +622,7 @@ local void gen_codes (tree, max_code, bl_count) * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ -local void build_tree(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void build_tree(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; int elems = desc->stat_desc->elems; @@ -624,7 +631,7 @@ local void build_tree(s, desc) int node; /* new node being created */ /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1]. * heap[0] is not used. */ s->heap_len = 0, s->heap_max = HEAP_SIZE; @@ -652,7 +659,7 @@ local void build_tree(s, desc) } desc->max_code = max_code; - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + /* The elements heap[heap_len/2 + 1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); @@ -700,11 +707,7 @@ local void build_tree(s, desc) * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ @@ -714,10 +717,10 @@ local void scan_tree (s, tree, max_code) int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ + tree[max_code + 1].Len = (ush)0xffff; /* guard */ for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; + curlen = nextlen; nextlen = tree[n + 1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { @@ -745,11 +748,7 @@ local void scan_tree (s, tree, max_code) * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void send_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ @@ -758,11 +757,11 @@ local void send_tree (s, tree, max_code) int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ - /* tree[max_code+1].Len = -1; */ /* guard already set */ + /* tree[max_code + 1].Len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; + curlen = nextlen; nextlen = tree[n + 1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { @@ -773,13 +772,13 @@ local void send_tree (s, tree, max_code) send_code(s, curlen, s->bl_tree); count--; } Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count - 3, 2); } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count - 3, 3); } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count - 11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { @@ -796,9 +795,7 @@ local void send_tree (s, tree, max_code) * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ -local int build_bl_tree(s) - deflate_state *s; -{ +local int build_bl_tree(deflate_state *s) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ @@ -807,8 +804,8 @@ local int build_bl_tree(s) /* Build the bit length tree: */ build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + /* opt_len now includes the length of the tree representations, except the + * lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format @@ -819,7 +816,7 @@ local int build_bl_tree(s) if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; } /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; + s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); @@ -831,61 +828,54 @@ local int build_bl_tree(s) * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ +local void send_all_trees(deflate_state *s, int lcodes, int dcodes, + int blcodes) { int rank; /* index in bl_order */ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes - 1, 5); + send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Tracev((stderr, "\nbl code %2d ", bl_order[rank])); send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); } Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1); /* literal tree */ Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1); /* distance tree */ Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); } /* =========================================================================== * Send a stored block */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { + send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ bi_windup(s); /* align on byte boundary */ put_short(s, (ush)stored_len); put_short(s, (ush)~stored_len); - zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); + if (stored_len) + zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); s->pending += stored_len; #ifdef ZLIB_DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; s->bits_sent += 2*16; - s->bits_sent += stored_len<<3; + s->bits_sent += stored_len << 3; #endif } /* =========================================================================== * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { bi_flush(s); } @@ -893,9 +883,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s) * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_align(deflate_state *s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef ZLIB_DEBUG @@ -904,16 +892,108 @@ void ZLIB_INTERNAL _tr_align(s) bi_flush(s); } +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(deflate_state *s, const ct_data *ltree, + const ct_data *dtree) { + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned sx = 0; /* running index in symbol buffers */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->sym_next != 0) do { +#ifdef LIT_MEM + dist = s->d_buf[sx]; + lc = s->l_buf[sx++]; +#else + dist = s->sym_buf[sx++] & 0xff; + dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; + lc = s->sym_buf[sx++]; +#endif + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code + LITERALS + 1, ltree); /* send length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= (unsigned)base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check for no overlay of pending_buf on needed symbols */ +#ifdef LIT_MEM + Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow"); +#else + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); +#endif + + } while (sx < s->sym_next); + + send_code(s, END_BLOCK, ltree); +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "block list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(deflate_state *s) { + /* block_mask is the bit mask of block-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long block_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("block-listed") bytes. */ + for (n = 0; n <= 31; n++, block_mask >>= 1) + if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("allow-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "block-listed" or "allow-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and write out the encoded block. */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ @@ -942,14 +1022,17 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) max_blindex = build_bl_tree(s); /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; + opt_lenb = (s->opt_len + 3 + 7) >> 3; + static_lenb = (s->static_len + 3 + 7) >> 3; Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); + s->sym_next / 3)); - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; +#ifndef FORCE_STATIC + if (static_lenb <= opt_lenb || s->strategy == Z_FIXED) +#endif + opt_lenb = static_lenb; } else { Assert(buf != (char*)0, "lost buf"); @@ -959,7 +1042,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) #ifdef FORCE_STORED if (buf != (char*)0) { /* force stored block */ #else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { + if (stored_len + 4 <= opt_lenb && buf != (char*)0) { /* 4: two words for the lengths */ #endif /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. @@ -970,21 +1053,17 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) */ _tr_stored_block(s, buf, stored_len, last); -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+last, 3); + } else if (static_lenb == opt_lenb) { + send_bits(s, (STATIC_TREES<<1) + last, 3); compress_block(s, (const ct_data *)static_ltree, (const ct_data *)static_dtree); #ifdef ZLIB_DEBUG s->compressed_len += 3 + s->static_len; #endif } else { - send_bits(s, (DYN_TREES<<1)+last, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); + send_bits(s, (DYN_TREES<<1) + last, 3); + send_all_trees(s, s->l_desc.max_code + 1, s->d_desc.max_code + 1, + max_blindex + 1); compress_block(s, (const ct_data *)s->dyn_ltree, (const ct_data *)s->dyn_dtree); #ifdef ZLIB_DEBUG @@ -1003,21 +1082,23 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) s->compressed_len += 7; /* align on byte boundary */ #endif } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*last)); + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3, + s->compressed_len - 7*last)); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ -int ZLIB_INTERNAL _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { +#ifdef LIT_MEM + s->d_buf[s->sym_next] = (ush)dist; + s->l_buf[s->sym_next++] = (uch)lc; +#else + s->sym_buf[s->sym_next++] = (uch)dist; + s->sym_buf[s->sym_next++] = (uch)(dist >> 8); + s->sym_buf[s->sym_next++] = (uch)lc; +#endif if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; @@ -1029,175 +1110,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++; s->dyn_dtree[d_code(dist)].Freq++; } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= (unsigned)base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "black list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* black_mask is the bit mask of black-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long black_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("black-listed") bytes. */ - for (n = 0; n <= 31; n++, black_mask >>= 1) - if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("white-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "black-listed" or "white-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif + return (s->sym_next == s->sym_end); } diff --git a/libz/uncompr.c b/libz/uncompr.c index f03a1a86..5e256663 100644 --- a/libz/uncompr.c +++ b/libz/uncompr.c @@ -24,12 +24,8 @@ Z_DATA_ERROR if the input data was corrupted, including if the input data is an incomplete zlib stream. */ -int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong *sourceLen; -{ +int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong *sourceLen) { z_stream stream; int err; const uInt max = (uInt)-1; @@ -83,11 +79,7 @@ int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) err; } -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return uncompress2(dest, destLen, source, &sourceLen); } diff --git a/libz/zconf.h b/libz/zconf.h index 5e1d68a0..62adc8d8 100644 --- a/libz/zconf.h +++ b/libz/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -38,6 +38,9 @@ # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 +# define crc32_combine_gen z_crc32_combine_gen +# define crc32_combine_gen64 z_crc32_combine_gen64 +# define crc32_combine_op z_crc32_combine_op # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound @@ -238,7 +241,11 @@ #endif #ifdef Z_SOLO - typedef unsigned long z_size_t; +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif #else # define z_longlong long long # if defined(NO_SIZE_T) @@ -293,14 +300,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have @@ -349,6 +348,9 @@ # ifdef FAR # undef FAR # endif +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif # include /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ @@ -467,11 +469,18 @@ typedef uLong FAR uLongf; # undef _LARGEFILE64_SOURCE #endif -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H +#ifndef Z_HAVE_UNISTD_H +# ifdef __WATCOMC__ +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_HAVE_UNISTD_H +# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32) +# define Z_HAVE_UNISTD_H +# endif #endif #ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# if defined(Z_HAVE_UNISTD_H) # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ # ifdef VMS # include /* for off_t */ @@ -507,7 +516,7 @@ typedef uLong FAR uLongf; #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# if defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t diff --git a/libz/zlib.def b/libz/zlib.def index 784b1386..53c80115 100644 --- a/libz/zlib.def +++ b/libz/zlib.def @@ -69,6 +69,7 @@ EXPORTS gzoffset64 adler32_combine64 crc32_combine64 + crc32_combine_gen64 ; checksum functions adler32 adler32_z @@ -76,6 +77,8 @@ EXPORTS crc32_z adler32_combine crc32_combine + crc32_combine_gen + crc32_combine_op ; various hacks, don't look :) deflateInit_ deflateInit2_ diff --git a/libz/zlib.h b/libz/zlib.h index f09cdaf1..8d4b932e 100644 --- a/libz/zlib.h +++ b/libz/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.11, January 15th, 2017 + version 1.3.1, January 22nd, 2024 - Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.11" -#define ZLIB_VERNUM 0x12b0 +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 #define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 11 +#define ZLIB_VER_MINOR 3 +#define ZLIB_VER_REVISION 1 #define ZLIB_VER_SUBREVISION 0 /* @@ -78,8 +78,8 @@ extern "C" { even in the case of corrupted input. */ -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); +typedef void (*free_func)(voidpf opaque, voidpf address); struct internal_state; @@ -217,7 +217,7 @@ typedef gz_header FAR *gz_headerp; /* basic functions */ -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +ZEXTERN const char * ZEXPORT zlibVersion(void); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check @@ -225,12 +225,12 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); */ /* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. + allocation functions. total_in, total_out, adler, and msg are initialized. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all @@ -247,7 +247,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); */ -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -276,7 +276,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. See deflatePending(), - which can be used if desired to determine whether or not there is more ouput + which can be used if desired to determine whether or not there is more output in that case. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to @@ -320,8 +320,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. + avail_out is greater than six when the flush marker begins, in order to avoid + repeated flush markers upon calling deflate() again when avail_out == 0. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was @@ -360,7 +360,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -375,7 +375,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by @@ -383,7 +383,8 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); read or consumed. The allocation of a sliding window will be deferred to the first call of inflate (if the decompression does not complete on the first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. + them to use default allocation functions. total_in, total_out, adler, and + msg are initialized. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the @@ -397,7 +398,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); */ -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce @@ -517,7 +518,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending @@ -535,16 +536,15 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); */ /* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. + fields zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. @@ -608,9 +608,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. When using the zlib format, this @@ -652,16 +652,16 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If deflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. + Similarly, if dictLength is Z_NULL, then it is not set. deflateGetDictionary() may return a length less than the window size, even when more than the window size in input has been provided. It may return up @@ -674,8 +674,8 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, stream state is inconsistent. */ -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. @@ -692,31 +692,32 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream will leave the compression level and any other attributes that may have been - set unchanged. + set unchanged. total_in, total_out, adler, and msg are initialized. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, + int level, + int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the - strategy is changed, and if any input has been consumed in a previous - deflate() call, then the input available so far is compressed with the old - level and strategy using deflate(strm, Z_BLOCK). There are three approaches - for the compression levels 0, 1..3, and 4..9 respectively. The new level - and strategy will take effect at the next call of deflate(). + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1..3, and 4..9 + respectively. The new level and strategy will take effect at the next call + of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not @@ -729,7 +730,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, Then no more input data should be provided before the deflateParams() call. If this is done, the old level and strategy will be applied to the data compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). + applied to the data compressed after deflateParams(). deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if @@ -740,11 +741,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, retried with more output space. */ -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for @@ -757,8 +758,8 @@ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, + uLong sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or @@ -772,9 +773,9 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, than Z_FINISH or Z_NO_FLUSH are used. */ -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, + unsigned *pending, + int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not @@ -787,9 +788,9 @@ ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, + int bits, + int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits @@ -804,8 +805,8 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, source stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, + gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called @@ -821,16 +822,17 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). + the time set to zero, and os set to the current operating system, with no + extra, name, or comment fields. The gzip header is returned to the default + state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, + int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized @@ -865,9 +867,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see - below), inflate() will not automatically decode concatenated gzip streams. - inflate() will return Z_STREAM_END at the end of the gzip stream. The state - would need to be reset to continue decoding a subsequent gzip stream. + below), inflate() will *not* automatically decode concatenated gzip members. + inflate() will return Z_STREAM_END at the end of the gzip member. The state + would need to be reset to continue decoding a subsequent gzip member. This + *must* be done if there is more data after a gzip member, in order for the + decompression to be compliant with the gzip standard (RFC 1952). inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the @@ -881,9 +885,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, deferred until inflate() is called. */ -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, @@ -904,22 +908,22 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflate(). */ -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If inflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. + Similarly, if dictLength is Z_NULL, then it is not set. inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent. */ -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -932,14 +936,14 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. */ -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. @@ -954,18 +958,19 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. + total_in, total_out, adler, and msg are initialized. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, + int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted @@ -978,9 +983,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, the windowBits parameter is invalid. */ -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, + int bits, + int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the @@ -999,7 +1004,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, stream state was inconsistent. */ -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the @@ -1027,8 +1032,8 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); source stream state was inconsistent. */ -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, + gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after @@ -1068,8 +1073,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, */ /* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, + unsigned char FAR *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized @@ -1089,13 +1094,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, the version of the header file. */ -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); +typedef unsigned (*in_func)(void FAR *, + z_const unsigned char FAR * FAR *); +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than @@ -1163,7 +1168,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, cannot return Z_OK. */ -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); /* All memory allocated by inflateBackInit() is freed. @@ -1171,7 +1176,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); state was inconsistent. */ -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: @@ -1224,8 +1229,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); you need special options. */ -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1239,9 +1244,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, buffer. */ -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte @@ -1255,15 +1260,15 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, Z_STREAM_ERROR if the level parameter is invalid. */ -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size @@ -1280,8 +1285,8 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, buffer with the uncompressed data up to that point. */ -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of @@ -1300,16 +1305,16 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) 'T' will - request transparent writing or appending with no compression and not using - the gzip format. + Open the gzip (.gz) file at path for reading and decompressing, or + compressing and writing. The mode parameter is as in fopen ("rb" or "wb") + but can also include a compression level ("wb9") or a strategy: 'f' for + filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", + 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression + as in "wb9F". (See the description of deflateInit2 for more information + about the strategy parameter.) 'T' will request transparent writing or + appending with no compression and not using the gzip format. "a" can be used instead of "w" to request that the gzip stream that will be written be appended to the file. "+" will result in an error, since @@ -1337,11 +1342,11 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); file could not be opened. */ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); /* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. + Associate a gzFile with the file descriptor fd. File descriptors are + obtained from calls like open, dup, creat, pipe or fileno (if the file has + been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor @@ -1360,15 +1365,15 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); will not detect if fd is invalid (unless fd is -1). */ -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); /* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Three times that size in buffer space is allocated. A larger buffer - size of, for example, 64K or 128K bytes will noticeably increase the speed - of decompression (reading). + Set the internal buffer size used by this library's functions for file to + size. The default buffer size is 8192 bytes. This function must be called + after gzopen() or gzdopen(), and before any other calls that read or write + the file. The buffer memory allocation is always deferred to the first read + or write. Three times that size in buffer space is allocated. A larger + buffer size of, for example, 64K or 128K bytes will noticeably increase the + speed of decompression (reading). The new buffer size also affects the maximum length for gzprintf(). @@ -1376,20 +1381,20 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); too late. */ -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); /* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. Previously provided - data is flushed before the parameter change. + Dynamically update the compression level and strategy for file. See the + description of deflateInit2 for the meaning of these parameters. Previously + provided data is flushed before applying the parameter changes. gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not opened for writing, Z_ERRNO if there is an error writing the flushed data, or Z_MEM_ERROR if there is a memory allocation error. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); /* - Reads the given number of uncompressed bytes from the compressed file. If + Read and decompress up to len uncompressed bytes from file into buf. If the input file is not in gzip format, gzread copies the given number of bytes into the buffer directly from the file. @@ -1417,14 +1422,14 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); Z_STREAM_ERROR. */ -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file); /* - Read up to nitems items of size size from file to buf, otherwise operating - as gzread() does. This duplicates the interface of stdio's fread(), with - size_t request and return types. If the library defines size_t, then - z_size_t is identical to size_t. If not, then z_size_t is an unsigned - integer type that can contain a pointer. + Read and decompress up to nitems items of size size from file into buf, + otherwise operating as gzread() does. This duplicates the interface of + stdio's fread(), with size_t request and return types. If the library + defines size_t, then z_size_t is identical to size_t. If not, then z_size_t + is an unsigned integer type that can contain a pointer. gzfread() returns the number of full items read of size size, or zero if the end of the file was reached and a full item could not be read, or if @@ -1435,26 +1440,24 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, In the event that the end of file is reached and only a partial item is available at the end, i.e. the remaining uncompressed data length is not a - multiple of size, then the final partial item is nevetheless read into buf + multiple of size, then the final partial item is nevertheless read into buf and the end-of-file flag is set. The length of the partial item read is not provided, but could be inferred from the result of gztell(). This behavior is the same as the behavior of fread() implementations in common libraries, but it prevents the direct use of gzfread() to read a concurrently written - file, reseting and retrying on end-of-file, when size is not 1. + file, resetting and retrying on end-of-file, when size is not 1. */ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); /* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. + Compress and write the len uncompressed bytes at buf to file. gzwrite + returns the number of uncompressed bytes written or 0 in case of error. */ -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, + z_size_t nitems, gzFile file); /* - gzfwrite() writes nitems items of size size from buf to file, duplicating + Compress and write nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. If the library defines size_t, then z_size_t is identical to size_t. If not, then z_size_t is an unsigned integer type that can contain a pointer. @@ -1465,61 +1468,62 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, is returned, and the error state is set to Z_STREAM_ERROR. */ -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); /* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of + Convert, format, compress, and write the arguments (...) to file under + control of the string format, as in fprintf. gzprintf returns the number of uncompressed bytes actually written, or a negative zlib error code in case of error. The number of uncompressed bytes written is limited to 8191, or one less than the buffer size given to gzbuffer(). The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() + zlib was compiled with the insecure functions sprintf() or vsprintf(), because the secure snprintf() or vsnprintf() functions were not available. This can be determined using zlibCompileFlags(). */ -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); /* - Writes the given null-terminated string to the compressed file, excluding + Compress and write the given null-terminated string s to file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); /* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. + Read and decompress bytes from file into buf, until len-1 characters are + read, or until a newline character is read and transferred to buf, or an + end-of-file condition is encountered. If any characters are read or if len + is one, the string is terminated with a null character. If no characters + are read due to an end-of-file or len is less than one, then the buffer is + left untouched. gzgets returns buf which is a null-terminated string, or it returns NULL for end-of-file or in case of error. If there was an error, the contents at buf are indeterminate. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); /* - Writes c, converted to an unsigned char, into the compressed file. gzputc + Compress and write c, converted to an unsigned char, into file. gzputc returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +ZEXTERN int ZEXPORT gzgetc(gzFile file); /* - Reads one byte from the compressed file. gzgetc returns this byte or -1 + Read and decompress one byte from file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. As such, it does not do all of the checking the other functions do. I.e. it does not check to see if file is NULL, nor whether the structure file points to has been clobbered or not. */ -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); /* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. + Push c back onto the stream for file to be read as the first character on + the next read. At least one character of push-back is always allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if c is -1, and may fail if a character has been pushed but not read yet. If gzungetc is used immediately after gzopen or gzdopen, at least the @@ -1528,11 +1532,11 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); gzseek() or gzrewind(). */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); /* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. + Flush all pending output to file. The parameter flush is as in the + deflate() function. The return value is the zlib error number (see function + gzerror below). gzflush is only permitted when writing. If the flush parameter is Z_FINISH, the remaining data is written and the gzip stream is completed in the output. If gzwrite() is called again, a new @@ -1544,11 +1548,11 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); */ /* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, + z_off_t offset, int whence); - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the + Set the starting position to offset relative to whence for the next gzread + or gzwrite on file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. @@ -1563,52 +1567,52 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, would be before the current position. */ -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +ZEXTERN int ZEXPORT gzrewind(gzFile file); /* - Rewinds the given file. This function is supported only for reading. + Rewind file. This function is supported only for reading. - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). */ /* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). + Return the starting position for the next gzread or gzwrite on file. + This position represents a number of bytes in the uncompressed data stream, + and is zero when starting, even if appending or reading a gzip stream from + the middle of a file using gzdopen(). gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ /* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. + Return the current compressed (actual) read or write offset of file. This + offset includes the count of bytes that precede the gzip stream, for example + when appending or when using gzdopen() for reading. When reading, the + offset does not include as yet unused buffered input. This information can + be used for a progress indicator. On error, gzoffset() returns -1. */ -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +ZEXTERN int ZEXPORT gzeof(gzFile file); /* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. + Return true (1) if the end-of-file indicator for file has been set while + reading, false (0) otherwise. Note that the end-of-file indicator is set + only if the read tried to go past the end of the input, but came up short. + Therefore, just like feof(), gzeof() may return false even if there is no + more data to read, in the event that the last read request was for the exact + number of bytes remaining in the input file. This will happen if the input + file size is an exact multiple of the buffer size. If gzeof() returns true, then the read functions will return no more data, unless the end-of-file indicator is reset by gzclearerr() and the input file has grown since the previous end of file was detected. */ -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +ZEXTERN int ZEXPORT gzdirect(gzFile file); /* - Returns true (1) if file is being copied directly while reading, or false + Return true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. If the input file is empty, gzdirect() will return true, since the input @@ -1627,10 +1631,10 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); gzip file reading and decompression, which may not be desired.) */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose(gzFile file); /* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you + Flush all pending output for file, if necessary, close file and + deallocate the (de)compression state. Note that once file is closed, you cannot call gzerror with file, since its structures have been deallocated. gzclose must not be called more than once on the same file, just as free must not be called more than once on the same allocation. @@ -1640,8 +1644,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); last read ended in the middle of a gzip stream, or Z_OK on success. */ -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to @@ -1652,12 +1656,12 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); zlib library. */ -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); /* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. + Return the error message for the last error which occurred on file. + errnum is set to zlib error number. If an error occurred in the file system + and not in the compression library, errnum is set to Z_ERRNO and the + application may consult errno to get the exact error code. The application must not modify the returned string. Future calls to this function may invalidate the previously returned string. If file is @@ -1668,9 +1672,9 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); functions above that do not distinguish those cases in their return values. */ -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +ZEXTERN void ZEXPORT gzclearerr(gzFile file); /* - Clears the error and end-of-file flags for file. This is analogous to the + Clear the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ @@ -1685,11 +1689,12 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. + return the updated checksum. An Adler-32 value is in the range of a 32-bit + unsigned integer. If buf is Z_NULL, this function returns the required + initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster. @@ -1704,15 +1709,15 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, + z_size_t len); /* Same as adler32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, + z_off_t len2); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for @@ -1722,12 +1727,13 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, negative, the result has no meaning or utility. */ -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. + updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. + If buf is Z_NULL, this function returns the required initial value for the + crc. Pre- and post-conditioning (one's complement) is performed within this + function so it shouldn't be done by the application. Usage example: @@ -1739,20 +1745,34 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); if (crc != original_crc) error(); */ -ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, + z_size_t len); /* Same as crc32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. + len2. len2 must be non-negative. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); + + Return the operator corresponding to length len2, to be used with + crc32_combine_op(). len2 must be non-negative. +*/ + +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); +/* + Give the same result as crc32_combine(), using op in place of len2. op is + is generated from len2 by crc32_combine_gen(). This will be faster than + crc32_combine() if the generated op is used more than once. */ @@ -1761,20 +1781,20 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, + const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size); #ifdef Z_PREFIX_SET # define z_deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) @@ -1819,7 +1839,7 @@ struct gzFile_s { unsigned char *next; z_off64_t pos; }; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ #ifdef Z_PREFIX_SET # undef z_gzgetc # define z_gzgetc(g) \ @@ -1836,12 +1856,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ * without large file support, _LFS64_LARGEFILE must also be true */ #ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) @@ -1852,6 +1873,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ # define z_gzoffset z_gzoffset64 # define z_adler32_combine z_adler32_combine64 # define z_crc32_combine z_crc32_combine64 +# define z_crc32_combine_gen z_crc32_combine_gen64 # else # define gzopen gzopen64 # define gzseek gzseek64 @@ -1859,49 +1881,53 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ # define gzoffset gzoffset64 # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 +# define crc32_combine_gen crc32_combine_gen64 # endif # ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); # endif #else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif #else /* Z_SOLO */ - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif /* !Z_SOLO */ /* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, + const char *mode); #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, + const char *format, + va_list va); # endif #endif diff --git a/libz/zlib1.rc b/libz/zlib1.rc index 96a889b0..c2c1f1a9 100644 --- a/libz/zlib1.rc +++ b/libz/zlib1.rc @@ -26,7 +26,7 @@ BEGIN VALUE "FileDescription", "zlib data compression library\0" VALUE "FileVersion", ZLIB_VERSION "\0" VALUE "InternalName", "zlib1.dll\0" - VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" VALUE "OriginalFilename", "zlib1.dll\0" VALUE "ProductName", "zlib\0" VALUE "ProductVersion", ZLIB_VERSION "\0" diff --git a/libz/zutil.c b/libz/zutil.c index a76c6b0c..b1c5d2d3 100644 --- a/libz/zutil.c +++ b/libz/zutil.c @@ -24,13 +24,11 @@ z_const char * const z_errmsg[10] = { }; -const char * ZEXPORT zlibVersion() -{ +const char * ZEXPORT zlibVersion(void) { return ZLIB_VERSION; } -uLong ZEXPORT zlibCompileFlags() -{ +uLong ZEXPORT zlibCompileFlags(void) { uLong flags; flags = 0; @@ -61,9 +59,11 @@ uLong ZEXPORT zlibCompileFlags() #ifdef ZLIB_DEBUG flags += 1 << 8; #endif + /* #if defined(ASMV) || defined(ASMINF) flags += 1 << 9; #endif + */ #ifdef ZLIB_WINAPI flags += 1 << 10; #endif @@ -119,9 +119,7 @@ uLong ZEXPORT zlibCompileFlags() # endif int ZLIB_INTERNAL z_verbose = verbose; -void ZLIB_INTERNAL z_error (m) - char *m; -{ +void ZLIB_INTERNAL z_error(char *m) { fprintf(stderr, "%s\n", m); exit(1); } @@ -130,14 +128,12 @@ void ZLIB_INTERNAL z_error (m) /* exported to allow conversion of error code to string for compress() and * uncompress() */ -const char * ZEXPORT zError(err) - int err; -{ +const char * ZEXPORT zError(int err) { return ERR_MSG(err); } -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have +#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 + /* The older Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. */ @@ -146,22 +142,14 @@ const char * ZEXPORT zError(err) #ifndef HAVE_MEMCPY -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ +void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ +int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { uInt j; for (j = 0; j < len; j++) { @@ -170,10 +158,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len) return 0; } -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ +void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ @@ -214,8 +199,7 @@ local ptr_table table[MAX_PTR]; * a protected system like OS/2. Use Microsoft C instead. */ -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { voidpf buf; ulg bsize = (ulg)items*size; @@ -240,8 +224,7 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) return buf; } -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { int n; (void)opaque; @@ -277,14 +260,12 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) # define _hfree hfree #endif -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { (void)opaque; return _halloc((long)items, size); } -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; _hfree(ptr); } @@ -297,25 +278,18 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); +extern voidp malloc(uInt size); +extern voidp calloc(uInt items, uInt size); +extern void free(voidpf ptr); #endif -voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } -void ZLIB_INTERNAL zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; free(ptr); } diff --git a/libz/zutil.h b/libz/zutil.h index b079ea6a..48dd7feb 100644 --- a/libz/zutil.h +++ b/libz/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -29,10 +29,6 @@ # include #endif -#ifdef Z_SOLO - typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ -#endif - #ifndef local # define local static #endif @@ -46,10 +42,21 @@ typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; +#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC) +# include +# if (ULONG_MAX == 0xffffffffffffffff) +# define Z_U8 unsigned long +# elif (ULLONG_MAX == 0xffffffffffffffff) +# define Z_U8 unsigned long long +# elif (UINT_MAX == 0xffffffffffffffff) +# define Z_U8 unsigned +# endif +#endif + extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) @@ -130,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#if defined(MACOS) || defined(TARGET_OS_MAC) +#if defined(MACOS) # define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif #endif #ifdef __acorn @@ -163,22 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define OS_CODE 19 #endif -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 @@ -188,8 +170,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); #endif /* common defaults */ @@ -228,16 +211,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); + void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); + int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); + void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); #endif /* Diagnostic functions */ #ifdef ZLIB_DEBUG # include extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); + extern void ZLIB_INTERNAL z_error(char *m); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} @@ -254,9 +237,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif #ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, + unsigned size); + void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); #endif #define ZALLOC(strm, items, size) \ diff --git a/lua/lua.c b/lua/lua.c index f0f78a98..5d7471f6 100644 --- a/lua/lua.c +++ b/lua/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.230.1.1 2017/04/19 17:29:57 roberto Exp $ +** $Id: lua.c $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -9,31 +9,22 @@ #include "lprefix.h" -#include #include #include #include +#include + #include "lua.h" #include "lauxlib.h" #include "lualib.h" - -#if !defined(LUA_PROMPT) -#define LUA_PROMPT "> " -#define LUA_PROMPT2 ">> " -#endif - #if !defined(LUA_PROGNAME) #define LUA_PROGNAME "lua" #endif -#if !defined(LUA_MAXINPUT) -#define LUA_MAXINPUT 512 -#endif - #if !defined(LUA_INIT_VAR) #define LUA_INIT_VAR "LUA_INIT" #endif @@ -41,68 +32,29 @@ #define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX -/* -** lua_stdin_is_tty detects whether the standard input is a 'tty' (that -** is, whether we're running lua interactively). -*/ -#if !defined(lua_stdin_is_tty) /* { */ - -#if defined(LUA_USE_POSIX) /* { */ - -#include -#define lua_stdin_is_tty() isatty(0) - -#elif defined(LUA_USE_WINDOWS) /* }{ */ - -#include -#include - -#define lua_stdin_is_tty() _isatty(_fileno(stdin)) - -#else /* }{ */ - -/* ISO C definition */ -#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +static lua_State *globalL = NULL; -#endif /* } */ +static const char *progname = LUA_PROGNAME; -#endif /* } */ +#if defined(LUA_USE_POSIX) /* { */ /* -** lua_readline defines how to show a prompt and then read a line from -** the standard input. -** lua_saveline defines how to "save" a read line in a "history". -** lua_freeline defines how to free a line read by lua_readline. +** Use 'sigaction' when available. */ -#if !defined(lua_readline) /* { */ - -#if defined(LUA_USE_READLINE) /* { */ - -#include -#include -#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) -#define lua_saveline(L,line) ((void)L, add_history(line)) -#define lua_freeline(L,b) ((void)L, free(b)) - -#else /* }{ */ - -#define lua_readline(L,b,p) \ - ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ - fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ -#define lua_saveline(L,line) { (void)L; (void)line; } -#define lua_freeline(L,b) { (void)L; (void)b; } - -#endif /* } */ - -#endif /* } */ +static void setsignal (int sig, void (*handler)(int)) { + struct sigaction sa; + sa.sa_handler = handler; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); /* do not mask any signal */ + sigaction(sig, &sa, NULL); +} +#else /* }{ */ +#define setsignal signal - -static lua_State *globalL = NULL; - -static const char *progname = LUA_PROGNAME; +#endif /* } */ /* @@ -122,8 +74,9 @@ static void lstop (lua_State *L, lua_Debug *ar) { ** interpreter. */ static void laction (int i) { - signal(i, SIG_DFL); /* if another SIGINT happens, terminate process */ - lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); + int flag = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT; + setsignal(i, SIG_DFL); /* if another SIGINT happens, terminate process */ + lua_sethook(globalL, lstop, flag, 1); } @@ -136,13 +89,15 @@ static void print_usage (const char *badoption) { lua_writestringerror( "usage: %s [options] [script [args]]\n" "Available options are:\n" - " -e stat execute string 'stat'\n" - " -i enter interactive mode after executing 'script'\n" - " -l name require library 'name' into global 'name'\n" - " -v show version information\n" - " -E ignore environment variables\n" - " -- stop handling options\n" - " - stop handling options and execute stdin\n" + " -e stat execute string 'stat'\n" + " -i enter interactive mode after executing 'script'\n" + " -l mod require library 'mod' into global 'mod'\n" + " -l g=mod require library 'mod' into global 'g'\n" + " -v show version information\n" + " -E ignore environment variables\n" + " -W turn warnings on\n" + " -- stop handling options\n" + " - stop handling options and execute stdin\n" , progname); } @@ -160,12 +115,13 @@ static void l_message (const char *pname, const char *msg) { /* ** Check whether 'status' is not OK and, if so, prints the error -** message on the top of the stack. It assumes that the error object -** is a string, as it was either generated by Lua or by 'msghandler'. +** message on the top of the stack. */ static int report (lua_State *L, int status) { if (status != LUA_OK) { const char *msg = lua_tostring(L, -1); + if (msg == NULL) + msg = "(error message not a string)"; l_message(progname, msg); lua_pop(L, 1); /* remove message */ } @@ -201,9 +157,9 @@ static int docall (lua_State *L, int narg, int nres) { lua_pushcfunction(L, msghandler); /* push message handler */ lua_insert(L, base); /* put it under function and args */ globalL = L; /* to be available to 'laction' */ - signal(SIGINT, laction); /* set C-signal handler */ + setsignal(SIGINT, laction); /* set C-signal handler */ status = lua_pcall(L, narg, nres, base); - signal(SIGINT, SIG_DFL); /* reset C-signal handler */ + setsignal(SIGINT, SIG_DFL); /* reset C-signal handler */ lua_remove(L, base); /* remove message handler from the stack */ return status; } @@ -222,10 +178,11 @@ static void print_version (void) { ** to the script (everything after 'script') go to positive indices; ** other arguments (before the script name) go to negative indices. ** If there is no script name, assume interpreter's name as base. +** (If there is no interpreter's name either, 'script' is -1, so +** table sizes are zero.) */ static void createargtable (lua_State *L, char **argv, int argc, int script) { int i, narg; - if (script == argc) script = 0; /* no script name? */ narg = argc - (script + 1); /* number of positive indices */ lua_createtable(L, narg, script + 1); for (i = 0; i < argc; i++) { @@ -253,29 +210,282 @@ static int dostring (lua_State *L, const char *s, const char *name) { /* -** Calls 'require(name)' and stores the result in a global variable -** with the given name. +** Receives 'globname[=modname]' and runs 'globname = require(modname)'. +** If there is no explicit modname and globname contains a '-', cut +** the suffix after '-' (the "version") to make the global name. */ -static int dolibrary (lua_State *L, const char *name) { +static int dolibrary (lua_State *L, char *globname) { int status; + char *suffix = NULL; + char *modname = strchr(globname, '='); + if (modname == NULL) { /* no explicit name? */ + modname = globname; /* module name is equal to global name */ + suffix = strchr(modname, *LUA_IGMARK); /* look for a suffix mark */ + } + else { + *modname = '\0'; /* global name ends here */ + modname++; /* module name starts after the '=' */ + } lua_getglobal(L, "require"); - lua_pushstring(L, name); - status = docall(L, 1, 1); /* call 'require(name)' */ - if (status == LUA_OK) - lua_setglobal(L, name); /* global[name] = require return */ + lua_pushstring(L, modname); + status = docall(L, 1, 1); /* call 'require(modname)' */ + if (status == LUA_OK) { + if (suffix != NULL) /* is there a suffix mark? */ + *suffix = '\0'; /* remove suffix from global name */ + lua_setglobal(L, globname); /* globname = require(modname) */ + } return report(L, status); } /* -** Returns the string to be used as a prompt by the interpreter. +** Push on the stack the contents of table 'arg' from 1 to #arg +*/ +static int pushargs (lua_State *L) { + int i, n; + if (lua_getglobal(L, "arg") != LUA_TTABLE) + luaL_error(L, "'arg' is not a table"); + n = (int)luaL_len(L, -1); + luaL_checkstack(L, n + 3, "too many arguments to script"); + for (i = 1; i <= n; i++) + lua_rawgeti(L, -i, i); + lua_remove(L, -i); /* remove table from the stack */ + return n; +} + + +static int handle_script (lua_State *L, char **argv) { + int status; + const char *fname = argv[0]; + if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0) + fname = NULL; /* stdin */ + status = luaL_loadfile(L, fname); + if (status == LUA_OK) { + int n = pushargs(L); /* push arguments to script */ + status = docall(L, n, LUA_MULTRET); + } + return report(L, status); +} + + +/* bits of various argument indicators in 'args' */ +#define has_error 1 /* bad option */ +#define has_i 2 /* -i */ +#define has_v 4 /* -v */ +#define has_e 8 /* -e */ +#define has_E 16 /* -E */ + + +/* +** Traverses all arguments from 'argv', returning a mask with those +** needed before running any Lua code or an error code if it finds any +** invalid argument. In case of error, 'first' is the index of the bad +** argument. Otherwise, 'first' is -1 if there is no program name, +** 0 if there is no script name, or the index of the script name. +*/ +static int collectargs (char **argv, int *first) { + int args = 0; + int i; + if (argv[0] != NULL) { /* is there a program name? */ + if (argv[0][0]) /* not empty? */ + progname = argv[0]; /* save it */ + } + else { /* no program name */ + *first = -1; + return 0; + } + for (i = 1; argv[i] != NULL; i++) { /* handle arguments */ + *first = i; + if (argv[i][0] != '-') /* not an option? */ + return args; /* stop handling options */ + switch (argv[i][1]) { /* else check option */ + case '-': /* '--' */ + if (argv[i][2] != '\0') /* extra characters after '--'? */ + return has_error; /* invalid option */ + *first = i + 1; + return args; + case '\0': /* '-' */ + return args; /* script "name" is '-' */ + case 'E': + if (argv[i][2] != '\0') /* extra characters? */ + return has_error; /* invalid option */ + args |= has_E; + break; + case 'W': + if (argv[i][2] != '\0') /* extra characters? */ + return has_error; /* invalid option */ + break; + case 'i': + args |= has_i; /* (-i implies -v) *//* FALLTHROUGH */ + case 'v': + if (argv[i][2] != '\0') /* extra characters? */ + return has_error; /* invalid option */ + args |= has_v; + break; + case 'e': + args |= has_e; /* FALLTHROUGH */ + case 'l': /* both options need an argument */ + if (argv[i][2] == '\0') { /* no concatenated argument? */ + i++; /* try next 'argv' */ + if (argv[i] == NULL || argv[i][0] == '-') + return has_error; /* no next argument or it is another option */ + } + break; + default: /* invalid option */ + return has_error; + } + } + *first = 0; /* no script name */ + return args; +} + + +/* +** Processes options 'e' and 'l', which involve running Lua code, and +** 'W', which also affects the state. +** Returns 0 if some code raises an error. +*/ +static int runargs (lua_State *L, char **argv, int n) { + int i; + for (i = 1; i < n; i++) { + int option = argv[i][1]; + lua_assert(argv[i][0] == '-'); /* already checked */ + switch (option) { + case 'e': case 'l': { + int status; + char *extra = argv[i] + 2; /* both options need an argument */ + if (*extra == '\0') extra = argv[++i]; + lua_assert(extra != NULL); + status = (option == 'e') + ? dostring(L, extra, "=(command line)") + : dolibrary(L, extra); + if (status != LUA_OK) return 0; + break; + } + case 'W': + lua_warning(L, "@on", 0); /* warnings on */ + break; + } + } + return 1; +} + + +static int handle_luainit (lua_State *L) { +#ifdef U8W_H + int d; +#endif + const char *name = "=" LUA_INITVARVERSION; + const char *init = getenv(name + 1); + if (init == NULL) { + name = "=" LUA_INIT_VAR; + init = getenv(name + 1); /* try alternative name */ + } + if (init == NULL) return LUA_OK; +#ifdef U8W_H + else if (init[0] == '@') + d = dofile(L, init+1); + else + d = dostring(L, init, name); + free((void *)init); + return d; +#else + else if (init[0] == '@') + return dofile(L, init+1); + else + return dostring(L, init, name); +#endif +} + + +/* +** {================================================================== +** Read-Eval-Print Loop (REPL) +** =================================================================== +*/ + +#if !defined(LUA_PROMPT) +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " +#endif + +#if !defined(LUA_MAXINPUT) +#define LUA_MAXINPUT 512 +#endif + + +/* +** lua_stdin_is_tty detects whether the standard input is a 'tty' (that +** is, whether we're running lua interactively). +*/ +#if !defined(lua_stdin_is_tty) /* { */ + +#if defined(LUA_USE_POSIX) /* { */ + +#include +#define lua_stdin_is_tty() isatty(0) + +#elif defined(LUA_USE_WINDOWS) /* }{ */ + +#include +#include + +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) + +#else /* }{ */ + +/* ISO C definition */ +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ + +#endif /* } */ + +#endif /* } */ + + +/* +** lua_readline defines how to show a prompt and then read a line from +** the standard input. +** lua_saveline defines how to "save" a read line in a "history". +** lua_freeline defines how to free a line read by lua_readline. +*/ +#if !defined(lua_readline) /* { */ + +#if defined(LUA_USE_READLINE) /* { */ + +#include +#include +#define lua_initreadline(L) ((void)L, rl_readline_name="lua") +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,line) ((void)L, add_history(line)) +#define lua_freeline(L,b) ((void)L, free(b)) + +#else /* }{ */ + +#define lua_initreadline(L) ((void)L) +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,line) { (void)L; (void)line; } +#define lua_freeline(L,b) { (void)L; (void)b; } + +#endif /* } */ + +#endif /* } */ + + +/* +** Return the string to be used as a prompt by the interpreter. Leave +** the string (or nil, if using the default value) on the stack, to keep +** it anchored. */ static const char *get_prompt (lua_State *L, int firstline) { - const char *p; - lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); - p = lua_tostring(L, -1); - if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); - return p; + if (lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2") == LUA_TNIL) + return (firstline ? LUA_PROMPT : LUA_PROMPT2); /* use the default */ + else { /* apply 'tostring' over the value */ + const char *p = luaL_tolstring(L, -1, NULL); + lua_remove(L, -2); /* remove original value */ + return p; + } } /* mark in error messages for incomplete statements */ @@ -406,6 +616,7 @@ static void doREPL (lua_State *L) { int status; const char *oldprogname = progname; progname = NULL; /* no 'progname' on errors in interactive mode */ + lua_initreadline(L); while ((status = loadline(L)) != -1) { if (status == LUA_OK) status = docall(L, 0, LUA_MULTRET); @@ -417,148 +628,7 @@ static void doREPL (lua_State *L) { progname = oldprogname; } - -/* -** Push on the stack the contents of table 'arg' from 1 to #arg -*/ -static int pushargs (lua_State *L) { - int i, n; - if (lua_getglobal(L, "arg") != LUA_TTABLE) - luaL_error(L, "'arg' is not a table"); - n = (int)luaL_len(L, -1); - luaL_checkstack(L, n + 3, "too many arguments to script"); - for (i = 1; i <= n; i++) - lua_rawgeti(L, -i, i); - lua_remove(L, -i); /* remove table from the stack */ - return n; -} - - -static int handle_script (lua_State *L, char **argv) { - int status; - const char *fname = argv[0]; - if (strcmp(fname, "-") == 0 && strcmp(argv[-1], "--") != 0) - fname = NULL; /* stdin */ - status = luaL_loadfile(L, fname); - if (status == LUA_OK) { - int n = pushargs(L); /* push arguments to script */ - status = docall(L, n, LUA_MULTRET); - } - return report(L, status); -} - - - -/* bits of various argument indicators in 'args' */ -#define has_error 1 /* bad option */ -#define has_i 2 /* -i */ -#define has_v 4 /* -v */ -#define has_e 8 /* -e */ -#define has_E 16 /* -E */ - -/* -** Traverses all arguments from 'argv', returning a mask with those -** needed before running any Lua code (or an error code if it finds -** any invalid argument). 'first' returns the first not-handled argument -** (either the script name or a bad argument in case of error). -*/ -static int collectargs (char **argv, int *first) { - int args = 0; - int i; - for (i = 1; argv[i] != NULL; i++) { - *first = i; - if (argv[i][0] != '-') /* not an option? */ - return args; /* stop handling options */ - switch (argv[i][1]) { /* else check option */ - case '-': /* '--' */ - if (argv[i][2] != '\0') /* extra characters after '--'? */ - return has_error; /* invalid option */ - *first = i + 1; - return args; - case '\0': /* '-' */ - return args; /* script "name" is '-' */ - case 'E': - if (argv[i][2] != '\0') /* extra characters after 1st? */ - return has_error; /* invalid option */ - args |= has_E; - break; - case 'i': - args |= has_i; /* (-i implies -v) *//* FALLTHROUGH */ - case 'v': - if (argv[i][2] != '\0') /* extra characters after 1st? */ - return has_error; /* invalid option */ - args |= has_v; - break; - case 'e': - args |= has_e; /* FALLTHROUGH */ - case 'l': /* both options need an argument */ - if (argv[i][2] == '\0') { /* no concatenated argument? */ - i++; /* try next 'argv' */ - if (argv[i] == NULL || argv[i][0] == '-') - return has_error; /* no next argument or it is another option */ - } - break; - default: /* invalid option */ - return has_error; - } - } - *first = i; /* no script name */ - return args; -} - - -/* -** Processes options 'e' and 'l', which involve running Lua code. -** Returns 0 if some code raises an error. -*/ -static int runargs (lua_State *L, char **argv, int n) { - int i; - for (i = 1; i < n; i++) { - int option = argv[i][1]; - lua_assert(argv[i][0] == '-'); /* already checked */ - if (option == 'e' || option == 'l') { - int status; - const char *extra = argv[i] + 2; /* both options need an argument */ - if (*extra == '\0') extra = argv[++i]; - lua_assert(extra != NULL); - status = (option == 'e') - ? dostring(L, extra, "=(command line)") - : dolibrary(L, extra); - if (status != LUA_OK) return 0; - } - } - return 1; -} - - - -static int handle_luainit (lua_State *L) { -#ifdef U8W_H - int d; -#endif - const char *name = "=" LUA_INITVARVERSION; - const char *init = getenv(name + 1); - if (init == NULL) { - name = "=" LUA_INIT_VAR; - init = getenv(name + 1); /* try alternative name */ - } - if (init == NULL) return LUA_OK; -#ifdef U8W_H - else if(init[0] == '@') { - d = dofile(L, init + 1); - } - else { - d = dostring(L, init, name); - } - free((void *)init); - return d; -#else - else if (init[0] == '@') - return dofile(L, init+1); - else - return dostring(L, init, name); -#endif -} +/* }================================================================== */ /* @@ -570,8 +640,8 @@ static int pmain (lua_State *L) { char **argv = (char **)lua_touserdata(L, 2); int script; int args = collectargs(argv, &script); + int optlim = (script > 0) ? script : argc; /* first argv not an option */ luaL_checkversion(L); /* check that interpreter has correct version */ - if (argv[0] && argv[0][0]) progname = argv[0]; if (args == has_error) { /* bad arg? */ print_usage(argv[script]); /* 'script' has index of bad arg. */ return 0; @@ -584,18 +654,21 @@ static int pmain (lua_State *L) { } luaL_openlibs(L); /* open standard libraries */ createargtable(L, argv, argc, script); /* create table 'arg' */ + lua_gc(L, LUA_GCRESTART); /* start GC... */ + lua_gc(L, LUA_GCGEN, 0, 0); /* ...in generational mode */ if (!(args & has_E)) { /* no option '-E'? */ if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */ return 0; /* error running LUA_INIT */ } - if (!runargs(L, argv, script)) /* execute arguments -e and -l */ + if (!runargs(L, argv, optlim)) /* execute arguments -e and -l */ return 0; /* something failed */ - if (script < argc && /* execute main script (if there is one) */ - handle_script(L, argv + script) != LUA_OK) - return 0; + if (script > 0) { /* execute main script (if there is one) */ + if (handle_script(L, argv + script) != LUA_OK) + return 0; /* interrupt in case of error */ + } if (args & has_i) /* -i option? */ doREPL(L); /* do read-eval-print loop */ - else if (script == argc && !(args & (has_e | has_v))) { /* no arguments? */ + else if (script < 1 && !(args & (has_e | has_v))) { /* no active option? */ if (lua_stdin_is_tty()) { /* running in interactive mode? */ print_version(); doREPL(L); /* do read-eval-print loop */ @@ -608,70 +681,17 @@ static int pmain (lua_State *L) { #ifdef U8W_H -void free_u8argv(int argc, char **argv) { - int i; - for (i = 0; i < argc; i++) { - if (argv && argv[i]) free(argv[i]); - } - if (argv) free(argv); -} - -char **make_u8argv(int argc, wchar_t **wargv) { - int i; - char **argv = (char **)calloc(argc + 1, sizeof(void *)); - if (argv == NULL) { - return NULL; - } else { - for (i = 0; i < argc; i++) { - argv[i] = u8wstos(wargv[i]); - if (argv[i] == NULL) { - free_u8argv(argc, argv); - return NULL; - } - } - } - return argv; -} - -int wmain(int argc, wchar_t **wargv) { - char **argv; - int status, result; - lua_State *L; - - setlocale(LC_ALL, ""); - - argv = make_u8argv(argc, wargv); - if (argv == NULL) return EXIT_FAILURE; - - L = luaL_newstate(); /* create state */ - if (L == NULL) { - l_message(argv[0], "cannot create state: not enough memory"); - - free_u8argv(argc, argv); - - return EXIT_FAILURE; - } - - lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ - lua_pushinteger(L, argc); /* 1st argument */ - lua_pushlightuserdata(L, argv); /* 2nd argument */ - status = lua_pcall(L, 2, 1, 0); /* do the call */ - result = lua_toboolean(L, -1); /* get result */ - report(L, status); - lua_close(L); - - free_u8argv(argc, argv); - - return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; -} -#else /* U8W_H */ +int u8main (int argc, char **argv) { +#else int main (int argc, char **argv) { +#endif int status, result; lua_State *L = luaL_newstate(); /* create state */ if (L == NULL) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } + lua_gc(L, LUA_GCSTOP); /* stop GC while building state */ lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ lua_pushinteger(L, argc); /* 1st argument */ lua_pushlightuserdata(L, argv); /* 2nd argument */ @@ -681,5 +701,15 @@ int main (int argc, char **argv) { lua_close(L); return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; } -#endif /* U8W_H */ +#ifdef U8W_H +int wmain(int argc, wchar_t *wargv[]) +{ + setlocale(LC_ALL, ""); + char **argv = make_u8argv(argc, wargv); + if (argv == NULL) return EXIT_FAILURE; + int e = u8main(argc, argv); + free_u8argv(argc, argv); + return e; +} +#endif diff --git a/lua/lua.rc b/lua/lua.rc index 0800c979..bd2bb19c 100644 --- a/lua/lua.rc +++ b/lua/lua.rc @@ -2,8 +2,8 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5,3,5,0 -PRODUCTVERSION 5,3,5,0 +FILEVERSION 5,4,7,0 +PRODUCTVERSION 5,4,7,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifndef _DEBUG FILEFLAGS 0x00000000L @@ -20,12 +20,12 @@ FILESUBTYPE VFT2_UNKNOWN { VALUE "CompanyName", "Lua.org, PUC-Rio" VALUE "FileDescription", "Lua Language Executable with Wide Character Patch" - VALUE "FileVersion", "5.3.5" - VALUE "InternalName", "lua53" - VALUE "LegalCopyright", "Copyright (C) 1994-2018 Lua.org, PUC-Rio." - VALUE "OriginalFilename", "lua53.exe" + VALUE "FileVersion", "5.4.7" + VALUE "InternalName", "lua54" + VALUE "LegalCopyright", "Copyright (C) 1994-2024 Lua.org, PUC-Rio." + VALUE "OriginalFilename", "lua54.exe" VALUE "ProductName", "Lua Language" - VALUE "ProductVersion", "5.3.5" + VALUE "ProductVersion", "5.4.7" } } BLOCK "VarFileInfo" diff --git a/lua/lua.vcxproj b/lua/lua.vcxproj index 98a9ecc2..96a56545 100644 --- a/lua/lua.vcxproj +++ b/lua/lua.vcxproj @@ -1,14 +1,6 @@  - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + {34405AB3-7404-4118-870E-EE572DB3F7B1} @@ -44,122 +36,93 @@ Application true - v142 + v143 Unicode Application true - v142 - Unicode - - - Application - true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 - true - Unicode - - - Application - false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode - + - - - - + - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ @@ -169,14 +132,15 @@ WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Console true - lua53.lib;%(AdditionalDependencies) + lua54.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) @@ -194,39 +158,15 @@ WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Console true - lua53.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - - - /c 65001 - - - lua.manifest %(AdditionalManifestFiles) - - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - true - $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h - true - true - - - Console - true - lua53.lib;%(AdditionalDependencies) + lua54.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) @@ -244,14 +184,15 @@ WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true + pch.h Console true - lua53.lib;%(AdditionalDependencies) + lua54.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) @@ -271,19 +212,21 @@ WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Console true true - lua53.lib;%(AdditionalDependencies) + lua54.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration + true /c 65001 @@ -302,50 +245,21 @@ WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h - true - true - Guard - - - Console - true - true - lua53.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - No - UseLinkTimeCodeGeneration - - - /c 65001 - - - lua.manifest %(AdditionalManifestFiles) - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - true - $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Console true true - lua53.lib;%(AdditionalDependencies) + lua54.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration + true /c 65001 @@ -364,16 +278,17 @@ WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true $(SolutionDir)liblua;%(AdditionalIncludeDirectories) - stdafx.h + pch.h;%(ForcedIncludeFiles) true true Guard + pch.h Console true true - lua53.lib;%(AdditionalDependencies) + lua54.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) No UseLinkTimeCodeGeneration @@ -386,19 +301,17 @@ - + - + Create Create - Create Create Create Create - Create Create diff --git a/lua/lua.vcxproj.filters b/lua/lua.vcxproj.filters index 2088342a..129d940e 100644 --- a/lua/lua.vcxproj.filters +++ b/lua/lua.vcxproj.filters @@ -15,12 +15,12 @@ - + Header Files - + Source Files diff --git a/lua/pch.c b/lua/pch.c new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/lua/pch.c @@ -0,0 +1 @@ + diff --git a/liblua/stdafx.h b/lua/pch.h similarity index 92% rename from liblua/stdafx.h rename to lua/pch.h index 5b05a781..3c1c1b34 100644 --- a/liblua/stdafx.h +++ b/lua/pch.h @@ -1,5 +1,7 @@ #pragma once +#define WIN32_LEAN_AND_MEAN + #include "lprefix.h" #include diff --git a/lua/stdafx.c b/lua/stdafx.c deleted file mode 100644 index dc564467..00000000 --- a/lua/stdafx.c +++ /dev/null @@ -1,2 +0,0 @@ - -/* nothing */ diff --git a/test/imcrvmgr_test/cpp.hint b/test/imcrvmgr_test/cpp.hint new file mode 100644 index 00000000..8660b6f3 --- /dev/null +++ b/test/imcrvmgr_test/cpp.hint @@ -0,0 +1,5 @@ +// common.h +#define FORWARD_ITERATION_I(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ++(iterator)) +#define FORWARD_ITERATION(iterator, container) for (auto (iterator) = (container).begin(); (iterator) != (container).end(); ) +#define REVERSE_ITERATION_I(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ++(reverse_iterator)) +#define REVERSE_ITERATION(reverse_iterator, container) for (auto (reverse_iterator) = (container).rbegin(); (reverse_iterator) != (container).rend(); ) diff --git a/test/imcrvmgr_test/dictionary.cpp b/test/imcrvmgr_test/dictionary.cpp index 6aa6d257..6b56d1ea 100644 --- a/test/imcrvmgr_test/dictionary.cpp +++ b/test/imcrvmgr_test/dictionary.cpp @@ -2,10 +2,11 @@ #include "common.h" #include "parseskkdic.h" #include "eucjis2004.h" +#include "eucjp.h" #include "dictionary.h" -WCHAR krnlobjsddl[MAX_KRNLOBJNAME]; //SDDL -WCHAR mgrpipename[MAX_KRNLOBJNAME]; //名前付きパイプ +WCHAR krnlobjsddl[MAX_SECURITYDESC]; //SDDL +WCHAR mgrpipename[MAX_PIPENAME]; //名前付きパイプ HANDLE hPipe = INVALID_HANDLE_VALUE; @@ -99,8 +100,7 @@ BOOL _SearchDic(WCHAR command, CANDIDATES &candidates, const std::wstring &searc BOOL ret = FALSE; DWORD bytesWrite, bytesRead; - std::wstring s, se, fmt, scd, scr, sad, sar; - std::wregex r; + std::wstring s, se, scd, scr, sad, sar; std::wsmatch m; candidates.clear(); @@ -121,7 +121,7 @@ BOOL _SearchDic(WCHAR command, CANDIDATES &candidates, const std::wstring &searc ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } @@ -133,21 +133,18 @@ BOOL _SearchDic(WCHAR command, CANDIDATES &candidates, const std::wstring &searc } s.assign(pipebuf); - r.assign(L"(.*)\t(.*)\t(.*)\t(.*)\n"); - while (std::regex_search(s, m, r)) + static const std::wregex re(L"(.*)\t(.*)\t(.*)\t(.*)\n"); + + while (std::regex_search(s, m, re)) { se = m.str(); s = m.suffix().str(); - fmt.assign(L"$1"); - scd = std::regex_replace(se, r, fmt); - fmt.assign(L"$2"); - scr = std::regex_replace(se, r, fmt); - fmt.assign(L"$3"); - sad = std::regex_replace(se, r, fmt); - fmt.assign(L"$4"); - sar = std::regex_replace(se, r, fmt); + scd = std::regex_replace(se, re, L"$1"); + scr = std::regex_replace(se, re, L"$2"); + sad = std::regex_replace(se, re, L"$3"); + sar = std::regex_replace(se, re, L"$4"); if (scd.empty()) { @@ -194,7 +191,7 @@ BOOL _AddUserDic(WCHAR command, const std::wstring &key, const std::wstring &can ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } @@ -231,7 +228,7 @@ BOOL _DelUserDic(WCHAR command, const std::wstring &key, const std::wstring &can ZeroMemory(pipebuf, sizeof(pipebuf)); bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } @@ -251,6 +248,11 @@ BOOL _SaveUserDic() return _CommandDic(REQ_USER_SAVE); } +BOOL _BackupUserDic() +{ + return _CommandDic(REQ_BACKUP); +} + BOOL _CommandDic(WCHAR command) { BOOL ret = FALSE; @@ -270,7 +272,7 @@ BOOL _CommandDic(WCHAR command) } bytesRead = 0; - if (ReadFile(hPipe, pipebuf, sizeof(pipebuf), &bytesRead, nullptr) == FALSE) + if (ReadFile(hPipe, pipebuf, sizeof(pipebuf) - sizeof(WCHAR), &bytesRead, nullptr) == FALSE) { goto exit; } @@ -285,52 +287,74 @@ BOOL _CommandDic(WCHAR command) return ret; } -HRESULT CheckMultiByteFile(LPCWSTR path, int encoding) +HRESULT CheckMultiByteFile(LPCWSTR path, SKKDICENCODING encoding) { HRESULT hr = S_OK; - FILE *fp; - CHAR buf[READBUFSIZE * sizeof(WCHAR)]; + FILE *fp = nullptr; + CHAR buf[READBUFSIZE]; std::string strbuf; size_t len; - _wfopen_s(&fp, path, RB); + _wfopen_s(&fp, path, modeRB); if (fp == nullptr) { return E_MAKESKKDIC_FILEIO; } - while (fgets(buf, _countof(buf), fp) != nullptr) + while (true) { - strbuf += buf; + strbuf.clear(); - if (!strbuf.empty() && strbuf.back() == '\n') + while (fgets(buf, _countof(buf), fp) != nullptr) { - switch (encoding) + strbuf += buf; + + if (!strbuf.empty() && strbuf.back() == '\n') { - case 1: //EUC-JIS-2004 - if (!EucJis2004ToWideChar(strbuf.c_str(), nullptr, nullptr, &len)) - { - hr = S_FALSE; - } - break; - case 8: //UTF-8 - if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, - strbuf.c_str(), -1, nullptr, 0) == 0) - { - hr = S_FALSE; - } - break; - default: - hr = S_FALSE; break; } + } - if (hr == S_FALSE) + if (ferror(fp) != 0) + { + hr = E_MAKESKKDIC_FILEIO; + break; + } + + if (strbuf.empty()) + { + break; + } + + switch (encoding) + { + case enc_euc_jis_2004: //EUC-JIS-2004 + if (EucJis2004ToWideChar(strbuf.c_str(), nullptr, nullptr, &len) == FALSE) { - break; + hr = S_FALSE; } + break; + case enc_euc_jp: //EUC-JP + if (EucJPToWideChar(strbuf.c_str(), nullptr, nullptr, &len) == FALSE) + { + hr = S_FALSE; + } + break; + case enc_utf_8: //UTF-8 + if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, + strbuf.c_str(), -1, nullptr, 0) == 0) + { + hr = S_FALSE; + } + break; + default: + hr = S_FALSE; + break; + } - strbuf.clear(); + if (hr == S_FALSE) + { + break; } } @@ -342,30 +366,46 @@ HRESULT CheckMultiByteFile(LPCWSTR path, int encoding) HRESULT CheckWideCharFile(LPCWSTR path) { HRESULT hr = S_OK; - FILE *fp; - WCHAR wbuf[READBUFSIZE]; + FILE *fp = nullptr; + WCHAR wbuf[READBUFSIZE / sizeof(WCHAR)]; std::wstring wstrbuf; - _wfopen_s(&fp, path, RB); + _wfopen_s(&fp, path, modeRB); if (fp == nullptr) { return E_MAKESKKDIC_FILEIO; } - while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) + while (true) { - wstrbuf += wbuf; + wstrbuf.clear(); - if (!wstrbuf.empty() && wstrbuf.back() == L'\n') + while (fgetws(wbuf, _countof(wbuf), fp) != nullptr) { - if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, - wstrbuf.c_str(), -1, nullptr, 0, nullptr, nullptr) == 0) + wstrbuf += wbuf; + + if (!wstrbuf.empty() && wstrbuf.back() == L'\n') { - hr = S_FALSE; break; } + } + + if (ferror(fp) != 0) + { + hr = E_MAKESKKDIC_FILEIO; + break; + } - wstrbuf.clear(); + if (wstrbuf.empty()) + { + break; + } + + if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, + wstrbuf.c_str(), -1, nullptr, 0, nullptr, nullptr) == 0) + { + hr = S_FALSE; + break; } } diff --git a/test/imcrvmgr_test/dictionary.h b/test/imcrvmgr_test/dictionary.h index 6b240f97..50f256d5 100644 --- a/test/imcrvmgr_test/dictionary.h +++ b/test/imcrvmgr_test/dictionary.h @@ -1,5 +1,6 @@ - -#pragma once +#pragma once + +#include "parseskkdic.h" // okuri block typedef struct _OKURI_BLOCK { @@ -10,7 +11,7 @@ typedef struct _OKURI_BLOCK { #define OKURI_BLOCK_NUM 32 extern OKURI_BLOCK okuri_block[OKURI_BLOCK_NUM]; -extern WCHAR mgrpipename[MAX_KRNLOBJNAME]; //名前付きパイプ +extern WCHAR mgrpipename[MAX_PIPENAME]; //名前付きパイプ void _CreateIpcName(); BOOL _ConnectDic(); @@ -19,6 +20,7 @@ BOOL _SearchDic(WCHAR command, CANDIDATES &candidates, const std::wstring &searc BOOL _AddUserDic(WCHAR command, const std::wstring &key, const std::wstring &candidate, const std::wstring &annotation, const std::wstring &okurikey); BOOL _DelUserDic(WCHAR command, const std::wstring &key, const std::wstring &candidate); BOOL _SaveUserDic(); +BOOL _BackupUserDic(); BOOL _CommandDic(WCHAR command); #define E_MAKESKKDIC_OK MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0) @@ -28,5 +30,5 @@ BOOL _CommandDic(WCHAR command); //#define E_MAKESKKDIC_UNGZIP MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 4) //#define E_MAKESKKDIC_UNTAR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 5) -HRESULT CheckMultiByteFile(LPCWSTR path, int encoding); +HRESULT CheckMultiByteFile(LPCWSTR path, SKKDICENCODING encoding); HRESULT CheckWideCharFile(LPCWSTR path); diff --git a/test/imcrvmgr_test/imcrvmgr_test.cpp b/test/imcrvmgr_test/imcrvmgr_test.cpp index 9b2ed9ae..dc2fb11f 100644 --- a/test/imcrvmgr_test/imcrvmgr_test.cpp +++ b/test/imcrvmgr_test/imcrvmgr_test.cpp @@ -18,26 +18,26 @@ int wmain(int argc, wchar_t *argv[]) _CreateIpcName(); - FILE *fp; + FILE *fp = nullptr; - //check BOM - _wfopen_s(&fp, filename, RB); + _wfopen_s(&fp, filename, modeRB); if (fp == nullptr) { fwprintf(stderr, L"\nERROR: File I/O.\n"); return -1; } - int encoding = 0; - + //check BOM WCHAR bom = L'\0'; fread(&bom, 2, 1, fp); fclose(fp); + SKKDICENCODING encoding = enc_none; + if (bom == BOM) { //UTF-16LE - encoding = 16; + encoding = enc_utf_16; HRESULT hr = CheckWideCharFile(filename); switch (hr) @@ -50,19 +50,19 @@ int wmain(int argc, wchar_t *argv[]) break; default: //Error - encoding = -1; + encoding = enc_error; break; } } //UTF-8 ? - if (encoding == 0) + if (encoding == enc_none) { - HRESULT hr = CheckMultiByteFile(filename, 8); + HRESULT hr = CheckMultiByteFile(filename, enc_utf_8); switch (hr) { case S_OK: - encoding = 8; + encoding = enc_utf_8; break; case E_MAKESKKDIC_FILEIO: fwprintf(stderr, L"\nERROR: File I/O.\n"); @@ -74,13 +74,31 @@ int wmain(int argc, wchar_t *argv[]) } //EUC-JIS-2004 ? - if (encoding == 0) + if (encoding == enc_none) + { + HRESULT hr = CheckMultiByteFile(filename, enc_euc_jis_2004); + switch (hr) + { + case S_OK: + encoding = enc_euc_jis_2004; + break; + case E_MAKESKKDIC_FILEIO: + fwprintf(stderr, L"\nERROR: File I/O.\n"); + return -1; + break; + default: + break; + } + } + + //EUC-JP ? + if (encoding == enc_none) { - HRESULT hr = CheckMultiByteFile(filename, 1); + HRESULT hr = CheckMultiByteFile(filename, enc_euc_jp); switch (hr) { case S_OK: - encoding = 1; + encoding = enc_euc_jp; break; case E_MAKESKKDIC_FILEIO: fwprintf(stderr, L"\nERROR: File I/O.\n"); @@ -93,19 +111,19 @@ int wmain(int argc, wchar_t *argv[]) switch (encoding) { - case 1: + case enc_euc_jis_2004: //EUC-JIS-2004 - bom = L'\0'; - _wfopen_s(&fp, filename, RB); + case enc_euc_jp: + //EUC-JP + _wfopen_s(&fp, filename, modeRT); break; - case 8: + case enc_utf_8: //UTF-8 - bom = BOM; - _wfopen_s(&fp, filename, RccsUTF8); + _wfopen_s(&fp, filename, modeRccsUTF8); break; - case 16: + case enc_utf_16: //UTF-16LE - _wfopen_s(&fp, filename, RccsUTF16); + _wfopen_s(&fp, filename, modeRccsUTF16); break; default: fwprintf(stderr, L"\nERROR: invalid encoding.\n"); @@ -130,7 +148,7 @@ int wmain(int argc, wchar_t *argv[]) while (true) { - int rl = ReadSKKDicLine(fp, bom, okuri, key, sc, so); + int rl = ReadSKKDicLine(fp, encoding, okuri, key, sc, so); if (rl == -1) { //EOF @@ -376,6 +394,18 @@ int wmain(int argc, wchar_t *argv[]) goto exit; } } + + // backup user dictionary + { + wprintf(L"%c\n", REQ_BACKUP); + + BOOL ret = _BackupUserDic(); + if (ret == FALSE) + { + fwprintf(stderr, L"\nERROR: connection.\n"); + goto exit; + } + } } exkey = key; @@ -394,6 +424,18 @@ int wmain(int argc, wchar_t *argv[]) goto exit; } } + + // backup user dictionary + { + wprintf(L"%c\n", REQ_BACKUP); + + BOOL ret = _BackupUserDic(); + if (ret == FALSE) + { + fwprintf(stderr, L"\nERROR: connection.\n"); + goto exit; + } + } } exit: diff --git a/test/imcrvmgr_test/imcrvmgr_test.vcxproj b/test/imcrvmgr_test/imcrvmgr_test.vcxproj index d9eb7106..d19d31d7 100644 --- a/test/imcrvmgr_test/imcrvmgr_test.vcxproj +++ b/test/imcrvmgr_test/imcrvmgr_test.vcxproj @@ -1,14 +1,6 @@ - - Debug - ARM - - - Debug - ARM64 - Debug Win32 @@ -17,12 +9,8 @@ Debug x64 - - Release - ARM - - - Release + + Debug ARM64 @@ -33,6 +21,10 @@ Release x64 + + Release + ARM64 + 16.0 @@ -42,55 +34,42 @@ 10.0 - - Application - true - v142 - Unicode - - - Application - true - v142 - Unicode - Application true - v142 + v143 Unicode Application true - v142 + v143 Unicode - + Application - false - v142 - true + true + v143 Unicode - + Application false - v142 + v143 true Unicode - + Application false - v142 + v143 true Unicode - + Application false - v142 + v143 true Unicode @@ -99,22 +78,13 @@ - - - - - - - - - - + @@ -123,83 +93,40 @@ + + + - - true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - + true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - + true - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - - false - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - - false - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)build\$(Platform)\$(Configuration)\ + $(SolutionDir)build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - Use - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdafx.h;%(ForcedIncludeFiles) - true - $(SolutionDir)common;%(AdditionalIncludeDirectories) - - - Console - true - common.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - - - - - Use - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdafx.h;%(ForcedIncludeFiles) - true - $(SolutionDir)common;%(AdditionalIncludeDirectories) - - - Console - true - common.lib;%(AdditionalDependencies) - $(OutDir);%(AdditionalLibraryDirectories) - - Use @@ -207,9 +134,10 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdafx.h;%(ForcedIncludeFiles) + pch.h;%(ForcedIncludeFiles) true $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h Console @@ -225,9 +153,10 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdafx.h;%(ForcedIncludeFiles) + pch.h;%(ForcedIncludeFiles) true $(SolutionDir)common;%(AdditionalIncludeDirectories) + pch.h Console @@ -236,31 +165,26 @@ $(OutDir);%(AdditionalLibraryDirectories) - + Use Level3 - true - true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdafx.h;%(ForcedIncludeFiles) + pch.h;%(ForcedIncludeFiles) true $(SolutionDir)common;%(AdditionalIncludeDirectories) - Guard + pch.h Console - true - true - false - UseLinkTimeCodeGeneration + true common.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) - + Use Level3 @@ -269,10 +193,11 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdafx.h;%(ForcedIncludeFiles) + pch.h;%(ForcedIncludeFiles) true $(SolutionDir)common;%(AdditionalIncludeDirectories) Guard + pch.h Console @@ -282,21 +207,23 @@ UseLinkTimeCodeGeneration common.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) + true - + Use Level3 true true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdafx.h;%(ForcedIncludeFiles) + pch.h;%(ForcedIncludeFiles) true $(SolutionDir)common;%(AdditionalIncludeDirectories) Guard + pch.h Console @@ -306,21 +233,23 @@ UseLinkTimeCodeGeneration common.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) + true - + Use Level3 true true true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdafx.h;%(ForcedIncludeFiles) + pch.h;%(ForcedIncludeFiles) true $(SolutionDir)common;%(AdditionalIncludeDirectories) Guard + pch.h Console @@ -335,20 +264,21 @@ - - Create - Create + Create Create - Create - Create + Create Create Create + Create - + + + + diff --git a/test/imcrvmgr_test/imcrvmgr_test.vcxproj.filters b/test/imcrvmgr_test/imcrvmgr_test.vcxproj.filters index be21a1ac..00d81dc0 100644 --- a/test/imcrvmgr_test/imcrvmgr_test.vcxproj.filters +++ b/test/imcrvmgr_test/imcrvmgr_test.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files @@ -26,11 +26,14 @@ - + Header Files Header Files + + + \ No newline at end of file diff --git a/test/imcrvmgr_test/pch.cpp b/test/imcrvmgr_test/pch.cpp new file mode 100644 index 00000000..af0744ae --- /dev/null +++ b/test/imcrvmgr_test/pch.cpp @@ -0,0 +1 @@ + diff --git a/test/imcrvmgr_test/stdafx.h b/test/imcrvmgr_test/pch.h similarity index 100% rename from test/imcrvmgr_test/stdafx.h rename to test/imcrvmgr_test/pch.h diff --git a/test/imcrvmgr_test/stdafx.cpp b/test/imcrvmgr_test/stdafx.cpp deleted file mode 100644 index 7438ada7..00000000 --- a/test/imcrvmgr_test/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -// nothing