diff options
| author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 11:07:18 +0000 |
|---|---|---|
| committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 11:07:18 +0000 |
| commit | bd7029a99b0c2974265c6665638ef14a052f42ab (patch) | |
| tree | f5661ba73366d81ef6e91f889ea7fec5ebe07b6b /gl/printf-args.c | |
| parent | f99612320d6eda67644c07be04bb21aa4d7789db (diff) | |
| download | monitoring-plugins-bd7029a99b0c2974265c6665638ef14a052f42ab.tar.gz | |
Sync to latest Gnulib
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1925 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl/printf-args.c')
| -rw-r--r-- | gl/printf-args.c | 68 |
1 files changed, 57 insertions, 11 deletions
diff --git a/gl/printf-args.c b/gl/printf-args.c index 358801c9..871c720a 100644 --- a/gl/printf-args.c +++ b/gl/printf-args.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* Decomposed printf argument list. | 1 | /* Decomposed printf argument list. |
| 2 | Copyright (C) 1999, 2002-2003, 2005-2006 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This program is free software; you can redistribute it and/or modify | 4 | 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 | 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; either version 2, or (at your option) | 6 | the Free Software Foundation; either version 3, or (at your option) |
| 7 | any later version. | 7 | any later version. |
| 8 | 8 | ||
| 9 | This program is distributed in the hope that it will be useful, | 9 | This program is distributed in the hope that it will be useful, |
| @@ -15,16 +15,25 @@ | |||
| 15 | with this program; if not, write to the Free Software Foundation, | 15 | with this program; if not, write to the Free Software Foundation, |
| 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
| 17 | 17 | ||
| 18 | #include <config.h> | 18 | /* This file can be parametrized with the following macros: |
| 19 | ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. | ||
| 20 | PRINTF_FETCHARGS Name of the function to be defined. | ||
| 21 | STATIC Set to 'static' to declare the function static. */ | ||
| 22 | |||
| 23 | #ifndef PRINTF_FETCHARGS | ||
| 24 | # include <config.h> | ||
| 25 | #endif | ||
| 19 | 26 | ||
| 20 | /* Specification. */ | 27 | /* Specification. */ |
| 21 | #include "printf-args.h" | 28 | #ifndef PRINTF_FETCHARGS |
| 29 | # include "printf-args.h" | ||
| 30 | #endif | ||
| 22 | 31 | ||
| 23 | #ifdef STATIC | 32 | #ifdef STATIC |
| 24 | STATIC | 33 | STATIC |
| 25 | #endif | 34 | #endif |
| 26 | int | 35 | int |
| 27 | printf_fetchargs (va_list args, arguments *a) | 36 | PRINTF_FETCHARGS (va_list args, arguments *a) |
| 28 | { | 37 | { |
| 29 | size_t i; | 38 | size_t i; |
| 30 | argument *ap; | 39 | argument *ap; |
| @@ -56,7 +65,7 @@ printf_fetchargs (va_list args, arguments *a) | |||
| 56 | case TYPE_ULONGINT: | 65 | case TYPE_ULONGINT: |
| 57 | ap->a.a_ulongint = va_arg (args, unsigned long int); | 66 | ap->a.a_ulongint = va_arg (args, unsigned long int); |
| 58 | break; | 67 | break; |
| 59 | #ifdef HAVE_LONG_LONG_INT | 68 | #if HAVE_LONG_LONG_INT |
| 60 | case TYPE_LONGLONGINT: | 69 | case TYPE_LONGLONGINT: |
| 61 | ap->a.a_longlongint = va_arg (args, long long int); | 70 | ap->a.a_longlongint = va_arg (args, long long int); |
| 62 | break; | 71 | break; |
| @@ -67,15 +76,13 @@ printf_fetchargs (va_list args, arguments *a) | |||
| 67 | case TYPE_DOUBLE: | 76 | case TYPE_DOUBLE: |
| 68 | ap->a.a_double = va_arg (args, double); | 77 | ap->a.a_double = va_arg (args, double); |
| 69 | break; | 78 | break; |
| 70 | #ifdef HAVE_LONG_DOUBLE | ||
| 71 | case TYPE_LONGDOUBLE: | 79 | case TYPE_LONGDOUBLE: |
| 72 | ap->a.a_longdouble = va_arg (args, long double); | 80 | ap->a.a_longdouble = va_arg (args, long double); |
| 73 | break; | 81 | break; |
| 74 | #endif | ||
| 75 | case TYPE_CHAR: | 82 | case TYPE_CHAR: |
| 76 | ap->a.a_char = va_arg (args, int); | 83 | ap->a.a_char = va_arg (args, int); |
| 77 | break; | 84 | break; |
| 78 | #ifdef HAVE_WINT_T | 85 | #if HAVE_WINT_T |
| 79 | case TYPE_WIDE_CHAR: | 86 | case TYPE_WIDE_CHAR: |
| 80 | /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by | 87 | /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by |
| 81 | default argument promotions", this is not the case in mingw32, | 88 | default argument promotions", this is not the case in mingw32, |
| @@ -94,7 +101,7 @@ printf_fetchargs (va_list args, arguments *a) | |||
| 94 | if (ap->a.a_string == NULL) | 101 | if (ap->a.a_string == NULL) |
| 95 | ap->a.a_string = "(NULL)"; | 102 | ap->a.a_string = "(NULL)"; |
| 96 | break; | 103 | break; |
| 97 | #ifdef HAVE_WCHAR_T | 104 | #if HAVE_WCHAR_T |
| 98 | case TYPE_WIDE_STRING: | 105 | case TYPE_WIDE_STRING: |
| 99 | ap->a.a_wide_string = va_arg (args, const wchar_t *); | 106 | ap->a.a_wide_string = va_arg (args, const wchar_t *); |
| 100 | /* A null pointer is an invalid argument for "%ls", but in practice | 107 | /* A null pointer is an invalid argument for "%ls", but in practice |
| @@ -128,11 +135,50 @@ printf_fetchargs (va_list args, arguments *a) | |||
| 128 | case TYPE_COUNT_LONGINT_POINTER: | 135 | case TYPE_COUNT_LONGINT_POINTER: |
| 129 | ap->a.a_count_longint_pointer = va_arg (args, long int *); | 136 | ap->a.a_count_longint_pointer = va_arg (args, long int *); |
| 130 | break; | 137 | break; |
| 131 | #ifdef HAVE_LONG_LONG_INT | 138 | #if HAVE_LONG_LONG_INT |
| 132 | case TYPE_COUNT_LONGLONGINT_POINTER: | 139 | case TYPE_COUNT_LONGLONGINT_POINTER: |
| 133 | ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); | 140 | ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); |
| 134 | break; | 141 | break; |
| 135 | #endif | 142 | #endif |
| 143 | #if ENABLE_UNISTDIO | ||
| 144 | /* The unistdio extensions. */ | ||
| 145 | case TYPE_U8_STRING: | ||
| 146 | 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 | it occurs quite frequently in printf statements that produce | ||
| 149 | debug output. Use a fallback in this case. */ | ||
| 150 | if (ap->a.a_u8_string == NULL) | ||
| 151 | { | ||
| 152 | static const uint8_t u8_null_string[] = | ||
| 153 | { '(', 'N', 'U', 'L', 'L', ')', 0 }; | ||
| 154 | ap->a.a_u8_string = u8_null_string; | ||
| 155 | } | ||
| 156 | break; | ||
| 157 | case TYPE_U16_STRING: | ||
| 158 | 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 | it occurs quite frequently in printf statements that produce | ||
| 161 | debug output. Use a fallback in this case. */ | ||
| 162 | if (ap->a.a_u16_string == NULL) | ||
| 163 | { | ||
| 164 | static const uint16_t u16_null_string[] = | ||
| 165 | { '(', 'N', 'U', 'L', 'L', ')', 0 }; | ||
| 166 | ap->a.a_u16_string = u16_null_string; | ||
| 167 | } | ||
| 168 | break; | ||
| 169 | case TYPE_U32_STRING: | ||
| 170 | 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 | it occurs quite frequently in printf statements that produce | ||
| 173 | debug output. Use a fallback in this case. */ | ||
| 174 | if (ap->a.a_u32_string == NULL) | ||
| 175 | { | ||
| 176 | static const uint32_t u32_null_string[] = | ||
| 177 | { '(', 'N', 'U', 'L', 'L', ')', 0 }; | ||
| 178 | ap->a.a_u32_string = u32_null_string; | ||
| 179 | } | ||
| 180 | break; | ||
| 181 | #endif | ||
| 136 | default: | 182 | default: |
| 137 | /* Unknown type. */ | 183 | /* Unknown type. */ |
| 138 | return -1; | 184 | return -1; |
