a523548600dfd06e19538e0bf9f4d5053e95a958
kent
  Thu Aug 15 10:17:55 2019 -0700
A optimization was making the csv escapes not be applied when there were quotes, it was only triggered by commas.  Needs both, so added second.  At this point might be as fast to just always escape it as to make two shortcut passes though....

diff --git src/lib/csv.c src/lib/csv.c
index 2ae0db3..bd18e7f 100644
--- src/lib/csv.c
+++ src/lib/csv.c
@@ -1,48 +1,47 @@
 /* csv - stuff to help process comma separated values.  Have to wrap quotes around
  * things with commas, and escape quotes with more quotes sometimes. */
 
 #include "common.h"
 #include "linefile.h"
 #include "csv.h"
 
 void csvEscapeAndAppend(struct dyString *dy, char *string)
 /* Append escaped string to dy.  Will insert comma if dy is non-empty */
 {
 if (dy->stringSize != 0)
     dyStringAppendC(dy, ',');
-if (strchr(string, ',') == NULL)
+if (strchr(string, ',') == NULL && strchr(string, '"') == NULL)
     dyStringAppend(dy, string);
 else
     {
     dyStringAppendC(dy, '"');
     char c;
     while ((c = *string++) != 0)
 	{
 	if (c == '"')
 	    dyStringAppendC(dy, c);
 	dyStringAppendC(dy, c);
 	}
     dyStringAppendC(dy, '"');
     }
 }
 
 char *csvEscapeToDyString(struct dyString *dy, char *string)
 /* Wrap string in quotes if it has any commas.  Put result into dy, and return it as a 
  * string.   Anything already in quotes get double-quoted */
 {
-/* If there are no commas just output it */
 dyStringClear(dy);
 csvEscapeAndAppend(dy, string);
 return dy->string;
 }
 
 void csvWriteVal(char *val, FILE *f)
 /* Write val, which may have some quotes or commas in it, in a way to be compatable with
  * csv list representation */
 {
 /* If there are no commas just output it */
 if (strchr(val, ',') == NULL)
     {
     fputs(val, f);
     return;
     }