From f2605bbfc1b113cb80c5f41faa84b6218edaeca5 Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Mon, 24 Apr 2000 08:07:28 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2199 57a11ea4-9604-0410-9ed3-97b8803252fd --- CHANGES | 6 ++++ ChangeLog | 11 +++++++ configure | 2 +- configure.in | 2 +- src/SplitLedger.c | 7 ++-- src/engine/Account.c | 23 +++++++------ src/engine/Account.h | 16 ++++----- src/engine/FileIO.c | 6 ++-- src/engine/GNCId.c | 44 +++++++++++++------------ src/engine/Group.c | 9 ++++-- src/engine/QIFIO.c | 7 ++-- src/engine/Scrub.c | 52 +++++++++++++++++------------- src/engine/Scrub.h | 35 +++++++++++--------- src/engine/Transaction.c | 18 +++++++---- src/gnome/account-tree.c | 2 +- src/gnome/account-tree.h | 1 + src/gnome/dialog-account-picker.c | 4 +-- src/gnome/dialog-edit.c | 6 ++-- src/gnome/dialog-utils.c | 8 +++-- src/gnome/window-main.c | 4 +-- src/scm/report/average-balance.scm | 10 ++++-- 21 files changed, 163 insertions(+), 110 deletions(-) diff --git a/CHANGES b/CHANGES index bc4ccde378..78348f29bb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ Version history: ------- ------- + 1.3.6 - 24 April 2000 + o transaction finder dialog + o even better qif importing + o some support for the euro + o bug fixes + 1.3.5 - 10 April 2000 o more work on reports and check-printing o fixes to qif importing diff --git a/ChangeLog b/ChangeLog index 36a14a99c4..9cf5c338da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-04-24 Dave Peticolas + + * src/engine/Group.c (xaccMallocAccountGroup): loop until we + get a unique id. This is just paranoia code. Ditto for Account.c + and Transaction.c. + + * src/engine/Account.c: add some 'const' keywords to string + arguments. This affected many other files. + + * src/engine/Scrub.c: i18n strings used to make new accounts. + 2000-04-22 Dave Peticolas * src/gnome/dialog-options.c: use the default section, if present, diff --git a/configure b/configure index 302abbfddd..e879fec9f9 100755 --- a/configure +++ b/configure @@ -747,7 +747,7 @@ fi PACKAGE=gnucash -VERSION=1.3.5 +VERSION=1.3.6 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/configure.in b/configure.in index 983aef6bc3..ae20e121d8 100644 --- a/configure.in +++ b/configure.in @@ -24,7 +24,7 @@ AC_INIT(src/guile/gnucash.h.in) -AM_INIT_AUTOMAKE(gnucash,1.3.5) +AM_INIT_AUTOMAKE(gnucash,1.3.6) dnl Set of available languages. ALL_LINGUAS="fr de en_GB sv" diff --git a/src/SplitLedger.c b/src/SplitLedger.c index b5a5fd06ed..0bce462d2a 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -2345,7 +2345,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist, static void LoadXferCell (ComboCell *cell, AccountGroup *grp, - char *base_currency, char *base_security) + const char *base_currency, + const char *base_security) { gncBoolean load_everything; Account * acc; @@ -2366,7 +2367,7 @@ LoadXferCell (ComboCell *cell, n = 0; acc = xaccGroupGetAccount (grp, n); while (acc) { - char *curr, *secu; + const char *curr, *secu; curr = xaccAccountGetCurrency (acc); secu = xaccAccountGetSecurity (acc); @@ -2404,7 +2405,7 @@ xaccLoadXferCell (ComboCell *cell, AccountGroup *grp, Account *base_account) { - char *curr, *secu; + const char *curr, *secu; curr = xaccAccountGetCurrency (base_account); secu = xaccAccountGetSecurity (base_account); diff --git a/src/engine/Account.c b/src/engine/Account.c index 4fb084e946..ec6159e15a 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -112,11 +112,14 @@ xaccMallocAccount( void ) xaccInitAccount (acc); - guid_new(&acc->guid); + do { + guid_new(&acc->guid); + + if (xaccGUIDType(&acc->guid) == GNC_ID_NONE) + break; - if (xaccGUIDType(&acc->guid) != GNC_ID_NONE) { PWARN("xaccMallocAccount: duplicate id\n"); - } + } while(1); xaccStoreEntity(acc, &acc->guid, GNC_ID_ACCOUNT); @@ -992,7 +995,7 @@ xaccAccountSetType (Account *acc, int tip) } void -xaccAccountSetName (Account *acc, char *str) +xaccAccountSetName (Account *acc, const char *str) { char * tmp; if ((!acc) || (!str)) return; @@ -1005,7 +1008,7 @@ xaccAccountSetName (Account *acc, char *str) } void -xaccAccountSetCode (Account *acc, char *str) +xaccAccountSetCode (Account *acc, const char *str) { char * tmp; if ((!acc) || (!str)) return; @@ -1018,7 +1021,7 @@ xaccAccountSetCode (Account *acc, char *str) } void -xaccAccountSetDescription (Account *acc, char *str) +xaccAccountSetDescription (Account *acc, const char *str) { char * tmp; if ((!acc) || (!str)) return; @@ -1031,7 +1034,7 @@ xaccAccountSetDescription (Account *acc, char *str) } void -xaccAccountSetNotes (Account *acc, char *str) +xaccAccountSetNotes (Account *acc, const char *str) { char * tmp; if ((!acc) || (!str)) return; @@ -1044,7 +1047,7 @@ xaccAccountSetNotes (Account *acc, char *str) } void -xaccAccountSetCurrency (Account *acc, char *str) +xaccAccountSetCurrency (Account *acc, const char *str) { if ((!acc) || (!str)) return; CHECK (acc); @@ -1068,7 +1071,7 @@ xaccAccountSetCurrency (Account *acc, char *str) } void -xaccAccountSetSecurity (Account *acc, char *str) +xaccAccountSetSecurity (Account *acc, const char *str) { if ((!acc) || (!str)) return; CHECK (acc); @@ -1141,7 +1144,7 @@ xaccAccountGetFullName(Account *account, const char separator) { Account *a; char *fullname; - char *name; + const char *name; char *p; int length; diff --git a/src/engine/Account.h b/src/engine/Account.h index f2164572e6..da90b3f164 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -60,8 +60,8 @@ void xaccAccountCommitEdit (Account *); * account associated with the given id, or NULL * if there is no such account. */ -GUID * xaccAccountGetGUID (Account *account); -Account * xaccAccountLookup (GUID *guid); +GUID * xaccAccountGetGUID (Account *account); +Account * xaccAccountLookup (GUID *guid); int xaccGetAccountID (Account *); char xaccGetAccountFlags (Account *); @@ -137,12 +137,12 @@ void xaccMoveFarEnd (Split *, Account *); void xaccMoveFarEndByName (Split *, const char *); void xaccAccountSetType (Account *, int); -void xaccAccountSetName (Account *, char *); -void xaccAccountSetCode (Account *, char *); -void xaccAccountSetDescription (Account *, char *); -void xaccAccountSetNotes (Account *, char *); -void xaccAccountSetCurrency (Account *, char *); -void xaccAccountSetSecurity (Account *, char *); +void xaccAccountSetName (Account *, const char *); +void xaccAccountSetCode (Account *, const char *); +void xaccAccountSetDescription (Account *, const char *); +void xaccAccountSetNotes (Account *, const char *); +void xaccAccountSetCurrency (Account *, const char *); +void xaccAccountSetSecurity (Account *, const char *); int xaccAccountGetType (Account *); char * xaccAccountGetName (Account *); diff --git a/src/engine/FileIO.c b/src/engine/FileIO.c index 6364a564dc..3c59c38823 100644 --- a/src/engine/FileIO.c +++ b/src/engine/FileIO.c @@ -150,7 +150,7 @@ static int writeAccount( int fd, Account *account ); static int writeAccInfo( int fd, AccInfo *accinfo ); static int writeTransaction( int fd, Transaction *trans ); static int writeSplit( int fd, Split *split); -static int writeString( int fd, char *str ); +static int writeString( int fd, const char *str ); static int writeTSDate( int fd, Timespec *); /*******************************************************/ @@ -1521,7 +1521,7 @@ writeAccount( int fd, Account *acc ) int numUnwrittenTrans, ntrans; int acc_id; int numChildren = 0; - char * tmp; + const char * tmp; DEBUG ("writeAccount(): writing acct %s \n", xaccAccountGetName (acc)); @@ -1816,7 +1816,7 @@ writeAccInfo ( int fd, AccInfo *accinfo ) * Return: -1 on failure * \********************************************************************/ static int -writeString( int fd, char *str ) +writeString( int fd, const char *str ) { int err=0; int size; diff --git a/src/engine/GNCId.c b/src/engine/GNCId.c index a5b755e415..ff7d5b6898 100644 --- a/src/engine/GNCId.c +++ b/src/engine/GNCId.c @@ -103,7 +103,26 @@ id_compare(gconstpointer key_1, gconstpointer key_2) return memcmp(key_1, key_2, sizeof(GUID)) == 0; } -static void summarize_table(); +#ifdef USE_DEBUG +static void +print_node(gpointer key, gpointer value, gpointer not_used) +{ + GUID *guid = key; + EntityNode *node = value; + + fprintf(stderr, "%s %d %p\n", + guid_to_string(guid), node->entity_type, node->entity); +} + +static void +summarize_table() +{ + if (entity_table == NULL) + return; + + g_hash_table_foreach(entity_table, print_node, NULL); +} +#endif static void entity_table_init() @@ -113,7 +132,9 @@ entity_table_init() entity_table = g_hash_table_new(id_hash, id_compare); - /* atexit(summarize_table); */ +#ifdef USE_DEBUG + atexit(summarize_table); +#endif } GNCIdType @@ -200,22 +221,3 @@ xaccRemoveEntity(GUID * guid) entity_node_destroy(old_guid, e_node, NULL); } } - -static void -print_node(gpointer key, gpointer value, gpointer not_used) -{ - GUID *guid = key; - EntityNode *node = value; - - fprintf(stderr, "%s %d %p\n", - guid_to_string(guid), node->entity_type, node->entity); -} - -static void -summarize_table() -{ - if (entity_table == NULL) - return; - - g_hash_table_foreach(entity_table, print_node, NULL); -} diff --git a/src/engine/Group.c b/src/engine/Group.c index de2492ee2a..f9ba73475d 100644 --- a/src/engine/Group.c +++ b/src/engine/Group.c @@ -69,11 +69,14 @@ xaccMallocAccountGroup( void ) xaccInitializeAccountGroup (grp); - guid_new(&grp->guid); + do { + guid_new(&grp->guid); + + if (xaccGUIDType(&grp->guid) == GNC_ID_NONE) + break; - if (xaccGUIDType(&grp->guid) != GNC_ID_NONE) { PWARN("xaccMallocAccountGroup: duplicate id\n"); - } + } while(1); xaccStoreEntity(grp, &grp->guid, GNC_ID_GROUP); diff --git a/src/engine/QIFIO.c b/src/engine/QIFIO.c index f632f3cf81..712ee7f29c 100644 --- a/src/engine/QIFIO.c +++ b/src/engine/QIFIO.c @@ -346,7 +346,8 @@ char * xaccReadQIFAccList (int fd, AccountGroup *grp, int cat) { char * qifline; Account *acc; - char *str, *tok; + const char *str; + char *tok; if (!grp) return 0x0; do { @@ -647,7 +648,7 @@ GetSubQIFAccount (AccountGroup *rootgrp, char *qifline, int acc_type) nacc = xaccGroupGetNumAccounts (rootgrp); for (i=0; i #include #include @@ -37,6 +41,7 @@ #include "GroupP.h" #include "Scrub.h" #include "Transaction.h" +#include "messages.h" #include "util.h" static short module = MOD_SCRUB; @@ -70,8 +75,9 @@ xaccAccountTreeScrubOrphans (Account *acc) xaccAccountScrubOrphans (acc); } -/* hack alert -- this string should probably be i18n'ed */ -#define ORPHAN_STR "Orphan-" +#ifndef ORPHAN_STR +# define ORPHAN_STR "Orphan" +#endif void xaccAccountScrubOrphans (Account *acc) @@ -131,8 +137,9 @@ xaccAccountTreeScrubImbalance (Account *acc) xaccAccountScrubImbalance (acc); } -/* hack alert -- this string should probably be i18n'ed */ -#define IMBALANCE_STR "Imbalance-" +#ifndef IMBALANCE_STR +# define IMBALANCE_STR "Imbalance" +#endif void xaccAccountScrubImbalance (Account *acc) @@ -180,14 +187,15 @@ static Account * GetOrMakeAccount (Account *peer, Transaction *trans, const char *name_root) { char * accname; - char * currency; + const char * currency; Account * acc; AccountGroup *root; /* build the account name */ currency = xaccTransFindCommonCurrency (trans); - accname = alloca (strlen (name_root) + strlen (currency) + 1); + accname = alloca (strlen (name_root) + strlen (currency) + 2); strcpy (accname, name_root); + strcat (accname, "-"); strcat (accname, currency); /* see if we've got one of these going already ... */ diff --git a/src/engine/Scrub.h b/src/engine/Scrub.h index ca5278ad6c..4e6fa5a4ad 100644 --- a/src/engine/Scrub.h +++ b/src/engine/Scrub.h @@ -1,17 +1,3 @@ -/* - * FILE: - * Scrub.h - * - * FUNCTION: - * Provides a set of functions and utilities for scrubbing clean - * single-entry accounts so that they can be promoted into - * self-consistent, clean double-entry accounts. - * - * HISTORY: - * Created by Linas Vepstas December 1998 - * Copyright (c) 1998 Linas Vepstas - */ - /********************************************************************\ * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -24,10 +10,27 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License* - * along with this program; if not, write to the Free Software * - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + * along with this program; if not, contact: * + * * + * Free Software Foundation Voice: +1-617-542-5942 * + * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * + * Boston, MA 02111-1307, USA gnu@gnu.org * + * * \********************************************************************/ +/* + * FILE: + * Scrub.h + * + * FUNCTION: + * Provides a set of functions and utilities for scrubbing clean + * single-entry accounts so that they can be promoted into + * self-consistent, clean double-entry accounts. + * + * HISTORY: + * Created by Linas Vepstas December 1998 + * Copyright (c) 1998, 1999, 2000 Linas Vepstas + */ #ifndef __XACC_SCRUB_H__ #define __XACC_SCRUB_H__ diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index df3fb46792..a5b914af44 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -115,11 +115,14 @@ xaccMallocSplit(void) xaccInitSplit (split); - guid_new(&split->guid); + do { + guid_new(&split->guid); + + if (xaccGUIDType(&split->guid) == GNC_ID_NONE) + break; - if (xaccGUIDType(&split->guid) != GNC_ID_NONE) { PWARN("xaccMallocSplit: duplicate id\n"); - } + } while (1); xaccStoreEntity(split, &split->guid, GNC_ID_SPLIT); @@ -388,11 +391,14 @@ xaccMallocTransaction( void ) xaccInitTransaction (trans); - guid_new(&trans->guid); + do { + guid_new(&trans->guid); + + if (xaccGUIDType(&trans->guid) == GNC_ID_NONE) + break; - if (xaccGUIDType(&trans->guid) != GNC_ID_NONE) { PWARN("xaccMallocTransaction: duplicate id\n"); - } + } while (1); xaccStoreEntity(trans, &trans->guid, GNC_ID_TRANS); diff --git a/src/gnome/account-tree.c b/src/gnome/account-tree.c index 8a08cadaf5..0b4f887962 100644 --- a/src/gnome/account-tree.c +++ b/src/gnome/account-tree.c @@ -924,9 +924,9 @@ gnc_account_tree_insert_row(GNCAccountTree *tree, GtkCTreeNode *sibling, Account *acc) { - int i; gchar *text[NUM_ACCOUNT_FIELDS + 1]; GtkCTreeNode *node; + gint i; if (acc == NULL) return NULL; diff --git a/src/gnome/account-tree.h b/src/gnome/account-tree.h index d9ddebbbd5..59ea06a7b7 100644 --- a/src/gnome/account-tree.h +++ b/src/gnome/account-tree.h @@ -61,6 +61,7 @@ struct _GNCAccountTree gint balance_column; gint total_column; gint column_fields[NUM_ACCOUNT_FIELDS]; + gchar * column_headings[NUM_ACCOUNT_FIELDS + 1]; GtkStyle *deficit_style; diff --git a/src/gnome/dialog-account-picker.c b/src/gnome/dialog-account-picker.c index 48551d53b6..aabd76e6cd 100644 --- a/src/gnome/dialog-account-picker.c +++ b/src/gnome/dialog-account-picker.c @@ -177,7 +177,7 @@ gnc_ui_account_picker_select_cb(GtkTree * tree, AccountGroup * topgroup = gncGetCurrentGroup(); Account * gnc_acct; char * selected_acct; - char * description; + const char * description; int acct_type; SCM infolist; @@ -198,7 +198,7 @@ gnc_ui_account_picker_select_cb(GtkTree * tree, acct_type); infolist = SCM_LIST3(gh_str02scm(selected_acct), gh_int2scm(acct_type), - gh_str02scm(description)); + gh_str02scm((char *) description)); scm_protect_object(infolist); scm_unprotect_object(wind->scm_acct_info); diff --git a/src/gnome/dialog-edit.c b/src/gnome/dialog-edit.c index 3fd7de68cf..428cdce4c5 100644 --- a/src/gnome/dialog-edit.c +++ b/src/gnome/dialog-edit.c @@ -229,8 +229,8 @@ gnc_account_change_currency_security(Account *account, const char *currency, const char *security) { - char *old_currency; - char *old_security; + const char *old_currency; + const char *old_security; gboolean new_currency; gboolean new_security; GSList *stack; @@ -915,7 +915,7 @@ editAccWindow(Account *account) gtk_box_pack_start(GTK_BOX(vbox), source_menu, FALSE, FALSE, 0); { /* Notes entry */ - gchar * notes; + const gchar * notes; widget = gnc_ui_notes_frame_create(&editAccData->edit_info.notes_entry); gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); diff --git a/src/gnome/dialog-utils.c b/src/gnome/dialog-utils.c index 61079c3351..236c3ab7c7 100644 --- a/src/gnome/dialog-utils.c +++ b/src/gnome/dialog-utils.c @@ -88,7 +88,7 @@ GtkWidget * gnc_ui_create_account_label(int field_type) { GtkWidget *label; - gchar *label_string = gnc_ui_get_account_field_name(field_type); + gchar *label_string = gnc_ui_get_account_field_name(field_type); label_string = g_strconcat(label_string, ":", NULL); @@ -569,7 +569,8 @@ gnc_ui_install_field_strings(Account * account, /* =========================================================== */ -char * gnc_ui_get_account_field_name(int field) +char * +gnc_ui_get_account_field_name(int field) { assert((field >= 0) && (field < NUM_ACCOUNT_FIELDS)); @@ -641,7 +642,8 @@ gnc_ui_account_get_balance(Account *account, gboolean include_children) } -char * gnc_ui_get_account_field_value_string(Account *account, int field) +char * +gnc_ui_get_account_field_value_string(Account *account, int field) { if (account == NULL) return NULL; diff --git a/src/gnome/window-main.c b/src/gnome/window-main.c index daea2cc953..f0006305fb 100644 --- a/src/gnome/window-main.c +++ b/src/gnome/window-main.c @@ -83,7 +83,7 @@ gnc_ui_refresh_statusbar() char profit_string[256]; int num_accounts; int account_type; - char *account_currency; + const char *account_currency; gboolean euro; int i; @@ -239,7 +239,7 @@ gnc_ui_delete_account_cb ( GtkWidget *widget, gpointer data ) if (account) { - gchar *name; + const gchar *name; gchar *message; name = xaccAccountGetName(account); diff --git a/src/scm/report/average-balance.scm b/src/scm/report/average-balance.scm index e765472423..43a1584935 100644 --- a/src/scm/report/average-balance.scm +++ b/src/scm/report/average-balance.scm @@ -338,7 +338,13 @@ (set! accounts (addunique accounts a))) (allsubaccounts accounts))) -; (map (lambda (acct) (gnc:query-add-account gncq acct)) accounts) + (gnc:query-set-group gncq (gnc:get-current-group)) + + (map (lambda (acct) + ;; FIXME - the '1' below is hard-coded and should + ;; be abstracted. Just a temp fix while + ;; the query api gets fully wrapped. + (gnc:query-add-account gncq acct 1)) accounts) (set! acctcurrency (gnc:account-get-currency (car accounts))) @@ -347,7 +353,7 @@ (gnc:free-query gncq) - (set! rept-data + (set! rept-data (reduce-split-list (dateloop begindate enddate stepsize) report-lines 0))