MCPcopy Create free account
hub / github.com/RsyncProject/rsync / conf_strtok

Function conf_strtok

util1.c:855–884  ·  view source on GitHub ↗

* Split a string into tokens based (usually) on whitespace & commas. If the * string starts with a comma (after skipping any leading whitespace), then * splitting is done only on commas. No empty tokens are ever returned. */

Source from the content-addressed store, hash-verified

853 * string starts with a comma (after skipping any leading whitespace), then
854 * splitting is done only on commas. No empty tokens are ever returned. */
855char *conf_strtok(char *str)
856{
857 static int commas_only = 0;
858
859 if (str) {
860 while (isSpace(str)) str++;
861 if (*str == ',') {
862 commas_only = 1;
863 str++;
864 } else
865 commas_only = 0;
866 }
867
868 while (commas_only) {
869 char *end, *tok = strtok(str, ",");
870 if (!tok)
871 return NULL;
872 /* Trim just leading and trailing whitespace. */
873 while (isSpace(tok))
874 tok++;
875 end = tok + strlen(tok);
876 while (end > tok && isSpace(end-1))
877 *--end = '\0';
878 if (*tok)
879 return tok;
880 str = NULL;
881 }
882
883 return strtok(str, " ,\t\r\n");
884}
885
886/* Join strings p1 & p2 into "dest" with a guaranteed '/' between them. (If
887 * p1 ends with a '/', no extra '/' is inserted.) Returns the length of both

Callers 1

rsync_moduleFunction · 0.85

Calls 1

isSpaceFunction · 0.85

Tested by

no test coverage detected