mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
opt: refactor folding auto-generate file
This commit is contained in:
parent
07615d9d9b
commit
cae258272f
|
@ -2,14 +2,13 @@
|
|||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "folding.hh"
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "utf8.hh"
|
||||
#include "globalregex.hh"
|
||||
#include "inc_case_folding.hh"
|
||||
|
||||
namespace Folding {
|
||||
|
||||
#include "inc_case_folding.hh"
|
||||
|
||||
/// Tests if the given char is one of the Unicode combining marks. Some are
|
||||
/// caught by the diacritics folding table, but they are only handled there
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// This file was generated automatically. Do not edit directly.
|
||||
|
||||
#pragma once
|
||||
enum { foldCaseMaxOut = 3 };
|
||||
|
||||
size_t foldCase( wchar in, wchar * out )
|
||||
inline size_t foldCase( char32_t in, char32_t * out )
|
||||
{
|
||||
switch( in )
|
||||
{
|
||||
|
@ -1540,7 +1540,7 @@ size_t foldCase( wchar in, wchar * out )
|
|||
}
|
||||
}
|
||||
|
||||
wchar foldCaseSimple( wchar in )
|
||||
char32_t foldCaseSimple( char32_t in )
|
||||
{
|
||||
switch( in )
|
||||
{
|
||||
|
|
|
@ -164,8 +164,9 @@ int main()
|
|||
|
||||
fprintf( outf, "// This file was generated automatically. Do not edit directly.\n\n" );
|
||||
|
||||
fprintf( outf, "#pragma once\n\n" );
|
||||
fprintf( outf, "enum { foldCaseMaxOut = 3 };\n\n" );
|
||||
fprintf( outf, "size_t foldCase( wchar in, wchar * out )\n{\n switch( in )\n {\n" );
|
||||
fprintf( outf, "inline size_t foldCase( char32_t in, char32_t * out )\n{\n switch( in )\n {\n" );
|
||||
|
||||
for ( map< char32_t, u32string >::const_iterator i = foldTable.begin(); i != foldTable.end(); ++i ) {
|
||||
if ( i->second.size() == 1 )
|
||||
|
@ -183,7 +184,7 @@ int main()
|
|||
fprintf( outf, " default: *out = in; return 1;\n" );
|
||||
fprintf( outf, " }\n}\n\n" );
|
||||
|
||||
fprintf( outf, "wchar foldCaseSimple( wchar in )\n{\n switch( in )\n {\n" );
|
||||
fprintf( outf, "char32_t foldCaseSimple( char32_t in )\n{\n switch( in )\n {\n" );
|
||||
|
||||
for ( map< char32_t, char32_t >::const_iterator i = simpleFoldTable.begin(); i != simpleFoldTable.end(); ++i )
|
||||
fprintf( outf, " case 0x%x: return 0x%x;\n", i->first, i->second );
|
||||
|
|
Loading…
Reference in a new issue