~ubuntu-branches/ubuntu/gutsy/m4/gutsy

« back to all changes in this revision

Viewing changes to lib/printf-args.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-08-01 14:00:55 UTC
  • mfrom: (1.5.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070801140055-ob48jo517shsyvgk
Tags: 1.4.10-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
   with this program; if not, write to the Free Software Foundation,
16
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
27
/* Specification.  */
21
 
#include "printf-args.h"
 
28
#ifndef PRINTF_FETCHARGS
 
29
# include "printf-args.h"
 
30
#endif
22
31
 
23
32
#ifdef STATIC
24
33
STATIC
25
34
#endif
26
35
int
27
 
printf_fetchargs (va_list args, arguments *a)
 
36
PRINTF_FETCHARGS (va_list args, arguments *a)
28
37
{
29
38
  size_t i;
30
39
  argument *ap;
67
76
      case TYPE_DOUBLE:
68
77
        ap->a.a_double = va_arg (args, double);
69
78
        break;
70
 
#if HAVE_LONG_DOUBLE
71
79
      case TYPE_LONGDOUBLE:
72
80
        ap->a.a_longdouble = va_arg (args, long double);
73
81
        break;
74
 
#endif
75
82
      case TYPE_CHAR:
76
83
        ap->a.a_char = va_arg (args, int);
77
84
        break;
133
140
        ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
134
141
        break;
135
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
182
      default:
137
183
        /* Unknown type.  */
138
184
        return -1;