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

Commit9d6f060

Browse files
committed
Fix for HAVE_LONG bug in snprintf.c.
1 parent6b7cf13 commit9d6f060

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

‎src/backend/port/snprintf.c

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
#include"regex/cdefs.h"
4242

4343
#include<stdarg.h>
44-
#defineVA_LOCAL_DECL va_list args;
45-
#defineVA_START(f) va_start(args, f)
46-
#defineVA_END va_end(args)
4744

4845
#include<sys/ioctl.h>
4946
#include<sys/param.h>
@@ -75,34 +72,30 @@ typedef long long long_long;
7572
* causing nast effects.
7673
**************************************************************/
7774

78-
/*static char _id[] = "$Id: snprintf.c,v 1.12 1998/12/1806:59:39 momjian Exp $";*/
75+
/*static char _id[] = "$Id: snprintf.c,v 1.13 1998/12/1807:03:06 momjian Exp $";*/
7976
staticchar*end;
8077
staticintSnprfOverflow;
8178

8279
intsnprintf(char*str,size_tcount,constchar*fmt,...);
83-
intvsnprintf(char*str,size_tcount,constchar*fmt,...);
84-
staticvoiddopr(char*buffer,constchar*format,...);
80+
intvsnprintf(char*str,size_tcount,constchar*fmt,va_listargs);
81+
staticvoiddopr(char*buffer,constchar*format,va_listargs);
8582

8683
int
8784
snprintf(char*str,size_tcount,constchar*fmt,...)
8885
{
8986
intlen;
87+
va_listargs;
9088

91-
VA_LOCAL_DECL
92-
93-
VA_START(fmt);
89+
va_start(args,fmt);
9490
len=vsnprintf(str,count,fmt,args);
95-
VA_END;
91+
va_end(args);
9692
returnlen;
9793
}
9894

9995

10096
int
101-
vsnprintf(char*str,size_tcount,constchar*fmt,...)
97+
vsnprintf(char*str,size_tcount,constchar*fmt,va_listargs)
10298
{
103-
VA_LOCAL_DECL
104-
105-
VA_START(fmt);
10699
str[0]=0;
107100
end=str+count-1;
108101
SnprfOverflow=0;
@@ -112,7 +105,6 @@ vsnprintf(char *str, size_t count, const char *fmt,...)
112105
if (SnprfOverflow)
113106
elog(NOTICE,"vsnprintf overflow, len = %d, str = %s",
114107
count,str);
115-
VA_END;
116108
returnstrlen(str);
117109
}
118110

@@ -122,7 +114,7 @@ vsnprintf(char *str, size_t count, const char *fmt,...)
122114

123115
staticvoidfmtstr__P((char*value,intljust,intlen,intzpad,intmaxwidth));
124116

125-
#ifndefHAVE_LONG_LONG_INT_64
117+
#ifndefHAVE_LONG_INT_64
126118
staticvoidfmtnum__P((longvalue,intbase,intdosign,intljust,intlen,intzpad));
127119
#else
128120
staticvoidfmtnum__P((long_longvalue,intbase,intdosign,intljust,intlen,intzpad));
@@ -133,27 +125,23 @@ static char *output;
133125
staticvoiddopr_outch__P((intc));
134126

135127
staticvoid
136-
dopr(char*buffer,constchar*format,...)
128+
dopr(char*buffer,constchar*format,va_listargs)
137129
{
138130
intch;
139131
#ifdefHAVE_LONG_LONG_INT_64
140132
long_longvalue;
133+
intlonglongflag=0;
141134
#else
142135
longvalue;
143136
#endif
144137
intlongflag=0;
145-
intlonglongflag=0;
146138
intpointflag=0;
147139
intmaxwidth=0;
148140
char*strvalue;
149141
intljust;
150142
intlen;
151143
intzpad;
152144

153-
VA_LOCAL_DECL
154-
155-
VA_START(format);
156-
157145
output=buffer;
158146
while ((ch=*format++))
159147
{
@@ -162,13 +150,15 @@ dopr(char *buffer, const char *format,...)
162150
case'%':
163151
ljust=len=zpad=maxwidth=0;
164152
longflag=pointflag=0;
153+
#ifdefHAVE_LONG_LONG_INT_64
154+
longlongflag=0;
155+
#endif
165156
nextch:
166157
ch=*format++;
167158
switch (ch)
168159
{
169160
case0:
170161
dostr("**end of format**",0);
171-
VA_END;
172162
return;
173163
case'-':
174164
ljust=1;
@@ -200,16 +190,13 @@ dopr(char *buffer, const char *format,...)
200190
pointflag=1;
201191
gotonextch;
202192
case'l':
193+
#ifdefHAVE_LONG_LONG_INT_64
203194
if (longflag)
204-
{
205195
longlongflag=1;
206-
gotonextch;
207-
}
208196
else
209-
{
197+
#endif
210198
longflag=1;
211-
gotonextch;
212-
}
199+
gotonextch;
213200
case'u':
214201
case'U':
215202
/* fmtnum(value,base,dosign,ljust,len,zpad) */
@@ -255,6 +242,7 @@ dopr(char *buffer, const char *format,...)
255242
}
256243
else
257244
value=va_arg(args,int);
245+
258246
fmtnum(value,10,1,ljust,len,zpad);
259247
break;
260248
case'x':
@@ -311,7 +299,6 @@ dopr(char *buffer, const char *format,...)
311299
}
312300
}
313301
*output=0;
314-
VA_END;
315302
}
316303

317304
staticvoid
@@ -362,7 +349,7 @@ intbase,
362349
zpad;
363350
{
364351
intsignvalue=0;
365-
#ifdefHAVE_LONG_LONG_INT_64
352+
#ifdefHAVE_LONG_INT_64
366353
unsignedlong_longuvalue;
367354
#else
368355
unsigned longuvalue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp