* 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. */
| 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. */ |
| 855 | char *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 |
no test coverage detected