49eebbfade7874bd516ceb6f138e16111837bc33
galt
  Mon May 7 12:57:31 2012 -0700
Make sqlList.c dynamic arrays thread-safe.  Fixes bug in bigBed reported by user #7850.
diff --git src/lib/common.c src/lib/common.c
index 373102b..f3098b8 100644
--- src/lib/common.c
+++ src/lib/common.c
@@ -1745,30 +1745,47 @@
 
 int countLeadingNondigits(const char *s)
 /* Count number of leading non-digit characters in s. */
 {
 int count = 0;
 char c;
 while ((c = *s++) != 0)
    {
    if (isdigit(c))
        break;
    ++count;
    }
 return count;
 }
 
+int countSeparatedItems(char *string, char separator)
+/* Count number of items in string you would parse out with given
+ * separator,  assuming final separator is optional. */
+{
+int count = 0;
+char c, lastC = 0;
+while ((c = *string++) != 0)
+    {   
+    if (c == separator)
+       ++count;
+    lastC = c;
+    }
+if (lastC != separator && lastC != 0)
+    ++count;
+return count;
+}
+
 int cmpStringsWithEmbeddedNumbers(const char *a, const char *b)
 /* Compare strings such as gene names that may have embedded numbers,
  * so that bmp4a comes before bmp14a */
 {
 for (;;)
    {
    /* Figure out number of digits at start, and do numerical comparison if there
     * are any.  If numbers agree step over numerical part, otherwise return difference. */
    int aNum = countLeadingDigits(a);
    int bNum = countLeadingDigits(b);
    if (aNum >= 0 && bNum >= 0)
        {
        int diff = atoi(a) - atoi(b);
        if (diff != 0)
            return diff;