[P21.4] Fix progress bar crash

Vin Shelton <[email protected]> Sun, 25 Jan 2015 23:29:00 -0500
Newsgroups gmane.emacs.xemacs.patches
Message-ID <CACeGjnW4-U=PXCWbzf2tV88KB=0uYdPdcqcpLCp5v+oF1A++Qg@mail.gmail.com>
Dear Stephen et al,

On Sat, Jan 10, 2015 at 3:39 AM, Stephen J. Turnbull <[email protected]> wrote:
> APPROVE COMMIT 21.5
>
> This patch, whose diagnosis and configure test is entirely due to Ralf
> Soergel, fixes the crash for me on both Mac OS X "Yosemite" with Apple
> Clang6.0 (LLVM 3.5svn) and Gentoo (about 2 months out of date) with
> Clang 3.5.0 as released.
>
> On Gentoo it was tested with and without optimization, and in all
> three cases the bogus "gctop" has the save value -- I'm guessing
> there's some string or other fixed value in that offset.
>
> @Vin: I think this is probably appropriate for 21.4.  I'll try to get
> to that tomorrow.

Here is my attempt at converting this patch to 21.4.  I had to move
the configure test from configure.ac to configure.in and use
AC_TRY_RUN.  Also, I placed the #define of interest into lwlib.h,
rather than the non-existent xt-wrappers.h.

Please review before I commit.

Thanks,
  Vin

diff -r 5dd9d9f7a11e ChangeLog
--- a/ChangeLog Sat Jan 24 22:35:21 2015 -0500
+++ b/ChangeLog Sun Jan 25 23:23:18 2015 -0500
@@ -1,3 +1,12 @@
++2015-01-08  Vin Shelton  <[email protected]>
+
+ Fix progress bar crashes.
+ Thanks to Ralf Soergel for diagnosis and a patch.
+
+ * configure.in (Athena widgets):
+ Test for "international" resource in SimpleWidgetClass in libXaw3d.
+ * configure: Rebuild.
+
 2008-12-28  Vin Shelton  <[email protected]>

  * XEmacs 21.4.22 is released
diff -r 5dd9d9f7a11e configure.in
--- a/configure.in Sat Jan 24 22:35:21 2015 -0500
+++ b/configure.in Sun Jan 25 23:23:18 2015 -0500
@@ -3640,6 +3640,37 @@
   dnl Do we actually have a usable Athena widget set? Please?
   if test -n "$athena_lib" -a -n "$athena_h_path"; then
     have_xaw=yes
+    have_athena_i18n=unset
+    dnl   X.org at some point added .international to SimplePart, protected
+    dnl by #ifdef XAW_INTERNATIONALIZATION in Xaw3d (only?).  Unfortunately,
+    dnl the distributed headers for Xaw3d don't set this to correspond to
+    dnl the distributed library.  (pkg-config does, if present.)
+    if test "$athena_variant" = "Xaw3d"; then
+      save_libs_x=$libs_x
+      XE_PREPEND(-lXaw3d, libs_x)
+      dnl The test below was provided by Ralf Soergel.
+      AC_MSG_CHECKING([for "international" resource in Xaw3d SimpleWidget])
+
+      AC_TRY_RUN([#include <stdlib.h>
+        #include <string.h>
+        #undef XAW_INTERNATIONALIZATION
+        #include <$athena_h_path/Simple.h>
+        int main(int c, char **v) {
+        int i = simpleWidgetClass->core_class.num_resources;
+         while (i-- > 0)
+           if (!strcmp(simpleWidgetClass->core_class.resources[i].resource_name,
+                       "international"))
+             exit(0);
+         exit(253);}],
+ [./conftest dummy_arg; xaw_intl_status=$?;
+  if test "$xaw_intl_status" = "0"; then
+            have_athena_i18n=yes
+          else
+            have_athena_i18n=no
+            libs_x=$save_libs_x
+          fi])
+      AC_MSG_RESULT([$have_athena_i18n])
+    fi
   else
     have_xaw=no
   fi
@@ -3748,6 +3779,9 @@

     if test "$athena_3d" = "yes"; then
       AC_DEFINE(HAVE_ATHENA_3D)
+      if test "$have_athena_i18n" = "yes"; then
+        AC_DEFINE(HAVE_ATHENA_I18N)
+      fi
     fi
   ;;
 esac
diff -r 5dd9d9f7a11e lwlib/ChangeLog
--- a/lwlib/ChangeLog Sat Jan 24 22:35:21 2015 -0500
+++ b/lwlib/ChangeLog Sun Jan 25 23:23:18 2015 -0500
@@ -1,3 +1,11 @@
+2015-01-08  Vin Shelton  <[email protected]>
+
+ Fix progress bar crashes.
+ Thanks to Ralf Soergel for diagnosis and a patch.
+
+ * lwlib.h (HAVE_ATHENA_I18N):
+ Define XAW_INTERNATIONALIZATION when needed.
+
 2008-12-28  Vin Shelton  <[email protected]>

  * XEmacs 21.4.22 is released
diff -r 5dd9d9f7a11e lwlib/lwlib.h
--- a/lwlib/lwlib.h Sat Jan 24 22:35:21 2015 -0500
+++ b/lwlib/lwlib.h Sun Jan 25 23:23:18 2015 -0500
@@ -3,6 +3,10 @@

 #include <X11/Intrinsic.h>

+#ifdef HAVE_ATHENA_I18N
+#define XAW_INTERNATIONALIZATION 1
+#endif
+
 #if defined (LWLIB_MENUBARS_LUCID) || defined (LWLIB_MENUBARS_MOTIF)
|| defined (LWLIB_MENUBARS_ATHENA)
 #define NEED_MENUBARS
 #endif
diff -r 5dd9d9f7a11e src/ChangeLog
--- a/src/ChangeLog Sat Jan 24 22:35:21 2015 -0500
+++ b/src/ChangeLog Sun Jan 25 23:23:18 2015 -0500
@@ -1,3 +1,10 @@
+2015-01-25  Vin Shelton  <[email protected]>
+
+ Fix progress bar crashes.
+ Thanks to Ralf Soergel for diagnosis and a patch.
+
+ * config.h.in (HAVE_ATHENA_I18N): New #define.
+
 2015-01-24  Vin Shelton  <[email protected]>

  * fileio.c: Guard include of w32api/aclapi.h to preserve Status
diff -r 5dd9d9f7a11e src/config.h.in
--- a/src/config.h.in Sat Jan 24 22:35:21 2015 -0500
+++ b/src/config.h.in Sun Jan 25 23:23:18 2015 -0500
@@ -720,6 +720,7 @@
 #undef LWLIB_WIDGETS_MOTIF
 #undef LWLIB_WIDGETS_ATHENA
 #undef HAVE_ATHENA_3D
+#undef HAVE_ATHENA_I18N

 /* Other things that can be disabled by configure. */
 #undef HAVE_MENUBARS