texlive[74082] Build/source/texk/xdvik: configure check for the type
commits+karl at tug.org
commits+karl at tug.org
Tue Feb 18 00:39:24 CET 2025
Revision: 74082
https://tug.org/svn/texlive?view=revision&revision=74082
Author: karl
Date: 2025-02-18 00:39:24 +0100 (Tue, 18 Feb 2025)
Log Message:
-----------
configure check for the type of the list (second) parameter of the XawListChange function, and cast to it in the call; probably too simplistic
Modified Paths:
--------------
trunk/Build/source/texk/xdvik/ChangeLog
trunk/Build/source/texk/xdvik/c-auto.in
trunk/Build/source/texk/xdvik/configure
trunk/Build/source/texk/xdvik/gui/pagesel.c
trunk/Build/source/texk/xdvik/m4/xdvi-check-xaw.m4
Modified: trunk/Build/source/texk/xdvik/ChangeLog
===================================================================
--- trunk/Build/source/texk/xdvik/ChangeLog 2025-02-17 23:11:37 UTC (rev 74081)
+++ trunk/Build/source/texk/xdvik/ChangeLog 2025-02-17 23:39:24 UTC (rev 74082)
@@ -1,3 +1,17 @@
+2025-02-17 Karl Berry <karl at freefriends.org>
+
+ * m4/xdvi-check-xaw.m4: try to discern the type of the list
+ (second) parameter of the XawListChange function, (too) simply
+ with: sed -n 's/list,$//p' /usr/include/X11/Xaw/List.h.
+ Default to the type of the page_labels member, as before.
+ Maybe it will work in practice?
+ * gui/pagesel.c (XAWLISTCHANGELISTTYPE): define if not defined.
+ (xaw_update_list): cast to it.
+ (See next ChangeLog entry for links to discussions.)
+
+ * c-auto.in,
+ * configure: regenerate.
+
2025-02-15 Karl Berry <karl at freefriends.org>
* gui/pagesel.c (xaw_update_list): put in comment about the known
Modified: trunk/Build/source/texk/xdvik/c-auto.in
===================================================================
--- trunk/Build/source/texk/xdvik/c-auto.in 2025-02-17 23:11:37 UTC (rev 74081)
+++ trunk/Build/source/texk/xdvik/c-auto.in 2025-02-17 23:39:24 UTC (rev 74082)
@@ -484,6 +484,9 @@
/* Define to use the Xaw toolkit. */
#undef XAW
+/* type of XawListChange list parameter */
+#undef XAWLISTCHANGELISTTYPE
+
/* Define to 1 if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING
Modified: trunk/Build/source/texk/xdvik/configure
===================================================================
--- trunk/Build/source/texk/xdvik/configure 2025-02-17 23:11:37 UTC (rev 74081)
+++ trunk/Build/source/texk/xdvik/configure 2025-02-17 23:39:24 UTC (rev 74082)
@@ -19947,6 +19947,55 @@
printf "%s\n" "#define XAW 1" >>confdefs.h
+
+ # We need the type of the "list" parameter to XawListChange
+ # (the second parameter), for use in gui/pagesel.c. See more comments there.
+ #
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for type of XawListChange list parameter" >&5
+printf %s "checking for type of XawListChange list parameter... " >&6; }
+ # Although we could try to use the compiler to discern the location of
+ # <X11/Xaw/List.h>, that seems likely to have its own problems. Let's
+ # try just assuming the standard location.
+ #
+ listh=/usr/include/X11/Xaw/List.h
+
+ # Clearly this simple search is subject to plenty of problems in
+ # theory, but in practice, if no one gratuitously changes the
+ # formatting in Xaw/List.h, it should be ok? The line intended to be
+ # matched looks like
+ # String *list, [except with tabs]
+ # or
+ # _Xconst char *list,
+ # or who knows what else. Hopefully it will be the complete type.
+ #
+ list_type=`sed -n 's/list,$//p' $listh`
+ #
+ # The type ordinarily has lots of whitespace, as in the String line above.
+ # People will uselessly complain about that, so reduce it to a single space:
+ tab=' ' # that's a tab character
+ # The outer square brackets are the Autoconf quote pair;
+ # the inner square brackets are the normal regexp character class.
+ echo "got '$list_type' from $listh, tab=$tab." >/tmp/lh
+ list_type=`echo "$list_type" | sed "s/[ $tab][ $tab]*/ /g"`
+ echo "new '$list_type' from $listh" >>/tmp/lh
+ #
+ if test -z "$list_type"; then
+ # But if we didn't find anything, default to the type of our
+ # page_labels member in pagesel.c, which has been the traditional
+ # effective behavior.
+ list_type="char **"
+ fi
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $list_type" >&5
+printf "%s\n" "$list_type" >&6; }
+ #debug: echo "got '$list_type' from $listh" >/tmp/lh
+ #
+ # autoconf internally quotes the shell variable value with
+ # ac_define_unquoted; we don't use shell "quotes" here since the final
+ # value must not have any quotes, being a type that we want to use in
+ # a cast, not a string constant.
+
+printf "%s\n" "#define XAWLISTCHANGELISTTYPE $list_type" >>confdefs.h
+
else
as_fn_error $? "Sorry, you will need at least the Xaw header/library files to compile xdvik." "$LINENO" 5
fi
Modified: trunk/Build/source/texk/xdvik/gui/pagesel.c
===================================================================
--- trunk/Build/source/texk/xdvik/gui/pagesel.c 2025-02-17 23:11:37 UTC (rev 74081)
+++ trunk/Build/source/texk/xdvik/gui/pagesel.c 2025-02-17 23:39:24 UTC (rev 74082)
@@ -539,18 +539,25 @@
/* delete and re-create list */
ASSERT(total_pages <= (int)page_info.index_size, "");
- /* The following line causes a gcc incompatible-pointer-types error
- on some system, due to lack and/or presence of const in the
+ /* The purpose of the (XAWLISTCHANGELISTTYPE) cast for page_labels
+ is to avoid a gcc incompatible-pointer-types error
+ on some systems, due to the lack and/or presence of const in the
XawListChange function parameter. Unfortunately different systems
evidently have different, and incompatible, types for that
parameter. Thus a cast to any single type will fail on some
- systems. A configure test to determine the correct type for the
- cast seems like the only robust solution? --karl, 15feb25.
- xdvi bug report: https://sourceforge.net/p/xdvi/bugs/406/
- discussion of alternatives:
- https://tug.org/pipermail/tex-k/2024-February/004008.html
+ systems. A (too) simplistic configure test to determine the
+ correct type is done in xdvi-check-xaw.m4. See more comments there.
+ xdvi bug report:
+ https://sourceforge.net/p/xdvi/bugs/406/
+ discussion of alternatives:
+ https://tug.org/pipermail/tex-k/2024-February/004008.html
*/
- XawListChange(LIST_WIDGET, page_info.page_labels, 0,
+#ifndef XAWLISTCHANGELISTTYPE
+#define XAWLISTCHANGELISTTYPE char **
+#endif
+ XawListChange(LIST_WIDGET,
+ (XAWLISTCHANGELISTTYPE) page_info.page_labels,
+ 0,
MAX(button_width, pagelist_width), False);
/* restore selected item */
if (idx != XAW_LIST_NONE) {
Modified: trunk/Build/source/texk/xdvik/m4/xdvi-check-xaw.m4
===================================================================
--- trunk/Build/source/texk/xdvik/m4/xdvi-check-xaw.m4 2025-02-17 23:11:37 UTC (rev 74081)
+++ trunk/Build/source/texk/xdvik/m4/xdvi-check-xaw.m4 2025-02-17 23:39:24 UTC (rev 74082)
@@ -70,10 +70,56 @@
[$x_xp_lib $x_xmu_lib -lXt $X_PRE_LIBS $x_ext_lib $x_xpm_libs -lX11 $X_EXTRA_LIBS $XLFLAG])
fi],
[$x_xmu_lib -lXt $X_PRE_LIBS $x_ext_lib $x_xpm_libs -lX11 $X_EXTRA_LIBS $XLFLAG])
-fi
+fi
if test "x$xdvi_have_xaw" = xyes; then
prog_extension="xaw"
AC_DEFINE([XAW], 1, [Define to use the Xaw toolkit.])
+
+ # We need the type of the "list" parameter to XawListChange
+ # (the second parameter), for use in gui/pagesel.c. See more comments there.
+ #
+ AC_MSG_CHECKING([for type of XawListChange list parameter])
+ # Although we could try to use the compiler to discern the location of
+ # <X11/Xaw/List.h>, that seems likely to have its own problems. Let's
+ # try just assuming the standard location.
+ #
+ listh=/usr/include/X11/Xaw/List.h
+
+ # Clearly this simple search is subject to plenty of problems in
+ # theory, but in practice, if no one gratuitously changes the
+ # formatting in Xaw/List.h, it should be ok? The line intended to be
+ # matched looks like
+ # String *list, [except with tabs]
+ # or
+ # _Xconst char *list,
+ # or who knows what else. Hopefully it will be the complete type.
+ #
+ list_type=`sed -n 's/list,$//p' $listh`
+ #
+ # The type ordinarily has lots of whitespace, as in the String line above.
+ # People will uselessly complain about that, so reduce it to a single space:
+ tab=' ' # that's a tab character
+ # The outer square brackets are the Autoconf quote pair;
+ # the inner square brackets are the normal regexp character class.
+ #echo "got '$list_type' from $listh, tab=$tab." >/tmp/lh
+ list_type=`echo "$list_type" | sed ["s/[ $tab][ $tab]*/ /g"]`
+ #echo "new '$list_type' from $listh" >>/tmp/lh
+ #
+ if test -z "$list_type"; then
+ # But if we didn't find anything, default to the type of our
+ # page_labels member in pagesel.c, which has been the traditional
+ # effective behavior.
+ list_type="char **"
+ fi
+ AC_MSG_RESULT([$list_type])
+ #debug: echo "got '$list_type' from $listh" >/tmp/lh
+ #
+ # autoconf internally quotes the shell variable value with
+ # ac_define_unquoted; we don't use shell "quotes" here since the final
+ # value must not have any quotes, being a type that we want to use in
+ # a cast, not a string constant.
+ AC_DEFINE_UNQUOTED([XAWLISTCHANGELISTTYPE], $list_type,
+ [type of XawListChange list parameter])
else
AC_MSG_ERROR([Sorry, you will need at least the Xaw header/library files to compile xdvik.])
fi
More information about the tex-live-commits
mailing list.