From: Miroslav Lichvar Date: Thu, 23 Oct 2014 07:23:30 +0000 (+0200) Subject: fix widget key collision in snack on 64-bit archs (#1151455) X-Git-Tag: r0-52-18~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7cdac0c41af5af74f7a932b50b070802109aa853;p=thirdparty%2Fnewt.git fix widget key collision in snack on 64-bit archs (#1151455) --- 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); }