src/hg/lib/customTrack.c 1.177
1.177 2009/09/24 22:25:17 tdreszer
autocreated custom trackNames now exclude all special chars and append a uniquifier number
Index: src/hg/lib/customTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customTrack.c,v
retrieving revision 1.176
retrieving revision 1.177
diff -b -B -U 4 -r1.176 -r1.177
--- src/hg/lib/customTrack.c 10 Apr 2009 19:54:40 -0000 1.176
+++ src/hg/lib/customTrack.c 24 Sep 2009 22:25:17 -0000 1.177
@@ -196,13 +196,12 @@
{
char buf[256];
char *tmp;
tmp = cloneString(label);
-eraseWhiteSpace(tmp); /* perhaps should be erase any */
-stripChar(tmp,'.'); /* periods confuse hgTables */
-stripChar(tmp,'_'); /* thing that isn't isalnum */
-stripChar(tmp,'-'); /* since that's the Invalid table */
-safef(buf, sizeof(buf), "%s%s", CT_PREFIX, tmp); /* name check in hgText */
+bits32 uniquifier = hashString(tmp);
+eraseNonAlphaNum(tmp);
+safef(buf, sizeof(buf), "%s%s_%d", CT_PREFIX, tmp, (uniquifier % 9997));
+// Name is not perfectly uniq but 4 chars of uniquifier should cut down on collisions
freeMem(tmp);
return cloneString(buf);
}