mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Dave Peticolas patch of Date: Sat, 05 Feb 2000 02:40:06 -0800
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2005 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
dd0cd39512
commit
0f1ebd5838
@ -1186,8 +1186,8 @@ IthAccount (Account **list, int i)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
gncBoolean xaccAccountsHaveCommonCurrency(Account *account_1,
|
||||
Account *account_2)
|
||||
gncBoolean
|
||||
xaccAccountsHaveCommonCurrency(Account *account_1, Account *account_2)
|
||||
{
|
||||
if ((account_1 == NULL) || (account_2 == NULL))
|
||||
return GNC_F;
|
||||
@ -1195,5 +1195,28 @@ gncBoolean xaccAccountsHaveCommonCurrency(Account *account_1,
|
||||
return xaccIsCommonCurrency(account_1->currency, account_1->security,
|
||||
account_2->currency, account_2->security);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
gncBoolean
|
||||
xaccAccountHasAncestor (Account *account, Account * ancestor)
|
||||
{
|
||||
Account *parent;
|
||||
|
||||
if ((account == NULL) || (ancestor == NULL))
|
||||
return GNC_F;
|
||||
|
||||
parent = xaccAccountGetParentAccount(account);
|
||||
while (parent != NULL)
|
||||
{
|
||||
if (parent == ancestor)
|
||||
return GNC_T;
|
||||
|
||||
parent = xaccAccountGetParentAccount(parent);
|
||||
}
|
||||
|
||||
return GNC_F;
|
||||
}
|
||||
|
||||
/*************************** END OF FILE **************************** */
|
||||
|
@ -164,4 +164,8 @@ Account * IthAccount (Account **list, int i);
|
||||
gncBoolean xaccAccountsHaveCommonCurrency(Account *account_1,
|
||||
Account *account_2);
|
||||
|
||||
/* Returns true if the account has 'ancestor' as an ancestor.
|
||||
* Returns false if either is NULL. */
|
||||
gncBoolean xaccAccountHasAncestor (Account *, Account * ancestor);
|
||||
|
||||
#endif /* __XACC_ACCOUNT_H__ */
|
||||
|
@ -29,7 +29,9 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -225,6 +227,42 @@ xaccQuerySetDateRangeL (Query *q, long long early, long long late)
|
||||
q->latest.tv_sec = late;
|
||||
}
|
||||
|
||||
void
|
||||
xaccQuerySetEarliest (Query *q, time_t earliest)
|
||||
{
|
||||
if (!q) return;
|
||||
q->changed = 1;
|
||||
q->earliest.tv_sec = earliest;
|
||||
}
|
||||
|
||||
void
|
||||
xaccQuerySetLatest (Query *q, time_t latest)
|
||||
{
|
||||
if (!q) return;
|
||||
q->changed = 1;
|
||||
q->latest.tv_sec = latest;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
xaccQueryShowEarliestDateFound (Query *q)
|
||||
{
|
||||
if (!q) return;
|
||||
q->changed = 1;
|
||||
q->earliest.tv_sec = LONG_LONG_MIN;
|
||||
q->earliest.tv_nsec = 0;
|
||||
}
|
||||
|
||||
void
|
||||
xaccQueryShowLatestDateFound (Query *q)
|
||||
{
|
||||
if (!q) return;
|
||||
q->changed = 1;
|
||||
q->latest.tv_sec = LONG_LONG_MAX;
|
||||
q->latest.tv_nsec = 0;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
/* ================================================== */
|
||||
@ -283,21 +321,65 @@ xaccQuerySetDateRangeL (Query *q, long long early, long long late)
|
||||
} \
|
||||
}
|
||||
|
||||
static gncBoolean
|
||||
gnc_strisnum(char *s)
|
||||
{
|
||||
if (s == NULL) return GNC_F;
|
||||
if (*s == 0) return GNC_F;
|
||||
|
||||
while (*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s == 0) return GNC_F;
|
||||
if (!isdigit(*s)) return GNC_F;
|
||||
|
||||
while (*s && isdigit(*s))
|
||||
s++;
|
||||
|
||||
if (*s == 0) return GNC_T;
|
||||
|
||||
while (*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s == 0) return GNC_T;
|
||||
|
||||
return GNC_F;
|
||||
}
|
||||
|
||||
#define CNUM { \
|
||||
/* sort on transaction number */ \
|
||||
unsigned long n1; \
|
||||
unsigned long n2; \
|
||||
da = ta->num; \
|
||||
db = tb->num; \
|
||||
if (da && db) { \
|
||||
retval = strcmp (da, db); \
|
||||
/* if strings differ, return */ \
|
||||
if (retval) return retval; \
|
||||
} else \
|
||||
if (gnc_strisnum(da)) { \
|
||||
if (!gnc_strisnum(db)) { \
|
||||
return -1; \
|
||||
} \
|
||||
sscanf(da, "%lu", &n1); \
|
||||
sscanf(db, "%lu", &n2); \
|
||||
if (n1 < n2) { \
|
||||
return -1; \
|
||||
} \
|
||||
if (n1 == n2) { \
|
||||
return 0; \
|
||||
} \
|
||||
return +1; \
|
||||
} \
|
||||
if (gnc_strisnum(db)) { \
|
||||
return +1; \
|
||||
} \
|
||||
if (!da && db) { \
|
||||
return -1; \
|
||||
} else \
|
||||
} \
|
||||
if (da && !db) { \
|
||||
return +1; \
|
||||
} \
|
||||
if (!da && !db) { \
|
||||
return 0; \
|
||||
} \
|
||||
retval = strcmp (da, db); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
#define CMEMO { \
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "gnc-common.h"
|
||||
#include "Account.h"
|
||||
#include "Transaction.h"
|
||||
|
||||
@ -72,9 +73,17 @@ void xaccQuerySetDateRange (Query *, time_t earliest, time_t latest);
|
||||
void xaccQuerySetDateRangeL (Query *, long long earliest, long long latest);
|
||||
#endif
|
||||
|
||||
void xaccQuerySetEarliest (Query *, time_t earliest);
|
||||
void xaccQuerySetLatest (Query *, time_t latest);
|
||||
|
||||
/* The xaccQueryShowEarliestDateFound function and its partner tell
|
||||
* the Query to use the earliest (resp. latest) splits found. */
|
||||
void xaccQueryShowEarliestDateFound (Query *);
|
||||
void xaccQueryShowLatestDateFound (Query *);
|
||||
|
||||
/* The xaccQuerySetSortOrder() method sets the sort order that
|
||||
* should be used on the splits. The three arguments should
|
||||
* be choosen from the enums above. The first argument has the
|
||||
* be chosen from the enums above. The first argument has the
|
||||
* sort priority, the next the next, etc.
|
||||
*/
|
||||
void xaccQuerySetSortOrder (Query *, int, int, int);
|
||||
|
@ -28,6 +28,8 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -204,6 +206,20 @@ scanDate(const char *buff, int *day, int *month, int *year)
|
||||
/* get numeric values */
|
||||
switch(dateFormat)
|
||||
{
|
||||
#if 0 /* strptime broken in glibc <= 2.1.2 */
|
||||
case DATE_FORMAT_LOCALE:
|
||||
if (buff[0] != 0)
|
||||
{
|
||||
struct tm thetime;
|
||||
|
||||
strptime(buff, "%x", &thetime);
|
||||
|
||||
iday = thetime.tm_mday;
|
||||
imonth = thetime.tm_mon + 1;
|
||||
iyear = thetime.tm_year + 1900;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case DATE_FORMAT_UK:
|
||||
case DATE_FORMAT_CE:
|
||||
if (first_field) iday = atoi (first_field);
|
||||
|
@ -390,7 +390,7 @@ xaccSPrintAmount (char * bufp, double val, short shrs)
|
||||
}
|
||||
|
||||
/* Now see if we print parentheses */
|
||||
if (print_sign && (sign_posn == 0))
|
||||
if (print_sign && (sign_posn == 0) && (val < 0.0))
|
||||
bufp = stpcpy(bufp, "(");
|
||||
|
||||
/* Now print the value */
|
||||
@ -398,7 +398,7 @@ xaccSPrintAmount (char * bufp, double val, short shrs)
|
||||
shrs & PRTSEP, ~(shrs & PRTSHR));
|
||||
|
||||
/* Now see if we print parentheses */
|
||||
if (print_sign && (sign_posn == 0))
|
||||
if (print_sign && (sign_posn == 0) && (val < 0.0))
|
||||
bufp = stpcpy(bufp, ")");
|
||||
|
||||
/* Now see if we print currency */
|
||||
|
@ -37,19 +37,9 @@
|
||||
/* The debuging macros enable the setting of trace messages */
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_NANA_H
|
||||
#include <nana.h>
|
||||
|
||||
/* override standard system assert with nana I assertion */
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert I
|
||||
#else /* HAVE_NANA_H */
|
||||
/* if there is no nana, use he system assert and mush up LG */
|
||||
#include <assert.h>
|
||||
|
||||
#define LG(condition,args...) if (condition) fprintf(stderr, ##args)
|
||||
#endif /* HAVE_NANA_H */
|
||||
|
||||
#define MOD_ENGINE 1
|
||||
#define MOD_IO 2
|
||||
@ -87,6 +77,7 @@ extern int loglevel[MODULE_MAX];
|
||||
#define DEBUGCMD(x) { if (LINFO) { x; }}
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define ERROR() fprintf(stderr,"%s: Line %d, error = %s\n", \
|
||||
__FILE__, __LINE__, strerror(errno));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user