mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
remove some unnecessary braces
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20170 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -44,7 +44,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
/* Maximum length of any variable */
|
/* Maximum length of any variable */
|
||||||
#define MAXRESULT 1024
|
#define MAXRESULT 1024
|
||||||
|
|
||||||
static char *tdesc = "Cut out information from a string";
|
|
||||||
|
|
||||||
LOCAL_USER_DECL;
|
LOCAL_USER_DECL;
|
||||||
|
|
||||||
@@ -56,14 +55,13 @@ struct sortable_keys {
|
|||||||
static int sort_subroutine(const void *arg1, const void *arg2)
|
static int sort_subroutine(const void *arg1, const void *arg2)
|
||||||
{
|
{
|
||||||
const struct sortable_keys *one=arg1, *two=arg2;
|
const struct sortable_keys *one=arg1, *two=arg2;
|
||||||
if (one->value < two->value) {
|
if (one->value < two->value)
|
||||||
return -1;
|
return -1;
|
||||||
} else if (one->value == two->value) {
|
else if (one->value == two->value)
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#define ERROR_NOARG (-1)
|
#define ERROR_NOARG (-1)
|
||||||
#define ERROR_NOMEM (-2)
|
#define ERROR_NOMEM (-2)
|
||||||
@@ -77,23 +75,20 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
|
|||||||
|
|
||||||
memset(buffer, 0, buflen);
|
memset(buffer, 0, buflen);
|
||||||
|
|
||||||
if (!data) {
|
if (!data)
|
||||||
return ERROR_NOARG;
|
return ERROR_NOARG;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(strings = ast_strdupa(data)))
|
if (!(strings = ast_strdupa(data)))
|
||||||
return ERROR_NOMEM;
|
return ERROR_NOMEM;
|
||||||
|
|
||||||
for (ptrkey = strings; *ptrkey; ptrkey++) {
|
for (ptrkey = strings; *ptrkey; ptrkey++) {
|
||||||
if (*ptrkey == '|') {
|
if (*ptrkey == '|')
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sortable_keys = alloca(count * sizeof(struct sortable_keys));
|
sortable_keys = alloca(count * sizeof(struct sortable_keys));
|
||||||
if (!sortable_keys) {
|
if (!sortable_keys)
|
||||||
return ERROR_NOMEM;
|
return ERROR_NOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
memset(sortable_keys, 0, count * sizeof(struct sortable_keys));
|
memset(sortable_keys, 0, count * sizeof(struct sortable_keys));
|
||||||
|
|
||||||
@@ -105,8 +100,7 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
|
|||||||
count--;
|
count--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*ptrvalue = '\0';
|
*ptrvalue++ = '\0';
|
||||||
ptrvalue++;
|
|
||||||
sortable_keys[count2].key = ptrkey;
|
sortable_keys[count2].key = ptrkey;
|
||||||
sscanf(ptrvalue, "%f", &sortable_keys[count2].value);
|
sscanf(ptrvalue, "%f", &sortable_keys[count2].value);
|
||||||
count2++;
|
count2++;
|
||||||
@@ -158,10 +152,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
|
|||||||
return ERROR_NOMEM;
|
return ERROR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.delimiter[0])
|
d = args.delimiter[0] ? args.delimiter[0] : '-';
|
||||||
d = args.delimiter[0];
|
|
||||||
else
|
|
||||||
d = '-';
|
|
||||||
|
|
||||||
/* String form of the delimiter, for use with strsep(3) */
|
/* String form of the delimiter, for use with strsep(3) */
|
||||||
snprintf(ds, sizeof(ds), "%c", d);
|
snprintf(ds, sizeof(ds), "%c", d);
|
||||||
@@ -170,7 +161,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
|
|||||||
|
|
||||||
if (tmp2) {
|
if (tmp2) {
|
||||||
int curfieldnum = 1;
|
int curfieldnum = 1;
|
||||||
while ((tmp2 != NULL) && (args.field != NULL)) {
|
while (tmp2 != NULL && args.field != NULL) {
|
||||||
char *nextgroup = strsep(&(args.field), "&");
|
char *nextgroup = strsep(&(args.field), "&");
|
||||||
int num1 = 0, num2 = MAXRESULT;
|
int num1 = 0, num2 = MAXRESULT;
|
||||||
char trashchar;
|
char trashchar;
|
||||||
@@ -192,31 +183,29 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
|
|||||||
|
|
||||||
/* Get to start, if any */
|
/* Get to start, if any */
|
||||||
if (num1 > 0) {
|
if (num1 > 0) {
|
||||||
while ((tmp2 != (char *)NULL + 1) && (curfieldnum < num1)) {
|
while (tmp2 != (char *)NULL + 1 && curfieldnum < num1) {
|
||||||
tmp2 = index(tmp2, d) + 1;
|
tmp2 = index(tmp2, d) + 1;
|
||||||
curfieldnum++;
|
curfieldnum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Most frequent problem is the expectation of reordering fields */
|
/* Most frequent problem is the expectation of reordering fields */
|
||||||
if ((num1 > 0) && (curfieldnum > num1)) {
|
if ((num1 > 0) && (curfieldnum > num1))
|
||||||
ast_log(LOG_WARNING, "We're already past the field you wanted?\n");
|
ast_log(LOG_WARNING, "We're already past the field you wanted?\n");
|
||||||
}
|
|
||||||
|
|
||||||
/* Re-null tmp2 if we added 1 to NULL */
|
/* Re-null tmp2 if we added 1 to NULL */
|
||||||
if (tmp2 == (char *)NULL + 1)
|
if (tmp2 == (char *)NULL + 1)
|
||||||
tmp2 = NULL;
|
tmp2 = NULL;
|
||||||
|
|
||||||
/* Output fields until we either run out of fields or num2 is reached */
|
/* Output fields until we either run out of fields or num2 is reached */
|
||||||
while ((tmp2 != NULL) && (curfieldnum <= num2)) {
|
while (tmp2 != NULL && curfieldnum <= num2) {
|
||||||
char *tmp3 = strsep(&tmp2, ds);
|
char *tmp3 = strsep(&tmp2, ds);
|
||||||
int curlen = strlen(buffer);
|
int curlen = strlen(buffer);
|
||||||
|
|
||||||
if (curlen) {
|
if (curlen)
|
||||||
snprintf(buffer + curlen, buflen - curlen, "%c%s", d, tmp3);
|
snprintf(buffer + curlen, buflen - curlen, "%c%s", d, tmp3);
|
||||||
} else {
|
else
|
||||||
snprintf(buffer, buflen, "%s", tmp3);
|
snprintf(buffer, buflen, "%s", tmp3);
|
||||||
}
|
|
||||||
|
|
||||||
curfieldnum++;
|
curfieldnum++;
|
||||||
}
|
}
|
||||||
@@ -327,7 +316,7 @@ static int load_module(void *mod)
|
|||||||
|
|
||||||
static const char *description(void)
|
static const char *description(void)
|
||||||
{
|
{
|
||||||
return tdesc;
|
return "Cut out information from a string";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *key(void)
|
static const char *key(void)
|
||||||
|
Reference in New Issue
Block a user