[21.4] Avoid m4 quoting in function definitions in configure
Stephen J. Turnbull
stephen at xemacs.org
Sat Jan 31 08:34:59 EST 2009
21.4
Vin,
This is a followup to a patch recommended by Martin for 21.5. It
simply changes the declaration of main() in test programs from
something that is intended to look like
int main (int argc, char *argv[])
but often doesn't because m4 sees the [] as a quoted empty string and
strips the brackets, to something like
int main (int argc, char **argv)
which is guaranteed to be equivalent by the definition of the C
language, but doesn't contain ay characters that might confuse m4.
As far as I can tell it does not fix any bugs (configure doesn't
contain any lines like "main (int argc, char *argv)" note 1 star!),
but it is much more readable in the face of m4's arcane quoting rules.
The patch does not include the changes for configure.
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/ChangeLog,v
retrieving revision 1.241.2.95
diff -u -r1.241.2.95 ChangeLog
--- ChangeLog 29 Dec 2008 02:18:50 -0000 1.241.2.95
+++ ChangeLog 31 Jan 2009 12:47:03 -0000
@@ -0,0 +1,9 @@
+2009-01-31 Stephen J. Turnbull <stephen at xemacs.org>
+
+ Based on a patch by Martin Buchholz <martin at xemacs.org> in
+ <18643.15864.667930.542671 at gargle.gargle.HOWL>. Thanks also to
+ Vladimir G. Ivanovic <vgivanovic at comcast.net>.
+
+ * configure.in: When defining main(argc,argv), declare char **argv
+ rather than char *argv[] (etc) to avoid problems with m4 quoting.
+
Index: configure.in
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/Attic/configure.in,v
retrieving revision 1.151.2.38
diff -u -r1.151.2.38 configure.in
--- configure.in 8 Dec 2006 03:31:16 -0000 1.151.2.38
+++ configure.in 31 Jan 2009 12:47:04 -0000
@@ -2298,7 +2298,7 @@
elif test "$GCC" = "yes"; then
dnl Compute runpath from gcc's -v output
ld_switch_run_save="$ld_switch_run"; ld_switch_run=""
- echo "int main(int argc, char *argv[[]]) {return 0;}" > conftest.c
+ echo "int main(int argc, char **argv) {return 0;}" > conftest.c
xe_runpath_link='${CC-cc} -o conftest -v $CFLAGS '"$xe_ldflags"' conftest.$ac_ext 2>&1 1>/dev/null'
for arg in `eval "$xe_runpath_link" | grep ' -L'`; do
case "$arg" in P,* | -L* | -R* )
@@ -2899,7 +2899,7 @@
AC_MSG_CHECKING(the version of X11 being used)
AC_TRY_RUN([#include <X11/Intrinsic.h>
- int main(int c, char *v[]) { return c>1 ? XlibSpecificationRelease : 0; }],
+ int main(int c, char **v) { return c>1 ? XlibSpecificationRelease : 0; }],
[./conftest foobar; x11_release=$?],[x11_release=4],[x11_release=4])
AC_MSG_RESULT(R${x11_release})
AC_DEFINE_UNQUOTED(THIS_IS_X11R${x11_release})
@@ -4167,7 +4167,7 @@
#define MAP_FAILED -1
#endif
-int main (int argc, char *argv[])
+int main (int argc, char **argv)
{
int fd = -1;
caddr_t p;
@@ -4711,7 +4711,7 @@
dnl One of the above link tests may have succeeded but caused resulting
dnl executables to fail to run. Also any tests using AC_TRY_RUN will
dnl have reported incorrect results.
-AC_TRY_RUN([int main(int c,char *v[]){return 0;}],[:],[
+AC_TRY_RUN([int main(int c,char **v){return 0;}],[:],[
echo ""
echo "*** PANIC *** configure forgot how to build working executables!"
echo ""
Index: src/regex.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/regex.c,v
retrieving revision 1.25.2.14
diff -u -r1.25.2.14 regex.c
2008-11-01 Stephen J. Turnbull <stephen at xemacs.org>
* regex.c (re_search_2): Fix at_dot by changing charpos to bytepos.
From Julian Bradfield <18654.1143.304851.782755 at krk.inf.ed.ac.uk>.
--- src/regex.c 31 Mar 2006 01:29:00 -0000 1.25.2.14
+++ src/regex.c 31 Jan 2009 12:47:06 -0000
@@ -4075,7 +4075,7 @@
don't keep searching past point. */
if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0)
{
- range = BUF_PT (regex_emacs_buffer) - BUF_BEGV (regex_emacs_buffer)
+ range = BI_BUF_PT (regex_emacs_buffer) - BI_BUF_BEGV (regex_emacs_buffer)
- startpos;
if (range < 0)
return -1;
More information about the XEmacs-Patches
mailing list