src/hg/lib/customFactory.c 1.124

1.124 2010/05/11 01:43:29 kent
Refactoring to split the trackDb.tableName field into separate track and table fields. Similarly track.mapName field goes to the same track and table fields.
Index: src/hg/lib/customFactory.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customFactory.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -b -B -U 4 -r1.123 -r1.124
--- src/hg/lib/customFactory.c	21 Apr 2010 19:25:40 -0000	1.123
+++ src/hg/lib/customFactory.c	11 May 2010 01:43:29 -0000	1.124
@@ -222,9 +222,9 @@
 struct dyString *errDy = newDyString(0);
 struct lineFile *lf;
 char *line;
 int i;
-dyStringPrintf(errDy, "track load error (track name='%s'):<BR>\n", track->tdb->tableName);
+dyStringPrintf(errDy, "track load error (track name='%s'):<BR>\n", track->tdb->track);
 lf = lineFileOpen(track->dbStderrFile, TRUE);
 i = 0;
 while( (i < 3) && lineFileNext(lf, &line, NULL))
     {
@@ -1815,8 +1815,16 @@
 *retG = atoi(row[1]);
 *retB = atoi(row[2]);
 }
 
+static void stripJavascript(char **pString)
+/* Replace *pString (which is dynamically allocated) with javascript free version of itself. */
+{
+char *tmp = *pString;
+*pString = jsStripJavascript(tmp);
+freeMem(tmp);
+}
+
 static void customTrackUpdateFromSettings(struct customTrack *track, 
                                           char *genomeDb,
 					  char *line, int lineIx)
 /* replace settings in track with those from new track line */
@@ -1844,9 +1852,10 @@
     else
         tdb->shortLabel = cloneString("My Track");
     stripChar(tdb->shortLabel,'"');	/*	no quotes please	*/
     stripChar(tdb->shortLabel,'\'');	/*	no quotes please	*/
-    tdb->tableName = customTrackTableFromLabel(tdb->shortLabel);
+    tdb->table = customTrackTableFromLabel(tdb->shortLabel);
+    tdb->track = cloneString(tdb->table);
     /* also use name for description, if not specified */
     tdb->longLabel = cloneString(tdb->shortLabel);
     }
 if ((val = hashFindVal(hash, "description")) != NULL)
@@ -1982,17 +1991,12 @@
     else
         dyStringPrintf(ds, "track %s", line);
     ctAddToSettings(track, "origTrackLine", dyStringCannibalize(&ds));
     }
-char *tmp = tdb->tableName;
-tdb->tableName = jsStripJavascript(tmp);
-freeMem(tmp);
-tmp = tdb->shortLabel;
-tdb->shortLabel = jsStripJavascript(tmp);
-freeMem(tmp);
-tmp = tdb->longLabel;
-tdb->longLabel = jsStripJavascript(tmp);
-freeMem(tmp);
+stripJavascript(&tdb->track);
+stripJavascript(&tdb->table);
+stripJavascript(&tdb->shortLabel);
+stripJavascript(&tdb->longLabel);
 }
 
 char *browserLinesToSetting(struct slName *browserLines)
 /* Create a setting with browser lines separated by semi-colons */