From c8223fc9578754dfaef1b337e5f0dfff546461b4 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Sat, 13 Dec 2008 08:36:35 +0000 Subject: Merge ast_str_opaque branch (discontinue usage of ast_str internals) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@163991 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_strings.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'funcs/func_strings.c') diff --git a/funcs/func_strings.c b/funcs/func_strings.c index da7525170..fa43752a4 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -321,7 +321,7 @@ static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, ch ); const char *orig_list, *ptr; const char *begin, *cur, *next; - int dlen, flen; + int dlen, flen, first = 1; struct ast_str *result = ast_str_thread_get(&result_buf, 16); char *delim; @@ -385,15 +385,12 @@ static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, ch begin += flen + dlen; } else { /* Copy field to output */ - if (result->used) { + if (!first) { ast_str_append(&result, 0, "%s", delim); } - /* Have to do it this way, since we're not null-terminated. */ - strncpy(result->str + result->used, begin, cur - begin); - result->used += cur - begin; - result->str[result->used] = '\0'; - + ast_str_append_substr(&result, 0, begin, cur - begin + 1); + first = 0; begin = cur + dlen; } } while (*cur != '\0'); @@ -401,7 +398,7 @@ static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, ch ast_channel_unlock(chan); } - ast_copy_string(buf, result->str, len); + ast_copy_string(buf, ast_str_buffer(result), len); return 0; } -- cgit v1.2.3