This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
egcs, finished patch for missing vfprintf
- To: egcs at cygnus dot com
- Subject: egcs, finished patch for missing vfprintf
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Wed, 22 Apr 1998 19:26:54 -0400 (EDT)
- Cc: ghazi at caip dot rutgers dot edu, law at cygnus dot com, wilson at cygnus dot com
I've finished writing patches to support missing vfprintf()
and _doprnt() for gcc. A couple of notes:
1. I split my previous vfprintf.c module into vfprintf.c and
doprint.c (which contains the function _doprnt().) This is cleaner
and fits better with eventual merging with libiberty support.
2. I fixed up support for the 'h' specifier in doprint.c.
3. I generalized _doprnt() so it parses %Ld in addition to %lld.
4. I switched cccp.c/cexp.y to use VPROTO (as does the rest of gcc)
instead of their own PRINTF_ALIST/PRINTF_DCL macros. The reason (besides
consistency) is that the PRINTF_* macros ended up defining functions like
this for !__STDC__ cases:
foo(msg, va_alist)
char * msg;
va_dcl
{
}
This is not valid on all KNR compilers. Some of the older
ones require that va_alist be the only argument and that you pull the
other args (like a format specifier) out manually. This is how the
rest of the source code using VPROTO does it.
5. Some general cleanup.
Is it okay to install?
--Kaveh
PS: Are there any special CVS issues regarding checking in new files?
Wed Apr 22 10:56:24 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4 (GCC_FUNC_VFPRINTF_DOPRNT): New macro.
* configure.in: Add a call to GCC_FUNC_VFPRINTF_DOPRNT.
(AC_CHECK_HEADERS): Remove unused check for varargs.h,sys/varargs.h.
(AC_CHECK_FUNCS): Remove unused check for vprintf.
* Makefile.in: Add support for linking in vfprintf.c and doprint.c.
(cccp.o): Depend on gansidecl.h.
(cexp.o): Likewise.
* cccp.c: Convert from using PRINTF_ALIST/PRINTF_DCL to VPROTO as
per the rest of gcc source.
* cexp.y: Likewise. Include gansidecl.h and remove all code made
redundant.
* cccp.c: Remove checks for HAVE_VPRINTF and the associated code
used when vfprintf is missing.
* cexp.y: Likewise.
* gcc.c: Likewise.
* genattrtab.c: Likewise.
* mips-tfile.c: Likewise.
* toplev.c: Likewise.
* vfprintf.c: New file.
* doprint.c: Likewise.
diff -rup orig/egcs-19980418/gcc/aclocal.m4 egcs-19980418/gcc/aclocal.m4
--- orig/egcs-19980418/gcc/aclocal.m4 Fri Apr 3 11:33:05 1998
+++ egcs-19980418/gcc/aclocal.m4 Sun Apr 19 22:34:04 1998
@@ -42,6 +42,22 @@ GCC_NEED_DECLARATION($ac_func)
done
])
+dnl Check if we have vprintf and possibly _doprnt.
+dnl Note autoconf checks for vprintf even though we care about vfprintf.
+AC_DEFUN(GCC_FUNC_VFPRINTF_DOPRNT,
+[AC_FUNC_VPRINTF
+vfprintf=
+doprint=
+if test $ac_cv_func_vprintf != yes ; then
+ vfprintf=vfprintf.o
+ if test $ac_cv_func__doprnt != yes ; then
+ doprint=doprint.o
+ fi
+fi
+AC_SUBST(vfprintf)
+AC_SUBST(doprint)
+])
+
dnl See if the printf functions in libc support %p in format strings.
AC_DEFUN(GCC_FUNC_PRINTF_PTR,
[AC_CACHE_CHECK(whether the printf functions support %p,
diff -rup orig/egcs-19980418/gcc/configure.in egcs-19980418/gcc/configure.in
--- orig/egcs-19980418/gcc/configure.in Wed Apr 15 08:41:32 1998
+++ egcs-19980418/gcc/configure.in Wed Apr 22 10:09:29 1998
@@ -148,7 +148,7 @@ EGCS_PROG_INSTALL
AC_HEADER_STDC
AC_HEADER_TIME
-AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h fcntl.h unistd.h sys/file.h sys/time.h sys/resource.h sys/param.h sys/times.h varargs.h sys/varargs.h wait.h sys/wait.h)
+AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h fcntl.h unistd.h sys/file.h sys/time.h sys/resource.h sys/param.h sys/times.h wait.h sys/wait.h)
# Check for thread headers.
AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
@@ -180,9 +180,10 @@ AC_CACHE_VAL(gcc_cv_header_inttypes_h,
gcc_cv_header_inttypes_h=no)])
AC_MSG_RESULT($gcc_cv_header_inttypes_h)
-AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen vprintf bcopy bzero bcmp \
+AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen bcopy bzero bcmp \
index rindex kill getrlimit setrlimit atoll atoq sysconf)
+GCC_FUNC_VFPRINTF_DOPRNT
GCC_FUNC_PRINTF_PTR
GCC_NEED_DECLARATIONS(malloc realloc calloc free bcopy bzero bcmp \
diff -rup orig/egcs-19980418/gcc/Makefile.in egcs-19980418/gcc/Makefile.in
--- orig/egcs-19980418/gcc/Makefile.in Fri Apr 17 13:31:30 1998
+++ egcs-19980418/gcc/Makefile.in Wed Apr 22 10:31:43 1998
@@ -265,6 +265,10 @@ CLIB=
# system library.
OBSTACK=obstack.o
+# Configure will set these if you need vfprintf and possibly _doprnt support.
+VFPRINTF=@vfprintf@
+DOPRINT=@doprint@
+
# Specify the rule for actually making libgcc.a,
LIBGCC = libgcc.a
# and the rule for installing it.
@@ -410,6 +414,8 @@ HOST_CPPFLAGS=$(ALL_CPPFLAGS)
HOST_ALLOCA=$(ALLOCA)
HOST_MALLOC=$(MALLOC)
HOST_OBSTACK=$(OBSTACK)
+HOST_VFPRINTF=$(VFPRINTF)
+HOST_DOPRINT=$(DOPRINT)
# Actual name to use when installing a native compiler.
GCC_INSTALL_NAME = `t='$(program_transform_name)'; echo gcc | sed -e $$t`
@@ -493,25 +499,27 @@ USE_ALLOCA= ${ALLOCA}
USE_HOST_ALLOCA= ` case "${HOST_ALLOCA}" in ?*) echo ${HOST_PREFIX}${HOST_ALLOCA} ;; esac `
USE_HOST_MALLOC= ` case "${HOST_MALLOC}" in ?*) echo ${HOST_PREFIX}${HOST_MALLOC} ;; esac `
USE_HOST_OBSTACK= ` case "${HOST_OBSTACK}" in ?*) echo ${HOST_PREFIX}${HOST_OBSTACK} ;; esac `
+USE_HOST_VFPRINTF= ` case "${HOST_VFPRINTF}" in ?*) echo ${HOST_PREFIX}${HOST_VFPRINTF} ;; esac `
+USE_HOST_DOPRINT= ` case "${HOST_DOPRINT}" in ?*) echo ${HOST_PREFIX}${HOST_DOPRINT} ;; esac `
# Dependency on obstack, alloca, malloc or whatever library facilities
# are not installed in the system libraries.
# We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
-LIBDEPS= $(OBSTACK) $(ALLOCA) $(MALLOC)
+LIBDEPS= $(OBSTACK) $(ALLOCA) $(MALLOC) $(VFPRINTF) $(DOPRINT)
# Likewise, for use in the tools that must run on this machine
# even if we are cross-building GCC.
# We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
-HOST_LIBDEPS= $(HOST_PREFIX)$(HOST_OBSTACK) $(HOST_PREFIX)$(HOST_ALLOCA) $(HOST_PREFIX)$(HOST_MALLOC)
+HOST_LIBDEPS= $(HOST_PREFIX)$(HOST_OBSTACK) $(HOST_PREFIX)$(HOST_ALLOCA) $(HOST_PREFIX)$(HOST_MALLOC) $(HOST_PREFIX)$(HOST_VFPRINTF) $(HOST_PREFIX)$(HOST_DOPRINT)
# How to link with both our special library facilities
# and the system's installed libraries.
-LIBS = $(OBSTACK) $(USE_ALLOCA) $(MALLOC) $(CLIB)
+LIBS = $(OBSTACK) $(USE_ALLOCA) $(MALLOC) $(VFPRINTF) $(DOPRINT) $(CLIB)
# Likewise, for use in the tools that must run on this machine
# even if we are cross-building GCC.
HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_ALLOCA) $(USE_HOST_MALLOC) \
- $(HOST_CLIB)
+ $(USE_HOST_VFPRINTF) $(USE_HOST_DOPRINT) $(HOST_CLIB)
HOST_RTL = $(HOST_PREFIX)rtl.o
HOST_RTLANAL = $(HOST_PREFIX)rtlanal.o
@@ -1726,6 +1734,16 @@ $(HOST_PREFIX_1)obstack.o: obstack.c
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/obstack.c > $(HOST_PREFIX)obstack.c
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c
+$(HOST_PREFIX_1)vfprintf.o: vfprintf.c
+ rm -f $(HOST_PREFIX)vfprintf.c
+ sed -e 's/config[.]h/hconfig.h/' $(srcdir)/vfprintf.c > $(HOST_PREFIX)vfprintf.c
+ $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)vfprintf.c
+
+$(HOST_PREFIX_1)doprint.o: doprint.c
+ rm -f $(HOST_PREFIX)doprint.c
+ sed -e 's/config[.]h/hconfig.h/' $(srcdir)/doprint.c > $(HOST_PREFIX)doprint.c
+ $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)doprint.c
+
$(HOST_PREFIX_1)malloc.o: malloc.c
rm -f $(HOST_PREFIX)malloc.c
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/malloc.c > $(HOST_PREFIX)malloc.c
@@ -1746,12 +1764,12 @@ cpp$(exeext): $(CCCP)$(exeext)
cccp$(exeext): cccp.o cexp.o version.o prefix.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ cccp.o cexp.o prefix.o \
version.o $(LIBS)
-cexp.o: $(srcdir)/cexp.c $(CONFIG_H) system.h
+cexp.o: $(srcdir)/cexp.c $(CONFIG_H) system.h gansidecl.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/cexp.c
$(srcdir)/cexp.c: $(srcdir)/cexp.y
cd $(srcdir); $(BISON) -o cexp.c cexp.y
-cccp.o: cccp.c $(CONFIG_H) pcp.h version.c config.status system.h
+cccp.o: cccp.c $(CONFIG_H) pcp.h version.c config.status system.h gansidecl.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
-DGPLUSPLUS_INCLUDE_DIR=\"$(gxx_include_dir)\" \
diff -rup orig/egcs-19980418/gcc/cccp.c egcs-19980418/gcc/cccp.c
--- orig/egcs-19980418/gcc/cccp.c Mon Apr 6 10:01:23 1998
+++ egcs-19980418/gcc/cccp.c Wed Apr 22 10:01:21 1998
@@ -19,26 +19,14 @@ Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
+#ifdef __STDC__
# include <stdarg.h>
-# define PRINTF_ALIST(msg) char *msg, ...
-# define PRINTF_DCL(msg)
-# define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n)))
#else
# include <varargs.h>
-# define PRINTF_ALIST(msg) msg, va_alist
-# define PRINTF_DCL(msg) char *msg; va_dcl
-# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))
-# define vfprintf(file, msg, args) \
- { \
- char *a0 = va_arg(args, char *); \
- char *a1 = va_arg(args, char *); \
- char *a2 = va_arg(args, char *); \
- char *a3 = va_arg(args, char *); \
- fprintf (file, msg, a0, a1, a2, a3); \
- }
#endif
+#define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n)
+
#define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
#define PRINTF_PROTO_2(ARGS) PRINTF_PROTO(ARGS, 2, 3)
#define PRINTF_PROTO_3(ARGS) PRINTF_PROTO(ARGS, 3, 4)
@@ -61,10 +49,6 @@ typedef unsigned char U_CHAR;
#define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ENV_VALUE = getenv (ENV_NAME)
#endif
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __attribute__(x)
-#endif
-
#ifndef STANDARD_INCLUDE_DIR
# define STANDARD_INCLUDE_DIR "/usr/include"
#endif
@@ -8852,12 +8836,19 @@ my_strerror (errnum)
/* error - print error message and increment count of errors. */
void
-error (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+error VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
verror (msg, args);
va_end (args);
}
@@ -8920,12 +8911,19 @@ error_from_errno (name)
/* Print error message but don't count it. */
void
-warning (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+warning VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
vwarning (msg, args);
va_end (args);
}
@@ -8963,17 +8961,21 @@ vwarning (msg, args)
}
static void
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
-error_with_line (int line, PRINTF_ALIST (msg))
-#else
-error_with_line (line, PRINTF_ALIST (msg))
- int line;
- PRINTF_DCL (msg)
-#endif
+error_with_line VPROTO ((int line, char * msg, ...))
{
+#ifndef __STDC__
+ int line;
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ line = va_arg (args, int);
+ msg = va_arg (args, char *);
+#endif
+
verror_with_line (line, msg, args);
va_end (args);
}
@@ -9006,17 +9008,21 @@ verror_with_line (line, msg, args)
}
static void
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
-warning_with_line (int line, PRINTF_ALIST (msg))
-#else
-warning_with_line (line, PRINTF_ALIST (msg))
- int line;
- PRINTF_DCL (msg)
-#endif
+warning_with_line VPROTO ((int line, char * msg, ...))
{
+#ifndef __STDC__
+ int line;
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ line = va_arg (args, int);
+ msg = va_arg (args, char *);
+#endif
+
vwarning_with_line (line, msg, args);
va_end (args);
}
@@ -9057,12 +9063,19 @@ vwarning_with_line (line, msg, args)
/* Print an error message and maybe count it. */
void
-pedwarn (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+pedwarn VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
if (pedantic_errors)
verror (msg, args);
else
@@ -9071,17 +9084,21 @@ pedwarn (PRINTF_ALIST (msg))
}
void
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
-pedwarn_with_line (int line, PRINTF_ALIST (msg))
-#else
-pedwarn_with_line (line, PRINTF_ALIST (msg))
- int line;
- PRINTF_DCL (msg)
-#endif
+pedwarn_with_line VPROTO ((int line, char * msg, ...))
{
+#ifndef __STDC__
+ int line;
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ line = va_arg (args, int);
+ msg = va_arg (args, char *);
+#endif
+
if (pedantic_errors)
verror_with_line (line, msg, args);
else
@@ -9093,17 +9110,15 @@ pedwarn_with_line (line, PRINTF_ALIST (m
giving specified file name and line number, not current. */
static void
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
-pedwarn_with_file_and_line (char *file, size_t file_len, int line,
- PRINTF_ALIST (msg))
-#else
-pedwarn_with_file_and_line (file, file_len, line, PRINTF_ALIST (msg))
- char *file;
- size_t file_len;
- int line;
- PRINTF_DCL (msg)
-#endif
+pedwarn_with_file_and_line VPROTO ((char *file, size_t file_len, int line,
+ char * msg, ...))
{
+#ifndef __STDC__
+ char *file;
+ size_t file_len;
+ int line;
+ char * msg;
+#endif
va_list args;
if (!pedantic_errors && inhibit_warnings)
@@ -9117,6 +9132,14 @@ pedwarn_with_file_and_line (file, file_l
if (!pedantic_errors)
fprintf (stderr, "warning: ");
VA_START (args, msg);
+
+#ifndef __STDC__
+ file = va_arg (args, char *);
+ file_len = va_arg (args, size_t);
+ line = va_arg (args, int);
+ msg = va_arg (args, char *);
+#endif
+
vfprintf (stderr, msg, args);
va_end (args);
fprintf (stderr, "\n");
@@ -10124,13 +10147,20 @@ deps_output (string, spacer)
}
static void
-fatal (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+fatal VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
fprintf (stderr, "%s: ", progname);
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
vfprintf (stderr, msg, args);
va_end (args);
fprintf (stderr, "\n");
diff -rup orig/egcs-19980418/gcc/cexp.y egcs-19980418/gcc/cexp.y
--- orig/egcs-19980418/gcc/cexp.y Mon Apr 6 10:01:24 1998
+++ egcs-19980418/gcc/cexp.y Wed Apr 22 10:05:27 1998
@@ -26,28 +26,14 @@ Boston, MA 02111-1307, USA.
%{
#include "config.h"
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
+#ifdef __STDC__
# include <stdarg.h>
-# define VA_START(va_list, var) va_start (va_list, var)
-# define PRINTF_ALIST(msg) char *msg, ...
-# define PRINTF_DCL(msg)
-# define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n)))
#else
# include <varargs.h>
-# define VA_START(va_list, var) va_start (va_list)
-# define PRINTF_ALIST(msg) msg, va_alist
-# define PRINTF_DCL(msg) char *msg; va_dcl
-# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))
-# define vfprintf(file, msg, args) \
- { \
- char *a0 = va_arg(args, char *); \
- char *a1 = va_arg(args, char *); \
- char *a2 = va_arg(args, char *); \
- char *a3 = va_arg(args, char *); \
- fprintf (file, msg, a0, a1, a2, a3); \
- }
#endif
+#define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n)
+
#define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
#include "system.h"
@@ -58,6 +44,8 @@ Boston, MA 02111-1307, USA.
#include <locale.h>
#endif
+#include "gansidecl.h"
+
typedef unsigned char U_CHAR;
/* This is used for communicating lists of keywords with cccp.c. */
@@ -68,24 +56,6 @@ struct arglist {
int argno;
};
-/* Define a generic NULL if one hasn't already been defined. */
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef GENERIC_PTR
-#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-#define GENERIC_PTR void *
-#else
-#define GENERIC_PTR char *
-#endif
-#endif
-
-#ifndef NULL_PTR
-#define NULL_PTR ((GENERIC_PTR) 0)
-#endif
-
/* Find the largest host integer type and set its size and type.
Watch out: on some crazy hosts `long' is shorter than `int'. */
@@ -119,18 +89,6 @@ struct arglist {
#define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
#endif
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __attribute__(x)
-#endif
-
-#ifndef PROTO
-# if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-# define PROTO(ARGS) ARGS
-# else
-# define PROTO(ARGS) ()
-# endif
-#endif
-
HOST_WIDE_INT parse_c_expression PROTO((char *, int));
static int yylex PROTO((void));
@@ -1179,12 +1137,19 @@ initialize_random_junk ()
}
void
-error (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+error VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
fprintf (stderr, "error: ");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
@@ -1192,12 +1157,19 @@ error (PRINTF_ALIST (msg))
}
void
-pedwarn (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+pedwarn VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
fprintf (stderr, "pedwarn: ");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
@@ -1205,12 +1177,19 @@ pedwarn (PRINTF_ALIST (msg))
}
void
-warning (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+warning VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
fprintf (stderr, "warning: ");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
diff -rup orig/egcs-19980418/gcc/cexp.c egcs-19980418/gcc/cexp.c
--- orig/egcs-19980418/gcc/cexp.c Sun Apr 19 03:10:01 1998
+++ egcs-19980418/gcc/cexp.c Wed Apr 22 10:08:03 1998
@@ -22,28 +22,14 @@
#line 27 "cexp.y"
#include "config.h"
-#if defined (__STDC__) && defined (HAVE_VPRINTF)
+#ifdef __STDC__
# include <stdarg.h>
-# define VA_START(va_list, var) va_start (va_list, var)
-# define PRINTF_ALIST(msg) char *msg, ...
-# define PRINTF_DCL(msg)
-# define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n)))
#else
# include <varargs.h>
-# define VA_START(va_list, var) va_start (va_list)
-# define PRINTF_ALIST(msg) msg, va_alist
-# define PRINTF_DCL(msg) char *msg; va_dcl
-# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))
-# define vfprintf(file, msg, args) \
- { \
- char *a0 = va_arg(args, char *); \
- char *a1 = va_arg(args, char *); \
- char *a2 = va_arg(args, char *); \
- char *a3 = va_arg(args, char *); \
- fprintf (file, msg, a0, a1, a2, a3); \
- }
#endif
+#define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n)
+
#define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
#include "system.h"
@@ -54,6 +40,8 @@
#include <locale.h>
#endif
+#include "gansidecl.h"
+
typedef unsigned char U_CHAR;
/* This is used for communicating lists of keywords with cccp.c. */
@@ -64,24 +52,6 @@ struct arglist {
int argno;
};
-/* Define a generic NULL if one hasn't already been defined. */
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef GENERIC_PTR
-#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-#define GENERIC_PTR void *
-#else
-#define GENERIC_PTR char *
-#endif
-#endif
-
-#ifndef NULL_PTR
-#define NULL_PTR ((GENERIC_PTR) 0)
-#endif
-
/* Find the largest host integer type and set its size and type.
Watch out: on some crazy hosts `long' is shorter than `int'. */
@@ -115,18 +85,6 @@ struct arglist {
#define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
#endif
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __attribute__(x)
-#endif
-
-#ifndef PROTO
-# if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-# define PROTO(ARGS) ARGS
-# else
-# define PROTO(ARGS) ()
-# endif
-#endif
-
HOST_WIDE_INT parse_c_expression PROTO((char *, int));
static int yylex PROTO((void));
@@ -2095,12 +2053,19 @@ initialize_random_junk ()
}
void
-error (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+error VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
fprintf (stderr, "error: ");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
@@ -2108,12 +2073,19 @@ error (PRINTF_ALIST (msg))
}
void
-pedwarn (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+pedwarn VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
fprintf (stderr, "pedwarn: ");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
@@ -2121,12 +2093,19 @@ pedwarn (PRINTF_ALIST (msg))
}
void
-warning (PRINTF_ALIST (msg))
- PRINTF_DCL (msg)
+warning VPROTO ((char * msg, ...))
{
+#ifndef __STDC__
+ char * msg;
+#endif
va_list args;
VA_START (args, msg);
+
+#ifndef __STDC__
+ msg = va_arg (args, char *);
+#endif
+
fprintf (stderr, "warning: ");
vfprintf (stderr, msg, args);
fprintf (stderr, "\n");
diff -rup orig/egcs-19980418/gcc/gcc.c egcs-19980418/gcc/gcc.c
--- orig/egcs-19980418/gcc/gcc.c Sat Apr 18 11:31:36 1998
+++ egcs-19980418/gcc/gcc.c Sun Apr 19 22:51:23 1998
@@ -251,14 +251,8 @@ static void print_multilib_info PROTO((v
static void pfatal_with_name PROTO((char *));
static void perror_with_name PROTO((char *));
static void pfatal_pexecute PROTO((char *, char *));
-#ifdef HAVE_VPRINTF
static void fatal PVPROTO((char *, ...));
static void error PVPROTO((char *, ...));
-#else
-/* We must not provide any prototype here, even if ANSI C. */
-static void fatal PROTO(());
-static void error PROTO(());
-#endif
void fancy_abort ();
char *xmalloc ();
@@ -5050,8 +5044,6 @@ fancy_abort ()
fatal ("Internal gcc abort.");
}
-#ifdef HAVE_VPRINTF
-
/* Output an error message and exit */
static void
@@ -5096,29 +5088,6 @@ error VPROTO((char *format, ...))
fprintf (stderr, "\n");
}
-
-#else /* not HAVE_VPRINTF */
-
-static void
-fatal (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- error (msg, arg1, arg2);
- delete_temp_files ();
- exit (1);
-}
-
-static void
-error (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- fprintf (stderr, "%s: ", programname);
- fprintf (stderr, msg, arg1, arg2);
- fprintf (stderr, "\n");
-}
-
-#endif /* not HAVE_VPRINTF */
-
static void
validate_all_switches ()
diff -rup orig/egcs-19980418/gcc/genattrtab.c egcs-19980418/gcc/genattrtab.c
--- orig/egcs-19980418/gcc/genattrtab.c Thu Apr 16 19:56:06 1998
+++ egcs-19980418/gcc/genattrtab.c Sun Apr 19 22:52:15 1998
@@ -366,12 +366,7 @@ rtx pic_offset_table_rtx;
static void attr_hash_add_rtx PROTO((int, rtx));
static void attr_hash_add_string PROTO((int, char *));
static rtx attr_rtx PVPROTO((enum rtx_code, ...));
-#ifdef HAVE_VPRINTF
static char *attr_printf PVPROTO((int, char *, ...));
-#else
-static char *attr_printf ();
-#endif
-
static char *attr_string PROTO((char *, int));
static rtx check_attr_test PROTO((rtx, int));
static rtx check_attr_value PROTO((rtx, struct attr_desc *));
@@ -736,8 +731,6 @@ attr_rtx VPROTO((enum rtx_code code, ...
rtx attr_printf (len, format, [arg1, ..., argn]) */
-#ifdef HAVE_VPRINTF
-
/*VARARGS2*/
static char *
attr_printf VPROTO((register int len, char *fmt, ...))
@@ -763,24 +756,6 @@ attr_printf VPROTO((register int len, ch
return attr_string (str, strlen (str));
}
-
-#else /* not HAVE_VPRINTF */
-
-static char *
-attr_printf (len, fmt, arg1, arg2, arg3)
- int len;
- char *fmt;
- char *arg1, *arg2, *arg3; /* also int */
-{
- register char *str;
-
- /* Print the string into a temporary location. */
- str = (char *) alloca (len);
- sprintf (str, fmt, arg1, arg2, arg3);
-
- return attr_string (str, strlen (str));
-}
-#endif /* not HAVE_VPRINTF */
rtx
attr_eq (name, value)
diff -rup orig/egcs-19980418/gcc/mips-tfile.c egcs-19980418/gcc/mips-tfile.c
--- orig/egcs-19980418/gcc/mips-tfile.c Sat Apr 4 12:38:18 1998
+++ egcs-19980418/gcc/mips-tfile.c Sun Apr 19 22:54:04 1998
@@ -671,15 +671,8 @@ extern PTR_T xcalloc __proto((Size_t, S
extern PTR_T xrealloc __proto((PTR_T, Size_t));
extern void xfree __proto((PTR_T));
-#ifdef HAVE_VPRINTF
extern void fatal PVPROTO((const char *format, ...));
extern void error PVPROTO((const char *format, ...));
-#else
-/* We must not provide any prototype here, even if ANSI C. */
-extern void fatal __proto(());
-extern void error __proto(());
-#endif
-
#ifndef MIPS_DEBUGGING_INFO
@@ -5600,8 +5593,6 @@ free_thead (ptr)
#endif /* MIPS_DEBUGGING_INFO */
-#ifdef HAVE_VPRINTF
-
/* Output an error message and exit */
/*VARARGS*/
@@ -5664,27 +5655,6 @@ error VPROTO((const char *format, ...))
saber_stop ();
}
-
-#else /* not HAVE_VPRINTF */
-
-void
-fatal (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- error (msg, arg1, arg2);
- exit (1);
-}
-
-void
-error (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- fprintf (stderr, "%s: ", progname);
- fprintf (stderr, msg, arg1, arg2);
- fprintf (stderr, "\n");
-}
-
-#endif /* not HAVE_VPRINTF */
/* More 'friendly' abort that prints the line and file.
config.h can #define abort fancy_abort if you like that sort of thing. */
diff -rup orig/egcs-19980418/gcc/toplev.c egcs-19980418/gcc/toplev.c
--- orig/egcs-19980418/gcc/toplev.c Thu Apr 16 20:40:33 1998
+++ egcs-19980418/gcc/toplev.c Sun Apr 19 22:52:47 1998
@@ -1269,17 +1269,7 @@ vmessage (prefix, s, ap)
if (prefix)
fprintf (stderr, "%s: ", prefix);
-#ifdef HAVE_VPRINTF
vfprintf (stderr, s, ap);
-#else
- {
- HOST_WIDE_INT v1 = va_arg(ap, HOST_WIDE_INT);
- HOST_WIDE_INT v2 = va_arg(ap, HOST_WIDE_INT);
- HOST_WIDE_INT v3 = va_arg(ap, HOST_WIDE_INT);
- HOST_WIDE_INT v4 = va_arg(ap, HOST_WIDE_INT);
- fprintf (stderr, s, v1, v2, v3, v4);
- }
-#endif
}
/* Print a message relevant to line LINE of file FILE. */
diff -rupN orig/egcs-19980418/gcc/vfprintf.c egcs-19980418/gcc/vfprintf.c
--- orig/egcs-19980418/gcc/vfprintf.c Wed Dec 31 19:00:00 1969
+++ egcs-19980418/gcc/vfprintf.c Sun Apr 19 22:34:26 1998
@@ -0,0 +1,21 @@
+/* Provide a version vfprintf in terms of _doprnt.
+ By Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ */
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <stdio.h>
+#undef vfprintf
+
+int
+vfprintf (stream, format, ap)
+ FILE * stream;
+ const char * format;
+ va_list ap;
+{
+ return _doprnt (format, ap, stream);
+}
diff -rupN orig/egcs-19980418/gcc/doprint.c egcs-19980418/gcc/doprint.c
*** orig/egcs-19980418/gcc/doprint.c Wed Dec 31 19:00:00 1969
--- egcs-19980418/gcc/doprint.c Wed Apr 22 16:23:43 1998
***************
*** 0 ****
--- 1,286 ----
+ /* Provide a version _doprnt in terms of fprintf.
+ By Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ */
+
+ #include "config.h"
+ #ifdef __STDC__
+ #include <stdarg.h>
+ #else
+ #include <varargs.h>
+ #endif
+ #include "system.h"
+ #include "gansidecl.h"
+ #undef _doprnt
+
+ #ifdef TEST /* Make sure to use the internal one. */
+ #define _doprnt my_doprnt
+ #endif
+
+ #define COPY_VA_INT \
+ do { \
+ const int value = abs (va_arg (ap, int)); \
+ char buf[32]; \
+ ptr++; /* Go past the asterisk. */ \
+ *sptr = '\0'; /* NULL terminate sptr. */ \
+ sprintf(buf, "%d", value); \
+ strcat(sptr, buf); \
+ while (*sptr) sptr++; \
+ } while (0)
+
+ #define PRINT_CHAR(CHAR) \
+ do { \
+ putc(CHAR, stream); \
+ ptr++; \
+ total_printed++; \
+ continue; \
+ } while (0)
+
+ #define PRINT_TYPE(TYPE) \
+ do { \
+ int result; \
+ TYPE value = va_arg (ap, TYPE); \
+ *sptr++ = *ptr++; /* Copy the type specifier. */ \
+ *sptr = '\0'; /* NULL terminate sptr. */ \
+ result = fprintf(stream, specifier, value); \
+ if (result == -1) \
+ return -1; \
+ else \
+ { \
+ total_printed += result; \
+ continue; \
+ } \
+ } while (0)
+
+ int
+ _doprnt (format, ap, stream)
+ const char * format;
+ va_list ap;
+ FILE * stream;
+ {
+ const char * ptr = format;
+ char specifier[128];
+ int total_printed = 0;
+
+ while (*ptr != '\0')
+ {
+ if (*ptr != '%') /* While we have regular characters, print them. */
+ PRINT_CHAR(*ptr);
+ else /* We got a format specifier! */
+ {
+ char * sptr = specifier;
+ int wide_width = 0, short_width = 0;
+
+ *sptr++ = *ptr++; /* Copy the % and move forward. */
+
+ while (strchr ("-+ #0", *ptr)) /* Move past flags. */
+ *sptr++ = *ptr++;
+
+ if (*ptr == '*')
+ COPY_VA_INT;
+ else
+ while (isdigit(*ptr)) /* Handle explicit numeric value. */
+ *sptr++ = *ptr++;
+
+ if (*ptr == '.')
+ {
+ *sptr++ = *ptr++; /* Copy and go past the period. */
+ if (*ptr == '*')
+ COPY_VA_INT;
+ else
+ while (isdigit(*ptr)) /* Handle explicit numeric value. */
+ *sptr++ = *ptr++;
+ }
+ while (strchr ("hlL", *ptr))
+ {
+ switch (*ptr)
+ {
+ case 'h':
+ short_width = 1;
+ break;
+ case 'l':
+ wide_width++;
+ break;
+ case 'L':
+ wide_width = 2;
+ break;
+ default:
+ abort();
+ }
+ *sptr++ = *ptr++;
+ }
+
+ switch (*ptr)
+ {
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ case 'c':
+ {
+ /* Short values are promoted to int, so just copy it
+ as an int and trust the C library printf to cast it
+ to the right width. */
+ if (short_width)
+ PRINT_TYPE(int);
+ else
+ {
+ switch (wide_width)
+ {
+ case 0:
+ PRINT_TYPE(int);
+ break;
+ case 1:
+ PRINT_TYPE(long);
+ break;
+ case 2:
+ default:
+ #if defined(__GNUC__) || defined(HAVE_LONG_LONG)
+ PRINT_TYPE(long long);
+ #else
+ PRINT_TYPE(long); /* Fake it and hope for the best. */
+ #endif
+ break;
+ } /* End of switch (wide_width) */
+ } /* End of else statement */
+ } /* End of integer case */
+ break;
+ case 'f':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ {
+ if (wide_width == 0)
+ PRINT_TYPE(double);
+ else
+ {
+ #if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
+ PRINT_TYPE(long double);
+ #else
+ PRINT_TYPE(double); /* Fake it and hope for the best. */
+ #endif
+ }
+ }
+ break;
+ case 's':
+ PRINT_TYPE(char *);
+ break;
+ case 'p':
+ PRINT_TYPE(void *);
+ break;
+ case '%':
+ PRINT_CHAR('%');
+ break;
+ default:
+ abort();
+ } /* End of switch (*ptr) */
+ } /* End of else statement */
+ }
+
+ return total_printed;
+ }
+
+ #ifdef TEST
+
+ #include <math.h>
+ #ifndef M_PI
+ #define M_PI (3.1415926535897932385)
+ #endif
+
+ #define RESULT(x) do \
+ { \
+ int i = (x); \
+ printf ("printed %d characters\n", i); \
+ fflush(stdin); \
+ } while (0)
+
+ static int checkit PVPROTO ((const char * format, ...)) ATTRIBUTE_PRINTF_1;
+
+ static int
+ checkit VPROTO ((const char* format, ...))
+ {
+ va_list args;
+ int result;
+
+ #ifndef __STDC__
+ char *format;
+ #endif
+
+ VA_START (args, format);
+
+ #ifndef __STDC__
+ format = va_arg (args, char *);
+ #endif
+
+ result = _doprnt (format, args, stdout);
+ va_end(args);
+
+ return result;
+ }
+
+ int
+ main ()
+ {
+ RESULT(checkit ("<%d>\n", 0x12345678));
+ RESULT(printf ("<%d>\n", 0x12345678));
+
+ RESULT(checkit ("<%200d>\n", 5));
+ RESULT(printf ("<%200d>\n", 5));
+
+ RESULT(checkit ("<%.300d>\n", 6));
+ RESULT(printf ("<%.300d>\n", 6));
+
+ RESULT(checkit ("<%100.150d>\n", 7));
+ RESULT(printf ("<%100.150d>\n", 7));
+
+ RESULT(checkit ("<%s>\n",
+ "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+ 777777777777777777333333333333366666666666622222222222777777777777733333"));
+ RESULT(printf ("<%s>\n",
+ "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+ 777777777777777777333333333333366666666666622222222222777777777777733333"));
+
+ RESULT(checkit ("<%f><%0+#f>%s%d%s>\n",
+ 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
+ RESULT(printf ("<%f><%0+#f>%s%d%s>\n",
+ 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
+
+ RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
+ RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
+
+ RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
+ RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
+
+ RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+ RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+
+ RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+ RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+
+ RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
+ RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
+
+ #if defined(__GNUC__) || defined (HAVE_LONG_LONG)
+ RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
+ RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
+ RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
+ RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
+ #endif
+
+ #if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE)
+ RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
+ 1.23456, 1.234567890123456789L, 1.23456));
+ RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
+ 1.23456, 1.234567890123456789L, 1.23456));
+ #endif
+
+ return 0;
+ }
+ #endif /* TEST */