From 7fab608205e7a29b2a9bcd344e409edbb4cea6e3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 17 Jan 1999 03:22:52 +0000 Subject: Add configure test to see whether vsnprintf() is present, separately from snprintf() --- HPUX, for one, has snprintf but not vsnprintf. Fix a minor typo in snprintf.c, too. --- src/include/c.h | 21 +++++++++++++++++++-- src/include/config.h.in | 3 +++ src/include/port/hpux.h | 8 ++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/c.h b/src/include/c.h index cd7ecb9de2..0432d81940 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.47 1998/12/13 03:44:38 momjian Exp $ + * $Id: c.h,v 1.48 1999/01/17 03:22:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -45,9 +45,13 @@ /* We have to include stdlib.h here because it defines many of these macros on some platforms, and we only want our definitions used if stdlib.h doesn't - have its own. + have its own. The same goes for stddef and stdarg if present. */ #include +#ifdef STDC_HEADERS +#include +#include +#endif /* ---------------------------------------------------------------- * Section 1: bool, true, false, TRUE, FALSE @@ -820,6 +824,19 @@ extern char *form(const char *fmt,...); #define COPY_CMD "cp" #define SEP_CHAR '/' +/* Provide prototypes for routines not present in a particular machine's + * standard C library. It'd be better to put these in config.h, but + * in config.h we haven't yet included anything that defines size_t... + */ + +#ifndef HAVE_SNPRINTF +extern int snprintf(char *str, size_t count, const char *fmt, ...); +#endif + +#ifndef HAVE_VSNPRINTF +extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args); +#endif + /* ---------------- * end of c.h * ---------------- diff --git a/src/include/config.h.in b/src/include/config.h.in index 3a54c89c1f..3ab45d0a73 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -118,6 +118,9 @@ /* Set to 1 if you have snprintf() */ #undef HAVE_SNPRINTF +/* Set to 1 if you have vsnprintf() */ +#undef HAVE_VSNPRINTF + /* Set to 1 if you have fp_class() */ #undef HAVE_FP_CLASS diff --git a/src/include/port/hpux.h b/src/include/port/hpux.h index 4ef01af095..0c42e6c4b7 100644 --- a/src/include/port/hpux.h +++ b/src/include/port/hpux.h @@ -6,6 +6,14 @@ typedef struct int sema[4]; } slock_t; +/* HPUX 9 has snprintf in the library, so configure will set HAVE_SNPRINTF; + * but it doesn't provide a prototype for it. To suppress warning messages + * from gcc, do this to make c.h provide the prototype: + */ +#ifndef HAVE_VSNPRINTF +#undef HAVE_SNPRINTF +#endif + #ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 #endif -- cgit v1.2.1