Skip to content

Commit

Permalink
configure check for the type of the list (second) parameter of the Xa…
Browse files Browse the repository at this point in the history
…wListChange function, and cast to it in the call; probably too simplistic

git-svn-id: svn://tug.org/texlive/trunk/Build/source@74082 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
kberry committed Feb 17, 2025
1 parent 5c74445 commit 47f1eb2
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 9 deletions.
14 changes: 14 additions & 0 deletions texk/xdvik/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2025-02-17 Karl Berry <karl@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@freefriends.org>

* gui/pagesel.c (xaw_update_list): put in comment about the known
Expand Down
3 changes: 3 additions & 0 deletions texk/xdvik/c-auto.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
49 changes: 49 additions & 0 deletions texk/xdvik/configure
Original file line number Diff line number Diff line change
Expand Up @@ -19947,6 +19947,55 @@ if test "x$xdvi_have_xaw" = xyes; then

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
Expand Down
23 changes: 15 additions & 8 deletions texk/xdvik/gui/pagesel.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,18 +539,25 @@ xaw_update_list(void)
/* 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) {
Expand Down
48 changes: 47 additions & 1 deletion texk/xdvik/m4/xdvi-check-xaw.m4
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,56 @@ if test "x$xdvi_have_xaw" = xyes; then
[$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
Expand Down

0 comments on commit 47f1eb2

Please sign in to comment.