gnucash maint: Bug 797356 - ninja check fails with GCC-9
John Ralls
jralls at code.gnucash.org
Mon Sep 9 18:08:04 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/e6e2258a (commit)
from https://github.com/Gnucash/gnucash/commit/b1d0dd7d (commit)
commit e6e2258a74b843bec159e5a6edb8a41baff80a31
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Sep 9 14:44:10 2019 -0700
Bug 797356 - ninja check fails with GCC-9
diff --git a/gnucash/gnome-utils/gnc-date-edit.c b/gnucash/gnome-utils/gnc-date-edit.c
index 547c121b6..a7539e7f9 100644
--- a/gnucash/gnome-utils/gnc-date-edit.c
+++ b/gnucash/gnome-utils/gnc-date-edit.c
@@ -558,13 +558,13 @@ fill_time_combo (GtkWidget *widget, GNCDateEdit *gde)
static void
gnc_date_edit_set_time_internal (GNCDateEdit *gde, time64 the_time)
{
- char buffer [40];
+ char buffer [MAX_DATE_LENGTH + 1];
struct tm *mytm = gnc_localtime (&the_time);
g_return_if_fail(mytm != NULL);
/* Update the date text. */
- qof_print_date_dmy_buff(buffer, 40,
+ qof_print_date_dmy_buff(buffer, MAX_DATE_LENGTH,
mytm->tm_mday,
mytm->tm_mon + 1,
1900 + mytm->tm_year);
diff --git a/gnucash/gnome-utils/gnc-period-select.c b/gnucash/gnome-utils/gnc-period-select.c
index fe27a54f5..31fdb8b4d 100644
--- a/gnucash/gnome-utils/gnc-period-select.c
+++ b/gnucash/gnome-utils/gnc-period-select.c
@@ -139,7 +139,7 @@ static void
gnc_period_sample_update_date_label (GncPeriodSelect *period)
{
GncPeriodSelectPrivate *priv;
- gchar time_string[MAX_DATE_LENGTH];
+ gchar time_string[MAX_DATE_LENGTH + 1];
GDate *date;
GncAccountingPeriod which;
diff --git a/gnucash/gnome-utils/gnc-tree-model-price.c b/gnucash/gnome-utils/gnc-tree-model-price.c
index 600631583..79885f4e1 100644
--- a/gnucash/gnome-utils/gnc-tree-model-price.c
+++ b/gnucash/gnome-utils/gnc-tree-model-price.c
@@ -735,7 +735,7 @@ gnc_tree_model_price_get_value (GtkTreeModel *tree_model,
g_value_set_string (value, gnc_commodity_get_printname (commodity));
break;
case GNC_TREE_MODEL_PRICE_COL_DATE:
- qof_print_date_buff (datebuff, sizeof(datebuff),
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH,
gnc_price_get_time64 (price));
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, datebuff);
diff --git a/gnucash/gnome-utils/gnc-tree-model-split-reg.c b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
index 05ecd8a8d..3b224e1be 100644
--- a/gnucash/gnome-utils/gnc-tree-model-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
@@ -850,7 +850,7 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
else
{
time64 t = xaccTransRetDatePosted (trans);
- qof_print_date_buff (date_text, sizeof(date_text), t);
+ qof_print_date_buff (date_text, MAX_DATE_LENGTH, t);
desc_text = xaccTransGetDescription (trans);
model->current_trans = trans;
return g_strconcat (date_text, "\n", desc_text, NULL);
diff --git a/gnucash/gnome-utils/gnc-tree-view-split-reg.c b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
index 3dec2f62c..b28e43c1b 100644
--- a/gnucash/gnome-utils/gnc-tree-view-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
@@ -1454,7 +1454,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
//date on new transactions
if (t == 0)
t = gnc_time (NULL);
- qof_print_date_buff (datebuff, sizeof(datebuff), t);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, t);
editable = TRUE;
}
else if (is_trow2 && show_extra_dates) {
@@ -1465,7 +1465,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
//date on new transactions
if (t == 0)
t = gnc_time (NULL);
- qof_print_date_buff (datebuff, sizeof(datebuff), t);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, t);
editable = FALSE;
}
else if (is_split && show_extra_dates) {
@@ -1473,7 +1473,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
if (xaccSplitGetReconcile (split) == YREC)
{
time64 t = xaccSplitGetDateReconciled (split);
- qof_print_date_buff (datebuff, sizeof(datebuff), t);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, t);
}
editable = FALSE;
}
@@ -1484,7 +1484,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
/* Is this a template */
if (is_template && is_trow1)
{
- strncpy (datebuff, _(" Scheduled "), sizeof(datebuff)-1);
+ strncpy (datebuff, _(" Scheduled "), MAX_DATE_LENGTH);
editable = FALSE;
}
else if (is_template && is_trow2 && show_extra_dates)
@@ -1514,7 +1514,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
if (type == TXN_TYPE_INVOICE)
{
time64 t = xaccTransRetDateDue (trans);
- qof_print_date_buff (datebuff, sizeof(datebuff), t);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, t);
editable = FALSE;
}
else {
diff --git a/gnucash/gnome/dialog-price-edit-db.c b/gnucash/gnome/dialog-price-edit-db.c
index 3936e5e59..ef89a72e6 100644
--- a/gnucash/gnome/dialog-price-edit-db.c
+++ b/gnucash/gnome/dialog-price-edit-db.c
@@ -364,7 +364,7 @@ get_fiscal_end_date (void)
char datebuff[MAX_DATE_LENGTH + 1];
memset (datebuff, 0, sizeof(datebuff));
end = gnc_accounting_period_fiscal_end();
- qof_print_date_buff(datebuff, sizeof(datebuff),
+ qof_print_date_buff(datebuff, MAX_DATE_LENGTH,
gnc_accounting_period_fiscal_end());
PINFO("Fiscal end date is %s", datebuff);
diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c
index 8d8f3b6f6..7c0fe0d20 100644
--- a/gnucash/gnome/dialog-trans-assoc.c
+++ b/gnucash/gnome/dialog-trans-assoc.c
@@ -422,7 +422,7 @@ get_trans_info (AssocDialog *assoc_dialog)
memset (datebuff, 0, sizeof(datebuff));
if (t == 0)
t = gnc_time (NULL);
- qof_print_date_buff (datebuff, sizeof(datebuff), t);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, t);
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
if (!scheme) // path is relative
diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 3710196b3..615b91f39 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1227,7 +1227,7 @@ gbv_refresh_col_titles(GncBudgetView *view)
GtkTreeViewColumn *col;
guint titlelen;
gint num_periods_visible;
- gchar title[MAX_DATE_LENGTH];
+ gchar title[MAX_DATE_LENGTH + 1];
GList *col_list;
gint i;
@@ -1420,7 +1420,7 @@ gnc_budget_view_refresh(GncBudgetView *view)
if (priv->total_col == NULL)
{
- gchar title[MAX_DATE_LENGTH];
+ gchar title[MAX_DATE_LENGTH + 1];
guint titlelen;
GDate *date;
GtkCellRenderer* renderer;
diff --git a/gnucash/import-export/csv-exp/csv-transactions-export.c b/gnucash/import-export/csv-exp/csv-transactions-export.c
index 7a1970e6b..4cc53ea85 100644
--- a/gnucash/import-export/csv-exp/csv-transactions-export.c
+++ b/gnucash/import-export/csv-exp/csv-transactions-export.c
@@ -151,7 +151,7 @@ add_reconcile_date (gchar *so_far, Split *split, CsvExportInfo *info)
time64 t = xaccSplitGetDateReconciled (split);
char str_rec_date[MAX_DATE_LENGTH + 1];
memset (str_rec_date, 0, sizeof(str_rec_date));
- qof_print_date_buff (str_rec_date, sizeof(str_rec_date), t);
+ qof_print_date_buff (str_rec_date, MAX_DATE_LENGTH, t);
result = g_strconcat (so_far, str_rec_date, info->mid_sep, NULL);
}
else
diff --git a/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp b/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp
index 0d794b005..0ef97d508 100644
--- a/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp
+++ b/gnucash/import-export/csv-imp/gnc-imp-props-price.cpp
@@ -316,7 +316,7 @@ Result GncImportPrice::create_price (QofBook* book, GNCPriceDB *pdb, bool over)
char date_str [MAX_DATE_LENGTH + 1];
memset (date_str, 0, sizeof(date_str));
- qof_print_date_buff (date_str, sizeof(date_str), date);
+ qof_print_date_buff (date_str, MAX_DATE_LENGTH, date);
DEBUG("Date is %s, Commodity from is '%s', Currency is '%s', "
"Amount is %s", date_str,
gnc_commodity_get_fullname (*m_from_commodity),
diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index ca5591d73..dca69116b 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -1186,7 +1186,7 @@ refresh_old_transactions (QIFImportWindow * wind, int selection)
}
gtk_list_store_append (store, &iter);
- qof_print_date_buff (datebuff, sizeof (datebuff),
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH,
xaccTransRetDatePosted (gnc_xtn));
gtk_list_store_set
(store, &iter,
@@ -3304,7 +3304,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
gdouble amount_gd = 0;
time64 send_time = 0;
char datebuff [MAX_DATE_LENGTH + 1];
- memset (datebuff, 0, sizeof (datebuff));
+ memset (datebuff, 0, MAX_DATE_LENGTH);
current_xtn = SCM_CAAR(duplicates);
#define FUNC_NAME "xaccTransCountSplits"
gnc_xtn = SWIG_MustGetPtr (current_xtn,
@@ -3323,7 +3323,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
}
gtk_list_store_append (store, &iter);
send_time = xaccTransRetDatePosted (gnc_xtn);
- qof_print_date_buff (datebuff, sizeof (datebuff), send_time);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, send_time);
gtk_list_store_set
(store, &iter,
QIF_TRANS_COL_INDEX, rownum++,
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 59c5281d8..e7e0a870d 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -526,7 +526,7 @@ gnc_split_register_get_recn_tooltip (VirtualLocation virt_loc,
char datebuff[MAX_DATE_LENGTH + 1];
time64 time = xaccSplitGetDateReconciled (split);
memset (datebuff, 0, sizeof(datebuff));
- qof_print_date_buff (datebuff, sizeof(datebuff), time);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, time);
return g_strdup_printf (_("Reconciled on %s"), datebuff);
}
else if (xaccSplitGetReconcile (split) == VREC)
diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c
index 7893b4cec..ddafd2574 100644
--- a/libgnucash/engine/Split.c
+++ b/libgnucash/engine/Split.c
@@ -656,7 +656,7 @@ xaccSplitDump (const Split *split, const char *tag)
{
char datebuff[MAX_DATE_LENGTH + 1];
memset (datebuff, 0, sizeof(datebuff));
- qof_print_date_buff (datebuff, sizeof(datebuff), split->date_reconciled);
+ qof_print_date_buff (datebuff, MAX_DATE_LENGTH, split->date_reconciled);
printf(" %s Split %p", tag, split);
printf(" Book: %p\n", qof_instance_get_book(split));
printf(" Account: %p (%s)\n", split->acc,
diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index a83bc48be..927e64356 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -524,13 +524,14 @@ void
xaccTransDump (const Transaction *trans, const char *tag)
{
GList *node;
+ char datebuff[MAX_DATE_LENGTH + 1];
printf("%s Trans %p", tag, trans);
memset(datebuff, 0, sizeof(datebuff));
- qof_print_date_buff(datebuff, sizeof(datebuff), trans->date_entered);
+ qof_print_date_buff(datebuff, MAX_DATE_LENGTH, trans->date_entered);
printf(" Entered: %s\n", datebuff);
memset(datebuff, 0, sizeof(datebuff));
- qof_print_date_buff(datebuff, sizeof(datebuff), trans->date_posted);
+ qof_print_date_buff(datebuff, MAX_DATE_LENGTH, trans->date_posted);
printf(" Posted: %s\n", datebuff);
printf(" Num: %s\n", trans->num ? trans->num : "(null)");
printf(" Description: %s\n",
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 48b3c062d..5cdf3a655 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -552,9 +552,10 @@ const gchar *qof_date_text_format_get_string(QofDateFormat df)
}
size_t
-qof_print_date_dmy_buff (char * buff, size_t len, int day, int month, int year)
+qof_print_date_dmy_buff (char * buff, const size_t len, int day, int month, int year)
{
if (!buff) return 0;
+
try
{
GncDate date(year, month, day);
@@ -577,9 +578,10 @@ qof_print_date_dmy_buff (char * buff, size_t len, int day, int month, int year)
}
size_t
-qof_print_date_buff (char * buff, size_t len, time64 t)
+qof_print_date_buff (char * buff, const size_t len, time64 t)
{
if (!buff) return 0;
+
try
{
GncDateTime gncdt(t);
@@ -614,7 +616,7 @@ qof_print_gdate( char *buf, size_t len, const GDate *gd )
char *
qof_print_date (time64 t)
{
- char buff[MAX_DATE_LENGTH];
+ char buff[MAX_DATE_LENGTH + 1];
memset (buff, 0, sizeof (buff));
qof_print_date_buff (buff, MAX_DATE_LENGTH, t);
return g_strdup (buff);
diff --git a/libgnucash/engine/test/test-gnc-date.c b/libgnucash/engine/test/test-gnc-date.c
index d4352f088..ab3795f4b 100644
--- a/libgnucash/engine/test/test-gnc-date.c
+++ b/libgnucash/engine/test/test-gnc-date.c
@@ -642,7 +642,7 @@ static void tm_set_dmy (struct tm *tm, gint year, gint month, gint mday)
static void
test_qof_print_date_dmy_buff (void)
{
- gchar buff[MAX_DATE_LENGTH], t_buff[MAX_DATE_LENGTH];
+ gchar buff[MAX_DATE_LENGTH + 1], t_buff[MAX_DATE_LENGTH + 1];
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
struct tm tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0
#ifdef HAVE_STRUCT_TM_GMTOFF
@@ -652,47 +652,47 @@ test_qof_print_date_dmy_buff (void)
qof_date_format_set (QOF_DATE_FORMAT_UK);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 23, 11, 1974), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 23, 11, 1974), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "23/11/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 2, 2, 1961), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 2, 2, 1961), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 16, 6, 2045), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 16, 6, 2045), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "16/06/2045");
qof_date_format_set (QOF_DATE_FORMAT_CE);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 23, 11, 1974), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 23, 11, 1974), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "23.11.1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 2, 2, 1961), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 2, 2, 1961), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "02.02.1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 16, 6, 2045), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 16, 6, 2045), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "16.06.2045");
qof_date_format_set (QOF_DATE_FORMAT_US);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 23, 11, 1974), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 23, 11, 1974), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "11/23/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 2, 2, 1961), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 2, 2, 1961), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 16, 6, 2045), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 16, 6, 2045), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "06/16/2045");
qof_date_format_set (QOF_DATE_FORMAT_ISO);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 23, 11, 1974), ==, strlen (buff));
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 23, 11, 1974), ==, strlen (buff));
g_assert_cmpstr (buff, ==, "1974-11-23");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 2, 2, 1961),
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 2, 2, 1961),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "1961-02-02");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), 16, 6, 2045),
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, 16, 6, 2045),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "2045-06-16");
@@ -701,7 +701,7 @@ test_qof_print_date_dmy_buff (void)
tm_set_dmy (&tm, 1974, 11, 23);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
@@ -710,7 +710,7 @@ test_qof_print_date_dmy_buff (void)
tm_set_dmy (&tm, 1961, 2, 2);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
@@ -718,7 +718,7 @@ test_qof_print_date_dmy_buff (void)
tm_set_dmy (&tm, 2045, 6, 16);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
@@ -727,22 +727,22 @@ test_qof_print_date_dmy_buff (void)
tm_set_dmy (&tm, 1974, 11, 23);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
tm_set_dmy (&tm, 1961, 2, 2);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
tm_set_dmy (&tm, 2045, 6, 16);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
- memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ memset ((gpointer)buff, 0, MAX_DATE_LENGTH);
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
@@ -751,14 +751,14 @@ test_qof_print_date_dmy_buff (void)
tm_set_dmy (&tm, 1974, 11, 23);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
tm_set_dmy (&tm, 1961, 2, 2);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
@@ -766,7 +766,7 @@ test_qof_print_date_dmy_buff (void)
tm_set_dmy (&tm, 2045, 6, 16);
strftime(t_buff, MAX_DATE_LENGTH, GNC_D_FMT, &tm);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_dmy_buff (buff, sizeof (buff), tm.tm_mday,
+ g_assert_cmpint (qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, tm.tm_mday,
tm.tm_mon + 1, tm.tm_year + 1900),
==, strlen (buff));
g_assert_cmpstr (buff, ==, t_buff);
@@ -787,7 +787,7 @@ test_qof_print_date_dmy_buff (void)
#define test_assert_localized_timestring(time, datestr) \
{ \
- gchar t_buff[MAX_DATE_LENGTH]; \
+ gchar t_buff[MAX_DATE_LENGTH + 1]; \
struct tm *ltime = gnc_localtime ((time64 *)(&time)); \
strftime (t_buff, sizeof (t_buff), GNC_D_FMT, ltime); \
gnc_tm_free (ltime); \
@@ -802,7 +802,7 @@ qof_print_date_buff (char * buff, size_t len, time64 t)// C: 3 in 1 Local: 2:0:
static void
test_qof_print_date_buff (void)
{
- gchar buff[MAX_DATE_LENGTH], ans[MAX_DATE_LENGTH];
+ gchar buff[MAX_DATE_LENGTH + 1], ans[MAX_DATE_LENGTH + 1];
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
struct tm tm1 = {0, 0, 12, 23, 10, 74};
@@ -814,110 +814,110 @@ test_qof_print_date_buff (void)
qof_date_format_set (QOF_DATE_FORMAT_UK);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "23/11/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "16/06/2045");
qof_date_format_set (QOF_DATE_FORMAT_CE);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "23.11.1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02.02.1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "16.06.2045");
qof_date_format_set (QOF_DATE_FORMAT_US);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "11/23/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "06/16/2045");
qof_date_format_set (QOF_DATE_FORMAT_ISO);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "1974-11-23");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "1961-02-02");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "2045-06-16");
qof_date_format_set (QOF_DATE_FORMAT_LOCALE);
test_gnc_setlocale (LC_TIME, "en_US");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "11/23/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "06/16/2045");
test_gnc_setlocale (LC_TIME, "en_GB");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
strftime(ans, MAX_DATE_LENGTH, GNC_D_FMT, &tm1);
g_assert_cmpstr (buff, ==, ans);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
strftime(ans, MAX_DATE_LENGTH, GNC_D_FMT, &tm2);
g_assert_cmpstr (buff, ==, ans);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
strftime(ans, MAX_DATE_LENGTH, GNC_D_FMT, &tm3);
g_assert_cmpstr (buff, ==, ans);
test_gnc_setlocale (LC_TIME, "fr_FR");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time1),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time1),
==, strlen (buff));
strftime(ans, MAX_DATE_LENGTH, GNC_D_FMT, &tm1);
g_assert_cmpstr (buff, ==, ans);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time2),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time2),
==, strlen (buff));
strftime(ans, MAX_DATE_LENGTH, GNC_D_FMT, &tm2);
g_assert_cmpstr (buff, ==, ans);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_date_buff (buff, sizeof (buff), time3),
+ g_assert_cmpint (qof_print_date_buff (buff, MAX_DATE_LENGTH, time3),
==, strlen (buff));
strftime(ans, MAX_DATE_LENGTH, GNC_D_FMT, &tm3);
g_assert_cmpstr (buff, ==, ans);
@@ -932,7 +932,7 @@ qof_print_gdate( char *buf, size_t len, const GDate *gd )// C: 6 in 5 Local: 0:
static void
test_qof_print_gdate (void)
{
- gchar buff[MAX_DATE_LENGTH], t_buff[MAX_DATE_LENGTH];
+ gchar buff[MAX_DATE_LENGTH + 1], t_buff[MAX_DATE_LENGTH + 1];
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
GDate *gd1 = g_date_new_dmy (23, 11, 1974);
GDate *gd2 = g_date_new_dmy (2, 2, 1961);
@@ -940,59 +940,59 @@ test_qof_print_gdate (void)
qof_date_format_set (QOF_DATE_FORMAT_UK);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "23/11/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "16/06/2045");
qof_date_format_set (QOF_DATE_FORMAT_CE);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "23.11.1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02.02.1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "16.06.2045");
qof_date_format_set (QOF_DATE_FORMAT_US);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "11/23/1974");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "02/02/1961");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "06/16/2045");
qof_date_format_set (QOF_DATE_FORMAT_ISO);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "1974-11-23");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "1961-02-02");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_assert_cmpstr (buff, ==, "2045-06-16");
@@ -1000,34 +1000,34 @@ test_qof_print_gdate (void)
qof_date_format_set (QOF_DATE_FORMAT_LOCALE);
test_gnc_setlocale (LC_TIME, "en_US");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd1);
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd2);
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd3);
g_assert_cmpstr (buff, ==, t_buff);
test_gnc_setlocale (LC_TIME, "en_GB");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd1);
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd2);
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd3);
g_assert_cmpstr (buff, ==, t_buff);
@@ -1035,17 +1035,17 @@ test_qof_print_gdate (void)
test_gnc_setlocale (LC_TIME, "fr_FR");
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd1),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd1),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd1);
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd2),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd2),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd2);
g_assert_cmpstr (buff, ==, t_buff);
memset ((gpointer)buff, 0, sizeof (buff));
- g_assert_cmpint (qof_print_gdate (buff, sizeof (buff), gd3),
+ g_assert_cmpint (qof_print_gdate (buff, MAX_DATE_LENGTH, gd3),
==, strlen (buff));
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd3);
g_assert_cmpstr (buff, ==, t_buff);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 61f879b4f..74f442854 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -157,6 +157,7 @@ gnucash/gnome-utils/gnc-main-window.c
gnucash/gnome-utils/gnc-menu-extensions.c
gnucash/gnome-utils/gnc-menu-extensions.scm
gnucash/gnome-utils/gncmod-gnome-utils.c
+gnucash/gnome-utils/gnc-option-wrapper.cpp
gnucash/gnome-utils/gnc-period-select.c
gnucash/gnome-utils/gnc-plugin.c
gnucash/gnome-utils/gnc-plugin-file-history.c
Summary of changes:
gnucash/gnome-utils/gnc-date-edit.c | 4 +-
gnucash/gnome-utils/gnc-period-select.c | 2 +-
gnucash/gnome-utils/gnc-tree-model-price.c | 2 +-
gnucash/gnome-utils/gnc-tree-model-split-reg.c | 2 +-
gnucash/gnome-utils/gnc-tree-view-split-reg.c | 10 +-
gnucash/gnome/dialog-price-edit-db.c | 2 +-
gnucash/gnome/dialog-trans-assoc.c | 2 +-
gnucash/gnome/gnc-budget-view.c | 4 +-
.../csv-exp/csv-transactions-export.c | 2 +-
.../import-export/csv-imp/gnc-imp-props-price.cpp | 2 +-
.../import-export/qif-imp/assistant-qif-import.c | 6 +-
.../register/ledger-core/split-register-model.c | 2 +-
libgnucash/engine/Split.c | 2 +-
libgnucash/engine/Transaction.c | 5 +-
libgnucash/engine/gnc-date.cpp | 8 +-
libgnucash/engine/test/test-gnc-date.c | 136 ++++++++++-----------
po/POTFILES.in | 1 +
17 files changed, 98 insertions(+), 94 deletions(-)
More information about the gnucash-changes
mailing list