X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fsnprintf.c;h=78228e6879c0edf16f61ba539a9e2a4def2ecf42;hp=4bf006c915889bb046d6551ff139b1c4b911cc5c;hb=277e840a0f8e3ec8800cfe7407fe3c16000bc622;hpb=9000d2b527680b4b13964475d84df42815d40e37 diff --git a/src/snprintf.c b/src/snprintf.c index 4bf006c9..78228e68 100644 --- a/src/snprintf.c +++ b/src/snprintf.c @@ -78,7 +78,6 @@ * actually print args for %g and %e * * Hrvoje Niksic 2005-04-15 - * use the PARAMS macro to handle prototypes. * write function definitions in the ansi2knr-friendly way. * if string precision is specified, don't read VALUE past it. * fix bug in fmtfp that caused 0.01 to be printed as 0.1. @@ -105,31 +104,11 @@ #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) -#ifdef HAVE_STRING_H -# include -#else -# include -#endif +#include #include #include /* for NULL */ -/* varargs declarations: */ - -#if defined(HAVE_STDARG_H) -# include -# define HAVE_STDARGS /* let's hope that works everywhere (mj) */ -# define VA_LOCAL_DECL va_list ap -# define VA_START(f) va_start(ap, f) -# define VA_SHIFT(v,t) ; /* no-op for ANSI */ -# define VA_END va_end(ap) -#else -# include -# undef HAVE_STDARGS -# define VA_LOCAL_DECL va_list ap -# define VA_START(f) va_start(ap) /* f is ignored! */ -# define VA_SHIFT(v,t) v = va_arg(ap,t) -# define VA_END va_end(ap) -#endif +#include #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double @@ -150,28 +129,17 @@ # define vsnprintf test_vsnprintf #endif -#ifdef HAVE_STDARGS int snprintf (char *str, size_t count, const char *fmt, ...); int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); -#else -int snprintf (); -int vsnprintf (); -#endif - -#ifndef PARAMS -# define PARAMS(x) x -#endif -static int dopr PARAMS ((char *buffer, size_t maxlen, const char *format, - va_list args)); -static int fmtstr PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - const char *value, int flags, int min, int max)); -static int fmtint PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - LLONG value, int base, int min, int max, int flags)); -static int fmtfp PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags)); -static int dopr_outch PARAMS ((char *buffer, size_t *currlen, size_t maxlen, - char c)); +static int dopr (char *buffer, size_t maxlen, const char *format, va_list args); +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + const char *value, int flags, int min, int max); +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + LLONG value, int base, int min, int max, int flags); +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c); /* * dopr(): poor man's version of doprintf @@ -896,22 +864,14 @@ vsnprintf (char *str, size_t count, const char *fmt, va_list args) #ifndef HAVE_SNPRINTF int -snprintf (char *str, size_t count,const char *fmt,...) +snprintf (char *str, size_t count, const char *fmt,...) { -#ifndef HAVE_STDARGS - char *str; - size_t count; - char *fmt; -#endif - VA_LOCAL_DECL; + va_list ap; int total; - - VA_START (fmt); - VA_SHIFT (str, char *); - VA_SHIFT (count, size_t ); - VA_SHIFT (fmt, char *); - total = vsnprintf(str, count, fmt, ap); - VA_END; + + va_start (ap, fmt); + total = vsnprintf (str, count, fmt, ap); + va_end (ap); return total; } #endif /* !HAVE_SNPRINTF */