a9ee71986f3eba65f361a8b07c15338526117e61 galt Mon Jan 25 13:04:34 2016 -0800 Fixes #16721. Bug in order of operations employed with user supplied position where start > end, causes both the start and end coordinates to be off by 1. Fixed by just doing the coordinate swap before decrementing the start by 1. diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c index ab5b08a..f887c1f 100644 --- src/hg/lib/hgFind.c +++ src/hg/lib/hgFind.c @@ -3175,40 +3175,40 @@ 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) - relStart--; - if (lengthSpec) - relEnd += relStart; if (relStart > relEnd) { int tmp = relStart; relStart = relEnd; relEnd = tmp; } + if (canonicalSpec || gbrowserSpec || lengthSpec) + relStart--; + if (lengthSpec) + relEnd += relStart; relativeFlag = TRUE; } term = cloneString(term); // because hgOfficialChromName mangles it if (hgOfficialChromName(db, term) != NULL) // this mangles the term { char *chrom; int start, end; hgParseChromRange(db, term, &chrom, &start, &end); if (relativeFlag) { int chromSize = end; end = start + relEnd; start = start + relStart;