From 5a490d9ff7f600654d06139999c099f55eacb9d5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 28 Oct 2020 06:44:42 +0100 Subject: [PATCH 1/9] Activate feature GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE --- gnucash/gnome/assistant-hierarchy.c | 3 +++ gnucash/gnome/gnc-plugin-page-register.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/gnucash/gnome/assistant-hierarchy.c b/gnucash/gnome/assistant-hierarchy.c index 6d39f37ad3c..f5431e9b81e 100644 --- a/gnucash/gnome/assistant-hierarchy.c +++ b/gnucash/gnome/assistant-hierarchy.c @@ -1424,6 +1424,9 @@ on_finish (GtkAssistant *gtkassistant, ENTER (" "); com = gnc_currency_edit_get_currency (GNC_CURRENCY_EDIT(data->currency_selector)); + if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book())) + gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book()); + if (data->our_account_tree) { gnc_account_foreach_descendant (data->our_account_tree, diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index 797b2959d40..8afdc5d51a8 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -742,6 +742,10 @@ gnc_plugin_page_register_new_common (GNCLedgerDisplay* ledger) if (!gnc_features_check_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER)) gnc_features_set_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER); + // added for version 4.5 onwards + if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book())) + gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book()); + /* Is there an existing page? */ gsr = gnc_ledger_display_get_user_data (ledger); if (gsr) From c16bde1aeac7d5a6febf76ef236829cc11ead358 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 23 Jan 2023 13:27:57 +0800 Subject: [PATCH 2/9] [commodity-utilities] shorten workload by deduping commodities --- gnucash/report/commodity-utilities.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gnucash/report/commodity-utilities.scm b/gnucash/report/commodity-utilities.scm index 5e1990de2b5..2ca72f09c2c 100644 --- a/gnucash/report/commodity-utilities.scm +++ b/gnucash/report/commodity-utilities.scm @@ -229,6 +229,12 @@ (gnc-account-get-descendants-sorted (gnc-get-current-root-account))) (all-splits (get-all-splits currency-accounts end-date)) (interesting-splits (sort (filter interesting-split? all-splits) date Date: Mon, 23 Jan 2023 14:12:21 +0800 Subject: [PATCH 3/9] [balsheet-pnl] shorten workload by deduping commodities --- gnucash/report/reports/standard/balsheet-pnl.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gnucash/report/reports/standard/balsheet-pnl.scm b/gnucash/report/reports/standard/balsheet-pnl.scm index e1f5d2b444c..ac0bc826a21 100644 --- a/gnucash/report/reports/standard/balsheet-pnl.scm +++ b/gnucash/report/reports/standard/balsheet-pnl.scm @@ -764,12 +764,17 @@ also show overall period profit & loss.")) ;; generate an exchange-fn for date, and cache its result. (get-date-exchange-fn - (let ((h (make-hash-table))) + (let ((h (make-hash-table)) + (commodities (sort-and-delete-duplicates + (map xaccAccountGetCommodity accounts) + (lambda (a b) + (gnc:string-locale Date: Mon, 23 Jan 2023 15:01:46 +0000 Subject: [PATCH 4/9] Fix some typos --- CMakeLists.txt | 2 +- gnucash/gnome-utils/dialog-totd.c | 2 +- gnucash/gnome-utils/gnc-date-edit.c | 2 +- gnucash/gnome-utils/gnc-main-window.c | 2 +- gnucash/gnucash.cpp | 2 +- gnucash/import-export/qif-imp/assistant-qif-import.c | 2 +- libgnucash/app-utils/QuickFill.h | 2 +- libgnucash/backend/dbi/gnc-dbisqlconnection.cpp | 2 +- libgnucash/backend/dbi/gnc-dbisqlconnection.hpp | 2 +- libgnucash/engine/qoflog.cpp | 2 +- libgnucash/engine/test/test-gnc-guid.cpp | 2 +- libgnucash/gnc-module/gnc-module.c | 6 +++--- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26e700bcd8c..8a4bacf3f4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -617,7 +617,7 @@ if (XCODE_VERSION) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${LIBDIR_BUILD}/gnucash) endif() -# For binarines +# For binaries set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) if (XCODE_VERSION) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin) diff --git a/gnucash/gnome-utils/dialog-totd.c b/gnucash/gnome-utils/dialog-totd.c index 48d10fd1e26..01e16f23764 100644 --- a/gnucash/gnome-utils/dialog-totd.c +++ b/gnucash/gnome-utils/dialog-totd.c @@ -103,7 +103,7 @@ gnc_new_tip_number (TotdDialog *totd_dialog, gint offset) */ if (tip_list[current_tip_number]) tip_components = g_strsplit(tip_list[current_tip_number], "|", 0); - /* If the tip is empty, g_strisplit will return an empty list. This + /* If the tip is empty, g_strsplit will return an empty list. This * shouldn't normally happen, but make sure we don't crash just in * case */ if (tip_components == NULL) diff --git a/gnucash/gnome-utils/gnc-date-edit.c b/gnucash/gnome-utils/gnc-date-edit.c index d0d7ba8e983..fde3aa5eeab 100644 --- a/gnucash/gnome-utils/gnc-date-edit.c +++ b/gnucash/gnome-utils/gnc-date-edit.c @@ -1057,7 +1057,7 @@ gnc_date_edit_get_date_internal (GNCDateEdit *gde) if (!date_was_valid) { - /* Hm... no valid date. What should we do not? As a hacky workaround we + /* Hm... no valid date. What should we do now? As a hacky workaround we revert to today's date. Alternatively we can return some value that signals that we don't get a valid date, but all callers of this function will have to check this. Alas, I'm too lazy to do this here. */ diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c index 2ffbac0522e..51890edfde8 100644 --- a/gnucash/gnome-utils/gnc-main-window.c +++ b/gnucash/gnome-utils/gnc-main-window.c @@ -1444,7 +1444,7 @@ gnc_main_window_quit(GncMainWindow *window) GList *w, *next; /* This is not a typical list iteration. There is a possibility - * that the window maybe removed from the active_windows list so + * that the window may be removed from the active_windows list so * we have to cache the 'next' pointer before executing any code * in the loop. */ for (w = active_windows; w; w = next) diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp index d32c21018ad..ba5116fc03e 100644 --- a/gnucash/gnucash.cpp +++ b/gnucash/gnucash.cpp @@ -322,7 +322,7 @@ Gnucash::Gnucash::start ([[maybe_unused]] int argc, [[maybe_unused]] char **argv } /* Now the module files are looked up, which might cause some library - initialization to be run, hence gtk must be initialized b*eforehand. */ + initialization to be run, hence gtk must be initialized beforehand. */ gnc_module_system_init(); gnc_gui_init(); diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c index fb1347fd074..9231ef308b8 100644 --- a/gnucash/import-export/qif-imp/assistant-qif-import.c +++ b/gnucash/import-export/qif-imp/assistant-qif-import.c @@ -2119,7 +2119,7 @@ gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data) if (wind->ask_date_format && wind->date_format) qif_import_reparse_dates (wind); - /* make sure there is a file selected, may of come back */ + /* make sure there is a file selected, may have come back */ if (wind->selected_file == SCM_BOOL_F) { GtkAssistant *assistant = GTK_ASSISTANT(wind->window); diff --git a/libgnucash/app-utils/QuickFill.h b/libgnucash/app-utils/QuickFill.h index 4fd125319f9..ba85097c6fd 100644 --- a/libgnucash/app-utils/QuickFill.h +++ b/libgnucash/app-utils/QuickFill.h @@ -71,7 +71,7 @@ void gnc_quickfill_purge (QuickFill *qf); */ const char * gnc_quickfill_string (QuickFill *qf); -/** Return the subnode of the tree whose strings all hold 'wc' as +/** Return the subnode of the tree whose strings all hold 'c' as * the next letter. That is, if 'qf' holds all strings starting * with the letter 'a', and we ask for the letter 'b', then this * routine will return the node holding all strings that start diff --git a/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp b/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp index 3eaf4d9bc2b..aabacc31331 100644 --- a/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp +++ b/libgnucash/backend/dbi/gnc-dbisqlconnection.cpp @@ -556,7 +556,7 @@ GncDbiSqlConnection::quote_string (const std::string& unquoted_str) /** Check if the dbi connection is valid. If not attempt to re-establish it - * Returns TRUE is there is a valid connection in the end or FALSE otherwise + * Returns TRUE if there is a valid connection in the end or FALSE otherwise */ bool GncDbiSqlConnection::verify () noexcept diff --git a/libgnucash/backend/dbi/gnc-dbisqlconnection.hpp b/libgnucash/backend/dbi/gnc-dbisqlconnection.hpp index 7865bd216ef..a87137836ed 100644 --- a/libgnucash/backend/dbi/gnc-dbisqlconnection.hpp +++ b/libgnucash/backend/dbi/gnc-dbisqlconnection.hpp @@ -76,7 +76,7 @@ class GncDbiSqlConnection : public GncSqlConnection set_error(ERR_BACKEND_NO_ERR, 0, false); } /** Check if the dbi connection is valid. If not attempt to re-establish it - * Returns TRUE is there is a valid connection in the end or FALSE otherwise + * Returns TRUE if there is a valid connection in the end or FALSE otherwise */ bool verify() noexcept override; bool retry_connection(const char* msg) noexcept override; diff --git a/libgnucash/engine/qoflog.cpp b/libgnucash/engine/qoflog.cpp index 993d9c208d2..58a78f4ccfc 100644 --- a/libgnucash/engine/qoflog.cpp +++ b/libgnucash/engine/qoflog.cpp @@ -237,7 +237,7 @@ qof_log_init_filename(const gchar* log_filename) g_assert(g_strcmp0(log_filename, "/dev/null") != 0); /* Windows prevents renaming of open files, so the next command silently fails there - * No problem, the filename on Winows will simply have the random characters */ + * No problem, the filename on Windows will simply have the random characters */ g_rename(fname, log_filename); fout = fdopen(fd, "w"); #endif diff --git a/libgnucash/engine/test/test-gnc-guid.cpp b/libgnucash/engine/test/test-gnc-guid.cpp index 65c9f341b0e..10137f42efc 100644 --- a/libgnucash/engine/test/test-gnc-guid.cpp +++ b/libgnucash/engine/test/test-gnc-guid.cpp @@ -82,7 +82,7 @@ TEST (GncGUID, from_string) fail = true; } /* Currently, boost uuid string parsing is mostly very permissive, but it has some - * odd pet peves. See https://svn.boost.org/trac/boost/ticket/12253 for more.*/ + * odd pet peeves. See https://svn.boost.org/trac/boost/ticket/12253 for more.*/ if (BOOST_VERSION >= 106600) EXPECT_TRUE (fail) << "Parsing the bogus string should throw"; else diff --git a/libgnucash/gnc-module/gnc-module.c b/libgnucash/gnc-module/gnc-module.c index 11465757ed6..f6ffcdf7d08 100644 --- a/libgnucash/gnc-module/gnc-module.c +++ b/libgnucash/gnc-module/gnc-module.c @@ -228,9 +228,9 @@ gnc_module_system_refresh(void) /* Gotcha: On MacOS, G_MODULE_SUFFIX is defined as "so", * but if we do not build clean libtool modules with - * "-module", we get dynamic libraries ending on .dylib On - * Windows, all modules will move to bin/, so they will be - * mixed with other libraries, such as gtk+. Adding a + * "-module", we get dynamic libraries ending in .dylib + * On Windows, all modules will move to bin/, so they will + * be mixed with other libraries, such as gtk+. Adding a * prefix "libgncmod" filter will prevent the module loader * from loading other libraries. The filter should work on * other platforms. From d6ac56ce5f7e50f3d52af2d8f6188b0866dea315 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Tue, 24 Jan 2023 13:35:22 +0000 Subject: [PATCH 5/9] Re-enable -Waddress - gncInvoiceLookup etc. are now inline functions, not macros - Remove outdated comments --- bindings/business-core.i | 13 ------------- gnucash/gnome/business-urls.c | 9 --------- gnucash/gnome/dialog-invoice.c | 9 --------- libgnucash/engine/gncBillTerm.h | 2 -- libgnucash/engine/gncCustomer.h | 2 -- libgnucash/engine/gncEmployee.h | 2 -- libgnucash/engine/gncEntry.h | 2 -- libgnucash/engine/gncInvoice.h | 2 -- libgnucash/engine/gncJob.h | 2 -- libgnucash/engine/gncOrder.h | 2 -- libgnucash/engine/gncTaxTable.h | 2 -- libgnucash/engine/gncVendor.h | 2 -- 12 files changed, 49 deletions(-) diff --git a/bindings/business-core.i b/bindings/business-core.i index af1349235b8..8c7eff8d890 100644 --- a/bindings/business-core.i +++ b/bindings/business-core.i @@ -18,19 +18,6 @@ * * \********************************************************************/ -#if defined(SWIGGUILE) -%{ -/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when - * passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via - * gncInvoiceLookup and friends. When the macro gets inlined, the compiler - * emits a warning that the guid null pointer test is always true. - */ -#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2) -# pragma GCC diagnostic warning "-Waddress" -#endif -%} -#endif - %rename(gncOwnerReturnGUID) gncOwnerRetGUID; %inline %{ diff --git a/gnucash/gnome/business-urls.c b/gnucash/gnome/business-urls.c index 3e585267f23..8868eb9eb56 100644 --- a/gnucash/gnome/business-urls.c +++ b/gnucash/gnome/business-urls.c @@ -45,15 +45,6 @@ #include "dialog-invoice.h" #include "dialog-job.h" -/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when - * passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via - * gncInvoiceLookup and friends. When the macro gets inlined, the compiler - * emits a warning that the guid null pointer test is always true. - */ -#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2) -# pragma GCC diagnostic warning "-Waddress" -#endif - #define HANDLE_TYPE(URL_TYPE_STR,OBJ_TYPE) { \ QofBook *book; \ GncGUID guid; \ diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index 8307cec9f3f..e72e5f5b43b 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -80,15 +80,6 @@ #include "dialog-transfer.h" #include "gnc-uri-utils.h" -/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when - * passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via - * gncInvoiceLookup and friends. When the macro gets inlined, the compiler - * emits a warning that the guid null pointer test is always true. - */ -#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2) -# pragma GCC diagnostic warning "-Waddress" -#endif - #define DIALOG_NEW_INVOICE_CM_CLASS "dialog-new-invoice" #define DIALOG_VIEW_INVOICE_CM_CLASS "dialog-view-invoice" diff --git a/libgnucash/engine/gncBillTerm.h b/libgnucash/engine/gncBillTerm.h index 724679cc757..34c1803548e 100644 --- a/libgnucash/engine/gncBillTerm.h +++ b/libgnucash/engine/gncBillTerm.h @@ -115,8 +115,6 @@ void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff); /** Return a pointer to the instance gncBillTerm that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncBillTerm * gncBillTermLookup (QofBook *book, const GncGUID *guid); */ static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncCustomer.h b/libgnucash/engine/gncCustomer.h index 58ca70b1d58..ec970407988 100644 --- a/libgnucash/engine/gncCustomer.h +++ b/libgnucash/engine/gncCustomer.h @@ -112,8 +112,6 @@ void gncCustomerRemoveJob (GncCustomer *customer, GncJob *job); /** Return a pointer to the instance gncCustomer that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncCustomer * gncCustomerLookup (QofBook *book, const GncGUID *guid); */ static inline GncCustomer * gncCustomerLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncEmployee.h b/libgnucash/engine/gncEmployee.h index 901123b6217..98bdd8d438f 100644 --- a/libgnucash/engine/gncEmployee.h +++ b/libgnucash/engine/gncEmployee.h @@ -108,8 +108,6 @@ Account * gncEmployeeGetCCard (const GncEmployee *employee); /** Return a pointer to the instance gncEmployee that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncEmployee * gncEmployeeLookup (QofBook *book, const GncGUID *guid); */ static inline GncEmployee * gncEmployeeLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncEntry.h b/libgnucash/engine/gncEntry.h index bdb4c12128e..ee818283cf8 100644 --- a/libgnucash/engine/gncEntry.h +++ b/libgnucash/engine/gncEntry.h @@ -290,8 +290,6 @@ GncInvoice * gncEntryGetBill (const GncEntry *entry); /** Return a pointer to the instance gncEntry that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncEntry * gncEntryLookup (QofBook *book, const GncGUID *guid); */ static inline GncEntry * gncEntryLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncInvoice.h b/libgnucash/engine/gncInvoice.h index 43cb1865b3c..fcc471df8ac 100644 --- a/libgnucash/engine/gncInvoice.h +++ b/libgnucash/engine/gncInvoice.h @@ -268,8 +268,6 @@ GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot); /** Return a pointer to the instance gncInvoice that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncInvoice * gncInvoiceLookup (QofBook *book, const GncGUID *guid); */ static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncJob.h b/libgnucash/engine/gncJob.h index b40cdbcab40..d200cdf11f3 100644 --- a/libgnucash/engine/gncJob.h +++ b/libgnucash/engine/gncJob.h @@ -89,8 +89,6 @@ gboolean gncJobGetActive (const GncJob *job); /** Return a pointer to the instance gncJob that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncJob * gncJobLookup (QofBook *book, const GncGUID *guid); */ static inline GncJob * gncJobLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncOrder.h b/libgnucash/engine/gncOrder.h index 7e77969640f..769d7ec2bfe 100644 --- a/libgnucash/engine/gncOrder.h +++ b/libgnucash/engine/gncOrder.h @@ -98,8 +98,6 @@ gboolean gncOrderIsClosed (const GncOrder *order); /** Return a pointer to the instance gncOrder that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncOrder * gncOrderLookup (QofBook *book, const GncGUID *guid); */ static inline GncOrder * gncOrderLookup (const QofBook *book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncTaxTable.h b/libgnucash/engine/gncTaxTable.h index 4ec0dafb23e..a479b85e0ad 100644 --- a/libgnucash/engine/gncTaxTable.h +++ b/libgnucash/engine/gncTaxTable.h @@ -142,8 +142,6 @@ gboolean gncTaxTableEqual(const GncTaxTable *a, const GncTaxTable *b); /** Return a pointer to the instance gncTaxTable that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncTaxTable * gncTaxTableLookup (QofBook *book, const GncGUID *guid); */ static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID *guid) { diff --git a/libgnucash/engine/gncVendor.h b/libgnucash/engine/gncVendor.h index 3bcdf6272c5..718c0b851d3 100644 --- a/libgnucash/engine/gncVendor.h +++ b/libgnucash/engine/gncVendor.h @@ -108,8 +108,6 @@ int gncVendorCompare (const GncVendor *a, const GncVendor *b); /** Return a pointer to the instance gncVendor that is identified * by the guid, and is residing in the book. Returns NULL if the * instance can't be found. - * Equivalent function prototype is - * GncVendor * gncVendorLookup (QofBook *book, const GncGUID *guid); */ static inline GncVendor * gncVendorLookup (const QofBook *book, const GncGUID *guid) { From 47491eeaa5780e0b800eac1e842acd1cb8597e75 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Tue, 24 Jan 2023 13:35:46 +0000 Subject: [PATCH 6/9] Update old-style function definition for my_strtok() --- gnucash/import-export/log-replay/gnc-log-replay.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gnucash/import-export/log-replay/gnc-log-replay.c b/gnucash/import-export/log-replay/gnc-log-replay.c index 0d44e144c61..f40e287d3ce 100644 --- a/gnucash/import-export/log-replay/gnc-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-log-replay.c @@ -109,9 +109,7 @@ static char *olds; returning a 0 length valid string between two consecutive ocurence of delim. It will also return a 0 length string instead of NULL when it reaches the end of s */ -static char * my_strtok (s, delim) -char *s; -const char *delim; +static char * my_strtok (char *s, const char *delim) { char *token; /*DEBUG("strtok(): Start...");*/ From e83c91050c1082c1c2af0bb130b7fd2db06e98b1 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Tue, 24 Jan 2023 13:36:02 +0000 Subject: [PATCH 7/9] Remove unneeded dummy.cpp --- libgnucash/engine/test/CMakeLists.txt | 1 - libgnucash/engine/test/dummy.cpp | 2 -- 2 files changed, 3 deletions(-) delete mode 100644 libgnucash/engine/test/dummy.cpp diff --git a/libgnucash/engine/test/CMakeLists.txt b/libgnucash/engine/test/CMakeLists.txt index b1ff56f965f..14513d91b35 100644 --- a/libgnucash/engine/test/CMakeLists.txt +++ b/libgnucash/engine/test/CMakeLists.txt @@ -204,7 +204,6 @@ gnc_add_test(test-qofevent "${test_qofevent_SOURCES}" set(test_engine_SOURCES_DIST - dummy.cpp gtest-gnc-euro.cpp gtest-gnc-int128.cpp gtest-gnc-rational.cpp diff --git a/libgnucash/engine/test/dummy.cpp b/libgnucash/engine/test/dummy.cpp deleted file mode 100644 index 78752143ea6..00000000000 --- a/libgnucash/engine/test/dummy.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// This is a dummy source file since we need a C++ file in test_engine so -// it will be linked as a C++ program. From 925fcbc3fdf7c0f32e7f307cdcebd8bd1e985a95 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Tue, 24 Jan 2023 13:36:23 +0000 Subject: [PATCH 8/9] Remove unused gnc-jalali.{c,h} --- libgnucash/core-utils/CMakeLists.txt | 2 - libgnucash/core-utils/gnc-jalali.c | 196 --------------------------- libgnucash/core-utils/gnc-jalali.h | 46 ------- po/POTFILES.in | 1 - 4 files changed, 245 deletions(-) delete mode 100644 libgnucash/core-utils/gnc-jalali.c delete mode 100644 libgnucash/core-utils/gnc-jalali.h diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt index d2ceff6a9e0..7d7b8653da8 100644 --- a/libgnucash/core-utils/CMakeLists.txt +++ b/libgnucash/core-utils/CMakeLists.txt @@ -11,7 +11,6 @@ set (core_utils_SOURCES gnc-filepath-utils.cpp gnc-gkeyfile-utils.c gnc-glib-utils.c - gnc-jalali.c gnc-locale-utils.c gnc-locale-utils.cpp gnc-path.c @@ -29,7 +28,6 @@ set(core_utils_noinst_HEADERS gnc-filepath-utils.h gnc-gkeyfile-utils.h gnc-glib-utils.h - gnc-jalali.h gnc-locale-utils.h gnc-locale-utils.hpp gnc-path.h diff --git a/libgnucash/core-utils/gnc-jalali.c b/libgnucash/core-utils/gnc-jalali.c deleted file mode 100644 index 2cd85dd16b0..00000000000 --- a/libgnucash/core-utils/gnc-jalali.c +++ /dev/null @@ -1,196 +0,0 @@ -/* This file is part of: - * Jalali, a Gregorian to Jalali and inverse date converter - * Copyright (C) 2001 Roozbeh Pournader - * Copyright (C) 2001 Mohammad Toossi - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You can receive a copy of GNU Lesser General Public License at the - * World Wide Web address . - * - * For licensing issues, contact The FarsiWeb Project Group, - * Computing Center, Sharif University of Technology, - * PO Box 11365-8515, Tehran, Iran, or contact us the - * email address . - */ - -/* Changes: - * - * 2005-Sep-06: - * General cleanup --Behdad Esfahbod - * - * 2001-Sep-21: - * Fixed a bug with "30 Esfand" dates, reported by Mahmoud Ghandi - * - * 2001-Sep-20: - * First LGPL release, with both sides of conversions - */ - - -#include "gnc-jalali.h" - - -/* implementation */ - -#include -#include -#include - -int g_days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; -int j_days_in_month[12] = {31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29}; -const char *j_month_name[12] = -{ - "Farvardin", "Ordibehesht", "Khordad", - "Tir", "Mordad", "Shahrivar", - "Mehr", "Aban", "Azar", - "Dey", "Bahman", "Esfand" -}; - -int gnc_jalali_days_in_month(int month_index) -{ - g_assert(month_index < 12); - return j_days_in_month[month_index]; -} - -const char* gnc_jalali_month_name(int month_index) -{ - g_assert(month_index < 12); - return j_month_name[month_index]; -} - -void gnc_gregorian_to_jalali(int *j_y, int *j_m, int *j_d, - int g_y, int g_m, int g_d) -{ - int gy, gm, gd; - int jy, jm, jd; - long g_day_no, j_day_no; - int j_np; - - int i; - - gy = g_y - 1600; - gm = g_m - 1; - gd = g_d - 1; - - g_day_no = 365 * gy + (gy + 3) / 4 - (gy + 99) / 100 + (gy + 399) / 400; - for (i = 0; i < gm; ++i) - g_day_no += g_days_in_month[i]; - if (gm > 1 && ((gy % 4 == 0 && gy % 100 != 0) || (gy % 400 == 0))) - /* leap and after Feb */ - ++g_day_no; - g_day_no += gd; - - j_day_no = g_day_no - 79; - - j_np = j_day_no / 12053; - j_day_no %= 12053; - - jy = 979 + 33 * j_np + 4 * (j_day_no / 1461); - j_day_no %= 1461; - - if (j_day_no >= 366) - { - jy += (j_day_no - 1) / 365; - j_day_no = (j_day_no - 1) % 365; - } - - for (i = 0; i < 11 && j_day_no >= j_days_in_month[i]; ++i) - { - j_day_no -= j_days_in_month[i]; - } - jm = i + 1; - jd = j_day_no + 1; - *j_y = jy; - *j_m = jm; - *j_d = jd; -} - -void gnc_jalali_to_gregorian(int *g_y, int *g_m, int *g_d, - int j_y, int j_m, int j_d) -{ - int gy, gm, gd; - int jy, jm, jd; - long g_day_no, j_day_no; - int leap; - - int i; - - jy = j_y - 979; - jm = j_m - 1; - jd = j_d - 1; - - j_day_no = 365 * jy + (jy / 33) * 8 + (jy % 33 + 3) / 4; - for (i = 0; i < jm; ++i) - j_day_no += j_days_in_month[i]; - - j_day_no += jd; - - g_day_no = j_day_no + 79; - - gy = 1600 + 400 * (g_day_no / 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */ - g_day_no = g_day_no % 146097; - - leap = 1; - if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */ - { - g_day_no--; - gy += 100 * (g_day_no / 36524); /* 36524 = 365*100 + 100/4 - 100/100 */ - g_day_no = g_day_no % 36524; - - if (g_day_no >= 365) - g_day_no++; - else - leap = 0; - } - - gy += 4 * (g_day_no / 1461); /* 1461 = 365*4 + 4/4 */ - g_day_no %= 1461; - - if (g_day_no >= 366) - { - leap = 0; - - g_day_no--; - gy += g_day_no / 365; - g_day_no = g_day_no % 365; - } - - for (i = 0; g_day_no >= g_days_in_month[i] + (i == 1 && leap); i++) - g_day_no -= g_days_in_month[i] + (i == 1 && leap); - gm = i + 1; - gd = g_day_no + 1; - - *g_y = gy; - *g_m = gm; - *g_d = gd; -} - -#if 0 -int -main(void) -{ - int y, m, d; - time64 bin_time; - struct tm br_time; - - gnc_time (&bin_time); - gnc_localtime_r (&bin_time, &br_time); - - gregorian_to_jalali(&y, &m, &d, - 1900 + br_time.tm_year, - 1 + br_time.tm_mon, - br_time.tm_mday); - - printf("Current Jalali date: %d %s %d\n", d, j_month_name[m-1], y); - - return 0; -} -#endif diff --git a/libgnucash/core-utils/gnc-jalali.h b/libgnucash/core-utils/gnc-jalali.h deleted file mode 100644 index 48841c12141..00000000000 --- a/libgnucash/core-utils/gnc-jalali.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * jalali.h - * Copyright (C) 2010 Christian Stimming - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, contact: - * - * Free Software Foundation Voice: +1-617-542-5942 - * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 - * Boston, MA 02110-1301, USA gnu@gnu.org - */ - -#ifndef GNC_JALALI_H -#define GNC_JALALI_H - -/** Convert gregorian year/month/day (arguments 4-6) to jalali - * year/month/day (arguments 1-3) */ -void gnc_gregorian_to_jalali(/* output */ int *j_y, int *j_m, int *j_d, - /* input */ int g_y, int g_m, int g_d); - -/** Convert jalali year/month/day (arguments 4-6) to gregorian - * year/month/day (arguments 1-3) */ -void gnc_jalali_to_gregorian(/* output */ int *g_y, int *g_m, int *g_d, - /* input */ int j_y, int j_m, int j_d); - -/** Returns the number of days in month in the Jalali calendar, which - * is different from the Gregorian one. Argument month_index is 0 for - * the first month. */ -int gnc_jalali_days_in_month(int month_index); - -/** Returns the month name of the Jalali calendar. Argument - * month_index is 0 for the first month. */ -const char* gnc_jalali_month_name(int month_index); - - -#endif diff --git a/po/POTFILES.in b/po/POTFILES.in index 51de233dab6..3fef79e99e6 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -615,7 +615,6 @@ libgnucash/core-utils/gnc-environment.c libgnucash/core-utils/gnc-filepath-utils.cpp libgnucash/core-utils/gnc-gkeyfile-utils.c libgnucash/core-utils/gnc-glib-utils.c -libgnucash/core-utils/gnc-jalali.c libgnucash/core-utils/gnc-locale-utils.c libgnucash/core-utils/gnc-locale-utils.cpp libgnucash/core-utils/gnc-path.c From 6927535a0a420df745778c03ad1b9949944c2589 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Tue, 24 Jan 2023 13:36:37 +0000 Subject: [PATCH 9/9] Remove unused test function get_object_is_initialized in qofobject.cpp --- libgnucash/engine/qofobject.cpp | 7 ------- libgnucash/engine/test/test-qofobject.c | 1 - 2 files changed, 8 deletions(-) diff --git a/libgnucash/engine/qofobject.cpp b/libgnucash/engine/qofobject.cpp index 0138aad159f..781cc12102c 100644 --- a/libgnucash/engine/qofobject.cpp +++ b/libgnucash/engine/qofobject.cpp @@ -45,7 +45,6 @@ extern "C" { #endif -gboolean get_object_is_initialized( void ); GList* get_object_modules( void ); GList* get_book_list( void ); @@ -53,12 +52,6 @@ GList* get_book_list( void ); } #endif -gboolean -get_object_is_initialized( void ) -{ - return object_is_initialized; -} - GList* get_object_modules( void ) { diff --git a/libgnucash/engine/test/test-qofobject.c b/libgnucash/engine/test/test-qofobject.c index fae5bc84358..7706ce416fb 100644 --- a/libgnucash/engine/test/test-qofobject.c +++ b/libgnucash/engine/test/test-qofobject.c @@ -90,7 +90,6 @@ extern "C" { #endif -extern gboolean get_object_is_initialized( void ); extern GList* get_object_modules( void ); extern GList* get_book_list( void );