[gcalctool] Make code build without warnings on 64 bit systems
- From: Robin Sonefors <rsonefors src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcalctool] Make code build without warnings on 64 bit systems
- Date: Sat, 3 Oct 2009 22:13:44 +0000 (UTC)
commit 8343a76e7f83d0a9c52d0a379fa8f81ca859bbba
Author: Robin Sonefors <ozamosi flukkost nu>
Date: Sat Oct 3 23:26:14 2009 +0200
Make code build without warnings on 64 bit systems
ChangeLog | 4 ++++
src/display.c | 18 +++++++++---------
src/display.h | 2 +-
src/gtk.c | 49 ++++++++++++++++++++++---------------------------
4 files changed, 36 insertions(+), 37 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4e79603..400d67d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
gcalctool change history.
=========================
+2009-10-03 Robin Sonefors <ozamosi flukkost nu>
+
+ * Fix so the code builds without warnings on 64 bit platforms
+
2009-09-28 Robin Sonefors <ozamosi flukkost nu>
* Make numbers written with a keyboard respect sub/superscript toggles
* Move factorization code to mp.c
diff --git a/src/display.c b/src/display.c
index fa76989..9e37181 100644
--- a/src/display.c
+++ b/src/display.c
@@ -891,7 +891,7 @@ do_sto(GCDisplay *display, int index)
void
-display_do_function(GCDisplay *display, int function, int arg, int cursor_start, int cursor_end)
+display_do_function(GCDisplay *display, int function, gpointer arg, int cursor_start, int cursor_end)
{
char buf[MAXLINE];
MPNumber *ans;
@@ -925,27 +925,27 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
break;
case FN_SHIFT:
- do_shift(display, arg);
+ do_shift(display, GPOINTER_TO_INT (arg));
break;
case FN_FACTORIZE:
- do_factorize(display, arg);
+ do_factorize(display, GPOINTER_TO_INT (arg));
break;
case FN_PASTE:
- do_paste(display, cursor_start, cursor_end, (const char *)arg); // FIXME: Probably not 64 bit safe
+ do_paste(display, cursor_start, cursor_end, (const char *)arg);
return;
case FN_INSERT_CHARACTER:
- do_insert_character(display, (const char *)arg); // FIXME: Probably not 64 bit safe
+ do_insert_character(display, (const char *)arg);
return;
case FN_STORE:
- do_sto(display, arg);
+ do_sto(display, GPOINTER_TO_INT (arg));
return;
case FN_RECALL:
- SNPRINTF(buf, MAXLINE, "R%d", arg);
+ SNPRINTF(buf, MAXLINE, "R%d", GPOINTER_TO_INT (arg));
display_insert(display, cursor_start, cursor_end, buf);
break;
@@ -962,10 +962,10 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
char buf[MAX_DISPLAY];
MPNumber MP;
- bit_value ^= (1LL << (63 - arg));
+ bit_value ^= (1LL << (63 - GPOINTER_TO_INT (arg)));
/* FIXME: Convert to string since we don't support setting MP numbers from 64 bit integers */
- SNPRINTF(buf, MAX_DISPLAY, "%llu", bit_value);
+ SNPRINTF(buf, MAX_DISPLAY, "%" G_GUINT64_FORMAT, bit_value);
mp_set_from_string(buf, &MP);
display_set_number(display, &MP);
}
diff --git a/src/display.h b/src/display.h
index 7957a00..bcb1a9b 100644
--- a/src/display.h
+++ b/src/display.h
@@ -115,6 +115,6 @@ const char *display_get_text(GCDisplay *display);
void display_make_number(GCDisplay *display, char *target, int target_len, const MPNumber *x);
-void display_do_function(GCDisplay *display, int function, int arg, int cursor_start, int cursor_end);
+void display_do_function(GCDisplay *display, int function, gpointer arg, int cursor_start, int cursor_end);
#endif /* DISPLAY_H */
diff --git a/src/gtk.c b/src/gtk.c
index b91532b..e05dd64 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -358,7 +358,7 @@ ui_set_bitfield(int enabled, guint64 bits)
static void
-do_button(int function, int arg)
+do_button(int function, gpointer arg)
{
GtkTextIter start, end;
gint cursor_start, cursor_end;
@@ -378,8 +378,8 @@ do_button(int function, int arg)
if (cursor_start == cursor_end &&
function == FN_TEXT && X.last_text != NULL &&
strcmp((char *)arg, "Ã?") == 0 && strcmp(X.last_text, "Ã?") == 0) {
- do_button(FN_BACKSPACE, 0);
- do_button(FN_TEXT, (int)"^"); // FIXME: Not 64 bit safe
+ do_button(FN_BACKSPACE, NULL);
+ do_button(FN_TEXT, "^");
}
else {
display_do_function(&v->display, function, arg, cursor_start, cursor_end);
@@ -394,7 +394,7 @@ do_button(int function, int arg)
static void
do_text(const char *text)
{
- do_button(FN_TEXT, (int)text); // FIXME: Not 64 bit safe
+ do_button(FN_TEXT, (gpointer) text); // FIXME: Not 64 bit safe
}
@@ -581,7 +581,7 @@ ascii_dialog_response_cb(GtkWidget *dialog, gint response_id)
text = gtk_entry_get_text(GTK_ENTRY(X.ascii_entry));
if (response_id == GTK_RESPONSE_OK)
- do_button(FN_INSERT_CHARACTER, GPOINTER_TO_INT(text));
+ do_button(FN_INSERT_CHARACTER, (gpointer) text);
gtk_widget_hide(dialog);
}
@@ -637,8 +637,7 @@ G_MODULE_EXPORT
void
store_menu_cb(GtkMenuItem *menu)
{
- int arg = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "register_id"));
- do_button(FN_STORE, arg);
+ do_button(FN_STORE, g_object_get_data(G_OBJECT(menu), "register_id"));
}
@@ -646,8 +645,7 @@ G_MODULE_EXPORT
void
recall_menu_cb(GtkMenuItem *menu)
{
- int arg = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "register_id"));
- do_button(FN_RECALL, arg);
+ do_button(FN_RECALL, g_object_get_data(G_OBJECT(menu), "register_id"));
}
@@ -741,9 +739,8 @@ G_MODULE_EXPORT
gboolean
bit_toggle_cb(GtkWidget *event_box, GdkEventButton *event)
{
- int index;
- index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(event_box), "bit_index"));
- do_button(FN_TOGGLE_BIT, index);
+ do_button(FN_TOGGLE_BIT,
+ g_object_get_data(G_OBJECT(event_box), "bit_index"));
return TRUE;
}
@@ -849,7 +846,7 @@ G_MODULE_EXPORT
void
solve_cb(GtkWidget *widget, GdkEventButton *event)
{
- do_button(FN_CALCULATE, 0);
+ do_button(FN_CALCULATE, NULL);
}
@@ -857,7 +854,7 @@ G_MODULE_EXPORT
void
clear_cb(GtkWidget *widget, GdkEventButton *event)
{
- do_button(FN_CLEAR, 0);
+ do_button(FN_CLEAR, NULL);
}
@@ -906,7 +903,7 @@ G_MODULE_EXPORT
void
factorize_cb(GtkWidget *widget, GdkEventButton *event)
{
- do_button(FN_FACTORIZE, 0);
+ do_button(FN_FACTORIZE, NULL);
}
@@ -972,7 +969,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
do_text("Ã?10^");
return TRUE;
case GDK_f:
- do_button(FN_FACTORIZE, 0);
+ do_button(FN_FACTORIZE, NULL);
return TRUE;
case GDK_r:
do_text("â??");
@@ -1060,11 +1057,11 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
/* Delete in display */
if (event->keyval == GDK_Delete && state == 0 && (event->state & GDK_SHIFT_MASK) == 0) {
- do_button(FN_DELETE, 0);
+ do_button(FN_DELETE, NULL);
return TRUE;
}
if (event->keyval == GDK_BackSpace && state == 0 && (event->state & GDK_SHIFT_MASK) == 0) {
- do_button(FN_BACKSPACE, 0);
+ do_button(FN_BACKSPACE, NULL);
return TRUE;
}
@@ -1072,14 +1069,14 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
if ((event->keyval == GDK_Escape && state == 0) ||
(event->keyval == GDK_BackSpace && state == GDK_CONTROL_MASK) ||
(event->keyval == GDK_Delete && state == GDK_SHIFT_MASK)) {
- do_button(FN_CLEAR, 0);
+ do_button(FN_CLEAR, NULL);
return TRUE;
}
/* Solve */
if ((event->keyval == GDK_Return && state == 0) ||
(event->keyval == GDK_KP_Enter && state == 0)) {
- do_button(FN_CALCULATE, 0);
+ do_button(FN_CALCULATE, NULL);
return TRUE;
}
@@ -1115,7 +1112,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
return TRUE;
case '=':
case '\n':
- do_button(FN_CALCULATE, 0);
+ do_button(FN_CALCULATE, NULL);
return TRUE;
}
@@ -1154,7 +1151,7 @@ static void
on_paste(GtkClipboard *clipboard, const gchar *text, gpointer data)
{
if (text != NULL)
- do_button(FN_PASTE, GPOINTER_TO_INT(text));
+ do_button(FN_PASTE, (gpointer) text);
}
@@ -1191,7 +1188,7 @@ G_MODULE_EXPORT
void
undo_cb(GtkWidget *widget)
{
- do_button(FN_UNDO, 0);
+ do_button(FN_UNDO, NULL);
}
@@ -1199,7 +1196,7 @@ G_MODULE_EXPORT
void
redo_cb(GtkWidget *widget)
{
- do_button(FN_REDO, 0);
+ do_button(FN_REDO, NULL);
}
@@ -1247,9 +1244,7 @@ G_MODULE_EXPORT
void
shift_cb(GtkWidget *widget)
{
- int count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
- "shiftcount"));
- do_button(FN_SHIFT, count);
+ do_button(FN_SHIFT, g_object_get_data(G_OBJECT(widget), "shiftcount"));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]