diff --git a/ChangeLog b/ChangeLog index e73ac2c4e1..a4b4f18068 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,24 @@ * src/engine/gnc-pricedb.c: Phil Longstaff's patch to prevent duplicate pricedb entries. + Heath Martin's x86_64 patch: + * macros/autogen.sh: + change "head -1" to "head -n 1" + * src/engine/gnc-numeric.[ch]: + change string_to_gnc_numeric() to return gboolean. + * src/app-utils/gnc-exp-parser.c: + * src/backend/file/sixtp-dom-parsers.c: + use new string_to_gnc_numeric() API + * src/engine/gnc-lot.c: + 64-bit safe for x86_64 + * src/gnome/dialog-scheduledxaction.c: + * src/gnome/dialog-sxsincelast.c: + * src/gnome/druid-loan.c: + * src/gnome-utils/dialog-account.c: + * src/gnome-utils/gnc-query-list.c: + * src/import-export/import-match-map.c: + use GPOINTER_TO_INT and GINT_TO_POINTER macros to be 64-bit safe. + 2004-10-30 Christian Stimming * doc/README.HBCI: Updated HBCI readme. diff --git a/macros/autogen.sh b/macros/autogen.sh index 5ff7df8c30..073fb14ee5 100644 --- a/macros/autogen.sh +++ b/macros/autogen.sh @@ -21,7 +21,7 @@ test_version() this_prog="$1" want_vers="$2" - testv=`"$this_prog" --version 2>/dev/null | head -1 | awk '{print $NF}'` + testv=`"$this_prog" --version 2>/dev/null | head -n 1 | awk '{print $NF}'` if test -z "$testv" ; then return 1 ; fi testv_major=`echo "$testv" | sed 's/\([0-9]*\).\([0-9]*\).*$/\1/'` diff --git a/src/app-utils/gnc-exp-parser.c b/src/app-utils/gnc-exp-parser.c index 701d730e55..d2cdfbc5d7 100644 --- a/src/app-utils/gnc-exp-parser.c +++ b/src/app-utils/gnc-exp-parser.c @@ -108,12 +108,12 @@ gnc_exp_parser_real_init ( gboolean addPredefined ) else if (SCM_STRINGP (val_scm)) { char *s; - const char *err; + gboolean err; s = gh_scm2newstr (val_scm, NULL); err = string_to_gnc_numeric (s, &value); - if (err == NULL) + if (err == FALSE) good = FALSE; free (s); diff --git a/src/backend/file/sixtp-dom-parsers.c b/src/backend/file/sixtp-dom-parsers.c index 895fe64e3a..e32583ed41 100644 --- a/src/backend/file/sixtp-dom-parsers.c +++ b/src/backend/file/sixtp-dom-parsers.c @@ -479,7 +479,7 @@ dom_tree_to_gnc_numeric(xmlNodePtr node) ret = g_new(gnc_numeric, 1); - if(string_to_gnc_numeric(content, ret) != NULL) + if(string_to_gnc_numeric(content, ret)) { g_free(content); return ret; diff --git a/src/engine/gnc-lot.c b/src/engine/gnc-lot.c index 216b5edcf1..59b3791407 100644 --- a/src/engine/gnc-lot.c +++ b/src/engine/gnc-lot.c @@ -308,7 +308,7 @@ gnc_lot_get_earliest_split (GNCLot *lot) Timespec ts; Split *earliest = NULL; - ts.tv_sec = 1000000LL * ((long long) LONG_MAX); + ts.tv_sec = ((long long) LONG_MAX); ts.tv_nsec = 0; if (!lot) return NULL; @@ -337,7 +337,7 @@ gnc_lot_get_latest_split (GNCLot *lot) Timespec ts; Split *latest = NULL; - ts.tv_sec = -1000000LL * ((long long) LONG_MAX); + ts.tv_sec = -((long long) LONG_MAX); ts.tv_nsec = 0; if (!lot) return NULL; diff --git a/src/engine/gnc-numeric.c b/src/engine/gnc-numeric.c index f2af8cd569..7f8e602fd6 100644 --- a/src/engine/gnc-numeric.c +++ b/src/engine/gnc-numeric.c @@ -1204,32 +1204,32 @@ gnc_num_dbg_to_string(gnc_numeric n) return p; } -const gchar * +gboolean string_to_gnc_numeric(const gchar* str, gnc_numeric *n) { size_t num_read; long long int tmpnum; long long int tmpdenom; - if(!str) return NULL; + if(!str) return FALSE; #ifdef GNC_DEPRECATED /* must use "<" here because %n's effects aren't well defined */ if(sscanf(str, " " GNC_SCANF_LLD "/" GNC_SCANF_LLD "%n", &tmpnum, &tmpdenom, &num_read) < 2) { - return(NULL); + return FALSE; } #else tmpnum = strtoll (str, NULL, 0); str = strchr (str, '/'); - if (!str) return NULL; + if (!str) return FALSE; str ++; tmpdenom = strtoll (str, NULL, 0); num_read = strspn (str, "0123456789"); #endif n->num = tmpnum; n->denom = tmpdenom; - return(str + num_read); + return TRUE; } /******************************************************************** diff --git a/src/engine/gnc-numeric.h b/src/engine/gnc-numeric.h index 89bba4d9e5..641e4a62bf 100644 --- a/src/engine/gnc-numeric.h +++ b/src/engine/gnc-numeric.h @@ -301,10 +301,10 @@ gnc_numeric gnc_numeric_zero(void) { return gnc_numeric_create(0, 1); } gnc_numeric double_to_gnc_numeric(double in, gint64 denom, gint how); -/** Read a gnc_numeric from str, skipping any leading whitespace, - * and return a pointer to just past the last byte read. +/** Read a gnc_numeric from str, skipping any leading whitespace. + * Return TRUE on success and store the resulting value in "n". * Return NULL on error. */ -const gchar *string_to_gnc_numeric(const gchar* str, gnc_numeric *n); +gboolean string_to_gnc_numeric(const gchar* str, gnc_numeric *n); /** Create a gnc_numeric object that signals the error condition * noted by error_code, rather than a number. diff --git a/src/gnome-utils/dialog-account.c b/src/gnome-utils/dialog-account.c index f53a6de55c..1f3da26b28 100644 --- a/src/gnome-utils/dialog-account.c +++ b/src/gnome-utils/dialog-account.c @@ -1148,7 +1148,7 @@ gnc_account_list_fill(GtkCList *type_list, GList *types) { text[0] = (gchar *) xaccAccountGetTypeStr(acct_type); row = gtk_clist_append(type_list, text); - gtk_clist_set_row_data(type_list, row, (gpointer)acct_type); + gtk_clist_set_row_data(type_list, row, GINT_TO_POINTER(acct_type)); } } else @@ -1171,7 +1171,7 @@ gnc_account_choose_new_acct_type (AccountWindow *aw) if (aw->valid_types == NULL) return last_used_account_type; - if (g_list_index (aw->valid_types, (gpointer)last_used_account_type) != -1) + if (g_list_index (aw->valid_types, GINT_TO_POINTER(last_used_account_type)) != -1) return last_used_account_type; return ((GNCAccountType)(aw->valid_types->data)); diff --git a/src/gnome-utils/gnc-query-list.c b/src/gnome-utils/gnc-query-list.c index f18ea4f52d..bd5e651651 100644 --- a/src/gnome-utils/gnc-query-list.c +++ b/src/gnome-utils/gnc-query-list.c @@ -178,7 +178,7 @@ update_booleans (GNCQueryList *list, gint row) if (safe_strcmp (type, QUERYCORE_BOOLEAN)) continue; - result = (gboolean)(gnc_search_param_compute_value(param, entry)); + result = (gboolean) GPOINTER_TO_INT(gnc_search_param_compute_value(param, entry)); gnc_clist_set_check (clist, row, i, result); } } diff --git a/src/gnome/dialog-scheduledxaction.c b/src/gnome/dialog-scheduledxaction.c index cdd2eeb6db..607d1cbabb 100644 --- a/src/gnome/dialog-scheduledxaction.c +++ b/src/gnome/dialog-scheduledxaction.c @@ -1770,7 +1770,7 @@ edit_button_clicked( GtkButton *b, gpointer d ) sxd = (SchedXactionDialog*)d; cl = GTK_CLIST(glade_xml_get_widget( sxd->gxml, SX_LIST )); for( sel = cl->selection; sel; sel = g_list_next(sel) ) { - row = (int)sel->data; + row = GPOINTER_TO_INT(sel->data); /* get the clist row for this listitem */ sx = (SchedXaction*)gtk_clist_get_row_data( cl, row ); /* get the object UD */ @@ -1807,7 +1807,7 @@ delete_button_clicked( GtkButton *b, gpointer d ) realConfDelOpenMsg = g_string_new( beingEditedMessage ); beingEditedList = NULL; for ( ; sel ; sel = sel->next ) { - sx = (SchedXaction*)gtk_clist_get_row_data( cl, (int)sel->data ); + sx = (SchedXaction*)gtk_clist_get_row_data( cl, GPOINTER_TO_INT(sel->data)); g_string_sprintfa( realConfDeleteMsg, "\n\"%s\"", xaccSchedXactionGetName( sx ) ); if ( (l = gnc_find_gui_components( DIALOG_SCHEDXACTION_EDITOR_CM_CLASS, @@ -1870,7 +1870,7 @@ delete_button_clicked( GtkButton *b, gpointer d ) gpointer unused; gboolean foundP; - sx = (SchedXaction*)gtk_clist_get_row_data( cl, (int)sel->data ); + sx = (SchedXaction*)gtk_clist_get_row_data( cl, GPOINTER_TO_INT(sel->data)); sxList = g_list_remove( sxList, (gpointer)sx ); foundP = g_hash_table_lookup_extended( sxd->sxData, sx, &unused, @@ -1891,7 +1891,7 @@ delete_button_clicked( GtkButton *b, gpointer d ) sel = g_list_reverse( sel ); gtk_clist_unselect_all( cl ); for ( ; sel; sel = sel->next ) { - gtk_clist_remove( cl, (int)sel->data ); + gtk_clist_remove( cl, GPOINTER_TO_INT(sel->data) ); } g_list_free( sel ); sel = NULL; diff --git a/src/gnome/dialog-sxsincelast.c b/src/gnome/dialog-sxsincelast.c index eb7ee12998..33682c5cc0 100644 --- a/src/gnome/dialog-sxsincelast.c +++ b/src/gnome/dialog-sxsincelast.c @@ -1327,7 +1327,7 @@ gnc_sxsld_finish( GnomeDruidPage *druid_page, toDelPtr; toDelPtr = toDelPtr->next ) { - row = (gint)toDelPtr->data; + row = GPOINTER_TO_INT(toDelPtr->data); tdt = (toDeleteTuple*)gtk_clist_get_row_data( cl, row ); elt = g_list_find( sxList, tdt->sx ); sxList = g_list_remove_link( sxList, elt ); @@ -2983,7 +2983,7 @@ void print_vars_helper( gpointer key, gpointer value, gpointer user_data ) { DEBUG( "\"%s\" -> %.8x [%s]", - (gchar*)key, (unsigned int)value, + (gchar*)key, GPOINTER_TO_UINT(value), gnc_numeric_to_string( *(gnc_numeric*)value ) ); } diff --git a/src/gnome/druid-loan.c b/src/gnome/druid-loan.c index e531df1a72..a9c0e1e5d2 100644 --- a/src/gnome/druid-loan.c +++ b/src/gnome/druid-loan.c @@ -2585,8 +2585,8 @@ ld_rev_hash_to_list( gpointer key, gpointer val, gpointer user_data ) RevRepaymentRow *rrr = g_new0( RevRepaymentRow, 1 ); if ( !key || !val ) { DEBUG( "%.8x, %.8x", - (unsigned int)key, - (unsigned int)val ); + GPOINTER_TO_UINT(key), + GPOINTER_TO_UINT(val)); return; } rrr->date = *(GDate*)key; diff --git a/src/import-export/import-match-map.c b/src/import-export/import-match-map.c index a2b56d6691..238d615b4b 100644 --- a/src/import-export/import-match-map.c +++ b/src/import-export/import-match-map.c @@ -238,7 +238,7 @@ static void buildProbabilities(gpointer key, gpointer value, gpointer data) PINFO("P('%s') = '%d'\n", (char*)key, probability); - g_hash_table_insert(final_probabilities, key, (gpointer)probability); + g_hash_table_insert(final_probabilities, key, GINT_TO_POINTER(probability)); } /** Frees an array of the same time that buildProperties built */ @@ -270,10 +270,10 @@ static void highestProbability(gpointer key, gpointer value, gpointer data) struct account_info *account_i = (struct account_info*)data; /* if the current probability is greater than the stored, store the current */ - if((gint32)value > account_i->probability) + if(GPOINTER_TO_INT(value) > account_i->probability) { /* Save the new highest probability and the assoaciated account name */ - account_i->probability = (gint32)value; + account_i->probability = GPOINTER_TO_INT(value); account_i->account_name = key; } }