mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2001-06-01 Dave Peticolas <dave@krondo.com>
* src/engine/sixtp-dom-parsers.c (string_to_integer): use new scanf macro below * src/engine/sixtp-utils.c: use new scanf macro below * src/engine/gnc-numeric.c: use new scanf macro below * src/engine/gnc-engine-util.h: define GNC_SCANF_LLD macro to use for scanf long long int conversion. This is needed since there is not a common solution between Linux, Solaris, and FreeBSD. Thanks to Matthew Condell for finding the problem and to Matt and Alan Orndorff for testing it. * configure.in: invoke conversion test below * acinclude.m4: add test for %lld scanf conversion git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4364 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3cc163db6e
commit
6c39681662
17
ChangeLog
17
ChangeLog
@ -1,5 +1,22 @@
|
||||
2001-06-01 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/engine/sixtp-dom-parsers.c (string_to_integer): use new
|
||||
scanf macro below
|
||||
|
||||
* src/engine/sixtp-utils.c: use new scanf macro below
|
||||
|
||||
* src/engine/gnc-numeric.c: use new scanf macro below
|
||||
|
||||
* src/engine/gnc-engine-util.h: define GNC_SCANF_LLD macro to use
|
||||
for scanf long long int conversion. This is needed since there is
|
||||
not a common solution between Linux, Solaris, and FreeBSD. Thanks
|
||||
to Matthew Condell for finding the problem and to Matt and Alan
|
||||
Orndorff for testing it.
|
||||
|
||||
* configure.in: invoke conversion test below
|
||||
|
||||
* acinclude.m4: add test for %lld scanf conversion
|
||||
|
||||
* README: update info
|
||||
|
||||
2001-06-01 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
38
acinclude.m4
38
acinclude.m4
@ -279,10 +279,13 @@ AC_DEFUN([LANGINFO_D_FMT_CHECK],
|
||||
|
||||
AC_DEFUN([STRUCT_TM_GMTOFF_CHECK],
|
||||
[
|
||||
AC_CACHE_CHECK([for the tm_gmtoff member of struct tm], am_cv_struct_tm_gmtoff,
|
||||
[AC_TRY_LINK([#include <time.h>
|
||||
#define _GNU_SOURCE
|
||||
#define __EXTENSIONS__],
|
||||
AC_CACHE_CHECK([for the tm_gmtoff member of struct tm],
|
||||
am_cv_struct_tm_gmtoff,
|
||||
[AC_TRY_LINK([
|
||||
#include <time.h>
|
||||
#define _GNU_SOURCE
|
||||
#define __EXTENSIONS__
|
||||
],
|
||||
[struct tm tm;
|
||||
tm.tm_gmtoff = 0;],
|
||||
am_cv_struct_tm_gmtoff=yes,
|
||||
@ -293,3 +296,30 @@ AC_DEFUN([STRUCT_TM_GMTOFF_CHECK],
|
||||
[Define if you have the tm_gmtoff member of struct tm.])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([SCANF_LLD_CHECK],
|
||||
[
|
||||
AC_CACHE_CHECK([if scanf supports %lld conversions],
|
||||
am_cv_scanf_lld,
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
long long int d;
|
||||
|
||||
d = 0;
|
||||
if ((sscanf ("10000000000", "%lld", &d) != 1) || (d != 10000000000))
|
||||
exit (1);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
],
|
||||
am_cv_scanf_lld=yes,
|
||||
am_cv_scanf_lld=no))
|
||||
if test $am_cv_scanf_lld = yes; then
|
||||
AC_DEFINE(HAVE_SCANF_LLD, 1,
|
||||
[Define if scanf supports %lld conversions.])
|
||||
fi
|
||||
])
|
||||
|
@ -46,6 +46,7 @@ AC_CHECK_HEADERS(limits.h)
|
||||
AC_CHECK_FUNCS(stpcpy memcpy timegm)
|
||||
|
||||
STRUCT_TM_GMTOFF_CHECK
|
||||
SCANF_LLD_CHECK
|
||||
|
||||
AM_PATH_GLIB
|
||||
|
||||
|
@ -169,6 +169,13 @@ void gnc_set_log_level_global(gncLogLevel level);
|
||||
} \
|
||||
}
|
||||
|
||||
/* Define the long long int conversion for scanf */
|
||||
#if HAVE_SCANF_LLD
|
||||
# define GNC_SCANF_LLD "%lld"
|
||||
#else
|
||||
# define GNC_SCANF_LLD "%qd"
|
||||
#endif
|
||||
|
||||
|
||||
/** Prototypes *************************************************/
|
||||
|
||||
|
@ -1062,7 +1062,8 @@ string_to_gnc_numeric(const gchar* str, gnc_numeric *n) {
|
||||
if(!str) return NULL;
|
||||
|
||||
/* must use "<" here because %n's effects aren't well defined */
|
||||
if(sscanf(str, " %lld/%lld%n", &tmpnum, &tmpdenom, &num_read) < 2) {
|
||||
if(sscanf(str, " " GNC_SCANF_LLD "/" GNC_SCANF_LLD "%n",
|
||||
&tmpnum, &tmpdenom, &num_read) < 2) {
|
||||
return(NULL);
|
||||
}
|
||||
n->num = tmpnum;
|
||||
|
@ -742,7 +742,7 @@ string_to_integer(const char *content, gint64 *to)
|
||||
{
|
||||
long long int to_in;
|
||||
|
||||
if(sscanf(content, "%lld", &to_in) == 1)
|
||||
if(sscanf(content, GNC_SCANF_LLD, &to_in) == 1)
|
||||
{
|
||||
if (to)
|
||||
*to = to_in;
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "date.h"
|
||||
#include "guid.h"
|
||||
#include "gnc-numeric.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
|
||||
gboolean
|
||||
isspace_str(const gchar *str, int nomorethan) {
|
||||
@ -197,7 +199,7 @@ string_to_gint64(const gchar *str, gint64 *v) {
|
||||
int num_read;
|
||||
|
||||
/* must use "<" here because %n's effects aren't well defined */
|
||||
if(sscanf(str, " %lld %n", &v_in, &num_read) < 1) {
|
||||
if(sscanf(str, " " GNC_SCANF_LLD " %n", &v_in, &num_read) < 1) {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
@ -1679,7 +1679,7 @@ xaccParseAmount (const char * in_str, gboolean monetary, gnc_numeric *result,
|
||||
{
|
||||
*out = '\0';
|
||||
|
||||
if (*out_str != '\0' && sscanf(out_str, "%lld", &numer) < 1)
|
||||
if (*out_str != '\0' && sscanf(out_str, GNC_SCANF_LLD, &numer) < 1)
|
||||
{
|
||||
next_state = NO_NUM_ST;
|
||||
}
|
||||
@ -1775,7 +1775,7 @@ xaccParseAmount (const char * in_str, gboolean monetary, gnc_numeric *result,
|
||||
len = 8;
|
||||
}
|
||||
|
||||
if (sscanf (out_str, "%lld", &fraction) < 1)
|
||||
if (sscanf (out_str, GNC_SCANF_LLD, &fraction) < 1)
|
||||
{
|
||||
g_free(out_str);
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user