From 42d1a48a1d5a62839e44a3734bc0dcfe5fda8f58 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 26 Oct 2011 22:25:21 -0700 Subject: [PATCH] don't include indices for prefixes that don't exist. --- xwords4/common/dictnry.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/xwords4/common/dictnry.c b/xwords4/common/dictnry.c index 3e930e9d5..febe38dcd 100644 --- a/xwords4/common/dictnry.c +++ b/xwords4/common/dictnry.c @@ -862,9 +862,7 @@ indexOne( const DictionaryCtxt* dict, XP_U16 depth, Tile* tiles, XWStreamCtxt* stream, EdgeArray* prevEdges, DictIndex* prevIndex ) { EdgeArray curEdges = { .nEdges = 0 }; - if ( !findStartsWith( dict, tiles, depth, &curEdges ) ) { - indices[(*nextIndex)++] = NO_INDEX; - } else { + if ( findStartsWith( dict, tiles, depth, &curEdges ) ) { XP_ASSERT( curEdges.nEdges == depth ); if ( ! ISACCEPTING( dict, curEdges.edges[curEdges.nEdges-1] ) ) { if ( !nextWord( dict, &curEdges ) ) { @@ -883,15 +881,14 @@ indexOne( const DictionaryCtxt* dict, XP_U16 depth, Tile* tiles, } } indices[(*nextIndex)++] = *prevIndex; + if ( NULL != stream ) { XP_UCHAR prefix[8]; (void)dict_tilesToString( dict, tiles, depth, prefix, VSIZE(prefix) ); stream_catString( stream, prefix ); + stream_catString( stream, "\n" ); } } - if ( NULL != stream ) { - stream_catString( stream, "\n" ); - } } static void @@ -906,7 +903,7 @@ doOneDepth( const DictionaryCtxt* dict, prefix[curDepth] = allTiles[ii]; if ( curDepth + 1 == maxDepth ) { indexOne( dict, maxDepth, prefix, indices, nextEntry, - stream, prevEdges, prevIndex); + stream, prevEdges, prevIndex ); } else { doOneDepth( dict, allTiles, nTiles, prefix, curDepth+1, maxDepth, indices, nextEntry, stream, prevEdges, prevIndex );