From ea6181fdf7d12ddd50c1beb852d0e60325c4aa18 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 21:45:53 +0800 Subject: [PATCH 01/10] [import-main-matcher.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- ...main-matcher.c => import-main-matcher.cpp} | 86 ++++++++++--------- gnucash/import-export/import-main-matcher.h | 9 +- po/POTFILES.in | 2 +- 4 files changed, 53 insertions(+), 46 deletions(-) rename gnucash/import-export/{import-main-matcher.c => import-main-matcher.cpp} (97%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index c4e038b950..23b2a929d2 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -22,7 +22,7 @@ set (generic_import_SOURCES import-parse.c import-utilities.c import-settings.c - import-main-matcher.c + import-main-matcher.cpp import-pending-matches.c ) diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.cpp similarity index 97% rename from gnucash/import-export/import-main-matcher.c rename to gnucash/import-export/import-main-matcher.cpp index 1f1f7ec663..b24b369490 100644 --- a/gnucash/import-export/import-main-matcher.c +++ b/gnucash/import-export/import-main-matcher.cpp @@ -48,7 +48,6 @@ #include "gnc-engine.h" #include "gnc-gtk-utils.h" #include "import-settings.h" -#include "import-match-picker.h" #include "import-backend.h" #include "import-account-matcher.h" #include "import-pending-matches.h" @@ -131,11 +130,13 @@ static QofLogModule log_module = G_MOD_IMPORT_MATCHER; static const gpointer one = GINT_TO_POINTER (1); +extern "C" { void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info); void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data); bool on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data); void on_matcher_help_clicked (GtkButton *button, gpointer user_data); void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data); +} static void gnc_gen_trans_list_create_matches (GNCImportMainMatcher *gui); @@ -171,8 +172,9 @@ update_all_balances (GNCImportMainMatcher *info) { for (GSList* iter = info->edited_accounts; iter; iter=iter->next) { - gnc_account_set_defer_bal_computation (iter->data,false); - xaccAccountRecomputeBalance (iter->data); + auto acct = static_cast(iter->data); + gnc_account_set_defer_bal_computation (acct, false); + xaccAccountRecomputeBalance (acct); } g_slist_free (info->edited_accounts); info->edited_accounts = NULL; @@ -307,7 +309,7 @@ static const GncGUID* get_top_trans_match_id (GList* match_list) { if (!match_list || !match_list->data) return NULL; - GNCImportMatchInfo *match_info = match_list->data; + auto match_info = static_cast(match_list->data); Transaction *trans = match_info->trans; return xaccTransGetGUID (trans); } @@ -317,7 +319,7 @@ static gint get_top_trans_match_score (GList* match_list) { if (!match_list || !match_list->data) return 0; - GNCImportMatchInfo *match_info = match_list->data; + auto match_info = static_cast(match_list->data); return match_info->probability; } @@ -388,7 +390,7 @@ static void remove_top_matches (GList* conflicts) { for (GList* iter = conflicts; iter && iter->data; iter=iter->next) - gnc_import_TransInfo_remove_top_match (iter->data); + gnc_import_TransInfo_remove_top_match (static_cast(iter->data)); } static void @@ -461,9 +463,9 @@ load_hash_tables (GNCImportMainMatcher *info) } for (GList *m = accounts_list; m; m = m->next) { - for (GList *n = xaccAccountGetSplitList (m->data); n; n = n->next) + for (GList *n = xaccAccountGetSplitList (static_cast(m->data)); n; n = n->next) { - const Split *s = n->data; + auto s = static_cast(n->data); const Transaction *t = xaccSplitGetParent (s); const gchar *key = xaccTransGetDescription (t); @@ -492,10 +494,10 @@ gnc_gen_trans_list_show_all (GNCImportMainMatcher *info) GSList *temp_trans_list = info->temp_trans_list; if (!temp_trans_list) { - gnc_info_dialog (GTK_WINDOW (info->main_widget), _("No new transactions were found in this import.")); + gnc_info_dialog (GTK_WINDOW (info->main_widget), "%s", _("No new transactions were found in this import.")); return; } - GNCImportTransInfo *trans_info = temp_trans_list->data; + auto trans_info = static_cast(temp_trans_list->data); Split *first_split = gnc_import_TransInfo_get_fsplit (trans_info); Account *account = xaccSplitGetAccount(first_split); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (info->append_text), @@ -550,7 +552,7 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info) Transaction *trans = xaccSplitGetParent (first_split); for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n)) - acc_begin_edit (&accounts_modified, xaccSplitGetAccount (n->data)); + acc_begin_edit (&accounts_modified, xaccSplitGetAccount (static_cast(n->data))); // Allow the backend to know if the Append checkbox is ticked or unticked // by propagating info->append_text to every trans_info->append_text @@ -592,14 +594,14 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info) void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data) { - GNCImportMainMatcher *info = user_data; + auto info = static_cast(user_data); gnc_gen_trans_list_delete (info); } bool on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data) { - GNCImportMainMatcher *info = data; + auto info = static_cast(data); gnc_gen_trans_list_delete (info); return false; } @@ -607,7 +609,7 @@ on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data) void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data) { - GtkWidget *help_dialog = user_data; + auto help_dialog = static_cast(user_data); gtk_widget_destroy (help_dialog); } @@ -615,7 +617,7 @@ on_matcher_help_close_clicked (GtkButton *button, gpointer user_data) void on_matcher_help_clicked (GtkButton *button, gpointer user_data) { - GNCImportMainMatcher *info = user_data; + auto info = static_cast(user_data); GtkBuilder *builder = gtk_builder_new (); gnc_builder_add_from_file (builder, "dialog-import.glade", "textbuffer2"); @@ -837,15 +839,16 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem, GList *refs = NULL; for (GList *l = selected_rows; l; l = l->next) { - gchar *path_str = gtk_tree_path_to_string (l->data); - GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, l->data); + auto path = static_cast(l->data); + gchar *path_str = gtk_tree_path_to_string (path); + GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, path); DEBUG("passing first = %s", first ? "true" : "false"); DEBUG("passing is_selection = %s", is_selection ? "true" : "false"); DEBUG("passing path = %s", path_str); g_free (path_str); refs = g_list_prepend (refs, ref); gnc_gen_trans_assign_transfer_account (treeview, - &first, is_selection, l->data, + &first, is_selection, path, &assigned_account, info); gchar *fullname = gnc_account_get_full_name (assigned_account); DEBUG("returned value of account = %s", fullname); @@ -859,10 +862,11 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem, // now reselect the transaction rows. This is very slow if there are lots of transactions. for (GList *l = refs; l; l = l->next) { - GtkTreePath *path = gtk_tree_row_reference_get_path (l->data); + auto ref = static_cast(l->data); + GtkTreePath *path = gtk_tree_row_reference_get_path (ref); gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); - gtk_tree_row_reference_free (l->data); + gtk_tree_row_reference_free (ref); } g_list_free (refs); @@ -888,7 +892,7 @@ static RowInfo * row_get_info (gpointer row, GNCImportMainMatcher *info) { GtkTreeModel *model = gtk_tree_view_get_model (info->view); RowInfo *retval = g_new (RowInfo, 1); - gtk_tree_model_get_iter (model, &retval->iter, row); + gtk_tree_model_get_iter (model, &retval->iter, static_cast(row)); gtk_tree_model_get (model, &retval->iter, DOWNLOADED_COL_DATA, &retval->trans_info, DOWNLOADED_COL_DESCRIPTION_ORIGINAL, &retval->orig_desc, @@ -908,7 +912,7 @@ enum static void populate_list (gpointer key, gpointer value, GtkListStore *list) { GtkTreeIter iter; - const char *original = key; + auto original = static_cast(key); char *normalized = g_utf8_normalize (original, -1, G_NORMALIZE_NFC); char *normalized_folded = normalized ? g_utf8_casefold (normalized, -1) : NULL; gtk_list_store_append (list, &iter); @@ -924,7 +928,7 @@ static bool match_func (GtkEntryCompletion *completion, const char *entry_str, GtkTreeIter *iter, gpointer user_data) { - GtkTreeModel *model = user_data; + auto model = static_cast(user_data); gchar *existing_str = NULL; bool ret = false; gtk_tree_model_get (model, iter, @@ -1084,7 +1088,7 @@ gnc_gen_trans_set_price_to_selection_cb (GtkMenuItem *menuitem, GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info); for (GList *n = row_info_list; n; n = g_list_next (n)) { - RowInfo *row = n->data; + auto row = static_cast(n->data); Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info); time64 post_date = xaccTransGetDate(trans); Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info); @@ -1137,12 +1141,12 @@ gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info) char *new_desc = NULL, *new_notes = NULL, *new_memo = NULL; GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info); - if (input_new_fields (info, row_info_list->data, + if (input_new_fields (info, static_cast(row_info_list->data), &new_desc, &new_notes, &new_memo)) { for (GList *n = row_info_list; n; n = g_list_next (n)) { - RowInfo *row = n->data; + auto row = static_cast(n->data); Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info); Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info); if (info->can_edit_desc) @@ -1273,8 +1277,9 @@ gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection, GList* list = gtk_tree_selection_get_selected_rows (selection, &model); for (GList *n = list; n; n = n->next) { - if (get_action_for_path (n->data, model) != GNCImport_ADD) - gtk_tree_selection_unselect_path (selection, n->data); + auto path = static_cast(n->data); + if (get_action_for_path (path, model) != GNCImport_ADD) + gtk_tree_selection_unselect_path (selection, path); } g_list_free_full (list, (GDestroyNotify)gtk_tree_path_free); } @@ -1317,7 +1322,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview, const char *desc = NULL, *memo = NULL, *notes = NULL; if (row_info_list) /* should never be NULL. collect from first row. */ { - RowInfo* first_rowinfo = row_info_list->data; + auto first_rowinfo = static_cast(row_info_list->data); Transaction *trans = gnc_import_TransInfo_get_trans (first_rowinfo->trans_info); Split *split = gnc_import_TransInfo_get_fsplit (first_rowinfo->trans_info); desc = xaccTransGetDescription (trans); @@ -1334,7 +1339,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview, bool can_assign_acct = true; for (GList *n = row_info_list; n; n = g_list_next(n)) { - RowInfo *rowinfo = n->data; + auto rowinfo = static_cast(n->data); /* Only allow assigning a destination account for unbalanced transactions */ if (can_assign_acct) @@ -1448,7 +1453,7 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview, GList* selected; GtkTreeModel *model; selected = gtk_tree_selection_get_selected_rows (selection, &model); - if (get_action_for_path (selected->data, model) == GNCImport_ADD) + if (get_action_for_path (static_cast(selected->data), model) == GNCImport_ADD) gnc_gen_trans_view_popup_menu (treeview, event, info); g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free); } @@ -1893,7 +1898,7 @@ get_peer_acct_names (Split *split) GList *names = NULL, *accounts_seen = NULL; for (GList *n = xaccTransGetSplitList (xaccSplitGetParent (split)); n; n = n->next) { - Account *account = xaccSplitGetAccount (n->data); + Account *account = xaccSplitGetAccount (static_cast(n->data)); if ((n->data == split) || (xaccAccountGetType (account) == ACCT_TYPE_TRADING) || (g_list_find (accounts_seen, account))) @@ -2277,7 +2282,7 @@ filter_existing_splits_on_account_and_date (GNCImportMainMatcher *gui) for (GSList* txn = gui->temp_trans_list; txn != NULL; txn = g_slist_next (txn)) { - GNCImportTransInfo* txn_info = txn->data; + auto txn_info = static_cast(txn->data); Account *txn_account = xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info)); time64 txn_time = @@ -2314,19 +2319,20 @@ create_hash_of_potential_matches (GList *candidate_splits, for (GList* candidate = candidate_splits; candidate != NULL; candidate = g_list_next (candidate)) { - if (gnc_import_split_has_online_id (candidate->data)) + auto split = static_cast(candidate->data); + if (gnc_import_split_has_online_id (split)) continue; /* In this context an open transaction represents a freshly * downloaded one. That can't possibly be a match yet */ - if (xaccTransIsOpen(xaccSplitGetParent(candidate->data))) + if (xaccTransIsOpen(xaccSplitGetParent(split))) continue; - Account *split_account = xaccSplitGetAccount (candidate->data); + Account *split_account = xaccSplitGetAccount (split); /* g_hash_table_steal_extended would do the two calls in one shot but is * not available until GLib 2.58. */ - GSList *split_list = g_hash_table_lookup (account_hash, split_account); + auto split_list = static_cast(g_hash_table_lookup (account_hash, split_account)); g_hash_table_steal (account_hash, split_account); - split_list = g_slist_prepend (split_list, candidate->data); + split_list = g_slist_prepend (split_list, split); g_hash_table_insert (account_hash, split_account, split_list); } return account_hash; @@ -2372,11 +2378,11 @@ perform_matching (GNCImportMainMatcher *gui, GHashTable *account_hash) for (GSList *imported_txn = gui->temp_trans_list; imported_txn !=NULL; imported_txn = g_slist_next (imported_txn)) { - GNCImportTransInfo* txn_info = imported_txn->data; + auto txn_info = static_cast(imported_txn->data); Account *importaccount = xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info)); match_struct s = {txn_info, display_threshold, date_threshold, date_not_threshold, fuzzy_amount}; - g_slist_foreach (g_hash_table_lookup (account_hash, importaccount), + g_slist_foreach (static_cast(g_hash_table_lookup (account_hash, importaccount)), (GFunc) match_helper, &s); // Sort the matches, select the best match, and set the action. diff --git a/gnucash/import-export/import-main-matcher.h b/gnucash/import-export/import-main-matcher.h index 1c75a47a3d..cf0120333f 100644 --- a/gnucash/import-export/import-main-matcher.h +++ b/gnucash/import-export/import-main-matcher.h @@ -33,15 +33,16 @@ #ifndef GNC_IMPORT_MAIN_MATCHER_H #define GNC_IMPORT_MAIN_MATCHER_H +#ifdef __cplusplus +extern "C" { +#endif + #include "Transaction.h" #include "import-backend.h" +#include "import-match-picker.h" #include -#ifdef __cplusplus -extern "C" { -#endif - typedef struct _main_matcher_info GNCImportMainMatcher; typedef void (*GNCTransactionProcessedCB) (GNCImportTransInfo *trans_info, diff --git a/po/POTFILES.in b/po/POTFILES.in index f75681988a..e786fb31f2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -350,7 +350,7 @@ gnucash/import-export/import-account-matcher.c gnucash/import-export/import-backend.cpp gnucash/import-export/import-commodity-matcher.c gnucash/import-export/import-format-dialog.c -gnucash/import-export/import-main-matcher.c +gnucash/import-export/import-main-matcher.cpp gnucash/import-export/import-match-picker.c gnucash/import-export/import-parse.c gnucash/import-export/import-pending-matches.c From 243710218c7d16494d2060c8034cd6180c7042d0 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 21:52:54 +0800 Subject: [PATCH 02/10] [import-match-picker.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- .../{import-match-picker.c => import-match-picker.cpp} | 5 +---- gnucash/import-export/import-match-picker.h | 7 +++++++ po/POTFILES.in | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) rename gnucash/import-export/{import-match-picker.c => import-match-picker.cpp} (99%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 23b2a929d2..dde22d4969 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -18,7 +18,7 @@ set (generic_import_SOURCES import-commodity-matcher.c import-backend.cpp import-format-dialog.c - import-match-picker.c + import-match-picker.cpp import-parse.c import-utilities.c import-settings.c diff --git a/gnucash/import-export/import-match-picker.c b/gnucash/import-export/import-match-picker.cpp similarity index 99% rename from gnucash/import-export/import-match-picker.c rename to gnucash/import-export/import-match-picker.cpp index fdc6bf06d5..80d12dd726 100644 --- a/gnucash/import-export/import-match-picker.c +++ b/gnucash/import-export/import-match-picker.cpp @@ -31,10 +31,7 @@ #include #include -#include "import-backend.h" #include "import-match-picker.h" -#include "import-pending-matches.h" - #include "qof.h" #include "gnc-ui-util.h" #include "dialog-utils.h" @@ -196,7 +193,7 @@ match_update_match_model (GNCImportMatchPicker *matcher) (matcher->selected_trans_info)); while (list_element != NULL) { - match_info = list_element->data; + match_info = static_cast(list_element->data); /* Skip this match if reconciled and we're not showing those */ reconciled = xaccSplitGetReconcile diff --git a/gnucash/import-export/import-match-picker.h b/gnucash/import-export/import-match-picker.h index 9ec7b31ba1..205faab152 100644 --- a/gnucash/import-export/import-match-picker.h +++ b/gnucash/import-export/import-match-picker.h @@ -26,6 +26,10 @@ #ifndef GNC_GEN_MATCH_PICKER_H #define GNC_GEN_MATCH_PICKER_H +#ifdef __cplusplus +extern "C" { +#endif + #include "import-backend.h" #include "import-pending-matches.h" @@ -59,5 +63,8 @@ gnc_import_match_picker_run_and_close (GtkWidget *parent, /**@}*/ +#ifdef __cplusplus +} +#endif #endif diff --git a/po/POTFILES.in b/po/POTFILES.in index e786fb31f2..7397a8028e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -351,7 +351,7 @@ gnucash/import-export/import-backend.cpp gnucash/import-export/import-commodity-matcher.c gnucash/import-export/import-format-dialog.c gnucash/import-export/import-main-matcher.cpp -gnucash/import-export/import-match-picker.c +gnucash/import-export/import-match-picker.cpp gnucash/import-export/import-parse.c gnucash/import-export/import-pending-matches.c gnucash/import-export/import-settings.c From b0e5316b916c2cdd5097b42305d8632dcceb72a7 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 21:54:36 +0800 Subject: [PATCH 03/10] [import-pending-matches.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- .../{import-pending-matches.c => import-pending-matches.cpp} | 5 +---- po/POTFILES.in | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) rename gnucash/import-export/{import-pending-matches.c => import-pending-matches.cpp} (97%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index dde22d4969..7ff2a3250a 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -23,7 +23,7 @@ set (generic_import_SOURCES import-utilities.c import-settings.c import-main-matcher.cpp - import-pending-matches.c + import-pending-matches.cpp ) # Add dependency on config.h diff --git a/gnucash/import-export/import-pending-matches.c b/gnucash/import-export/import-pending-matches.cpp similarity index 97% rename from gnucash/import-export/import-pending-matches.c rename to gnucash/import-export/import-pending-matches.cpp index 76dac1a074..4c20146640 100644 --- a/gnucash/import-export/import-pending-matches.c +++ b/gnucash/import-export/import-pending-matches.cpp @@ -75,7 +75,6 @@ static GNCPendingMatches * gnc_import_PendingMatches_get_value (GNCImportPendingMatches *map, GNCImportMatchInfo *match_info) { - GNCPendingMatches *pending_matches; const GncGUID *match_guid; g_return_val_if_fail (map, NULL); @@ -83,9 +82,7 @@ gnc_import_PendingMatches_get_value (GNCImportPendingMatches *map, match_guid = gnc_import_PendingMatches_get_key (match_info); - pending_matches = g_hash_table_lookup (map, match_guid); - - return pending_matches; + return static_cast(g_hash_table_lookup (map, match_guid)); } void diff --git a/po/POTFILES.in b/po/POTFILES.in index 7397a8028e..d547c29b0e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -353,7 +353,7 @@ gnucash/import-export/import-format-dialog.c gnucash/import-export/import-main-matcher.cpp gnucash/import-export/import-match-picker.cpp gnucash/import-export/import-parse.c -gnucash/import-export/import-pending-matches.c +gnucash/import-export/import-pending-matches.cpp gnucash/import-export/import-settings.c gnucash/import-export/import-utilities.c gnucash/import-export/log-replay/gnc-log-replay.c From f1c70a00ad5de12a5674c8b24ca78b8ad835dfbd Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 22:00:40 +0800 Subject: [PATCH 04/10] [import-settings.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- .../import-export/{import-settings.c => import-settings.cpp} | 0 gnucash/import-export/test/CMakeLists.txt | 2 +- po/POTFILES.in | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename gnucash/import-export/{import-settings.c => import-settings.cpp} (100%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 7ff2a3250a..829ab1d826 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -21,7 +21,7 @@ set (generic_import_SOURCES import-match-picker.cpp import-parse.c import-utilities.c - import-settings.c + import-settings.cpp import-main-matcher.cpp import-pending-matches.cpp ) diff --git a/gnucash/import-export/import-settings.c b/gnucash/import-export/import-settings.cpp similarity index 100% rename from gnucash/import-export/import-settings.c rename to gnucash/import-export/import-settings.cpp diff --git a/gnucash/import-export/test/CMakeLists.txt b/gnucash/import-export/test/CMakeLists.txt index 1f29f7c8fe..d1b39c0d70 100644 --- a/gnucash/import-export/test/CMakeLists.txt +++ b/gnucash/import-export/test/CMakeLists.txt @@ -57,7 +57,7 @@ set(gtest_import_backend_LIBS set(gtest_import_backend_SOURCES gtest-import-backend.cpp ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-backend.cpp - ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-settings.c + ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-settings.cpp ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-utilities.c ${CMAKE_SOURCE_DIR}/libgnucash/engine/mocks/gmock-qofinstance.cpp ${CMAKE_SOURCE_DIR}/libgnucash/app-utils/mocks/gmock-gnc-prefs.cpp diff --git a/po/POTFILES.in b/po/POTFILES.in index d547c29b0e..94e5c3af25 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -354,7 +354,7 @@ gnucash/import-export/import-main-matcher.cpp gnucash/import-export/import-match-picker.cpp gnucash/import-export/import-parse.c gnucash/import-export/import-pending-matches.cpp -gnucash/import-export/import-settings.c +gnucash/import-export/import-settings.cpp gnucash/import-export/import-utilities.c gnucash/import-export/log-replay/gnc-log-replay.c gnucash/import-export/log-replay/gnc-plugin-log-replay.c From e48e6e2af9f23a6beebcc6a936dfbdc33ac18258 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 22:02:08 +0800 Subject: [PATCH 05/10] [import-commodity-matcher.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- ...-commodity-matcher.c => import-commodity-matcher.cpp} | 4 ++-- gnucash/import-export/import-commodity-matcher.h | 9 +++++++++ po/POTFILES.in | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) rename gnucash/import-export/{import-commodity-matcher.c => import-commodity-matcher.cpp} (97%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 829ab1d826..a7a6510523 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -15,7 +15,7 @@ add_subdirectory(qif-imp) set (generic_import_SOURCES import-account-matcher.c - import-commodity-matcher.c + import-commodity-matcher.cpp import-backend.cpp import-format-dialog.c import-match-picker.cpp diff --git a/gnucash/import-export/import-commodity-matcher.c b/gnucash/import-export/import-commodity-matcher.cpp similarity index 97% rename from gnucash/import-export/import-commodity-matcher.c rename to gnucash/import-export/import-commodity-matcher.cpp index 3a75d66edb..afd5d58949 100644 --- a/gnucash/import-export/import-commodity-matcher.c +++ b/gnucash/import-export/import-commodity-matcher.cpp @@ -68,12 +68,12 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip, for (GList *n = namespace_list; !retval && n; n = g_list_next (n)) { - const char *ns = n->data; + auto ns = static_cast(n->data); DEBUG("Looking at namespace %s", ns); GList *comm_list = gnc_commodity_table_get_commodities (commodity_table, ns); for (GList *m = comm_list; !retval && m; m = g_list_next (m)) { - gnc_commodity *com = m->data; + auto com = static_cast(m->data); DEBUG("Looking at commodity %s", gnc_commodity_get_fullname (com)); if (!g_strcmp0 (gnc_commodity_get_cusip (com), cusip)) { diff --git a/gnucash/import-export/import-commodity-matcher.h b/gnucash/import-export/import-commodity-matcher.h index 5171a07a4a..373c3e82cb 100644 --- a/gnucash/import-export/import-commodity-matcher.h +++ b/gnucash/import-export/import-commodity-matcher.h @@ -25,6 +25,10 @@ #ifndef IMPORT_COMMODITY_MATCHER_H #define IMPORT_COMMODITY_MATCHER_H +#ifdef __cplusplus +extern "C" { +#endif + #include "gnc-commodity.h" /** @@ -63,5 +67,10 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip, const char * default_fullname, const char * default_mnemonic); + +#ifdef __cplusplus +} +#endif + #endif /**@}*/ diff --git a/po/POTFILES.in b/po/POTFILES.in index 94e5c3af25..7c9ffa4a51 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -348,7 +348,7 @@ gnucash/import-export/customer-import/dialog-customer-import-gui.c gnucash/import-export/customer-import/gnc-plugin-customer-import.c gnucash/import-export/import-account-matcher.c gnucash/import-export/import-backend.cpp -gnucash/import-export/import-commodity-matcher.c +gnucash/import-export/import-commodity-matcher.cpp gnucash/import-export/import-format-dialog.c gnucash/import-export/import-main-matcher.cpp gnucash/import-export/import-match-picker.cpp From 0e484889645877be5b8b22014202cf4ceaf7c846 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 22:05:41 +0800 Subject: [PATCH 06/10] [import-account-matcher.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- ...import-account-matcher.c => import-account-matcher.cpp} | 7 +++---- po/POTFILES.in | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) rename gnucash/import-export/{import-account-matcher.c => import-account-matcher.cpp} (98%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index a7a6510523..739dbf0489 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -14,7 +14,7 @@ add_subdirectory(qif-imp) set (generic_import_SOURCES - import-account-matcher.c + import-account-matcher.cpp import-commodity-matcher.cpp import-backend.cpp import-format-dialog.c diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.cpp similarity index 98% rename from gnucash/import-export/import-account-matcher.c rename to gnucash/import-export/import-account-matcher.cpp index 0795d52944..4179e27d18 100644 --- a/gnucash/import-export/import-account-matcher.c +++ b/gnucash/import-export/import-account-matcher.cpp @@ -368,10 +368,9 @@ Account * gnc_import_select_account(GtkWidget *parent, if (account_online_id_value) { AccountOnlineMatch match = {NULL, 0, account_online_id_value}; - retval = - gnc_account_foreach_descendant_until(gnc_get_current_root_account (), - test_acct_online_id_match, - (void*)&match); + retval = static_cast(gnc_account_foreach_descendant_until (gnc_get_current_root_account (), + test_acct_online_id_match, + (void*)&match)); if (!retval && match.count == 1 && new_account_default_type == ACCT_TYPE_NONE) retval = match.partial_match; diff --git a/po/POTFILES.in b/po/POTFILES.in index 7c9ffa4a51..fd6e3ea360 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -346,7 +346,7 @@ gnucash/import-export/csv-imp/gnc-tokenizer-fw.cpp gnucash/import-export/customer-import/dialog-customer-import.c gnucash/import-export/customer-import/dialog-customer-import-gui.c gnucash/import-export/customer-import/gnc-plugin-customer-import.c -gnucash/import-export/import-account-matcher.c +gnucash/import-export/import-account-matcher.cpp gnucash/import-export/import-backend.cpp gnucash/import-export/import-commodity-matcher.cpp gnucash/import-export/import-format-dialog.c From 5f20e633f24d7b87c32958eaee6025e4d732c9bd Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 22:07:56 +0800 Subject: [PATCH 07/10] [import-format-dialog.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- .../{import-format-dialog.c => import-format-dialog.cpp} | 4 ++-- po/POTFILES.in | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename gnucash/import-export/{import-format-dialog.c => import-format-dialog.cpp} (98%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 739dbf0489..40b93d2793 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -17,7 +17,7 @@ set (generic_import_SOURCES import-account-matcher.cpp import-commodity-matcher.cpp import-backend.cpp - import-format-dialog.c + import-format-dialog.cpp import-match-picker.cpp import-parse.c import-utilities.c diff --git a/gnucash/import-export/import-format-dialog.c b/gnucash/import-export/import-format-dialog.cpp similarity index 98% rename from gnucash/import-export/import-format-dialog.c rename to gnucash/import-export/import-format-dialog.cpp index ecd495da81..93cabb6f2c 100644 --- a/gnucash/import-export/import-format-dialog.c +++ b/gnucash/import-export/import-format-dialog.cpp @@ -38,7 +38,7 @@ static void option_changed_cb (GtkWidget *widget, gpointer index_p) { - gint *my_index = index_p; + auto my_index = static_cast(index_p); *my_index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); } @@ -139,7 +139,7 @@ gnc_import_choose_fmt(const char* msg, GncImportFormat fmts, gpointer data) GtkWidget *dialog; GtkWidget *widget; - g_return_val_if_fail(fmts, FALSE); + g_return_val_if_fail (fmts, GNCIF_NONE); /* if there is only one format available, just return it */ if (!(fmts & (fmts - 1))) diff --git a/po/POTFILES.in b/po/POTFILES.in index fd6e3ea360..5f5c90b545 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -349,7 +349,7 @@ gnucash/import-export/customer-import/gnc-plugin-customer-import.c gnucash/import-export/import-account-matcher.cpp gnucash/import-export/import-backend.cpp gnucash/import-export/import-commodity-matcher.cpp -gnucash/import-export/import-format-dialog.c +gnucash/import-export/import-format-dialog.cpp gnucash/import-export/import-main-matcher.cpp gnucash/import-export/import-match-picker.cpp gnucash/import-export/import-parse.c From 96707e5eeed5fbaf7ba43231c219ee929a37f6b3 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 22:10:13 +0800 Subject: [PATCH 08/10] [import-utilities.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- .../import-export/{import-utilities.c => import-utilities.cpp} | 0 gnucash/import-export/test/CMakeLists.txt | 2 +- po/POTFILES.in | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename gnucash/import-export/{import-utilities.c => import-utilities.cpp} (100%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 40b93d2793..38e0ac97ed 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -20,7 +20,7 @@ set (generic_import_SOURCES import-format-dialog.cpp import-match-picker.cpp import-parse.c - import-utilities.c + import-utilities.cpp import-settings.cpp import-main-matcher.cpp import-pending-matches.cpp diff --git a/gnucash/import-export/import-utilities.c b/gnucash/import-export/import-utilities.cpp similarity index 100% rename from gnucash/import-export/import-utilities.c rename to gnucash/import-export/import-utilities.cpp diff --git a/gnucash/import-export/test/CMakeLists.txt b/gnucash/import-export/test/CMakeLists.txt index d1b39c0d70..7d1d1c8dc2 100644 --- a/gnucash/import-export/test/CMakeLists.txt +++ b/gnucash/import-export/test/CMakeLists.txt @@ -58,7 +58,7 @@ set(gtest_import_backend_SOURCES gtest-import-backend.cpp ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-backend.cpp ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-settings.cpp - ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-utilities.c + ${CMAKE_SOURCE_DIR}/gnucash/import-export/import-utilities.cpp ${CMAKE_SOURCE_DIR}/libgnucash/engine/mocks/gmock-qofinstance.cpp ${CMAKE_SOURCE_DIR}/libgnucash/app-utils/mocks/gmock-gnc-prefs.cpp ${CMAKE_SOURCE_DIR}/libgnucash/engine/mocks/gmock-qofbook.cpp diff --git a/po/POTFILES.in b/po/POTFILES.in index 5f5c90b545..7bcc0cf5f2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -355,7 +355,7 @@ gnucash/import-export/import-match-picker.cpp gnucash/import-export/import-parse.c gnucash/import-export/import-pending-matches.cpp gnucash/import-export/import-settings.cpp -gnucash/import-export/import-utilities.c +gnucash/import-export/import-utilities.cpp gnucash/import-export/log-replay/gnc-log-replay.c gnucash/import-export/log-replay/gnc-plugin-log-replay.c gnucash/import-export/ofx/gncmod-ofx-import.c From 4c231c5c35d94f783438a08933e83a6897db4477 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Fri, 14 Jul 2023 15:52:13 +0800 Subject: [PATCH 09/10] [import-parse.cpp] convert to cpp --- gnucash/import-export/CMakeLists.txt | 2 +- .../{import-parse.c => import-parse.cpp} | 27 +++++++++++-------- gnucash/import-export/import-parse.h | 10 ++++--- po/POTFILES.in | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) rename gnucash/import-export/{import-parse.c => import-parse.cpp} (93%) diff --git a/gnucash/import-export/CMakeLists.txt b/gnucash/import-export/CMakeLists.txt index 38e0ac97ed..5cdde066f4 100644 --- a/gnucash/import-export/CMakeLists.txt +++ b/gnucash/import-export/CMakeLists.txt @@ -19,7 +19,7 @@ set (generic_import_SOURCES import-backend.cpp import-format-dialog.cpp import-match-picker.cpp - import-parse.c + import-parse.cpp import-utilities.cpp import-settings.cpp import-main-matcher.cpp diff --git a/gnucash/import-export/import-parse.c b/gnucash/import-export/import-parse.cpp similarity index 93% rename from gnucash/import-export/import-parse.c rename to gnucash/import-export/import-parse.cpp index bb0874a1ad..f4d8b52326 100644 --- a/gnucash/import-export/import-parse.c +++ b/gnucash/import-export/import-parse.cpp @@ -53,6 +53,10 @@ static regex_t date_ymd_regex; static gboolean regex_compiled = FALSE; +/* Set and clear flags in bit-flags */ +#define import_set_flag(i,f) (i = static_cast(static_cast(i) | static_cast(f))) +#define import_clear_flag(i,f) (i = static_cast(static_cast(i) & static_cast(~f))) + static void compile_regex(void) { @@ -104,7 +108,7 @@ my_strntol(const char *str, int len) static GncImportFormat check_date_format(const char * str, regmatch_t *match, GncImportFormat fmts) { - GncImportFormat res = 0; + GncImportFormat res = GNCIF_NONE; int len0 = 0, len1 = 0, len2 = 0; int val0 = 0, val1 = 0, val2 = 0; @@ -179,7 +183,7 @@ check_date_format(const char * str, regmatch_t *match, GncImportFormat fmts) GncImportFormat gnc_import_test_numeric(const char* str, GncImportFormat fmts) { - GncImportFormat res = 0; + GncImportFormat res = GNCIF_NONE; g_return_val_if_fail(str, fmts); @@ -187,10 +191,10 @@ gnc_import_test_numeric(const char* str, GncImportFormat fmts) compile_regex(); if ((fmts & GNCIF_NUM_PERIOD) && !regexec(&decimal_radix_regex, str, 0, NULL, 0)) - res |= GNCIF_NUM_PERIOD; + import_set_flag (res, GNCIF_NUM_PERIOD); if ((fmts & GNCIF_NUM_COMMA) && !regexec(&comma_radix_regex, str, 0, NULL, 0)) - res |= GNCIF_NUM_COMMA; + import_set_flag (res, GNCIF_NUM_COMMA); return res; } @@ -200,7 +204,7 @@ GncImportFormat gnc_import_test_date(const char* str, GncImportFormat fmts) { regmatch_t match[5]; - GncImportFormat res = 0; + GncImportFormat res = GNCIF_NONE; g_return_val_if_fail(str, fmts); g_return_val_if_fail(strlen(str) > 1, fmts); @@ -218,23 +222,24 @@ gnc_import_test_date(const char* str, GncImportFormat fmts) * let's try both ways and let the parser check that YYYY is * valid. */ - char temp[9]; + #define DATE_LEN 8 + char temp[DATE_LEN + 1]; g_return_val_if_fail(match[4].rm_so != -1, fmts); - g_return_val_if_fail(match[4].rm_eo - match[4].rm_so == 8, fmts); + g_return_val_if_fail(match[4].rm_eo - match[4].rm_so == DATE_LEN, fmts); /* make a temp copy of the XXXXXXXX string */ - strncpy(temp, str + match[4].rm_so, 8); - temp[8] = '\0'; + strncpy(temp, str + match[4].rm_so, DATE_LEN); + temp[DATE_LEN] = '\0'; /* then check it against the ymd or mdy formats, as necessary */ if (((fmts & GNCIF_DATE_YDM) || (fmts & GNCIF_DATE_YMD)) && !regexec(&date_ymd_regex, temp, 4, match, 0)) - res |= check_date_format(temp, match, fmts); + import_set_flag (res, check_date_format (temp, match, fmts)); if (((fmts & GNCIF_DATE_DMY) || (fmts & GNCIF_DATE_MDY)) && !regexec(&date_mdy_regex, temp, 4, match, 0)) - res |= check_date_format(temp, match, fmts); + import_set_flag (res, check_date_format (temp, match, fmts)); } } diff --git a/gnucash/import-export/import-parse.h b/gnucash/import-export/import-parse.h index a6bc850675..5a13813c4a 100644 --- a/gnucash/import-export/import-parse.h +++ b/gnucash/import-export/import-parse.h @@ -27,6 +27,10 @@ #ifndef IMPORT_PARSE_H #define IMPORT_PARSE_H +#ifdef __cplusplus +extern "C" { +#endif + #include "qof.h" typedef enum @@ -57,9 +61,9 @@ gboolean gnc_import_parse_numeric(const char* str, GncImportFormat fmt, gboolean gnc_import_parse_date(const char *date, GncImportFormat fmt, time64 *val); -/* Set and clear flags in bit-flags */ -#define import_set_flag(i,f) (i |= f) -#define import_clear_flag(i,f) (i &= ~f) +#ifdef __cplusplus +} +#endif #endif /* IMPORT_PARSE_H */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 7bcc0cf5f2..59ef26e7ac 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -352,7 +352,7 @@ gnucash/import-export/import-commodity-matcher.cpp gnucash/import-export/import-format-dialog.cpp gnucash/import-export/import-main-matcher.cpp gnucash/import-export/import-match-picker.cpp -gnucash/import-export/import-parse.c +gnucash/import-export/import-parse.cpp gnucash/import-export/import-pending-matches.cpp gnucash/import-export/import-settings.cpp gnucash/import-export/import-utilities.cpp From 513d5442bb5ee1c54ec4a91474f2b441b715a0dd Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jul 2023 22:39:48 +0800 Subject: [PATCH 10/10] [gnc-ofx-import.cpp] convert to cpp --- gnucash/import-export/ofx/CMakeLists.txt | 2 +- .../{gnc-ofx-import.c => gnc-ofx-import.cpp} | 24 +++++++++---------- gnucash/import-export/ofx/gnc-ofx-import.h | 9 +++++++ po/POTFILES.in | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) rename gnucash/import-export/ofx/{gnc-ofx-import.c => gnc-ofx-import.cpp} (98%) diff --git a/gnucash/import-export/ofx/CMakeLists.txt b/gnucash/import-export/ofx/CMakeLists.txt index 30d273829d..479e16e24d 100644 --- a/gnucash/import-export/ofx/CMakeLists.txt +++ b/gnucash/import-export/ofx/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(gschemas) add_subdirectory(test) set(ofx_SOURCES - gnc-ofx-import.c + gnc-ofx-import.cpp gncmod-ofx-import.c gnc-plugin-ofx.c ) diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.cpp similarity index 98% rename from gnucash/import-export/ofx/gnc-ofx-import.c rename to gnucash/import-export/ofx/gnc-ofx-import.cpp index 342e3ffbd7..21d1f6b558 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.c +++ b/gnucash/import-export/ofx/gnc-ofx-import.cpp @@ -1058,32 +1058,32 @@ int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data) { switch (data.account_type) { - case OFX_CHECKING : + case OfxAccountData::OFX_CHECKING: default_type = ACCT_TYPE_BANK; account_type_name = _("Unknown OFX checking account"); break; - case OFX_SAVINGS : + case OfxAccountData::OFX_SAVINGS: default_type = ACCT_TYPE_BANK; account_type_name = _("Unknown OFX savings account"); break; - case OFX_MONEYMRKT : + case OfxAccountData::OFX_MONEYMRKT: default_type = ACCT_TYPE_MONEYMRKT; account_type_name = _("Unknown OFX money market account"); break; - case OFX_CREDITLINE : + case OfxAccountData::OFX_CREDITLINE: default_type = ACCT_TYPE_CREDITLINE; account_type_name = _("Unknown OFX credit line account"); break; - case OFX_CMA : + case OfxAccountData::OFX_CMA: default_type = ACCT_TYPE_NONE; /* Cash Management Account */ account_type_name = _("Unknown OFX CMA account"); break; - case OFX_CREDITCARD : + case OfxAccountData::OFX_CREDITCARD: default_type = ACCT_TYPE_CREDIT; account_type_name = _("Unknown OFX credit card account"); break; - case OFX_INVESTMENT : + case OfxAccountData::OFX_INVESTMENT: default_type = ACCT_TYPE_BANK; account_type_name = _("Unknown OFX investment account"); break; @@ -1226,7 +1226,7 @@ gnc_ofx_match_done (GtkDialog *dialog, gpointer user_data) if (info->run_reconcile && info->statement && info->statement->data) { - struct OfxStatementData* statement = info->statement->data; + auto statement = static_cast(info->statement->data); // Open a reconcile window. Account* account = gnc_import_select_account (gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui), statement->account_id, @@ -1305,13 +1305,13 @@ runMatcher (ofx_info* info, char * selected_filename, gboolean go_to_next_file) // a hash of amount and date, and whose value is the account in which they appear. for(GList* node = info->trans_list; node; node=node->next) { - Transaction* trans = node->data; + auto trans = static_cast(node->data); Split* split = xaccTransGetSplit (trans, 0); Account* account = xaccSplitGetAccount (split); gchar *date_amount_key = make_date_amount_key (xaccTransGetDate (trans), gnc_numeric_abs (xaccSplitGetAmount (split))); // Test if date_amount_key is already in trans_hash. - Account* _account = g_hash_table_lookup (trans_hash, date_amount_key); + auto _account = static_cast(g_hash_table_lookup (trans_hash, date_amount_key)); if (_account && _account != account) { if (qof_log_check (G_LOG_DOMAIN, QOF_LOG_DEBUG)) @@ -1393,7 +1393,7 @@ gnc_file_ofx_import_process_file (ofx_info* info) if (info->file_list == NULL) return; - filename = info->file_list->data; + filename = static_cast(info->file_list->data); libofx_context = libofx_get_new_context(); #ifdef G_OS_WIN32 @@ -1465,7 +1465,7 @@ void gnc_file_ofx_import (GtkWindow *parent) if (selected_filenames) { /* Remember the directory as the default. */ - default_dir = g_path_get_dirname(selected_filenames->data); + default_dir = g_path_get_dirname(static_cast(selected_filenames->data)); gnc_set_default_directory(GNC_PREFS_GROUP, default_dir); g_free(default_dir); diff --git a/gnucash/import-export/ofx/gnc-ofx-import.h b/gnucash/import-export/ofx/gnc-ofx-import.h index e1fce0c901..96ce680c0e 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.h +++ b/gnucash/import-export/ofx/gnc-ofx-import.h @@ -25,6 +25,10 @@ #ifndef OFX_IMPORT_H #define OFX_IMPORT_H +#ifdef __cplusplus +extern "C" { +#endif + #include /** The gnc_file_ofx_import() routine will pop up a standard file @@ -33,4 +37,9 @@ * are merged into the existing session (if any). The current * session continues to remain open for editing. */ void gnc_file_ofx_import (GtkWindow *parent); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/po/POTFILES.in b/po/POTFILES.in index 59ef26e7ac..1bdbc10368 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -359,7 +359,7 @@ gnucash/import-export/import-utilities.cpp gnucash/import-export/log-replay/gnc-log-replay.c gnucash/import-export/log-replay/gnc-plugin-log-replay.c gnucash/import-export/ofx/gncmod-ofx-import.c -gnucash/import-export/ofx/gnc-ofx-import.c +gnucash/import-export/ofx/gnc-ofx-import.cpp gnucash/import-export/ofx/gnc-plugin-ofx.c gnucash/import-export/ofx/gnc-plugin-ofx.ui gnucash/import-export/ofx/gschemas/org.gnucash.GnuCash.dialogs.import.ofx.gschema.xml.in