Index: pbx/pbx_config.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_config.c,v retrieving revision 1.43 diff -u -r1.43 pbx_config.c --- pbx/pbx_config.c 21 Jun 2004 14:20:03 -0000 1.43 +++ pbx/pbx_config.c 16 Aug 2004 16:37:34 -0000 @@ -1581,7 +1581,7 @@ struct ast_variable *v; char *cxt, *ext, *pri, *appl, *data, *tc, *cidmatch; struct ast_context *con; - char *start, *end; + char *end, *firstc, *firstp; char realvalue[256]; cfg = ast_load(config); @@ -1632,25 +1632,28 @@ appl = stringp; if (!appl) appl=""; - if (!(start = strchr(appl, '('))) { - if (stringp) - appl = strsep(&stringp, ","); - else - appl = ""; - } - if (start && (end = strrchr(appl, ')'))) { - *start = *end = '\0'; - data = start + 1; - process_quotes_and_slashes(data, ',', '|'); - } else if (stringp!=NULL && *stringp=='"') { - stringp++; - data = strsep(&stringp, "\""); - stringp++; + /* Find the first occurrence of either '(' or ',' */ + firstc = strchr(appl, ','); + firstp = strchr(appl, '('); + if (firstc && ((!firstp) || (firstc < firstp))) { + /* comma found, no parenthesis */ + /* or both found, but comma found first */ + appl = strsep(&stringp, ","); + data = stringp; + } else if ((!firstc) && (!firstp)) { + /* Neither found */ + data = ""; } else { - if (stringp) - data = strsep(&stringp, ","); - else - data = ""; + /* Final remaining case is parenthesis found first */ + appl = strsep(&stringp, "("); + data = stringp; + end = strrchr(data, ')'); + if ((end = strrchr(data, ')'))) { + *end = '\0'; + } else { + ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data); + } + process_quotes_and_slashes(data, ',', '|'); } cidmatch = strchr(ext, '/'); if (cidmatch) {