mirror of
https://github.com/osmarks/ngircd.git
synced 2025-04-05 07:17:13 +00:00
vsnprintf.c: make code compatible with ansi2knr tool
(cherry picked from commit 8d25044ce515e25f453d22426c484a11d00af0f1)
This commit is contained in:
parent
ac127ff20a
commit
3b46356ce2
@ -109,15 +109,16 @@ void dummy_snprintf PARAMS(( void )) { }
|
||||
#define LLONG long
|
||||
#endif
|
||||
|
||||
static size_t dopr(char *buffer, size_t maxlen, const char *format,
|
||||
va_list args);
|
||||
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max);
|
||||
static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags);
|
||||
static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
|
||||
LDOUBLE fvalue, int min, int max, int flags);
|
||||
static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
|
||||
static size_t dopr PARAMS((char *buffer, size_t maxlen, const char *format,
|
||||
va_list args));
|
||||
static void fmtstr PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max));
|
||||
static void fmtint PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags));
|
||||
static void fmtfp PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||
LDOUBLE fvalue, int min, int max, int flags));
|
||||
static void dopr_outch PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||
char c));
|
||||
|
||||
/*
|
||||
* dopr(): poor man's version of doprintf
|
||||
@ -153,7 +154,8 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
|
||||
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
|
||||
#endif
|
||||
|
||||
static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
|
||||
static size_t
|
||||
dopr(char *buffer, size_t maxlen, const char *format, va_list args)
|
||||
{
|
||||
char ch;
|
||||
LLONG value;
|
||||
@ -410,8 +412,9 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
|
||||
return currlen;
|
||||
}
|
||||
|
||||
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max)
|
||||
static void
|
||||
fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags,
|
||||
int min, int max)
|
||||
{
|
||||
int padlen, strln; /* amount to pad */
|
||||
int cnt = 0;
|
||||
@ -448,8 +451,9 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
||||
|
||||
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
|
||||
|
||||
static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags)
|
||||
static void
|
||||
fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base,
|
||||
int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
unsigned long uvalue;
|
||||
@ -532,7 +536,8 @@ static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
|
||||
}
|
||||
}
|
||||
|
||||
static LDOUBLE abs_val(LDOUBLE value)
|
||||
static LDOUBLE
|
||||
abs_val(LDOUBLE value)
|
||||
{
|
||||
LDOUBLE result = value;
|
||||
|
||||
@ -542,7 +547,8 @@ static LDOUBLE abs_val(LDOUBLE value)
|
||||
return result;
|
||||
}
|
||||
|
||||
static LDOUBLE POW10(int exp)
|
||||
static LDOUBLE
|
||||
POW10(int exp)
|
||||
{
|
||||
LDOUBLE result = 1;
|
||||
|
||||
@ -554,7 +560,8 @@ static LDOUBLE POW10(int exp)
|
||||
return result;
|
||||
}
|
||||
|
||||
static LLONG ROUND(LDOUBLE value)
|
||||
static LLONG
|
||||
ROUND(LDOUBLE value)
|
||||
{
|
||||
LLONG intpart;
|
||||
|
||||
@ -567,7 +574,8 @@ static LLONG ROUND(LDOUBLE value)
|
||||
|
||||
/* a replacement for modf that doesn't need the math library. Should
|
||||
be portable, but slow */
|
||||
static double my_modf(double x0, double *iptr)
|
||||
static double
|
||||
my_modf(double x0, double *iptr)
|
||||
{
|
||||
int i;
|
||||
long l;
|
||||
@ -601,8 +609,9 @@ static double my_modf(double x0, double *iptr)
|
||||
}
|
||||
|
||||
|
||||
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
LDOUBLE fvalue, int min, int max, int flags)
|
||||
static void
|
||||
fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue,
|
||||
int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
double ufvalue;
|
||||
@ -755,7 +764,8 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
}
|
||||
}
|
||||
|
||||
static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
|
||||
static void
|
||||
dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
|
||||
{
|
||||
if (*currlen < maxlen) {
|
||||
buffer[(*currlen)] = c;
|
||||
@ -764,14 +774,25 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
|
||||
}
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF)
|
||||
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)
|
||||
{
|
||||
return dopr(str, count, fmt, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
int snprintf(char *str,size_t count,const char *fmt,...)
|
||||
#ifdef PROTOTYPES
|
||||
int
|
||||
snprintf(char *str, size_t count, const char *fmt, ...)
|
||||
#else
|
||||
int
|
||||
snprintf(str, count, fmt, va_alist)
|
||||
char *str;
|
||||
size_t count;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
size_t ret;
|
||||
va_list ap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user