8c2001c3a5c7f1b077d7379ec77dc9756b1fe100 chmalee Tue Nov 1 12:14:16 2022 -0700 Wrap snippet code in an errCatch so we can still reset prefixSize when a supporting file is not found, refs #30200 diff --git src/lib/trix.c src/lib/trix.c index 83cbe95..f9821c6 100644 --- src/lib/trix.c +++ src/lib/trix.c @@ -1,30 +1,31 @@ /* trix - text retrieval index. Stuff for fast two level index * of text for fast word searches. */ /* Copyright (C) 2013 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #include "common.h" #include "hash.h" #include "linefile.h" #include "trix.h" #include "sqlNum.h" #include "udc.h" #include "net.h" #include "rangeTree.h" #include "portable.h" +#include "errCatch.h" /* Some local structures for the search. */ struct trixHitPos /* A hit to the index. */ { struct trixHitPos *next; /* Next in list */ char *itemId; /* Associated itemId */ int wordIx; /* Which word this is part of. */ int leftoverLetters; /* Number of letters at end of word not matched */ }; struct trixWordResult /* Results of a search on one word. */ { struct trixWordResult *next; @@ -944,23 +945,33 @@ void resetPrefixSize() { trixPrefixSize = 5; } void initSnippetIndex(struct trix *trix) /* Setup what we need to obtain snippets */ { trixPrefixSize = 15; initCharTables(); openSnippetIndex(trix); } void addSnippetsToSearchResults(struct trixSearchResult *tsrList, struct trix *trix) -/* Add snippets to each search result in tsrList */ +/* Add snippets to each search result in tsrList. Wrap in an errCatch + * in case the supporting files don't exist. */ +{ +struct errCatch *errCatch = errCatchNew(); +if (errCatchStart(errCatch)) { initSnippetIndex(trix); struct trixSearchResult *tsr; for (tsr = tsrList; tsr != NULL; tsr = tsr->next) addSnippetForResult(tsr, trix); + } +if (errCatch->gotError || errCatch->gotWarning) + { + warn("error adding snippets to search results: %s", errCatch->message->string); + } +errCatchEnd(errCatch); resetPrefixSize(); }