src/hg/lib/hVarSubst.c 1.3
1.3 2009/02/12 00:59:24 markd
correctly handle $$ escape in variable subtituion
Index: src/hg/lib/hVarSubst.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hVarSubst.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -B -U 4 -r1.2 -r1.3
--- src/hg/lib/hVarSubst.c 23 Jan 2009 22:19:46 -0000 1.2
+++ src/hg/lib/hVarSubst.c 12 Feb 2009 00:59:24 -0000 1.3
@@ -218,15 +218,20 @@
char varName[65];
while ((next = strchr(next, '$')) != NULL)
{
- if (*(next+1) == '$')
- next +=2; // $$ is a literal
- else
- {
if (dest == NULL)
dest = dyStringNew(strlen(src));
dyStringAppendN(dest, start, next-start);
+ if (*(next+1) == '$')
+ {
+ // $$ is a literal $
+ dyStringAppendC(dest, '$');
+ start = next = next + 2;
+ }
+ else
+ {
+ // variable reference
start = next = parseVarName(desc, next, varName, sizeof(varName));
substVar(desc, tdb, database, varName, dest);
}
}