src/hg/oneShot/tdbRewriteSubtrackToParent/tdbRewriteSubtrackToParent.c 1.2
1.2 2010/02/17 20:16:44 kent
Fixing so it doesn't get misdirected by critically placed comments.
Index: src/hg/oneShot/tdbRewriteSubtrackToParent/tdbRewriteSubtrackToParent.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/oneShot/tdbRewriteSubtrackToParent/tdbRewriteSubtrackToParent.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/oneShot/tdbRewriteSubtrackToParent/tdbRewriteSubtrackToParent.c 16 Feb 2010 20:02:14 -0000 1.1
+++ src/hg/oneShot/tdbRewriteSubtrackToParent/tdbRewriteSubtrackToParent.c 17 Feb 2010 20:16:44 -0000 1.2
@@ -15,8 +15,11 @@
static char const rcsid[] = "$Id$";
static char *clRoot = "~/kent/src/hg/makeDb/trackDb"; /* Root dir of trackDb system. */
+char *newTag = "parent";
+char *oldTag = "subTrack";
+
void usage()
/* Explain usage and exit. */
{
errAbort(
@@ -34,8 +37,24 @@
{"root", OPTION_STRING},
{NULL, 0},
};
+char *firstTagInText(char *text)
+/* Return the location of tag in text - skipping blank and comment lines and white-space */
+{
+char *s = text;
+for (;;)
+ {
+ s = skipLeadingSpaces(s);
+ if (s[0] == '#')
+ {
+ s = strchr(s, '\n');
+ }
+ else
+ break;
+ }
+return s;
+}
static void rewriteOneFile(char *inFile, char *outFile)
/* Rewrite file. */
{
struct lineFile *lf = lineFileOpen(inFile, TRUE);
@@ -45,14 +64,14 @@
{
char *name, *val;
while (raNextTagVal(lf, &name, &val, dy))
{
- if (sameString("subTrack", name))
+ if (sameString(oldTag, name))
{
char *s = dy->string;
- char *e = skipLeadingSpaces(dy->string);
+ char *e = firstTagInText(dy->string);
mustWrite(f, s, e-s);
- fputs("parent", f);
+ fputs(newTag, f);
s = skipToSpaces(e);
fputs(s, f);
}
else