gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Sep 23 12:28:53 EDT 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/9fc6119d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bffb5d12 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4ad901f4 (commit)
	from  https://github.com/Gnucash/gnucash/commit/d8711619 (commit)



commit 9fc6119d228065b8ab371cb8c11fef6ca371d5f8
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Sep 23 18:28:03 2016 +0200

    See if setting TZ affects Travis tests.

diff --git a/.travis.yml b/.travis.yml
index 4f51249..b7fad01 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,4 +14,4 @@ install:
   - sudo apt-get install -qq swig
   - sudo apt-get install -qq libboost-all-dev
   - sudo apt-get --reinstall install -qq language-pack-en language-pack-fr
-script: ./autogen.sh && ./configure && make && make check
+script: ./autogen.sh && ./configure && make && TZ="America/Los_Angeles" make check

commit bffb5d128387aa6268db7edf5a0e490fe9ae53f1
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Sep 23 18:26:43 2016 +0200

    Check the TZ env variable before defaulting to /etc/localtime.
    
    Note that only location-based timezones (e.g. 'America/Los_Angeles' are supported.

diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp
index 847a5d0..45f9a60 100644
--- a/src/libqof/qof/gnc-timezone.cpp
+++ b/src/libqof/qof/gnc-timezone.cpp
@@ -351,14 +351,17 @@ namespace IANAParser
     find_tz_file(const std::string& name)
     {
 	std::ifstream ifs;
-	if (name.empty())
+        auto tzname = name;
+        if (tzname.empty())
+            tzname = std::string(std::getenv("TZ"));
+        std::cout << "Testing tzname " << tzname << "\n";
+	if (tzname.empty())
 	{
 	    ifs.open("/etc/localtime",
 		     std::ios::in|std::ios::binary|std::ios::ate);
 	}
 	else
 	{
-	    std::string tzname = name;
 //POSIX specifies that that identifier should begin with ':', but we
 //should be liberal. If it's there, it's not part of the filename.
 	    if (tzname[0] == ':')

commit 4ad901f4cf42f8031c8c7e648dcfdf7ecdd25a55
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Sep 23 08:21:45 2016 +0200

    Fix several instances of wrong way to retrieve boolean from KVP.
    
    Extracted functions set_boolean_key and boolean_from_key to ensure consistency.

diff --git a/src/engine/Account.c b/src/engine/Account.c
index 6221e88..764d76e 100644
--- a/src/engine/Account.c
+++ b/src/engine/Account.c
@@ -3807,6 +3807,33 @@ xaccAccountForEachLot(const Account *acc,
     return result;
 }
 
+static void
+set_boolean_key (Account *acc, const char* key, gboolean option)
+{
+    GValue v = G_VALUE_INIT;
+    g_return_if_fail(GNC_IS_ACCOUNT(acc));
+
+    g_value_init (&v, G_TYPE_BOOLEAN);
+    g_value_set_boolean (&v, option);
+    xaccAccountBeginEdit (acc);
+    qof_instance_set_kvp (QOF_INSTANCE (acc),key , &v);
+    mark_account (acc);
+    xaccAccountCommitEdit (acc);
+}
+
+static gboolean
+boolean_from_key (const Account *acc, const char *key)
+{
+    GValue v = G_VALUE_INIT;
+    g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
+    qof_instance_get_kvp (QOF_INSTANCE(acc), key, &v);
+    if (G_VALUE_HOLDS_BOOLEAN (&v))
+         return g_value_get_boolean (&v);
+    if (G_VALUE_HOLDS_STRING (&v))
+         return strcmp (g_value_get_string (&v), "true") == 0;
+    return FALSE;
+}
+
 /********************************************************************\
 \********************************************************************/
 
@@ -3814,25 +3841,13 @@ xaccAccountForEachLot(const Account *acc,
 gboolean
 xaccAccountGetTaxRelated (const Account *acc)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
-    qof_instance_get_kvp (QOF_INSTANCE(acc), "tax-related", &v);
-    return G_VALUE_HOLDS_BOOLEAN (&v) ? g_value_get_boolean (&v) : FALSE;
+    return boolean_from_key(acc, "tax-related");
 }
 
 void
 xaccAccountSetTaxRelated (Account *acc, gboolean tax_related)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_if_fail(GNC_IS_ACCOUNT(acc));
-
-    g_value_init (&v, G_TYPE_BOOLEAN);
-    g_value_set_boolean (&v, tax_related);
-
-    xaccAccountBeginEdit(acc);
-    qof_instance_set_kvp (QOF_INSTANCE (acc), "tax-related", &v);
-    mark_account (acc);
-    xaccAccountCommitEdit(acc);
+    set_boolean_key(acc, "tax-related", tax_related);
 }
 
 const char *
@@ -3921,28 +3936,13 @@ xaccAccountSetTaxUSCopyNumber (Account *acc, gint64 copy_number)
 gboolean
 xaccAccountGetPlaceholder (const Account *acc)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
-    qof_instance_get_kvp (QOF_INSTANCE(acc), "placeholder", &v);
-    if (G_VALUE_HOLDS_BOOLEAN (&v))
-         return g_value_get_boolean (&v);
-    if (G_VALUE_HOLDS_STRING (&v))
-         return strcmp (g_value_get_string (&v), "true") == 0;
-    return FALSE;
+    return boolean_from_key(acc, "placeholder");
 }
 
 void
 xaccAccountSetPlaceholder (Account *acc, gboolean val)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_if_fail(GNC_IS_ACCOUNT(acc));
-
-    g_value_init (&v, G_TYPE_BOOLEAN);
-    g_value_set_boolean (&v, val);
-    xaccAccountBeginEdit (acc);
-    qof_instance_set_kvp (QOF_INSTANCE (acc), "placeholder", &v);
-    mark_account (acc);
-    xaccAccountCommitEdit (acc);
+    set_boolean_key(acc, "placeholder", val);
 }
 
 GNCPlaceholderType
@@ -3972,24 +3972,13 @@ xaccAccountGetDescendantPlaceholder (const Account *acc)
 gboolean
 xaccAccountGetHidden (const Account *acc)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
-    qof_instance_get_kvp (QOF_INSTANCE(acc), "hidden", &v);
-    return G_VALUE_HOLDS_BOOLEAN (&v) ? g_value_get_boolean (&v) : FALSE;
+    return boolean_from_key (acc, "hidden");
 }
 
 void
 xaccAccountSetHidden (Account *acc, gboolean val)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_if_fail(GNC_IS_ACCOUNT(acc));
-
-    g_value_init (&v, G_TYPE_BOOLEAN);
-    g_value_set_boolean (&v, val);
-    xaccAccountBeginEdit (acc);
-    qof_instance_set_kvp (QOF_INSTANCE (acc), "hidden", &v);
-    mark_account (acc);
-    xaccAccountCommitEdit (acc);
+    set_boolean_key (acc, "hidden", val);
 }
 
 gboolean
@@ -4471,11 +4460,7 @@ xaccAccountClearReconcilePostpone (Account *acc)
 gboolean
 xaccAccountGetAutoInterestXfer (const Account *acc, gboolean default_value)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
-    qof_instance_get_kvp (QOF_INSTANCE(acc),
-                          "reconcile-info/auto-interest-transfer", &v);
-    return G_VALUE_HOLDS_BOOLEAN (&v) ? g_value_get_boolean (&v) : FALSE;
+    return boolean_from_key (acc, "reconcile-info/auto-interest-transfer");
 }
 
 /********************************************************************\
@@ -4484,16 +4469,7 @@ xaccAccountGetAutoInterestXfer (const Account *acc, gboolean default_value)
 void
 xaccAccountSetAutoInterestXfer (Account *acc, gboolean option)
 {
-    GValue v = G_VALUE_INIT;
-    g_return_if_fail(GNC_IS_ACCOUNT(acc));
-
-    g_value_init (&v, G_TYPE_BOOLEAN);
-    g_value_set_boolean (&v, option);
-    xaccAccountBeginEdit (acc);
-    qof_instance_set_kvp (QOF_INSTANCE (acc),
-                          "/reconcile-info/auto-interest-transfer", &v);
-    mark_account (acc);
-    xaccAccountCommitEdit (acc);
+    set_boolean_key (acc, "reconcile-info/auto-interest-transfer", option);
 }
 
 /********************************************************************\
diff --git a/src/libqof/qof/test/test-gnc-date.c b/src/libqof/qof/test/test-gnc-date.c
index 037ade6..a3dfc21 100644
--- a/src/libqof/qof/test/test-gnc-date.c
+++ b/src/libqof/qof/test/test-gnc-date.c
@@ -241,13 +241,13 @@ test_gnc_mktime (void)
     struct tm time[5] =
     {
 #ifdef HAVE_STRUCT_TM_GMTOFF
-        { 6, 41, 2, 24, 9, -430, 0, 0, -1, 0, NULL },
+        { 6, 41, 2, 24, 9, -430, 0, 0, 1, 0, NULL },
         { 48, 51, 23, 18, 11, 69, 0, 0, -1, 0, NULL },
         { 41, 12, 0, 6, 0, 70, 0, 0, -1, 0, NULL },
         { 32, 30, 2, 3, 11, 92, 0, 0, -1, 0, NULL },
         { 6, 47, 16, 7, 3, 107, 0, 0, -1, 0, NULL },
 #else
-        { 6, 41, 2, 24, 9, -430, 0, 0, -1 },
+        { 6, 41, 2, 24, 9, -430, 0, 0, 1 },
         { 48, 51, 23, 18, 11, 69, 0, 0, -1 },
         { 41, 12, 0, 6, 0, 70, 0, 0, -1 },
         { 32, 30, 2, 3, 11, 92, 0, 0, -1 },



Summary of changes:
 .travis.yml                         |  2 +-
 src/engine/Account.c                | 94 ++++++++++++++-----------------------
 src/libqof/qof/gnc-timezone.cpp     |  7 ++-
 src/libqof/qof/test/test-gnc-date.c |  4 +-
 4 files changed, 43 insertions(+), 64 deletions(-)



More information about the gnucash-changes mailing list