mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
C++ Windows fixes.
Particularly interesting is src/engine/Makefile.am: Having a mention of target_CFLAGS in an #if disables automatic use AM_CFLAGS even when the #if condition is false.
This commit is contained in:
parent
c7f4bf7fed
commit
82df074771
@ -131,6 +131,8 @@ noinst_SCRIPTS = iso-currencies-to-c
|
|||||||
libgncmod_engine_la_LDFLAGS = -avoid-version
|
libgncmod_engine_la_LDFLAGS = -avoid-version
|
||||||
if CLANG
|
if CLANG
|
||||||
libgncmod_engine_la_CFLAGS = ${AM_CFLAGS} -Wno-invalid-source-encoding
|
libgncmod_engine_la_CFLAGS = ${AM_CFLAGS} -Wno-invalid-source-encoding
|
||||||
|
else
|
||||||
|
libgncmod_engine_la_CFLAGS = ${AM_CFLAGS}
|
||||||
endif
|
endif
|
||||||
libgncmod_engine_la_LIBADD = \
|
libgncmod_engine_la_LIBADD = \
|
||||||
../gnc-module/libgnc-module.la \
|
../gnc-module/libgnc-module.la \
|
||||||
|
@ -126,7 +126,8 @@ test_engine_CFLAGS = \
|
|||||||
${DEFAULT_INCLUDES} \
|
${DEFAULT_INCLUDES} \
|
||||||
-I${top_srcdir}/${MODULEPATH}/ \
|
-I${top_srcdir}/${MODULEPATH}/ \
|
||||||
-DTESTPROG=test_engine \
|
-DTESTPROG=test_engine \
|
||||||
${GLIB_CFLAGS}
|
${GLIB_CFLAGS} \
|
||||||
|
${AM_CFLAGS}
|
||||||
|
|
||||||
noinst_LTLIBRARIES = \
|
noinst_LTLIBRARIES = \
|
||||||
libutest-Split.la \
|
libutest-Split.la \
|
||||||
|
@ -119,7 +119,6 @@ gnc_g_time_zone_new_local (void)
|
|||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
TIME_ZONE_INFORMATION tzinfo;
|
TIME_ZONE_INFORMATION tzinfo;
|
||||||
gint64 dst = GetTimeZoneInformation (&tzinfo);
|
|
||||||
gint bias = tzinfo.Bias + tzinfo.StandardBias;
|
gint bias = tzinfo.Bias + tzinfo.StandardBias;
|
||||||
gint hours = -bias / 60; // 60 minutes per hour
|
gint hours = -bias / 60; // 60 minutes per hour
|
||||||
gint minutes = (bias < 0 ? -bias : bias) % 60;
|
gint minutes = (bias < 0 ? -bias : bias) % 60;
|
||||||
@ -151,13 +150,13 @@ dst_systemtime_to_gdate (SYSTEMTIME stime, GDate *gdate, gint year)
|
|||||||
*/
|
*/
|
||||||
static const int gdate_sunday = 7;
|
static const int gdate_sunday = 7;
|
||||||
static const int week_length = 7;
|
static const int week_length = 7;
|
||||||
|
GDateMonth month = static_cast<GDateMonth>(stime.wMonth);
|
||||||
g_date_clear (gdate, 1);
|
g_date_clear (gdate, 1);
|
||||||
g_date_set_dmy (gdate, 1, stime.wMonth, year);
|
g_date_set_dmy (gdate, 1, month, year);
|
||||||
wkday = g_date_get_weekday (gdate) % gdate_sunday;
|
wkday = g_date_get_weekday (gdate) % gdate_sunday;
|
||||||
|
|
||||||
days = week_length * stime.wDay + stime.wDayOfWeek - wkday;
|
days = week_length * stime.wDay + stime.wDayOfWeek - wkday;
|
||||||
while (days > g_date_get_days_in_month (stime.wMonth, year))
|
while (days > g_date_get_days_in_month (month, year))
|
||||||
days -= week_length;
|
days -= week_length;
|
||||||
g_date_add_days (gdate, days);
|
g_date_add_days (gdate, days);
|
||||||
wkday = g_date_get_weekday (gdate) % gdate_sunday;
|
wkday = g_date_get_weekday (gdate) % gdate_sunday;
|
||||||
@ -179,7 +178,7 @@ win32_in_dst (GDateTime *date, TIME_ZONE_INFORMATION *tzinfo)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
g_date_time_get_ymd (date, &year, &month, &day);
|
g_date_time_get_ymd (date, &year, &month, &day);
|
||||||
g_date_clear (&gdate, 1);
|
g_date_clear (&gdate, 1);
|
||||||
g_date_set_dmy (&gdate, day, month, year);
|
g_date_set_dmy (&gdate, day, static_cast<GDateMonth>(month), year);
|
||||||
dst_systemtime_to_gdate (tzinfo->StandardDate, &std, year);
|
dst_systemtime_to_gdate (tzinfo->StandardDate, &std, year);
|
||||||
dst_systemtime_to_gdate (tzinfo->DaylightDate, &dlt, year);
|
dst_systemtime_to_gdate (tzinfo->DaylightDate, &dlt, year);
|
||||||
/* In the southern hemisphere, where DST ends in spring and begins in fall, we look for the date being before std or after dlt; in the northern hemisphere we look for them to be between dlt and std.
|
/* In the southern hemisphere, where DST ends in spring and begins in fall, we look for the date being before std or after dlt; in the northern hemisphere we look for them to be between dlt and std.
|
||||||
|
@ -676,10 +676,10 @@ guid_to_string(const GncGUID * guid)
|
|||||||
static GStaticPrivate guid_buffer_key = G_STATIC_PRIVATE_INIT;
|
static GStaticPrivate guid_buffer_key = G_STATIC_PRIVATE_INIT;
|
||||||
gchar *string;
|
gchar *string;
|
||||||
|
|
||||||
string = g_static_private_get (&guid_buffer_key);
|
string = static_cast<gchar*>(g_static_private_get (&guid_buffer_key));
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
{
|
{
|
||||||
string = malloc(GUID_ENCODING_LENGTH + 1);
|
string = static_cast<gchar*>(malloc(GUID_ENCODING_LENGTH + 1));
|
||||||
g_static_private_set (&guid_buffer_key, string, g_free);
|
g_static_private_set (&guid_buffer_key, string, g_free);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -44,11 +44,12 @@ G_LOCK_DEFINE_STATIC(picture_to_format);
|
|||||||
gchar *
|
gchar *
|
||||||
qof_time_format_from_utf8(const gchar *utf8_format)
|
qof_time_format_from_utf8(const gchar *utf8_format)
|
||||||
{
|
{
|
||||||
gunichar2 *utf16_format;
|
wchar_t* utf16_format;
|
||||||
gchar* retval;
|
gchar* retval;
|
||||||
gsize count;
|
gsize count;
|
||||||
|
|
||||||
utf16_format = g_utf8_to_utf16(utf8_format, -1, NULL, NULL, NULL);
|
utf16_format = reinterpret_cast<wchar_t*>(g_utf8_to_utf16(utf8_format, -1,
|
||||||
|
NULL, NULL, NULL));
|
||||||
if (!utf16_format)
|
if (!utf16_format)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ qof_time_format_from_utf8(const gchar *utf8_format)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* malloc and convert */
|
/* malloc and convert */
|
||||||
retval = g_malloc((count + 1) * sizeof(gchar));
|
retval = static_cast<gchar*>(g_malloc((count + 1) * sizeof(gchar)));
|
||||||
count = wcstombs(retval, utf16_format, count + 1);
|
count = wcstombs(retval, utf16_format, count + 1);
|
||||||
g_free(utf16_format);
|
g_free(utf16_format);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
@ -83,8 +84,9 @@ qof_formatted_time_to_utf8(const gchar *locale_string)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* malloc and convert */
|
/* malloc and convert */
|
||||||
utf16_string = g_malloc((count + 1) * sizeof(gunichar2));
|
utf16_string = static_cast<gunichar2*>(g_malloc((count + 1) * sizeof(gunichar2)));
|
||||||
count = mbstowcs(utf16_string, locale_string, count + 1);
|
count = mbstowcs(reinterpret_cast<wchar_t*>(utf16_string),
|
||||||
|
locale_string, count + 1);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
{
|
{
|
||||||
g_free(utf16_string);
|
g_free(utf16_string);
|
||||||
@ -126,7 +128,7 @@ qof_win32_get_time_format(QofWin32Picture picture)
|
|||||||
if (!picture_to_format)
|
if (!picture_to_format)
|
||||||
picture_to_format = g_hash_table_new_full(g_str_hash, g_str_equal,
|
picture_to_format = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||||
NULL, g_free);
|
NULL, g_free);
|
||||||
format = g_hash_table_lookup(picture_to_format, locale_string);
|
format = static_cast<char*>(g_hash_table_lookup(picture_to_format, locale_string));
|
||||||
if (!format)
|
if (!format)
|
||||||
{
|
{
|
||||||
format = translate_win32_picture(locale_string);
|
format = translate_win32_picture(locale_string);
|
||||||
|
@ -197,7 +197,7 @@ div128 (qofint128 n, gint64 d)
|
|||||||
remainder <<= 1;
|
remainder <<= 1;
|
||||||
if (sbit) remainder |= 1;
|
if (sbit) remainder |= 1;
|
||||||
quotient = shiftleft128 (quotient);
|
quotient = shiftleft128 (quotient);
|
||||||
if (remainder >= static_cast<unsigned int64_t>(d))
|
if (remainder >= static_cast<guint64>(d))
|
||||||
{
|
{
|
||||||
remainder -= d;
|
remainder -= d;
|
||||||
quotient.lo |= 1;
|
quotient.lo |= 1;
|
||||||
|
@ -995,7 +995,7 @@ qof_print_date_buff (char * buff, size_t len, time64 t)// C: 3 in 1 Local: 2:0:
|
|||||||
static void
|
static void
|
||||||
test_qof_print_date_buff (void)
|
test_qof_print_date_buff (void)
|
||||||
{
|
{
|
||||||
gchar buff[MAX_DATE_LENGTH], t_buff[MAX_DATE_LENGTH];
|
gchar buff[MAX_DATE_LENGTH];
|
||||||
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
|
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
|
||||||
GDateTime *gd1 = gncdt.new_local (1974, 11, 23, 12, 0, 0.0);
|
GDateTime *gd1 = gncdt.new_local (1974, 11, 23, 12, 0, 0.0);
|
||||||
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
|
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
|
||||||
@ -1276,7 +1276,6 @@ static void
|
|||||||
test_qof_print_date (void)
|
test_qof_print_date (void)
|
||||||
{
|
{
|
||||||
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
|
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
|
||||||
gchar *buff;
|
|
||||||
GDateTime *gd1 = gncdt.new_local (1974, 11, 23, 12, 0, 0.0);
|
GDateTime *gd1 = gncdt.new_local (1974, 11, 23, 12, 0, 0.0);
|
||||||
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
|
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
|
||||||
GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0);
|
GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0);
|
||||||
|
@ -446,42 +446,12 @@ mock_sync (QofBackend *be, QofBook *book)
|
|||||||
session_save_struct.sync_called = TRUE;
|
session_save_struct.sync_called = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
mock_session_begin_for_save (QofBackend *be, QofSession *session, const char *book_id,
|
|
||||||
gboolean ignore_lock, gboolean create, gboolean force)
|
|
||||||
{
|
|
||||||
g_assert (be);
|
|
||||||
g_assert (be == session_save_struct.be);
|
|
||||||
g_assert (session);
|
|
||||||
g_assert (session == session_save_struct.session);
|
|
||||||
g_assert (book_id);
|
|
||||||
g_assert_cmpstr (book_id, == , session_save_struct.book_id);
|
|
||||||
g_assert (ignore_lock);
|
|
||||||
g_assert (create);
|
|
||||||
g_assert (force);
|
|
||||||
session_save_struct.session_begin_called = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QofBackend*
|
|
||||||
mock_backend_new_for_save (void)
|
|
||||||
{
|
|
||||||
QofBackend *be = NULL;
|
|
||||||
|
|
||||||
be = g_new0 (QofBackend, 1);
|
|
||||||
g_assert (be);
|
|
||||||
be->session_begin = mock_session_begin_for_save;
|
|
||||||
be->sync = mock_sync;
|
|
||||||
session_save_struct.be = be;
|
|
||||||
session_save_struct.backend_new_called = TRUE;
|
|
||||||
return be;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_qof_session_save (Fixture *fixture, gconstpointer pData)
|
test_qof_session_save (Fixture *fixture, gconstpointer pData)
|
||||||
{
|
{
|
||||||
QofBook *book = NULL;
|
QofBook *book = NULL;
|
||||||
QofBackend *be = NULL;
|
QofBackend *be = NULL;
|
||||||
QofBackendProvider *prov = NULL, *reg_prov = NULL;
|
QofBackendProvider *prov = NULL;
|
||||||
|
|
||||||
g_test_message ("Test when backend not set");
|
g_test_message ("Test when backend not set");
|
||||||
g_assert (fixture->session->backend == NULL);
|
g_assert (fixture->session->backend == NULL);
|
||||||
|
@ -52,7 +52,8 @@ libtest_core_guile_la_LIBADD = \
|
|||||||
|
|
||||||
libtest_core_guile_la_CFLAGS = \
|
libtest_core_guile_la_CFLAGS = \
|
||||||
${libtest_core_la_CPPFLAGS} \
|
${libtest_core_la_CPPFLAGS} \
|
||||||
${GUILE_CFLAGS}
|
${GUILE_CFLAGS} \
|
||||||
|
${AM_CFLAGS}
|
||||||
|
|
||||||
libtest_core_guile_la_LDFLAGS = \
|
libtest_core_guile_la_LDFLAGS = \
|
||||||
-rpath ${exec-prefix}/lib
|
-rpath ${exec-prefix}/lib
|
||||||
|
Loading…
Reference in New Issue
Block a user