Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 098c63c

Browse files
committed
Porting efforts... :)
1 parent ee00b75 commit 098c63c

File tree

1 file changed

+41
-37
lines changed

1 file changed

+41
-37
lines changed

src/backend/port/snprintf.c

+41-37
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@
3131
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232
* SUCH DAMAGE.
3333
*/
34-
34+
#if 0
3535
# include "sendmail.h"
3636
# include "pathnames.h"
37+
#endif
38+
39+
# include "postgres.h"
40+
41+
# include <stdarg.h>
42+
# define VA_LOCAL_DECL va_list args;
43+
# define VA_START(f) va_start(args, f)
44+
# define VA_END va_end(args)
45+
3746
# include <sys/ioctl.h>
3847
# include <sys/param.h>
3948

@@ -59,50 +68,43 @@
5968
* causing nast effects.
6069
**************************************************************/
6170

62-
/*static char _id[] = "$Id: snprintf.c,v 1.4 1998/09/04 14:34:23 scrappy Exp $";*/
63-
static void dopr();
71+
/*static char _id[] = "$Id: snprintf.c,v 1.5 1998/09/10 04:11:52 vadim Exp $";*/
6472
static char *end;
6573
static int SnprfOverflow;
6674

67-
/* VARARGS3 */
75+
int snprintf(char *str, size_t count, const char *fmt, ...);
76+
int vsnprintf(char *str, size_t count, const char *fmt, ...);
77+
static void dopr (char *buffer, const char *format, ... );
78+
6879
int
69-
# ifdef __STDC__
7080
snprintf(char *str, size_t count, const char *fmt, ...)
71-
# else
72-
snprintf(str, count, fmt, va_alist)
73-
char *str;
74-
size_t count;
75-
const char *fmt;
76-
va_dcl
77-
#endif
7881
{
7982
int len;
8083
VA_LOCAL_DECL
8184

8285
VA_START(fmt);
83-
len = vsnprintf(str, count, fmt, ap);
86+
len = vsnprintf(str, count, fmt, args);
8487
VA_END;
8588
return len;
8689
}
8790

8891

89-
# ifndef luna2
9092
int
91-
vsnprintf(str, count, fmt, args)
92-
char *str;
93-
size_t count;
94-
const char *fmt;
95-
va_list args;
93+
vsnprintf(char *str, size_t count, const char *fmt, ...)
9694
{
95+
VA_LOCAL_DECL
96+
97+
VA_START(fmt);
9798
str[0] = 0;
9899
end = str + count - 1;
99100
SnprfOverflow = 0;
100-
dopr( str, fmt, args );
101+
dopr( str, fmt, args);
101102
if (count > 0)
102103
end[0] = 0;
103-
if (SnprfOverflow && tTd(57, 2))
104-
printf("\nvsnprintf overflow, len = %d, str = %s",
105-
count, shortenstring(str, 203));
104+
if (SnprfOverflow)
105+
elog(NOTICE, "vsnprintf overflow, len = %d, str = %s",
106+
count, str);
107+
VA_END;
106108
return strlen(str);
107109
}
108110

@@ -117,20 +119,20 @@ static char *output;
117119
static void dopr_outch __P(( int c ));
118120

119121
static void
120-
dopr( buffer, format, args )
121-
char *buffer;
122-
const char *format;
123-
va_list args;
122+
dopr (char *buffer, const char *format, ... )
124123
{
125-
int ch;
126-
long value;
127-
int longflag = 0;
128-
int pointflag = 0;
129-
int maxwidth = 0;
130-
char *strvalue;
131-
int ljust;
132-
int len;
133-
int zpad;
124+
int ch;
125+
long value;
126+
int longflag = 0;
127+
int pointflag = 0;
128+
int maxwidth = 0;
129+
char *strvalue;
130+
int ljust;
131+
int len;
132+
int zpad;
133+
VA_LOCAL_DECL
134+
135+
VA_START(format);
134136

135137
output = buffer;
136138
while( (ch = *format++) ){
@@ -143,6 +145,7 @@ dopr( buffer, format, args )
143145
switch( ch ){
144146
case 0:
145147
dostr( "**end of format**" , 0);
148+
VA_END;
146149
return;
147150
case '-': ljust = 1; goto nextch;
148151
case '0': /* set zero padding if len not set */
@@ -222,6 +225,7 @@ dopr( buffer, format, args )
222225
}
223226
}
224227
*output = 0;
228+
VA_END;
225229
}
226230

227231
static void
@@ -340,4 +344,4 @@ dopr_outch( c )
340344
SnprfOverflow++;
341345
}
342346

343-
# endif /* !luna2 */
347+

0 commit comments

Comments
 (0)