<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19316">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">say: Don't prepend ampersand erroneously.<br><br>Some logic in say.c for determining if we need<br>to also add an ampersand for file seperation was faulty,<br>as non-successful files would increment the count, causing<br>a leading ampersand to be added improperly.<br><br>This is fixed, and a unit test that captures this regression<br>is also added.<br><br>ASTERISK-30248 #close<br><br>Change-Id: I02c1d3a11d82fe4ea8b462070cbd1effb5834d2b<br>---<br>M funcs/func_sayfiles.c<br>M main/say.c<br>2 files changed, 34 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/16/19316/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/funcs/func_sayfiles.c b/funcs/func_sayfiles.c</span><br><span>index d3f3341..7e0ece2 100644</span><br><span>--- a/funcs/func_sayfiles.c</span><br><span>+++ b/funcs/func_sayfiles.c</span><br><span>@@ -211,6 +211,15 @@</span><br><span> res = AST_TEST_FAIL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* + should be ignored and there should not be a leading & */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_set(&expr, 0, "${SAYFILES(+18005551212,digits)}");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strcmp(ast_str_buffer(result), "digits/1&digits/8&digits/0&digits/0&digits/5&digits/5&digits/5&digits/1&digits/2&digits/1&digits/2") != 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_test_status_update(test, "SAYFILES(+18005551212,digits) test failed ('%s')\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_buffer(result));</span><br><span style="color: hsl(120, 100%, 40%);">+ res = AST_TEST_FAIL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_str_set(&expr, 0, "${SAYFILES(35,number)}");</span><br><span> ast_str_substitute_variables(&result, 0, NULL, ast_str_buffer(expr));</span><br><span> if (strcmp(ast_str_buffer(result), "digits/30&digits/5") != 0) {</span><br><span>diff --git a/main/say.c b/main/say.c</span><br><span>index b60d4bf..e9fc5c4 100644</span><br><span>--- a/main/say.c</span><br><span>+++ b/main/say.c</span><br><span>@@ -64,7 +64,7 @@</span><br><span> const char *fn;</span><br><span> char fnbuf[10], asciibuf[20] = "letters/ascii";</span><br><span> char ltr;</span><br><span style="color: hsl(0, 100%, 40%);">- int num = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int outnum = 0, num = 0;</span><br><span> int res = 0;</span><br><span> int upper = 0;</span><br><span> int lower = 0;</span><br><span>@@ -160,7 +160,7 @@</span><br><span> }</span><br><span> if ((fn && ast_fileexists(fn, NULL, lang) > 0) ||</span><br><span> (snprintf(asciibuf + 13, sizeof(asciibuf) - 13, "%d", str[num]) > 0 && ast_fileexists(asciibuf, NULL, lang) > 0 && (fn = asciibuf))) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&filenames, 0, (num == 0 ? "%s" : "&%s"), fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&filenames, 0, (outnum++ == 0 ? "%s" : "&%s"), fn);</span><br><span> }</span><br><span> if (upper || lower) {</span><br><span> continue;</span><br><span>@@ -217,7 +217,7 @@</span><br><span> const char *fn;</span><br><span> char fnbuf[256];</span><br><span> char ltr;</span><br><span style="color: hsl(0, 100%, 40%);">- int num = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int outnum = 0, num = 0;</span><br><span> </span><br><span> struct ast_str *filenames = ast_str_create(20);</span><br><span> if (!filenames) {</span><br><span>@@ -282,7 +282,7 @@</span><br><span> fn = fnbuf;</span><br><span> }</span><br><span> if (fn && ast_fileexists(fn, NULL, lang) > 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&filenames, 0, (num == 0 ? "%s" : "&%s"), fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&filenames, 0, (outnum++ == 0 ? "%s" : "&%s"), fn);</span><br><span> }</span><br><span> num++;</span><br><span> }</span><br><span>@@ -300,7 +300,7 @@</span><br><span> {</span><br><span> const char *fn;</span><br><span> char fnbuf[256];</span><br><span style="color: hsl(0, 100%, 40%);">- int num = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int outnum = 0, num = 0;</span><br><span> </span><br><span> struct ast_str *filenames = ast_str_create(20);</span><br><span> if (!filenames) {</span><br><span>@@ -336,7 +336,7 @@</span><br><span> break;</span><br><span> }</span><br><span> if (fn && ast_fileexists(fn, NULL, lang) > 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&filenames, 0, (num == 0 ? "%s" : "&%s"), fn);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&filenames, 0, (outnum++ == 0 ? "%s" : "&%s"), fn);</span><br><span> }</span><br><span> num++;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19316">change 19316</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19316"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I02c1d3a11d82fe4ea8b462070cbd1effb5834d2b </div>
<div style="display:none"> Gerrit-Change-Number: 19316 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>