From 7cdac0c41af5af74f7a932b50b070802109aa853 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 23 Oct 2014 09:23:30 +0200 Subject: [PATCH] fix widget key collision in snack on 64-bit archs (#1151455) --- configure.ac | 4 ++++ snack.c | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 92e6da8..2cc75d1 100644 --- a/configure.ac +++ b/configure.ac @@ -16,6 +16,10 @@ AC_PROG_LN_S AC_PROG_GREP AC_SYS_LARGEFILE +AC_CHECK_SIZEOF([long]) +AC_CHECK_SIZEOF([long long]) +AC_CHECK_SIZEOF([void *]) + # Are we using GNU ld? AC_MSG_CHECKING([for GNU ld]) LD=`$CC -print-prog-name=ld 2>&5` diff --git a/snack.c b/snack.c index b4cee2e..5ccdf74 100644 --- a/snack.c +++ b/snack.c @@ -317,7 +317,15 @@ static PyMethodDef widgetMethods[] = { }; static PyMemberDef widget_members[] = { - { "key" , T_INT, offsetof(snackWidget, co), 0, NULL }, + { "key", +#if SIZEOF_VOID_P == SIZEOF_LONG + T_LONG, +#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG + T_LONGLONG, +#else +#error unsupported pointer size +#endif + offsetof(snackWidget, co), 0, NULL }, { "entryValue", T_STRING, offsetof(snackWidget, apointer), 0, NULL }, { NULL } }; @@ -1020,7 +1028,11 @@ static PyObject * formRun(snackForm * s, PyObject * args) { else if (result.reason == NEWT_EXIT_FDREADY) return Py_BuildValue("(si)", "fdready", result.u.watch); else if (result.reason == NEWT_EXIT_COMPONENT) - return Py_BuildValue("(si)", "widget", result.u.co); +#if SIZEOF_VOID_P <= SIZEOF_LONG + return Py_BuildValue("(sl)", "widget", (long)result.u.co); +#else + return Py_BuildValue("(sL)", "widget", (long long)result.u.co); +#endif else return Py_BuildValue("(si)", "error", 0); } -- 2.47.3