[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch-1_4 C89 cleanup
From: |
Eric Blake |
Subject: |
branch-1_4 C89 cleanup |
Date: |
Fri, 7 Jul 2006 20:20:05 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
I tried ./configure --with-dmalloc, and found a collision with xfree. In the
process, I fixed up some K&R cruft no longer needed now that we assume C89 or
better. I also got tired of seeing a message that m4.1 was being rebuilt, only
to have no timestamp update because the file contents didn't change. Committed:
2006-07-07 Eric Blake <address@hidden>
* doc/Makefile.am (m4.1): No need to go through a temporary file;
this also ensures timestamps are updated.
* src/m4.h (includes): Require config.h. Assume string.h,
stdlib.h, errno. Include error.h, exit.h, and xalloc.h rather
than prototyping ourselves.
(builtin_func): Add parameter type-checking.
(voidstar): Delete, now that we assume C89.
* src/builtin.c, src/m4.c, src/macro.c, src/symtab.c: All users of
voidstar changed.
* src/m4.c (xfree) [WITH_DMALLOC]: Avoid clash with dmalloc's
xfree.
Index: doc/Makefile.am
===================================================================
RCS file: /sources/m4/m4/doc/Attic/Makefile.am,v
retrieving revision 1.8.2.4
diff -u -r1.8.2.4 Makefile.am
--- doc/Makefile.am 6 Jul 2006 18:10:38 -0000 1.8.2.4
+++ doc/Makefile.am 7 Jul 2006 20:15:44 -0000
@@ -34,9 +34,7 @@
@if test -x ../src/m4$(EXEEXT) ; then \
echo "Updating man page m4.1" ; \
$(SHELL) $(top_srcdir)/missing --run \
- help2man -o address@hidden ../src/m4$(EXEEXT) ; \
- cmp -s address@hidden $@ || cp address@hidden $@; \
- rm -f address@hidden; \
+ help2man -o $@ ../src/m4$(EXEEXT) ; \
else \
echo "WARNING: The \`man' page \`$@' cannot be updated yet."; \
echo " Retry once the program executable is ready."; \
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.17
diff -u -r1.1.1.1.2.17 builtin.c
--- src/builtin.c 7 Jul 2006 02:40:46 -0000 1.1.1.1.2.17
+++ src/builtin.c 7 Jul 2006 20:15:44 -0000
@@ -590,7 +590,7 @@
`------------------------------------------------------------------------*/
static int
-dumpdef_cmp (const voidstar s1, const voidstar s2)
+dumpdef_cmp (const void *s1, const void *s2)
{
return strcmp (SYMBOL_NAME (* (symbol *const *) s1),
SYMBOL_NAME (* (symbol *const *) s2));
Index: src/m4.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/m4.c,v
retrieving revision 1.1.1.1.2.12
diff -u -r1.1.1.1.2.12 m4.c
--- src/m4.c 23 Jun 2006 13:06:10 -0000 1.1.1.1.2.12
+++ src/m4.c 7 Jul 2006 20:15:44 -0000
@@ -121,8 +121,12 @@
| Failsafe free routine. |
`------------------------*/
+#ifdef WITH_DMALLOC
+# undef xfree
+#endif
+
void
-xfree (voidstar p)
+xfree (void *p)
{
if (p != NULL)
free (p);
@@ -450,7 +454,7 @@
}
next = defines->next;
- xfree ((voidstar) defines);
+ xfree (defines);
defines = next;
}
Index: src/m4.h
===================================================================
RCS file: /sources/m4/m4/src/m4.h,v
retrieving revision 1.1.1.1.2.14
diff -u -r1.1.1.1.2.14 m4.h
--- src/m4.h 7 Jul 2006 03:37:26 -0000 1.1.1.1.2.14
+++ src/m4.h 7 Jul 2006 20:15:44 -0000
@@ -23,9 +23,7 @@
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
(which it would do because it found this file in $srcdir). */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
/* Canonicalize UNIX recognition macros. */
#if defined unix || defined __unix || defined __unix__ \
@@ -38,74 +36,21 @@
# define W32_NATIVE 1
#endif
-#include <sys/types.h>
-
-#ifdef __STDC__
-# define voidstar void *
-#else
-# define voidstar char *
-#endif
-
/* FIXME - we no longer need this ansi2knr hack. */
#define _(Args) Args
-#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
#include "binary-io.h"
+#include "error.h"
+#include "exit.h"
#include "obstack.h"
-
-/* An ANSI string.h and pre-ANSI memory.h might conflict. */
-
-#if defined (HAVE_STRING_H) || defined (STDC_HEADERS)
-# include <string.h>
-# if !defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
-# include <memory.h>
-# endif
-/* This is for obstack code -- should live in obstack.h. */
-# ifndef bcopy
-# define bcopy(S, D, N) memcpy ((D), (S), (N))
-# endif
-#else
-# include <strings.h>
-# ifndef memcpy
-# define memcpy(D, S, N) bcopy((S), (D), (N))
-# endif
-# ifndef strchr
-# define strchr(S, C) index ((S), (C))
-# endif
-# ifndef strrchr
-# define strrchr(S, C) rindex ((S), (C))
-# endif
-# ifndef bcopy
-void bcopy ();
-# endif
-#endif
-
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#else /* not STDC_HEADERS */
-
-voidstar malloc ();
-voidstar realloc ();
-char *getenv ();
-double atof ();
-long strtol ();
-
-#endif /* STDC_HEADERS */
-
-/* Some systems do not define EXIT_*, even with STDC_HEADERS. */
-#ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-#endif
-#ifndef EXIT_FAILURE
-# define EXIT_FAILURE 1
-#endif
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
+#include "xalloc.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -134,19 +79,13 @@
typedef struct string STRING;
/* Memory allocation. */
-voidstar xmalloc _((unsigned int));
-voidstar xrealloc _((voidstar , unsigned int));
-void xfree _((voidstar));
-char *xstrdup _((const char *));
+void xfree (void *);
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free xfree
-/* Other library routines. */
-void error _((int, int, const char *, ...));
-
/* Those must come first. */
-typedef void builtin_func ();
typedef struct token_data token_data;
+typedef void builtin_func (struct obstack *, int, token_data **);
/* File: m4.c --- global definitions. */
Index: src/macro.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/macro.c,v
retrieving revision 1.1.1.1.2.5
diff -u -r1.1.1.1.2.5 macro.c
--- src/macro.c 23 Jun 2006 13:06:10 -0000 1.1.1.1.2.5
+++ src/macro.c 7 Jul 2006 20:15:44 -0000
@@ -202,8 +202,8 @@
TOKEN_DATA_TYPE (&td) = TOKEN_TEXT;
TOKEN_DATA_TEXT (&td) = SYMBOL_NAME (sym);
- tdp = (token_data *) obstack_copy (arguments, (voidstar) &td, sizeof (td));
- obstack_grow (argptr, (voidstar) &tdp, sizeof (tdp));
+ tdp = (token_data *) obstack_copy (arguments, &td, sizeof (td));
+ obstack_grow (argptr, &tdp, sizeof (tdp));
ch = peek_input ();
if (ch == '(')
@@ -219,8 +219,8 @@
TOKEN_DATA_TEXT (&td) = "";
}
tdp = (token_data *)
- obstack_copy (arguments, (voidstar) &td, sizeof (td));
- obstack_grow (argptr, (voidstar) &tdp, sizeof (tdp));
+ obstack_copy (arguments, &td, sizeof (td));
+ obstack_grow (argptr, &tdp, sizeof (tdp));
}
while (more_args);
}
Index: src/symtab.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/symtab.c,v
retrieving revision 1.1.1.1.2.11
diff -u -r1.1.1.1.2.11 symtab.c
--- src/symtab.c 23 Jun 2006 13:06:10 -0000 1.1.1.1.2.11
+++ src/symtab.c 7 Jul 2006 20:15:44 -0000
@@ -148,7 +148,7 @@
xfree (SYMBOL_NAME (sym));
if (SYMBOL_TYPE (sym) == TOKEN_TEXT)
xfree (SYMBOL_TEXT (sym));
- xfree ((voidstar) sym);
+ xfree (sym);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch-1_4 C89 cleanup,
Eric Blake <=