From 267a24619a2f5b6c08f251fb627b44336bd89081 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 24 Apr 2020 21:36:16 -0700 Subject: [PATCH] don't require .xwd's extension to be omitted for file to be found! --- xwords4/linux/linuxmain.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 7efa0b494..bd8c2d3b2 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -2156,14 +2156,24 @@ getDictPath( const LaunchParams *params, const char* name, XP_Bool success = XP_FALSE; GSList* iter; result[0] = '\0'; - for ( iter = params->dictDirs; !!iter; iter = iter->next ) { + for ( iter = params->dictDirs; !!iter && !success; iter = iter->next ) { const char* path = iter->data; - char buf[256]; - int len = snprintf( buf, VSIZE(buf), "%s/%s.xwd", path, name ); - if ( len < VSIZE(buf) && file_exists( buf ) ) { - snprintf( result, resultLen, "%s", buf ); - success = XP_TRUE; - break; + + for ( bool firstPass = true; ; firstPass = false ) { + char buf[256]; + int len = snprintf( buf, VSIZE(buf), "%s/%s%s", path, name, + firstPass ? "" : ".xwd" ); + XP_ASSERT( len < VSIZE(buf) ); + if ( len < VSIZE(buf) && file_exists( buf ) ) { + snprintf( result, resultLen, "%s", buf ); + success = XP_TRUE; + break; + } else { + XP_LOGFF( "nothing found at %s", buf ); + if ( !firstPass ) { + break; + } + } } } XP_LOGF( "%s(%s)=>%d", __func__, name, success );