src/lib/bbiWrite.c 1.11

1.11 2010/01/30 01:03:33 kent
Adding more error checking on input.
Index: src/lib/bbiWrite.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/bbiWrite.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -b -B -U 4 -r1.10 -r1.11
--- src/lib/bbiWrite.c	13 Nov 2009 19:02:38 -0000	1.10
+++ src/lib/bbiWrite.c	30 Jan 2010 01:03:33 -0000	1.11
@@ -138,8 +138,18 @@
     lineFileExpectWords(lf, 3, rowSize);
     char *chrom = row[0];
     int start = lineFileNeedNum(lf, row, 1);
     int end = lineFileNeedNum(lf, row, 2);
+    if (start >= end)
+        {
+	if (start == end)
+	    errAbort("line %d of %s: start and end coordinates the same\n"
+	             "They need to be at least one apart"
+		     , lf->lineIx, lf->fileName);
+	else
+	    errAbort("end (%d) before start (%d) line %d of %s",
+	    	end, start, lf->lineIx, lf->fileName);
+	}
     ++bedCount;
     totalBases += (end - start);
     if (usage == NULL || differentString(usage->name, chrom))
         {