mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Use const return values for string cache
This is a prerequisite for being able to return "" (which is const) and none of the returned values should ever be modified.
This commit is contained in:
parent
e1c153a516
commit
320df7e409
@ -241,9 +241,9 @@ add_event_type (ComponentEventInfo *cei, QofIdTypeConst entity_type,
|
|||||||
mask = g_hash_table_lookup (cei->event_masks, entity_type);
|
mask = g_hash_table_lookup (cei->event_masks, entity_type);
|
||||||
if (!mask)
|
if (!mask)
|
||||||
{
|
{
|
||||||
char * key = qof_string_cache_insert ((gpointer) entity_type);
|
const char * key = qof_string_cache_insert ((gpointer) entity_type);
|
||||||
mask = g_new0 (QofEventId, 1);
|
mask = g_new0 (QofEventId, 1);
|
||||||
g_hash_table_insert (cei->event_masks, key, mask);
|
g_hash_table_insert (cei->event_masks, (gpointer)key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or_in)
|
if (or_in)
|
||||||
|
@ -317,9 +317,9 @@ gnc_account_init(Account* acc)
|
|||||||
priv->parent = NULL;
|
priv->parent = NULL;
|
||||||
priv->children = NULL;
|
priv->children = NULL;
|
||||||
|
|
||||||
priv->accountName = static_cast<char*>(qof_string_cache_insert(""));
|
priv->accountName = qof_string_cache_insert("");
|
||||||
priv->accountCode = static_cast<char*>(qof_string_cache_insert(""));
|
priv->accountCode = qof_string_cache_insert("");
|
||||||
priv->description = static_cast<char*>(qof_string_cache_insert(""));
|
priv->description = qof_string_cache_insert("");
|
||||||
|
|
||||||
priv->type = ACCT_TYPE_NONE;
|
priv->type = ACCT_TYPE_NONE;
|
||||||
|
|
||||||
@ -1265,9 +1265,9 @@ xaccCloneAccount(const Account *from, QofBook *book)
|
|||||||
* Also let caller issue the generate_event (EVENT_CREATE) */
|
* Also let caller issue the generate_event (EVENT_CREATE) */
|
||||||
priv->type = from_priv->type;
|
priv->type = from_priv->type;
|
||||||
|
|
||||||
priv->accountName = static_cast<char*>(qof_string_cache_insert(from_priv->accountName));
|
priv->accountName = qof_string_cache_replace(priv->accountName, from_priv->accountName);
|
||||||
priv->accountCode = static_cast<char*>(qof_string_cache_insert(from_priv->accountCode));
|
priv->accountCode = qof_string_cache_replace(priv->accountCode, from_priv->accountCode);
|
||||||
priv->description = static_cast<char*>(qof_string_cache_insert(from_priv->description));
|
priv->description = qof_string_cache_replace(priv->description, from_priv->description);
|
||||||
|
|
||||||
qof_instance_copy_kvp (QOF_INSTANCE (ret), QOF_INSTANCE (from));
|
qof_instance_copy_kvp (QOF_INSTANCE (ret), QOF_INSTANCE (from));
|
||||||
|
|
||||||
@ -2327,7 +2327,7 @@ int
|
|||||||
xaccAccountOrder (const Account *aa, const Account *ab)
|
xaccAccountOrder (const Account *aa, const Account *ab)
|
||||||
{
|
{
|
||||||
AccountPrivate *priv_aa, *priv_ab;
|
AccountPrivate *priv_aa, *priv_ab;
|
||||||
char *da, *db;
|
const char *da, *db;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
int ta, tb, result;
|
int ta, tb, result;
|
||||||
long la, lb;
|
long la, lb;
|
||||||
@ -3264,7 +3264,7 @@ gnc_account_get_full_name(const Account *account)
|
|||||||
AccountPrivate *priv;
|
AccountPrivate *priv;
|
||||||
const Account *a;
|
const Account *a;
|
||||||
char *fullname;
|
char *fullname;
|
||||||
gchar **names;
|
const gchar **names;
|
||||||
int level;
|
int level;
|
||||||
|
|
||||||
/* So much for hardening the API. Too many callers to this function don't
|
/* So much for hardening the API. Too many callers to this function don't
|
||||||
@ -3291,7 +3291,7 @@ gnc_account_get_full_name(const Account *account)
|
|||||||
|
|
||||||
/* Get all the pointers in the right order. The root node "entry"
|
/* Get all the pointers in the right order. The root node "entry"
|
||||||
* becomes the terminating NULL pointer for the array of strings. */
|
* becomes the terminating NULL pointer for the array of strings. */
|
||||||
names = (gchar **)g_malloc(level * sizeof(gchar *));
|
names = (const gchar **)g_malloc(level * sizeof(gchar *));
|
||||||
names[--level] = NULL;
|
names[--level] = NULL;
|
||||||
for (a = account; level > 0; a = priv->parent)
|
for (a = account; level > 0; a = priv->parent)
|
||||||
{
|
{
|
||||||
@ -3300,7 +3300,7 @@ gnc_account_get_full_name(const Account *account)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build the full name */
|
/* Build the full name */
|
||||||
fullname = g_strjoinv(account_separator, names);
|
fullname = g_strjoinv(account_separator, (gchar **)names);
|
||||||
g_free(names);
|
g_free(names);
|
||||||
|
|
||||||
return fullname;
|
return fullname;
|
||||||
|
@ -62,7 +62,7 @@ typedef struct AccountPrivate
|
|||||||
* It is intended to a short, 5 to 30 character long string that
|
* It is intended to a short, 5 to 30 character long string that
|
||||||
* is displayed by the GUI as the account mnemonic.
|
* is displayed by the GUI as the account mnemonic.
|
||||||
*/
|
*/
|
||||||
char *accountName;
|
const char *accountName;
|
||||||
|
|
||||||
/* The accountCode is an arbitrary string assigned by the user.
|
/* The accountCode is an arbitrary string assigned by the user.
|
||||||
* It is intended to be reporting code that is a synonym for the
|
* It is intended to be reporting code that is a synonym for the
|
||||||
@ -71,13 +71,13 @@ typedef struct AccountPrivate
|
|||||||
* as 100, 200 or 600 for top-level accounts, and 101, 102.. etc.
|
* as 100, 200 or 600 for top-level accounts, and 101, 102.. etc.
|
||||||
* for detail accounts.
|
* for detail accounts.
|
||||||
*/
|
*/
|
||||||
char *accountCode;
|
const char *accountCode;
|
||||||
|
|
||||||
/* The description is an arbitrary string assigned by the user.
|
/* The description is an arbitrary string assigned by the user.
|
||||||
* It is intended to be a longer, 1-5 sentence description of what
|
* It is intended to be a longer, 1-5 sentence description of what
|
||||||
* this account is all about.
|
* this account is all about.
|
||||||
*/
|
*/
|
||||||
char *description;
|
const char *description;
|
||||||
|
|
||||||
/* The type field is the account type, picked from the enumerated
|
/* The type field is the account type, picked from the enumerated
|
||||||
* list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
|
* list that includes ACCT_TYPE_BANK, ACCT_TYPE_STOCK,
|
||||||
|
@ -1495,7 +1495,7 @@ xaccSplitOrder (const Split *sa, const Split *sb)
|
|||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
int comp;
|
int comp;
|
||||||
char *da, *db;
|
const char *da, *db;
|
||||||
gboolean action_for_num;
|
gboolean action_for_num;
|
||||||
|
|
||||||
if (sa == sb) return 0;
|
if (sa == sb) return 0;
|
||||||
|
@ -83,7 +83,7 @@ struct split_s
|
|||||||
* It is intended to hold a short (zero to forty character) string
|
* It is intended to hold a short (zero to forty character) string
|
||||||
* that is displayed by the GUI along with this split.
|
* that is displayed by the GUI along with this split.
|
||||||
*/
|
*/
|
||||||
char * memo;
|
const char *memo;
|
||||||
|
|
||||||
/* The action field is an arbitrary user-assigned value.
|
/* The action field is an arbitrary user-assigned value.
|
||||||
* It is meant to be a very short (one to ten character) string that
|
* It is meant to be a very short (one to ten character) string that
|
||||||
@ -91,7 +91,7 @@ struct split_s
|
|||||||
* Withdraw, Deposit, ATM, Check, etc. The idea is that this field
|
* Withdraw, Deposit, ATM, Check, etc. The idea is that this field
|
||||||
* can be used to create custom reports or graphs of data.
|
* can be used to create custom reports or graphs of data.
|
||||||
*/
|
*/
|
||||||
char * action; /* Buy, Sell, Div, etc. */
|
const char *action; /* Buy, Sell, Div, etc. */
|
||||||
|
|
||||||
time64 date_reconciled; /* date split was reconciled */
|
time64 date_reconciled; /* date split was reconciled */
|
||||||
char reconciled; /* The reconciled field */
|
char reconciled; /* The reconciled field */
|
||||||
|
@ -1699,6 +1699,7 @@ xaccTransCommitEdit (Transaction *trans)
|
|||||||
LEAVE ("(trans=%p)", trans);
|
LEAVE ("(trans=%p)", trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SWAP_STR(a, b) do { const char *tmp = (a); (a) = (b); (b) = tmp; } while (0);
|
||||||
#define SWAP(a, b) do { gpointer tmp = (a); (a) = (b); (b) = tmp; } while (0);
|
#define SWAP(a, b) do { gpointer tmp = (a); (a) = (b); (b) = tmp; } while (0);
|
||||||
|
|
||||||
/* Ughhh. The Rollback function is terribly complex, and, what's worse,
|
/* Ughhh. The Rollback function is terribly complex, and, what's worse,
|
||||||
@ -1738,8 +1739,8 @@ xaccTransRollbackEdit (Transaction *trans)
|
|||||||
/* copy the original values back in. */
|
/* copy the original values back in. */
|
||||||
|
|
||||||
orig = trans->orig;
|
orig = trans->orig;
|
||||||
SWAP(trans->num, orig->num);
|
SWAP_STR(trans->num, orig->num);
|
||||||
SWAP(trans->description, orig->description);
|
SWAP_STR(trans->description, orig->description);
|
||||||
trans->date_entered = orig->date_entered;
|
trans->date_entered = orig->date_entered;
|
||||||
trans->date_posted = orig->date_posted;
|
trans->date_posted = orig->date_posted;
|
||||||
SWAP(trans->common_currency, orig->common_currency);
|
SWAP(trans->common_currency, orig->common_currency);
|
||||||
@ -1766,8 +1767,8 @@ xaccTransRollbackEdit (Transaction *trans)
|
|||||||
Split *so = onode->data;
|
Split *so = onode->data;
|
||||||
|
|
||||||
xaccSplitRollbackEdit(s);
|
xaccSplitRollbackEdit(s);
|
||||||
SWAP(s->action, so->action);
|
SWAP_STR(s->action, so->action);
|
||||||
SWAP(s->memo, so->memo);
|
SWAP_STR(s->memo, so->memo);
|
||||||
qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so));
|
qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so));
|
||||||
s->reconciled = so->reconciled;
|
s->reconciled = so->reconciled;
|
||||||
s->amount = so->amount;
|
s->amount = so->amount;
|
||||||
@ -1915,7 +1916,7 @@ int
|
|||||||
xaccTransOrder_num_action (const Transaction *ta, const char *actna,
|
xaccTransOrder_num_action (const Transaction *ta, const char *actna,
|
||||||
const Transaction *tb, const char *actnb)
|
const Transaction *tb, const char *actnb)
|
||||||
{
|
{
|
||||||
char *da, *db;
|
const char *da, *db;
|
||||||
int retval;
|
int retval;
|
||||||
int64_t na, nb;
|
int64_t na, nb;
|
||||||
|
|
||||||
|
@ -82,12 +82,12 @@ struct transaction_s
|
|||||||
* It is intended to store a short id number, typically the check number,
|
* It is intended to store a short id number, typically the check number,
|
||||||
* deposit number, invoice number or other tracking number.
|
* deposit number, invoice number or other tracking number.
|
||||||
*/
|
*/
|
||||||
char * num;
|
const char *num;
|
||||||
|
|
||||||
/* The description field is an arbitrary user-assigned value.
|
/* The description field is an arbitrary user-assigned value.
|
||||||
* It is meant to be a short descriptive phrase.
|
* It is meant to be a short descriptive phrase.
|
||||||
*/
|
*/
|
||||||
char * description;
|
const char *description;
|
||||||
|
|
||||||
/* The common_currency field is the balancing common currency for
|
/* The common_currency field is the balancing common currency for
|
||||||
* all the splits in the transaction. Alternate, better(?) name:
|
* all the splits in the transaction. Alternate, better(?) name:
|
||||||
|
@ -61,10 +61,10 @@ typedef struct
|
|||||||
typedef struct GncBudgetPrivate
|
typedef struct GncBudgetPrivate
|
||||||
{
|
{
|
||||||
/* The name is an arbitrary string assigned by the user. */
|
/* The name is an arbitrary string assigned by the user. */
|
||||||
gchar* name;
|
const gchar *name;
|
||||||
|
|
||||||
/* The description is an arbitrary string assigned by the user. */
|
/* The description is an arbitrary string assigned by the user. */
|
||||||
gchar* description;
|
const gchar *description;
|
||||||
|
|
||||||
/* Recurrence (period info) for the budget */
|
/* Recurrence (period info) for the budget */
|
||||||
Recurrence recurrence;
|
Recurrence recurrence;
|
||||||
|
@ -70,23 +70,23 @@ typedef struct gnc_commodityPrivate
|
|||||||
{
|
{
|
||||||
gnc_commodity_namespace *name_space;
|
gnc_commodity_namespace *name_space;
|
||||||
|
|
||||||
char * fullname;
|
const char *fullname;
|
||||||
char * mnemonic;
|
const char *mnemonic;
|
||||||
char * printname;
|
char *printname;
|
||||||
char * cusip; /* CUSIP or other identifying code */
|
const char *cusip; /* CUSIP or other identifying code */
|
||||||
int fraction;
|
int fraction;
|
||||||
char * unique_name;
|
char *unique_name;
|
||||||
|
|
||||||
gboolean quote_flag; /* user wants price quotes */
|
gboolean quote_flag; /* user wants price quotes */
|
||||||
gnc_quote_source * quote_source; /* current/old source of quotes */
|
gnc_quote_source *quote_source; /* current/old source of quotes */
|
||||||
char * quote_tz;
|
const char *quote_tz;
|
||||||
|
|
||||||
/* the number of accounts using this commodity - this field is not
|
/* the number of accounts using this commodity - this field is not
|
||||||
* persisted */
|
* persisted */
|
||||||
int usage_count;
|
int usage_count;
|
||||||
|
|
||||||
/* the default display_symbol, set in iso-4217-currencies at start-up */
|
/* the default display_symbol, set in iso-4217-currencies at start-up */
|
||||||
const char * default_symbol;
|
const char *default_symbol;
|
||||||
} gnc_commodityPrivate;
|
} gnc_commodityPrivate;
|
||||||
|
|
||||||
#define GET_PRIVATE(o) \
|
#define GET_PRIVATE(o) \
|
||||||
@ -104,7 +104,7 @@ struct gnc_commodity_namespace_s
|
|||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
|
|
||||||
gchar * name;
|
const gchar *name;
|
||||||
gboolean iso4217;
|
gboolean iso4217;
|
||||||
GHashTable * cm_table;
|
GHashTable * cm_table;
|
||||||
GList * cm_list;
|
GList * cm_list;
|
||||||
@ -1997,7 +1997,7 @@ gnc_commodity_table_insert(gnc_commodity_table * table,
|
|||||||
PINFO ("insert %p %s into nsp=%p %s", priv->mnemonic, priv->mnemonic,
|
PINFO ("insert %p %s into nsp=%p %s", priv->mnemonic, priv->mnemonic,
|
||||||
nsp->cm_table, nsp->name);
|
nsp->cm_table, nsp->name);
|
||||||
g_hash_table_insert(nsp->cm_table,
|
g_hash_table_insert(nsp->cm_table,
|
||||||
CACHE_INSERT(priv->mnemonic),
|
(gpointer)CACHE_INSERT(priv->mnemonic),
|
||||||
(gpointer)comm);
|
(gpointer)comm);
|
||||||
nsp->cm_list = g_list_append(nsp->cm_list, comm);
|
nsp->cm_list = g_list_append(nsp->cm_list, comm);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ struct gnc_price_s
|
|||||||
gnc_commodity *currency;
|
gnc_commodity *currency;
|
||||||
time64 tmspec;
|
time64 tmspec;
|
||||||
PriceSource source;
|
PriceSource source;
|
||||||
char *type;
|
const char *type;
|
||||||
gnc_numeric value;
|
gnc_numeric value;
|
||||||
|
|
||||||
/* 'private' object management fields */
|
/* 'private' object management fields */
|
||||||
|
@ -558,12 +558,8 @@ gnc_price_set_typestr(GNCPrice *p, const char* type)
|
|||||||
if (!p) return;
|
if (!p) return;
|
||||||
if (g_strcmp0(p->type, type) != 0)
|
if (g_strcmp0(p->type, type) != 0)
|
||||||
{
|
{
|
||||||
gchar *tmp;
|
|
||||||
|
|
||||||
gnc_price_begin_edit (p);
|
gnc_price_begin_edit (p);
|
||||||
tmp = CACHE_INSERT((gpointer) type);
|
CACHE_REPLACE(p->type, type);
|
||||||
if (p->type) CACHE_REMOVE(p->type);
|
|
||||||
p->type = tmp;
|
|
||||||
gnc_price_set_dirty(p);
|
gnc_price_set_dirty(p);
|
||||||
gnc_price_commit_edit (p);
|
gnc_price_commit_edit (p);
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@ struct _gncAddress
|
|||||||
QofBook * book;
|
QofBook * book;
|
||||||
QofInstance * parent;
|
QofInstance * parent;
|
||||||
gboolean dirty;
|
gboolean dirty;
|
||||||
char * name;
|
const char * name;
|
||||||
char * addr1;
|
const char * addr1;
|
||||||
char * addr2;
|
const char * addr2;
|
||||||
char * addr3;
|
const char * addr3;
|
||||||
char * addr4;
|
const char * addr4;
|
||||||
char * phone;
|
const char * phone;
|
||||||
char * fax;
|
const char * fax;
|
||||||
char * email;
|
const char * email;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _gncAddressClass
|
struct _gncAddressClass
|
||||||
@ -393,14 +393,10 @@ gncAddressFree (GncAddress *addr)
|
|||||||
/* Set functions */
|
/* Set functions */
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (member == str) return; \
|
if (member == str) return; \
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncAddressBeginEdit (obj); \
|
gncAddressBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE(member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncAddressSetName (GncAddress *addr, const char *name)
|
void gncAddressSetName (GncAddress *addr, const char *name)
|
||||||
|
@ -39,8 +39,8 @@ struct _gncBillTerm
|
|||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
|
|
||||||
/* 'visible' data fields directly manipulated by user */
|
/* 'visible' data fields directly manipulated by user */
|
||||||
char * name;
|
const char * name;
|
||||||
char * desc;
|
const char * desc;
|
||||||
GncBillTermType type;
|
GncBillTermType type;
|
||||||
gint due_days;
|
gint due_days;
|
||||||
gint disc_days;
|
gint disc_days;
|
||||||
@ -72,13 +72,9 @@ static QofLogModule log_module = GNC_MOD_BUSINESS;
|
|||||||
#define _GNC_MOD_NAME GNC_ID_BILLTERM
|
#define _GNC_MOD_NAME GNC_ID_BILLTERM
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncBillTermBeginEdit (obj); \
|
gncBillTermBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE(member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AS_STRING_DEC(GncBillTermType, ENUM_TERMS_TYPE)
|
AS_STRING_DEC(GncBillTermType, ENUM_TERMS_TYPE)
|
||||||
|
@ -53,9 +53,9 @@ struct _gncCustomer
|
|||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
|
|
||||||
/* The following fields are identical to 'vendor' */
|
/* The following fields are identical to 'vendor' */
|
||||||
char * id;
|
const char * id;
|
||||||
char * name;
|
const char * name;
|
||||||
char * notes;
|
const char * notes;
|
||||||
GncBillTerm * terms;
|
GncBillTerm * terms;
|
||||||
GncAddress * addr;
|
GncAddress * addr;
|
||||||
gnc_commodity * currency;
|
gnc_commodity * currency;
|
||||||
@ -371,13 +371,9 @@ static void gncCustomerFree (GncCustomer *cust)
|
|||||||
/* Set Functions */
|
/* Set Functions */
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncCustomerBeginEdit (obj); \
|
gncCustomerBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE(member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncCustomerSetID (GncCustomer *cust, const char *id)
|
void gncCustomerSetID (GncCustomer *cust, const char *id)
|
||||||
|
@ -47,15 +47,15 @@ static void empl_handle_qof_events (QofInstance *entity, QofEventId event_type,
|
|||||||
struct _gncEmployee
|
struct _gncEmployee
|
||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
char * id;
|
const char * id;
|
||||||
char * username;
|
const char * username;
|
||||||
GncAddress * addr;
|
GncAddress * addr;
|
||||||
gnc_commodity * currency;
|
gnc_commodity * currency;
|
||||||
gboolean active;
|
gboolean active;
|
||||||
gnc_numeric * balance;
|
gnc_numeric * balance;
|
||||||
|
|
||||||
char * language;
|
const char * language;
|
||||||
char * acl;
|
const char * acl;
|
||||||
gnc_numeric workday;
|
gnc_numeric workday;
|
||||||
gnc_numeric rate;
|
gnc_numeric rate;
|
||||||
|
|
||||||
@ -481,13 +481,9 @@ static void gncEmployeeFree (GncEmployee *employee)
|
|||||||
/* Set Functions */
|
/* Set Functions */
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncEmployeeBeginEdit (obj); \
|
gncEmployeeBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncEmployeeSetID (GncEmployee *employee, const char *id)
|
void gncEmployeeSetID (GncEmployee *employee, const char *id)
|
||||||
|
@ -44,9 +44,9 @@ struct _gncEntry
|
|||||||
|
|
||||||
time64 date;
|
time64 date;
|
||||||
time64 date_entered;
|
time64 date_entered;
|
||||||
char * desc;
|
const char * desc;
|
||||||
char * action;
|
const char * action;
|
||||||
char * notes;
|
const char * notes;
|
||||||
gnc_numeric quantity;
|
gnc_numeric quantity;
|
||||||
|
|
||||||
/* customer invoice data */
|
/* customer invoice data */
|
||||||
@ -191,13 +191,9 @@ gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type
|
|||||||
#define _GNC_MOD_NAME GNC_ID_ENTRY
|
#define _GNC_MOD_NAME GNC_ID_ENTRY
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncEntryBeginEdit (obj); \
|
gncEntryBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mark_entry (GncEntry *entry);
|
static inline void mark_entry (GncEntry *entry);
|
||||||
|
@ -50,11 +50,11 @@ struct _gncInvoice
|
|||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
|
|
||||||
char *id;
|
const char *id;
|
||||||
char *notes;
|
const char *notes;
|
||||||
gboolean active;
|
gboolean active;
|
||||||
|
|
||||||
char *billing_id;
|
const char *billing_id;
|
||||||
char *printname;
|
char *printname;
|
||||||
GncBillTerm *terms;
|
GncBillTerm *terms;
|
||||||
GList *entries;
|
GList *entries;
|
||||||
@ -87,13 +87,9 @@ static QofLogModule log_module = GNC_MOD_BUSINESS;
|
|||||||
#define GNC_INVOICE_DOCLINK "assoc_uri" // this is the old name for the document link, kept for compatibility
|
#define GNC_INVOICE_DOCLINK "assoc_uri" // this is the old name for the document link, kept for compatibility
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncInvoiceBeginEdit (obj); \
|
gncInvoiceBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_invoice (GncInvoice *invoice);
|
static void mark_invoice (GncInvoice *invoice);
|
||||||
|
@ -41,9 +41,9 @@
|
|||||||
struct _gncJob
|
struct _gncJob
|
||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
char * id;
|
const char * id;
|
||||||
char * name;
|
const char * name;
|
||||||
char * desc;
|
const char * desc;
|
||||||
GncOwner owner;
|
GncOwner owner;
|
||||||
gboolean active;
|
gboolean active;
|
||||||
};
|
};
|
||||||
@ -269,13 +269,9 @@ static void gncJobFree (GncJob *job)
|
|||||||
/* Set Functions */
|
/* Set Functions */
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncJobBeginEdit (obj); \
|
gncJobBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncJobSetID (GncJob *job, const char *id)
|
void gncJobSetID (GncJob *job, const char *id)
|
||||||
|
@ -43,11 +43,11 @@ struct _gncOrder
|
|||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
|
|
||||||
char * id;
|
const char * id;
|
||||||
char * notes;
|
const char * notes;
|
||||||
gboolean active;
|
gboolean active;
|
||||||
|
|
||||||
char * reference;
|
const char * reference;
|
||||||
char * printname;
|
char * printname;
|
||||||
GncOwner owner;
|
GncOwner owner;
|
||||||
GList * entries;
|
GList * entries;
|
||||||
@ -65,13 +65,9 @@ static QofLogModule log_module = GNC_MOD_BUSINESS;
|
|||||||
#define _GNC_MOD_NAME GNC_ID_ORDER
|
#define _GNC_MOD_NAME GNC_ID_ORDER
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncOrderBeginEdit (obj); \
|
gncOrderBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mark_order (GncOrder *order);
|
static inline void mark_order (GncOrder *order);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
struct _gncTaxTable
|
struct _gncTaxTable
|
||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
char * name;
|
const char * name;
|
||||||
GncTaxTableEntryList* entries;
|
GncTaxTableEntryList* entries;
|
||||||
time64 modtime; /* internal date of last modtime */
|
time64 modtime; /* internal date of last modtime */
|
||||||
|
|
||||||
@ -136,13 +136,9 @@ gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type)
|
|||||||
#define _GNC_MOD_NAME GNC_ID_TAXTABLE
|
#define _GNC_MOD_NAME GNC_ID_TAXTABLE
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncTaxTableBeginEdit (obj); \
|
gncTaxTableBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -52,9 +52,9 @@ struct _gncVendor
|
|||||||
{
|
{
|
||||||
QofInstance inst;
|
QofInstance inst;
|
||||||
|
|
||||||
char * id;
|
const char * id;
|
||||||
char * name;
|
const char * name;
|
||||||
char * notes;
|
const char * notes;
|
||||||
GncBillTerm * terms;
|
GncBillTerm * terms;
|
||||||
GncAddress * addr;
|
GncAddress * addr;
|
||||||
gnc_commodity * currency;
|
gnc_commodity * currency;
|
||||||
@ -512,13 +512,9 @@ static void gncVendorFree (GncVendor *vendor)
|
|||||||
/* Set Functions */
|
/* Set Functions */
|
||||||
|
|
||||||
#define SET_STR(obj, member, str) { \
|
#define SET_STR(obj, member, str) { \
|
||||||
char * tmp; \
|
|
||||||
\
|
|
||||||
if (!g_strcmp0 (member, str)) return; \
|
if (!g_strcmp0 (member, str)) return; \
|
||||||
gncVendorBeginEdit (obj); \
|
gncVendorBeginEdit (obj); \
|
||||||
tmp = CACHE_INSERT (str); \
|
CACHE_REPLACE (member, str); \
|
||||||
CACHE_REMOVE (member); \
|
|
||||||
member = tmp; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncVendorSetID (GncVendor *vendor, const char *id)
|
void gncVendorSetID (GncVendor *vendor, const char *id)
|
||||||
|
@ -50,7 +50,7 @@ KvpFrameImpl::KvpFrameImpl(const KvpFrameImpl & rhs) noexcept
|
|||||||
std::for_each(rhs.m_valuemap.begin(), rhs.m_valuemap.end(),
|
std::for_each(rhs.m_valuemap.begin(), rhs.m_valuemap.end(),
|
||||||
[this](const map_type::value_type & a)
|
[this](const map_type::value_type & a)
|
||||||
{
|
{
|
||||||
auto key = static_cast<char *>(qof_string_cache_insert(a.first));
|
auto key = qof_string_cache_insert(a.first);
|
||||||
auto val = new KvpValueImpl(*a.second);
|
auto val = new KvpValueImpl(*a.second);
|
||||||
this->m_valuemap.insert({key,val});
|
this->m_valuemap.insert({key,val});
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ qof_string_cache_remove(const char * key)
|
|||||||
|
|
||||||
/* If the key exists in the cache, increment the refcount. Otherwise,
|
/* If the key exists in the cache, increment the refcount. Otherwise,
|
||||||
* add it with a refcount of 1. */
|
* add it with a refcount of 1. */
|
||||||
char *
|
const char *
|
||||||
qof_string_cache_insert(const char * key)
|
qof_string_cache_insert(const char * key)
|
||||||
{
|
{
|
||||||
if (key)
|
if (key)
|
||||||
@ -132,10 +132,10 @@ qof_string_cache_insert(const char * key)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
qof_string_cache_replace(char const * dst, char const * src)
|
qof_string_cache_replace(char const * dst, char const * src)
|
||||||
{
|
{
|
||||||
char * tmp {qof_string_cache_insert (src)};
|
const char * tmp {qof_string_cache_insert (src)};
|
||||||
qof_string_cache_remove (dst);
|
qof_string_cache_remove (dst);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,11 @@ void qof_string_cache_remove(const char * key);
|
|||||||
/** You can use this function with g_hash_table_insert(), for the key
|
/** You can use this function with g_hash_table_insert(), for the key
|
||||||
(or value), as long as you use the destroy notifier above.
|
(or value), as long as you use the destroy notifier above.
|
||||||
*/
|
*/
|
||||||
char * qof_string_cache_insert(const char * key);
|
const char * qof_string_cache_insert(const char * key);
|
||||||
|
|
||||||
/** Same as CACHE_REPLACE below, but safe to call from C++.
|
/** Same as CACHE_REPLACE below, but safe to call from C++.
|
||||||
*/
|
*/
|
||||||
char * qof_string_cache_replace(const char * dst, const char * src);
|
const char * qof_string_cache_replace(const char * dst, const char * src);
|
||||||
|
|
||||||
#define CACHE_INSERT(str) qof_string_cache_insert((str))
|
#define CACHE_INSERT(str) qof_string_cache_insert((str))
|
||||||
#define CACHE_REMOVE(str) qof_string_cache_remove((str))
|
#define CACHE_REMOVE(str) qof_string_cache_remove((str))
|
||||||
@ -101,7 +101,7 @@ char * qof_string_cache_replace(const char * dst, const char * src);
|
|||||||
* It avoids unnecessary ejection by doing INSERT before REMOVE.
|
* It avoids unnecessary ejection by doing INSERT before REMOVE.
|
||||||
*/
|
*/
|
||||||
#define CACHE_REPLACE(dst, src) do { \
|
#define CACHE_REPLACE(dst, src) do { \
|
||||||
gpointer tmp = CACHE_INSERT((src)); \
|
const char *tmp = CACHE_INSERT((src)); \
|
||||||
CACHE_REMOVE((dst)); \
|
CACHE_REMOVE((dst)); \
|
||||||
(dst) = tmp; \
|
(dst) = tmp; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -613,7 +613,7 @@ qof_book_get_collection (const QofBook *book, QofIdType entity_type)
|
|||||||
col = qof_collection_new (entity_type);
|
col = qof_collection_new (entity_type);
|
||||||
g_hash_table_insert(
|
g_hash_table_insert(
|
||||||
book->hash_of_collections,
|
book->hash_of_collections,
|
||||||
qof_string_cache_insert(entity_type), col);
|
(gpointer)qof_string_cache_insert(entity_type), col);
|
||||||
}
|
}
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@ test_qof_string_cache( void )
|
|||||||
/* Strings added to the cache should always return the same string address
|
/* Strings added to the cache should always return the same string address
|
||||||
* as long as the refcount > 0. */
|
* as long as the refcount > 0. */
|
||||||
gchar str[100];
|
gchar str[100];
|
||||||
gchar* str1_1;
|
const gchar* str1_1;
|
||||||
gchar* str1_2;
|
const gchar* str1_2;
|
||||||
gchar* str1_3;
|
const gchar* str1_3;
|
||||||
gchar* str1_4;
|
const gchar* str1_4;
|
||||||
|
|
||||||
strncpy(str, "str1", sizeof(str));
|
strncpy(str, "str1", sizeof(str));
|
||||||
str1_1 = qof_string_cache_insert(str); /* Refcount = 1 */
|
str1_1 = qof_string_cache_insert(str); /* Refcount = 1 */
|
||||||
|
@ -305,8 +305,8 @@ setup (Fixture *fixture, gconstpointer pData)
|
|||||||
auto accts = g_hash_table_new (g_str_hash, g_str_equal);
|
auto accts = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
guint ind;
|
guint ind;
|
||||||
|
|
||||||
auto root_str = static_cast<char*>(CACHE_INSERT("root"));
|
auto root_str = CACHE_INSERT("root");
|
||||||
g_hash_table_insert (accts, root_str, root);
|
g_hash_table_insert (accts, (gpointer)root_str, root);
|
||||||
fixture->func = _utest_account_fill_functions ();
|
fixture->func = _utest_account_fill_functions ();
|
||||||
if (parms == NULL)
|
if (parms == NULL)
|
||||||
{
|
{
|
||||||
|
@ -79,8 +79,8 @@ setup (Fixture *fixture, gconstpointer pData)
|
|||||||
xaccSplitSetParent (fixture->split, txn);
|
xaccSplitSetParent (fixture->split, txn);
|
||||||
xaccTransCommitEdit (txn);
|
xaccTransCommitEdit (txn);
|
||||||
gnc_lot_set_account (lot, acc);
|
gnc_lot_set_account (lot, acc);
|
||||||
fixture->split->action = static_cast<char*>(CACHE_INSERT ("foo"));
|
fixture->split->action = CACHE_INSERT ("foo");
|
||||||
fixture->split->memo = static_cast<char*>(CACHE_INSERT ("bar"));
|
fixture->split->memo = CACHE_INSERT ("bar");
|
||||||
fixture->split->acc = acc;
|
fixture->split->acc = acc;
|
||||||
fixture->split->lot = lot;
|
fixture->split->lot = lot;
|
||||||
fixture->split->parent = txn;
|
fixture->split->parent = txn;
|
||||||
|
@ -137,16 +137,16 @@ setup (Fixture *fixture, gconstpointer pData)
|
|||||||
xaccAccountSetCommodity (fixture->acc2, fixture->curr);
|
xaccAccountSetCommodity (fixture->acc2, fixture->curr);
|
||||||
txn->date_posted = posted;
|
txn->date_posted = posted;
|
||||||
txn->date_entered = entered;
|
txn->date_entered = entered;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
split1->value = gnc_numeric_create (3200, 240);
|
split1->value = gnc_numeric_create (3200, 240);
|
||||||
split2->amount = gnc_numeric_create (-3200, 240);
|
split2->amount = gnc_numeric_create (-3200, 240);
|
||||||
split2->value = gnc_numeric_create (-3200, 240);
|
split2->value = gnc_numeric_create (-3200, 240);
|
||||||
split1->acc = fixture->acc1;
|
split1->acc = fixture->acc1;
|
||||||
split2->acc = fixture->acc2;
|
split2->acc = fixture->acc2;
|
||||||
txn->num = static_cast<char*>(CACHE_INSERT ("123"));
|
txn->num = CACHE_INSERT ("123");
|
||||||
txn->description = static_cast<char*>(CACHE_INSERT ("Waldo Pepper"));
|
txn->description = CACHE_INSERT ("Waldo Pepper");
|
||||||
xaccTransBeginEdit (txn);
|
xaccTransBeginEdit (txn);
|
||||||
{
|
{
|
||||||
xaccTransSetCurrency (txn, fixture->curr);
|
xaccTransSetCurrency (txn, fixture->curr);
|
||||||
@ -722,7 +722,7 @@ test_xaccFreeTransaction (Fixture *fixture, gconstpointer pData)
|
|||||||
/* so the "free" doesn't, leaving the structure for us to test */
|
/* so the "free" doesn't, leaving the structure for us to test */
|
||||||
g_object_ref (txn);
|
g_object_ref (txn);
|
||||||
g_object_ref (orig);
|
g_object_ref (orig);
|
||||||
orig->num = static_cast<char*>(CACHE_INSERT (txn_num));
|
orig->num = CACHE_INSERT (txn_num);
|
||||||
txn->orig = orig;
|
txn->orig = orig;
|
||||||
|
|
||||||
fixture->func->xaccFreeTransaction (txn);
|
fixture->func->xaccFreeTransaction (txn);
|
||||||
@ -849,17 +849,17 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert (xaccTransEqual (txn1, clone, TRUE, FALSE, TRUE, TRUE));
|
g_assert (xaccTransEqual (txn1, clone, TRUE, FALSE, TRUE, TRUE));
|
||||||
g_assert_cmpint (check->hits, ==, 5);
|
g_assert_cmpint (check->hits, ==, 5);
|
||||||
|
|
||||||
txn1->num = g_strdup("321");
|
txn1->num = CACHE_INSERT("321");
|
||||||
g_free (check->msg);
|
g_free (check->msg);
|
||||||
check->msg = g_strdup ("[xaccTransEqual] num differs: 321 vs 123");
|
check->msg = g_strdup ("[xaccTransEqual] num differs: 321 vs 123");
|
||||||
g_assert (!xaccTransEqual (txn1, txn0, TRUE, FALSE, TRUE, TRUE));
|
g_assert (!xaccTransEqual (txn1, txn0, TRUE, FALSE, TRUE, TRUE));
|
||||||
g_assert_cmpint (check->hits, ==, 6);
|
g_assert_cmpint (check->hits, ==, 6);
|
||||||
|
|
||||||
g_free(clone->num);
|
g_free ((char*)clone->num);
|
||||||
clone->num = static_cast<char*>(CACHE_INSERT("123"));
|
clone->num = CACHE_INSERT("123");
|
||||||
g_free(txn1->num);
|
CACHE_REMOVE(txn1->num);
|
||||||
txn1->num = g_strdup("123");
|
txn1->num = g_strdup("123");
|
||||||
clone->description = g_strdup("salt pork");
|
clone->description = CACHE_INSERT("salt pork");
|
||||||
g_free (check->msg);
|
g_free (check->msg);
|
||||||
check->msg = g_strdup ("[xaccTransEqual] descriptions differ: salt pork vs Waldo Pepper");
|
check->msg = g_strdup ("[xaccTransEqual] descriptions differ: salt pork vs Waldo Pepper");
|
||||||
g_assert (!xaccTransEqual (clone, txn0, TRUE, FALSE, TRUE, TRUE));
|
g_assert (!xaccTransEqual (clone, txn0, TRUE, FALSE, TRUE, TRUE));
|
||||||
@ -871,8 +871,8 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
|
|||||||
|
|
||||||
xaccTransBeginEdit (clone);
|
xaccTransBeginEdit (clone);
|
||||||
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
||||||
g_free(clone->description);
|
CACHE_REMOVE(clone->description);
|
||||||
clone->description = static_cast<char*>(CACHE_INSERT ("Waldo Pepper"));
|
clone->description = CACHE_INSERT ("Waldo Pepper");
|
||||||
auto frame = qof_instance_get_slots (QOF_INSTANCE (clone));
|
auto frame = qof_instance_get_slots (QOF_INSTANCE (clone));
|
||||||
frame->set({"qux", "quux", "corge"}, new KvpValue(654.321));
|
frame->set({"qux", "quux", "corge"}, new KvpValue(654.321));
|
||||||
xaccTransCommitEdit (clone);
|
xaccTransCommitEdit (clone);
|
||||||
@ -885,7 +885,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpint (check->hits, ==, 9);
|
g_assert_cmpint (check->hits, ==, 9);
|
||||||
xaccTransBeginEdit (clone);
|
xaccTransBeginEdit (clone);
|
||||||
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
||||||
clone->description = static_cast<char*>(CACHE_INSERT ("Waldo Pepper"));
|
clone->description = CACHE_INSERT ("Waldo Pepper");
|
||||||
frame->set({"qux", "quux", "corge"}, new KvpValue(123.456));
|
frame->set({"qux", "quux", "corge"}, new KvpValue(123.456));
|
||||||
xaccTransCommitEdit (clone);
|
xaccTransCommitEdit (clone);
|
||||||
g_free (cleanup->msg);
|
g_free (cleanup->msg);
|
||||||
@ -975,8 +975,8 @@ test_xaccTransGetImbalanceValue (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert (gnc_numeric_equal (xaccTransGetImbalanceValue (fixture->txn),
|
g_assert (gnc_numeric_equal (xaccTransGetImbalanceValue (fixture->txn),
|
||||||
gnc_numeric_zero ()));
|
gnc_numeric_zero ()));
|
||||||
split1->acc = fixture->acc1;
|
split1->acc = fixture->acc1;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
split1->value = gnc_numeric_create (3200, 240);
|
split1->value = gnc_numeric_create (3200, 240);
|
||||||
xaccTransBeginEdit (fixture->txn);
|
xaccTransBeginEdit (fixture->txn);
|
||||||
@ -1001,8 +1001,8 @@ test_xaccTransGetImbalance (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpint (g_list_length (mlist), ==, 0);
|
g_assert_cmpint (g_list_length (mlist), ==, 0);
|
||||||
|
|
||||||
split1->acc = fixture->acc1;
|
split1->acc = fixture->acc1;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
split1->value = gnc_numeric_create (3200, 240);
|
split1->value = gnc_numeric_create (3200, 240);
|
||||||
xaccTransBeginEdit (fixture->txn);
|
xaccTransBeginEdit (fixture->txn);
|
||||||
@ -1043,13 +1043,13 @@ test_xaccTransGetImbalance_trading (Fixture *fixture,
|
|||||||
g_assert (!xaccTransIsBalanced (fixture->txn));
|
g_assert (!xaccTransIsBalanced (fixture->txn));
|
||||||
/* Make it look like a proper trading accounts transactionm */
|
/* Make it look like a proper trading accounts transactionm */
|
||||||
split1->acc = acc1;
|
split1->acc = acc1;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (-10000, 100);
|
split1->amount = gnc_numeric_create (-10000, 100);
|
||||||
split1->value = gnc_numeric_create (-3200, 240);
|
split1->value = gnc_numeric_create (-3200, 240);
|
||||||
split2->acc = acc2;
|
split2->acc = acc2;
|
||||||
split2->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split2->memo = CACHE_INSERT ("foo");
|
||||||
split2->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split2->action = CACHE_INSERT ("bar");
|
||||||
split2->amount = gnc_numeric_create (3000, 240);
|
split2->amount = gnc_numeric_create (3000, 240);
|
||||||
split2->value = gnc_numeric_create (3200, 240);
|
split2->value = gnc_numeric_create (3200, 240);
|
||||||
xaccTransBeginEdit (fixture->txn);
|
xaccTransBeginEdit (fixture->txn);
|
||||||
@ -1091,8 +1091,8 @@ test_xaccTransIsBalanced (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert (xaccTransIsBalanced (fixture->txn));
|
g_assert (xaccTransIsBalanced (fixture->txn));
|
||||||
|
|
||||||
split1->acc = fixture->acc1;
|
split1->acc = fixture->acc1;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
split1->value = gnc_numeric_create (3200, 240);
|
split1->value = gnc_numeric_create (3200, 240);
|
||||||
xaccTransBeginEdit (fixture->txn);
|
xaccTransBeginEdit (fixture->txn);
|
||||||
@ -1124,13 +1124,13 @@ test_xaccTransIsBalanced_trading (Fixture *fixture, gconstpointer pData)
|
|||||||
/* The setup transaction is unbalanced in a trading-accounts environment. */
|
/* The setup transaction is unbalanced in a trading-accounts environment. */
|
||||||
g_assert (!xaccTransIsBalanced (fixture->txn));
|
g_assert (!xaccTransIsBalanced (fixture->txn));
|
||||||
split1->acc = acc1;
|
split1->acc = acc1;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (3200, 240);
|
split1->amount = gnc_numeric_create (3200, 240);
|
||||||
split1->value = gnc_numeric_create (3200, 240);
|
split1->value = gnc_numeric_create (3200, 240);
|
||||||
split2->acc = acc2;
|
split2->acc = acc2;
|
||||||
split2->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split2->memo = CACHE_INSERT ("foo");
|
||||||
split2->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split2->action = CACHE_INSERT ("bar");
|
||||||
split2->amount = gnc_numeric_create (-10000, 100);
|
split2->amount = gnc_numeric_create (-10000, 100);
|
||||||
split2->value = gnc_numeric_create (-3000, 240);
|
split2->value = gnc_numeric_create (-3000, 240);
|
||||||
xaccTransBeginEdit (fixture->txn);
|
xaccTransBeginEdit (fixture->txn);
|
||||||
@ -1592,8 +1592,8 @@ test_xaccTransCommitEdit (void)
|
|||||||
xaccAccountSetCommodity (acc1, comm);
|
xaccAccountSetCommodity (acc1, comm);
|
||||||
xaccAccountSetCommodity (acc2, curr);
|
xaccAccountSetCommodity (acc2, curr);
|
||||||
txn->date_posted = posted;
|
txn->date_posted = posted;
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = CACHE_INSERT ("foo");
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = CACHE_INSERT ("bar");
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
split1->value = gnc_numeric_create (3200, 240);
|
split1->value = gnc_numeric_create (3200, 240);
|
||||||
/* Note, deliberately imblanced to force xaccTransScrubImbalance
|
/* Note, deliberately imblanced to force xaccTransScrubImbalance
|
||||||
@ -1603,8 +1603,8 @@ test_xaccTransCommitEdit (void)
|
|||||||
split2->value = gnc_numeric_create (-3000, 240);
|
split2->value = gnc_numeric_create (-3000, 240);
|
||||||
split1->acc = acc1;
|
split1->acc = acc1;
|
||||||
split2->acc = acc2;
|
split2->acc = acc2;
|
||||||
txn->num = static_cast<char*>(CACHE_INSERT ("123"));
|
txn->num = CACHE_INSERT ("123");
|
||||||
txn->description = static_cast<char*>(CACHE_INSERT ("Waldo Pepper"));
|
txn->description = CACHE_INSERT ("Waldo Pepper");
|
||||||
xaccTransBeginEdit (txn);
|
xaccTransBeginEdit (txn);
|
||||||
{
|
{
|
||||||
xaccTransSetCurrency (txn, curr);
|
xaccTransSetCurrency (txn, curr);
|
||||||
@ -1664,8 +1664,8 @@ test_xaccTransRollbackEdit (Fixture *fixture, gconstpointer pData)
|
|||||||
orig = txn->orig;
|
orig = txn->orig;
|
||||||
base_frame = orig->inst.kvp_data; /* DupeTransaction copies the kvp_frame */
|
base_frame = orig->inst.kvp_data; /* DupeTransaction copies the kvp_frame */
|
||||||
g_object_ref (orig); /* Keep rollback from actually freeing it */
|
g_object_ref (orig); /* Keep rollback from actually freeing it */
|
||||||
txn->num = static_cast<char*>(CACHE_INSERT("321"));
|
txn->num = CACHE_INSERT("321");
|
||||||
txn->description = static_cast<char*>(CACHE_INSERT("salt peanuts"));
|
txn->description = CACHE_INSERT("salt peanuts");
|
||||||
txn->common_currency = NULL;
|
txn->common_currency = NULL;
|
||||||
txn->inst.kvp_data = NULL;
|
txn->inst.kvp_data = NULL;
|
||||||
txn->date_entered = new_entered;
|
txn->date_entered = new_entered;
|
||||||
@ -1757,19 +1757,19 @@ test_xaccTransOrder_num_action (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpint (xaccTransOrder_num_action (NULL, NULL, NULL, NULL), ==, 0);
|
g_assert_cmpint (xaccTransOrder_num_action (NULL, NULL, NULL, NULL), ==, 0);
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==,
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==,
|
||||||
qof_instance_guid_compare (txnA, txnB));
|
qof_instance_guid_compare (txnA, txnB));
|
||||||
txnB->description = static_cast<char*>(CACHE_INSERT ("Salt Peanuts"));
|
txnB->description = CACHE_INSERT ("Salt Peanuts");
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), >=, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), >=, 1);
|
||||||
txnB->date_entered += 1;
|
txnB->date_entered += 1;
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
||||||
txnB->num = static_cast<char*>(CACHE_INSERT ("101"));
|
txnB->num = CACHE_INSERT ("101");
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
||||||
txnA->num = static_cast<char*>(CACHE_INSERT ("12a"));
|
txnA->num = CACHE_INSERT ("12a");
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
||||||
txnB->num = static_cast<char*>(CACHE_INSERT ("12c"));
|
txnB->num = CACHE_INSERT ("12c");
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
||||||
txnB->num = static_cast<char*>(CACHE_INSERT ("12"));
|
txnB->num = CACHE_INSERT ("12");
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
||||||
txnB->num = static_cast<char*>(CACHE_INSERT ("one-oh-one"));
|
txnB->num = CACHE_INSERT ("one-oh-one");
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, -1);
|
||||||
txnB->date_posted -= 1;
|
txnB->date_posted -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user