[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: branch-1_4 modernize configure
From: |
Eric Blake |
Subject: |
FYI: branch-1_4 modernize configure |
Date: |
Sat, 27 May 2006 16:17:22 +0000 |
./configure had some old cruft. Most GNU projects are now requiring C89,
so I killed ansi2knr support in the process of upgrading to autoconf 2.59.
I did not follow through with extensive C code changes, to minimize the
scope of this patch, but can do so if anyone thinks it best. I also did
not upgrade to 2.59d (if we don't mind CVS autoconf, or waiting for
autoconf 2.60, we could use constructs like AC_CHECK_DECLS_ONCE
for a smaller configure); I made sure that stock 2.59 worked. But
prior to 2.59 does not work, thanks to AS_HELP_STRING.
2006-05-27 Eric Blake <address@hidden>
* configure.ac: Update to autoconf 2.59. Forbid ^M4_. Fix
quoting.
* aclocal.m4 (fp_PROG_CC_STDC): Delete; now covered by autoconf.
(fp_C_PROTOTYPES): Delete, GNU Coding Standards state we can now
assume C89.
(M4_WITH_DMALLOC): Rename from fp_WITH_DMALLOC. Fix quoting.
* src/m4.h (_): PROTOTYPES is no longer provided, assume C89.
* src/Makefile.in: Delete remains of ansi2knr.
* src/ansi2knr.1: Delete.
* src/ansi2knr.c: Delete.
Index: aclocal.m4
===================================================================
RCS file: /sources/m4/m4/Attic/aclocal.m4,v
retrieving revision 1.1.1.1.2.2
diff -u -p -r1.1.1.1.2.2 aclocal.m4
--- aclocal.m4 3 Feb 2005 16:43:11 -0000 1.1.1.1.2.2
+++ aclocal.m4 27 May 2006 15:43:47 -0000
@@ -1,85 +1,20 @@
# Local additions to Autoconf macros.
-# Copyright (C) 1992, 1994, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1994, 2004, 2006 Free Software Foundation, Inc.
# Francois Pinard <address@hidden>, 1992.
-# @defmac AC_PROG_CC_STDC
-# @maindex PROG_CC_STDC
-# @ovindex CC
-# If the C compiler in not in ANSI C mode by default, try to add an option
-# to output variable @code{CC} to make it so. This macro tries various
-# options that select ANSI C on some system or another. It considers the
-# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
-# handles function prototypes correctly.
-#
-# If you use this macro, you should check after calling it whether the C
-# compiler has been set to accept ANSI C; if not, the shell variable
-# @code{ac_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
-# code in ANSI C, you can make an un-ANSIfied copy of it by using the
-# program @code{ansi2knr}, which comes with Ghostscript.
-# @end defmac
-
-AC_DEFUN([fp_PROG_CC_STDC],
-[AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
-AC_CACHE_VAL(ac_cv_prog_cc_stdc,
-[ac_cv_prog_cc_stdc=no
-ac_save_CFLAGS="$CFLAGS"
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX -Aa -D_HPUX_SOURCE
-# SVR4 -Xc
-for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc
-do
- CFLAGS="$ac_save_CFLAGS $ac_arg"
- AC_TRY_COMPILE(
-[#if !defined(__STDC__) || __STDC__ != 1
-choke me
-#endif
-], [int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};],
-[ac_cv_prog_cc_stdc="$ac_arg"; break])
-done
-CFLAGS="$ac_save_CFLAGS"
-])
-AC_MSG_RESULT($ac_cv_prog_cc_stdc)
-case "x$ac_cv_prog_cc_stdc" in
- x|xno) ;;
- *) CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-])
-
-# Check for function prototypes.
-
-AC_DEFUN(fp_C_PROTOTYPES,
-[AC_REQUIRE([fp_PROG_CC_STDC])
-AC_MSG_CHECKING([for function prototypes])
-if test "$ac_cv_prog_cc_stdc" != no; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(PROTOTYPES, 1, Define to 1 if ANSI function prototypes are
available)
- U= ANSI2KNR=
-else
- AC_MSG_RESULT(no)
- U=_ ANSI2KNR=ansi2knr
-fi
-AC_SUBST(U)dnl
-AC_SUBST(ANSI2KNR)dnl
-])
-
# Check if --with-dmalloc was given.
-AC_DEFUN(fp_WITH_DMALLOC,
-[AC_MSG_CHECKING(if malloc debugging is wanted)
-AC_ARG_WITH(dmalloc,
-[ --with-dmalloc use dmalloc, as in dmalloc.tar.gz from
- @/ftp.antaire.com:antaire/src/dmalloc.],
+AC_DEFUN([M4_WITH_DMALLOC],
+[AC_MSG_CHECKING([if malloc debugging is wanted])
+AC_ARG_WITH([dmalloc],
+[AS_HELP_STRING([--with-dmalloc],
+ [use dmalloc, as in dmalloc.tar.gz from
+ @/ftp.antaire.com:antaire/src/dmalloc.])],
[if test "$withval" = yes; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(WITH_DMALLOC, 1, Define to 1 if malloc debugging is enabled)
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([WITH_DMALLOC], [1], [Define to 1 if malloc debugging is enabled])
LIBS="$LIBS -ldmalloc"
LDFLAGS="$LDFLAGS -g"
else
- AC_MSG_RESULT(no)
-fi], [AC_MSG_RESULT(no)])])
-
+ AC_MSG_RESULT([no])
+fi], [AC_MSG_RESULT([no])])])
Index: configure.ac
===================================================================
RCS file: /sources/m4/m4/configure.ac,v
retrieving revision 1.36.2.7
diff -u -p -r1.36.2.7 configure.ac
--- configure.ac 20 Oct 2005 12:50:53 -0000 1.36.2.7
+++ configure.ac 27 May 2006 15:43:47 -0000
@@ -1,5 +1,6 @@
# Configure template for GNU M4. -*-Autoconf-*-
-# Copyright (C) 1991, 1993, 1994, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1991, 1993, 1994, 2004, 2005, 2006 Free Software
+# Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,10 +17,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
-
+AC_PREREQ([2.59])
AC_INIT([GNU M4], [1.4.4a], address@hidden)
-PACKAGE=$PACKAGE_TARNAME; AC_SUBST(PACKAGE)
-VERSION=$PACKAGE_VERSION; AC_SUBST(VERSION)
+PACKAGE=$PACKAGE_TARNAME; AC_SUBST([PACKAGE])
+VERSION=$PACKAGE_VERSION; AC_SUBST([VERSION])
+
+m4_pattern_forbid([^M4_])
AC_CONFIG_SRCDIR([src/m4.h])
AC_CONFIG_HEADERS([config.h:config-h.in])
@@ -34,7 +37,6 @@ AC_PROG_RANLIB
AC_AIX
AC_ISC_POSIX
AC_MINIX
-fp_C_PROTOTYPES
AC_C_CONST
AC_CHECK_HEADERS([limits.h memory.h siginfo.h string.h unistd.h])
@@ -51,14 +53,15 @@ AC_REPLACE_FUNCS([strtol])
AC_MSG_CHECKING([ecvt declaration])
AC_EGREP_HEADER([ecvt], [stdlib.h],
- [AC_MSG_RESULT(yes)
+ [AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_EFGCVT], [2],
- [Define to 1 if you have ecvt(3), fcvt(3) and gcvt(3). Define to 2 if
they are declared in stdlib.h])
+ [Define to 1 if you have ecvt(3), fcvt(3) and gcvt(3). Define to 2 if
+they are declared in stdlib.h])
],
- [AC_MSG_RESULT(no); AC_CHECK_FUNCS(ecvt)])
+ [AC_MSG_RESULT([no]); AC_CHECK_FUNCS([ecvt])])
-AC_MSG_CHECKING(if stack overflow is detectable)
+AC_MSG_CHECKING([if stack overflow is detectable])
# Code from Jim Avera <address@hidden>.
# stackovf.c requires:
# 1. Either sigaction with SA_ONSTACK, or sigvec with SV_ONSTACK
@@ -67,23 +70,22 @@ AC_MSG_CHECKING(if stack overflow is det
use_stackovf=no
if test "$ac_cv_func_sigaction" = yes || test "$ac_cv_func_sigvec" = yes; then
if test "$ac_cv_func_sigaltstack" = yes || test "$ac_cv_func_sigstack" =
yes; then
- AC_TRY_LINK([#include <sys/time.h>
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>
#include <sys/resource.h>
-#include <signal.h>],
- [struct rlimit r; int i; getrlimit (RLIMIT_STACK, &r)
+#include <signal.h>]],
+ [[struct rlimit r; int i; getrlimit (RLIMIT_STACK, &r)
#if (!defined(HAVE_SIGACTION) || !defined(SA_ONSTACK)) \
&& (!defined(HAVE_SIGVEC) || !defined(SV_ONSTACK))
choke me /* SA_ONSTACK and/or SV_ONSTACK are not defined */
-#endif],
- use_stackovf=yes)
+#endif]])],[use_stackovf=yes],[])
fi
fi
-AC_MSG_RESULT($use_stackovf)
+AC_MSG_RESULT([$use_stackovf])
if test "$use_stackovf" = yes; then
AC_DEFINE([USE_STACKOVF], [1],
[Define to 1 if using stack overflow detection])
- STACKOVF=stackovf.${U}o
- AC_SUBST(STACKOVF)
+ STACKOVF=stackovf.$(OBJEXT)
+ AC_SUBST([STACKOVF])
AC_EGREP_HEADER([rlim_t], [sys/resource.h], [],
[AC_DEFINE([rlim_t], [int],
[Define to int if rlim_t is not defined in sys/resource.h])
@@ -100,16 +102,17 @@ fi
AC_MSG_CHECKING([[if changeword is wanted]])
AC_ARG_ENABLE([changeword],
- [[ --enable-changeword enable -W and changeword() builtin]],
+ [AS_HELP_STRING([--enable-changeword],
+ [enable -W and changeword() builtin])],
[if test "$enableval" = yes; then
- AC_MSG_RESULT(yes)
+ AC_MSG_RESULT([yes])
AC_DEFINE([ENABLE_CHANGEWORD], [1],
[Define to 1 if the changeword(REGEXP) functionality is wanted])
else
- AC_MSG_RESULT(no)
- fi], [AC_MSG_RESULT(no)])
+ AC_MSG_RESULT([no])
+ fi], [AC_MSG_RESULT([no])])
-fp_WITH_DMALLOC
+M4_WITH_DMALLOC
AC_CONFIG_FILES([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
Index: src/Makefile.in
===================================================================
RCS file: /sources/m4/m4/src/Attic/Makefile.in,v
retrieving revision 1.1.1.1.2.5
diff -u -p -r1.1.1.1.2.5 Makefile.in
--- src/Makefile.in 11 May 2006 12:21:24 -0000 1.1.1.1.2.5
+++ src/Makefile.in 27 May 2006 15:43:47 -0000
@@ -51,21 +51,7 @@ LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
.c.obj:
$(COMPILE) $<
-ANSI2KNR = @ANSI2KNR@
-O = address@hidden@$(OBJEXT)
-
-.SUFFIXES: ._c ._o
-.c._c:
- ./ansi2knr --varargs $< > $@
-._c._o:
- @echo $(COMPILE) $<
- @rm -f _$*.c
- @ln $< _$*.c && $(COMPILE) _$*.c && mv _$*.$(OBJEXT) $@ && rm _$*.c
-.c._o:
- ./ansi2knr --varargs $< > $*._c
- @echo $(COMPILE) $*._c
- @rm -f _$*.c
- @ln $*._c _$*.c && $(COMPILE) _$*.c && mv _$*.$(OBJEXT) $@ && rm _$*.c
+O = .$(OBJEXT)
INCLUDES = -I.. -I$(srcdir) -I$(srcdir)/../lib
@@ -75,7 +61,7 @@ macro.c output.c path.c stackovf.c symta
OBJECTS = m4$O builtin$O debug$O eval$O format$O freeze$O input$O \
macro$O output$O path$O $(STACKOVF) symtab$O
-DISTFILES = Makefile.in ansi2knr.c ansi2knr.1 $(HEADERS) $(SOURCES) \
+DISTFILES = Makefile.in $(HEADERS) $(SOURCES) \
TAGS
all: m4$(EXEEXT)
@@ -83,12 +69,9 @@ all: m4$(EXEEXT)
m4$(EXEEXT): $(OBJECTS) ../lib/libm4.a
$(LINK) $(OBJECTS) ../lib/libm4.a $(LIBS)
-$(OBJECTS): $(ANSI2KNR) ../config.h m4.h ../lib/obstack.h
+$(OBJECTS): ../config.h m4.h ../lib/obstack.h
builtin$O: ../lib/regex.h
-ansi2knr: ansi2knr.$(OBJEXT)
- $(LINK) ansi2knr.$(OBJEXT) $(LIBS)
-
install: all
$(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) m4$(EXEEXT) \
@@ -109,7 +92,7 @@ clean: mostlyclean
rm -f m4$(EXEEXT)
distclean: clean
- rm -f Makefile ansi2knr
+ rm -f Makefile
realclean: distclean
rm -f TAGS
Index: src/ansi2knr.1
===================================================================
RCS file: src/ansi2knr.1
diff -N src/ansi2knr.1
--- src/ansi2knr.1 17 Feb 2000 03:03:19 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-.TH ANSI2KNR 1 "31 December 1990"
-.SH NAME
-ansi2knr \- convert ANSI C to Kernighan & Ritchie C
-.SH SYNOPSIS
-.I ansi2knr
-input_file output_file
-.SH DESCRIPTION
-If no output_file is supplied, output goes to stdout.
-.br
-There are no error messages.
-.sp
-.I ansi2knr
-recognizes functions by seeing a non-keyword identifier at the left margin,
followed by a left parenthesis, with a right parenthesis as the last character
on the line. It will recognize a multi-line header if the last character on
each line but the last is a left parenthesis or comma. These algorithms ignore
whitespace and comments, except that the function name must be the first thing
on the line.
-.sp
-The following constructs will confuse it:
-.br
- - Any other construct that starts at the left margin and follows the
above syntax (such as a macro or function call).
-.br
- - Macros that tinker with the syntax of the function header.
Index: src/ansi2knr.c
===================================================================
RCS file: src/ansi2knr.c
diff -N src/ansi2knr.c
--- src/ansi2knr.c 17 Feb 2000 03:03:19 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,439 +0,0 @@
-/* Copyright (C) 1989, 1991, 1993, 1994 Aladdin Enterprises. All rights
reserved. */
-
-/* ansi2knr.c */
-/* Convert ANSI function declarations to K&R syntax */
-
-/*
-ansi2knr is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
-to anyone for the consequences of using it or for whether it serves any
-particular purpose or works at all, unless he says so in writing. Refer
-to the GNU General Public License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-ansi2knr, but only under the conditions described in the GNU
-General Public License. A copy of this license is supposed to have been
-given to you along with ansi2knr so you can know your rights and
-responsibilities. It should be in a file named COPYLEFT. Among other
-things, the copyright notice and this notice must be preserved on all
-copies.
-*/
-
-/*
- * Usage:
- ansi2knr [--varargs] input_file [output_file]
- * If no output_file is supplied, output goes to stdout.
- * There are no error messages.
- *
- * ansi2knr recognizes function definitions by seeing a non-keyword
- * identifier at the left margin, followed by a left parenthesis,
- * with a right parenthesis as the last character on the line.
- * It will recognize a multi-line header provided that the last character
- * of the last line of the header is a right parenthesis,
- * and no intervening line ends with a left brace or a semicolon.
- * These algorithms ignore whitespace and comments, except that
- * the function name must be the first thing on the line.
- * The following constructs will confuse it:
- * - Any other construct that starts at the left margin and
- * follows the above syntax (such as a macro or function call).
- * - Macros that tinker with the syntax of the function header.
- *
- * If the --varargs switch is supplied, ansi2knr will attempt to
- * convert a ... argument to va_alist and va_dcl. If this switch is not
- * supplied, ansi2knr will simply drop any such arguments.
- */
-
-/*
- * The original and principal author of ansi2knr is L. Peter Deutsch
- * <address@hidden>. Other authors are noted in the change history
- * that follows (in reverse chronological order):
- lpd 94-10-10 removed CONFIG_BROKETS conditional
- lpd 94-07-16 added some conditionals to help GNU `configure',
- suggested by Francois Pinard <address@hidden>;
- properly erase prototype args in function parameters,
- contributed by Jim Avera <address@hidden>;
- correct error in writeblanks (it shouldn't erase EOLs)
- lpd 89-xx-xx original version
- */
-
-/* Most of the conditionals here are to make ansi2knr work with */
-/* the GNU configure machinery. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-
-#ifdef HAVE_CONFIG_H
-
-/*
- For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
- This will define HAVE_CONFIG_H and so, activate the following lines.
- */
-
-# if STDC_HEADERS || HAVE_STRING_H
-# include <string.h>
-# else
-# include <strings.h>
-# endif
-
-#else /* not HAVE_CONFIG_H */
-
-/*
- Without AC_CONFIG_HEADER, merely use <string.h> as in the original
- Ghostscript distribution. This loses on older BSD systems.
- */
-
-# include <string.h>
-
-#endif /* not HAVE_CONFIG_H */
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#else
-/*
- malloc and free should be declared in stdlib.h,
- but if you've got a K&R compiler, they probably aren't.
- */
-char *malloc();
-void free();
-#endif
-
-/* Scanning macros */
-#define isidchar(ch) (isalnum(ch) || (ch) == '_')
-#define isidfirstchar(ch) (isalpha(ch) || (ch) == '_')
-
-/* Forward references */
-char *skipspace();
-void writeblanks();
-int test1();
-int convert1();
-
-/* The main program */
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{ FILE *in, *out;
-#define bufsize 5000 /* arbitrary size */
- char *buf;
- char *line;
- int convert_varargs = 0;
- if ( argc > 1 && argv[1][0] == '-' )
- { if ( !strcmp(argv[1], "--varargs") )
- { convert_varargs = 1;
- argc--;
- argv++;
- }
- else
- { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]);
- exit(1);
- }
- }
- switch ( argc )
- {
- default:
- printf("Usage: ansi2knr [--varargs] input_file
[output_file]\n");
- exit(0);
- case 2:
- out = stdout;
- break;
- case 3:
- out = fopen(argv[2], "w");
- if ( out == NULL )
- { fprintf(stderr, "Cannot open output file %s\n",
argv[2]);
- exit(1);
- }
- }
- in = fopen(argv[1], "r");
- if ( in == NULL )
- { fprintf(stderr, "Cannot open input file %s\n", argv[1]);
- exit(1);
- }
- fprintf(out, "#line 1 \"%s\"\n", argv[1]);
- buf = malloc(bufsize);
- line = buf;
- while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
- { switch ( test1(buf) )
- {
- case 2: /* a function header */
- convert1(buf, out, 1, convert_varargs);
- break;
- case 1: /* a function */
- convert1(buf, out, 0, convert_varargs);
- break;
- case -1: /* maybe the start of a function */
- line = buf + strlen(buf);
- if ( line != buf + (bufsize - 1) ) /* overflow check */
- continue;
- /* falls through */
- default: /* not a function */
- fputs(buf, out);
- break;
- }
- line = buf;
- }
- if ( line != buf ) fputs(buf, out);
- free(buf);
- fclose(out);
- fclose(in);
- return 0;
-}
-
-/* Skip over space and comments, in either direction. */
-char *
-skipspace(p, dir)
- register char *p;
- register int dir; /* 1 for forward, -1 for backward */
-{ for ( ; ; )
- { while ( isspace(*p) ) p += dir;
- if ( !(*p == '/' && p[dir] == '*') ) break;
- p += dir; p += dir;
- while ( !(*p == '*' && p[dir] == '/') )
- { if ( *p == 0 ) return p; /* multi-line comment??
*/
- p += dir;
- }
- p += dir; p += dir;
- }
- return p;
-}
-
-/*
- * Write blanks over part of a string.
- * Don't overwrite end-of-line characters.
- */
-void
-writeblanks(start, end)
- char *start;
- char *end;
-{ char *p;
- for ( p = start; p < end; p++ )
- if ( *p != '\r' && *p != '\n' ) *p = ' ';
-}
-
-/*
- * Test whether the string in buf is a function definition.
- * The string may contain and/or end with a newline.
- * Return as follows:
- * 0 - definitely not a function definition;
- * 1 - definitely a function definition;
- * 2 - definitely a function prototype (NOT USED);
- * -1 - may be the beginning of a function definition,
- * append another line and look again.
- * The reason we don't attempt to convert function prototypes is that
- * Ghostscript's declaration-generating macros look too much like
- * prototypes, and confuse the algorithms.
- */
-int
-test1(buf)
- char *buf;
-{ register char *p = buf;
- char *bend;
- char *endfn;
- int contin;
- if ( !isidfirstchar(*p) )
- return 0; /* no name at left margin */
- bend = skipspace(buf + strlen(buf) - 1, -1);
- switch ( *bend )
- {
- case ';': contin = 0 /*2*/; break;
- case ')': contin = 1; break;
- case '{': return 0; /* not a function */
- default: contin = -1;
- }
- while ( isidchar(*p) ) p++;
- endfn = p;
- p = skipspace(p, 1);
- if ( *p++ != '(' )
- return 0; /* not a function */
- p = skipspace(p, 1);
- if ( *p == ')' )
- return 0; /* no parameters */
- /* Check that the apparent function name isn't a keyword. */
- /* We only need to check for keywords that could be followed */
- /* by a left parenthesis (which, unfortunately, is most of them). */
- { static char *words[] =
- { "asm", "auto", "case", "char", "const", "double",
- "extern", "float", "for", "if", "int", "long",
- "register", "return", "short", "signed", "sizeof",
- "static", "switch", "typedef", "unsigned",
- "void", "volatile", "while", 0
- };
- char **key = words;
- char *kp;
- int len = endfn - buf;
- while ( (kp = *key) != 0 )
- { if ( strlen(kp) == len && !strncmp(kp, buf, len) )
- return 0; /* name is a keyword */
- key++;
- }
- }
- return contin;
-}
-
-/* Convert a recognized function definition or header to K&R syntax. */
-int
-convert1(buf, out, header, convert_varargs)
- char *buf;
- FILE *out;
- int header; /* Boolean */
- int convert_varargs; /* Boolean */
-{ char *endfn;
- register char *p;
- char **breaks;
- unsigned num_breaks = 2; /* for testing */
- char **btop;
- char **bp;
- char **ap;
- char *vararg = 0;
- /* Pre-ANSI implementations don't agree on whether strchr */
- /* is called strchr or index, so we open-code it here. */
- for ( endfn = buf; *(endfn++) != '('; ) ;
-top: p = endfn;
- breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
- if ( breaks == 0 )
- { /* Couldn't allocate break table, give up */
- fprintf(stderr, "Unable to allocate break table!\n");
- fputs(buf, out);
- return -1;
- }
- btop = breaks + num_breaks * 2 - 2;
- bp = breaks;
- /* Parse the argument list */
- do
- { int level = 0;
- char *lp = NULL;
- char *rp;
- char *end = NULL;
- if ( bp >= btop )
- { /* Filled up break table. */
- /* Allocate a bigger one and start over. */
- free((char *)breaks);
- num_breaks <<= 1;
- goto top;
- }
- *bp++ = p;
- /* Find the end of the argument */
- for ( ; end == NULL; p++ )
- { switch(*p)
- {
- case ',':
- if ( !level ) end = p;
- break;
- case '(':
- if ( !level ) lp = p;
- level++;
- break;
- case ')':
- if ( --level < 0 ) end = p;
- else rp = p;
- break;
- case '/':
- p = skipspace(p, 1) - 1;
- break;
- default:
- ;
- }
- }
- /* Erase any embedded prototype parameters. */
- if ( lp )
- writeblanks(lp + 1, rp);
- p--; /* back up over terminator */
- /* Find the name being declared. */
- /* This is complicated because of procedure and */
- /* array modifiers. */
- for ( ; ; )
- { p = skipspace(p - 1, -1);
- switch ( *p )
- {
- case ']': /* skip array dimension(s) */
- case ')': /* skip procedure args OR name */
- { int level = 1;
- while ( level )
- switch ( *--p )
- {
- case ']': case ')': level++; break;
- case '[': case '(': level--; break;
- case '/': p = skipspace(p, -1) + 1; break;
- default: ;
- }
- }
- if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
- { /* We found the name being declared */
- while ( !isidfirstchar(*p) )
- p = skipspace(p, 1) + 1;
- goto found;
- }
- break;
- default: goto found;
- }
- }
-found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
- { if ( convert_varargs )
- { *bp++ = "va_alist";
- vararg = p-2;
- }
- else
- { p++;
- if ( bp == breaks + 1 ) /* sole argument */
- writeblanks(breaks[0], p);
- else
- writeblanks(bp[-1] - 1, p);
- bp--;
- }
- }
- else
- { while ( isidchar(*p) ) p--;
- *bp++ = p+1;
- }
- p = end;
- }
- while ( *p++ == ',' );
- *bp = p;
- /* Make a special check for 'void' arglist */
- if ( bp == breaks+2 )
- { p = skipspace(breaks[0], 1);
- if ( !strncmp(p, "void", 4) )
- { p = skipspace(p+4, 1);
- if ( p == breaks[2] - 1 )
- { bp = breaks; /* yup, pretend arglist is
empty */
- writeblanks(breaks[0], p + 1);
- }
- }
- }
- /* Put out the function name and left parenthesis. */
- p = buf;
- while ( p != endfn ) putc(*p, out), p++;
- /* Put out the declaration. */
- if ( header )
- { fputs(");", out);
- for ( p = breaks[0]; *p; p++ )
- if ( *p == '\r' || *p == '\n' )
- putc(*p, out);
- }
- else
- { for ( ap = breaks+1; ap < bp; ap += 2 )
- { p = *ap;
- while ( isidchar(*p) )
- putc(*p, out), p++;
- if ( ap < bp - 1 )
- fputs(", ", out);
- }
- fputs(") ", out);
- /* Put out the argument declarations */
- for ( ap = breaks+2; ap <= bp; ap += 2 )
- (*ap)[-1] = ';';
- if ( vararg != 0 )
- { *vararg = 0;
- fputs(breaks[0], out); /* any prior args */
- fputs("va_dcl", out); /* the final arg */
- fputs(bp[0], out);
- }
- else
- fputs(breaks[0], out);
- }
- free((char *)breaks);
- return 0;
-}
Index: src/m4.h
===================================================================
RCS file: /sources/m4/m4/src/m4.h,v
retrieving revision 1.1.1.1.2.4
diff -u -p -r1.1.1.1.2.4 m4.h
--- src/m4.h 1 May 2005 11:54:12 -0000 1.1.1.1.2.4
+++ src/m4.h 27 May 2006 15:43:47 -0000
@@ -1,6 +1,6 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005 Free
+ Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005, 2006 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -43,11 +43,8 @@
# define voidstar char *
#endif
-#ifdef PROTOTYPES
-# define _(Args) Args
-#else
-# define _(Args) ()
-#endif
+/* FIXME - we no longer need this ansi2knr hack. */
+#define _(Args) Args
#include <stdio.h>
#include <ctype.h>
@@ -315,7 +312,7 @@ struct token_data
# define TOKEN_DATA_ORIG_TEXT(Td) ((Td)->u.u_t.original_text)
#endif
#define TOKEN_DATA_FUNC(Td) ((Td)->u.u_f.func)
-#define TOKEN_DATA_FUNC_TRACED(Td) ((Td)->u.u_f.traced)
+#define TOKEN_DATA_FUNC_TRACED(Td) ((Td)->u.u_f.traced)
typedef enum token_type token_type;
typedef enum token_data_type token_data_type;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: branch-1_4 modernize configure,
Eric Blake <=