summaryrefslogtreecommitdiffstats
path: root/gl/printf-args.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-08 01:11:46 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-13 01:26:35 (GMT)
commit74da141e618ef99959d509cb2e7be35a348a39db (patch)
tree88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/printf-args.c
parentc63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff)
downloadmonitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/printf-args.c')
-rw-r--r--gl/printf-args.c211
1 files changed, 106 insertions, 105 deletions
diff --git a/gl/printf-args.c b/gl/printf-args.c
index 871c720..46c03a2 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,5 +1,6 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 Free Software
3 Foundation, Inc.
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -42,146 +43,146 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
42 switch (ap->type) 43 switch (ap->type)
43 { 44 {
44 case TYPE_SCHAR: 45 case TYPE_SCHAR:
45 ap->a.a_schar = va_arg (args, /*signed char*/ int); 46 ap->a.a_schar = va_arg (args, /*signed char*/ int);
46 break; 47 break;
47 case TYPE_UCHAR: 48 case TYPE_UCHAR:
48 ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); 49 ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
49 break; 50 break;
50 case TYPE_SHORT: 51 case TYPE_SHORT:
51 ap->a.a_short = va_arg (args, /*short*/ int); 52 ap->a.a_short = va_arg (args, /*short*/ int);
52 break; 53 break;
53 case TYPE_USHORT: 54 case TYPE_USHORT:
54 ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); 55 ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
55 break; 56 break;
56 case TYPE_INT: 57 case TYPE_INT:
57 ap->a.a_int = va_arg (args, int); 58 ap->a.a_int = va_arg (args, int);
58 break; 59 break;
59 case TYPE_UINT: 60 case TYPE_UINT:
60 ap->a.a_uint = va_arg (args, unsigned int); 61 ap->a.a_uint = va_arg (args, unsigned int);
61 break; 62 break;
62 case TYPE_LONGINT: 63 case TYPE_LONGINT:
63 ap->a.a_longint = va_arg (args, long int); 64 ap->a.a_longint = va_arg (args, long int);
64 break; 65 break;
65 case TYPE_ULONGINT: 66 case TYPE_ULONGINT:
66 ap->a.a_ulongint = va_arg (args, unsigned long int); 67 ap->a.a_ulongint = va_arg (args, unsigned long int);
67 break; 68 break;
68#if HAVE_LONG_LONG_INT 69#if HAVE_LONG_LONG_INT
69 case TYPE_LONGLONGINT: 70 case TYPE_LONGLONGINT:
70 ap->a.a_longlongint = va_arg (args, long long int); 71 ap->a.a_longlongint = va_arg (args, long long int);
71 break; 72 break;
72 case TYPE_ULONGLONGINT: 73 case TYPE_ULONGLONGINT:
73 ap->a.a_ulonglongint = va_arg (args, unsigned long long int); 74 ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
74 break; 75 break;
75#endif 76#endif
76 case TYPE_DOUBLE: 77 case TYPE_DOUBLE:
77 ap->a.a_double = va_arg (args, double); 78 ap->a.a_double = va_arg (args, double);
78 break; 79 break;
79 case TYPE_LONGDOUBLE: 80 case TYPE_LONGDOUBLE:
80 ap->a.a_longdouble = va_arg (args, long double); 81 ap->a.a_longdouble = va_arg (args, long double);
81 break; 82 break;
82 case TYPE_CHAR: 83 case TYPE_CHAR:
83 ap->a.a_char = va_arg (args, int); 84 ap->a.a_char = va_arg (args, int);
84 break; 85 break;
85#if HAVE_WINT_T 86#if HAVE_WINT_T
86 case TYPE_WIDE_CHAR: 87 case TYPE_WIDE_CHAR:
87 /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by 88 /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
88 default argument promotions", this is not the case in mingw32, 89 default argument promotions", this is not the case in mingw32,
89 where wint_t is 'unsigned short'. */ 90 where wint_t is 'unsigned short'. */
90 ap->a.a_wide_char = 91 ap->a.a_wide_char =
91 (sizeof (wint_t) < sizeof (int) 92 (sizeof (wint_t) < sizeof (int)
92 ? va_arg (args, int) 93 ? (wint_t) va_arg (args, int)
93 : va_arg (args, wint_t)); 94 : va_arg (args, wint_t));
94 break; 95 break;
95#endif 96#endif
96 case TYPE_STRING: 97 case TYPE_STRING:
97 ap->a.a_string = va_arg (args, const char *); 98 ap->a.a_string = va_arg (args, const char *);
98 /* A null pointer is an invalid argument for "%s", but in practice 99 /* A null pointer is an invalid argument for "%s", but in practice
99 it occurs quite frequently in printf statements that produce 100 it occurs quite frequently in printf statements that produce
100 debug output. Use a fallback in this case. */ 101 debug output. Use a fallback in this case. */
101 if (ap->a.a_string == NULL) 102 if (ap->a.a_string == NULL)
102 ap->a.a_string = "(NULL)"; 103 ap->a.a_string = "(NULL)";
103 break; 104 break;
104#if HAVE_WCHAR_T 105#if HAVE_WCHAR_T
105 case TYPE_WIDE_STRING: 106 case TYPE_WIDE_STRING:
106 ap->a.a_wide_string = va_arg (args, const wchar_t *); 107 ap->a.a_wide_string = va_arg (args, const wchar_t *);
107 /* A null pointer is an invalid argument for "%ls", but in practice 108 /* A null pointer is an invalid argument for "%ls", but in practice
108 it occurs quite frequently in printf statements that produce 109 it occurs quite frequently in printf statements that produce
109 debug output. Use a fallback in this case. */ 110 debug output. Use a fallback in this case. */
110 if (ap->a.a_wide_string == NULL) 111 if (ap->a.a_wide_string == NULL)
111 { 112 {
112 static const wchar_t wide_null_string[] = 113 static const wchar_t wide_null_string[] =
113 { 114 {
114 (wchar_t)'(', 115 (wchar_t)'(',
115 (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', 116 (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
116 (wchar_t)')', 117 (wchar_t)')',
117 (wchar_t)0 118 (wchar_t)0
118 }; 119 };
119 ap->a.a_wide_string = wide_null_string; 120 ap->a.a_wide_string = wide_null_string;
120 } 121 }
121 break; 122 break;
122#endif 123#endif
123 case TYPE_POINTER: 124 case TYPE_POINTER:
124 ap->a.a_pointer = va_arg (args, void *); 125 ap->a.a_pointer = va_arg (args, void *);
125 break; 126 break;
126 case TYPE_COUNT_SCHAR_POINTER: 127 case TYPE_COUNT_SCHAR_POINTER:
127 ap->a.a_count_schar_pointer = va_arg (args, signed char *); 128 ap->a.a_count_schar_pointer = va_arg (args, signed char *);
128 break; 129 break;
129 case TYPE_COUNT_SHORT_POINTER: 130 case TYPE_COUNT_SHORT_POINTER:
130 ap->a.a_count_short_pointer = va_arg (args, short *); 131 ap->a.a_count_short_pointer = va_arg (args, short *);
131 break; 132 break;
132 case TYPE_COUNT_INT_POINTER: 133 case TYPE_COUNT_INT_POINTER:
133 ap->a.a_count_int_pointer = va_arg (args, int *); 134 ap->a.a_count_int_pointer = va_arg (args, int *);
134 break; 135 break;
135 case TYPE_COUNT_LONGINT_POINTER: 136 case TYPE_COUNT_LONGINT_POINTER:
136 ap->a.a_count_longint_pointer = va_arg (args, long int *); 137 ap->a.a_count_longint_pointer = va_arg (args, long int *);
137 break; 138 break;
138#if HAVE_LONG_LONG_INT 139#if HAVE_LONG_LONG_INT
139 case TYPE_COUNT_LONGLONGINT_POINTER: 140 case TYPE_COUNT_LONGLONGINT_POINTER:
140 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); 141 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
141 break; 142 break;
142#endif 143#endif
143#if ENABLE_UNISTDIO 144#if ENABLE_UNISTDIO
144 /* The unistdio extensions. */ 145 /* The unistdio extensions. */
145 case TYPE_U8_STRING: 146 case TYPE_U8_STRING:
146 ap->a.a_u8_string = va_arg (args, const uint8_t *); 147 ap->a.a_u8_string = va_arg (args, const uint8_t *);
147 /* A null pointer is an invalid argument for "%U", but in practice 148 /* A null pointer is an invalid argument for "%U", but in practice
148 it occurs quite frequently in printf statements that produce 149 it occurs quite frequently in printf statements that produce
149 debug output. Use a fallback in this case. */ 150 debug output. Use a fallback in this case. */
150 if (ap->a.a_u8_string == NULL) 151 if (ap->a.a_u8_string == NULL)
151 { 152 {
152 static const uint8_t u8_null_string[] = 153 static const uint8_t u8_null_string[] =
153 { '(', 'N', 'U', 'L', 'L', ')', 0 }; 154 { '(', 'N', 'U', 'L', 'L', ')', 0 };
154 ap->a.a_u8_string = u8_null_string; 155 ap->a.a_u8_string = u8_null_string;
155 } 156 }
156 break; 157 break;
157 case TYPE_U16_STRING: 158 case TYPE_U16_STRING:
158 ap->a.a_u16_string = va_arg (args, const uint16_t *); 159 ap->a.a_u16_string = va_arg (args, const uint16_t *);
159 /* A null pointer is an invalid argument for "%lU", but in practice 160 /* A null pointer is an invalid argument for "%lU", but in practice
160 it occurs quite frequently in printf statements that produce 161 it occurs quite frequently in printf statements that produce
161 debug output. Use a fallback in this case. */ 162 debug output. Use a fallback in this case. */
162 if (ap->a.a_u16_string == NULL) 163 if (ap->a.a_u16_string == NULL)
163 { 164 {
164 static const uint16_t u16_null_string[] = 165 static const uint16_t u16_null_string[] =
165 { '(', 'N', 'U', 'L', 'L', ')', 0 }; 166 { '(', 'N', 'U', 'L', 'L', ')', 0 };
166 ap->a.a_u16_string = u16_null_string; 167 ap->a.a_u16_string = u16_null_string;
167 } 168 }
168 break; 169 break;
169 case TYPE_U32_STRING: 170 case TYPE_U32_STRING:
170 ap->a.a_u32_string = va_arg (args, const uint32_t *); 171 ap->a.a_u32_string = va_arg (args, const uint32_t *);
171 /* A null pointer is an invalid argument for "%llU", but in practice 172 /* A null pointer is an invalid argument for "%llU", but in practice
172 it occurs quite frequently in printf statements that produce 173 it occurs quite frequently in printf statements that produce
173 debug output. Use a fallback in this case. */ 174 debug output. Use a fallback in this case. */
174 if (ap->a.a_u32_string == NULL) 175 if (ap->a.a_u32_string == NULL)
175 { 176 {
176 static const uint32_t u32_null_string[] = 177 static const uint32_t u32_null_string[] =
177 { '(', 'N', 'U', 'L', 'L', ')', 0 }; 178 { '(', 'N', 'U', 'L', 'L', ')', 0 };
178 ap->a.a_u32_string = u32_null_string; 179 ap->a.a_u32_string = u32_null_string;
179 } 180 }
180 break; 181 break;
181#endif 182#endif
182 default: 183 default:
183 /* Unknown type. */ 184 /* Unknown type. */
184 return -1; 185 return -1;
185 } 186 }
186 return 0; 187 return 0;
187} 188}