mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
fix to support synonyms within specials too -- for linux only so far.
Seems to work, though the dawg2dict.pl script is broken.
This commit is contained in:
parent
3a628f4375
commit
07cfdad699
7 changed files with 76 additions and 49 deletions
|
@ -83,4 +83,6 @@ typedef struct Xloc_specialEntry {
|
||||||
short hasSmall;
|
short hasSmall;
|
||||||
} Xloc_specialEntry;
|
} Xloc_specialEntry;
|
||||||
|
|
||||||
|
#define SYNONYM_DELIM ' '
|
||||||
|
|
||||||
#endif /* _DAWG_H_ */
|
#endif /* _DAWG_H_ */
|
||||||
|
|
|
@ -101,24 +101,32 @@ dict_getTileString( const DictionaryCtxt* dict, Tile tile )
|
||||||
}
|
}
|
||||||
|
|
||||||
const XP_UCHAR*
|
const XP_UCHAR*
|
||||||
dict_getNextTileString( const DictionaryCtxt* ctxt, Tile tile,
|
dict_getNextTileString( const DictionaryCtxt* dict, Tile tile,
|
||||||
const XP_UCHAR* cur )
|
const XP_UCHAR* cur )
|
||||||
{
|
{
|
||||||
const XP_UCHAR* result = NULL;
|
const XP_UCHAR* result = NULL;
|
||||||
if ( NULL == cur ) {
|
if ( NULL == cur ) {
|
||||||
result = dict_getTileString( ctxt, tile );
|
result = dict_getTileString( dict, tile );
|
||||||
} else {
|
} else {
|
||||||
cur += XP_STRLEN( cur ) + 1;
|
cur += XP_STRLEN( cur ) + 1;
|
||||||
/* use cur only if it is is not now off the end or pointing to to the
|
XP_Bool isSpecial = dict_faceIsBitmap( dict, tile );
|
||||||
next tile */
|
if ( isSpecial ) {
|
||||||
if ( ++tile == ctxt->nFaces ) {
|
const XP_UCHAR* facep = dict_getTileStringRaw( dict, tile );
|
||||||
if ( cur < ctxt->facesEnd ) {
|
if ( cur < dict->charEnds[(XP_U16)*facep] ) {
|
||||||
result = cur;
|
result = cur;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const XP_UCHAR* nxt = dict_getTileStringRaw( ctxt, tile );
|
/* use cur only if it is is not now off the end or pointing to to the
|
||||||
if ( nxt != cur ) {
|
next tile */
|
||||||
result = cur;
|
if ( ++tile == dict->nFaces ) {
|
||||||
|
if ( cur < dict->facesEnd ) {
|
||||||
|
result = cur;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const XP_UCHAR* nxt = dict_getTileStringRaw( dict, tile );
|
||||||
|
if ( nxt != cur ) {
|
||||||
|
result = cur;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct DictionaryCtxt {
|
||||||
|
|
||||||
SpecialBitmaps* bitmaps;
|
SpecialBitmaps* bitmaps;
|
||||||
XP_UCHAR** chars;
|
XP_UCHAR** chars;
|
||||||
|
XP_UCHAR** charEnds;
|
||||||
XP_U32 nWords;
|
XP_U32 nWords;
|
||||||
|
|
||||||
XP_LangCode langCode;
|
XP_LangCode langCode;
|
||||||
|
|
|
@ -36,9 +36,9 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LANG_SPECIAL_INFO = \
|
LANG_SPECIAL_INFO = \
|
||||||
"L·L" $(PBITMS)/large_ll.pbitm $(PBITMS)/small_ll.pbitm \
|
"L·L L-L ĿL l·l l-l ŀl" $(PBITMS)/large_ll.pbitm $(PBITMS)/small_ll.pbitm \
|
||||||
"NY" $(PBITMS)/large_ny.pbitm $(PBITMS)/small_ny.pbitm \
|
"NY ny" $(PBITMS)/large_ny.pbitm $(PBITMS)/small_ny.pbitm \
|
||||||
"QU" $(PBITMS)/large_qu.pbitm $(PBITMS)/small_qu.pbitm \
|
"QU qu" $(PBITMS)/large_qu.pbitm $(PBITMS)/small_qu.pbitm \
|
||||||
|
|
||||||
include ../Makefile.langcommon
|
include ../Makefile.langcommon
|
||||||
|
|
||||||
|
|
|
@ -63,32 +63,32 @@ XLOC_HEADER:0x8C00
|
||||||
|
|
||||||
<BEGIN_TILES>
|
<BEGIN_TILES>
|
||||||
2 0 {"_"}
|
2 0 {"_"}
|
||||||
12 1 'A'
|
12 1 'A|a'
|
||||||
2 3 'B'
|
2 3 'B|b'
|
||||||
3 2 'C'
|
3 2 'C|c'
|
||||||
1 10 'Ç'
|
1 10 'Ç|ç'
|
||||||
3 2 'D'
|
3 2 'D|d'
|
||||||
13 1 'E'
|
13 1 'E|e'
|
||||||
1 4 'F'
|
1 4 'F|f'
|
||||||
2 3 'G'
|
2 3 'G|g'
|
||||||
1 8 'H'
|
1 8 'H|h'
|
||||||
8 1 'I'
|
8 1 'I|i'
|
||||||
1 8 'J'
|
1 8 'J|j'
|
||||||
4 1 'L'
|
4 1 'L|l'
|
||||||
1 10 {"L·L"}
|
1 10 {"L·L|L-L|ĿL|l·l|l-l|ŀl"}
|
||||||
3 2 'M'
|
3 2 'M|m'
|
||||||
6 1 'N'
|
6 1 'N|n'
|
||||||
1 10 {"NY"}
|
1 10 {"ny|ny"}
|
||||||
5 1 'O'
|
5 1 'O|o'
|
||||||
2 3 'P'
|
2 3 'P|p'
|
||||||
1 8 {"QU"}
|
1 8 {"QU|qu"}
|
||||||
8 1 'R'
|
8 1 'R|r'
|
||||||
8 1 'S'
|
8 1 'S|s'
|
||||||
5 1 'T'
|
5 1 'T|t'
|
||||||
4 1 'U'
|
4 1 'U|u'
|
||||||
1 4 'V'
|
1 4 'V|v'
|
||||||
1 10 'X'
|
1 10 'X|x'
|
||||||
1 8 'Z'
|
1 8 'Z|z'
|
||||||
<END_TILES>
|
<END_TILES>
|
||||||
#
|
#
|
||||||
# NOTES:
|
# NOTES:
|
||||||
|
|
|
@ -146,6 +146,7 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, const XP_U8** ptrp )
|
||||||
XP_U16 nSpecials;
|
XP_U16 nSpecials;
|
||||||
XP_UCHAR* text;
|
XP_UCHAR* text;
|
||||||
XP_UCHAR** texts;
|
XP_UCHAR** texts;
|
||||||
|
XP_UCHAR** textEnds;
|
||||||
SpecialBitmaps* bitmaps;
|
SpecialBitmaps* bitmaps;
|
||||||
Tile tile;
|
Tile tile;
|
||||||
const XP_U8* ptr = *ptrp;
|
const XP_U8* ptr = *ptrp;
|
||||||
|
@ -154,6 +155,8 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, const XP_U8** ptrp )
|
||||||
|
|
||||||
texts = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool,
|
texts = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool,
|
||||||
nSpecials * sizeof(*texts) );
|
nSpecials * sizeof(*texts) );
|
||||||
|
textEnds = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool,
|
||||||
|
nSpecials * sizeof(*textEnds) );
|
||||||
bitmaps = (SpecialBitmaps*)XP_MALLOC( ctxt->super.mpool,
|
bitmaps = (SpecialBitmaps*)XP_MALLOC( ctxt->super.mpool,
|
||||||
nSpecials * sizeof(*bitmaps) );
|
nSpecials * sizeof(*bitmaps) );
|
||||||
XP_MEMSET( bitmaps, 0, nSpecials * sizeof(*bitmaps) );
|
XP_MEMSET( bitmaps, 0, nSpecials * sizeof(*bitmaps) );
|
||||||
|
@ -167,23 +170,35 @@ skipBitmaps( LinuxDictionaryCtxt* ctxt, const XP_U8** ptrp )
|
||||||
XP_ASSERT( *facep < nSpecials );
|
XP_ASSERT( *facep < nSpecials );
|
||||||
|
|
||||||
/* get the string */
|
/* get the string */
|
||||||
txtlen = *ptr++;
|
txtlen = *ptr++;
|
||||||
text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1);
|
text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1);
|
||||||
memcpy( text, ptr, txtlen );
|
memcpy( text, ptr, txtlen );
|
||||||
ptr += txtlen;
|
ptr += txtlen;
|
||||||
|
|
||||||
text[txtlen] = '\0';
|
text[txtlen] = '\0';
|
||||||
texts[(XP_U16)*facep] = text;
|
texts[(XP_U16)*facep] = text;
|
||||||
|
textEnds[(XP_U16)*facep] = text + txtlen + 1;
|
||||||
|
|
||||||
|
/* Now replace the delimiter char with \0. It must be one byte in
|
||||||
|
length and of course equal to the delimiter */
|
||||||
|
while ( '\0' != *text ) {
|
||||||
|
XP_UCHAR* cp = g_utf8_offset_to_pointer( text, 1 );
|
||||||
|
if ( 1 == (cp - text) && *text == SYNONYM_DELIM ) {
|
||||||
|
*text = '\0';
|
||||||
|
}
|
||||||
|
text = cp;
|
||||||
|
}
|
||||||
|
|
||||||
XP_DEBUGF( "skipping bitmaps for " XP_S, texts[asIndex] );
|
XP_DEBUGF( "skipping bitmaps for " XP_S, texts[asIndex] );
|
||||||
|
|
||||||
bitmaps[asIndex].largeBM = skipBitmap( ctxt, &ptr );
|
bitmaps[asIndex].largeBM = skipBitmap( ctxt, &ptr );
|
||||||
bitmaps[asIndex].smallBM = skipBitmap( ctxt, &ptr );
|
bitmaps[asIndex].smallBM = skipBitmap( ctxt, &ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptrp = ptr;
|
*ptrp = ptr;
|
||||||
|
|
||||||
ctxt->super.chars = texts;
|
ctxt->super.chars = texts;
|
||||||
|
ctxt->super.charEnds = textEnds;
|
||||||
ctxt->super.bitmaps = bitmaps;
|
ctxt->super.bitmaps = bitmaps;
|
||||||
} /* skipBitmaps */
|
} /* skipBitmaps */
|
||||||
|
|
||||||
|
@ -207,7 +222,7 @@ dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
|
||||||
XP_MEMCPY( next, bytes, len );
|
XP_MEMCPY( next, bytes, len );
|
||||||
next += len;
|
next += len;
|
||||||
bytes += len;
|
bytes += len;
|
||||||
if ( ' ' != bytes[0] ) {
|
if ( SYNONYM_DELIM != bytes[0] ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++bytes; /* skip delimiter */
|
++bytes; /* skip delimiter */
|
||||||
|
|
|
@ -1377,7 +1377,8 @@ walk_dict_test( const LaunchParams* XP_UNUSED_DBG(params),
|
||||||
XP_UCHAR bufPrev[32] = {0};
|
XP_UCHAR bufPrev[32] = {0};
|
||||||
dict_wordToString( &iter, buf, VSIZE(buf) );
|
dict_wordToString( &iter, buf, VSIZE(buf) );
|
||||||
|
|
||||||
XP_ASSERT( 0 == strncasecmp( buf, prefix, lenMatched ) );
|
/* This doesn't work with synonyms like "L-L" for "L·L" */
|
||||||
|
// XP_ASSERT( 0 == strncasecmp( buf, prefix, lenMatched ) );
|
||||||
|
|
||||||
DictPosition pos = dict_getPosition( &iter );
|
DictPosition pos = dict_getPosition( &iter );
|
||||||
XP_ASSERT( 0 == strcmp( buf, words[pos] ) );
|
XP_ASSERT( 0 == strcmp( buf, words[pos] ) );
|
||||||
|
|
Loading…
Add table
Reference in a new issue