mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-12 09:50:29 +00:00
vsnprintf.c: make code compatible with ansi2knr tool
This commit is contained in:
parent
c3c719b978
commit
8d25044ce5
@ -107,15 +107,16 @@ void dummy_snprintf PARAMS(( void )) { }
|
|||||||
#define LLONG long
|
#define LLONG long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static size_t dopr(char *buffer, size_t maxlen, const char *format,
|
static size_t dopr PARAMS((char *buffer, size_t maxlen, const char *format,
|
||||||
va_list args);
|
va_list args));
|
||||||
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
static void fmtstr PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||||
char *value, int flags, int min, int max);
|
char *value, int flags, int min, int max));
|
||||||
static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
|
static void fmtint PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||||
long value, int base, int min, int max, int flags);
|
long value, int base, int min, int max, int flags));
|
||||||
static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
|
static void fmtfp PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||||
LDOUBLE fvalue, int min, int max, int flags);
|
LDOUBLE fvalue, int min, int max, int flags));
|
||||||
static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
|
static void dopr_outch PARAMS((char *buffer, size_t *currlen, size_t maxlen,
|
||||||
|
char c));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dopr(): poor man's version of doprintf
|
* dopr(): poor man's version of doprintf
|
||||||
@ -151,7 +152,8 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
|
|||||||
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
|
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
|
||||||
#endif
|
#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;
|
char ch;
|
||||||
LLONG value;
|
LLONG value;
|
||||||
@ -408,8 +410,9 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
|
|||||||
return currlen;
|
return currlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
static void
|
||||||
char *value, int flags, int min, int max)
|
fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags,
|
||||||
|
int min, int max)
|
||||||
{
|
{
|
||||||
int padlen, strln; /* amount to pad */
|
int padlen, strln; /* amount to pad */
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
@ -446,8 +449,9 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
|||||||
|
|
||||||
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
|
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
|
||||||
|
|
||||||
static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
|
static void
|
||||||
long value, int base, int min, int max, int flags)
|
fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base,
|
||||||
|
int min, int max, int flags)
|
||||||
{
|
{
|
||||||
int signvalue = 0;
|
int signvalue = 0;
|
||||||
unsigned long uvalue;
|
unsigned long uvalue;
|
||||||
@ -530,7 +534,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;
|
LDOUBLE result = value;
|
||||||
|
|
||||||
@ -540,7 +545,8 @@ static LDOUBLE abs_val(LDOUBLE value)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LDOUBLE POW10(int exp)
|
static LDOUBLE
|
||||||
|
POW10(int exp)
|
||||||
{
|
{
|
||||||
LDOUBLE result = 1;
|
LDOUBLE result = 1;
|
||||||
|
|
||||||
@ -552,7 +558,8 @@ static LDOUBLE POW10(int exp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LLONG ROUND(LDOUBLE value)
|
static LLONG
|
||||||
|
ROUND(LDOUBLE value)
|
||||||
{
|
{
|
||||||
LLONG intpart;
|
LLONG intpart;
|
||||||
|
|
||||||
@ -565,7 +572,8 @@ static LLONG ROUND(LDOUBLE value)
|
|||||||
|
|
||||||
/* a replacement for modf that doesn't need the math library. Should
|
/* a replacement for modf that doesn't need the math library. Should
|
||||||
be portable, but slow */
|
be portable, but slow */
|
||||||
static double my_modf(double x0, double *iptr)
|
static double
|
||||||
|
my_modf(double x0, double *iptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long l;
|
long l;
|
||||||
@ -599,8 +607,9 @@ static double my_modf(double x0, double *iptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
static void
|
||||||
LDOUBLE fvalue, int min, int max, int flags)
|
fmtfp (char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue,
|
||||||
|
int min, int max, int flags)
|
||||||
{
|
{
|
||||||
int signvalue = 0;
|
int signvalue = 0;
|
||||||
double ufvalue;
|
double ufvalue;
|
||||||
@ -745,7 +754,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) {
|
if (*currlen < maxlen) {
|
||||||
buffer[(*currlen)] = c;
|
buffer[(*currlen)] = c;
|
||||||
@ -754,14 +764,25 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAVE_VSNPRINTF)
|
#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);
|
return dopr(str, count, fmt, args);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_SNPRINTF)
|
#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;
|
size_t ret;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
Loading…
Reference in New Issue
Block a user