mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
Fix snprintf on Win32:
* If vsnprintf() is not before snprintf() in this file, snprintf() * will call the system vsnprintf() on MinGW.
This commit is contained in:
parent
9989e90490
commit
47ea7148e3
@ -66,13 +66,41 @@
|
|||||||
* causing nasty effects.
|
* causing nasty effects.
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.10 2005/03/02 00:02:13 momjian Exp $";*/
|
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.11 2005/03/02 03:21:52 momjian Exp $";*/
|
||||||
|
|
||||||
int snprintf(char *str, size_t count, const char *fmt,...);
|
int snprintf(char *str, size_t count, const char *fmt,...);
|
||||||
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
||||||
int printf(const char *format, ...);
|
int 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);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If vsnprintf() is not before snprintf() in this file, snprintf()
|
||||||
|
* will call the system vsnprintf() on MinGW.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
|
char *end;
|
||||||
|
str[0] = '\0';
|
||||||
|
end = str + count - 1;
|
||||||
|
dopr(str, fmt, args, end);
|
||||||
|
if (count > 0)
|
||||||
|
end[0] = '\0';
|
||||||
|
return strlen(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
snprintf(char *str, size_t count, const char *fmt,...)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
len = vsnprintf(str, count, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
printf(const char *fmt,...)
|
printf(const char *fmt,...)
|
||||||
{
|
{
|
||||||
@ -90,31 +118,6 @@ printf(const char *fmt,...)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
snprintf(char *str, size_t count, const char *fmt,...)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
|
||||||
len = vsnprintf(str, count, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
|
|
||||||
{
|
|
||||||
char *end;
|
|
||||||
str[0] = '\0';
|
|
||||||
end = str + count - 1;
|
|
||||||
dopr(str, fmt, args, end);
|
|
||||||
if (count > 0)
|
|
||||||
end[0] = '\0';
|
|
||||||
return strlen(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dopr(): poor man's version of doprintf
|
* dopr(): poor man's version of doprintf
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user