Ignore:
Timestamp:
Feb 3, 2017, 2:02:34 PM (8 years ago)
Author:
Silvan Scherrer
Message:

cpio: update vendor to version 2.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified cpio/vendor/current/gnu/printf-parse.c

    r118 r1964  
    1 /* -*- buffer-read-only: t -*- vi: set ro: */
    2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
    31/* Formatted output to strings.
    4    Copyright (C) 1999-2000, 2002-2003, 2006-2010 Free Software Foundation, Inc.
     2   Copyright (C) 1999-2000, 2002-2003, 2006-2015 Free Software Foundation, Inc.
    53
    64   This program is free software; you can redistribute it and/or modify
     
    1513
    1614   You should have received a copy of the GNU General Public License along
    17    with this program; if not, write to the Free Software Foundation,
    18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     15   with this program; if not, see <http://www.gnu.org/licenses/>.  */
    1916
    2017/* This file can be parametrized with the following macros:
     
    6663#include <stdlib.h>
    6764
     65/* memcpy().  */
     66#include <string.h>
     67
    6868/* errno.  */
    6969#include <errno.h>
     
    8383PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
    8484{
    85   const CHAR_T *cp = format;            /* pointer into format */
     85  const CHAR_T *cp = format;    /* pointer into format */
    8686  size_t arg_posn = 0;          /* number of regular arguments consumed */
    87   size_t d_allocated;                   /* allocated elements of d->dir */
    88   size_t a_allocated;                   /* allocated elements of a->arg */
     87  size_t d_allocated;           /* allocated elements of d->dir */
     88  size_t a_allocated;           /* allocated elements of a->arg */
    8989  size_t max_width_length = 0;
    9090  size_t max_precision_length = 0;
    9191
    9292  d->count = 0;
    93   d_allocated = 1;
    94   d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE));
    95   if (d->dir == NULL)
    96     /* Out of memory.  */
    97     goto out_of_memory_1;
     93  d_allocated = N_DIRECT_ALLOC_DIRECTIVES;
     94  d->dir = d->direct_alloc_dir;
    9895
    9996  a->count = 0;
    100   a_allocated = 0;
    101   a->arg = NULL;
     97  a_allocated = N_DIRECT_ALLOC_ARGUMENTS;
     98  a->arg = a->direct_alloc_arg;
    10299
    103100#define REGISTER_ARG(_index_,_type_) \
     
    116113          /* Overflow, would lead to out of memory.  */                 \
    117114          goto out_of_memory;                                           \
    118         memory = (argument *) (a->arg                                   \
     115        memory = (argument *) (a->arg != a->direct_alloc_arg            \
    119116                               ? realloc (a->arg, memory_size)          \
    120117                               : malloc (memory_size));                 \
     
    122119          /* Out of memory.  */                                         \
    123120          goto out_of_memory;                                           \
     121        if (a->arg == a->direct_alloc_arg)                              \
     122          memcpy (memory, a->arg, a->count * sizeof (argument));        \
    124123        a->arg = memory;                                                \
    125124      }                                                                 \
     
    209208                  cp++;
    210209                }
     210#if __GLIBC__ >= 2 && !defined __UCLIBC__
     211              else if (*cp == 'I')
     212                {
     213                  dp->flags |= FLAG_LOCALIZED;
     214                  cp++;
     215                }
     216#endif
    211217              else
    212218                break;
     
    396402                    }
    397403#if defined __APPLE__ && defined __MACH__
    398                   /* On MacOS X 10.3, PRIdMAX is defined as "qd".
     404                  /* On Mac OS X 10.3, PRIdMAX is defined as "qd".
    399405                     We cannot change it to "lld" because PRIdMAX must also
    400406                     be understood by the system's printf routines.  */
     
    415421#endif
    416422#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
    417                   /* On native Win32, PRIdMAX is defined as "I64d".
     423                  /* On native Windows, PRIdMAX is defined as "I64d".
    418424                     We cannot change it to "lld" because PRIdMAX must also
    419425                     be understood by the system's printf routines.  */
     
    584590                /* Overflow, would lead to out of memory.  */
    585591                goto out_of_memory;
    586               memory = (DIRECTIVE *) realloc (d->dir, memory_size);
     592              memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
     593                                      ? realloc (d->dir, memory_size)
     594                                      : malloc (memory_size));
    587595              if (memory == NULL)
    588596                /* Out of memory.  */
    589597                goto out_of_memory;
     598              if (d->dir == d->direct_alloc_dir)
     599                memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE));
    590600              d->dir = memory;
    591601            }
     
    606616
    607617error:
    608   if (a->arg)
     618  if (a->arg != a->direct_alloc_arg)
    609619    free (a->arg);
    610   if (d->dir)
     620  if (d->dir != d->direct_alloc_dir)
    611621    free (d->dir);
    612622  errno = EINVAL;
     
    614624
    615625out_of_memory:
    616   if (a->arg)
     626  if (a->arg != a->direct_alloc_arg)
    617627    free (a->arg);
    618   if (d->dir)
     628  if (d->dir != d->direct_alloc_dir)
    619629    free (d->dir);
    620 out_of_memory_1:
    621630  errno = ENOMEM;
    622631  return -1;
Note: See TracChangeset for help on using the changeset viewer.