~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to grub-core/gnulib/printf-args.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

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