|
@@ -104,13 +104,13 @@
|
|
|
#include <printf.h>
|
|
|
|
|
|
#ifdef __UCLIBC_HAS_THREADS__
|
|
|
-#include <stdio_ext.h>
|
|
|
-#include <pthread.h>
|
|
|
-#endif
|
|
|
+# include <stdio_ext.h>
|
|
|
+# include <pthread.h>
|
|
|
+#endif
|
|
|
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
-#include <wchar.h>
|
|
|
-#endif
|
|
|
+# include <wchar.h>
|
|
|
+#endif
|
|
|
|
|
|
#include <bits/uClibc_uintmaxtostr.h>
|
|
|
#include <bits/uClibc_va_copy.h>
|
|
@@ -136,24 +136,24 @@
|
|
|
|
|
|
|
|
|
#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_FLOATS__)
|
|
|
-#undef __STDIO_PRINTF_FLOAT
|
|
|
+# undef __STDIO_PRINTF_FLOAT
|
|
|
#endif
|
|
|
|
|
|
#ifdef __BCC__
|
|
|
-#undef __STDIO_PRINTF_FLOAT
|
|
|
+# undef __STDIO_PRINTF_FLOAT
|
|
|
#endif
|
|
|
|
|
|
#ifdef __STDIO_PRINTF_FLOAT
|
|
|
-#include <float.h>
|
|
|
-#include <bits/uClibc_fpmax.h>
|
|
|
-#else
|
|
|
-#undef L__fpmaxtostr
|
|
|
-#endif
|
|
|
+# include <float.h>
|
|
|
+# include <bits/uClibc_fpmax.h>
|
|
|
+#else
|
|
|
+# undef L__fpmaxtostr
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
#undef __STDIO_HAS_VSNPRINTF
|
|
|
#if defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
|
|
|
-#define __STDIO_HAS_VSNPRINTF 1
|
|
|
+# define __STDIO_HAS_VSNPRINTF 1
|
|
|
#endif
|
|
|
|
|
|
|
|
@@ -162,40 +162,36 @@
|
|
|
|
|
|
|
|
|
#ifdef __UCLIBC_MJN3_ONLY__
|
|
|
-#ifdef L_register_printf_function
|
|
|
+# ifdef L_register_printf_function
|
|
|
|
|
|
-#warning WISHLIST: Make MAX_USER_SPEC configurable?
|
|
|
-#warning WISHLIST: Make MAX_ARGS_PER_SPEC configurable?
|
|
|
+# warning WISHLIST: Make MAX_USER_SPEC configurable?
|
|
|
+# warning WISHLIST: Make MAX_ARGS_PER_SPEC configurable?
|
|
|
+# endif
|
|
|
#endif
|
|
|
-#endif
|
|
|
|
|
|
#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
|
|
|
-
|
|
|
-#define MAX_USER_SPEC 10
|
|
|
-#define MAX_ARGS_PER_SPEC 5
|
|
|
-
|
|
|
-#else
|
|
|
-
|
|
|
-#undef MAX_USER_SPEC
|
|
|
-#define MAX_ARGS_PER_SPEC 1
|
|
|
-
|
|
|
-#endif
|
|
|
+# define MAX_USER_SPEC 10
|
|
|
+# define MAX_ARGS_PER_SPEC 5
|
|
|
+#else
|
|
|
+# undef MAX_USER_SPEC
|
|
|
+# define MAX_ARGS_PER_SPEC 1
|
|
|
+#endif
|
|
|
|
|
|
#if MAX_ARGS_PER_SPEC < 1
|
|
|
-#error MAX_ARGS_PER_SPEC < 1!
|
|
|
-#undef MAX_ARGS_PER_SPEC
|
|
|
-#define MAX_ARGS_PER_SPEC 1
|
|
|
+# error MAX_ARGS_PER_SPEC < 1!
|
|
|
+# undef MAX_ARGS_PER_SPEC
|
|
|
+# define MAX_ARGS_PER_SPEC 1
|
|
|
#endif
|
|
|
|
|
|
#if defined(NL_ARGMAX) && (NL_ARGMAX < 9)
|
|
|
-#error NL_ARGMAX < 9!
|
|
|
+# error NL_ARGMAX < 9!
|
|
|
#endif
|
|
|
|
|
|
#if defined(NL_ARGMAX) && (NL_ARGMAX >= (MAX_ARGS_PER_SPEC + 2))
|
|
|
-#define MAX_ARGS NL_ARGMAX
|
|
|
+# define MAX_ARGS NL_ARGMAX
|
|
|
#else
|
|
|
|
|
|
-#define MAX_ARGS (MAX_ARGS_PER_SPEC + 2)
|
|
|
+# define MAX_ARGS (MAX_ARGS_PER_SPEC + 2)
|
|
|
#endif
|
|
|
|
|
|
|
|
@@ -207,20 +203,20 @@
|
|
|
extern printf_function _custom_printf_handler[MAX_USER_SPEC] attribute_hidden;
|
|
|
extern printf_arginfo_function *_custom_printf_arginfo[MAX_USER_SPEC] attribute_hidden;
|
|
|
extern char *_custom_printf_spec attribute_hidden;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define SPEC_FLAGS " +0-#'I"
|
|
|
enum {
|
|
|
- FLAG_SPACE = 0x01,
|
|
|
- FLAG_PLUS = 0x02,
|
|
|
- FLAG_ZERO = 0x04,
|
|
|
- FLAG_MINUS = 0x08,
|
|
|
- FLAG_HASH = 0x10,
|
|
|
- FLAG_THOUSANDS = 0x20,
|
|
|
- FLAG_I18N = 0x40,
|
|
|
- FLAG_WIDESTREAM = 0x80
|
|
|
+ FLAG_SPACE = 0x01,
|
|
|
+ FLAG_PLUS = 0x02,
|
|
|
+ FLAG_ZERO = 0x04,
|
|
|
+ FLAG_MINUS = 0x08,
|
|
|
+ FLAG_HASH = 0x10,
|
|
|
+ FLAG_THOUSANDS = 0x20,
|
|
|
+ FLAG_I18N = 0x40,
|
|
|
+ FLAG_WIDESTREAM = 0x80
|
|
|
};
|
|
|
|
|
|
|
|
@@ -240,10 +236,10 @@ enum {
|
|
|
};
|
|
|
|
|
|
|
|
|
-#define SPEC_BASE { 16, 16, 16, 8, 10, 10, 10 }
|
|
|
+#define SPEC_BASE { 16, 16, 16, 8, 10, 10, 10 }
|
|
|
|
|
|
-#define SPEC_RANGES { CONV_n, CONV_p, CONV_i, CONV_A, \
|
|
|
- CONV_C, CONV_S, CONV_c, CONV_s, CONV_custom0 }
|
|
|
+#define SPEC_RANGES { CONV_n, CONV_p, CONV_i, CONV_A, \
|
|
|
+ CONV_C, CONV_S, CONV_c, CONV_s, CONV_custom0 }
|
|
|
|
|
|
#define SPEC_OR_MASK { \
|
|
|
(PA_FLAG_PTR|PA_INT), \
|
|
@@ -284,43 +280,43 @@ enum {
|
|
|
|
|
|
|
|
|
#ifdef PDS
|
|
|
-#error PDS already defined!
|
|
|
+# error PDS already defined!
|
|
|
#endif
|
|
|
#ifdef SS
|
|
|
-#error SS already defined!
|
|
|
+# error SS already defined!
|
|
|
#endif
|
|
|
#ifdef IMS
|
|
|
-#error IMS already defined!
|
|
|
+# error IMS already defined!
|
|
|
#endif
|
|
|
|
|
|
#if PTRDIFF_MAX == INT_MAX
|
|
|
-#define PDS 0
|
|
|
+# define PDS 0
|
|
|
#elif PTRDIFF_MAX == LONG_MAX
|
|
|
-#define PDS 4
|
|
|
+# define PDS 4
|
|
|
#elif defined(LLONG_MAX) && (PTRDIFF_MAX == LLONG_MAX)
|
|
|
-#define PDS 8
|
|
|
+# define PDS 8
|
|
|
#else
|
|
|
-#error fix QUAL_CHARS ptrdiff_t entry 't'!
|
|
|
+# error fix QUAL_CHARS ptrdiff_t entry 't'!
|
|
|
#endif
|
|
|
|
|
|
#if SIZE_MAX == UINT_MAX
|
|
|
-#define SS 0
|
|
|
+# define SS 0
|
|
|
#elif SIZE_MAX == ULONG_MAX
|
|
|
-#define SS 4
|
|
|
+# define SS 4
|
|
|
#elif defined(LLONG_MAX) && (SIZE_MAX == ULLONG_MAX)
|
|
|
-#define SS 8
|
|
|
+# define SS 8
|
|
|
#else
|
|
|
-#error fix QUAL_CHARS size_t entries 'z', 'Z'!
|
|
|
+# error fix QUAL_CHARS size_t entries 'z', 'Z'!
|
|
|
#endif
|
|
|
|
|
|
#if INTMAX_MAX == INT_MAX
|
|
|
-#define IMS 0
|
|
|
+# define IMS 0
|
|
|
#elif INTMAX_MAX == LONG_MAX
|
|
|
-#define IMS 4
|
|
|
+# define IMS 4
|
|
|
#elif defined(LLONG_MAX) && (INTMAX_MAX == LLONG_MAX)
|
|
|
-#define IMS 8
|
|
|
+# define IMS 8
|
|
|
#else
|
|
|
-#error fix QUAL_CHARS intmax_t entry 'j'!
|
|
|
+# error fix QUAL_CHARS intmax_t entry 'j'!
|
|
|
#endif
|
|
|
|
|
|
#define QUAL_CHARS { \
|
|
@@ -334,45 +330,46 @@ enum {
|
|
|
|
|
|
|
|
|
#ifdef __STDIO_VA_ARG_PTR
|
|
|
-#ifdef __BCC__
|
|
|
-#define __va_arg_ptr(ap,type) (((type *)(ap += sizeof(type))) - 1)
|
|
|
-#endif
|
|
|
+# ifdef __BCC__
|
|
|
+# define __va_arg_ptr(ap,type) (((type *)(ap += sizeof(type))) - 1)
|
|
|
+# endif
|
|
|
|
|
|
-#if 1
|
|
|
-#ifdef __GNUC__
|
|
|
+# if 1
|
|
|
+# ifdef __GNUC__
|
|
|
|
|
|
|
|
|
-#ifndef __va_rounded_size
|
|
|
-#define __va_rounded_size(TYPE) \
|
|
|
- (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
|
|
|
-#endif
|
|
|
-#define __va_arg_ptr(AP, TYPE) \
|
|
|
- (AP = (va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
|
|
|
- ((void *) ((char *) (AP) - __va_rounded_size (TYPE))))
|
|
|
-#endif
|
|
|
-#endif
|
|
|
+# ifndef __va_rounded_size
|
|
|
+# define __va_rounded_size(TYPE) \
|
|
|
+ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
|
|
|
+# endif
|
|
|
+# define __va_arg_ptr(AP, TYPE) \
|
|
|
+ (AP = (va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
|
|
|
+ ((void *) ((char *) (AP) - __va_rounded_size (TYPE))) \
|
|
|
+ )
|
|
|
+# endif
|
|
|
+# endif
|
|
|
#endif
|
|
|
|
|
|
#ifdef __va_arg_ptr
|
|
|
-#define GET_VA_ARG(AP,F,TYPE,ARGS) (*(AP) = __va_arg_ptr(ARGS,TYPE))
|
|
|
-#define GET_ARG_VALUE(AP,F,TYPE) (*((TYPE *)(*(AP))))
|
|
|
+# define GET_VA_ARG(AP,F,TYPE,ARGS) (*(AP) = __va_arg_ptr(ARGS,TYPE))
|
|
|
+# define GET_ARG_VALUE(AP,F,TYPE) (*((TYPE *)(*(AP))))
|
|
|
#else
|
|
|
typedef union {
|
|
|
wchar_t wc;
|
|
|
unsigned int u;
|
|
|
unsigned long ul;
|
|
|
-#ifdef ULLONG_MAX
|
|
|
+# ifdef ULLONG_MAX
|
|
|
unsigned long long ull;
|
|
|
-#endif
|
|
|
-#ifdef __STDIO_PRINTF_FLOAT
|
|
|
+# endif
|
|
|
+# ifdef __STDIO_PRINTF_FLOAT
|
|
|
double d;
|
|
|
long double ld;
|
|
|
-#endif
|
|
|
+# endif
|
|
|
void *p;
|
|
|
} argvalue_t;
|
|
|
|
|
|
-#define GET_VA_ARG(AU,F,TYPE,ARGS) (AU->F = va_arg(ARGS,TYPE))
|
|
|
-#define GET_ARG_VALUE(AU,F,TYPE) ((TYPE)((AU)->F))
|
|
|
+# define GET_VA_ARG(AU,F,TYPE,ARGS) (AU->F = va_arg(ARGS,TYPE))
|
|
|
+# define GET_ARG_VALUE(AU,F,TYPE) ((TYPE)((AU)->F))
|
|
|
#endif
|
|
|
|
|
|
typedef struct {
|
|
@@ -380,7 +377,7 @@ typedef struct {
|
|
|
struct printf_info info;
|
|
|
#ifdef NL_ARGMAX
|
|
|
int maxposarg;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
int num_data_args;
|
|
|
unsigned int conv_num;
|
|
|
unsigned char argnumber[4];
|
|
@@ -436,7 +433,8 @@ size_t parse_printf_format(register const char *template,
|
|
|
|
|
|
if (_ppfs_init(&ppfs, template) >= 0) {
|
|
|
#ifdef NL_ARGMAX
|
|
|
- if (ppfs.maxposarg > 0) {
|
|
|
+ if (ppfs.maxposarg > 0) {
|
|
|
+
|
|
|
count = ppfs.maxposarg;
|
|
|
if (n > count) {
|
|
|
n = count;
|
|
@@ -444,8 +442,10 @@ size_t parse_printf_format(register const char *template,
|
|
|
for (i = 0 ; i < n ; i++) {
|
|
|
*argtypes++ = ppfs.argtype[i];
|
|
|
}
|
|
|
- } else {
|
|
|
-#endif
|
|
|
+ } else
|
|
|
+#endif
|
|
|
+ {
|
|
|
+
|
|
|
while (*template) {
|
|
|
if ((*template == '%') && (*++template != '%')) {
|
|
|
ppfs.fmtpos = template;
|
|
@@ -478,9 +478,7 @@ size_t parse_printf_format(register const char *template,
|
|
|
++template;
|
|
|
}
|
|
|
}
|
|
|
-#ifdef NL_ARGMAX
|
|
|
}
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
return count;
|
|
@@ -498,10 +496,10 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0)
|
|
|
memset(ppfs, 0, sizeof(ppfs_t));
|
|
|
#ifdef NL_ARGMAX
|
|
|
--ppfs->maxposarg;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
ppfs->fmtpos = fmt0;
|
|
|
#ifdef __UCLIBC_MJN3_ONLY__
|
|
|
-#warning TODO: Make checking of the format string in C locale an option.
|
|
|
+# warning TODO: Make checking of the format string in C locale an option.
|
|
|
#endif
|
|
|
#ifdef __UCLIBC_HAS_LOCALE__
|
|
|
|
|
@@ -595,7 +593,7 @@ void attribute_hidden _ppfs_prepargs(register ppfs_t *ppfs, va_list arg)
|
|
|
_ppfs_setargs(ppfs);
|
|
|
ppfs->maxposarg = i;
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -612,7 +610,7 @@ void attribute_hidden _ppfs_setargs(register ppfs_t *ppfs)
|
|
|
|
|
|
#ifdef NL_ARGMAX
|
|
|
if (ppfs->maxposarg == 0) {
|
|
|
-#endif
|
|
|
+#endif
|
|
|
if (ppfs->info.width == INT_MIN) {
|
|
|
ppfs->info.width =
|
|
|
#ifdef __va_arg_ptr
|
|
@@ -745,7 +743,7 @@ static const short int type_codes[] = {
|
|
|
|
|
|
PA_DOUBLE,
|
|
|
PA_DOUBLE|PA_FLAG_LONG_DOUBLE,
|
|
|
-#endif
|
|
|
+#endif
|
|
|
};
|
|
|
|
|
|
static const unsigned char type_sizes[] = {
|
|
@@ -768,7 +766,7 @@ static const unsigned char type_sizes[] = {
|
|
|
|
|
|
PROMOTED_SIZE_OF(double),
|
|
|
PROMOTED_SIZE_OF(long double),
|
|
|
-#endif
|
|
|
+#endif
|
|
|
};
|
|
|
|
|
|
static int _promoted_size(int argtype)
|
|
@@ -827,7 +825,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
int dpoint;
|
|
|
#ifdef NL_ARGMAX
|
|
|
int maxposarg;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
int p_m_spec_chars;
|
|
|
int n;
|
|
|
int argtype[MAX_ARGS_PER_SPEC+2];
|
|
@@ -840,7 +838,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
static const char qual_chars[] = QUAL_CHARS;
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
char buf[32];
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
@@ -851,7 +849,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
argtype[1] = __PA_NOARG;
|
|
|
#ifdef NL_ARGMAX
|
|
|
maxposarg = ppfs->maxposarg;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
|
|
@@ -878,7 +876,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
#else
|
|
|
width = flags = dpoint = 0;
|
|
|
fmt = ppfs->fmtpos;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
assert(fmt[-1] == '%');
|
|
|
assert(fmt[0] != '%');
|
|
@@ -917,16 +915,16 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
|
|
|
} else {
|
|
|
if (maxposarg > 0) {
|
|
|
-#ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
|
|
|
-#ifdef __UCLIBC_MJN3_ONLY__
|
|
|
-#warning TODO: Support prec and width for %m when positional args used
|
|
|
+# ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
|
|
|
+# ifdef __UCLIBC_MJN3_ONLY__
|
|
|
+# warning TODO: Support prec and width for %m when positional args used
|
|
|
|
|
|
* for specifiers that don't require an arg. */
|
|
|
-#endif
|
|
|
+# endif
|
|
|
if (*fmt == 'm') {
|
|
|
goto PREC_WIDTH;
|
|
|
}
|
|
|
-#endif
|
|
|
+# endif
|
|
|
return -1;
|
|
|
}
|
|
|
maxposarg = 0;
|
|
@@ -985,7 +983,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
}
|
|
|
argnumber[-dpoint] = i;
|
|
|
} else
|
|
|
-#endif
|
|
|
+#endif
|
|
|
if (++p != fmt) {
|
|
|
|
|
|
return -1;
|
|
@@ -1105,15 +1103,16 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
ppfs->argtype[n] = argtype[i];
|
|
|
}
|
|
|
} while (++i < ppfs->num_data_args + 2);
|
|
|
- } else {
|
|
|
+ } else
|
|
|
#endif
|
|
|
+ {
|
|
|
ppfs->argnumber[2] = 1;
|
|
|
memcpy(ppfs->argtype, argtype + 2, ppfs->num_data_args * sizeof(int));
|
|
|
-#ifdef NL_ARGMAX
|
|
|
}
|
|
|
|
|
|
+#ifdef NL_ARGMAX
|
|
|
ppfs->maxposarg = maxposarg;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
flags = ppfs->info._flags & FLAG_WIDESTREAM;
|
|
@@ -1125,7 +1124,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
|
|
|
}
|
|
|
#else
|
|
|
ppfs->fmtpos = ++fmt;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
return ppfs->num_data_args + 2;
|
|
|
}
|
|
@@ -1296,13 +1295,13 @@ static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf)
|
|
|
do {
|
|
|
#ifdef __LOCALE_C_ONLY
|
|
|
wbuf[i] = s[i];
|
|
|
-#else
|
|
|
+#else
|
|
|
|
|
|
-#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
|
|
|
+# ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
|
|
|
if (s[i] == ',') {
|
|
|
wbuf[i] = __UCLIBC_CURLOCALE->thousands_sep_wc;
|
|
|
} else
|
|
|
-#endif
|
|
|
+# endif
|
|
|
if (s[i] == '.') {
|
|
|
wbuf[i] = __UCLIBC_CURLOCALE->decimal_point_wc;
|
|
|
} else {
|
|
@@ -1329,7 +1328,7 @@ static int _ppwfs_init(register ppfs_t *ppfs, const wchar_t *fmt0)
|
|
|
memset(ppfs, 0, sizeof(ppfs_t));
|
|
|
#ifdef NL_ARGMAX
|
|
|
--ppfs->maxposarg;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
ppfs->fmtpos = (const char *) fmt0;
|
|
|
ppfs->info._flags = FLAG_WIDESTREAM;
|
|
|
|
|
@@ -1430,9 +1429,9 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
#ifdef L__vfprintf_internal
|
|
|
static const char prefix[] = "+\0-\0 \0000x\0000X";
|
|
|
|
|
|
-#else
|
|
|
+#else
|
|
|
static const wchar_t prefix[] = L"+\0-\0 \0000x\0000X";
|
|
|
-#endif
|
|
|
+#endif
|
|
|
enum {
|
|
|
PREFIX_PLUS = 0,
|
|
|
PREFIX_MINUS = 2,
|
|
@@ -1451,7 +1450,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
const wchar_t *ws = NULL;
|
|
|
mbstate_t mbstate;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
size_t slen;
|
|
|
#ifdef L__vfprintf_internal
|
|
|
#define SLEN slen
|
|
@@ -1467,7 +1466,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
char padchar = ' ';
|
|
|
#ifdef __UCLIBC_MJN3_ONLY__
|
|
|
#warning TODO: Determine appropriate buf size.
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
* and also for any locale-grouped long long integer strings generated.
|
|
|
* This should be large enough for any of the current archs/locales, but
|
|
@@ -1487,21 +1486,21 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
|
|
|
#ifdef __va_arg_ptr
|
|
|
argptr = (const void * const *) ppfs->argptr;
|
|
|
-#ifdef NL_ARGMAX
|
|
|
+# ifdef NL_ARGMAX
|
|
|
if (ppfs->maxposarg > 0) {
|
|
|
argptr += ppfs->argnumber[2] - 1;
|
|
|
}
|
|
|
-#endif
|
|
|
+# endif
|
|
|
#else
|
|
|
|
|
|
{
|
|
|
register argvalue_t *p = ppfs->argvalue;
|
|
|
int i;
|
|
|
-#ifdef NL_ARGMAX
|
|
|
+# ifdef NL_ARGMAX
|
|
|
if (ppfs->maxposarg > 0) {
|
|
|
p += ppfs->argnumber[2] - 1;
|
|
|
}
|
|
|
-#endif
|
|
|
+# endif
|
|
|
for (i = 0 ; i < ppfs->num_data_args ; i++ ) {
|
|
|
argptr[i] = (void *) p++;
|
|
|
}
|
|
@@ -1523,7 +1522,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
#ifdef L__vfprintf_internal
|
|
|
#warning CONSIDER: Should we ignore these flags if stub locale? What about custom specs?
|
|
|
#endif
|
|
|
-#endif
|
|
|
+#endif
|
|
|
base = spec_base[(int)(ppfs->conv_num - CONV_p)];
|
|
|
if (base == 10) {
|
|
|
if (PRINT_INFO_FLAG_VAL(&(ppfs->info),group)) {
|
|
@@ -1552,7 +1551,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
#ifdef L__vfprintf_internal
|
|
|
#warning CONSIDER: If using outdigits and/or grouping, how should we interpret precision?
|
|
|
#endif
|
|
|
-#endif
|
|
|
+#endif
|
|
|
s = _uintmaxtostr(buf + sizeof(buf) - 1,
|
|
|
(uintmax_t)
|
|
|
_load_inttype(ppfs->conv_num == CONV_p ? PA_FLAG_LONG : *argtype & __PA_INTMASK,
|
|
@@ -1624,7 +1623,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
return 0;
|
|
|
#else
|
|
|
return -1;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
} else if (ppfs->conv_num <= CONV_S) {
|
|
|
#ifdef L__vfprintf_internal
|
|
|
|
|
@@ -1658,7 +1657,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
}
|
|
|
#else
|
|
|
return -1;
|
|
|
-#endif
|
|
|
+#endif
|
|
|
} else if (ppfs->conv_num <= CONV_s) {
|
|
|
if (ppfs->conv_num == CONV_s) {
|
|
|
s = *((char **) (*argptr));
|
|
@@ -1704,7 +1703,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
if (ppfs->conv_num == CONV_s) {
|
|
|
#ifdef __UCLIBC_MJN3_ONLY__
|
|
|
#warning TODO: Fix %s for _vfwprintf_internal... output upto illegal sequence?
|
|
|
-#endif
|
|
|
+#endif
|
|
|
s = *((char **) (*argptr));
|
|
|
if (s) {
|
|
|
#ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
|
|
@@ -1771,7 +1770,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
#ifdef L__vfprintf_internal
|
|
|
#warning CONSIDER: If using outdigits and/or grouping, how should we pad?
|
|
|
#endif
|
|
|
-#endif
|
|
|
+#endif
|
|
|
{
|
|
|
size_t t;
|
|
|
|
|
@@ -1802,7 +1801,7 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
|
|
|
#ifdef L__vfprintf_internal
|
|
|
|
|
|
-#ifdef __UCLIBC_HAS_WCHAR__
|
|
|
+# ifdef __UCLIBC_HAS_WCHAR__
|
|
|
if (!ws) {
|
|
|
assert(s);
|
|
|
if (_outnstr(stream, s, slen) != slen) {
|
|
@@ -1814,18 +1813,18 @@ static int _do_one_spec(FILE * __restrict stream,
|
|
|
while (slen) {
|
|
|
t = (slen <= sizeof(buf)) ? slen : sizeof(buf);
|
|
|
t = wcsrtombs(buf, &ws, t, &mbstate);
|
|
|
- assert (t != ((size_t)(-1)));
|
|
|
+ assert(t != ((size_t)(-1)));
|
|
|
if (_outnstr(stream, buf, t) != t) {
|
|
|
return -1;
|
|
|
}
|
|
|
slen -= t;
|
|
|
}
|
|
|
}
|
|
|
-#else
|
|
|
+# else
|
|
|
if (_outnstr(stream, (const unsigned char *) s, slen) != slen) {
|
|
|
return -1;
|
|
|
}
|
|
|
-#endif
|
|
|
+# endif
|
|
|
|
|
|
#else
|
|
|
|
|
@@ -1930,13 +1929,13 @@ int VFPRINTF_internal (FILE * __restrict stream,
|
|
|
* is using __stdio_fwrite (TODO: do the same for wide functions).
|
|
|
*/
|
|
|
#ifdef L_vfprintf
|
|
|
-#define VFPRINTF vfprintf
|
|
|
-#define VFPRINTF_internal _vfprintf_internal
|
|
|
-#define FMT_TYPE char
|
|
|
+# define VFPRINTF vfprintf
|
|
|
+# define VFPRINTF_internal _vfprintf_internal
|
|
|
+# define FMT_TYPE char
|
|
|
#else
|
|
|
-#define VFPRINTF vfwprintf
|
|
|
-#define VFPRINTF_internal _vfwprintf_internal
|
|
|
-#define FMT_TYPE wchar_t
|
|
|
+# define VFPRINTF vfwprintf
|
|
|
+# define VFPRINTF_internal _vfwprintf_internal
|
|
|
+# define FMT_TYPE wchar_t
|
|
|
#endif
|
|
|
|
|
|
libc_hidden_proto(VFPRINTF)
|