aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-27 19:09:42 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-27 19:09:42 +0000
commit9c66eb49b2db6c62d2497ff9ce5564ad03f95f9b (patch)
tree8afb09506a759a91a1ccec83b41e76648a02cdc2
parentd73975d1133c6344c4687b28e8d18a3b615270f6 (diff)
Use a different determinator on whether to print the delimiter, since leading fields may be blank.
(closes issue #15208) Reported by: ramonpeek Patch by me, though inspired in part by a patch from ramonpeek git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@197194 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--funcs/func_cut.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/funcs/func_cut.c b/funcs/func_cut.c
index b8f5c5869..1bafbd669 100644
--- a/funcs/func_cut.c
+++ b/funcs/func_cut.c
@@ -167,7 +167,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
pbx_substitute_variables_helper(chan, tmp, tmp2, MAXRESULT - 1);
if (tmp2) {
- int curfieldnum = 1;
+ int curfieldnum = 1, firstfield = 1;
while (tmp2 != NULL && args.field != NULL) {
char *nextgroup = strsep(&(args.field), "&");
int num1 = 0, num2 = MAXRESULT;
@@ -209,11 +209,12 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
char *tmp3 = strsep(&tmp2, ds);
int curlen = strlen(buffer);
- if (curlen)
- snprintf(buffer + curlen, buflen - curlen, "%c%s", d, tmp3);
- else
+ if (firstfield) {
snprintf(buffer, buflen, "%s", tmp3);
-
+ firstfield = 0;
+ } else {
+ snprintf(buffer + curlen, buflen - curlen, "%c%s", d, tmp3);
+ }
curfieldnum++;
}
}