[asterisk-commits] tilghman: trunk r336790 - in /trunk: ./ funcs/func_strings.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 19 16:42:12 CDT 2011


Author: tilghman
Date: Mon Sep 19 16:42:11 2011
New Revision: 336790

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=336790
Log:
Merged revisions 336789 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/10

........
  r336789 | tilghman | 2011-09-19 16:41:16 -0500 (Mon, 19 Sep 2011) | 2 lines
  
  Ensure substring will not be found in the previous match.
........

Modified:
    trunk/   (props changed)
    trunk/funcs/func_strings.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_strings.c?view=diff&rev=336790&r1=336789&r2=336790
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Mon Sep 19 16:42:11 2011
@@ -923,7 +923,8 @@
 	for (x = 0; x < max_matches; x++) {
 		if ((p = strstr(p, args.find_string))) {
 			starts[count_len++] = p;
-			*p++ = '\0';
+			*p = '\0';
+			p += find_size;
 		} else {
 			break;
 		}
@@ -933,12 +934,12 @@
 
 	/* here we rebuild the string with the replaced words by using fancy ast_string_append on the buffer */
 	for (x = 0; x < count_len; x++) {
-		ast_str_append(buf, 0, "%s", p);
+		ast_str_append(buf, len, "%s", p);
 		p = starts[x];
 		p += find_size;
-		ast_str_append(buf, 0, "%s", args.replace_string);
-	}
-	ast_str_append(buf, 0, "%s", p);
+		ast_str_append(buf, len, "%s", args.replace_string);
+	}
+	ast_str_append(buf, len, "%s", p);
 
 	return 0;
 }
@@ -1762,6 +1763,7 @@
 	const char *test_strings[][5] = {
 		{"Weasels have eaten my telephone system", "have eaten my", "are eating our", "", "Weasels are eating our telephone system"}, /*Test normal conditions */
 		{"Did you know twenty plus two is twenty-two?", "twenty", "thirty", NULL, "Did you know thirty plus two is thirty-two?"}, /* Test no third comma */
+		{"foofoofoofoofoofoofoo", "foofoo", "bar", NULL, "barbarbarfoo"}, /* Found string within previous match */
 		{"My pet dog once ate a dog who sat on a dog while eating a corndog.", "dog", "cat", "3", "My pet cat once ate a cat who sat on a cat while eating a corndog."},
 		{"One and one and one is three", "and", "plus", "1", "One plus one and one is three"}, /* Test <max-replacements> = 1*/
 		{"", "fhqwagads", "spelunker", NULL, ""}, /* Empty primary string */




More information about the asterisk-commits mailing list