From 50646f04a9e77f3a0d2827670918b26928b47c8b Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Sun, 16 Apr 2000 20:37:38 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2190 57a11ea4-9604-0410-9ed3-97b8803252fd --- doc/README | 1 + doc/html/C/xacc-about.html | 4 ++++ src/SplitLedger.c | 8 ++++---- src/engine/Account.c | 16 +++++++++++++++- src/engine/Transaction.c | 23 ++++++++++++----------- src/engine/Transaction.h | 12 +++++++----- 6 files changed, 43 insertions(+), 21 deletions(-) diff --git a/doc/README b/doc/README index 6259a4dc58..b3b825c5d8 100644 --- a/doc/README +++ b/doc/README @@ -560,6 +560,7 @@ Dave Freese for leap-year fix Bill Gribble qif importation code Otto Hammersmith for RedHat RPM version Alexandru Harsanyi for core dumps, lockups, gtk work +John Hasler engine patch Jon K}re Hellan misc core dump fixes Prakash Kailasa for gnome build fixes Ben Kelly for motif menu bug fix, core dump fixes diff --git a/doc/html/C/xacc-about.html b/doc/html/C/xacc-about.html index 8e8cb8870e..5487d6989e 100644 --- a/doc/html/C/xacc-about.html +++ b/doc/html/C/xacc-about.html @@ -322,6 +322,10 @@
for fixing miscellaneous core dumps and lockups.
+
John Hasler
+ +
engine patch
+
Jon K}re Hellan
diff --git a/src/SplitLedger.c b/src/SplitLedger.c index d3b0df530f..b5a5fd06ed 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -1386,8 +1386,8 @@ xaccSRSaveRegEntry (SplitRegister *reg, Transaction *new_trans) if ((new_acc != NULL) && (old_acc != new_acc)) { - char *currency = NULL; - char *security = NULL; + const char *currency = NULL; + const char *security = NULL; currency = xaccAccountGetCurrency(new_acc); currency = xaccTransIsCommonCurrency(trans, currency); @@ -1461,8 +1461,8 @@ xaccSRSaveRegEntry (SplitRegister *reg, Transaction *new_trans) if ((new_acc != NULL) && (old_acc != new_acc)) { - char *currency = NULL; - char *security = NULL; + const char *currency = NULL; + const char *security = NULL; currency = xaccAccountGetCurrency(new_acc); currency = xaccTransIsCommonCurrency(trans, currency); diff --git a/src/engine/Account.c b/src/engine/Account.c index 874a4fd5c1..4fb084e946 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -673,8 +673,10 @@ static int revorder[NUM_ACCOUNT_TYPES] = { int xaccAccountOrder (Account **aa, Account **ab) { - char *da, *db; + char *da, *db; + char *endptr = NULL; int ta, tb; + long la, lb; if ( (*aa) && !(*ab) ) return -1; if ( !(*aa) && (*ab) ) return +1; @@ -683,6 +685,18 @@ xaccAccountOrder (Account **aa, Account **ab) /* sort on accountCode strings */ da = (*aa)->accountCode; db = (*ab)->accountCode; + + /* If accountCodes are both base 36 integers do an integer sort */ + la = strtoul (da, &endptr, 36); + if((*da != '\0') && (*endptr == '\0')) { + lb = strtoul (db, &endptr, 36); + if((*db != '\0') && (*endptr == '\0')) { + if (la < lb) return -1; + if (la > lb) return +1; + } + } + + /* Otherwise do a string sort */ SAFE_STRCMP (da, db); /* if acccount-type-order array not initialized, initialize it */ diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index 0dd2e10808..df3fb46792 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -520,7 +520,7 @@ xaccTransLookup (GUID *guid) \********************************************************************/ void -xaccSplitSetBaseValue (Split *s, double value, char * base_currency) +xaccSplitSetBaseValue (Split *s, double value, const char * base_currency) { if (!s) return; @@ -606,7 +606,7 @@ xaccSplitGetBaseValue (Split *s, char * base_currency) \********************************************************************/ static double -ComputeValue (Split **sarray, Split * skip_me, char * base_currency) +ComputeValue (Split **sarray, Split * skip_me, const char * base_currency) { Split *s; int i=0; @@ -656,15 +656,16 @@ ComputeValue (Split **sarray, Split * skip_me, char * base_currency) double xaccTransGetImbalance (Transaction * trans) { - char * currency = xaccTransFindCommonCurrency (trans); + const char * currency = xaccTransFindCommonCurrency (trans); double imbal = ComputeValue (trans->splits, NULL, currency); return imbal; } /********************************************************************\ \********************************************************************/ -gncBoolean xaccIsCommonCurrency(char *currency_1, char *security_1, - char *currency_2, char *security_2) +gncBoolean +xaccIsCommonCurrency(const char *currency_1, const char *security_1, + const char *currency_2, const char *security_2) { int c1c2, c1s2, s1c2, s1s2; @@ -694,8 +695,8 @@ gncBoolean xaccIsCommonCurrency(char *currency_1, char *security_1, return (c1c2 == 0) || (c1s2 == 0) || (s1c2 == 0) || (s1s2 == 0); } -static char * -FindCommonCurrency (Split **slist, char * ra, char * rb) +static const char * +FindCommonCurrency (Split **slist, const char * ra, const char * rb) { Split *s; int i = 0; @@ -756,7 +757,7 @@ FindCommonCurrency (Split **slist, char * ra, char * rb) } -char * +const char * xaccTransFindCommonCurrency (Transaction *trans) { char *ra, *rb; @@ -771,8 +772,8 @@ xaccTransFindCommonCurrency (Transaction *trans) return FindCommonCurrency (trans->splits, ra, rb); } -char * -xaccTransIsCommonCurrency (Transaction *trans, char * ra) +const char * +xaccTransIsCommonCurrency (Transaction *trans, const char * ra) { return FindCommonCurrency (trans->splits, ra, NULL); } @@ -799,7 +800,7 @@ xaccSplitRebalance (Split *split) Split *s; int i = 0; double value = 0.0; - char *base_currency=0x0; + const char *base_currency = NULL; trans = split->parent; diff --git a/src/engine/Transaction.h b/src/engine/Transaction.h index 6a7b4a905a..de42f8f69b 100644 --- a/src/engine/Transaction.h +++ b/src/engine/Transaction.h @@ -262,8 +262,8 @@ int xaccTransCountSplits (Transaction *trans); * xaccTransFindCommonCurrency. This method is useful for determining * whether two accounts can have transactions in common. */ -gncBoolean xaccIsCommonCurrency(char *currency_1, char *security_1, - char *currency_2, char *security_2); +gncBoolean xaccIsCommonCurrency(const char *currency_1, const char *security_1, + const char *currency_2, const char *security_2); /* The xaccTransFindCommonCurrency () method returns a string value * indicating a currency denomination that all of the splits in this @@ -276,7 +276,7 @@ gncBoolean xaccIsCommonCurrency(char *currency_1, char *security_1, * If all of the splits share both a common security and a common currency, * then the string name for the currency is returned. */ -char * xaccTransFindCommonCurrency (Transaction *trans); +const char * xaccTransFindCommonCurrency (Transaction *trans); /* The xaccTransIsCommonCurrency () method compares the input string * to the currency/security denominations of all splits in the @@ -294,7 +294,8 @@ char * xaccTransFindCommonCurrency (Transaction *trans); * transaction have in common. This routine is useful in dealing * securities of differing types are moved across accounts. */ -char * xaccTransIsCommonCurrency (Transaction *trans, char * currency); +const char * xaccTransIsCommonCurrency (Transaction *trans, + const char * currency); /* The xaccTransGetImbalance() method returns the total value of the * transaction. In a pure double-entry system, this imbalance @@ -373,7 +374,8 @@ void xaccSplitSetSharePriceAndAmount (Split *, double price, void xaccSplitSetShareAmount (Split *, double); void xaccSplitSetSharePrice (Split *, double); void xaccSplitSetValue (Split *, double); -void xaccSplitSetBaseValue (Split *s, double value, char * base_currency); +void xaccSplitSetBaseValue (Split *s, double value, + const char * base_currency); /* The following four subroutines return the running balance up