mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
load new-format dict into linux client, display default faces
correctly, and search using alternate as well as default faces. Next: support for alternate specials.
This commit is contained in:
parent
03f175dd8f
commit
3a628f4375
5 changed files with 66 additions and 22 deletions
|
@ -206,21 +206,29 @@ findStartsWithChars( DictIter* iter, const XP_UCHAR* chars, XP_U16 charsOffset,
|
|||
} else {
|
||||
const DictionaryCtxt* dict = iter->dict;
|
||||
XP_U16 nodeSize = dict->nodeSize;
|
||||
for ( ; ; ) {
|
||||
for ( ; ; ) { /* for all the tiles */
|
||||
Tile tile = EDGETILE( dict, edge );
|
||||
const XP_UCHAR* facep = dict_getTileString( dict, tile );
|
||||
XP_U16 faceLen = XP_STRLEN( facep );
|
||||
if ( faceLen > charsLen ) {
|
||||
faceLen = charsLen;
|
||||
}
|
||||
if ( 0 == XP_STRNCMP( facep, &chars[charsOffset], faceLen ) ) {
|
||||
XP_S16 newOffset = findStartsWithChars( iter, chars,
|
||||
charsOffset + faceLen,
|
||||
dict_follow( dict, edge ),
|
||||
nTilesUsed + 1 );
|
||||
if ( result < newOffset ) {
|
||||
iter->edges[nTilesUsed] = edge;
|
||||
result = newOffset;
|
||||
const XP_UCHAR* facep = NULL;
|
||||
for ( ; ; ) { /* for each string that tile can be */
|
||||
facep = dict_getNextTileString( dict, tile, facep );
|
||||
if ( NULL == facep ) {
|
||||
break;
|
||||
}
|
||||
XP_U16 faceLen = XP_STRLEN( facep );
|
||||
if ( faceLen > charsLen ) {
|
||||
faceLen = charsLen;
|
||||
}
|
||||
if ( 0 == XP_STRNCMP( facep, &chars[charsOffset], faceLen ) ) {
|
||||
XP_S16 newOffset =
|
||||
findStartsWithChars( iter, chars,
|
||||
charsOffset + faceLen,
|
||||
dict_follow( dict, edge ),
|
||||
nTilesUsed + 1 );
|
||||
if ( result < newOffset ) {
|
||||
iter->edges[nTilesUsed] = edge;
|
||||
result = newOffset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( IS_LAST_EDGE( dict, edge ) ) {
|
||||
|
|
|
@ -100,6 +100,31 @@ dict_getTileString( const DictionaryCtxt* dict, Tile tile )
|
|||
return facep;
|
||||
}
|
||||
|
||||
const XP_UCHAR*
|
||||
dict_getNextTileString( const DictionaryCtxt* ctxt, Tile tile,
|
||||
const XP_UCHAR* cur )
|
||||
{
|
||||
const XP_UCHAR* result = NULL;
|
||||
if ( NULL == cur ) {
|
||||
result = dict_getTileString( ctxt, tile );
|
||||
} else {
|
||||
cur += XP_STRLEN( cur ) + 1;
|
||||
/* use cur only if it is is not now off the end or pointing to to the
|
||||
next tile */
|
||||
if ( ++tile == ctxt->nFaces ) {
|
||||
if ( cur < ctxt->facesEnd ) {
|
||||
result = cur;
|
||||
}
|
||||
} else {
|
||||
const XP_UCHAR* nxt = dict_getTileStringRaw( ctxt, tile );
|
||||
if ( nxt != cur ) {
|
||||
result = cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
XP_U16
|
||||
dict_numTiles( const DictionaryCtxt* dict, Tile tile )
|
||||
{
|
||||
|
|
|
@ -72,10 +72,11 @@ struct DictionaryCtxt {
|
|||
necessarily the entry point for search!! */
|
||||
XP_UCHAR* name;
|
||||
XP_UCHAR* langName;
|
||||
XP_UCHAR* faces;
|
||||
XP_UCHAR* faces; /* storage for faces */
|
||||
XP_UCHAR* facesEnd;
|
||||
XP_UCHAR* desc;
|
||||
XP_UCHAR* md5Sum;
|
||||
const XP_UCHAR** facePtrs;
|
||||
const XP_UCHAR** facePtrs; /* elems point into faces, above */
|
||||
XP_U8* countsAndValues;
|
||||
|
||||
SpecialBitmaps* bitmaps;
|
||||
|
@ -150,6 +151,8 @@ XP_U16 dict_numTileFaces( const DictionaryCtxt* ctxt );
|
|||
XP_U16 dict_tilesToString( const DictionaryCtxt* ctxt, const Tile* tiles,
|
||||
XP_U16 nTiles, XP_UCHAR* buf, XP_U16 bufSize );
|
||||
const XP_UCHAR* dict_getTileString( const DictionaryCtxt* ctxt, Tile tile );
|
||||
const XP_UCHAR* dict_getNextTileString( const DictionaryCtxt* ctxt, Tile tile,
|
||||
const XP_UCHAR* cur );
|
||||
const XP_UCHAR* dict_getName( const DictionaryCtxt* ctxt );
|
||||
const XP_UCHAR* dict_getLangName(const DictionaryCtxt* ctxt );
|
||||
|
||||
|
|
|
@ -201,11 +201,18 @@ dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
|
|||
for ( ii = 0; ii < nFaces; ++ii ) {
|
||||
ptrs[ii] = next;
|
||||
if ( isUTF8 ) {
|
||||
gchar* cp = g_utf8_offset_to_pointer( bytes, 1 );
|
||||
XP_U16 len = cp - bytes;
|
||||
XP_MEMCPY( next, bytes, len );
|
||||
next += len;
|
||||
bytes += len;
|
||||
for ( ; ; ) {
|
||||
gchar* cp = g_utf8_offset_to_pointer( bytes, 1 );
|
||||
XP_U16 len = cp - bytes;
|
||||
XP_MEMCPY( next, bytes, len );
|
||||
next += len;
|
||||
bytes += len;
|
||||
if ( ' ' != bytes[0] ) {
|
||||
break;
|
||||
}
|
||||
++bytes; /* skip delimiter */
|
||||
*next++ = '\0';
|
||||
}
|
||||
} else {
|
||||
XP_ASSERT( 0 == *bytes );
|
||||
++bytes; /* skip empty */
|
||||
|
@ -216,6 +223,7 @@ dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
|
|||
}
|
||||
XP_ASSERT( !dict->faces );
|
||||
dict->faces = faces;
|
||||
dict->facesEnd = faces + nFaces + nBytes;
|
||||
XP_ASSERT( !dict->facePtrs );
|
||||
dict->facePtrs = ptrs;
|
||||
} /* dict_splitFaces */
|
||||
|
|
|
@ -1377,7 +1377,7 @@ walk_dict_test( const LaunchParams* XP_UNUSED_DBG(params),
|
|||
XP_UCHAR bufPrev[32] = {0};
|
||||
dict_wordToString( &iter, buf, VSIZE(buf) );
|
||||
|
||||
XP_ASSERT( 0 == strncmp( buf, prefix, lenMatched ) );
|
||||
XP_ASSERT( 0 == strncasecmp( buf, prefix, lenMatched ) );
|
||||
|
||||
DictPosition pos = dict_getPosition( &iter );
|
||||
XP_ASSERT( 0 == strcmp( buf, words[pos] ) );
|
||||
|
|
Loading…
Reference in a new issue