mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-24 22:58:21 +00:00
- move the string join() function to utils.c since it is used in both cli.c and res_agi.c
- reimplement ast_join to be of linear effieciency instead of quadratic - remove some useless checks for "if (e)" - reorder checks for strings starting with '_' to avoid a useless call to ast_join() - check array bounds when parsing arguments to AGI (issue #5868) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7556 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
19
utils.c
19
utils.c
@@ -903,3 +903,22 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
|
||||
*dataPut = 0;
|
||||
return dataPut;
|
||||
}
|
||||
|
||||
void ast_join(char *s, size_t len, char * const w[])
|
||||
{
|
||||
int x, ofs = 0;
|
||||
const char *src;
|
||||
|
||||
/* Join words into a string */
|
||||
if (!s)
|
||||
return;
|
||||
for (x=0; ofs < len && w[x]; x++) {
|
||||
if (x > 0)
|
||||
s[ofs++] = ' ';
|
||||
for (src = w[x]; *src && ofs < len; src++)
|
||||
s[ofs++] = *src;
|
||||
}
|
||||
if (ofs == len)
|
||||
ofs--;
|
||||
s[ofs] = '\0';
|
||||
}
|
||||
|
Reference in New Issue
Block a user