2008-06-30 08:58:15 -04:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
1999-12-29 09:20:26 -05:00
|
|
|
*
|
2016-04-01 04:14:06 -04:00
|
|
|
* Copyright (C) 1999 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2008-06-30 08:58:15 -04:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2016-02-02 18:19:02 -05:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2003-01-16 16:10:10 -05:00
|
|
|
*
|
2008-06-30 08:58:15 -04:00
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
2003-01-16 16:10:10 -05:00
|
|
|
*
|
2008-06-30 08:58:15 -04:00
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
2003-01-16 16:10:10 -05:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Purpose:
|
|
|
|
* A merge of Bjorn Reese's format() function and Daniel's dsprintf()
|
|
|
|
* 1.0. A full blooded printf() clone with full support for <num>$
|
|
|
|
* everywhere (parameters, widths and precisions) including variabled
|
|
|
|
* sized parameters (like doubles, long longs, long doubles and even
|
|
|
|
* void * in 64-bit architectures).
|
|
|
|
*
|
|
|
|
* Current restrictions:
|
|
|
|
* - Max 128 parameters
|
|
|
|
* - No 'long double' support.
|
|
|
|
*
|
|
|
|
* If you ever want truly portable and good *printf() clones, the project that
|
|
|
|
* took on from here is named 'Trio' and you find more details on the trio web
|
2016-03-06 22:57:47 -05:00
|
|
|
* page at https://daniel.haxx.se/projects/trio/
|
2003-01-16 16:10:10 -05:00
|
|
|
*/
|
|
|
|
|
2013-01-06 13:06:49 -05:00
|
|
|
#include "curl_setup.h"
|
2004-01-29 08:56:45 -05:00
|
|
|
#include <curl/mprintf.h>
|
|
|
|
|
2009-04-21 07:46:16 -04:00
|
|
|
#include "curl_memory.h"
|
2008-08-22 07:11:33 -04:00
|
|
|
/* The last #include file should be: */
|
2013-01-03 20:50:28 -05:00
|
|
|
#include "memdebug.h"
|
2008-08-22 07:11:33 -04:00
|
|
|
|
2003-01-16 16:10:10 -05:00
|
|
|
#ifndef SIZEOF_LONG_DOUBLE
|
|
|
|
#define SIZEOF_LONG_DOUBLE 0
|
|
|
|
#endif
|
|
|
|
|
2008-08-20 20:10:27 -04:00
|
|
|
/*
|
|
|
|
* If SIZEOF_SIZE_T has not been defined, default to the size of long.
|
|
|
|
*/
|
|
|
|
|
2004-05-05 02:57:26 -04:00
|
|
|
#ifndef SIZEOF_SIZE_T
|
2008-08-20 20:10:27 -04:00
|
|
|
# define SIZEOF_SIZE_T CURL_SIZEOF_LONG
|
2004-05-05 02:57:26 -04:00
|
|
|
#endif
|
|
|
|
|
2008-08-20 20:06:15 -04:00
|
|
|
#ifdef HAVE_LONGLONG
|
|
|
|
# define LONG_LONG_TYPE long long
|
|
|
|
# define HAVE_LONG_LONG_TYPE
|
|
|
|
#else
|
2008-08-21 02:58:12 -04:00
|
|
|
# if defined(_MSC_VER) && (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
2008-08-20 20:06:15 -04:00
|
|
|
# define LONG_LONG_TYPE __int64
|
|
|
|
# define HAVE_LONG_LONG_TYPE
|
|
|
|
# else
|
|
|
|
# undef LONG_LONG_TYPE
|
|
|
|
# undef HAVE_LONG_LONG_TYPE
|
|
|
|
# endif
|
2004-02-25 09:15:38 -05:00
|
|
|
#endif
|
2003-01-16 16:10:10 -05:00
|
|
|
|
2013-12-29 09:45:28 -05:00
|
|
|
/*
|
|
|
|
* Non-ANSI integer extensions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)) || \
|
|
|
|
(defined(__WATCOMC__) && defined(__386__)) || \
|
|
|
|
(defined(__POCC__) && defined(_MSC_VER)) || \
|
|
|
|
(defined(_WIN32_WCE)) || \
|
|
|
|
(defined(__MINGW32__)) || \
|
|
|
|
(defined(_MSC_VER) && (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64))
|
|
|
|
# define MP_HAVE_INT_EXTENSIONS
|
|
|
|
#endif
|
|
|
|
|
2008-08-22 07:11:33 -04:00
|
|
|
/*
|
2013-01-03 20:50:28 -05:00
|
|
|
* Max integer data types that mprintf.c is capable
|
2008-08-22 07:11:33 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_LONG_LONG_TYPE
|
|
|
|
# define mp_intmax_t LONG_LONG_TYPE
|
|
|
|
# define mp_uintmax_t unsigned LONG_LONG_TYPE
|
|
|
|
#else
|
|
|
|
# define mp_intmax_t long
|
|
|
|
# define mp_uintmax_t unsigned long
|
|
|
|
#endif
|
2003-01-16 16:10:10 -05:00
|
|
|
|
2016-11-08 09:32:37 -05:00
|
|
|
#define BUFFSIZE 326 /* buffer for long-to-str and float-to-str calcs, should
|
|
|
|
fit negative DBL_MAX (317 letters) */
|
2003-01-16 16:10:10 -05:00
|
|
|
#define MAX_PARAMETERS 128 /* lame static limit */
|
|
|
|
|
2007-02-28 09:45:48 -05:00
|
|
|
#ifdef __AMIGA__
|
2005-07-13 14:06:40 -04:00
|
|
|
# undef FORMAT_INT
|
|
|
|
#endif
|
2003-01-16 16:10:10 -05:00
|
|
|
|
|
|
|
/* Lower-case digits. */
|
|
|
|
static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
|
|
|
|
|
|
/* Upper-case digits. */
|
|
|
|
static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
|
2004-06-24 07:54:11 -04:00
|
|
|
#define OUTCHAR(x) \
|
2004-05-12 08:05:13 -04:00
|
|
|
do{ \
|
|
|
|
if(stream((unsigned char)(x), (FILE *)data) != -1) \
|
|
|
|
done++; \
|
|
|
|
else \
|
|
|
|
return done; /* return immediately on failure */ \
|
2011-09-02 13:40:53 -04:00
|
|
|
} WHILE_FALSE
|
2003-01-16 16:10:10 -05:00
|
|
|
|
|
|
|
/* Data type to read from the arglist */
|
|
|
|
typedef enum {
|
|
|
|
FORMAT_UNKNOWN = 0,
|
|
|
|
FORMAT_STRING,
|
|
|
|
FORMAT_PTR,
|
|
|
|
FORMAT_INT,
|
|
|
|
FORMAT_INTPTR,
|
|
|
|
FORMAT_LONG,
|
|
|
|
FORMAT_LONGLONG,
|
|
|
|
FORMAT_DOUBLE,
|
|
|
|
FORMAT_LONGDOUBLE,
|
|
|
|
FORMAT_WIDTH /* For internal use */
|
|
|
|
} FormatType;
|
|
|
|
|
2011-04-19 09:54:13 -04:00
|
|
|
/* conversion and display flags */
|
2003-01-16 16:10:10 -05:00
|
|
|
enum {
|
|
|
|
FLAGS_NEW = 0,
|
|
|
|
FLAGS_SPACE = 1<<0,
|
|
|
|
FLAGS_SHOWSIGN = 1<<1,
|
|
|
|
FLAGS_LEFT = 1<<2,
|
|
|
|
FLAGS_ALT = 1<<3,
|
|
|
|
FLAGS_SHORT = 1<<4,
|
|
|
|
FLAGS_LONG = 1<<5,
|
|
|
|
FLAGS_LONGLONG = 1<<6,
|
|
|
|
FLAGS_LONGDOUBLE = 1<<7,
|
|
|
|
FLAGS_PAD_NIL = 1<<8,
|
|
|
|
FLAGS_UNSIGNED = 1<<9,
|
|
|
|
FLAGS_OCTAL = 1<<10,
|
|
|
|
FLAGS_HEX = 1<<11,
|
|
|
|
FLAGS_UPPER = 1<<12,
|
|
|
|
FLAGS_WIDTH = 1<<13, /* '*' or '*<num>$' used */
|
|
|
|
FLAGS_WIDTHPARAM = 1<<14, /* width PARAMETER was specified */
|
|
|
|
FLAGS_PREC = 1<<15, /* precision was specified */
|
|
|
|
FLAGS_PRECPARAM = 1<<16, /* precision PARAMETER was specified */
|
|
|
|
FLAGS_CHAR = 1<<17, /* %c story */
|
|
|
|
FLAGS_FLOATE = 1<<18, /* %e or %E */
|
|
|
|
FLAGS_FLOATG = 1<<19 /* %g or %G */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FormatType type;
|
|
|
|
int flags;
|
2004-03-23 10:25:54 -05:00
|
|
|
long width; /* width OR width parameter number */
|
|
|
|
long precision; /* precision OR precision parameter number */
|
2003-01-16 16:10:10 -05:00
|
|
|
union {
|
|
|
|
char *str;
|
|
|
|
void *ptr;
|
2008-08-22 07:11:33 -04:00
|
|
|
union {
|
|
|
|
mp_intmax_t as_signed;
|
|
|
|
mp_uintmax_t as_unsigned;
|
|
|
|
} num;
|
2003-01-16 16:10:10 -05:00
|
|
|
double dnum;
|
|
|
|
} data;
|
|
|
|
} va_stack_t;
|
|
|
|
|
|
|
|
struct nsprintf {
|
|
|
|
char *buffer;
|
|
|
|
size_t length;
|
|
|
|
size_t max;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct asprintf {
|
|
|
|
char *buffer; /* allocated buffer */
|
|
|
|
size_t len; /* length of string */
|
|
|
|
size_t alloc; /* length of alloc */
|
2008-08-22 02:53:01 -04:00
|
|
|
int fail; /* (!= 0) if an alloc has failed and thus
|
|
|
|
the output is not the complete data */
|
2003-01-16 16:10:10 -05:00
|
|
|
};
|
|
|
|
|
2004-03-08 06:28:14 -05:00
|
|
|
static long dprintf_DollarString(char *input, char **end)
|
2003-01-16 16:10:10 -05:00
|
|
|
{
|
|
|
|
int number=0;
|
2006-10-17 17:32:56 -04:00
|
|
|
while(ISDIGIT(*input)) {
|
2003-01-16 16:10:10 -05:00
|
|
|
number *= 10;
|
|
|
|
number += *input-'0';
|
|
|
|
input++;
|
|
|
|
}
|
|
|
|
if(number && ('$'==*input++)) {
|
|
|
|
*end = input;
|
|
|
|
return number;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-29 09:45:28 -05:00
|
|
|
static bool dprintf_IsQualifierNoDollar(const char *fmt)
|
2003-01-16 16:10:10 -05:00
|
|
|
{
|
2013-12-29 09:45:28 -05:00
|
|
|
#if defined(MP_HAVE_INT_EXTENSIONS)
|
|
|
|
if(!strncmp(fmt, "I32", 3) || !strncmp(fmt, "I64", 3)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch(*fmt) {
|
2003-01-16 16:10:10 -05:00
|
|
|
case '-': case '+': case ' ': case '#': case '.':
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
2004-03-01 07:44:07 -05:00
|
|
|
case 'h': case 'l': case 'L': case 'z': case 'q':
|
2004-01-05 17:29:29 -05:00
|
|
|
case '*': case 'O':
|
2013-12-29 09:45:28 -05:00
|
|
|
#if defined(MP_HAVE_INT_EXTENSIONS)
|
|
|
|
case 'I':
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
|
2003-01-16 16:10:10 -05:00
|
|
|
default:
|
2013-12-29 09:45:28 -05:00
|
|
|
return FALSE;
|
2003-01-16 16:10:10 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
*
|
|
|
|
* Pass 1:
|
|
|
|
* Create an index with the type of each parameter entry and its
|
|
|
|
* value (may vary in size)
|
|
|
|
*
|
2016-10-08 14:47:04 -04:00
|
|
|
* Returns zero on success.
|
|
|
|
*
|
2003-01-16 16:10:10 -05:00
|
|
|
******************************************************************/
|
1999-12-29 09:20:26 -05:00
|
|
|
|
2016-10-08 14:47:04 -04:00
|
|
|
static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|
|
|
va_list arglist)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
2007-08-09 17:05:05 -04:00
|
|
|
char *fmt = (char *)format;
|
1999-12-29 09:20:26 -05:00
|
|
|
int param_num = 0;
|
2004-03-08 06:28:14 -05:00
|
|
|
long this_param;
|
|
|
|
long width;
|
|
|
|
long precision;
|
1999-12-29 09:20:26 -05:00
|
|
|
int flags;
|
2004-03-08 06:28:14 -05:00
|
|
|
long max_param=0;
|
|
|
|
long i;
|
2008-08-23 23:59:43 -04:00
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
while(*fmt) {
|
|
|
|
if(*fmt++ == '%') {
|
|
|
|
if(*fmt == '%') {
|
2004-06-24 07:54:11 -04:00
|
|
|
fmt++;
|
|
|
|
continue; /* while */
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
flags = FLAGS_NEW;
|
|
|
|
|
|
|
|
/* Handle the positional case (N$) */
|
|
|
|
|
|
|
|
param_num++;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
this_param = dprintf_DollarString(fmt, &fmt);
|
2007-11-05 04:45:09 -05:00
|
|
|
if(0 == this_param)
|
2004-06-24 07:54:11 -04:00
|
|
|
/* we got no positional, get the next counter */
|
|
|
|
this_param = param_num;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(this_param > max_param)
|
2004-06-24 07:54:11 -04:00
|
|
|
max_param = this_param;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The parameter with number 'i' should be used. Next, we need
|
|
|
|
* to get SIZE and TYPE of the parameter. Add the information
|
|
|
|
* to our array.
|
|
|
|
*/
|
|
|
|
|
|
|
|
width = 0;
|
|
|
|
precision = 0;
|
|
|
|
|
|
|
|
/* Handle the flags */
|
|
|
|
|
2013-12-29 09:45:28 -05:00
|
|
|
while(dprintf_IsQualifierNoDollar(fmt)) {
|
|
|
|
#if defined(MP_HAVE_INT_EXTENSIONS)
|
|
|
|
if(!strncmp(fmt, "I32", 3)) {
|
|
|
|
flags |= FLAGS_LONG;
|
|
|
|
fmt += 3;
|
|
|
|
}
|
|
|
|
else if(!strncmp(fmt, "I64", 3)) {
|
|
|
|
flags |= FLAGS_LONGLONG;
|
|
|
|
fmt += 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch(*fmt++) {
|
2004-06-24 07:54:11 -04:00
|
|
|
case ' ':
|
|
|
|
flags |= FLAGS_SPACE;
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
flags |= FLAGS_SHOWSIGN;
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
flags |= FLAGS_LEFT;
|
|
|
|
flags &= ~FLAGS_PAD_NIL;
|
|
|
|
break;
|
|
|
|
case '#':
|
|
|
|
flags |= FLAGS_ALT;
|
|
|
|
break;
|
|
|
|
case '.':
|
2007-11-05 04:45:09 -05:00
|
|
|
if('*' == *fmt) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* The precision is picked from a specified parameter */
|
|
|
|
|
|
|
|
flags |= FLAGS_PRECPARAM;
|
|
|
|
fmt++;
|
|
|
|
param_num++;
|
|
|
|
|
|
|
|
i = dprintf_DollarString(fmt, &fmt);
|
2007-11-05 04:45:09 -05:00
|
|
|
if(i)
|
2004-06-24 07:54:11 -04:00
|
|
|
precision = i;
|
|
|
|
else
|
|
|
|
precision = param_num;
|
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(precision > max_param)
|
2004-06-24 07:54:11 -04:00
|
|
|
max_param = precision;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
flags |= FLAGS_PREC;
|
|
|
|
precision = strtol(fmt, &fmt, 10);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
flags |= FLAGS_SHORT;
|
|
|
|
break;
|
2013-12-29 09:45:28 -05:00
|
|
|
#if defined(MP_HAVE_INT_EXTENSIONS)
|
|
|
|
case 'I':
|
|
|
|
#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
|
|
|
|
flags |= FLAGS_LONGLONG;
|
|
|
|
#else
|
|
|
|
flags |= FLAGS_LONG;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
#endif
|
2004-06-24 07:54:11 -04:00
|
|
|
case 'l':
|
2007-11-05 04:45:09 -05:00
|
|
|
if(flags & FLAGS_LONG)
|
2004-06-24 07:54:11 -04:00
|
|
|
flags |= FLAGS_LONGLONG;
|
|
|
|
else
|
|
|
|
flags |= FLAGS_LONG;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
flags |= FLAGS_LONGDOUBLE;
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
flags |= FLAGS_LONGLONG;
|
|
|
|
break;
|
|
|
|
case 'z':
|
2004-03-01 07:44:07 -05:00
|
|
|
/* the code below generates a warning if -Wunreachable-code is
|
|
|
|
used */
|
2008-08-20 20:10:27 -04:00
|
|
|
#if (SIZEOF_SIZE_T > CURL_SIZEOF_LONG)
|
2004-05-05 02:57:26 -04:00
|
|
|
flags |= FLAGS_LONGLONG;
|
|
|
|
#else
|
|
|
|
flags |= FLAGS_LONG;
|
|
|
|
#endif
|
|
|
|
break;
|
2004-03-01 11:22:17 -05:00
|
|
|
case 'O':
|
2008-08-20 20:10:27 -04:00
|
|
|
#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
|
2004-02-20 10:16:31 -05:00
|
|
|
flags |= FLAGS_LONGLONG;
|
|
|
|
#else
|
|
|
|
flags |= FLAGS_LONG;
|
|
|
|
#endif
|
2004-03-01 11:22:17 -05:00
|
|
|
break;
|
2004-06-24 07:54:11 -04:00
|
|
|
case '0':
|
2007-11-05 04:45:09 -05:00
|
|
|
if(!(flags & FLAGS_LEFT))
|
2004-06-24 07:54:11 -04:00
|
|
|
flags |= FLAGS_PAD_NIL;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
|
|
flags |= FLAGS_WIDTH;
|
|
|
|
width = strtol(fmt-1, &fmt, 10);
|
|
|
|
break;
|
|
|
|
case '*': /* Special case */
|
|
|
|
flags |= FLAGS_WIDTHPARAM;
|
|
|
|
param_num++;
|
|
|
|
|
|
|
|
i = dprintf_DollarString(fmt, &fmt);
|
|
|
|
if(i)
|
|
|
|
width = i;
|
|
|
|
else
|
|
|
|
width = param_num;
|
|
|
|
if(width > max_param)
|
|
|
|
max_param=width;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
} /* switch */
|
|
|
|
|
|
|
|
/* Handle the specifier */
|
|
|
|
|
|
|
|
i = this_param - 1;
|
|
|
|
|
2016-10-08 14:47:04 -04:00
|
|
|
if((i < 0) || (i >= MAX_PARAMETERS))
|
|
|
|
/* out of allowed range */
|
|
|
|
return 1;
|
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
switch (*fmt) {
|
|
|
|
case 'S':
|
2004-06-24 07:54:11 -04:00
|
|
|
flags |= FLAGS_ALT;
|
|
|
|
/* FALLTHROUGH */
|
1999-12-29 09:20:26 -05:00
|
|
|
case 's':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_STRING;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'n':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INTPTR;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'p':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_PTR;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'd': case 'i':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INT;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'u':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INT;
|
|
|
|
flags |= FLAGS_UNSIGNED;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'o':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INT;
|
|
|
|
flags |= FLAGS_OCTAL;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'x':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INT;
|
2013-06-25 03:52:06 -04:00
|
|
|
flags |= FLAGS_HEX|FLAGS_UNSIGNED;
|
2004-06-24 07:54:11 -04:00
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'X':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INT;
|
2013-06-25 03:52:06 -04:00
|
|
|
flags |= FLAGS_HEX|FLAGS_UPPER|FLAGS_UNSIGNED;
|
2004-06-24 07:54:11 -04:00
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'c':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_INT;
|
|
|
|
flags |= FLAGS_CHAR;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
case 'f':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_DOUBLE;
|
|
|
|
break;
|
2004-03-08 06:28:14 -05:00
|
|
|
case 'e':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_DOUBLE;
|
|
|
|
flags |= FLAGS_FLOATE;
|
|
|
|
break;
|
2004-03-08 06:28:14 -05:00
|
|
|
case 'E':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_DOUBLE;
|
|
|
|
flags |= FLAGS_FLOATE|FLAGS_UPPER;
|
|
|
|
break;
|
2004-03-08 06:28:14 -05:00
|
|
|
case 'g':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_DOUBLE;
|
|
|
|
flags |= FLAGS_FLOATG;
|
|
|
|
break;
|
2004-03-08 06:28:14 -05:00
|
|
|
case 'G':
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_DOUBLE;
|
|
|
|
flags |= FLAGS_FLOATG|FLAGS_UPPER;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
default:
|
2004-06-24 07:54:11 -04:00
|
|
|
vto[i].type = FORMAT_UNKNOWN;
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
} /* switch */
|
|
|
|
|
|
|
|
vto[i].flags = flags;
|
|
|
|
vto[i].width = width;
|
|
|
|
vto[i].precision = precision;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(flags & FLAGS_WIDTHPARAM) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* we have the width specified from a parameter, so we make that
|
|
|
|
parameter's info setup properly */
|
2016-03-09 02:59:05 -05:00
|
|
|
long k = width - 1;
|
|
|
|
vto[i].width = k;
|
|
|
|
vto[k].type = FORMAT_WIDTH;
|
|
|
|
vto[k].flags = FLAGS_NEW;
|
|
|
|
/* can't use width or precision of width! */
|
|
|
|
vto[k].width = 0;
|
|
|
|
vto[k].precision = 0;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
2007-11-05 04:45:09 -05:00
|
|
|
if(flags & FLAGS_PRECPARAM) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* we have the precision specified from a parameter, so we make that
|
|
|
|
parameter's info setup properly */
|
2016-03-09 02:59:05 -05:00
|
|
|
long k = precision - 1;
|
|
|
|
vto[i].precision = k;
|
|
|
|
vto[k].type = FORMAT_WIDTH;
|
|
|
|
vto[k].flags = FLAGS_NEW;
|
|
|
|
/* can't use width or precision of width! */
|
|
|
|
vto[k].width = 0;
|
|
|
|
vto[k].precision = 0;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
*endpos++ = fmt + 1; /* end of this sequence */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the arg list parameters into our data list */
|
2011-04-20 09:17:42 -04:00
|
|
|
for(i=0; i<max_param; i++) {
|
2016-03-09 02:59:05 -05:00
|
|
|
/* Width/precision arguments must be read before the main argument
|
|
|
|
they are attached to */
|
|
|
|
if(vto[i].flags & FLAGS_WIDTHPARAM) {
|
|
|
|
vto[vto[i].width].data.num.as_signed =
|
|
|
|
(mp_intmax_t)va_arg(arglist, int);
|
|
|
|
}
|
|
|
|
if(vto[i].flags & FLAGS_PRECPARAM) {
|
|
|
|
vto[vto[i].precision].data.num.as_signed =
|
|
|
|
(mp_intmax_t)va_arg(arglist, int);
|
2011-04-20 09:17:42 -04:00
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
|
2016-12-13 17:34:59 -05:00
|
|
|
switch(vto[i].type) {
|
2011-04-20 09:17:42 -04:00
|
|
|
case FORMAT_STRING:
|
|
|
|
vto[i].data.str = va_arg(arglist, char *);
|
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2011-04-20 09:17:42 -04:00
|
|
|
case FORMAT_INTPTR:
|
|
|
|
case FORMAT_UNKNOWN:
|
|
|
|
case FORMAT_PTR:
|
|
|
|
vto[i].data.ptr = va_arg(arglist, void *);
|
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2011-04-20 09:17:42 -04:00
|
|
|
case FORMAT_INT:
|
2008-08-20 20:06:15 -04:00
|
|
|
#ifdef HAVE_LONG_LONG_TYPE
|
2011-04-20 09:17:42 -04:00
|
|
|
if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
|
|
|
|
vto[i].data.num.as_unsigned =
|
|
|
|
(mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
|
|
|
|
else if(vto[i].flags & FLAGS_LONGLONG)
|
|
|
|
vto[i].data.num.as_signed =
|
|
|
|
(mp_intmax_t)va_arg(arglist, mp_intmax_t);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
|
2008-08-24 19:21:46 -04:00
|
|
|
vto[i].data.num.as_unsigned =
|
2011-04-20 09:17:42 -04:00
|
|
|
(mp_uintmax_t)va_arg(arglist, unsigned long);
|
|
|
|
else if(vto[i].flags & FLAGS_LONG)
|
2008-08-24 19:21:46 -04:00
|
|
|
vto[i].data.num.as_signed =
|
2011-04-20 09:17:42 -04:00
|
|
|
(mp_intmax_t)va_arg(arglist, long);
|
|
|
|
else if(vto[i].flags & FLAGS_UNSIGNED)
|
|
|
|
vto[i].data.num.as_unsigned =
|
|
|
|
(mp_uintmax_t)va_arg(arglist, unsigned int);
|
2004-06-24 07:54:11 -04:00
|
|
|
else
|
2011-04-20 09:17:42 -04:00
|
|
|
vto[i].data.num.as_signed =
|
|
|
|
(mp_intmax_t)va_arg(arglist, int);
|
|
|
|
}
|
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2011-04-20 09:17:42 -04:00
|
|
|
case FORMAT_DOUBLE:
|
|
|
|
vto[i].data.dnum = va_arg(arglist, double);
|
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2011-04-20 09:17:42 -04:00
|
|
|
case FORMAT_WIDTH:
|
|
|
|
/* Argument has been read. Silently convert it into an integer
|
|
|
|
* for later use
|
|
|
|
*/
|
|
|
|
vto[i].type = FORMAT_INT;
|
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2011-04-20 09:17:42 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
2016-10-08 14:47:04 -04:00
|
|
|
return 0;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dprintf_formatf(
|
2004-05-12 08:05:13 -04:00
|
|
|
void *data, /* untouched by format(), just sent to the stream() function in
|
|
|
|
the second argument */
|
|
|
|
/* function pointer called for each output character */
|
|
|
|
int (*stream)(int, FILE *),
|
|
|
|
const char *format, /* %-formatted string */
|
|
|
|
va_list ap_save) /* list of parameters */
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
/* Base-36 digits for numbers. */
|
|
|
|
const char *digits = lower_digits;
|
|
|
|
|
|
|
|
/* Pointer into the format string. */
|
|
|
|
char *f;
|
|
|
|
|
|
|
|
/* Number of characters written. */
|
2004-03-08 06:28:14 -05:00
|
|
|
int done = 0;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
long param; /* current parameter to read */
|
|
|
|
long param_num=0; /* parameter counter */
|
|
|
|
|
|
|
|
va_stack_t vto[MAX_PARAMETERS];
|
|
|
|
char *endpos[MAX_PARAMETERS];
|
|
|
|
char **end;
|
|
|
|
|
|
|
|
char work[BUFFSIZE];
|
|
|
|
|
|
|
|
va_stack_t *p;
|
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
/* 'workend' points to the final buffer byte position, but with an extra
|
|
|
|
byte as margin to avoid the (false?) warning Coverity gives us
|
|
|
|
otherwise */
|
|
|
|
char *workend = &work[sizeof(work) - 2];
|
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Do the actual %-code parsing */
|
2016-10-08 14:47:04 -04:00
|
|
|
if(dprintf_Pass1(format, vto, endpos, ap_save))
|
|
|
|
return -1;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
end = &endpos[0]; /* the initial end-position from the list dprintf_Pass1()
|
|
|
|
created for us */
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
f = (char *)format;
|
2007-11-05 04:45:09 -05:00
|
|
|
while(*f != '\0') {
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Format spec modifiers. */
|
2008-08-22 02:53:01 -04:00
|
|
|
int is_alt;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Width of a field. */
|
2004-02-26 07:32:29 -05:00
|
|
|
long width;
|
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Precision of a field. */
|
|
|
|
long prec;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Decimal integer is negative. */
|
2008-08-20 21:49:19 -04:00
|
|
|
int is_neg;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Base of a number to be written. */
|
|
|
|
long base;
|
|
|
|
|
|
|
|
/* Integral values to be written. */
|
2008-08-22 07:11:33 -04:00
|
|
|
mp_uintmax_t num;
|
|
|
|
|
|
|
|
/* Used to convert negative in positive. */
|
|
|
|
mp_intmax_t signed_num;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
char *w;
|
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(*f != '%') {
|
1999-12-29 09:20:26 -05:00
|
|
|
/* This isn't a format spec, so write everything out until the next one
|
2004-06-24 07:54:11 -04:00
|
|
|
OR end of string is reached. */
|
1999-12-29 09:20:26 -05:00
|
|
|
do {
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(*f);
|
1999-12-29 09:20:26 -05:00
|
|
|
} while(*++f && ('%' != *f));
|
|
|
|
continue;
|
|
|
|
}
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
++f;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Check for "%%". Note that although the ANSI standard lists
|
|
|
|
'%' as a conversion specifier, it says "The complete format
|
|
|
|
specification shall be `%%'," so we can avoid all the width
|
|
|
|
and precision processing. */
|
2007-11-05 04:45:09 -05:00
|
|
|
if(*f == '%') {
|
1999-12-29 09:20:26 -05:00
|
|
|
++f;
|
|
|
|
OUTCHAR('%');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-04-19 09:54:13 -04:00
|
|
|
/* If this is a positional parameter, the position must follow immediately
|
1999-12-29 09:20:26 -05:00
|
|
|
after the %, thus create a %<num>$ sequence */
|
|
|
|
param=dprintf_DollarString(f, &f);
|
|
|
|
|
|
|
|
if(!param)
|
|
|
|
param = param_num;
|
|
|
|
else
|
|
|
|
--param;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
param_num++; /* increase this always to allow "%2$s %1$s %s" and then the
|
2004-06-24 07:54:11 -04:00
|
|
|
third %s will pick the 3rd argument */
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
p = &vto[param];
|
|
|
|
|
|
|
|
/* pick up the specified width */
|
2016-03-09 02:59:05 -05:00
|
|
|
if(p->flags & FLAGS_WIDTHPARAM) {
|
2008-08-22 07:11:33 -04:00
|
|
|
width = (long)vto[p->width].data.num.as_signed;
|
2016-03-09 02:59:05 -05:00
|
|
|
param_num++; /* since the width is extracted from a parameter, we
|
|
|
|
must skip that to get to the next one properly */
|
|
|
|
if(width < 0) {
|
|
|
|
/* "A negative field width is taken as a '-' flag followed by a
|
|
|
|
positive field width." */
|
|
|
|
width = -width;
|
|
|
|
p->flags |= FLAGS_LEFT;
|
|
|
|
p->flags &= ~FLAGS_PAD_NIL;
|
|
|
|
}
|
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
else
|
|
|
|
width = p->width;
|
|
|
|
|
|
|
|
/* pick up the specified precision */
|
2007-11-20 05:03:33 -05:00
|
|
|
if(p->flags & FLAGS_PRECPARAM) {
|
2008-08-22 07:11:33 -04:00
|
|
|
prec = (long)vto[p->precision].data.num.as_signed;
|
2016-03-09 02:59:05 -05:00
|
|
|
param_num++; /* since the precision is extracted from a parameter, we
|
2007-11-20 05:03:33 -05:00
|
|
|
must skip that to get to the next one properly */
|
2016-03-09 02:59:05 -05:00
|
|
|
if(prec < 0)
|
|
|
|
/* "A negative precision is taken as if the precision were
|
|
|
|
omitted." */
|
|
|
|
prec = -1;
|
2007-11-20 05:03:33 -05:00
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
else if(p->flags & FLAGS_PREC)
|
|
|
|
prec = p->precision;
|
|
|
|
else
|
|
|
|
prec = -1;
|
|
|
|
|
2008-08-22 22:35:16 -04:00
|
|
|
is_alt = (p->flags & FLAGS_ALT) ? 1 : 0;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2016-12-13 17:34:59 -05:00
|
|
|
switch(p->type) {
|
1999-12-29 09:20:26 -05:00
|
|
|
case FORMAT_INT:
|
2008-08-22 07:11:33 -04:00
|
|
|
num = p->data.num.as_unsigned;
|
1999-12-29 09:20:26 -05:00
|
|
|
if(p->flags & FLAGS_CHAR) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* Character. */
|
2007-11-05 04:45:09 -05:00
|
|
|
if(!(p->flags & FLAGS_LEFT))
|
|
|
|
while(--width > 0)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(' ');
|
|
|
|
OUTCHAR((char) num);
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_LEFT)
|
|
|
|
while(--width > 0)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(' ');
|
|
|
|
break;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
if(p->flags & FLAGS_OCTAL) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* Octal unsigned integer. */
|
|
|
|
base = 8;
|
|
|
|
goto unsigned_number;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
2013-06-25 03:52:06 -04:00
|
|
|
else if(p->flags & FLAGS_HEX) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* Hexadecimal unsigned integer. */
|
1999-12-29 09:20:26 -05:00
|
|
|
|
2004-06-24 07:54:11 -04:00
|
|
|
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
|
|
|
|
base = 16;
|
|
|
|
goto unsigned_number;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
2013-06-25 03:52:06 -04:00
|
|
|
else if(p->flags & FLAGS_UNSIGNED) {
|
|
|
|
/* Decimal unsigned integer. */
|
|
|
|
base = 10;
|
|
|
|
goto unsigned_number;
|
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
/* Decimal integer. */
|
|
|
|
base = 10;
|
|
|
|
|
2008-08-24 19:21:46 -04:00
|
|
|
is_neg = (p->data.num.as_signed < (mp_intmax_t)0) ? 1 : 0;
|
2008-08-22 07:11:33 -04:00
|
|
|
if(is_neg) {
|
|
|
|
/* signed_num might fail to hold absolute negative minimum by 1 */
|
2008-08-24 19:21:46 -04:00
|
|
|
signed_num = p->data.num.as_signed + (mp_intmax_t)1;
|
2008-08-23 23:59:43 -04:00
|
|
|
signed_num = -signed_num;
|
|
|
|
num = (mp_uintmax_t)signed_num;
|
2008-08-24 19:21:46 -04:00
|
|
|
num += (mp_uintmax_t)1;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
2008-08-22 07:11:33 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
goto number;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2004-06-24 07:54:11 -04:00
|
|
|
unsigned_number:
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Unsigned number of base BASE. */
|
|
|
|
is_neg = 0;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
2004-06-24 07:54:11 -04:00
|
|
|
number:
|
1999-12-29 09:20:26 -05:00
|
|
|
/* Number of base BASE. */
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
/* Supply a default precision if none was given. */
|
|
|
|
if(prec == -1)
|
|
|
|
prec = 1;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
/* Put the number in WORK. */
|
|
|
|
w = workend;
|
|
|
|
while(num > 0) {
|
|
|
|
*w-- = digits[num % base];
|
|
|
|
num /= base;
|
|
|
|
}
|
|
|
|
width -= (long)(workend - w);
|
|
|
|
prec -= (long)(workend - w);
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(is_alt && base == 8 && prec <= 0) {
|
|
|
|
*w-- = '0';
|
|
|
|
--width;
|
|
|
|
}
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(prec > 0) {
|
|
|
|
width -= prec;
|
|
|
|
while(prec-- > 0)
|
|
|
|
*w-- = '0';
|
|
|
|
}
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(is_alt && base == 16)
|
|
|
|
width -= 2;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
|
|
|
|
--width;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
|
|
|
|
while(width-- > 0)
|
|
|
|
OUTCHAR(' ');
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(is_neg)
|
|
|
|
OUTCHAR('-');
|
|
|
|
else if(p->flags & FLAGS_SHOWSIGN)
|
|
|
|
OUTCHAR('+');
|
|
|
|
else if(p->flags & FLAGS_SPACE)
|
|
|
|
OUTCHAR(' ');
|
|
|
|
|
|
|
|
if(is_alt && base == 16) {
|
|
|
|
OUTCHAR('0');
|
|
|
|
if(p->flags & FLAGS_UPPER)
|
|
|
|
OUTCHAR('X');
|
|
|
|
else
|
|
|
|
OUTCHAR('x');
|
|
|
|
}
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
|
|
|
|
while(width-- > 0)
|
|
|
|
OUTCHAR('0');
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2016-05-17 03:06:32 -04:00
|
|
|
/* Write the number. */
|
|
|
|
while(++w <= workend) {
|
|
|
|
OUTCHAR(*w);
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
2016-05-17 03:06:32 -04:00
|
|
|
|
|
|
|
if(p->flags & FLAGS_LEFT)
|
|
|
|
while(width-- > 0)
|
|
|
|
OUTCHAR(' ');
|
1999-12-29 09:20:26 -05:00
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
case FORMAT_STRING:
|
2004-06-24 07:54:11 -04:00
|
|
|
/* String. */
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
2004-12-14 20:38:25 -05:00
|
|
|
static const char null[] = "(nil)";
|
|
|
|
const char *str;
|
2004-06-24 07:54:11 -04:00
|
|
|
size_t len;
|
|
|
|
|
|
|
|
str = (char *) p->data.str;
|
2011-04-22 17:01:30 -04:00
|
|
|
if(str == NULL) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* Write null[] if there's space. */
|
2007-11-05 04:45:09 -05:00
|
|
|
if(prec == -1 || prec >= (long) sizeof(null) - 1) {
|
2004-06-24 07:54:11 -04:00
|
|
|
str = null;
|
|
|
|
len = sizeof(null) - 1;
|
|
|
|
/* Disable quotes around (nil) */
|
|
|
|
p->flags &= (~FLAGS_ALT);
|
|
|
|
}
|
|
|
|
else {
|
2004-12-14 20:38:25 -05:00
|
|
|
str = "";
|
2004-06-24 07:54:11 -04:00
|
|
|
len = 0;
|
|
|
|
}
|
|
|
|
}
|
2014-05-04 17:37:24 -04:00
|
|
|
else if(prec != -1)
|
|
|
|
len = (size_t)prec;
|
2004-06-24 07:54:11 -04:00
|
|
|
else
|
|
|
|
len = strlen(str);
|
|
|
|
|
2016-03-09 02:59:05 -05:00
|
|
|
width -= (len > LONG_MAX) ? LONG_MAX : (long)len;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_ALT)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR('"');
|
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(!(p->flags&FLAGS_LEFT))
|
|
|
|
while(width-- > 0)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(' ');
|
|
|
|
|
2014-05-04 17:37:24 -04:00
|
|
|
while((len-- > 0) && *str)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(*str++);
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags&FLAGS_LEFT)
|
|
|
|
while(width-- > 0)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(' ');
|
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_ALT)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR('"');
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
break;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
case FORMAT_PTR:
|
|
|
|
/* Generic pointer. */
|
|
|
|
{
|
2004-06-24 07:54:11 -04:00
|
|
|
void *ptr;
|
|
|
|
ptr = (void *) p->data.ptr;
|
2007-11-05 04:45:09 -05:00
|
|
|
if(ptr != NULL) {
|
2004-06-24 07:54:11 -04:00
|
|
|
/* If the pointer is not NULL, write it as a %#x spec. */
|
|
|
|
base = 16;
|
|
|
|
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
|
2008-08-22 02:53:01 -04:00
|
|
|
is_alt = 1;
|
2005-04-26 09:08:49 -04:00
|
|
|
num = (size_t) ptr;
|
2004-06-24 07:54:11 -04:00
|
|
|
is_neg = 0;
|
|
|
|
goto number;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Write "(nil)" for a nil pointer. */
|
2004-12-14 20:38:25 -05:00
|
|
|
static const char strnil[] = "(nil)";
|
|
|
|
const char *point;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2010-02-20 06:58:26 -05:00
|
|
|
width -= (long)(sizeof(strnil) - 1);
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_LEFT)
|
|
|
|
while(width-- > 0)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(' ');
|
2011-04-20 09:17:42 -04:00
|
|
|
for(point = strnil; *point != '\0'; ++point)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(*point);
|
2007-11-05 04:45:09 -05:00
|
|
|
if(! (p->flags & FLAGS_LEFT))
|
|
|
|
while(width-- > 0)
|
2004-06-24 07:54:11 -04:00
|
|
|
OUTCHAR(' ');
|
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FORMAT_DOUBLE:
|
|
|
|
{
|
2004-06-24 07:54:11 -04:00
|
|
|
char formatbuf[32]="%";
|
2013-03-06 07:27:51 -05:00
|
|
|
char *fptr = &formatbuf[1];
|
2004-06-24 07:54:11 -04:00
|
|
|
size_t left = sizeof(formatbuf)-strlen(formatbuf);
|
|
|
|
int len;
|
|
|
|
|
|
|
|
width = -1;
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_WIDTH)
|
2004-06-24 07:54:11 -04:00
|
|
|
width = p->width;
|
2007-11-05 04:45:09 -05:00
|
|
|
else if(p->flags & FLAGS_WIDTHPARAM)
|
2008-08-22 07:11:33 -04:00
|
|
|
width = (long)vto[p->width].data.num.as_signed;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
|
|
|
prec = -1;
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_PREC)
|
2004-06-24 07:54:11 -04:00
|
|
|
prec = p->precision;
|
2007-11-05 04:45:09 -05:00
|
|
|
else if(p->flags & FLAGS_PRECPARAM)
|
2008-08-22 07:11:33 -04:00
|
|
|
prec = (long)vto[p->precision].data.num.as_signed;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_LEFT)
|
2013-03-06 07:27:51 -05:00
|
|
|
*fptr++ = '-';
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_SHOWSIGN)
|
2013-03-06 07:27:51 -05:00
|
|
|
*fptr++ = '+';
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_SPACE)
|
2013-03-06 07:27:51 -05:00
|
|
|
*fptr++ = ' ';
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_ALT)
|
2013-03-06 07:27:51 -05:00
|
|
|
*fptr++ = '#';
|
2004-06-24 07:54:11 -04:00
|
|
|
|
2013-03-06 07:27:51 -05:00
|
|
|
*fptr = 0;
|
2004-06-24 07:54:11 -04:00
|
|
|
|
|
|
|
if(width >= 0) {
|
2016-11-08 09:32:37 -05:00
|
|
|
if(width >= (long)sizeof(work))
|
|
|
|
width = sizeof(work)-1;
|
2004-06-24 07:54:11 -04:00
|
|
|
/* RECURSIVE USAGE */
|
|
|
|
len = curl_msnprintf(fptr, left, "%ld", width);
|
|
|
|
fptr += len;
|
|
|
|
left -= len;
|
|
|
|
}
|
|
|
|
if(prec >= 0) {
|
2016-11-08 09:32:37 -05:00
|
|
|
/* for each digit in the integer part, we can have one less
|
|
|
|
precision */
|
|
|
|
size_t maxprec = sizeof(work) - 2;
|
|
|
|
double val = p->data.dnum;
|
|
|
|
while(val >= 10.0) {
|
|
|
|
val /= 10;
|
|
|
|
maxprec--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prec > (long)maxprec)
|
2016-12-21 05:05:13 -05:00
|
|
|
prec = (long)maxprec-1;
|
2004-06-24 07:54:11 -04:00
|
|
|
/* RECURSIVE USAGE */
|
|
|
|
len = curl_msnprintf(fptr, left, ".%ld", prec);
|
|
|
|
fptr += len;
|
|
|
|
}
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_LONG)
|
2004-06-24 07:54:11 -04:00
|
|
|
*fptr++ = 'l';
|
|
|
|
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_FLOATE)
|
2007-01-31 20:42:13 -05:00
|
|
|
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
|
2007-11-05 04:45:09 -05:00
|
|
|
else if(p->flags & FLAGS_FLOATG)
|
2007-01-31 20:42:13 -05:00
|
|
|
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
|
2004-06-24 07:54:11 -04:00
|
|
|
else
|
|
|
|
*fptr++ = 'f';
|
|
|
|
|
|
|
|
*fptr = 0; /* and a final zero termination */
|
|
|
|
|
2013-03-06 07:27:51 -05:00
|
|
|
/* NOTE NOTE NOTE!! Not all sprintf implementations return number of
|
|
|
|
output characters */
|
2004-06-24 03:43:48 -04:00
|
|
|
(sprintf)(work, formatbuf, p->data.dnum);
|
2016-11-08 09:32:37 -05:00
|
|
|
#ifdef CURLDEBUG
|
|
|
|
assert(strlen(work) <= sizeof(work));
|
|
|
|
#endif
|
2004-06-24 07:54:11 -04:00
|
|
|
for(fptr=work; *fptr; fptr++)
|
|
|
|
OUTCHAR(*fptr);
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FORMAT_INTPTR:
|
|
|
|
/* Answer the count of characters written. */
|
2008-08-20 20:06:15 -04:00
|
|
|
#ifdef HAVE_LONG_LONG_TYPE
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_LONGLONG)
|
2008-08-20 20:06:15 -04:00
|
|
|
*(LONG_LONG_TYPE *) p->data.ptr = (LONG_LONG_TYPE)done;
|
1999-12-29 09:20:26 -05:00
|
|
|
else
|
|
|
|
#endif
|
2007-11-05 04:45:09 -05:00
|
|
|
if(p->flags & FLAGS_LONG)
|
2004-06-24 07:54:11 -04:00
|
|
|
*(long *) p->data.ptr = (long)done;
|
2007-11-05 04:45:09 -05:00
|
|
|
else if(!(p->flags & FLAGS_SHORT))
|
2004-06-24 07:54:11 -04:00
|
|
|
*(int *) p->data.ptr = (int)done;
|
1999-12-29 09:20:26 -05:00
|
|
|
else
|
2004-06-24 07:54:11 -04:00
|
|
|
*(short *) p->data.ptr = (short)done;
|
1999-12-29 09:20:26 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
f = *end++; /* goto end of %-code */
|
|
|
|
|
|
|
|
}
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fputc() look-alike */
|
2004-11-08 09:20:14 -05:00
|
|
|
static int addbyter(int output, FILE *data)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
struct nsprintf *infop=(struct nsprintf *)data;
|
2004-05-12 08:05:13 -04:00
|
|
|
unsigned char outc = (unsigned char)output;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
if(infop->length < infop->max) {
|
|
|
|
/* only do this if we haven't reached max length yet */
|
2004-05-12 08:05:13 -04:00
|
|
|
infop->buffer[0] = outc; /* store */
|
2000-11-15 10:36:41 -05:00
|
|
|
infop->buffer++; /* increase pointer */
|
|
|
|
infop->length++; /* we are now one byte larger */
|
2004-05-12 08:05:13 -04:00
|
|
|
return outc; /* fputc() returns like this on success */
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2003-10-26 10:37:45 -05:00
|
|
|
int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format,
|
|
|
|
va_list ap_save)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
int retcode;
|
|
|
|
struct nsprintf info;
|
|
|
|
|
|
|
|
info.buffer = buffer;
|
|
|
|
info.length = 0;
|
|
|
|
info.max = maxlength;
|
|
|
|
|
|
|
|
retcode = dprintf_formatf(&info, addbyter, format, ap_save);
|
2016-10-08 14:47:04 -04:00
|
|
|
if((retcode != -1) && info.max) {
|
2003-10-26 10:37:45 -05:00
|
|
|
/* we terminate this with a zero byte */
|
|
|
|
if(info.max == info.length)
|
|
|
|
/* we're at maximum, scrap the last letter */
|
|
|
|
info.buffer[-1] = 0;
|
|
|
|
else
|
|
|
|
info.buffer[0] = 0;
|
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
2003-10-26 10:37:45 -05:00
|
|
|
int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
int retcode;
|
2003-10-26 10:37:45 -05:00
|
|
|
va_list ap_save; /* argument pointer */
|
|
|
|
va_start(ap_save, format);
|
|
|
|
retcode = curl_mvsnprintf(buffer, maxlength, format, ap_save);
|
|
|
|
va_end(ap_save);
|
1999-12-29 09:20:26 -05:00
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fputc() look-alike */
|
2004-11-08 09:20:14 -05:00
|
|
|
static int alloc_addbyter(int output, FILE *data)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
struct asprintf *infop=(struct asprintf *)data;
|
2004-05-12 08:05:13 -04:00
|
|
|
unsigned char outc = (unsigned char)output;
|
2004-06-24 03:43:48 -04:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
if(!infop->buffer) {
|
2008-09-06 01:29:05 -04:00
|
|
|
infop->buffer = malloc(32);
|
2004-05-10 06:50:43 -04:00
|
|
|
if(!infop->buffer) {
|
2008-08-22 02:53:01 -04:00
|
|
|
infop->fail = 1;
|
1999-12-29 09:20:26 -05:00
|
|
|
return -1; /* fail */
|
2004-05-10 06:50:43 -04:00
|
|
|
}
|
1999-12-29 09:20:26 -05:00
|
|
|
infop->alloc = 32;
|
|
|
|
infop->len =0;
|
|
|
|
}
|
|
|
|
else if(infop->len+1 >= infop->alloc) {
|
2016-09-28 04:15:34 -04:00
|
|
|
char *newptr = NULL;
|
|
|
|
size_t newsize = infop->alloc*2;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
2016-09-28 04:15:34 -04:00
|
|
|
/* detect wrap-around or other overflow problems */
|
|
|
|
if(newsize > infop->alloc)
|
|
|
|
newptr = realloc(infop->buffer, newsize);
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
if(!newptr) {
|
2008-08-22 02:53:01 -04:00
|
|
|
infop->fail = 1;
|
|
|
|
return -1; /* fail */
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
infop->buffer = newptr;
|
2016-09-28 04:15:34 -04:00
|
|
|
infop->alloc = newsize;
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
2004-05-12 08:05:13 -04:00
|
|
|
infop->buffer[ infop->len ] = outc;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
infop->len++;
|
|
|
|
|
2004-05-12 08:05:13 -04:00
|
|
|
return outc; /* fputc() returns like this on success */
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
char *curl_maprintf(const char *format, ...)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
va_list ap_save; /* argument pointer */
|
|
|
|
int retcode;
|
|
|
|
struct asprintf info;
|
|
|
|
|
|
|
|
info.buffer = NULL;
|
|
|
|
info.len = 0;
|
|
|
|
info.alloc = 0;
|
2008-08-22 02:53:01 -04:00
|
|
|
info.fail = 0;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
va_start(ap_save, format);
|
|
|
|
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
|
|
|
|
va_end(ap_save);
|
2004-05-10 06:50:43 -04:00
|
|
|
if((-1 == retcode) || info.fail) {
|
2002-05-21 13:59:57 -04:00
|
|
|
if(info.alloc)
|
|
|
|
free(info.buffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if(info.alloc) {
|
1999-12-29 09:20:26 -05:00
|
|
|
info.buffer[info.len] = 0; /* we terminate this with a zero byte */
|
|
|
|
return info.buffer;
|
|
|
|
}
|
2017-03-10 08:28:37 -05:00
|
|
|
return strdup("");
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
char *curl_mvaprintf(const char *format, va_list ap_save)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
int retcode;
|
|
|
|
struct asprintf info;
|
|
|
|
|
|
|
|
info.buffer = NULL;
|
|
|
|
info.len = 0;
|
|
|
|
info.alloc = 0;
|
2008-08-22 02:53:01 -04:00
|
|
|
info.fail = 0;
|
1999-12-29 09:20:26 -05:00
|
|
|
|
|
|
|
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
|
2004-05-10 06:50:43 -04:00
|
|
|
if((-1 == retcode) || info.fail) {
|
2002-05-21 13:59:57 -04:00
|
|
|
if(info.alloc)
|
|
|
|
free(info.buffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(info.alloc) {
|
1999-12-29 09:20:26 -05:00
|
|
|
info.buffer[info.len] = 0; /* we terminate this with a zero byte */
|
|
|
|
return info.buffer;
|
|
|
|
}
|
2017-03-10 08:28:37 -05:00
|
|
|
return strdup("");
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
2004-11-08 09:20:14 -05:00
|
|
|
static int storebuffer(int output, FILE *data)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
char **buffer = (char **)data;
|
2004-05-12 08:05:13 -04:00
|
|
|
unsigned char outc = (unsigned char)output;
|
|
|
|
**buffer = outc;
|
1999-12-29 09:20:26 -05:00
|
|
|
(*buffer)++;
|
2004-05-12 08:05:13 -04:00
|
|
|
return outc; /* act like fputc() ! */
|
1999-12-29 09:20:26 -05:00
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
int curl_msprintf(char *buffer, const char *format, ...)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
va_list ap_save; /* argument pointer */
|
|
|
|
int retcode;
|
|
|
|
va_start(ap_save, format);
|
|
|
|
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
|
|
|
|
va_end(ap_save);
|
|
|
|
*buffer=0; /* we terminate this with a zero byte */
|
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
int curl_mprintf(const char *format, ...)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
int retcode;
|
|
|
|
va_list ap_save; /* argument pointer */
|
|
|
|
va_start(ap_save, format);
|
2004-11-02 05:12:22 -05:00
|
|
|
|
1999-12-29 09:20:26 -05:00
|
|
|
retcode = dprintf_formatf(stdout, fputc, format, ap_save);
|
|
|
|
va_end(ap_save);
|
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
int curl_mfprintf(FILE *whereto, const char *format, ...)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
int retcode;
|
|
|
|
va_list ap_save; /* argument pointer */
|
|
|
|
va_start(ap_save, format);
|
|
|
|
retcode = dprintf_formatf(whereto, fputc, format, ap_save);
|
|
|
|
va_end(ap_save);
|
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
int curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
int retcode;
|
|
|
|
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
|
|
|
|
*buffer=0; /* we terminate this with a zero byte */
|
|
|
|
return retcode;
|
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
int curl_mvprintf(const char *format, va_list ap_save)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
return dprintf_formatf(stdout, fputc, format, ap_save);
|
|
|
|
}
|
|
|
|
|
2001-01-05 07:19:42 -05:00
|
|
|
int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
|
1999-12-29 09:20:26 -05:00
|
|
|
{
|
|
|
|
return dprintf_formatf(whereto, fputc, format, ap_save);
|
|
|
|
}
|