Merged revisions 57426 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r57426 | murf | 2007-03-01 22:21:36 -0700 (Thu, 01 Mar 2007) | 1 line I almost had comma escapes right, but 9184 points out the problem-- the escape is removed by pbx_config, and pbx_ael should also, before sending it down into the pbx engine. Also, you have to insert it back in, if you are generating extensions.conf code from the AEL. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@57438 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
9802426219
commit
91a9b97a73
|
@ -155,11 +155,19 @@ static void substitute_commas(char *str);
|
||||||
static void substitute_commas(char *str)
|
static void substitute_commas(char *str)
|
||||||
{
|
{
|
||||||
char *p = str;
|
char *p = str;
|
||||||
|
|
||||||
while (p && *p)
|
while (p && *p)
|
||||||
{
|
{
|
||||||
if (*p == ',' && ((p != str && *(p-1) != '\\')
|
if (*p == ',' && ((p != str && *(p-1) != '\\')
|
||||||
|| p == str))
|
|| p == str))
|
||||||
*p = '|';
|
*p = '|';
|
||||||
|
if (*p == '\\' && *(p+1) == ',') { /* learning experience: the '\,' is turned into just ',' by pbx_config; So we need to do the same */
|
||||||
|
char *q = p;
|
||||||
|
while (*q) { /* move the ',' and everything after it up 1 char */
|
||||||
|
*q = *(q+1);
|
||||||
|
q++;
|
||||||
|
}
|
||||||
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,8 @@ int ast_add_extension2(struct ast_context *con,
|
||||||
|
|
||||||
if( dump_extensions && dumpfile ) {
|
if( dump_extensions && dumpfile ) {
|
||||||
struct namelist *n;
|
struct namelist *n;
|
||||||
|
char *data2,*data3=0;
|
||||||
|
int commacount = 0;
|
||||||
|
|
||||||
if( FIRST_TIME ) {
|
if( FIRST_TIME ) {
|
||||||
FIRST_TIME = 0;
|
FIRST_TIME = 0;
|
||||||
|
@ -215,11 +217,43 @@ int ast_add_extension2(struct ast_context *con,
|
||||||
filter_newlines((char*)data);
|
filter_newlines((char*)data);
|
||||||
filter_leading_space_from_exprs((char*)data);
|
filter_leading_space_from_exprs((char*)data);
|
||||||
|
|
||||||
|
/* compiling turns commas into vertical bars in the app data, and also removes the backslash from before escaped commas;
|
||||||
|
we have to restore the escaping backslash in front of any commas; the vertical bars are OK to leave as-is */
|
||||||
|
for (data2 = data; *data2; data2++) {
|
||||||
|
if (*data2 == ',')
|
||||||
|
commacount++; /* we need to know how much bigger the string will grow-- one backslash for each comma */
|
||||||
|
}
|
||||||
|
if (commacount)
|
||||||
|
{
|
||||||
|
char *d3,*d4;
|
||||||
|
|
||||||
|
data2 = (char*)malloc(strlen(data)+commacount+1);
|
||||||
|
data3 = data;
|
||||||
|
d3 = data;
|
||||||
|
d4 = data2;
|
||||||
|
while (*d3) {
|
||||||
|
if (*d3 == ',') {
|
||||||
|
*d4++ = '\\'; /* put a backslash in front of each comma */
|
||||||
|
*d4++ = *d3++;
|
||||||
|
} else
|
||||||
|
*d4++ = *d3++; /* or just copy the char */
|
||||||
|
}
|
||||||
|
*d4++ = 0; /* cap off the new string */
|
||||||
|
data = data2;
|
||||||
|
} else
|
||||||
|
data2 = 0;
|
||||||
|
|
||||||
if( strcmp(label,"(null)") != 0 )
|
if( strcmp(label,"(null)") != 0 )
|
||||||
fprintf(dumpfile,"exten => %s,%d(%s),%s(%s)\n", extension, priority, label, application, (char*)data);
|
fprintf(dumpfile,"exten => %s,%d(%s),%s(%s)\n", extension, priority, label, application, (char*)data);
|
||||||
else
|
else
|
||||||
fprintf(dumpfile,"exten => %s,%d,%s(%s)\n", extension, priority, application, (char*)data);
|
fprintf(dumpfile,"exten => %s,%d,%s(%s)\n", extension, priority, application, (char*)data);
|
||||||
|
|
||||||
|
if (data2) {
|
||||||
|
free(data2);
|
||||||
|
data2 = 0;
|
||||||
|
data = data3; /* restore data to pre-messedup state */
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if( strcmp(label,"(null)") != 0 )
|
if( strcmp(label,"(null)") != 0 )
|
||||||
|
|
Loading…
Reference in New Issue