4a030195664cbdd1d3c1a4b81b1ed41dbf6d9bc5
angie
  Fri Feb 15 14:02:58 2019 -0800
Prevent hgFind lib (specifically genomePos -> hgPositionsHtml) from opening a web page; instead, pass up results and warning messages to the calling CGI so it can open the page its own way.  refs #22945
hgTracks, hgTables and hgVai used to call findGenomePos{,Web} to resolve positions; hgTables and hgVai had to detect after the fact whether an HTML page had been started (with warnings and/or multiple results).
In fact, hgPositionsHtml called webEnd which could cause conflicts with what the CGI was doing afterwards.
Now, instead of findGenomePos{,Web} there is hgFindSearch which returns hgp and also warning messages, if any, via a dyString parameter.
The calling CGI decides how to open the page if necessary (for hgTracks, it's already open) and displays warnings/multiple results -- or just proceeds as usual with the single position result.

diff --git src/hg/checkHgFindSpec/checkHgFindSpec.c src/hg/checkHgFindSpec/checkHgFindSpec.c
index 07e4a88..2c5e444 100644
--- src/hg/checkHgFindSpec/checkHgFindSpec.c
+++ src/hg/checkHgFindSpec/checkHgFindSpec.c
@@ -57,31 +57,30 @@
 "                      the target table for the search).  Search for it.\n"
 "  -makeExamples       Print out an HTML table of example positions\n"
 "                      (suitable for a gateway description.html).\n"
 */
 	 );
 }
 
 
 boolean reportSearch(char *termToSearch)
 /* Show the list of tables that will be searched, and how long it took to 
  * figure that out.  Then do the search; show results and time required. */
 //#*** this doesn't handle ; in termToSearch (until the actual search)
 {
 struct hgFindSpec *shortList = NULL, *longList = NULL;
 struct hgFindSpec *hfs = NULL;
-struct hgPositions *hgp = NULL;
 int startMs = 0, endMs = 0;
 boolean gotError = FALSE;
 char *chrom = NULL;
 int chromStart = 0, chromEnd = 0;
 
 hgFindSpecGetAllSpecs(database, &shortList, &longList);
 puts("\n");
 startMs = clock1000();
 for (hfs = shortList;  hfs != NULL;  hfs = hfs->next)
     {
     boolean matches = TRUE;
     boolean tablesExist = hTableOrSplitExists(database, hfs->searchTable);
     if (isNotEmpty(termToSearch) && isNotEmpty(hfs->termRegex))
 	matches = regexMatchNoCase(termToSearch, hfs->termRegex);
     if (isNotEmpty(hfs->xrefTable))
@@ -124,46 +123,54 @@
 		isNotEmpty(hfs->xrefTable) ? " and/or " : "",
 		isNotEmpty(hfs->xrefTable) ? hfs->xrefTable : "");
 	}
     else
 	{
 	verbose(2, "no match %s: %s\n", hfs->searchName, hfs->termRegex);
 	}
     }
 endMs = clock1000();
 printf("\nTook %dms to determine multiple/additive searches.\n"
        "(These won't happen if it short-circuits.)\n\n",
        endMs - startMs);
 
 if (isNotEmpty(termToSearch))
     {
+    cartSetString(cart, "db", database);
+    char *position = cloneString(termToSearch);
+    struct dyString *dyWarn = dyStringNew(0);
     startMs = clock1000();
-    hgp = findGenomePos(database, termToSearch, &chrom, &chromStart, &chromEnd, cart);
+    struct hgPositions *hgp = hgFindSearch(cart, &position, &chrom, &chromStart, &chromEnd,
+                                           "checkHgFindSpec", dyWarn);
     endMs = clock1000();
-    if (hgp != NULL && hgp->singlePos != NULL)
+    if (isNotEmpty(dyWarn->string))
+        warn("%s", dyWarn->string);
+    if (hgp->singlePos != NULL)
 	{
 	struct hgPos *pos = hgp->singlePos;
 	char *table = "[No reported table!]";
 	char *name = pos->name ? pos->name : "";
 	char *browserName = pos->browserName ? pos->browserName : "";
 	char *description = pos->description ? pos->description : "";
 	if (hgp->tableList != NULL)
 	    table = hgp->tableList->name;
 	printf("\nSingle result for %s from %s: %s:%d-%d   [%s | %s | %s]\n",
 	       termToSearch, table, chrom, chromStart+1, chromEnd,
 	       name, browserName, description);
 	}
+    else
+        hgPositionsHtml(database, hgp, "checkHgFindSpec", cart);
     printf("\nTook %dms to search for %s.\n\n",
 	   endMs - startMs, termToSearch);
     }
 
 hgFindSpecFreeList(&shortList);
 hgFindSpecFreeList(&longList);
 return(gotError);
 }
 
 static char *getFieldFromQuery(char *query, char *searchName)
 /* Get the value of the field that's being searched in query. */
 {
 char *ptr = strstr(query, " where ");
 char *field = NULL;
 if (ptr == NULL)