Commit caad817d authored by Bruce Momjian's avatar Bruce Momjian

Add fprintf() custom version to libpgport.

Document use of macros for pg_printf functions.

Bump major versions of all interfaces to handle movement of get_progname
from libpq to libpgport in 8.0, and probably other libpgport changes in 8.1.
parent 3bc6bdf3
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.38 2004/12/31 21:59:34 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.39 2005/03/11 19:13:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.120 2005/02/22 04:36:22 momjian Exp $ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.121 2005/03/11 19:13:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
extern YYSTYPE yylval; extern YYSTYPE yylval;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.29 2005/01/01 05:43:08 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.30 2005/03/11 19:13:42 momjian Exp $
*/ */
%{ %{
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "utils/guc.h" #include "utils/guc.h"
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
static unsigned ConfigFileLineno; static unsigned ConfigFileLineno;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.71 2005/03/11 17:20:34 momjian Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.72 2005/03/11 19:13:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -112,17 +112,27 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args); ...@@ -112,17 +112,27 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
extern int pg_snprintf(char *str, size_t count, const char *fmt,...) extern int pg_snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(printf, 3, 4))); __attribute__((format(printf, 3, 4)));
extern int pg_fprintf(FILE *stream, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
extern int pg_printf(const char *fmt,...) extern int pg_printf(const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(printf, 1, 2))); __attribute__((format(printf, 1, 2)));
/*
* The GCC-specific code below prevents the __attribute__(... 'printf')
* above from being replaced, and this is required because gcc doesn't
* know anything about pg_printf.
*/
#ifdef __GNUC__ #ifdef __GNUC__
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
#define snprintf(...) pg_snprintf(__VA_ARGS__) #define snprintf(...) pg_snprintf(__VA_ARGS__)
#define fprintf(...) pg_fprintf(__VA_ARGS__)
#define printf(...) pg_printf(__VA_ARGS__) #define printf(...) pg_printf(__VA_ARGS__)
#else #else
#define vsnprintf pg_vsnprintf #define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf #define snprintf pg_snprintf
#define fprintf pg_fprintf
#define printf pg_printf #define printf pg_printf
#endif #endif
#endif #endif
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.19 2005/01/18 05:00:15 momjian Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.20 2005/03/11 19:13:42 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -13,8 +13,8 @@ top_builddir = ../../../.. ...@@ -13,8 +13,8 @@ top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
NAME= ecpg_compat NAME= ecpg_compat
SO_MAJOR_VERSION= 1 SO_MAJOR_VERSION= 2
SO_MINOR_VERSION= 2 SO_MINOR_VERSION= 0
DLTYPE= library DLTYPE= library
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) \ override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) \
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.31 2005/01/26 19:24:01 tgl Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.32 2005/03/11 19:13:42 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -13,8 +13,8 @@ top_builddir = ../../../.. ...@@ -13,8 +13,8 @@ top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
NAME= ecpg NAME= ecpg
SO_MAJOR_VERSION= 4 SO_MAJOR_VERSION= 5
SO_MINOR_VERSION= 3 SO_MINOR_VERSION= 0
DLTYPE= library DLTYPE= library
override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \ override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.24 2005/01/18 05:00:23 momjian Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.25 2005/03/11 19:13:43 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -13,8 +13,8 @@ top_builddir = ../../../.. ...@@ -13,8 +13,8 @@ top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
NAME= pgtypes NAME= pgtypes
SO_MAJOR_VERSION= 1 SO_MAJOR_VERSION= 2
SO_MINOR_VERSION= 3 SO_MINOR_VERSION= 0
DLTYPE= library DLTYPE= library
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \ override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1998-2005, PostgreSQL Global Development Group # Copyright (c) 1998-2005, PostgreSQL Global Development Group
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.112 2005/01/25 12:51:31 meskes Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.113 2005/03/11 19:13:43 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -13,8 +13,8 @@ subdir = src/interfaces/ecpg/preproc ...@@ -13,8 +13,8 @@ subdir = src/interfaces/ecpg/preproc
top_builddir = ../../../.. top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
MAJOR_VERSION=3 MAJOR_VERSION= 4
MINOR_VERSION=2 MINOR_VERSION= 0
PATCHLEVEL=1 PATCHLEVEL=1
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \ override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.128 2005/01/26 19:24:02 tgl Exp $ # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.129 2005/03/11 19:13:43 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -16,8 +16,8 @@ include $(top_builddir)/src/Makefile.global ...@@ -16,8 +16,8 @@ include $(top_builddir)/src/Makefile.global
# shared library parameters # shared library parameters
NAME= pq NAME= pq
SO_MAJOR_VERSION= 3 SO_MAJOR_VERSION= 4
SO_MINOR_VERSION= 3 SO_MINOR_VERSION= 0
DLTYPE= library DLTYPE= library
override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.39 2005/02/22 07:18:24 neilc Exp $ * $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.40 2005/03/11 19:13:43 momjian Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#define YY_READ_BUF_SIZE 16777216 #define YY_READ_BUF_SIZE 16777216
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
/* Handles to the buffer that the lexer uses internally */ /* Handles to the buffer that the lexer uses internally */
......
...@@ -65,13 +65,19 @@ ...@@ -65,13 +65,19 @@
* causing nasty effects. * causing nasty effects.
**************************************************************/ **************************************************************/
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.17 2005/03/11 17:20:35 momjian Exp $";*/ /*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.18 2005/03/11 19:13:43 momjian Exp $";*/
int pg_snprintf(char *str, size_t count, const char *fmt,...); int pg_snprintf(char *str, size_t count, const char *fmt,...);
int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args); int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
int pg_printf(const char *format, ...); int pg_printf(const char *format, ...);
static void dopr(char *buffer, const char *format, va_list args, char *end); static void dopr(char *buffer, const char *format, va_list args, char *end);
/* Prevent recursion */
#undef vsnprintf
#undef snprintf
#undef fprintf
#undef printf
int int
pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args) pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{ {
...@@ -96,6 +102,23 @@ pg_snprintf(char *str, size_t count, const char *fmt,...) ...@@ -96,6 +102,23 @@ pg_snprintf(char *str, size_t count, const char *fmt,...)
return len; return len;
} }
int
pg_fprintf(FILE *stream, const char *fmt,...)
{
int len;
va_list args;
char* buffer[4096];
char* p;
va_start(args, fmt);
len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
va_end(args);
p = (char*)buffer;
for( ;*p; p++)
putc(*p, stream);
return len;
}
int int
pg_printf(const char *fmt,...) pg_printf(const char *fmt,...)
{ {
...@@ -108,7 +131,7 @@ pg_printf(const char *fmt,...) ...@@ -108,7 +131,7 @@ pg_printf(const char *fmt,...)
len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args); len = pg_vsnprintf((char*)buffer, (size_t)4096, fmt, args);
va_end(args); va_end(args);
p = (char*)buffer; p = (char*)buffer;
for(;*p;p++) for( ;*p; p++)
putchar(*p); putchar(*p);
return len; return len;
} }
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
* Version numbers * Version numbers
o configure.in, and run autoconf or update configure o configure.in, and run autoconf or update configure
o doc/bug.template o doc/bug.template
o bump interface version numbers o bump library versions
- src/interfaces/*/Makefile (major releases only) - src/interfaces/*/Makefile (major releases only)
- src/interfaces/*/*/Makefile (major releases only) - src/interfaces/*/*/Makefile (major releases only)
o bump interface version numbers
- src/interfaces/libpq/libpq.rc.in (major and minor releases) - src/interfaces/libpq/libpq.rc.in (major and minor releases)
- src/include/pg_config.h.win32 (major and minor releases) - src/include/pg_config.h.win32 (major and minor releases)
- src/port/win32ver.rc (major and minor releases) - src/port/win32ver.rc (major and minor releases)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment