mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Win32/MSVC compatiblity
- Replace trunc() by floor() - Provide a round() workaround implementation for MSVC - Use g_strcasecmp instead of the libc one - Add include for libc replacements git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18876 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c2ac86abb6
commit
1efdb1a6c6
@ -16,6 +16,7 @@ FILE (APPEND ${CONFIG_H} "
|
||||
|
||||
/* Definitions for all OS */
|
||||
#define HAVE_LIBQOF /**/
|
||||
#define HAVE_TOWUPPER 1
|
||||
#define QOF_DISABLE_DEPRECATED 1
|
||||
")
|
||||
|
||||
@ -57,7 +58,6 @@ IF (UNIX OR MINGW)
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_TOWUPPER 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_WCTYPE_H 1
|
||||
|
||||
|
@ -8,6 +8,7 @@ INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
|
||||
INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for pow.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
|
||||
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h
|
||||
|
@ -82,7 +82,7 @@ gnc_euro_rate_compare (const void * key, const void * value)
|
||||
if (!key || !value)
|
||||
return -1;
|
||||
|
||||
return strcasecmp(gnc_commodity_get_mnemonic(curr), euro->currency);
|
||||
return g_ascii_strcasecmp(gnc_commodity_get_mnemonic(curr), euro->currency);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -94,7 +94,7 @@ gnc_euro_rate_compare_code (const void * key, const void * value)
|
||||
if (!key || !value)
|
||||
return -1;
|
||||
|
||||
return strcasecmp (code, euro->currency);
|
||||
return g_ascii_strcasecmp (code, euro->currency);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#ifdef G_OS_WIN32
|
||||
#include <pow.h>
|
||||
#if defined(G_OS_WIN32) && !defined(_MSC_VER)
|
||||
# include <pow.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@ -1841,6 +1841,14 @@ integer_to_words(gint64 val)
|
||||
return g_string_free(result, FALSE);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
static double round(double x)
|
||||
{
|
||||
// A simple round() implementation because MSVC doesn't seem to have that
|
||||
return floor(x + 0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
gchar *
|
||||
number_to_words(gdouble val, gint64 denom)
|
||||
{
|
||||
@ -1850,7 +1858,7 @@ number_to_words(gdouble val, gint64 denom)
|
||||
if (val < 0) val = -val;
|
||||
if (denom < 0) denom = -denom;
|
||||
|
||||
int_part = trunc(val);
|
||||
int_part = floor(val);
|
||||
frac_part = round((val - int_part) * denom);
|
||||
|
||||
int_string = integer_to_words(int_part);
|
||||
|
Loading…
Reference in New Issue
Block a user