f3f70bbd22bd95273633de2a0ecb469e475ab265
larrym
  Wed Apr 18 13:41:35 2012 -0700
cleanup string escape code
diff --git src/hg/lib/jsHelper.c src/hg/lib/jsHelper.c
index 6ccc920..d4c56f8 100644
--- src/hg/lib/jsHelper.c
+++ src/hg/lib/jsHelper.c
@@ -751,62 +751,64 @@
     }
 }
 
 static void getSpecificChar(char c, char *str, int *posPtr)
 {
 // get specified char from string or errAbort
 if(str[*posPtr] != c)
     errAbort("Unexpected character '%c' (expected '%c') - string position %d\n", str[*posPtr], c, *posPtr);
 (*posPtr)++;
 }
 
 static char *getString(char *str, int *posPtr)
 {
 // read a double-quote delimited string; we handle backslash escaping.
 // returns allocated string.
-char prevChar = 0;
+boolean escapeMode = FALSE;
 int i;
 struct dyString *ds = dyStringNew(1024);
 getSpecificChar('"', str, posPtr);
 for(i = 0;; i++)
     {
     char c = str[*posPtr + i];
     if(!c)
         errAbort("Premature end of string (missing trailing double-quote); string position '%d'", *posPtr);
-    else if(prevChar == '\\')
+    else if(escapeMode)
         {
         switch(c)
             {
             case 'n':
                 c = '\n';
                 break;
             case 'r':
                 c = '\r';
                 break;
             case 't':
                 c = '\t';
                 break;
             }
         dyStringAppendC(ds, c);
-        prevChar = 0;   // watch out for edge case where this is an escaped backslash
+        escapeMode = FALSE;
         }
     else if(c == '"')
         break;
-    else if(c != '\\')
+    else if(c == '\\')
+        escapeMode = TRUE;
+    else
         {
         dyStringAppendC(ds, c);
-        prevChar = c;
+        escapeMode = FALSE;
         }
     }
 *posPtr += i;
 getSpecificChar('"', str, posPtr);
 return dyStringCannibalize(&ds);
 }
 
 static struct jsonElement *jsonParseExpression(char *str, int *posPtr);
 
 static struct jsonElement *jsonParseObject(char *str, int *posPtr)
 {
 struct hash *h = newHash(0);
 getSpecificChar('{', str, posPtr);
 while(str[*posPtr] != '}')
     {