Commit 47ea7148 authored by Bruce Momjian's avatar Bruce Momjian

Fix snprintf on Win32:

 *  If vsnprintf() is not before snprintf() in this file, snprintf()
 *  will call the system vsnprintf() on MinGW.
parent 9989e904
......@@ -66,28 +66,27 @@
* 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 vsnprintf(char *str, size_t count, const char *fmt, va_list args);
int printf(const char *format, ...);
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
printf(const char *fmt,...)
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
int len;
va_list args;
char* buffer[4096];
char* p;
va_start(args, fmt);
len = vsnprintf((char*)buffer, (size_t)4096, fmt, args);
va_end(args);
p = (char*)buffer;
for(;*p;p++)
putchar(*p);
return len;
char *end;
str[0] = '\0';
end = str + count - 1;
dopr(str, fmt, args, end);
if (count > 0)
end[0] = '\0';
return strlen(str);
}
int
......@@ -102,17 +101,21 @@ snprintf(char *str, size_t count, const char *fmt,...)
return len;
}
int
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
printf(const char *fmt,...)
{
char *end;
str[0] = '\0';
end = str + count - 1;
dopr(str, fmt, args, end);
if (count > 0)
end[0] = '\0';
return strlen(str);
int len;
va_list args;
char* buffer[4096];
char* p;
va_start(args, fmt);
len = vsnprintf((char*)buffer, (size_t)4096, fmt, args);
va_end(args);
p = (char*)buffer;
for(;*p;p++)
putchar(*p);
return len;
}
/*
......
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