diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java index 46f86e6d8..ed6d6a415 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -81,9 +81,9 @@ public class DictBrowseDelegate extends DelegateBase { super(); - XwJNI.dict_iter_setMinMax( m_dictClosure, m_browseState.m_minShown, - m_browseState.m_maxShown ); - m_nWords = XwJNI.dict_iter_wordCount( m_dictClosure ); + XwJNI.di_setMinMax( m_dictClosure, m_browseState.m_minShown, + m_browseState.m_maxShown ); + m_nWords = XwJNI.di_wordCount( m_dictClosure ); int format = m_browseState.m_minShown == m_browseState.m_maxShown ? R.string.dict_browse_title1_fmt : R.string.dict_browse_title_fmt; @@ -96,7 +96,7 @@ public class DictBrowseDelegate extends DelegateBase { TextView text = (TextView) inflate( android.R.layout.simple_list_item_1 ); - String str = XwJNI.dict_iter_nthWord( m_dictClosure, position ); + String str = XwJNI.di_nthWord( m_dictClosure, position ); if ( null != str ) { text.setText( str ); text.setOnClickListener( DictBrowseDelegate.this ); @@ -138,8 +138,8 @@ public class DictBrowseDelegate extends DelegateBase public Object[] getSections() { - m_prefixes = XwJNI.dict_iter_getPrefixes( m_dictClosure ); - m_indices = XwJNI.dict_iter_getIndices( m_dictClosure ); + m_prefixes = XwJNI.di_getPrefixes( m_dictClosure ); + m_indices = XwJNI.di_getIndices( m_dictClosure ); return m_prefixes; } } @@ -166,10 +166,10 @@ public class DictBrowseDelegate extends DelegateBase String[] names = { name }; DictUtils.DictPairs pairs = DictUtils.openDicts( m_activity, names ); - m_dictClosure = XwJNI.dict_iter_init( pairs.m_bytes[0], - name, pairs.m_paths[0] ); + m_dictClosure = XwJNI.di_init( pairs.m_bytes[0], + name, pairs.m_paths[0] ); - String desc = XwJNI.dict_iter_getDesc( m_dictClosure ); + String desc = XwJNI.di_getDesc( m_dictClosure ); Log.d( TAG, "got desc: %s", desc ); if ( null != desc ) { TextView view = (TextView)findViewById( R.id.desc ); @@ -186,8 +186,7 @@ public class DictBrowseDelegate extends DelegateBase m_browseState.m_top = 0; } if ( null == m_browseState.m_counts ) { - m_browseState.m_counts = - XwJNI.dict_iter_getCounts( m_dictClosure ); + m_browseState.m_counts = XwJNI.di_getCounts( m_dictClosure ); } if ( null == m_browseState.m_counts ) { @@ -246,7 +245,7 @@ public class DictBrowseDelegate extends DelegateBase protected void onDestroy() { - XwJNI.dict_iter_destroy( m_dictClosure ); + XwJNI.di_destroy( m_dictClosure ); m_dictClosure = 0; } @@ -254,7 +253,7 @@ public class DictBrowseDelegate extends DelegateBase @Override public void finalize() { - XwJNI.dict_iter_destroy( m_dictClosure ); + XwJNI.di_destroy( m_dictClosure ); try { super.finalize(); } catch ( java.lang.Throwable err ){ @@ -348,7 +347,7 @@ public class DictBrowseDelegate extends DelegateBase { String text = m_browseState.m_prefix; if ( null != text && 0 < text.length() ) { - int pos = XwJNI.dict_iter_getStartsWith( m_dictClosure, text ); + int pos = XwJNI.di_getStartsWith( m_dictClosure, text ); if ( 0 <= pos ) { m_list.setSelection( pos ); } else { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java index 921d320db..fa3e358ef 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java @@ -514,22 +514,22 @@ public class XwJNI { // Dict iterator public final static int MAX_COLS_DICT = 15; // from dictiter.h - public static long dict_iter_init( byte[] dict, String name, - String path ) + public static long di_init( byte[] dict, String name, + String path ) { - return dict_iter_init( getJNI().m_ptrGlobals, dict, name, path ); + return di_init( getJNI().m_ptrGlobals, dict, name, path ); } - public static native void dict_iter_setMinMax( long closure, - int min, int max ); - public static native void dict_iter_destroy( long closure ); - public static native int dict_iter_wordCount( long closure ); - public static native int[] dict_iter_getCounts( long closure ); - public static native String dict_iter_nthWord( long closure, int nn ); - public static native String[] dict_iter_getPrefixes( long closure ); - public static native int[] dict_iter_getIndices( long closure ); - public static native int dict_iter_getStartsWith( long closure, - String prefix ); - public static native String dict_iter_getDesc( long closure ); + public static native void di_setMinMax( long closure, + int min, int max ); + public static native void di_destroy( long closure ); + public static native int di_wordCount( long closure ); + public static native int[] di_getCounts( long closure ); + public static native String di_nthWord( long closure, int nn ); + public static native String[] di_getPrefixes( long closure ); + public static native int[] di_getIndices( long closure ); + public static native int di_getStartsWith( long closure, + String prefix ); + public static native String di_getDesc( long closure ); // Private methods -- called only here private static native long initGlobals( DUtilCtxt dutil, JNIUtils jniu ); @@ -548,8 +548,8 @@ public class XwJNI { String name, String path, boolean check, DictInfo info ); - private static native long dict_iter_init( long jniState, byte[] dict, - String name, String path ); + private static native long di_init( long jniState, byte[] dict, + String name, String path ); private static native byte[][] smsproto_prepOutbound( long jniState, SMS_CMD cmd, int gameID, byte[] buf, diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 31abb0881..1f38b4e55 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -2413,7 +2413,7 @@ static void makeIndex( DictIterData* data ); static void freeIndices( DictIterData* data ); JNIEXPORT jlong JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1init +Java_org_eehouse_android_xw4_jni_XwJNI_di_1init ( JNIEnv* env, jclass C, jlong jniGlobalPtr, jbyteArray jDictBytes, jstring jname, jstring jpath ) { @@ -2441,19 +2441,19 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1init } JNIEXPORT void JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1setMinMax +Java_org_eehouse_android_xw4_jni_XwJNI_di_1setMinMax ( JNIEnv* env, jclass C, jlong closure, jint min, jint max ) { DictIterData* data = (DictIterData*)closure; if ( NULL != data ) { - dict_initIter( &data->iter, data->dict, min, max ); + di_initIter( &data->iter, data->dict, min, max ); makeIndex( data ); - (void)dict_firstWord( &data->iter ); + (void)di_firstWord( &data->iter ); } } JNIEXPORT void JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1destroy +Java_org_eehouse_android_xw4_jni_XwJNI_di_1destroy ( JNIEnv* env, jclass C, jlong closure ) { DictIterData* data = (DictIterData*)closure; @@ -2472,7 +2472,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1destroy } JNIEXPORT jint JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1wordCount +Java_org_eehouse_android_xw4_jni_XwJNI_di_1wordCount (JNIEnv* env, jclass C, jlong closure ) { jint result = 0; @@ -2484,17 +2484,17 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1wordCount } JNIEXPORT jintArray JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getCounts +Java_org_eehouse_android_xw4_jni_XwJNI_di_1getCounts (JNIEnv* env, jclass C, jlong closure ) { jintArray result = NULL; DictIterData* data = (DictIterData*)closure; if ( NULL != data ) { DictIter iter; - dict_initIter( &iter, data->dict, 0, MAX_COLS_DICT ); + di_initIter( &iter, data->dict, 0, MAX_COLS_DICT ); LengthsArray lens; - if ( 0 < dict_countWords( &iter, &lens ) ) { + if ( 0 < di_countWords( &iter, &lens ) ) { XP_ASSERT( sizeof(jint) == sizeof(lens.lens[0]) ); result = makeIntArray( env, VSIZE(lens.lens), (jint*)&lens.lens, sizeof(lens.lens[0]) ); @@ -2504,7 +2504,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getCounts } JNIEXPORT jobjectArray JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getPrefixes +Java_org_eehouse_android_xw4_jni_XwJNI_di_1getPrefixes ( JNIEnv* env, jclass C, jlong closure ) { jobjectArray result = NULL; @@ -2527,7 +2527,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getPrefixes } JNIEXPORT jintArray JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getIndices +Java_org_eehouse_android_xw4_jni_XwJNI_di_1getIndices ( JNIEnv* env, jclass C, jlong closure ) { jintArray jindices = NULL; @@ -2543,15 +2543,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getIndices } JNIEXPORT jstring JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1nthWord +Java_org_eehouse_android_xw4_jni_XwJNI_di_1nthWord ( JNIEnv* env, jclass C, jlong closure, jint nn) { jstring result = NULL; DictIterData* data = (DictIterData*)closure; if ( NULL != data ) { - if ( dict_getNthWord( &data->iter, nn, data->depth, &data->idata ) ) { + if ( di_getNthWord( &data->iter, nn, data->depth, &data->idata ) ) { XP_UCHAR buf[64]; - dict_wordToString( &data->iter, buf, VSIZE(buf) ); + di_wordToString( &data->iter, buf, VSIZE(buf) ); result = (*env)->NewStringUTF( env, buf ); } } @@ -2559,15 +2559,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1nthWord } JNIEXPORT jint JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getStartsWith +Java_org_eehouse_android_xw4_jni_XwJNI_di_1getStartsWith ( JNIEnv* env, jclass C, jlong closure, jstring jprefix ) { jint result = -1; DictIterData* data = (DictIterData*)closure; if ( NULL != data ) { const char* prefix = (*env)->GetStringUTFChars( env, jprefix, NULL ); - if ( 0 <= dict_findStartsWith( &data->iter, prefix ) ) { - result = dict_getPosition( &data->iter ); + if ( 0 <= di_findStartsWith( &data->iter, prefix ) ) { + result = di_getPosition( &data->iter ); } (*env)->ReleaseStringUTFChars( env, jprefix, prefix ); } @@ -2575,7 +2575,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getStartsWith } JNIEXPORT jstring JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getDesc +Java_org_eehouse_android_xw4_jni_XwJNI_di_1getDesc ( JNIEnv* env, jclass C, jlong closure ) { jstring result = NULL; @@ -2622,7 +2622,7 @@ makeIndex( DictIterData* data ) count * sizeof(*idata->indices) ); idata->count = count; - dict_makeIndex( &data->iter, data->depth, idata ); + di_makeIndex( &data->iter, data->depth, idata ); if ( 0 < idata->count ) { idata->prefixes = XP_REALLOC( data->mpool, idata->prefixes, idata->count * data->depth * diff --git a/xwords4/common/dictiter.c b/xwords4/common/dictiter.c index eacde18c5..75ffcaee1 100644 --- a/xwords4/common/dictiter.c +++ b/xwords4/common/dictiter.c @@ -282,15 +282,15 @@ wordsEqual( const DictIter* word1, const DictIter* word2 ) } static void -dict_initIterFrom( DictIter* dest, const DictIter* src ) +initIterFrom( DictIter* dest, const DictIter* src ) { - dict_initIter( dest, src->dict, + di_initIter( dest, src->dict, #ifdef XWFEATURE_WALKDICT_FILTER - src->min, src->max + src->min, src->max #else - 0, 0 + 0, 0 #endif - ); + ); } static XP_Bool @@ -307,10 +307,10 @@ firstWord( DictIter* iter ) } XP_U32 -dict_countWords( const DictIter* iter, LengthsArray* lens ) +di_countWords( const DictIter* iter, LengthsArray* lens ) { DictIter counter; - dict_initIterFrom( &counter, iter ); + initIterFrom( &counter, iter ); if ( NULL != lens ) { XP_MEMSET( lens, 0, sizeof(*lens) ); @@ -333,8 +333,8 @@ dict_countWords( const DictIter* iter, LengthsArray* lens ) #define ASSERT_INITED( iter ) XP_ASSERT( (iter)->guard == GUARD_VALUE ) void -dict_initIter( DictIter* iter, const DictionaryCtxt* dict, - XP_U16 min, XP_U16 max ) +di_initIter( DictIter* iter, const DictionaryCtxt* dict, + XP_U16 min, XP_U16 max ) { XP_MEMSET( iter, 0, sizeof(*iter) ); iter->dict = dict; @@ -421,7 +421,7 @@ indexOne( XP_U16 depth, Tile* tiles, IndexData* data, DictIter* prevIter, DictPosition* prevIndex ) { DictIter curIter; - dict_initIterFrom( &curIter, prevIter ); + initIterFrom( &curIter, prevIter ); if ( findWordStartsWith( &curIter, tiles, depth ) ) { while ( !wordsEqual( &curIter, prevIter ) ) { ++*prevIndex; @@ -458,7 +458,7 @@ doOneDepth( const Tile* allTiles, XP_U16 nTiles, Tile* prefix, } void -dict_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ) +di_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ) { ASSERT_INITED( iter ); const DictionaryCtxt* dict = iter->dict; @@ -490,7 +490,7 @@ dict_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ) */ data->count = 0; DictIter prevIter; - dict_initIterFrom( &prevIter, iter ); + initIterFrom( &prevIter, iter ); if ( firstWord( &prevIter ) ) { DictPosition prevIndex = 0; Tile prefix[depth]; @@ -504,16 +504,16 @@ dict_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ) DI_ASSERT( data->indices[pos-1] < data->indices[pos] ); } #endif -} /* dict_makeIndex */ +} /* di_makeIndex */ static void initWord( DictIter* iter ) { - iter->nWords = dict_countWords( iter, NULL ); + iter->nWords = di_countWords( iter, NULL ); } XP_Bool -dict_firstWord( DictIter* iter ) +di_firstWord( DictIter* iter ) { ASSERT_INITED( iter ); XP_Bool success = firstWord( iter ); @@ -526,7 +526,7 @@ dict_firstWord( DictIter* iter ) } XP_Bool -dict_getNextWord( DictIter* iter ) +di_getNextWord( DictIter* iter ) { ASSERT_INITED( iter ); XP_Bool success = nextWord( iter ); @@ -537,7 +537,7 @@ dict_getNextWord( DictIter* iter ) } XP_Bool -dict_lastWord( DictIter* iter ) +di_lastWord( DictIter* iter ) { ASSERT_INITED( iter ); iter->nEdges = 1; @@ -553,7 +553,7 @@ dict_lastWord( DictIter* iter ) } XP_Bool -dict_getPrevWord( DictIter* iter ) +di_getPrevWord( DictIter* iter ) { ASSERT_INITED( iter ); XP_Bool success = prevWord( iter ); @@ -567,8 +567,8 @@ dict_getPrevWord( DictIter* iter ) sought. OR if we're father than necessary from what's sought, start over at the closer end. Then move as many steps as necessary to reach it. */ XP_Bool -dict_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, - const IndexData* data ) +di_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, + const IndexData* data ) { ASSERT_INITED( iter ); const DictionaryCtxt* dict = iter->dict; @@ -576,7 +576,7 @@ dict_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, XP_Bool validWord = 0 < iter->nEdges; if ( validWord ) { /* uninitialized */ wordCount = iter->nWords; - DI_ASSERT( wordCount == dict_countWords( iter, NULL ) ); + DI_ASSERT( wordCount == di_countWords( iter, NULL ) ); } else { wordCount = dict_getWordCount( dict ); } @@ -589,9 +589,9 @@ dict_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, success = XP_TRUE; /* do nothing; we're done */ } else if ( iter->position == position - 1 ) { - success = dict_getNextWord( iter ); + success = di_getNextWord( iter ); } else if ( iter->position == position + 1 ) { - success = dict_getPrevWord( iter ); + success = di_getPrevWord( iter ); } } @@ -614,9 +614,9 @@ dict_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, if ( !validWord ) { if ( position >= wordCount ) { - dict_lastWord( iter ); + di_lastWord( iter ); } else { - dict_firstWord( iter ); + di_firstWord( iter ); } } wordIndex = iter->position; @@ -642,14 +642,14 @@ dict_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, } } return success; -} /* dict_getNthWord */ +} /* di_getNthWord */ static DictPosition figurePosition( DictIter* iter ) { DictPosition result = 0; DictIter iterZero; - dict_initIterFrom( &iterZero, iter ); + initIterFrom( &iterZero, iter ); if ( !firstWord( &iterZero ) ) { XP_ASSERT( 0 ); } @@ -665,7 +665,7 @@ figurePosition( DictIter* iter ) } XP_S16 -dict_findStartsWith( DictIter* iter, const XP_UCHAR* prefix ) +di_findStartsWith( DictIter* iter, const XP_UCHAR* prefix ) { ASSERT_INITED( iter ); array_edge* edge = dict_getTopEdge( iter->dict ); @@ -688,14 +688,14 @@ dict_findStartsWith( DictIter* iter, const XP_UCHAR* prefix ) } void -dict_wordToString( const DictIter* iter, XP_UCHAR* buf, XP_U16 buflen ) +di_wordToString( const DictIter* iter, XP_UCHAR* buf, XP_U16 buflen ) { ASSERT_INITED( iter ); iterToString( iter, buf, buflen ); } DictPosition -dict_getPosition( const DictIter* iter ) +di_getPosition( const DictIter* iter ) { ASSERT_INITED( iter ); return iter->position; diff --git a/xwords4/common/dictiter.h b/xwords4/common/dictiter.h index 6d31d75d8..c2fe3a4ff 100644 --- a/xwords4/common/dictiter.h +++ b/xwords4/common/dictiter.h @@ -63,19 +63,19 @@ typedef struct _LengthsArray { XP_U32 lens[MAX_COLS_DICT+1]; } LengthsArray; -void dict_initIter( DictIter* iter, const DictionaryCtxt* dict, - XP_U16 min, XP_U16 max ); -XP_U32 dict_countWords( const DictIter* iter, LengthsArray* lens ); -void dict_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ); -XP_Bool dict_firstWord( DictIter* iter ); -XP_Bool dict_lastWord( DictIter* iter ); -XP_Bool dict_getNextWord( DictIter* iter ); -XP_Bool dict_getPrevWord( DictIter* iter ); -XP_Bool dict_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, - const IndexData* data ); -void dict_wordToString( const DictIter* iter, XP_UCHAR* buf, XP_U16 buflen ); -XP_S16 dict_findStartsWith( DictIter* iter, const XP_UCHAR* prefix ); -DictPosition dict_getPosition( const DictIter* iter ); +void di_initIter( DictIter* iter, const DictionaryCtxt* dict, + XP_U16 min, XP_U16 max ); +XP_U32 di_countWords( const DictIter* iter, LengthsArray* lens ); +void di_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ); +XP_Bool di_firstWord( DictIter* iter ); +XP_Bool di_lastWord( DictIter* iter ); +XP_Bool di_getNextWord( DictIter* iter ); +XP_Bool di_getPrevWord( DictIter* iter ); +XP_Bool di_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth, + const IndexData* data ); +void di_wordToString( const DictIter* iter, XP_UCHAR* buf, XP_U16 buflen ); +XP_S16 di_findStartsWith( DictIter* iter, const XP_UCHAR* prefix ); +DictPosition di_getPosition( const DictIter* iter ); #ifdef CPLUS } #endif diff --git a/xwords4/common/dictnry.c b/xwords4/common/dictnry.c index 516dd2173..de2ac3c47 100644 --- a/xwords4/common/dictnry.c +++ b/xwords4/common/dictnry.c @@ -844,8 +844,8 @@ dict_getWordCount( const DictionaryCtxt* dict ) #ifdef XWFEATURE_WALKDICT if ( 0 == nWords ) { DictIter iter; - dict_initIter( &iter, dict, 0, MAX_COLS_DICT ); - nWords = dict_countWords( &iter, NULL ); + di_initIter( &iter, dict, 0, MAX_COLS_DICT ); + nWords = di_countWords( &iter, NULL ); } #endif return nWords; diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 8b9cf9f7f..4ac8e98ae 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -1903,16 +1903,16 @@ testGetNthWord( const DictionaryCtxt* dict, char** XP_UNUSED_DBG(words), XP_U32 ii, jj; DictIter iter; - dict_initIter( &iter, dict, min, max ); - XP_U32 half = dict_countWords( &iter, NULL ) / 2; + di_initIter( &iter, dict, min, max ); + XP_U32 half = di_countWords( &iter, NULL ) / 2; XP_U32 interval = half / 100; if ( interval == 0 ) { ++interval; } for ( ii = 0, jj = half; ii < half; ii += interval, jj += interval ) { - if ( dict_getNthWord( &iter, ii, depth, data ) ) { - dict_wordToString( &iter, buf, VSIZE(buf) ); + if ( di_getNthWord( &iter, ii, depth, data ) ) { + di_wordToString( &iter, buf, VSIZE(buf) ); XP_ASSERT( 0 == strcmp( buf, words[ii] ) ); # ifdef PRINT_ALL XP_LOGF( "%s: word[%ld]: %s", __func__, ii, buf ); @@ -1920,8 +1920,8 @@ testGetNthWord( const DictionaryCtxt* dict, char** XP_UNUSED_DBG(words), } else { XP_ASSERT( 0 ); } - if ( dict_getNthWord( &iter, jj, depth, data ) ) { - dict_wordToString( &iter, buf, VSIZE(buf) ); + if ( di_getNthWord( &iter, jj, depth, data ) ) { + di_wordToString( &iter, buf, VSIZE(buf) ); XP_ASSERT( 0 == strcmp( buf, words[jj] ) ); # ifdef PRINT_ALL XP_LOGF( "%s: word[%ld]: %s", __func__, jj, buf ); @@ -1948,9 +1948,9 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict, max = MAX_COLS_DICT; } - dict_initIter( &iter, dict, min, max ); + di_initIter( &iter, dict, min, max ); LengthsArray lens; - XP_U32 count = dict_countWords( &iter, &lens ); + XP_U32 count = di_countWords( &iter, &lens ); XP_U32 sum = 0; for ( jj = 0; jj < VSIZE(lens.lens); ++jj ) { @@ -1963,12 +1963,12 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict, char** words = g_malloc( count * sizeof(char*) ); XP_ASSERT( !!words ); - for ( jj = 0, gotOne = dict_firstWord( &iter ); + for ( jj = 0, gotOne = di_firstWord( &iter ); gotOne; - gotOne = dict_getNextWord( &iter ) ) { - XP_ASSERT( dict_getPosition( &iter ) == jj ); + gotOne = di_getNextWord( &iter ) ) { + XP_ASSERT( di_getPosition( &iter ) == jj ); XP_UCHAR buf[64]; - dict_wordToString( &iter, buf, VSIZE(buf) ); + di_wordToString( &iter, buf, VSIZE(buf) ); # ifdef PRINT_ALL fprintf( stderr, "%.6ld: %s\n", jj, buf ); # endif @@ -1979,12 +1979,12 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict, } XP_ASSERT( count == jj ); - for ( jj = 0, gotOne = dict_lastWord( &iter ); + for ( jj = 0, gotOne = di_lastWord( &iter ); gotOne; - ++jj, gotOne = dict_getPrevWord( &iter ) ) { - XP_ASSERT( dict_getPosition(&iter) == count-jj-1 ); + ++jj, gotOne = di_getPrevWord( &iter ) ) { + XP_ASSERT( di_getPosition(&iter) == count-jj-1 ); XP_UCHAR buf[64]; - dict_wordToString( &iter, buf, VSIZE(buf) ); + di_wordToString( &iter, buf, VSIZE(buf) ); # ifdef PRINT_ALL fprintf( stderr, "%.6ld: %s\n", jj, buf ); # endif @@ -2012,7 +2012,7 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict, depth * data.count * sizeof(data.prefixes[0]) ); XP_LOGF( "making index..." ); - dict_makeIndex( &iter, depth, &data ); + di_makeIndex( &iter, depth, &data ); XP_LOGF( "DONE making index" ); data.indices = XP_REALLOC( mpool, data.indices, @@ -2047,22 +2047,22 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict, guint count = g_slist_length( testPrefixes ); for ( ii = 0; ii < count; ++ii ) { gchar* prefix = (gchar*)g_slist_nth_data( testPrefixes, ii ); - XP_S16 lenMatched = dict_findStartsWith( &iter, prefix ); + XP_S16 lenMatched = di_findStartsWith( &iter, prefix ); if ( 0 <= lenMatched ) { XP_UCHAR buf[32]; XP_UCHAR bufPrev[32] = {0}; - dict_wordToString( &iter, buf, VSIZE(buf) ); + di_wordToString( &iter, buf, VSIZE(buf) ); /* 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 = di_getPosition( &iter ); XP_ASSERT( 0 == strcmp( buf, words[pos] ) ); if ( pos > 0 ) { - if ( !dict_getNthWord( &iter, pos-1, depth, &data ) ) { + if ( !di_getNthWord( &iter, pos-1, depth, &data ) ) { XP_ASSERT( 0 ); } - dict_wordToString( &iter, bufPrev, VSIZE(bufPrev) ); + di_wordToString( &iter, bufPrev, VSIZE(bufPrev) ); XP_ASSERT( 0 == strcmp( bufPrev, words[pos-1] ) ); } XP_LOGF( "dict_getStartsWith(%s) => %s (prev=%s)", @@ -2103,12 +2103,12 @@ static void dumpDict( DictionaryCtxt* dict ) { DictIter iter; - dict_initIter( &iter, dict, 0, MAX_COLS_DICT ); - for ( XP_Bool result = dict_firstWord( &iter ); + di_initIter( &iter, dict, 0, MAX_COLS_DICT ); + for ( XP_Bool result = di_firstWord( &iter ); result; - result = dict_getNextWord( &iter ) ) { + result = di_getNextWord( &iter ) ) { XP_UCHAR buf[32]; - dict_wordToString( &iter, buf, VSIZE(buf) ); + di_wordToString( &iter, buf, VSIZE(buf) ); fprintf( stdout, "%s\n", buf ); } }