Commit Graph
1342 Commits
Author SHA1 Message Date
John Ralls 2911a0cce3 Bug 797384 - Gnucash doesn't handle commodity prices with big...
numerator/denominator properly

- Use GNC_HOW_DENOM_REDUCE | GNC_HOW_RND_ROUND to preserve precision while
avoiding overflows.

- Rearrange the function's tests to perform only one division or
multiplication instead of unconditionally dividing

- Rename the from_ and to_ variables to p(rice)1 and p2 to reduce
conflation with the input from and to.
2026-05-25 11:32:19 -07:00
John Ralls ec4a85a56c Correct the Doxygen doc for qof_instance_get/set_kvp. 2026-05-22 15:47:40 -07:00
Christopher Lam bbb80105ff [gnc-aqbanking-templates.cpp] fix incorrect setter, free GList* 2026-05-22 21:15:29 +08:00
Christopher Lam 55856c63dd [gnc-budget.cpp] null check arguments *before* accessing them 2026-05-22 21:15:27 +08:00
Bruce Schuck 4ff491b565 Removed AEX from list of commodities.
euronext.com is now using JS based anti-webscraping.
2026-05-10 10:49:32 -07:00
John Ralls d4c6101c6c Return immediately from qof_book_destroy if hash_of_collections is null.
If qof_book_destroy is called on a QofBook* freshly created with
qof_book_new (usually because it was used to create a session that now
must be destroyed) it would try to empty the non-existent hash tables,
crashing.
2026-04-22 11:24:18 -07:00
John Ralls d42e2c5e40 Apply -Wall -Werr -Wmissing-prototypes to C++ compilation on Windows.
And fix the resulting errors.
2026-03-29 13:46:27 -07:00
Christopher Lam 3d4f19f830 [gnc-date.cpp] fix ifdef conditional, and comment 2026-03-17 09:10:19 +08:00
Christopher Lam 06c7f4bd3f [gnc-datetime.cpp] fast_iso8601_utc_parse: precompute length
because std::from_chars is UB if the string is less than 4 bytes
therefore end_ptr would point to unallocated memory.
2026-03-17 09:10:19 +08:00
Robert Fewell b02612c437 Bug799722 - Inconsistent wording: Bill and Invoice
There is some inconsistency with the wording of the invoice menu
entries when say a bill is displayed, like 'Jump to Invoice' when it
would be 'Jump to Bill'. Whilst looking at this, further places where
this could be a problem was highlighted so this commit changes entries
to 'Business item'.
2026-03-13 16:05:36 +00:00
Robert Fewell 62af7f0d6d Bug 799734 - mapped OFX income account not listed
Change the Import Map Editor to look for the KVP slot
"ofx/associated-income-account" so it can be listed. The account
reference stored is a GUID so add a function to retrieve that so the
existing gnc_account_delete_map_entry function can be used to remove it.
2026-03-13 09:26:22 +00:00
John Ralls 1fda575c5b Bug 666536 - smallest fraction of KRW is invalid 2026-02-27 13:14:20 -08:00
Christopher Lam 47938d1a2c [gnc-date.cpp] gnc_date_interval_format localisable with ICU 2026-02-13 21:58:01 +08:00
Stefan Koch e1bbb9bb7b Bug 798873 - Crash when scrubbing after "undoing” changes
Fix double delete in qof_instance_kvp_remove_guid and remove vestigial glist support.

In the KvpValue::Type::FRAME case if the guid matches, it does both:
            delete inst->kvp_data->set_path({path}, nullptr);
            delete v;
Where earlier the v was set to be:
    auto v = inst->kvp_data->get_slot({path});
The second delete is a duplicate of the first and should be removed.
2026-01-30 09:50:21 -05:00
Stefan Koch 52bbcf72c5 Fix innocuous bug in qofinstance idata property. 2026-01-30 09:50:21 -05:00
Christopher Lam 0b4f14e107 [Transaction.cpp] use g_list_copy_deep avoiding g_list_append 2026-01-27 23:43:49 +08:00
Christopher Lam d64c8c8d59 [account.cpp] remove unused static var 2026-01-27 23:43:44 +08:00
Christopher Lam 3a2ac526a6 [gnc-commodity.cpp] improve gnc_commodity_compare
ensure it is a stable sort
2026-01-24 23:49:30 +08:00
John Ralls e5fe2f3e0e Merge Stefan Koch's 'sk-unittest-qofid' into stable. 2026-01-17 17:11:27 -08:00
Stefan Koch 113af56272 fixup: Review comments about style of code. 2026-01-15 13:14:36 -05:00
Stefan Koch 7f0d66d439 fixup: Add the new test-qofid.cpp file the the source distribution. 2026-01-15 13:00:52 -05:00
Stefan Koch be5933a1ec fixup: Remove memory leaks in the test code. 2026-01-15 11:52:59 -05:00
Stefan Koch 0e3853bfb7 Fix undefined behaviour in collection_compare_cb function.
The collection_compare_cb function set the user_data pointer to point to a local variable
of the function.  That pointer is then used in the (only) calling function
qof_collection_compare to make decisions.  This is undefined.  It is likely not an actual
problem because the stack depth of the qof_collection_foreach followed by
collection_compare_cb is deeper than the qof_collection_get_data call (and others
in between if any) that the stack data user data stays uncorrupted.

But, it is undefined behavior, and could cause really subtle bugs if these there are code
changes that have deeper stack between the setting and using.

Also, using this local variable is not necessary, the qof_collection_compare function
already  sets up a variable local to its scope for this that the collection_compare_cb can
use directly.

This commit removes the local (to collection_compare_cb) variable and uses the one setup
in qof_collection_compare.

The full coverage test for qofid.cpp passed before and after this change.
2026-01-15 08:52:50 -05:00
Stefan Koch 6e9a20dfeb Implement full test coverage of libgnucash/engine/qofid
NOTE:  This does not have full coverage because the "if (!target || !ent)" body in the
collection_compare_cp function cannot be reached. There is too  much safety in the rest of
the system to test this error.

NOTE: I made this a separate test from the test-engine so that I was able to check that it
by itself could test the full coverage of the qofid.cpp file. If it was part of the larger
test, I could have missed some parts that were covered incidentally elsewhere.
2026-01-15 08:52:50 -05:00
Stefan Koch a2cc9881df Explicitly set the is_dirty attribute in qof_collection_new
It is likely that the memory was zeroed anyway, but the explicitness makes it easier to read.
2026-01-15 08:52:50 -05:00
Stefan Koch 9079d87307 Remove unused qof_collection_from_glist function. 2026-01-15 08:52:50 -05:00
Christopher Lam 334b015c19 [Account.h] gnc_account_get_earliest_date
Returns posted date of earliest split, or INT64_MAX if the account has
no splits.

This may reflect the opening date of the account.
2026-01-14 07:58:07 +08:00
John Ralls 622c35cfaa WORDS_BIGENDIAN needs to be a compile definition and checked with ifdef. 2026-01-13 11:06:54 -08:00
Robert Fewell b5185e1823 Bug 799706 - Rename Namespace
Add a rename namespace button to the Security editor that is enabled by
the selection of a namespace row in the tree view.
2026-01-08 10:31:39 +00:00
Christopher Lam c3e4f374a9 [account.cpp] gnc_account_child_index non-child acct should return -1
bugfix from 6cac9d0ebb
2026-01-05 07:17:04 +08:00
John Ralls be46171d02 Turn of deprecation warning for wstring_convert.
Deprecated in C++17, no replacement until C++26.
2026-01-01 17:41:08 -08:00
John Ralls 942313d099 GncDateTime: New exceptions and a 32-bit time_t problem.
Boost::date_time has changed to throwing a std::out_of_range instead of a
boost::date_time::gregorian::bad_year when a date is outside of the
1400-9999 year range it can deal with.

We also recently discovered that it will use the system localtime function
when creating a new date which can lead to a 2038 failure. Use std::chrono
to resolve that problem.
2025-12-28 16:00:26 -08:00
John Ralls 3a06602910 Fix Asan UB complaint about int64_t alignment.
by doing endian_swap on the aligned local instead of the unaligned bytes of the memory mapped file.
2025-12-20 17:46:44 -08:00
John Ralls 34330c2a57 gncTaxTable: chain up to the correct parent function. 2025-12-16 19:10:31 -08:00
Bruce Schuck f055c3c5a4 Added US Bonds (usbonds) to gnc-commodity.cpp
New Finance::Quote module to get prices for series E, EE, or I bonds
2025-12-14 16:42:09 -08:00
Christopher Lam c80234341c [gnc-euro.cpp] fix typo for bulgarian lev rate 2025-12-09 06:18:53 +08:00
Christopher Lam 349c208a6c [guid.cpp] GncGUID* avoids temporary gnc::GUID, and better hash 2025-12-09 06:16:31 +08:00
John Ralls 6907d3648a Bulgarian Lev (BGN) replaced by Euro 1 Jan 2026. 2025-12-08 12:20:16 -08:00
Christopher Lam 722a455593 [guid.cpp] string->guid should disallow 'g' char
off-by-1 error in alpha test. only 'a'-'f' should be allowed.
2025-11-30 20:51:33 +08:00
Christopher Lam 1cfda5a71a [test-gnc-guid.cpp] use EXPECT_THROW
instead of try..catch
2025-11-30 20:51:33 +08:00
Christopher Lam cdb9dfa0ee [guid.cpp] fast_string_to_guid: -1<<4 is UB, fix UB
when parsing invalid chars, hi|lo would return -1. convert to unsigned
to avoid UB.
2025-11-30 20:51:04 +08:00
Christopher Lam 3e4e334944 [guid.cpp] string->guid: parse into uuid data, avoids memcpy 2025-11-30 20:49:40 +08:00
Christopher Lam 534bea748f [guid.cpp] Specialise guid<->32-byte string
- string->guid has branch-lite unrollable loop, fallback to slow
  boost parser
- guid->string uses lookup table
- avoids creating several temporary heap-allocated std::strings
2025-11-29 07:58:04 +08:00
Christopher Lam 3c5a1801e2 [guid.cpp] fix guid==nullptr comparison retvals
- if guid_1 guid_2 are both null they should return int(0) or bool(true)
2025-11-29 07:58:04 +08:00
John Ralls 7e5f559724 Merge Christian Wehling's 'improve_strings' into stable. 2025-11-28 10:37:04 -08:00
Christopher Lam 7c7c8b0992 [gnc-pricedb.cpp] plug leak when fiscal_end_date is null
fiscal_end_date was assigned g_date_new but never freed. merge with
invalid fiscal_end_date too.
2025-11-26 16:03:38 +08:00
Christopher Lam 04af7b5fa6 [qofobject.cpp] check col!=nullptr instead of obj
because obj was already verified non-nullptr a few lines prior. this
logic error present since original qofobject.c
2025-11-23 12:10:20 +08:00
Christopher Lam 7bdf31f9d3 [gnc-date.cpp] gnc_g_date_new_today calls gnc_gdate_set_today
instead of vice-versa.

- avoids malloc/free in gnc_gdate_set_today
- avoids unnecessary dmy->julian->dmy(*) conversion

(*) the GDate is typically used by gdate_to_time64 which performs a
julian->dmy conversion, and this is now avoided
2025-11-05 07:51:05 +08:00
Christopher Lam 2119fceb3a [transaction.cpp] xaccTransSetDate has GDate on stack
avoid malloc/free
2025-11-05 07:51:05 +08:00
Christopher Lam dde10464d1 [transaction.cpp] comparing identical txns returns 0
bypassing many comparisons
2025-11-03 10:55:42 +08:00