Simplify function parameters.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15639 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2007-02-21 06:59:50 +00:00
parent 43277fef39
commit 88456c2b3c
4 changed files with 26 additions and 23 deletions

View File

@ -996,20 +996,20 @@ static int revorder[NUM_ACCOUNT_TYPES] = {
int int
xaccAccountOrder (const Account **aa, const Account **ab) xaccAccountOrder (const Account *aa, const Account *ab)
{ {
char *da, *db; char *da, *db;
char *endptr = NULL; char *endptr = NULL;
int ta, tb, result; int ta, tb, result;
long la, lb; long la, lb;
if ( (*aa) && !(*ab) ) return -1; if ( aa && !ab ) return -1;
if ( !(*aa) && (*ab) ) return +1; if ( !aa && ab ) return +1;
if ( !(*aa) && !(*ab) ) return 0; if ( !aa && !ab ) return 0;
/* sort on accountCode strings */ /* sort on accountCode strings */
da = (*aa)->accountCode; da = aa->accountCode;
db = (*ab)->accountCode; db = ab->accountCode;
/* If accountCodes are both base 36 integers do an integer sort */ /* If accountCodes are both base 36 integers do an integer sort */
la = strtoul (da, &endptr, 36); la = strtoul (da, &endptr, 36);
@ -1036,22 +1036,28 @@ xaccAccountOrder (const Account **aa, const Account **ab)
} }
/* otherwise, sort on account type */ /* otherwise, sort on account type */
ta = (*aa)->type; ta = aa->type;
tb = (*ab)->type; tb = ab->type;
ta = revorder[ta]; ta = revorder[ta];
tb = revorder[tb]; tb = revorder[tb];
if (ta < tb) return -1; if (ta < tb) return -1;
if (ta > tb) return +1; if (ta > tb) return +1;
/* otherwise, sort on accountName strings */ /* otherwise, sort on accountName strings */
da = (*aa)->accountName; da = aa->accountName;
db = (*ab)->accountName; db = ab->accountName;
result = safe_utf8_collate(da, db); result = safe_utf8_collate(da, db);
if (result) if (result)
return result; return result;
/* guarantee a stable sort */ /* guarantee a stable sort */
return guid_compare (&((*aa)->inst.entity.guid), &((*ab)->inst.entity.guid)); return guid_compare (&(aa->inst.entity.guid), &(ab->inst.entity.guid));
}
static int
qof_xaccAccountOrder (const Account **aa, const Account **ab)
{
return xaccAccountOrder(*aa, *ab);
} }
/********************************************************************\ /********************************************************************\
@ -2717,7 +2723,7 @@ gboolean xaccAccountRegister (void)
{ NULL }, { NULL },
}; };
qof_class_register (GNC_ID_ACCOUNT, (QofSortFunc) xaccAccountOrder, params); qof_class_register (GNC_ID_ACCOUNT, (QofSortFunc) qof_xaccAccountOrder, params);
return qof_object_register (&account_object_def); return qof_object_register (&account_object_def);
} }

View File

@ -188,7 +188,7 @@ gboolean xaccAccountEqual(const Account *a, const Account* b,
* the account codes are compared, and if these are equal, then * the account codes are compared, and if these are equal, then
* account types, and, if these are equal, the account names. * account types, and, if these are equal, the account names.
*/ */
int xaccAccountOrder (const Account **account_1, const Account **account_2); int xaccAccountOrder (const Account *account_1, const Account *account_2);
/** @} */ /** @} */

View File

@ -421,12 +421,9 @@ xaccGroupGetSubAccounts (const AccountGroup *grp)
static int static int
group_sort_helper (gconstpointer a, gconstpointer b) group_sort_helper (gconstpointer a, gconstpointer b)
{ {
const Account *aa = (const Account *) a; /* xaccAccountOrder returns > 1 if a should come after b.
const Account *bb = (const Account *) b;
/* xaccAccountOrder returns > 1 if aa should come after bb.
* This funciton is building a reversed list. */ * This funciton is building a reversed list. */
return xaccAccountOrder (&aa, &bb); return xaccAccountOrder ((const Account *) a, (const Account *) b);
} }
static void static void

View File

@ -286,7 +286,7 @@ sort_by_string (GtkTreeModel *f_model,
result = safe_utf8_collate(str1, str2); result = safe_utf8_collate(str1, str2);
if (result != 0) if (result != 0)
return result; return result;
return xaccAccountOrder(&account1, &account2); return xaccAccountOrder(account1, account2);
} }
static gint static gint
@ -300,7 +300,7 @@ sort_by_code (GtkTreeModel *f_model,
sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b); sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
/* Default ordering uses this column first. */ /* Default ordering uses this column first. */
return xaccAccountOrder(&account_a, &account_b); return xaccAccountOrder(account_a, account_b);
} }
static gint static gint
@ -325,7 +325,7 @@ sort_by_xxx_value (xaccGetBalanceInCurrencyFn fn,
result = gnc_numeric_compare(balance_a, balance_b); result = gnc_numeric_compare(balance_a, balance_b);
if (result != 0) if (result != 0)
return result; return result;
return xaccAccountOrder(&account_a, &account_b); return xaccAccountOrder(account_a, account_b);
} }
static gint static gint
@ -408,7 +408,7 @@ sort_by_placeholder (GtkTreeModel *f_model,
return -1; return -1;
else if (flag_a < flag_b) else if (flag_a < flag_b)
return 1; return 1;
return xaccAccountOrder(&account_a, &account_b); return xaccAccountOrder(account_a, account_b);
} }
static gint static gint
@ -434,7 +434,7 @@ sort_by_xxx_period_value (GtkTreeModel *f_model,
result = gnc_numeric_compare(b1, b2); result = gnc_numeric_compare(b1, b2);
if (result != 0) if (result != 0)
return result; return result;
return xaccAccountOrder((const Account **)&acct1, (const Account **)&acct2); return xaccAccountOrder(acct1, acct2);
} }
static gint static gint