new, improved debug printing macros

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2308 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2000-05-14 20:54:20 +00:00
parent 42fa37831d
commit e92c343927
12 changed files with 108 additions and 87 deletions

View File

@ -57,8 +57,7 @@ xaccAccountTypeEnumAsString(int type) {
GNC_RETURN_ENUM_AS_STRING(MONEYMRKT); GNC_RETURN_ENUM_AS_STRING(MONEYMRKT);
GNC_RETURN_ENUM_AS_STRING(CREDITLINE); GNC_RETURN_ENUM_AS_STRING(CREDITLINE);
default: default:
fprintf(stderr, PERR ("asked to translate unknown account type %d.\n", type);
"Big problem asked to translate unknown account type %d.\n", type);
break; break;
}; };
return(NULL); return(NULL);
@ -128,7 +127,7 @@ xaccAccountTypesCompatible (int parent_type, int child_type)
compatible = (child_type == EQUITY); compatible = (child_type == EQUITY);
break; break;
default: default:
PERR("xaccAccountTypesCompatible: bad account type: %d", parent_type); PERR("bad account type: %d", parent_type);
break; break;
} }

View File

@ -275,7 +275,7 @@ xaccGetAccountFlags (Account *acc)
#define CHECK(acc) { \ #define CHECK(acc) { \
if (0 == acc->open) { \ if (0 == acc->open) { \
/* not today, some day in the future ... */ \ /* not today, some day in the future ... */ \
/* printf ("Error: Account not open for editing\n"); */ \ /* PERR ("Account not open for editing\n"); */ \
/* assert (0); */ \ /* assert (0); */ \
/* return; */ \ /* return; */ \
} \ } \
@ -345,7 +345,7 @@ xaccAccountInsertSplit ( Account *acc, Split *split )
} }
/* Insertion point is now i */ /* Insertion point is now i */
//fprintf(stderr, "Insertion position is: %d\n", i); PINFO ("Insertion position is: %d\n", i);
/* Move all the other splits down (this could be done faster with memmove)*/ /* Move all the other splits down (this could be done faster with memmove)*/
for( j = acc->numSplits; j > i; j--) { for( j = acc->numSplits; j > i; j--) {
@ -600,8 +600,7 @@ xaccCheckDateOrder (Account * acc, Split *split )
} }
if (!s) { if (!s) {
printf ("Internal Error: xaccCheckDateOrder(): "); PERR ("split %p not present in account \n", split);
printf (" split %p not present in account \n", split);
return 0; return 0;
} }
@ -1056,13 +1055,11 @@ xaccAccountSetCurrency (Account *acc, const char *str)
if (acc->currency && (0x0 != acc->currency[0])) { if (acc->currency && (0x0 != acc->currency[0])) {
if (unsafe_ops) { if (unsafe_ops) {
PWARN ("xaccAccountSetCurrency(): " PWARN ( "it is dangerous to change the currency denomination of an account! \n"
"it is dangerous to change the currency denomination of an account! \n"
"\tAccount=%s old currency=%s new currency=%s \n", "\tAccount=%s old currency=%s new currency=%s \n",
acc->accountName, acc->currency, str); acc->accountName, acc->currency, str);
} else { } else {
PERR ("xaccAccountSetCurrency(): " PERR ("the currency denomination of an account cannot be changed!\n"
"the currency denomination of an account cannot be changed!\n"
"\tAccount=%s \n", acc->accountName); "\tAccount=%s \n", acc->accountName);
return; return;
} }
@ -1080,14 +1077,12 @@ xaccAccountSetSecurity (Account *acc, const char *str)
if (acc->security && (0x0 != acc->security[0])) { if (acc->security && (0x0 != acc->security[0])) {
if (unsafe_ops) { if (unsafe_ops) {
PWARN ("xaccAccountSetSecurity(): " PWARN ("it is dangerous to change the security denomination of an account! \n"
"it is dangerous to change the security denomination of an account! \n"
"\tAccount=%s old security=%s new security=%s \n", "\tAccount=%s old security=%s new security=%s \n",
acc->accountName, acc->security, str); acc->accountName, acc->security, str);
} else { } else {
PERR ("xaccAccountSetSecurity(): " PERR ("the security denomination of an account cannot be changed!\n"
"the security denomination of an account cannot be changed!\n" "\tAccount=%s \n", acc->accountName);
"\tAccount=%s \n", acc->accountName);
return; return;
} }
} }

View File

@ -1,7 +1,7 @@
/********************************************************************\ /********************************************************************\
* Account.h -- the Account data structure * * AccountP.h -- the Account data structure *
* Copyright (C) 1997 Robin D. Clark * * Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997, 1998, 1999 Linas Vepstas * * Copyright (C) 1997-2000, Linas Vepstas <linas@linas.org> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *
@ -44,8 +44,8 @@
#include "config.h" #include "config.h"
#include "AccInfo.h" #include "AccInfo.h"
#include "Transaction.h"
#include "GNCId.h" #include "GNCId.h"
#include "Transaction.h"
/** STRUCTS *********************************************************/ /** STRUCTS *********************************************************/

View File

@ -2,7 +2,7 @@
* FileIO.c -- read from and writing to a datafile for gnucash * * FileIO.c -- read from and writing to a datafile for gnucash *
* (GnuCash/X-Accountant) * * (GnuCash/X-Accountant) *
* Copyright (C) 1997 Robin D. Clark * * Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997, 1998, 1999, 2000 Linas Vepstas * * Copyright (C) 1997-2000 Linas Vepstas <linas@linas.org> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *
@ -399,7 +399,7 @@ readGroup (int fd, Account *aparent, int token)
int i; int i;
AccountGroup *grp = xaccMallocAccountGroup(); AccountGroup *grp = xaccMallocAccountGroup();
ENTER ("readGroup"); ENTER ("");
if (NULL == aparent) { if (NULL == aparent) {
maingrp = grp; maingrp = grp;
@ -414,15 +414,15 @@ readGroup (int fd, Account *aparent, int token)
} }
XACC_FLIP_INT (numAcc); XACC_FLIP_INT (numAcc);
DEBUG ("readGroup(): expecting %d accounts \n", numAcc); DEBUG ("expecting %d accounts \n", numAcc);
/* read in the accounts */ /* read in the accounts */
for( i=0; i<numAcc; i++ ) for( i=0; i<numAcc; i++ )
{ {
Account * acc = readAccount( fd, grp, token ); Account * acc = readAccount( fd, grp, token );
if( NULL == acc ) { if( NULL == acc ) {
printf("Error: readGroup(): Short group read: \n"); PERR("Short group read: \n");
printf("expected %d, got %d accounts\n",numAcc,i); "\texpected %d, got %d accounts\n",numAcc,i);
break; break;
} }
} }
@ -454,7 +454,7 @@ readAccount( int fd, AccountGroup *grp, int token )
Account *acc; Account *acc;
char * tmp; char * tmp;
ENTER ("readAccount"); ENTER ("");
/* version 1 does not store the account number */ /* version 1 does not store the account number */
if (1 < token) { if (1 < token) {
@ -500,7 +500,7 @@ readAccount( int fd, AccountGroup *grp, int token )
tmp = readString( fd, token ); tmp = readString( fd, token );
if( NULL == tmp) return NULL; if( NULL == tmp) return NULL;
DEBUG ("readAccount(): reading acct %s \n", tmp); DEBUG ("reading acct %s \n", tmp);
xaccAccountSetName (acc, tmp); xaccAccountSetName (acc, tmp);
free (tmp); free (tmp);
@ -548,7 +548,7 @@ readAccount( int fd, AccountGroup *grp, int token )
if( err != sizeof(int) ) { return NULL; } if( err != sizeof(int) ) { return NULL; }
XACC_FLIP_INT (numTrans); XACC_FLIP_INT (numTrans);
DEBUG ("Info: readAccount(): expecting %d transactions \n", numTrans); DEBUG ("expecting %d transactions \n", numTrans);
/* read the transactions */ /* read the transactions */
for( i=0; i<numTrans; i++ ) for( i=0; i<numTrans; i++ )
{ {
@ -556,8 +556,8 @@ readAccount( int fd, AccountGroup *grp, int token )
trans = readTransaction( fd, acc, token ); trans = readTransaction( fd, acc, token );
if( trans == NULL ) if( trans == NULL )
{ {
PERR ("readAccount(): Short Transaction Read: \n"); PERR ("Short Transaction Read: \n"
printf (" expected %d got %d transactions \n",numTrans,i); "\texpected %d got %d transactions \n",numTrans,i);
break; break;
} }
#ifdef DELINT_BLANK_SPLITS_HACK #ifdef DELINT_BLANK_SPLITS_HACK
@ -653,8 +653,7 @@ springAccount (int acc_id)
/* first, see if we're confused about the account */ /* first, see if we're confused about the account */
acc = xaccGetAccountFromID (maingrp, acc_id); acc = xaccGetAccountFromID (maingrp, acc_id);
if (acc) { if (acc) {
printf ("Internal Error: springAccount(): \n"); PERR ("account already parented \n");
printf ("account already parented \n");
return NULL; return NULL;
} }
@ -666,8 +665,7 @@ springAccount (int acc_id)
} }
/* if we got to here, its an error */ /* if we got to here, its an error */
printf ("Internal Error: springAccount(): \n"); PERR ("Couldn't find account \n");
printf ("Couldn't find account \n");
return NULL; return NULL;
} }
@ -738,7 +736,7 @@ readTransaction( int fd, Account *acc, int token )
double num_shares = 0.0; double num_shares = 0.0;
double share_price = 0.0; double share_price = 0.0;
ENTER ("readTransaction"); ENTER ("");
/* create a transaction structure */ /* create a transaction structure */
trans = xaccMallocTransaction(); trans = xaccMallocTransaction();
@ -944,7 +942,7 @@ readTransaction( int fd, Account *acc, int token )
xaccSplitSetSharePriceAndAmount (s, share_price, num_shares); xaccSplitSetSharePriceAndAmount (s, share_price, num_shares);
} }
DEBUG ("readTransaction(): num_shares %f \n", num_shares); DEBUG ("num_shares %f \n", num_shares);
/* Read the account numbers for double-entry */ /* Read the account numbers for double-entry */
/* These are first used in Version 2 of the file format */ /* These are first used in Version 2 of the file format */
@ -960,7 +958,7 @@ readTransaction( int fd, Account *acc, int token )
return NULL; return NULL;
} }
XACC_FLIP_INT (acc_id); XACC_FLIP_INT (acc_id);
DEBUG ("readTransaction(): credit %d\n", acc_id); DEBUG ("credit %d\n", acc_id);
peer_acc = locateAccount (acc_id); peer_acc = locateAccount (acc_id);
/* insert the split part of the transaction into /* insert the split part of the transaction into
@ -978,7 +976,7 @@ readTransaction( int fd, Account *acc, int token )
return NULL; return NULL;
} }
XACC_FLIP_INT (acc_id); XACC_FLIP_INT (acc_id);
DEBUG ("readTransaction(): debit %d\n", acc_id); DEBUG ("debit %d\n", acc_id);
peer_acc = locateAccount (acc_id); peer_acc = locateAccount (acc_id);
if (peer_acc) { if (peer_acc) {
Split *split; Split *split;
@ -1067,7 +1065,7 @@ readSplit ( int fd, int token )
/* create a split structure */ /* create a split structure */
split = xaccMallocSplit(); split = xaccMallocSplit();
ENTER ("readSplit"); ENTER ("");
tmp = readString( fd, token ); tmp = readString( fd, token );
if( NULL == tmp ) if( NULL == tmp )
@ -1161,7 +1159,7 @@ readSplit ( int fd, int token )
XACC_FLIP_DOUBLE (share_price); XACC_FLIP_DOUBLE (share_price);
xaccSplitSetSharePriceAndAmount (split, share_price, num_shares); xaccSplitSetSharePriceAndAmount (split, share_price, num_shares);
DEBUG ("readSplit(): num_shares %f \n", num_shares); DEBUG ("num_shares %f \n", num_shares);
/* Read the account number */ /* Read the account number */
@ -1173,7 +1171,7 @@ readSplit ( int fd, int token )
return NULL; return NULL;
} }
XACC_FLIP_INT (acc_id); XACC_FLIP_INT (acc_id);
DEBUG ("readSplit(): account id %d\n", acc_id); DEBUG ("account id %d\n", acc_id);
peer_acc = locateAccount (acc_id); peer_acc = locateAccount (acc_id);
xaccAccountInsertSplit (peer_acc, split); xaccAccountInsertSplit (peer_acc, split);
@ -1204,7 +1202,7 @@ readString( int fd, int token )
err = read( fd, str, size ); err = read( fd, str, size );
if( err != size ) if( err != size )
{ {
printf( "Error: readString: size = %d err = %d str = %s\n", size, err, str ); PERR("size = %d err = %d str = %s\n", size, err, str );
free(str); free(str);
return NULL; return NULL;
} }
@ -1408,7 +1406,7 @@ xaccWriteAccountGroup (int fd, AccountGroup *grp )
int token = VERSION; /* The file format version */ int token = VERSION; /* The file format version */
int err = 0; int err = 0;
ENTER ("xaccWriteAccountGroup"); ENTER ("");
if( 0 > fd ) if( 0 > fd )
{ {
@ -1475,7 +1473,7 @@ writeGroup (int fd, AccountGroup *grp )
int i,numAcc; int i,numAcc;
int err = 0; int err = 0;
ENTER ("writeGroup"); ENTER ("");
if (NULL == grp) return 0; if (NULL == grp) return 0;
@ -1527,7 +1525,7 @@ writeAccount( int fd, Account *acc )
int numChildren = 0; int numChildren = 0;
const char * tmp; const char * tmp;
DEBUG ("writeAccount(): writing acct %s \n", xaccAccountGetName (acc)); DEBUG ("writing acct %s \n", xaccAccountGetName (acc));
acc_id = acc->id; acc_id = acc->id;
XACC_FLIP_INT (acc_id); XACC_FLIP_INT (acc_id);
@ -1619,7 +1617,7 @@ writeAccount( int fd, Account *acc )
if( err != sizeof(int) ) if( err != sizeof(int) )
return -1; return -1;
DEBUG ("writeAccount(): will write %d trans\n", numUnwrittenTrans); DEBUG ("will write %d trans\n", numUnwrittenTrans);
if (0 != xaccAccountStagedTransactionTraversal(acc, 2, if (0 != xaccAccountStagedTransactionTraversal(acc, 2,
_write_transaction_wrapper_, &fd)) { _write_transaction_wrapper_, &fd)) {
@ -1659,7 +1657,7 @@ writeTransaction( int fd, Transaction *trans )
int i=0; int i=0;
Timespec ts; Timespec ts;
ENTER ("writeTransaction"); ENTER ("");
err = writeString( fd, xaccTransGetNum (trans) ); err = writeString( fd, xaccTransGetNum (trans) );
if( -1 == err ) return err; if( -1 == err ) return err;
@ -1715,7 +1713,7 @@ writeSplit ( int fd, Split *split )
Account *xfer_acc = NULL; Account *xfer_acc = NULL;
char recn; char recn;
ENTER ("writeSplit"); ENTER ("");
err = writeString( fd, xaccSplitGetMemo (split) ); err = writeString( fd, xaccSplitGetMemo (split) );
if( -1 == err ) if( -1 == err )
@ -1738,7 +1736,7 @@ writeSplit ( int fd, Split *split )
if( -1 == err ) return err; if( -1 == err ) return err;
damount = xaccSplitGetShareAmount (split); damount = xaccSplitGetShareAmount (split);
DEBUG ("writeSplit: amount=%f \n", damount); DEBUG ("amount=%f \n", damount);
XACC_FLIP_DOUBLE (damount); XACC_FLIP_DOUBLE (damount);
err = write( fd, &damount, sizeof(double) ); err = write( fd, &damount, sizeof(double) );
if( err != sizeof(double) ) if( err != sizeof(double) )
@ -1754,7 +1752,7 @@ writeSplit ( int fd, Split *split )
xfer_acc = split->acc; xfer_acc = split->acc;
acc_id = -1; acc_id = -1;
if (xfer_acc) acc_id = xfer_acc -> id; if (xfer_acc) acc_id = xfer_acc -> id;
DEBUG ("writeSplit: credit %d \n", acc_id); DEBUG ("credit %d \n", acc_id);
XACC_FLIP_INT (acc_id); XACC_FLIP_INT (acc_id);
err = write( fd, &acc_id, sizeof(int) ); err = write( fd, &acc_id, sizeof(int) );
if( err != sizeof(int) ) if( err != sizeof(int) )
@ -1776,7 +1774,7 @@ writeInvAcct ( int fd, InvAcct * invacct )
{ {
int err=0; int err=0;
ENTER ("writeInvAcct"); ENTER ("");
if (!invacct) return 0; if (!invacct) return 0;
err = writeString( fd, xaccInvAcctGetPriceSrc (invacct) ); err = writeString( fd, xaccInvAcctGetPriceSrc (invacct) );
@ -1800,7 +1798,7 @@ writeAccInfo ( int fd, AccInfo *accinfo )
int err=0; int err=0;
InvAcct *invacct=NULL; InvAcct *invacct=NULL;
ENTER ("writeAccInfo"); ENTER ("");
if (!accinfo) return err; if (!accinfo) return err;
invacct = xaccCastToInvAcct (accinfo); invacct = xaccCastToInvAcct (accinfo);

View File

@ -180,7 +180,7 @@ xaccGUIDNew(GUID *guid)
if (xaccGUIDType(guid) == GNC_ID_NONE) if (xaccGUIDType(guid) == GNC_ID_NONE)
break; break;
PWARN("xaccGUIDNew: duplicate id\n"); PWARN("duplicate id\n");
} while(1); } while(1);
} }

View File

@ -97,7 +97,7 @@ xaccGroupToList (Account *acc)
if (!acc) return NULL; if (!acc) return NULL;
ENTER ("xaccGroupToList(): acc=%p \n", acc); ENTER ("acc=%p \n", acc);
nacc = xaccGetNumAccounts (acc->children); nacc = xaccGetNumAccounts (acc->children);
nacc ++; /* add one for this account */ nacc ++; /* add one for this account */
@ -132,7 +132,7 @@ xaccGroupToList (Account *acc)
} }
} }
list[n] = NULL; list[n] = NULL;
LEAVE ("xaccGroupToList(): n=%d nacc=%d \n", n, nacc); LEAVE ("n=%d nacc=%d \n", n, nacc);
assert (n==nacc); assert (n==nacc);
return list; return list;

View File

@ -316,7 +316,7 @@ char * xaccReadQIFAccount (int fd, Account * acc)
xaccAccountSetType (acc, LIABILITY); xaccAccountSetType (acc, LIABILITY);
} else } else
{ {
printf ("QIF Parse: Unsupported account type %s \n", &qifline[1]); PERR("Unsupported account type %s \n", &qifline[1]);
xaccAccountSetType (acc, -1); /* hack alert -- */ xaccAccountSetType (acc, -1); /* hack alert -- */
} }
break; break;
@ -914,7 +914,7 @@ xaccReadQIFTransaction (int fd, Account *acc, int guess_name,
pute = xaccSplitGetValue (source_split); pute = xaccSplitGetValue (source_split);
if (isneg) pute = -pute; if (isneg) pute = -pute;
printf ("QIF Warning: Adjustment of %.2f to amount %.2f not handled \n", adjust, pute); PWARN("Adjustment of %.2f to amount %.2f not handled \n", adjust, pute);
} }
break; break;
case 'P': case 'P':
@ -998,7 +998,7 @@ xaccReadQIFTransaction (int fd, Account *acc, int guess_name,
wanted = (int) (100.0 * parse + 0.5); wanted = (int) (100.0 * parse + 0.5);
got = (int) (100.0 * (pute+adjust) + 0.5); got = (int) (100.0 * (pute+adjust) + 0.5);
if (wanted != got) { if (wanted != got) {
printf ("QIF Parse Error: wanted %f got %f \n", parse, pute); PERR("Parse $: wanted %f got %f \n", parse, pute);
} }
} }
} }

View File

@ -208,8 +208,8 @@ xaccQueryInvert(Query * q) {
num_or_terms = g_list_length(q->terms); num_or_terms = g_list_length(q->terms);
/* printf("inverting query: "); DEBUG("inverting query: ");
print_query(q); */ DEBUGCMD (print_query(q));
switch(num_or_terms) { switch(num_or_terms) {
case 0: case 0:
@ -284,9 +284,8 @@ xaccQueryMerge(Query * q1, Query * q2, QueryOp op) {
Query * t1, * t2; Query * t1, * t2;
GList * i, * j; GList * i, * j;
/* printf("merging queries: op=%d\n", op); DEBUG("merging queries: op=%d\n", op);
print_query(q1); DEBUGCMD(print_query(q1); print_query(q2);)
print_query(q2); */
switch(op) { switch(op) {
case QUERY_OR: case QUERY_OR:
@ -758,13 +757,11 @@ xaccQueryGetSplits(Query * q) {
gettimeofday(&end, NULL); gettimeofday(&end, NULL);
#if 0 PINFO("elapsed time = %e ms\n",
printf("xaccQueryGetSplits: elapsed time = %e ms\n",
(end.tv_sec - start.tv_sec)*1000.0 + (end.tv_sec - start.tv_sec)*1000.0 +
(end.tv_usec - start.tv_usec)/1000.0); (end.tv_usec - start.tv_usec)/1000.0);
printf("xaccQueryGetSplits: %d splits checked, %d splits matched.\n", PINFO("%d splits checked, %d splits matched.\n",
total_splits_checked, split_count); total_splits_checked, split_count);
#endif
q->changed = 0; q->changed = 0;
if(q->split_list) { if(q->split_list) {

View File

@ -173,7 +173,7 @@ xaccQueuePushHead (Queue *q, Split *s)
/* I'm too lazy to code up a more complex feature that no one will use ... */ /* I'm too lazy to code up a more complex feature that no one will use ... */
/* If you are reading this, you are invited to do so yourself :-) */ /* If you are reading this, you are invited to do so yourself :-) */
if ( !DEQ (q->head_amount, 0.0)) { if ( !DEQ (q->head_amount, 0.0)) {
PERR ("xaccQueuePushHead(): The current implementation does not\n" PERR ("The current implementation does not\n"
"\tsupport pushing onto a queue that has been popped \n"); "\tsupport pushing onto a queue that has been popped \n");
return; return;
} }
@ -342,14 +342,14 @@ xaccQueuePopTailValue (Queue *q, double val)
double double
xaccQueuePopHeadValue (Queue *q, double val) xaccQueuePopHeadValue (Queue *q, double val)
{ {
PERR("xaccQueuePopHeadValue(): not implemented\n"); PERR("not implemented\n");
return 0.0; return 0.0;
} }
double double
xaccQueuePopHeadShares (Queue *q, double val) xaccQueuePopHeadShares (Queue *q, double val)
{ {
PERR("xaccQueuePopHeadsahres(): not implemented\n"); PERR("not implemented\n");
return 0.0; return 0.0;
} }

View File

@ -87,8 +87,7 @@ xaccAccountScrubOrphans (Account *acc)
Transaction *trans; Transaction *trans;
Account * parent; Account * parent;
PINFO ("xaccAccountScrubOrphans(): " PINFO ("Looking for orphans in account %s \n", xaccAccountGetName(acc));
"Looking for orphans in account %s \n", xaccAccountGetName(acc));
slist = xaccAccountGetSplitList (acc); slist = xaccAccountGetSplitList (acc);
split = slist[0]; split = slist[0];
@ -102,7 +101,7 @@ xaccAccountScrubOrphans (Account *acc)
parent = xaccSplitGetAccount (s); parent = xaccSplitGetAccount (s);
if (!parent) { if (!parent) {
Account *orph; Account *orph;
DEBUG ("xaccAccountScrubOrphans(): Found an orphan \n"); DEBUG ("Found an orphan \n");
/* OK, we found an orphan. Put it in an orphan account. */ /* OK, we found an orphan. Put it in an orphan account. */
orph = GetOrMakeAccount (acc, trans, ORPHAN_STR); orph = GetOrMakeAccount (acc, trans, ORPHAN_STR);
xaccAccountBeginEdit (orph, 1); xaccAccountBeginEdit (orph, 1);
@ -148,8 +147,7 @@ xaccAccountScrubImbalance (Account *acc)
Split *split, **slist; Split *split, **slist;
Transaction *trans; Transaction *trans;
PINFO ("xaccAccountScrubImbalance(): " PINFO ("Looking for imbalance in account %s \n", xaccAccountGetName(acc));
"Looking for imbalance in account %s \n", xaccAccountGetName(acc));
slist = xaccAccountGetSplitList (acc); slist = xaccAccountGetSplitList (acc);
split = slist[0]; split = slist[0];
@ -161,8 +159,7 @@ xaccAccountScrubImbalance (Account *acc)
if (!(DEQ (imbalance, 0.0))) { if (!(DEQ (imbalance, 0.0))) {
Split *splat; Split *splat;
Account *orph; Account *orph;
DEBUG ("xaccAccountScrubImbalance(): " DEBUG ("Found imbalance of %g\n", imbalance);
"Found imbalance of %g\n", imbalance);
/* OK, we found an imbalanced trans. Put it in the imbal account. */ /* OK, we found an imbalanced trans. Put it in the imbal account. */
orph = GetOrMakeAccount (acc, trans, IMBALANCE_STR); orph = GetOrMakeAccount (acc, trans, IMBALANCE_STR);

View File

@ -2,7 +2,7 @@
* util.c -- utility functions that are used everywhere else for * * util.c -- utility functions that are used everywhere else for *
* xacc (X-Accountant) * * xacc (X-Accountant) *
* Copyright (C) 1997 Robin D. Clark * * Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997, 1998, 1999, 2000 Linas Vepstas * * Copyright (C) 1997-2000 Linas Vepstas <linas@linas.org> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *
@ -60,8 +60,39 @@ int loglevel[MODULE_MAX] =
2, /* GUI */ 2, /* GUI */
2, /* SCRUB */ 2, /* SCRUB */
2, /* GTK_REG */ 2, /* GTK_REG */
2, /* GUILE */
4, /* BACKEND */
}; };
/********************************************************************\
\********************************************************************/
/* prettify() cleans up subroutine names.
* AIX/xlC has the habit of printing signatures not names; clean this up.
* On other operating systems, truncate name to 30 chars.
* Note this routine is not thread safe. Note we wouldn't need this
* routine if AIX did something more reasonable. Hope thread safety
* doesn't poke us in eye.
*/
char *
prettify (const char *name)
{
static char bf[35];
char *p;
strncpy (bf, name, 29); bf[28] = 0;
p = strchr (bf, '(');
if (p)
{
*(p+1) = ')';
*(p+2) = 0x0;
}
else
{
strcpy (&bf[26], "...()");
}
return bf;
}
/********************************************************************\ /********************************************************************\
* DEBUGGING MEMORY ALLOCATION STUFF * * DEBUGGING MEMORY ALLOCATION STUFF *
\********************************************************************/ \********************************************************************/

View File

@ -2,7 +2,7 @@
* util.h -- utility functions that are used everywhere for * * util.h -- utility functions that are used everywhere for *
* gnucash (ex-xacc (X-Accountant)) * * gnucash (ex-xacc (X-Accountant)) *
* Copyright (C) 1997 Robin D. Clark * * Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1998, 1999, 2000 Linas Vepstas * * Copyright (C) 1998-2000 Linas Vepstas <linas@linas.org> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *
@ -51,7 +51,8 @@
#define MOD_SCRUB 7 #define MOD_SCRUB 7
#define MOD_GTK_REG 8 #define MOD_GTK_REG 8
#define MOD_GUILE 9 #define MOD_GUILE 9
#define MODULE_MAX 10 #define MOD_BACKEND 10
#define MODULE_MAX 11
extern int loglevel[MODULE_MAX]; extern int loglevel[MODULE_MAX];
@ -65,15 +66,18 @@ extern int loglevel[MODULE_MAX];
#undef DEBUG #undef DEBUG
#endif #endif
/* some preprocessors use ugly __FUNCTION__ substitution ... */
char * prettify (const char *);
/* utility macros */ /* utility macros */
#define FATAL(x...) LG(1, "Fatal Error: "); LG(1, ##x); #define FATAL(x...) LG(1, "Fatal Error: %s: ", prettify(__FUNCTION__)); LG(1, ##x);
#define PERR(x...) LG(LERR, "Error: "); LG(LERR, ##x); #define PERR(x...) LG(LERR, "Error: %s: ", prettify(__FUNCTION__)); LG(LERR, ##x);
#define PWARN(x...) LG(LWARN, "Waring: "); LG(LWARN, ##x); #define PWARN(x...) LG(LWARN, "Waring: %s: ", prettify(__FUNCTION__)); LG(LWARN, ##x);
#define PINFO(x...) LG(LINFO, "Info: "); LG(LINFO, ##x); #define PINFO(x...) LG(LINFO, "Info: %s: ", prettify(__FUNCTION__)); LG(LINFO, ##x);
#define DEBUG(x...) LG(LDEBUG, "Debug: "); LG(LDEBUG, ##x); #define DEBUG(x...) LG(LDEBUG, "Debug: %s: ", prettify(__FUNCTION__)); LG(LDEBUG, ##x);
#define ENTER(x...) LG(LDEBUG, "Enter: "); LG(LDEBUG, ##x); #define ENTER(x...) LG(LDEBUG, "Enter: %s: ", prettify(__FUNCTION__)); LG(LDEBUG, ##x);
#define LEAVE(x...) LG(LDEBUG, "Leave: "); LG(LDEBUG, ##x); #define LEAVE(x...) LG(LDEBUG, "Leave: %s: ", prettify(__FUNCTION__)); LG(LDEBUG, ##x);
#define DETAIL(x...) LG(LDETAIL, "Detail: "); LG(LDETAIL, ##x); #define DETAIL(x...) LG(LDETAIL, "Detail: %s: ", prettify(__FUNCTION__)); LG(LDETAIL, ##x);
#define DEBUGCMD(x) { if (LINFO) { x; }} #define DEBUGCMD(x) { if (LINFO) { x; }}