47d151294952433d9815a5778e90e8ac74e0fed1
angie
  Mon Nov 8 10:00:13 2010 -0800
Better bug fix for b509f936321e0d635a785f48ee0638744fbc3b8d:chop up a copy, not the original search term, when it looks like
a chrom:offset or chrom:start-end term.  Merely restoring the
original for searching left the original term chopped for
error-reporting, which meant a truncated term in the message
when a term couldn't be found, as Fan noticed.

diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c
index c6dfbb1..d97176a 100644
--- src/hg/lib/hgFind.c
+++ src/hg/lib/hgFind.c
@@ -2986,45 +2986,46 @@
 if(isEmpty(term))
     return hgp;
 
 hgp->query = cloneString(term);
 hgp->database = db;
 if (extraCgi == NULL)
     extraCgi = "";
 hgp->extraCgi = cloneString(extraCgi);
 
 if (singleSearch(db, term, cart, hgp))
     return hgp;
 
 /* Allow any search term to end with a :Start-End range -- also support stuff 
  * pasted in from BED (chrom start end) or SQL query (chrom | start | end).  
  * If found, strip it off and remember the start and end. */
-char *originalTerm = cloneString(term);
+char *originalTerm = term;
 if ((canonicalSpec = 
         matchRegexSubstr(term, canonicalRangeExp,
 				  substrs, ArraySize(substrs))) ||
     (gbrowserSpec = 
         matchRegexSubstr(term, gbrowserRangeExp, 
                                 substrs, ArraySize(substrs))) ||
     (lengthSpec = 
         matchRegexSubstr(term, lengthRangeExp, 
                                 substrs, ArraySize(substrs))) ||
     matchRegexSubstr(term, bedRangeExp, substrs, ArraySize(substrs)) ||
     (singleBaseSpec = 
 	matchRegexSubstr(term, singleBaseExp, substrs, ArraySize(substrs))) ||
     matchRegexSubstr(term, sqlRangeExp, substrs, ArraySize(substrs)))
     {
+    term = cloneString(term);
     /* Since we got a match, substrs[1] is the chrom/term, [2] is relStart, 
      * [3] is relEnd. ([0] is all.) */
     term[substrs[1].rm_eo] = 0;
     eraseTrailingSpaces(term);
     term[substrs[2].rm_eo] = 0;
     relStart = atoi(stripCommas(term+substrs[2].rm_so));
     term[substrs[3].rm_eo] = 0;
     if (singleBaseSpec)
 	{
 	relEnd   = relStart;
 	relStart--;
 	}
     else
 	relEnd   = atoi(stripCommas(term+substrs[3].rm_so));
     if (canonicalSpec || gbrowserSpec || lengthSpec)
@@ -3045,31 +3046,31 @@
     {
     char *chrom;
     int start, end;
 
     hgParseChromRange(db, term, &chrom, &start, &end);
     if (relativeFlag)
 	{
 	int chromSize = end;
 	end = start + relEnd;
 	start = start + relStart;
 	if (end > chromSize)
 	    end = chromSize;
 	if (start < 0)
 	    start = 0;
 	}
-    singlePos(hgp, "Chromosome Range", NULL, "chromInfo", term,
+    singlePos(hgp, "Chromosome Range", NULL, "chromInfo", originalTerm,
 	      "", chrom, start, end);
     }
 else
     {
     struct hgFindSpec *shortList = NULL, *longList = NULL;
     struct hgFindSpec *hfs;
     boolean done = FALSE;
 
     // Disable singleBaseSpec for any term that is not hgOfficialChromName
     // because that mangles legitimate IDs that are [A-Z]:[0-9]+.
     if (singleBaseSpec)
 	term = sqlEscapeString(originalTerm);
 
     hgFindSpecGetAllSpecs(db, &shortList, &longList);
     for (hfs = shortList;  hfs != NULL;  hfs = hfs->next)