Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47ea714

Browse files
committed
Fix snprintf on Win32:
* If vsnprintf() is not before snprintf() in this file, snprintf() * will call the system vsnprintf() on MinGW.
1 parent9989e90 commit47ea714

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

‎src/port/snprintf.c

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,27 @@
6666
* causing nasty effects.
6767
**************************************************************/
6868

69-
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.10 2005/03/0200:02:13 momjian Exp $";*/
69+
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.11 2005/03/0203:21:52 momjian Exp $";*/
7070

7171
intsnprintf(char*str,size_tcount,constchar*fmt,...);
7272
intvsnprintf(char*str,size_tcount,constchar*fmt,va_listargs);
7373
intprintf(constchar*format, ...);
7474
staticvoiddopr(char*buffer,constchar*format,va_listargs,char*end);
7575

76+
/*
77+
*If vsnprintf() is not before snprintf() in this file, snprintf()
78+
*will call the system vsnprintf() on MinGW.
79+
*/
7680
int
77-
printf(constchar*fmt,...)
81+
vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs)
7882
{
79-
intlen;
80-
va_listargs;
81-
char*buffer[4096];
82-
char*p;
83-
84-
va_start(args,fmt);
85-
len=vsnprintf((char*)buffer, (size_t)4096,fmt,args);
86-
va_end(args);
87-
p= (char*)buffer;
88-
for(;*p;p++)
89-
putchar(*p);
90-
returnlen;
83+
char*end;
84+
str[0]='\0';
85+
end=str+count-1;
86+
dopr(str,fmt,args,end);
87+
if (count>0)
88+
end[0]='\0';
89+
returnstrlen(str);
9190
}
9291

9392
int
@@ -102,17 +101,21 @@ snprintf(char *str, size_t count, const char *fmt,...)
102101
returnlen;
103102
}
104103

105-
106104
int
107-
vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs)
105+
printf(constchar*fmt,...)
108106
{
109-
char*end;
110-
str[0]='\0';
111-
end=str+count-1;
112-
dopr(str,fmt,args,end);
113-
if (count>0)
114-
end[0]='\0';
115-
returnstrlen(str);
107+
intlen;
108+
va_listargs;
109+
char*buffer[4096];
110+
char*p;
111+
112+
va_start(args,fmt);
113+
len=vsnprintf((char*)buffer, (size_t)4096,fmt,args);
114+
va_end(args);
115+
p= (char*)buffer;
116+
for(;*p;p++)
117+
putchar(*p);
118+
returnlen;
116119
}
117120

118121
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp