1 /* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License along
15 with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
23 #include "printf-args.h"
29 printf_fetchargs (va_list args
, arguments
*a
)
34 for (i
= 0, ap
= &a
->arg
[0]; i
< a
->count
; i
++, ap
++)
38 ap
->a
.a_schar
= va_arg (args
, /*signed char*/ int);
41 ap
->a
.a_uchar
= va_arg (args
, /*unsigned char*/ int);
44 ap
->a
.a_short
= va_arg (args
, /*short*/ int);
47 ap
->a
.a_ushort
= va_arg (args
, /*unsigned short*/ int);
50 ap
->a
.a_int
= va_arg (args
, int);
53 ap
->a
.a_uint
= va_arg (args
, unsigned int);
56 ap
->a
.a_longint
= va_arg (args
, long int);
59 ap
->a
.a_ulongint
= va_arg (args
, unsigned long int);
62 case TYPE_LONGLONGINT
:
63 ap
->a
.a_longlongint
= va_arg (args
, long long int);
65 case TYPE_ULONGLONGINT
:
66 ap
->a
.a_ulonglongint
= va_arg (args
, unsigned long long int);
70 ap
->a
.a_double
= va_arg (args
, double);
72 #ifdef HAVE_LONG_DOUBLE
74 ap
->a
.a_longdouble
= va_arg (args
, long double);
78 ap
->a
.a_char
= va_arg (args
, int);
82 ap
->a
.a_wide_char
= va_arg (args
, wint_t);
86 ap
->a
.a_string
= va_arg (args
, const char *);
87 /* A null pointer is an invalid argument for "%s", but in practice
88 it occurs quite frequently in printf statements that produce
89 debug output. Use a fallback in this case. */
90 if (ap
->a
.a_string
== NULL
)
91 ap
->a
.a_string
= "(NULL)";
94 case TYPE_WIDE_STRING
:
95 ap
->a
.a_wide_string
= va_arg (args
, const wchar_t *);
96 /* A null pointer is an invalid argument for "%ls", but in practice
97 it occurs quite frequently in printf statements that produce
98 debug output. Use a fallback in this case. */
99 if (ap
->a
.a_wide_string
== NULL
)
101 static const wchar_t wide_null_string
[] =
104 (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
108 ap
->a
.a_wide_string
= wide_null_string
;
113 ap
->a
.a_pointer
= va_arg (args
, void *);
115 case TYPE_COUNT_SCHAR_POINTER
:
116 ap
->a
.a_count_schar_pointer
= va_arg (args
, signed char *);
118 case TYPE_COUNT_SHORT_POINTER
:
119 ap
->a
.a_count_short_pointer
= va_arg (args
, short *);
121 case TYPE_COUNT_INT_POINTER
:
122 ap
->a
.a_count_int_pointer
= va_arg (args
, int *);
124 case TYPE_COUNT_LONGINT_POINTER
:
125 ap
->a
.a_count_longint_pointer
= va_arg (args
, long int *);
127 #ifdef HAVE_LONG_LONG
128 case TYPE_COUNT_LONGLONGINT_POINTER
:
129 ap
->a
.a_count_longlongint_pointer
= va_arg (args
, long long int *);