summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-26 18:16:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:59 -0500
commit01319b8462aa8ebf3b5be4598e7317aa08f40350 (patch)
tree8cbd411e39a0dedabdf12d942da4e014c2b0dab4 /source4/lib
parentbb9c9ec69c58c9707381e37a7d984e1fab32548f (diff)
downloadsamba-01319b8462aa8ebf3b5be4598e7317aa08f40350.tar.gz
samba-01319b8462aa8ebf3b5be4598e7317aa08f40350.tar.bz2
samba-01319b8462aa8ebf3b5be4598e7317aa08f40350.zip
r10516: Add seperator argument to str_list_{make,join}_shell()
(This used to be commit 0a5c9197f28e5451406d422e0a8ff84c1b20faae)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/util_strlist.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source4/lib/util_strlist.c b/source4/lib/util_strlist.c
index 7aff027d66..ec6c58162f 100644
--- a/source4/lib/util_strlist.c
+++ b/source4/lib/util_strlist.c
@@ -75,7 +75,7 @@ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *
Entries are seperated by spaces and can be enclosed by quotes.
Does NOT support escaping
*/
-const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string)
+const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
{
int num_elements = 0;
const char **ret = NULL;
@@ -85,13 +85,16 @@ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string)
return NULL;
}
+ if (sep == NULL)
+ sep = " \t\n\r";
+
while (string && *string) {
- size_t len = strcspn(string, " ");
+ size_t len = strcspn(string, sep);
char *element;
const char **ret2;
if (len == 0) {
- string += strspn(string, " ");
+ string += strspn(string, sep);
continue;
}
@@ -148,7 +151,7 @@ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator)
/* join a list back to one (shell-like) string; entries
* seperated by spaces, using quotes where necessary */
-char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list)
+char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep)
{
char *ret = NULL;
int i;
@@ -163,9 +166,9 @@ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list)
for (i = 1; list[i]; i++) {
if (strchr(list[i], ' ') || strlen(list[i]) == 0)
- ret = talloc_asprintf_append(ret, " \"%s\"", list[i]);
+ ret = talloc_asprintf_append(ret, "%c\"%s\"", sep, list[i]);
else
- ret = talloc_asprintf_append(ret, " %s", list[i]);
+ ret = talloc_asprintf_append(ret, "%c%s", sep, list[i]);
}
return ret;