Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
585b0a61
Commit
585b0a61
authored
Jul 04, 2013
by
antirez
Browse files
sds.c: new function sdsjoin() to join strings.
parent
1135e9fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
585b0a61
...
...
@@ -621,6 +621,19 @@ sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen) {
return
s
;
}
/* Join an array of C strings using the specified separator (also a C string).
* Returns the result as an sds string. */
sds
sdsjoin
(
char
**
argv
,
int
argc
,
char
*
sep
)
{
sds
join
=
sdsempty
();
int
j
;
for
(
j
=
0
;
j
<
argc
;
j
++
)
{
join
=
sdscat
(
join
,
argv
[
j
]);
if
(
j
!=
argc
-
1
)
join
=
sdscat
(
join
,
sep
);
}
return
join
;
}
#ifdef SDS_TEST_MAIN
#include <stdio.h>
#include "testhelp.h"
...
...
src/sds.h
View file @
585b0a61
...
...
@@ -89,6 +89,7 @@ sds sdsfromlonglong(long long value);
sds
sdscatrepr
(
sds
s
,
const
char
*
p
,
size_t
len
);
sds
*
sdssplitargs
(
const
char
*
line
,
int
*
argc
);
sds
sdsmapchars
(
sds
s
,
const
char
*
from
,
const
char
*
to
,
size_t
setlen
);
sds
sdsjoin
(
char
**
argv
,
int
argc
,
char
*
sep
);
/* Low level functions exposed to the user API */
sds
sdsMakeRoomFor
(
sds
s
,
size_t
addlen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment