d11734eb8be118418ae02fe26799870807b43685 jcasper Mon Mar 3 07:41:09 2025 -0800 Needed a function to split up CSV without losing empty records, refs #31812 diff --git src/inc/common.h src/inc/common.h index 8e3b1469f01..48bc58973f2 100644 --- src/inc/common.h +++ src/inc/common.h @@ -1005,30 +1005,34 @@ #define chopLineLen(line) chopByWhite(line, NULL, 0) /* Return the number of elements if you were to chop line by white space. */ int chopByWhiteRespectDoubleQuotes(char *in, char *outArray[], int outSize); /* Like chopString, but specialized for white space separators. * Further, any doubleQuotes (") are respected. * If doubleQuote encloses whole string, then they are removed: * "Fred and Ethyl" results in word [Fred and Ethyl] * If doubleQuotes exist inside string they are retained: * Fred "and Ethyl" results in word [Fred "and Ethyl"] * Special note "" is a valid, though empty word. */ int chopByCharRespectDoubleQuotes(char *in, char sep, char *outArray[], int outSize); /* Chop a string into sep delimited strings but honor double quotes */ +int chopByCharRespectDoubleQuotesKeepEmpty(char *in, char sep, char *outArray[], int outSize); +/* Chop a string into sep delimited strings but honor double quotes. Keep empty entries (",,") + * in the list instead of skipping over them. */ + int chopByChar(char *in, char chopper, char *outArray[], int outSize); /* Chop based on a single character. */ #define chopTabs(string, words) chopByChar(string, '\t', words, ArraySize(words)) /* Chop string by tabs. */ #define chopTabsLen(string) chopByChar(string, '\t', NULL, 0) /* Return the number of elements if you were to chop string by tab. */ #define chopCommas(string, words) chopByChar(string, ',', words, ArraySize(words)) /* Chop string by commas. */ #define chopCommasLen(string) chopByChar(string, ',', NULL, 0) /* Return the number of elements if you were to chop string by comma. */