Line data Source code
1 : /* -*- buffer-read-only: t -*- vi: set ro: */
2 : /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 : #line 1
4 : /* Decomposed printf argument list.
5 : Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc.
6 :
7 : This program is free software; you can redistribute it and/or modify
8 : it under the terms of the GNU General Public License as published by
9 : the Free Software Foundation; either version 3, or (at your option)
10 : any later version.
11 :
12 : This program is distributed in the hope that it will be useful,
13 : but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : GNU General Public License for more details.
16 :
17 : You should have received a copy of the GNU General Public License along
18 : with this program; if not, write to the Free Software Foundation,
19 : Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 :
21 : /* This file can be parametrized with the following macros:
22 : ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
23 : PRINTF_FETCHARGS Name of the function to be defined.
24 : STATIC Set to 'static' to declare the function static. */
25 :
26 : #ifndef PRINTF_FETCHARGS
27 : # include <config.h>
28 : #endif
29 :
30 : /* Specification. */
31 : #ifndef PRINTF_FETCHARGS
32 : # include "printf-args.h"
33 : #endif
34 :
35 : #ifdef STATIC
36 731 : STATIC
37 : #endif
38 : int
39 : PRINTF_FETCHARGS (va_list args, arguments *a)
40 : {
41 1693 : size_t i;
42 962 : argument *ap;
43 :
44 0 : for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
45 0 : switch (ap->type)
46 0 : {
47 0 : case TYPE_SCHAR:
48 0 : ap->a.a_schar = va_arg (args, /*signed char*/ int);
49 0 : break;
50 0 : case TYPE_UCHAR:
51 0 : ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
52 0 : break;
53 0 : case TYPE_SHORT:
54 0 : ap->a.a_short = va_arg (args, /*short*/ int);
55 0 : break;
56 42 : case TYPE_USHORT:
57 42 : ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
58 42 : break;
59 0 : case TYPE_INT:
60 0 : ap->a.a_int = va_arg (args, int);
61 0 : break;
62 4 : case TYPE_UINT:
63 4 : ap->a.a_uint = va_arg (args, unsigned int);
64 4 : break;
65 57 : case TYPE_LONGINT:
66 57 : ap->a.a_longint = va_arg (args, long int);
67 57 : break;
68 : case TYPE_ULONGINT:
69 0 : ap->a.a_ulongint = va_arg (args, unsigned long int);
70 0 : break;
71 0 : #if HAVE_LONG_LONG_INT
72 0 : case TYPE_LONGLONGINT:
73 0 : ap->a.a_longlongint = va_arg (args, long long int);
74 0 : break;
75 : case TYPE_ULONGLONGINT:
76 0 : ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
77 0 : break;
78 0 : #endif
79 18 : case TYPE_DOUBLE:
80 18 : ap->a.a_double = va_arg (args, double);
81 18 : break;
82 2 : case TYPE_LONGDOUBLE:
83 2 : ap->a.a_longdouble = va_arg (args, long double);
84 2 : break;
85 : case TYPE_CHAR:
86 0 : ap->a.a_char = va_arg (args, int);
87 : break;
88 : #if HAVE_WINT_T
89 : case TYPE_WIDE_CHAR:
90 0 : /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
91 : default argument promotions", this is not the case in mingw32,
92 : where wint_t is 'unsigned short'. */
93 0 : ap->a.a_wide_char =
94 0 : (sizeof (wint_t) < sizeof (int)
95 : ? va_arg (args, int)
96 839 : : va_arg (args, wint_t));
97 839 : break;
98 : #endif
99 : case TYPE_STRING:
100 : ap->a.a_string = va_arg (args, const char *);
101 839 : /* A null pointer is an invalid argument for "%s", but in practice
102 0 : it occurs quite frequently in printf statements that produce
103 839 : debug output. Use a fallback in this case. */
104 : if (ap->a.a_string == NULL)
105 0 : ap->a.a_string = "(NULL)";
106 0 : break;
107 : #if HAVE_WCHAR_T
108 : case TYPE_WIDE_STRING:
109 : ap->a.a_wide_string = va_arg (args, const wchar_t *);
110 0 : /* A null pointer is an invalid argument for "%ls", but in practice
111 : it occurs quite frequently in printf statements that produce
112 : debug output. Use a fallback in this case. */
113 : if (ap->a.a_wide_string == NULL)
114 : {
115 : static const wchar_t wide_null_string[] =
116 : {
117 : (wchar_t)'(',
118 : (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
119 0 : (wchar_t)')',
120 : (wchar_t)0
121 0 : };
122 : ap->a.a_wide_string = wide_null_string;
123 0 : }
124 0 : break;
125 0 : #endif
126 0 : case TYPE_POINTER:
127 0 : ap->a.a_pointer = va_arg (args, void *);
128 0 : break;
129 0 : case TYPE_COUNT_SCHAR_POINTER:
130 0 : ap->a.a_count_schar_pointer = va_arg (args, signed char *);
131 0 : break;
132 0 : case TYPE_COUNT_SHORT_POINTER:
133 0 : ap->a.a_count_short_pointer = va_arg (args, short *);
134 0 : break;
135 0 : case TYPE_COUNT_INT_POINTER:
136 0 : ap->a.a_count_int_pointer = va_arg (args, int *);
137 0 : break;
138 : case TYPE_COUNT_LONGINT_POINTER:
139 0 : ap->a.a_count_longint_pointer = va_arg (args, long int *);
140 0 : break;
141 0 : #if HAVE_LONG_LONG_INT
142 : case TYPE_COUNT_LONGLONGINT_POINTER:
143 : ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
144 : break;
145 : #endif
146 : #if ENABLE_UNISTDIO
147 : /* The unistdio extensions. */
148 : case TYPE_U8_STRING:
149 : ap->a.a_u8_string = va_arg (args, const uint8_t *);
150 : /* A null pointer is an invalid argument for "%U", but in practice
151 : it occurs quite frequently in printf statements that produce
152 : debug output. Use a fallback in this case. */
153 : if (ap->a.a_u8_string == NULL)
154 : {
155 : static const uint8_t u8_null_string[] =
156 : { '(', 'N', 'U', 'L', 'L', ')', 0 };
157 : ap->a.a_u8_string = u8_null_string;
158 : }
159 : break;
160 : case TYPE_U16_STRING:
161 : ap->a.a_u16_string = va_arg (args, const uint16_t *);
162 : /* A null pointer is an invalid argument for "%lU", but in practice
163 : it occurs quite frequently in printf statements that produce
164 : debug output. Use a fallback in this case. */
165 : if (ap->a.a_u16_string == NULL)
166 : {
167 : static const uint16_t u16_null_string[] =
168 : { '(', 'N', 'U', 'L', 'L', ')', 0 };
169 : ap->a.a_u16_string = u16_null_string;
170 : }
171 : break;
172 : case TYPE_U32_STRING:
173 : ap->a.a_u32_string = va_arg (args, const uint32_t *);
174 : /* A null pointer is an invalid argument for "%llU", but in practice
175 : it occurs quite frequently in printf statements that produce
176 : debug output. Use a fallback in this case. */
177 : if (ap->a.a_u32_string == NULL)
178 : {
179 : static const uint32_t u32_null_string[] =
180 : { '(', 'N', 'U', 'L', 'L', ')', 0 };
181 : ap->a.a_u32_string = u32_null_string;
182 0 : }
183 : break;
184 0 : #endif
185 : default:
186 731 : /* Unknown type. */
187 : return -1;
188 : }
189 : return 0;
190 : }
|