lib/printf: disable wchar_t support

... we just don't use wchar_t in FRR, no point in having this enabled.

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2019-05-12 22:39:28 +02:00
parent 32b67a0aeb
commit e8c672ea81
3 changed files with 16 additions and 4 deletions

View file

@ -214,6 +214,7 @@ addaster(struct typetable *types, char **fmtp)
return (0); return (0);
} }
#ifdef WCHAR_SUPPORT
static inline int static inline int
addwaster(struct typetable *types, wchar_t **fmtp) addwaster(struct typetable *types, wchar_t **fmtp)
{ {
@ -239,6 +240,7 @@ addwaster(struct typetable *types, wchar_t **fmtp)
} }
return (0); return (0);
} }
#endif /* WCHAR_SUPPORT */
/* /*
* Find all arguments when a positional parameter is encountered. Returns a * Find all arguments when a positional parameter is encountered. Returns a
@ -437,6 +439,7 @@ error:
return (error || *argtable == NULL); return (error || *argtable == NULL);
} }
#ifdef WCHAR_SUPPORT
/* wchar version of __find_arguments. */ /* wchar version of __find_arguments. */
int int
__find_warguments (const wchar_t *fmt0, va_list ap, union arg **argtable) __find_warguments (const wchar_t *fmt0, va_list ap, union arg **argtable)
@ -627,6 +630,7 @@ error:
freetypes(&types); freetypes(&types);
return (error || *argtable == NULL); return (error || *argtable == NULL);
} }
#endif /* WCHAR_SUPPORT */
/* /*
* Increase the size of the type table. Returns 0 on success. * Increase the size of the type table. Returns 0 on success.

View file

@ -93,4 +93,6 @@ union arg {
/* Handle positional parameters. */ /* Handle positional parameters. */
int __find_arguments(const char *, va_list, union arg **); int __find_arguments(const char *, va_list, union arg **);
#ifdef WCHAR_SUPPORT
int __find_warguments(const wchar_t *, va_list, union arg **); int __find_warguments(const wchar_t *, va_list, union arg **);
#endif

View file

@ -73,11 +73,10 @@ struct __suio {
#include "printflocal.h" #include "printflocal.h"
static char *__wcsconv(wchar_t *, int);
#define CHAR char #define CHAR char
#include "printfcommon.h" #include "printfcommon.h"
#ifdef WCHAR_SUPPORT
/* /*
* Convert a wide character string argument for the %ls format to a multibyte * Convert a wide character string argument for the %ls format to a multibyte
* string representation. If not -1, prec specifies the maximum number of * string representation. If not -1, prec specifies the maximum number of
@ -136,6 +135,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
convbuf[nbytes] = '\0'; convbuf[nbytes] = '\0';
return (convbuf); return (convbuf);
} }
#endif /* WCHAR_SUPPORT */
/* /*
* The size of the buffer we use as scratch space for integer * The size of the buffer we use as scratch space for integer
@ -412,6 +412,7 @@ reswitch: switch (ch) {
flags |= LONGINT; flags |= LONGINT;
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 'c': case 'c':
#ifdef WCHAR_SUPPORT
if (flags & LONGINT) { if (flags & LONGINT) {
static const mbstate_t initial; static const mbstate_t initial;
mbstate_t mbs; mbstate_t mbs;
@ -424,7 +425,9 @@ reswitch: switch (ch) {
goto error; goto error;
} }
size = (int)mbseqlen; size = (int)mbseqlen;
} else { } else
#endif /* WCHAR_SUPPORT */
{
*(cp = buf) = GETARG(int); *(cp = buf) = GETARG(int);
size = 1; size = 1;
} }
@ -542,6 +545,7 @@ reswitch: switch (ch) {
flags |= LONGINT; flags |= LONGINT;
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 's': case 's':
#ifdef WCHAR_SUPPORT
if (flags & LONGINT) { if (flags & LONGINT) {
wchar_t *wcp; wchar_t *wcp;
@ -556,7 +560,9 @@ reswitch: switch (ch) {
} }
cp = convbuf; cp = convbuf;
} }
} else if ((cp = GETARG(char *)) == NULL) } else
#endif
if ((cp = GETARG(char *)) == NULL)
cp = "(null)"; cp = "(null)";
size = (prec >= 0) ? strnlen(cp, prec) : strlen(cp); size = (prec >= 0) ? strnlen(cp, prec) : strlen(cp);
sign = '\0'; sign = '\0';