Modifications to allow the output of SHELL() to be split per line (Issue 8676)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49786 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2007-01-07 14:44:49 +00:00
parent 6b13c4d7d4
commit 785483f304
3 changed files with 25 additions and 3 deletions

View File

@@ -131,7 +131,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
AST_STANDARD_APP_ARGS(args, parse);
/* Check and parse arguments */
if(args.argc < 3){
if (args.argc < 3) {
return ERROR_NOARG;
} else {
char d, ds[2];
@@ -145,7 +145,19 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
return ERROR_NOMEM;
}
d = args.delimiter[0] ? args.delimiter[0] : '-';
if (args.delimiter[0] == '\\') {
if (args.delimiter[1] == 'n')
d = '\n';
else if (args.delimiter[1] == 't')
d = '\t';
else if (args.delimiter[1])
d = args.delimiter[1];
else
d = '-';
} else if (args.delimiter[0])
d = args.delimiter[0];
else
d = '-';
/* String form of the delimiter, for use with strsep(3) */
snprintf(ds, sizeof(ds), "%c", d);