]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Recorded merge of revisions 197194 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 27 May 2009 19:20:56 +0000 (19:20 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 27 May 2009 19:20:56 +0000 (19:20 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r197194 | tilghman | 2009-05-27 14:09:42 -0500 (Wed, 27 May 2009) | 5 lines

  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: https://origsvn.digium.com/svn/asterisk/trunk@197209 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_cut.c

index 437ebf62150c688c0d9ed94a336512a218785838..9c7c530f4f72052fb51a9d49ae91a86d33fd92c1 100644 (file)
@@ -186,6 +186,7 @@ static int cut_internal(struct ast_channel *chan, char *data, struct ast_str **b
                if (ast_str_strlen(str)) {
                        int curfieldnum = 1;
                        char *tmp2 = ast_str_buffer(str);
+                       int firstfield = 1;
                        while (tmp2 != NULL && args.field != NULL) {
                                char *nextgroup = strsep(&(args.field), "&");
                                int num1 = 0, num2 = INT_MAX;
@@ -222,7 +223,8 @@ static int cut_internal(struct ast_channel *chan, char *data, struct ast_str **b
                                /* Output fields until we either run out of fields or num2 is reached */
                                while (tmp2 != NULL && curfieldnum <= num2) {
                                        char *tmp3 = strsep(&tmp2, ds);
-                                       ast_str_append(buf, buflen, "%s%s", ast_str_strlen(*buf) ? ds : "", tmp3);
+                                       ast_str_append(buf, buflen, "%s%s", firstfield ? "" : ds, tmp3);
+                                       firstfield = 0;
                                        curfieldnum++;
                                }
                        }