b168eec18c0cb3f2d06b1ccc59eb34776403f50e kent Wed May 31 18:05:09 2017 -0700 Writing and testing new csvParseNext function. diff --git src/inc/csv.h src/inc/csv.h index cff8000..d4bcdce 100644 --- src/inc/csv.h +++ src/inc/csv.h @@ -1,17 +1,26 @@ /* csv - stuff to help process comma separated values. Have to wrap quotes around * things with commas, and escape quotes with more quotes sometimes. */ #ifndef CSV_H #define CSV_H char *csvEscapeToDyString(struct dyString *dy, char *string); /* Wrap string in quotes if it has any commas. Anything already in quotes get s double-quoted * Returns transformated result, which will be input string if it has no commas, otherwise * will be dy*/ 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 */ +char *csvParseNext(char **pos, struct dyString *scratch); +/* Return next value starting at pos, putting results into scratch and + * returning scratch->string or NULL if no values left. Will update *pos + * to after trailing comma if any. This will tolerate and ignore leading + * and trailing white space. + * Since an empty or all-white string is will return NULL, if you + * want empty strings to be a legitimate value then they have to be quoted + * or followed by a comma. */ + #endif /* CSV_H */