int main(int argc, char **argv) {
	// Avoid SEGV

	if ( ! g_log.init( "foo.log" )        ) {
		fprintf (stderr,"db: Log file init failed.\n" ); exit( 1 ); }
	// init our table for doing zobrist hashing
	if ( ! hashinit() ) {
		log("db: Failed to init hashtable." ); exit(1); }
	// . hashinit() calls srand() w/ a fixed number
	// . let's mix it up again
	srand ( time(NULL) );

	UCProps props = 0;
	g_ucProps.setValue(0, &props);

	// Download data from:
	//   ftp://ftp.unicode.org/Public/UNIDATA/

	loadUnidataProps("UNIDATA/DerivedNormalizationProps.txt", handleDerivedNormalizationProps);
	loadUnidataProps("UNIDATA/UnicodeData.txt", handleUnicodeData);

	decomposeHangul(); // set up algorithmic hangul decomps
 	printf("%d canonical deompositions\n", g_canonicalDecompCount);
	printf("%d code points excluded\n", g_excludeCount);

	loadUnidataProps("UNIDATA/DerivedCoreProperties.txt", handleDerivedCoreProps);
	loadUnidataProps("UNIDATA/PropList.txt", handlePropList);
	loadUnidataProps("UNIDATA/Scripts.txt", handleScripts);
	
	printf("lower case map size: %lu\n", g_ucLowerMap.getSize());
	saveUnicodeTable(&g_ucLowerMap, "ucdata/lowermap.dat");
	printf("upper case map size: %lu\n", g_ucUpperMap.getSize());
	saveUnicodeTable(&g_ucUpperMap, "ucdata/uppermap.dat");
	printf("properties size: %lu\n", g_ucProps.getSize());
	saveUnicodeTable(&g_ucProps, "ucdata/properties.dat");
	printf("scripts size: %lu\n", g_ucScripts.getSize());
	saveUnicodeTable(&g_ucScripts, "ucdata/scripts.dat");

	// JAB: we now have Kompatible and Canonical decompositions
	saveKDecompTable();

	g_mem.printMem();

	if (loadUnicodeTable(&g_ucUpperMap,"ucdata/uppermap.dat") &&
	    loadUnicodeTable(&g_ucLowerMap,"ucdata/lowermap.dat") &&
	    loadUnicodeTable(&g_ucProps,"ucdata/properties.dat") &&
	    loadUnicodeTable(&g_ucScripts,"ucdata/scripts.dat") &&
	    // JAB: we now have Kompatible and Canonical decompositions
	    loadDecompTables()){
		printf("tables reloaded successfully\n\n");

		printf("lower case map size: %lu\n", g_ucLowerMap.getSize());
		printf("upper case map size: %lu\n", g_ucUpperMap.getSize());
		printf("properties size: %lu\n", g_ucProps.getSize());
		printf("scripts size: %lu\n", g_ucScripts.getSize());
		printf("Kompat Decomp size: %lu\n", g_ucKDIndex.getSize());
		exit(0);
	}
}
예제 #2
0
static void doDecomposition( int iRecursionCheck, int fCanonical,
                             DWORD ch, DWORD * outbuf )
{
    const DWORD* pDecomposeString;
    int i,len;
    int iDecompResult;
    DWORD iCompatValue, iCompatResult;

    if (iRecursionCheck > 20)
        return;

    {

        /* Q: there will never be a compatible entry for hangul characters?
           Q: Is recursion of resulting hangul string is needed?? We recurse to be sure anyway. */

        DWORD hangubuf[5];

        if ( decomposeHangul( ch, hangubuf ) )
        {
            len = dwstrlen( hangubuf );

            for (i=0; i < len; i++)
            {
                doDecomposition(iRecursionCheck+1, fCanonical, hangubuf[i], outbuf );
            }
            return;
        }
    }

    iDecompResult = lookup_decompose( ch, &pDecomposeString );

    iCompatResult = lookup_compatible(ch);
    iCompatValue = ch;

    if (iDecompResult && !(fCanonical && iCompatResult))
    {
        len = dwstrlen( pDecomposeString );

        for (i=0; i < len; i++)
        {
            doDecomposition(iRecursionCheck+1, fCanonical, pDecomposeString[i], outbuf);
        }

    } else {
        dwstrncat(outbuf, &ch, 1);
    }

}