bug-cpio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-cpio] cpio-2.6 portability patches


From: Albert Chin
Subject: [Bug-cpio] cpio-2.6 portability patches
Date: Mon, 10 Jan 2005 15:05:09 -0600
User-agent: Mutt/1.5.6i

1. Tru64 UNIX 4.0D doesn't have vsnprintf()/vasnprintf(). Patch below.
   I just sucked in the files from gnulib.
2. Switch from old BSD bzero()/bcopy()/index() functions to non-BSD
   variants (memset()/memcpy()/strchr()).
3. IRIX 6.5 has isnumber(). Rename to is_number().

-- 
albert chin (address@hidden)

-- snip snip
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/vasnprintf.c    2005-01-09 20:12:59.000000000 -0600
@@ -0,0 +1,896 @@
+/* vsprintf with automatic memory allocation.
+   Copyright (C) 1999, 2002-2004 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+   This must come before <config.h> because <config.h> may include
+   <features.h>, and once <features.h> has been included, it's too late.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE    1
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#ifndef IN_LIBINTL
+# include <alloca.h>
+#endif
+
+/* Specification.  */
+#if WIDE_CHAR_VERSION
+# include "vasnwprintf.h"
+#else
+# include "vasnprintf.h"
+#endif
+
+#include <stdio.h>     /* snprintf(), sprintf() */
+#include <stdlib.h>    /* abort(), malloc(), realloc(), free() */
+#include <string.h>    /* memcpy(), strlen() */
+#include <errno.h>     /* errno */
+#include <limits.h>    /* CHAR_BIT, INT_MAX */
+#include <float.h>     /* DBL_MAX_EXP, LDBL_MAX_EXP */
+#if WIDE_CHAR_VERSION
+# include "wprintf-parse.h"
+#else
+# include "printf-parse.h"
+#endif
+
+/* Checked size_t computations.  */
+#include "xsize.h"
+
+#ifdef HAVE_WCHAR_T
+# ifdef HAVE_WCSLEN
+#  define local_wcslen wcslen
+# else
+   /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
+      a dependency towards this library, here is a local substitute.
+      Define this substitute only once, even if this file is included
+      twice in the same compilation unit.  */
+#  ifndef local_wcslen_defined
+#   define local_wcslen_defined 1
+static size_t
+local_wcslen (const wchar_t *s)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; *ptr != (wchar_t) 0; ptr++)
+    ;
+  return ptr - s;
+}
+#  endif
+# endif
+#endif
+
+#if WIDE_CHAR_VERSION
+# define VASNPRINTF vasnwprintf
+# define CHAR_T wchar_t
+# define DIRECTIVE wchar_t_directive
+# define DIRECTIVES wchar_t_directives
+# define PRINTF_PARSE wprintf_parse
+# define USE_SNPRINTF 1
+# if HAVE_DECL__SNWPRINTF
+   /* On Windows, the function swprintf() has a different signature than
+      on Unix; we use the _snwprintf() function instead.  */
+#  define SNPRINTF _snwprintf
+# else
+   /* Unix.  */
+#  define SNPRINTF swprintf
+# endif
+#else
+# define VASNPRINTF vasnprintf
+# define CHAR_T char
+# define DIRECTIVE char_directive
+# define DIRECTIVES char_directives
+# define PRINTF_PARSE printf_parse
+# define USE_SNPRINTF (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF)
+# if HAVE_DECL__SNPRINTF
+   /* Windows.  */
+#  define SNPRINTF _snprintf
+# else
+   /* Unix.  */
+#  define SNPRINTF snprintf
+# endif
+#endif
+
+CHAR_T *
+VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list 
args)
+{
+  DIRECTIVES d;
+  arguments a;
+
+  if (PRINTF_PARSE (format, &d, &a) < 0)
+    {
+      errno = EINVAL;
+      return NULL;
+    }
+
+#define CLEANUP() \
+  free (d.dir);                                                                
\
+  if (a.arg)                                                           \
+    free (a.arg);
+
+  if (printf_fetchargs (args, &a) < 0)
+    {
+      CLEANUP ();
+      errno = EINVAL;
+      return NULL;
+    }
+
+  {
+    size_t buf_neededlength;
+    CHAR_T *buf;
+    CHAR_T *buf_malloced;
+    const CHAR_T *cp;
+    size_t i;
+    DIRECTIVE *dp;
+    /* Output string accumulator.  */
+    CHAR_T *result;
+    size_t allocated;
+    size_t length;
+
+    /* Allocate a small buffer that will hold a directive passed to
+       sprintf or snprintf.  */
+    buf_neededlength =
+      xsum4 (7, d.max_width_length, d.max_precision_length, 6);
+#if HAVE_ALLOCA
+    if (buf_neededlength < 4000 / sizeof (CHAR_T))
+      {
+       buf = (CHAR_T *) alloca (buf_neededlength * sizeof (CHAR_T));
+       buf_malloced = NULL;
+      }
+    else
+#endif
+      {
+       size_t buf_memsize = xtimes (buf_neededlength, sizeof (CHAR_T));
+       if (size_overflow_p (buf_memsize))
+         goto out_of_memory_1;
+       buf = (CHAR_T *) malloc (buf_memsize);
+       if (buf == NULL)
+         goto out_of_memory_1;
+       buf_malloced = buf;
+      }
+
+    if (resultbuf != NULL)
+      {
+       result = resultbuf;
+       allocated = *lengthp;
+      }
+    else
+      {
+       result = NULL;
+       allocated = 0;
+      }
+    length = 0;
+    /* Invariants:
+       result is either == resultbuf or == NULL or malloc-allocated.
+       If length > 0, then result != NULL.  */
+
+    /* Ensures that allocated >= needed.  Aborts through a jump to
+       out_of_memory if needed is SIZE_MAX or otherwise too big.  */
+#define ENSURE_ALLOCATION(needed) \
+    if ((needed) > allocated)                                               \
+      {                                                                        
     \
+       size_t memory_size;                                                  \
+       CHAR_T *memory;                                                      \
+                                                                            \
+       allocated = (allocated > 0 ? xtimes (allocated, 2) : 12);            \
+       if ((needed) > allocated)                                            \
+         allocated = (needed);                                              \
+       memory_size = xtimes (allocated, sizeof (CHAR_T));                   \
+       if (size_overflow_p (memory_size))                                   \
+         goto out_of_memory;                                                \
+       if (result == resultbuf || result == NULL)                           \
+         memory = (CHAR_T *) malloc (memory_size);                          \
+       else                                                                 \
+         memory = (CHAR_T *) realloc (result, memory_size);                 \
+       if (memory == NULL)                                                  \
+         goto out_of_memory;                                                \
+       if (result == resultbuf && length > 0)                               \
+         memcpy (memory, result, length * sizeof (CHAR_T));                 \
+       result = memory;                                                     \
+      }
+
+    for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
+      {
+       if (cp != dp->dir_start)
+         {
+           size_t n = dp->dir_start - cp;
+           size_t augmented_length = xsum (length, n);
+
+           ENSURE_ALLOCATION (augmented_length);
+           memcpy (result + length, cp, n * sizeof (CHAR_T));
+           length = augmented_length;
+         }
+       if (i == d.count)
+         break;
+
+       /* Execute a single directive.  */
+       if (dp->conversion == '%')
+         {
+           size_t augmented_length;
+
+           if (!(dp->arg_index == ARG_NONE))
+             abort ();
+           augmented_length = xsum (length, 1);
+           ENSURE_ALLOCATION (augmented_length);
+           result[length] = '%';
+           length = augmented_length;
+         }
+       else
+         {
+           if (!(dp->arg_index != ARG_NONE))
+             abort ();
+
+           if (dp->conversion == 'n')
+             {
+               switch (a.arg[dp->arg_index].type)
+                 {
+                 case TYPE_COUNT_SCHAR_POINTER:
+                   *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
+                   break;
+                 case TYPE_COUNT_SHORT_POINTER:
+                   *a.arg[dp->arg_index].a.a_count_short_pointer = length;
+                   break;
+                 case TYPE_COUNT_INT_POINTER:
+                   *a.arg[dp->arg_index].a.a_count_int_pointer = length;
+                   break;
+                 case TYPE_COUNT_LONGINT_POINTER:
+                   *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
+                   break;
+#ifdef HAVE_LONG_LONG
+                 case TYPE_COUNT_LONGLONGINT_POINTER:
+                   *a.arg[dp->arg_index].a.a_count_longlongint_pointer = 
length;
+                   break;
+#endif
+                 default:
+                   abort ();
+                 }
+             }
+           else
+             {
+               arg_type type = a.arg[dp->arg_index].type;
+               CHAR_T *p;
+               unsigned int prefix_count;
+               int prefixes[2];
+#if !USE_SNPRINTF
+               size_t tmp_length;
+               CHAR_T tmpbuf[700];
+               CHAR_T *tmp;
+
+               /* Allocate a temporary buffer of sufficient size for calling
+                  sprintf.  */
+               {
+                 size_t width;
+                 size_t precision;
+
+                 width = 0;
+                 if (dp->width_start != dp->width_end)
+                   {
+                     if (dp->width_arg_index != ARG_NONE)
+                       {
+                         int arg;
+
+                         if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                           abort ();
+                         arg = a.arg[dp->width_arg_index].a.a_int;
+                         width = (arg < 0 ? (unsigned int) (-arg) : arg);
+                       }
+                     else
+                       {
+                         const CHAR_T *digitp = dp->width_start;
+
+                         do
+                           width = xsum (xtimes (width, 10), *digitp++ - '0');
+                         while (digitp != dp->width_end);
+                       }
+                   }
+
+                 precision = 6;
+                 if (dp->precision_start != dp->precision_end)
+                   {
+                     if (dp->precision_arg_index != ARG_NONE)
+                       {
+                         int arg;
+
+                         if (!(a.arg[dp->precision_arg_index].type == 
TYPE_INT))
+                           abort ();
+                         arg = a.arg[dp->precision_arg_index].a.a_int;
+                         precision = (arg < 0 ? 0 : arg);
+                       }
+                     else
+                       {
+                         const CHAR_T *digitp = dp->precision_start + 1;
+
+                         precision = 0;
+                         while (digitp != dp->precision_end)
+                           precision = xsum (xtimes (precision, 10), *digitp++ 
- '0');
+                       }
+                   }
+
+                 switch (dp->conversion)
+                   {
+
+                   case 'd': case 'i': case 'u':
+# ifdef HAVE_LONG_LONG
+                     if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+                                         * 0.30103 /* binary -> decimal */
+                                         * 2 /* estimate for FLAG_GROUP */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 1; /* account for leading sign */
+                     else
+# endif
+                     if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+                                         * 0.30103 /* binary -> decimal */
+                                         * 2 /* estimate for FLAG_GROUP */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 1; /* account for leading sign */
+                     else
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+                                         * 0.30103 /* binary -> decimal */
+                                         * 2 /* estimate for FLAG_GROUP */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 1; /* account for leading sign */
+                     break;
+
+                   case 'o':
+# ifdef HAVE_LONG_LONG
+                     if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+                                         * 0.333334 /* binary -> octal */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 1; /* account for leading sign */
+                     else
+# endif
+                     if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+                                         * 0.333334 /* binary -> octal */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 1; /* account for leading sign */
+                     else
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+                                         * 0.333334 /* binary -> octal */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 1; /* account for leading sign */
+                     break;
+
+                   case 'x': case 'X':
+# ifdef HAVE_LONG_LONG
+                     if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+                                         * 0.25 /* binary -> hexadecimal */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 2; /* account for leading sign or alternate form */
+                     else
+# endif
+                     if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+                                         * 0.25 /* binary -> hexadecimal */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 2; /* account for leading sign or alternate form */
+                     else
+                       tmp_length =
+                         (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+                                         * 0.25 /* binary -> hexadecimal */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 2; /* account for leading sign or alternate form */
+                     break;
+
+                   case 'f': case 'F':
+# ifdef HAVE_LONG_DOUBLE
+                     if (type == TYPE_LONGDOUBLE)
+                       tmp_length =
+                         (unsigned int) (LDBL_MAX_EXP
+                                         * 0.30103 /* binary -> decimal */
+                                         * 2 /* estimate for FLAG_GROUP */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 10; /* sign, decimal point etc. */
+                     else
+# endif
+                       tmp_length =
+                         (unsigned int) (DBL_MAX_EXP
+                                         * 0.30103 /* binary -> decimal */
+                                         * 2 /* estimate for FLAG_GROUP */
+                                        )
+                         + 1 /* turn floor into ceil */
+                         + 10; /* sign, decimal point etc. */
+                     tmp_length = xsum (tmp_length, precision);
+                     break;
+
+                   case 'e': case 'E': case 'g': case 'G':
+                   case 'a': case 'A':
+                     tmp_length =
+                       12; /* sign, decimal point, exponent etc. */
+                     tmp_length = xsum (tmp_length, precision);
+                     break;
+
+                   case 'c':
+# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION
+                     if (type == TYPE_WIDE_CHAR)
+                       tmp_length = MB_CUR_MAX;
+                     else
+# endif
+                       tmp_length = 1;
+                     break;
+
+                   case 's':
+# ifdef HAVE_WCHAR_T
+                     if (type == TYPE_WIDE_STRING)
+                       {
+                         tmp_length =
+                           local_wcslen (a.arg[dp->arg_index].a.a_wide_string);
+
+#  if !WIDE_CHAR_VERSION
+                         tmp_length = xtimes (tmp_length, MB_CUR_MAX);
+#  endif
+                       }
+                     else
+# endif
+                       tmp_length = strlen (a.arg[dp->arg_index].a.a_string);
+                     break;
+
+                   case 'p':
+                     tmp_length =
+                       (unsigned int) (sizeof (void *) * CHAR_BIT
+                                       * 0.25 /* binary -> hexadecimal */
+                                      )
+                         + 1 /* turn floor into ceil */
+                         + 2; /* account for leading 0x */
+                     break;
+
+                   default:
+                     abort ();
+                   }
+
+                 if (tmp_length < width)
+                   tmp_length = width;
+
+                 tmp_length = xsum (tmp_length, 1); /* account for trailing 
NUL */
+               }
+
+               if (tmp_length <= sizeof (tmpbuf) / sizeof (CHAR_T))
+                 tmp = tmpbuf;
+               else
+                 {
+                   size_t tmp_memsize = xtimes (tmp_length, sizeof (CHAR_T));
+
+                   if (size_overflow_p (tmp_memsize))
+                     /* Overflow, would lead to out of memory.  */
+                     goto out_of_memory;
+                   tmp = (CHAR_T *) malloc (tmp_memsize);
+                   if (tmp == NULL)
+                     /* Out of memory.  */
+                     goto out_of_memory;
+                 }
+#endif
+
+               /* Construct the format string for calling snprintf or
+                  sprintf.  */
+               p = buf;
+               *p++ = '%';
+               if (dp->flags & FLAG_GROUP)
+                 *p++ = '\'';
+               if (dp->flags & FLAG_LEFT)
+                 *p++ = '-';
+               if (dp->flags & FLAG_SHOWSIGN)
+                 *p++ = '+';
+               if (dp->flags & FLAG_SPACE)
+                 *p++ = ' ';
+               if (dp->flags & FLAG_ALT)
+                 *p++ = '#';
+               if (dp->flags & FLAG_ZERO)
+                 *p++ = '0';
+               if (dp->width_start != dp->width_end)
+                 {
+                   size_t n = dp->width_end - dp->width_start;
+                   memcpy (p, dp->width_start, n * sizeof (CHAR_T));
+                   p += n;
+                 }
+               if (dp->precision_start != dp->precision_end)
+                 {
+                   size_t n = dp->precision_end - dp->precision_start;
+                   memcpy (p, dp->precision_start, n * sizeof (CHAR_T));
+                   p += n;
+                 }
+
+               switch (type)
+                 {
+#ifdef HAVE_LONG_LONG
+                 case TYPE_LONGLONGINT:
+                 case TYPE_ULONGLONGINT:
+                   *p++ = 'l';
+                   /*FALLTHROUGH*/
+#endif
+                 case TYPE_LONGINT:
+                 case TYPE_ULONGINT:
+#ifdef HAVE_WINT_T
+                 case TYPE_WIDE_CHAR:
+#endif
+#ifdef HAVE_WCHAR_T
+                 case TYPE_WIDE_STRING:
+#endif
+                   *p++ = 'l';
+                   break;
+#ifdef HAVE_LONG_DOUBLE
+                 case TYPE_LONGDOUBLE:
+                   *p++ = 'L';
+                   break;
+#endif
+                 default:
+                   break;
+                 }
+               *p = dp->conversion;
+#if USE_SNPRINTF
+               p[1] = '%';
+               p[2] = 'n';
+               p[3] = '\0';
+#else
+               p[1] = '\0';
+#endif
+
+               /* Construct the arguments for calling snprintf or sprintf.  */
+               prefix_count = 0;
+               if (dp->width_arg_index != ARG_NONE)
+                 {
+                   if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                     abort ();
+                   prefixes[prefix_count++] = 
a.arg[dp->width_arg_index].a.a_int;
+                 }
+               if (dp->precision_arg_index != ARG_NONE)
+                 {
+                   if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                     abort ();
+                   prefixes[prefix_count++] = 
a.arg[dp->precision_arg_index].a.a_int;
+                 }
+
+#if USE_SNPRINTF
+               /* Prepare checking whether snprintf returns the count
+                  via %n.  */
+               ENSURE_ALLOCATION (xsum (length, 1));
+               result[length] = '\0';
+#endif
+
+               for (;;)
+                 {
+                   size_t maxlen;
+                   int count;
+                   int retcount;
+
+                   maxlen = allocated - length;
+                   count = -1;
+                   retcount = 0;
+
+#if USE_SNPRINTF
+# define SNPRINTF_BUF(arg) \
+                   switch (prefix_count)                                   \
+                     {                                                     \
+                     case 0:                                               \
+                       retcount = SNPRINTF (result + length, maxlen, buf,  \
+                                            arg, &count);                  \
+                       break;                                              \
+                     case 1:                                               \
+                       retcount = SNPRINTF (result + length, maxlen, buf,  \
+                                            prefixes[0], arg, &count);     \
+                       break;                                              \
+                     case 2:                                               \
+                       retcount = SNPRINTF (result + length, maxlen, buf,  \
+                                            prefixes[0], prefixes[1], arg, \
+                                            &count);                       \
+                       break;                                              \
+                     default:                                              \
+                       abort ();                                           \
+                     }
+#else
+# define SNPRINTF_BUF(arg) \
+                   switch (prefix_count)                                   \
+                     {                                                     \
+                     case 0:                                               \
+                       count = sprintf (tmp, buf, arg);                    \
+                       break;                                              \
+                     case 1:                                               \
+                       count = sprintf (tmp, buf, prefixes[0], arg);       \
+                       break;                                              \
+                     case 2:                                               \
+                       count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
+                                        arg);                              \
+                       break;                                              \
+                     default:                                              \
+                       abort ();                                           \
+                     }
+#endif
+
+                   switch (type)
+                     {
+                     case TYPE_SCHAR:
+                       {
+                         int arg = a.arg[dp->arg_index].a.a_schar;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_UCHAR:
+                       {
+                         unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_SHORT:
+                       {
+                         int arg = a.arg[dp->arg_index].a.a_short;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_USHORT:
+                       {
+                         unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_INT:
+                       {
+                         int arg = a.arg[dp->arg_index].a.a_int;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_UINT:
+                       {
+                         unsigned int arg = a.arg[dp->arg_index].a.a_uint;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_LONGINT:
+                       {
+                         long int arg = a.arg[dp->arg_index].a.a_longint;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_ULONGINT:
+                       {
+                         unsigned long int arg = 
a.arg[dp->arg_index].a.a_ulongint;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#ifdef HAVE_LONG_LONG
+                     case TYPE_LONGLONGINT:
+                       {
+                         long long int arg = 
a.arg[dp->arg_index].a.a_longlongint;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     case TYPE_ULONGLONGINT:
+                       {
+                         unsigned long long int arg = 
a.arg[dp->arg_index].a.a_ulonglongint;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#endif
+                     case TYPE_DOUBLE:
+                       {
+                         double arg = a.arg[dp->arg_index].a.a_double;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#ifdef HAVE_LONG_DOUBLE
+                     case TYPE_LONGDOUBLE:
+                       {
+                         long double arg = a.arg[dp->arg_index].a.a_longdouble;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#endif
+                     case TYPE_CHAR:
+                       {
+                         int arg = a.arg[dp->arg_index].a.a_char;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#ifdef HAVE_WINT_T
+                     case TYPE_WIDE_CHAR:
+                       {
+                         wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#endif
+                     case TYPE_STRING:
+                       {
+                         const char *arg = a.arg[dp->arg_index].a.a_string;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#ifdef HAVE_WCHAR_T
+                     case TYPE_WIDE_STRING:
+                       {
+                         const wchar_t *arg = 
a.arg[dp->arg_index].a.a_wide_string;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+#endif
+                     case TYPE_POINTER:
+                       {
+                         void *arg = a.arg[dp->arg_index].a.a_pointer;
+                         SNPRINTF_BUF (arg);
+                       }
+                       break;
+                     default:
+                       abort ();
+                     }
+
+#if USE_SNPRINTF
+                   /* Portability: Not all implementations of snprintf()
+                      are ISO C 99 compliant.  Determine the number of
+                      bytes that snprintf() has produced or would have
+                      produced.  */
+                   if (count >= 0)
+                     {
+                       /* Verify that snprintf() has NUL-terminated its
+                          result.  */
+                       if (count < maxlen && result[length + count] != '\0')
+                         abort ();
+                       /* Portability hack.  */
+                       if (retcount > count)
+                         count = retcount;
+                     }
+                   else
+                     {
+                       /* snprintf() doesn't understand the '%n'
+                          directive.  */
+                       if (p[1] != '\0')
+                         {
+                           /* Don't use the '%n' directive; instead, look
+                              at the snprintf() return value.  */
+                           p[1] = '\0';
+                           continue;
+                         }
+                       else
+                         {
+                           /* Look at the snprintf() return value.  */
+                           if (retcount < 0)
+                             {
+                               /* HP-UX 10.20 snprintf() is doubly deficient:
+                                  It doesn't understand the '%n' directive,
+                                  *and* it returns -1 (rather than the length
+                                  that would have been required) when the
+                                  buffer is too small.  */
+                               size_t bigger_need =
+                                 xsum (xtimes (allocated, 2), 12);
+                               ENSURE_ALLOCATION (bigger_need);
+                               continue;
+                             }
+                           else
+                             count = retcount;
+                         }
+                     }
+#endif
+
+                   /* Attempt to handle failure.  */
+                   if (count < 0)
+                     {
+                       if (!(result == resultbuf || result == NULL))
+                         free (result);
+                       if (buf_malloced != NULL)
+                         free (buf_malloced);
+                       CLEANUP ();
+                       errno = EINVAL;
+                       return NULL;
+                     }
+
+#if !USE_SNPRINTF
+                   if (count >= tmp_length)
+                     /* tmp_length was incorrectly calculated - fix the
+                        code above!  */
+                     abort ();
+#endif
+
+                   /* Make room for the result.  */
+                   if (count >= maxlen)
+                     {
+                       /* Need at least count bytes.  But allocate
+                          proportionally, to avoid looping eternally if
+                          snprintf() reports a too small count.  */
+                       size_t n =
+                         xmax (xsum (length, count), xtimes (allocated, 2));
+
+                       ENSURE_ALLOCATION (n);
+#if USE_SNPRINTF
+                       continue;
+#endif
+                     }
+
+#if USE_SNPRINTF
+                   /* The snprintf() result did fit.  */
+#else
+                   /* Append the sprintf() result.  */
+                   memcpy (result + length, tmp, count * sizeof (CHAR_T));
+                   if (tmp != tmpbuf)
+                     free (tmp);
+#endif
+
+                   length += count;
+                   break;
+                 }
+             }
+         }
+      }
+
+    /* Add the final NUL.  */
+    ENSURE_ALLOCATION (xsum (length, 1));
+    result[length] = '\0';
+
+    if (result != resultbuf && length + 1 < allocated)
+      {
+       /* Shrink the allocated memory if possible.  */
+       CHAR_T *memory;
+
+       memory = (CHAR_T *) realloc (result, (length + 1) * sizeof (CHAR_T));
+       if (memory != NULL)
+         result = memory;
+      }
+
+    if (buf_malloced != NULL)
+      free (buf_malloced);
+    CLEANUP ();
+    *lengthp = length;
+    if (length > INT_MAX)
+      goto length_overflow;
+    return result;
+
+  length_overflow:
+    /* We could produce such a big string, but its length doesn't fit into
+       an 'int'.  POSIX says that snprintf() fails with errno = EOVERFLOW in
+       this case.  */
+    if (result != resultbuf)
+      free (result);
+    errno = EOVERFLOW;
+    return NULL;
+
+  out_of_memory:
+    if (!(result == resultbuf || result == NULL))
+      free (result);
+    if (buf_malloced != NULL)
+      free (buf_malloced);
+  out_of_memory_1:
+    CLEANUP ();
+    errno = ENOMEM;
+    return NULL;
+  }
+}
+
+#undef SNPRINTF
+#undef USE_SNPRINTF
+#undef PRINTF_PARSE
+#undef DIRECTIVES
+#undef DIRECTIVE
+#undef CHAR_T
+#undef VASNPRINTF
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/vasnprintf.h    2005-01-09 20:12:57.000000000 -0600
@@ -0,0 +1,77 @@
+/* vsprintf with automatic memory allocation.
+   Copyright (C) 2002-2004 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _VASNPRINTF_H
+#define _VASNPRINTF_H
+
+/* Get va_list.  */
+#include <stdarg.h>
+
+/* Get size_t.  */
+#include <stddef.h>
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+#  define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __format__ format
+#  define __printf__ printf
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Write formatted output to a string dynamically allocated with malloc().
+   You can pass a preallocated buffer for the result in RESULTBUF and its
+   size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
+   If successful, return the address of the string (this may be = RESULTBUF
+   if no dynamic memory allocation was necessary) and set *LENGTHP to the
+   number of resulting bytes, excluding the trailing NUL.  Upon error, set
+   errno and return NULL.
+
+   When dynamic memory allocation occurs, the preallocated buffer is left
+   alone (with possibly modified contents).  This makes it possible to use
+   a statically allocated or stack-allocated buffer, like this:
+
+          char buf[100];
+          size_t len = sizeof (buf);
+          char *output = vasnprintf (buf, &len, format, args);
+          if (output == NULL)
+            ... error handling ...;
+          else
+            {
+              ... use the output string ...;
+              if (output != buf)
+                free (output);
+            }
+  */
+extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, 
...)
+       __attribute__ ((__format__ (__printf__, 3, 4)));
+extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char 
*format, va_list args)
+       __attribute__ ((__format__ (__printf__, 3, 0)));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VASNPRINTF_H */
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/asnprintf.c     2005-01-09 20:37:05.000000000 -0600
@@ -0,0 +1,37 @@
+/* Formatted output to strings.
+   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification.  */
+#include "vasnprintf.h"
+
+#include <stdarg.h>
+
+char *
+asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+{
+  va_list args;
+  char *result;
+
+  va_start (args, format);
+  result = vasnprintf (resultbuf, lengthp, format, args);
+  va_end (args);
+  return result;
+}
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/printf-args.c   2005-01-09 20:37:16.000000000 -0600
@@ -0,0 +1,118 @@
+/* Decomposed printf argument list.
+   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification.  */
+#include "printf-args.h"
+
+#ifdef STATIC
+STATIC
+#endif
+int
+printf_fetchargs (va_list args, arguments *a)
+{
+  size_t i;
+  argument *ap;
+
+  for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
+    switch (ap->type)
+      {
+      case TYPE_SCHAR:
+       ap->a.a_schar = va_arg (args, /*signed char*/ int);
+       break;
+      case TYPE_UCHAR:
+       ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
+       break;
+      case TYPE_SHORT:
+       ap->a.a_short = va_arg (args, /*short*/ int);
+       break;
+      case TYPE_USHORT:
+       ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
+       break;
+      case TYPE_INT:
+       ap->a.a_int = va_arg (args, int);
+       break;
+      case TYPE_UINT:
+       ap->a.a_uint = va_arg (args, unsigned int);
+       break;
+      case TYPE_LONGINT:
+       ap->a.a_longint = va_arg (args, long int);
+       break;
+      case TYPE_ULONGINT:
+       ap->a.a_ulongint = va_arg (args, unsigned long int);
+       break;
+#ifdef HAVE_LONG_LONG
+      case TYPE_LONGLONGINT:
+       ap->a.a_longlongint = va_arg (args, long long int);
+       break;
+      case TYPE_ULONGLONGINT:
+       ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
+       break;
+#endif
+      case TYPE_DOUBLE:
+       ap->a.a_double = va_arg (args, double);
+       break;
+#ifdef HAVE_LONG_DOUBLE
+      case TYPE_LONGDOUBLE:
+       ap->a.a_longdouble = va_arg (args, long double);
+       break;
+#endif
+      case TYPE_CHAR:
+       ap->a.a_char = va_arg (args, int);
+       break;
+#ifdef HAVE_WINT_T
+      case TYPE_WIDE_CHAR:
+       ap->a.a_wide_char = va_arg (args, wint_t);
+       break;
+#endif
+      case TYPE_STRING:
+       ap->a.a_string = va_arg (args, const char *);
+       break;
+#ifdef HAVE_WCHAR_T
+      case TYPE_WIDE_STRING:
+       ap->a.a_wide_string = va_arg (args, const wchar_t *);
+       break;
+#endif
+      case TYPE_POINTER:
+       ap->a.a_pointer = va_arg (args, void *);
+       break;
+      case TYPE_COUNT_SCHAR_POINTER:
+       ap->a.a_count_schar_pointer = va_arg (args, signed char *);
+       break;
+      case TYPE_COUNT_SHORT_POINTER:
+       ap->a.a_count_short_pointer = va_arg (args, short *);
+       break;
+      case TYPE_COUNT_INT_POINTER:
+       ap->a.a_count_int_pointer = va_arg (args, int *);
+       break;
+      case TYPE_COUNT_LONGINT_POINTER:
+       ap->a.a_count_longint_pointer = va_arg (args, long int *);
+       break;
+#ifdef HAVE_LONG_LONG
+      case TYPE_COUNT_LONGLONGINT_POINTER:
+       ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
+       break;
+#endif
+      default:
+       /* Unknown type.  */
+       return -1;
+      }
+  return 0;
+}
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/printf-args.h   2005-01-09 20:37:16.000000000 -0600
@@ -0,0 +1,136 @@
+/* Decomposed printf argument list.
+   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _PRINTF_ARGS_H
+#define _PRINTF_ARGS_H
+
+/* Get size_t.  */
+#include <stddef.h>
+
+/* Get wchar_t.  */
+#ifdef HAVE_WCHAR_T
+# include <stddef.h>
+#endif
+
+/* Get wint_t.  */
+#ifdef HAVE_WINT_T
+# include <wchar.h>
+#endif
+
+/* Get va_list.  */
+#include <stdarg.h>
+
+
+/* Argument types */
+typedef enum
+{
+  TYPE_NONE,
+  TYPE_SCHAR,
+  TYPE_UCHAR,
+  TYPE_SHORT,
+  TYPE_USHORT,
+  TYPE_INT,
+  TYPE_UINT,
+  TYPE_LONGINT,
+  TYPE_ULONGINT,
+#ifdef HAVE_LONG_LONG
+  TYPE_LONGLONGINT,
+  TYPE_ULONGLONGINT,
+#endif
+  TYPE_DOUBLE,
+#ifdef HAVE_LONG_DOUBLE
+  TYPE_LONGDOUBLE,
+#endif
+  TYPE_CHAR,
+#ifdef HAVE_WINT_T
+  TYPE_WIDE_CHAR,
+#endif
+  TYPE_STRING,
+#ifdef HAVE_WCHAR_T
+  TYPE_WIDE_STRING,
+#endif
+  TYPE_POINTER,
+  TYPE_COUNT_SCHAR_POINTER,
+  TYPE_COUNT_SHORT_POINTER,
+  TYPE_COUNT_INT_POINTER,
+  TYPE_COUNT_LONGINT_POINTER
+#ifdef HAVE_LONG_LONG
+, TYPE_COUNT_LONGLONGINT_POINTER
+#endif
+} arg_type;
+
+/* Polymorphic argument */
+typedef struct
+{
+  arg_type type;
+  union
+  {
+    signed char                        a_schar;
+    unsigned char              a_uchar;
+    short                      a_short;
+    unsigned short             a_ushort;
+    int                                a_int;
+    unsigned int               a_uint;
+    long int                   a_longint;
+    unsigned long int          a_ulongint;
+#ifdef HAVE_LONG_LONG
+    long long int              a_longlongint;
+    unsigned long long int     a_ulonglongint;
+#endif
+    float                      a_float;
+    double                     a_double;
+#ifdef HAVE_LONG_DOUBLE
+    long double                        a_longdouble;
+#endif
+    int                                a_char;
+#ifdef HAVE_WINT_T
+    wint_t                     a_wide_char;
+#endif
+    const char*                        a_string;
+#ifdef HAVE_WCHAR_T
+    const wchar_t*             a_wide_string;
+#endif
+    void*                      a_pointer;
+    signed char *              a_count_schar_pointer;
+    short *                    a_count_short_pointer;
+    int *                      a_count_int_pointer;
+    long int *                 a_count_longint_pointer;
+#ifdef HAVE_LONG_LONG
+    long long int *            a_count_longlongint_pointer;
+#endif
+  }
+  a;
+}
+argument;
+
+typedef struct
+{
+  size_t count;
+  argument *arg;
+}
+arguments;
+
+
+/* Fetch the arguments, putting them into a. */
+#ifdef STATIC
+STATIC
+#else
+extern
+#endif
+int printf_fetchargs (va_list args, arguments *a);
+
+#endif /* _PRINTF_ARGS_H */
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/printf-parse.c  2005-01-09 20:37:22.000000000 -0600
@@ -0,0 +1,536 @@
+/* Formatted output to strings.
+   Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification.  */
+#if WIDE_CHAR_VERSION
+# include "wprintf-parse.h"
+#else
+# include "printf-parse.h"
+#endif
+
+/* Get size_t, NULL.  */
+#include <stddef.h>
+
+/* Get intmax_t.  */
+#if HAVE_STDINT_H_WITH_UINTMAX
+# include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H_WITH_UINTMAX
+# include <inttypes.h>
+#endif
+
+/* malloc(), realloc(), free().  */
+#include <stdlib.h>
+
+/* Checked size_t computations.  */
+#include "xsize.h"
+
+#if WIDE_CHAR_VERSION
+# define PRINTF_PARSE wprintf_parse
+# define CHAR_T wchar_t
+# define DIRECTIVE wchar_t_directive
+# define DIRECTIVES wchar_t_directives
+#else
+# define PRINTF_PARSE printf_parse
+# define CHAR_T char
+# define DIRECTIVE char_directive
+# define DIRECTIVES char_directives
+#endif
+
+#ifdef STATIC
+STATIC
+#endif
+int
+PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
+{
+  const CHAR_T *cp = format;           /* pointer into format */
+  size_t arg_posn = 0;         /* number of regular arguments consumed */
+  size_t d_allocated;                  /* allocated elements of d->dir */
+  size_t a_allocated;                  /* allocated elements of a->arg */
+  size_t max_width_length = 0;
+  size_t max_precision_length = 0;
+
+  d->count = 0;
+  d_allocated = 1;
+  d->dir = malloc (d_allocated * sizeof (DIRECTIVE));
+  if (d->dir == NULL)
+    /* Out of memory.  */
+    return -1;
+
+  a->count = 0;
+  a_allocated = 0;
+  a->arg = NULL;
+
+#define REGISTER_ARG(_index_,_type_) \
+  {                                                                    \
+    size_t n = (_index_);                                              \
+    if (n >= a_allocated)                                              \
+      {                                                                        
\
+       size_t memory_size;                                             \
+       argument *memory;                                               \
+                                                                       \
+       a_allocated = xtimes (a_allocated, 2);                          \
+       if (a_allocated <= n)                                           \
+         a_allocated = xsum (n, 1);                                    \
+       memory_size = xtimes (a_allocated, sizeof (argument));          \
+       if (size_overflow_p (memory_size))                              \
+         /* Overflow, would lead to out of memory.  */                 \
+         goto error;                                                   \
+       memory = (a->arg                                                \
+                 ? realloc (a->arg, memory_size)                       \
+                 : malloc (memory_size));                              \
+       if (memory == NULL)                                             \
+         /* Out of memory.  */                                         \
+         goto error;                                                   \
+       a->arg = memory;                                                \
+      }                                                                        
\
+    while (a->count <= n)                                              \
+      a->arg[a->count++].type = TYPE_NONE;                             \
+    if (a->arg[n].type == TYPE_NONE)                                   \
+      a->arg[n].type = (_type_);                                       \
+    else if (a->arg[n].type != (_type_))                               \
+      /* Ambiguous type for positional argument.  */                   \
+      goto error;                                                      \
+  }
+
+  while (*cp != '\0')
+    {
+      CHAR_T c = *cp++;
+      if (c == '%')
+       {
+         size_t arg_index = ARG_NONE;
+         DIRECTIVE *dp = &d->dir[d->count];/* pointer to next directive */
+
+         /* Initialize the next directive.  */
+         dp->dir_start = cp - 1;
+         dp->flags = 0;
+         dp->width_start = NULL;
+         dp->width_end = NULL;
+         dp->width_arg_index = ARG_NONE;
+         dp->precision_start = NULL;
+         dp->precision_end = NULL;
+         dp->precision_arg_index = ARG_NONE;
+         dp->arg_index = ARG_NONE;
+
+         /* Test for positional argument.  */
+         if (*cp >= '0' && *cp <= '9')
+           {
+             const CHAR_T *np;
+
+             for (np = cp; *np >= '0' && *np <= '9'; np++)
+               ;
+             if (*np == '$')
+               {
+                 size_t n = 0;
+
+                 for (np = cp; *np >= '0' && *np <= '9'; np++)
+                   n = xsum (xtimes (n, 10), *np - '0');
+                 if (n == 0)
+                   /* Positional argument 0.  */
+                   goto error;
+                 if (size_overflow_p (n))
+                   /* n too large, would lead to out of memory later.  */
+                   goto error;
+                 arg_index = n - 1;
+                 cp = np + 1;
+               }
+           }
+
+         /* Read the flags.  */
+         for (;;)
+           {
+             if (*cp == '\'')
+               {
+                 dp->flags |= FLAG_GROUP;
+                 cp++;
+               }
+             else if (*cp == '-')
+               {
+                 dp->flags |= FLAG_LEFT;
+                 cp++;
+               }
+             else if (*cp == '+')
+               {
+                 dp->flags |= FLAG_SHOWSIGN;
+                 cp++;
+               }
+             else if (*cp == ' ')
+               {
+                 dp->flags |= FLAG_SPACE;
+                 cp++;
+               }
+             else if (*cp == '#')
+               {
+                 dp->flags |= FLAG_ALT;
+                 cp++;
+               }
+             else if (*cp == '0')
+               {
+                 dp->flags |= FLAG_ZERO;
+                 cp++;
+               }
+             else
+               break;
+           }
+
+         /* Parse the field width.  */
+         if (*cp == '*')
+           {
+             dp->width_start = cp;
+             cp++;
+             dp->width_end = cp;
+             if (max_width_length < 1)
+               max_width_length = 1;
+
+             /* Test for positional argument.  */
+             if (*cp >= '0' && *cp <= '9')
+               {
+                 const CHAR_T *np;
+
+                 for (np = cp; *np >= '0' && *np <= '9'; np++)
+                   ;
+                 if (*np == '$')
+                   {
+                     size_t n = 0;
+
+                     for (np = cp; *np >= '0' && *np <= '9'; np++)
+                       n = xsum (xtimes (n, 10), *np - '0');
+                     if (n == 0)
+                       /* Positional argument 0.  */
+                       goto error;
+                     if (size_overflow_p (n))
+                       /* n too large, would lead to out of memory later.  */
+                       goto error;
+                     dp->width_arg_index = n - 1;
+                     cp = np + 1;
+                   }
+               }
+             if (dp->width_arg_index == ARG_NONE)
+               {
+                 dp->width_arg_index = arg_posn++;
+                 if (dp->width_arg_index == ARG_NONE)
+                   /* arg_posn wrapped around.  */
+                   goto error;
+               }
+             REGISTER_ARG (dp->width_arg_index, TYPE_INT);
+           }
+         else if (*cp >= '0' && *cp <= '9')
+           {
+             size_t width_length;
+
+             dp->width_start = cp;
+             for (; *cp >= '0' && *cp <= '9'; cp++)
+               ;
+             dp->width_end = cp;
+             width_length = dp->width_end - dp->width_start;
+             if (max_width_length < width_length)
+               max_width_length = width_length;
+           }
+
+         /* Parse the precision.  */
+         if (*cp == '.')
+           {
+             cp++;
+             if (*cp == '*')
+               {
+                 dp->precision_start = cp - 1;
+                 cp++;
+                 dp->precision_end = cp;
+                 if (max_precision_length < 2)
+                   max_precision_length = 2;
+
+                 /* Test for positional argument.  */
+                 if (*cp >= '0' && *cp <= '9')
+                   {
+                     const CHAR_T *np;
+
+                     for (np = cp; *np >= '0' && *np <= '9'; np++)
+                       ;
+                     if (*np == '$')
+                       {
+                         size_t n = 0;
+
+                         for (np = cp; *np >= '0' && *np <= '9'; np++)
+                           n = xsum (xtimes (n, 10), *np - '0');
+                         if (n == 0)
+                           /* Positional argument 0.  */
+                           goto error;
+                         if (size_overflow_p (n))
+                           /* n too large, would lead to out of memory
+                              later.  */
+                           goto error;
+                         dp->precision_arg_index = n - 1;
+                         cp = np + 1;
+                       }
+                   }
+                 if (dp->precision_arg_index == ARG_NONE)
+                   {
+                     dp->precision_arg_index = arg_posn++;
+                     if (dp->precision_arg_index == ARG_NONE)
+                       /* arg_posn wrapped around.  */
+                       goto error;
+                   }
+                 REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
+               }
+             else
+               {
+                 size_t precision_length;
+
+                 dp->precision_start = cp - 1;
+                 for (; *cp >= '0' && *cp <= '9'; cp++)
+                   ;
+                 dp->precision_end = cp;
+                 precision_length = dp->precision_end - dp->precision_start;
+                 if (max_precision_length < precision_length)
+                   max_precision_length = precision_length;
+               }
+           }
+
+         {
+           arg_type type;
+
+           /* Parse argument type/size specifiers.  */
+           {
+             int flags = 0;
+
+             for (;;)
+               {
+                 if (*cp == 'h')
+                   {
+                     flags |= (1 << (flags & 1));
+                     cp++;
+                   }
+                 else if (*cp == 'L')
+                   {
+                     flags |= 4;
+                     cp++;
+                   }
+                 else if (*cp == 'l')
+                   {
+                     flags += 8;
+                     cp++;
+                   }
+#ifdef HAVE_INTMAX_T
+                 else if (*cp == 'j')
+                   {
+                     if (sizeof (intmax_t) > sizeof (long))
+                       {
+                         /* intmax_t = long long */
+                         flags += 16;
+                       }
+                     else if (sizeof (intmax_t) > sizeof (int))
+                       {
+                         /* intmax_t = long */
+                         flags += 8;
+                       }
+                     cp++;
+                   }
+#endif
+                 else if (*cp == 'z' || *cp == 'Z')
+                   {
+                     /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
+                        because the warning facility in gcc-2.95.2 understands
+                        only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784).  */
+                     if (sizeof (size_t) > sizeof (long))
+                       {
+                         /* size_t = long long */
+                         flags += 16;
+                       }
+                     else if (sizeof (size_t) > sizeof (int))
+                       {
+                         /* size_t = long */
+                         flags += 8;
+                       }
+                     cp++;
+                   }
+                 else if (*cp == 't')
+                   {
+                     if (sizeof (ptrdiff_t) > sizeof (long))
+                       {
+                         /* ptrdiff_t = long long */
+                         flags += 16;
+                       }
+                     else if (sizeof (ptrdiff_t) > sizeof (int))
+                       {
+                         /* ptrdiff_t = long */
+                         flags += 8;
+                       }
+                     cp++;
+                   }
+                 else
+                   break;
+               }
+
+             /* Read the conversion character.  */
+             c = *cp++;
+             switch (c)
+               {
+               case 'd': case 'i':
+#ifdef HAVE_LONG_LONG
+                 if (flags >= 16 || (flags & 4))
+                   type = TYPE_LONGLONGINT;
+                 else
+#endif
+                 if (flags >= 8)
+                   type = TYPE_LONGINT;
+                 else if (flags & 2)
+                   type = TYPE_SCHAR;
+                 else if (flags & 1)
+                   type = TYPE_SHORT;
+                 else
+                   type = TYPE_INT;
+                 break;
+               case 'o': case 'u': case 'x': case 'X':
+#ifdef HAVE_LONG_LONG
+                 if (flags >= 16 || (flags & 4))
+                   type = TYPE_ULONGLONGINT;
+                 else
+#endif
+                 if (flags >= 8)
+                   type = TYPE_ULONGINT;
+                 else if (flags & 2)
+                   type = TYPE_UCHAR;
+                 else if (flags & 1)
+                   type = TYPE_USHORT;
+                 else
+                   type = TYPE_UINT;
+                 break;
+               case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+               case 'a': case 'A':
+#ifdef HAVE_LONG_DOUBLE
+                 if (flags >= 16 || (flags & 4))
+                   type = TYPE_LONGDOUBLE;
+                 else
+#endif
+                 type = TYPE_DOUBLE;
+                 break;
+               case 'c':
+                 if (flags >= 8)
+#ifdef HAVE_WINT_T
+                   type = TYPE_WIDE_CHAR;
+#else
+                   goto error;
+#endif
+                 else
+                   type = TYPE_CHAR;
+                 break;
+#ifdef HAVE_WINT_T
+               case 'C':
+                 type = TYPE_WIDE_CHAR;
+                 c = 'c';
+                 break;
+#endif
+               case 's':
+                 if (flags >= 8)
+#ifdef HAVE_WCHAR_T
+                   type = TYPE_WIDE_STRING;
+#else
+                   goto error;
+#endif
+                 else
+                   type = TYPE_STRING;
+                 break;
+#ifdef HAVE_WCHAR_T
+               case 'S':
+                 type = TYPE_WIDE_STRING;
+                 c = 's';
+                 break;
+#endif
+               case 'p':
+                 type = TYPE_POINTER;
+                 break;
+               case 'n':
+#ifdef HAVE_LONG_LONG
+                 if (flags >= 16 || (flags & 4))
+                   type = TYPE_COUNT_LONGLONGINT_POINTER;
+                 else
+#endif
+                 if (flags >= 8)
+                   type = TYPE_COUNT_LONGINT_POINTER;
+                 else if (flags & 2)
+                   type = TYPE_COUNT_SCHAR_POINTER;
+                 else if (flags & 1)
+                   type = TYPE_COUNT_SHORT_POINTER;
+                 else
+                   type = TYPE_COUNT_INT_POINTER;
+                 break;
+               case '%':
+                 type = TYPE_NONE;
+                 break;
+               default:
+                 /* Unknown conversion character.  */
+                 goto error;
+               }
+           }
+
+           if (type != TYPE_NONE)
+             {
+               dp->arg_index = arg_index;
+               if (dp->arg_index == ARG_NONE)
+                 {
+                   dp->arg_index = arg_posn++;
+                   if (dp->arg_index == ARG_NONE)
+                     /* arg_posn wrapped around.  */
+                     goto error;
+                 }
+               REGISTER_ARG (dp->arg_index, type);
+             }
+           dp->conversion = c;
+           dp->dir_end = cp;
+         }
+
+         d->count++;
+         if (d->count >= d_allocated)
+           {
+             size_t memory_size;
+             DIRECTIVE *memory;
+
+             d_allocated = xtimes (d_allocated, 2);
+             memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
+             if (size_overflow_p (memory_size))
+               /* Overflow, would lead to out of memory.  */
+               goto error;
+             memory = realloc (d->dir, memory_size);
+             if (memory == NULL)
+               /* Out of memory.  */
+               goto error;
+             d->dir = memory;
+           }
+       }
+    }
+  d->dir[d->count].dir_start = cp;
+
+  d->max_width_length = max_width_length;
+  d->max_precision_length = max_precision_length;
+  return 0;
+
+error:
+  if (a->arg)
+    free (a->arg);
+  if (d->dir)
+    free (d->dir);
+  return -1;
+}
+
+#undef DIRECTIVES
+#undef DIRECTIVE
+#undef CHAR_T
+#undef PRINTF_PARSE
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/printf-parse.h  2005-01-09 20:37:22.000000000 -0600
@@ -0,0 +1,74 @@
+/* Parse printf format string.
+   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _PRINTF_PARSE_H
+#define _PRINTF_PARSE_H
+
+#include "printf-args.h"
+
+
+/* Flags */
+#define FLAG_GROUP      1      /* ' flag */
+#define FLAG_LEFT       2      /* - flag */
+#define FLAG_SHOWSIGN   4      /* + flag */
+#define FLAG_SPACE      8      /* space flag */
+#define FLAG_ALT       16      /* # flag */
+#define FLAG_ZERO      32
+
+/* arg_index value indicating that no argument is consumed.  */
+#define ARG_NONE       (~(size_t)0)
+
+/* A parsed directive.  */
+typedef struct
+{
+  const char* dir_start;
+  const char* dir_end;
+  int flags;
+  const char* width_start;
+  const char* width_end;
+  size_t width_arg_index;
+  const char* precision_start;
+  const char* precision_end;
+  size_t precision_arg_index;
+  char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
+  size_t arg_index;
+}
+char_directive;
+
+/* A parsed format string.  */
+typedef struct
+{
+  size_t count;
+  char_directive *dir;
+  size_t max_width_length;
+  size_t max_precision_length;
+}
+char_directives;
+
+
+/* Parses the format string.  Fills in the number N of directives, and fills
+   in directives[0], ..., directives[N-1], and sets directives[N].dir_start
+   to the end of the format string.  Also fills in the arg_type fields of the
+   arguments and the needed count of arguments.  */
+#ifdef STATIC
+STATIC
+#else
+extern
+#endif
+int printf_parse (const char *format, char_directives *d, arguments *a);
+
+#endif /* _PRINTF_PARSE_H */
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/xsize.h 2005-01-09 20:37:27.000000000 -0600
@@ -0,0 +1,108 @@
+/* xsize.h -- Checked size_t computations.
+
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _XSIZE_H
+#define _XSIZE_H
+
+/* Get size_t.  */
+#include <stddef.h>
+
+/* Get SIZE_MAX.  */
+#include <limits.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+/* The size of memory objects is often computed through expressions of
+   type size_t. Example:
+      void* p = malloc (header_size + n * element_size).
+   These computations can lead to overflow.  When this happens, malloc()
+   returns a piece of memory that is way too small, and the program then
+   crashes while attempting to fill the memory.
+   To avoid this, the functions and macros in this file check for overflow.
+   The convention is that SIZE_MAX represents overflow.
+   malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
+   implementation that uses mmap --, it's recommended to use size_overflow_p()
+   or size_in_bounds_p() before invoking malloc().
+   The example thus becomes:
+      size_t size = xsum (header_size, xtimes (n, element_size));
+      void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
+*/
+
+/* Convert an arbitrary value >= 0 to type size_t.  */
+#define xcast_size_t(N) \
+  ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
+
+/* Sum of two sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum (size_t size1, size_t size2)
+{
+  size_t sum = size1 + size2;
+  return (sum >= size1 ? sum : SIZE_MAX);
+}
+
+/* Sum of three sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum3 (size_t size1, size_t size2, size_t size3)
+{
+  return xsum (xsum (size1, size2), size3);
+}
+
+/* Sum of four sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
+{
+  return xsum (xsum (xsum (size1, size2), size3), size4);
+}
+
+/* Maximum of two sizes, with overflow check.  */
+static inline size_t
+#if __GNUC__ >= 3
+__attribute__ ((__pure__))
+#endif
+xmax (size_t size1, size_t size2)
+{
+  /* No explicit check is needed here, because for any n:
+     max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX.  */
+  return (size1 >= size2 ? size1 : size2);
+}
+
+/* Multiplication of a count with an element size, with overflow check.
+   The count must be >= 0 and the element size must be > 0.
+   This is a macro, not an inline function, so that it works correctly even
+   when N is of a wider tupe and N > SIZE_MAX.  */
+#define xtimes(N, ELSIZE) \
+  ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
+
+/* Check for overflow.  */
+#define size_overflow_p(SIZE) \
+  ((SIZE) == SIZE_MAX)
+/* Check against overflow.  */
+#define size_in_bounds_p(SIZE) \
+  ((SIZE) != SIZE_MAX)
+
+#endif /* _XSIZE_H */
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/vsnprintf.c     2005-01-09 20:44:25.000000000 -0600
@@ -0,0 +1,58 @@
+/* Formatted output to strings.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Written by Simon Josefsson and Yoann Vandoorselaere <address@hidden>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification.  */
+#include "vsnprintf.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vasnprintf.h"
+
+/* Print formatted output to string STR.  Similar to vsprintf, but
+   additional length SIZE limit how much is written into STR.  Returns
+   string length of formatted string (which may be larger than SIZE).
+   STR may be NULL, in which case nothing will be written.  On error,
+   return a negative value. */
+int
+vsnprintf (char *str, size_t size, const char *format, va_list args)
+{
+  char *output;
+  size_t len;
+
+  len = size;
+  output = vasnprintf (str, &len, format, args);
+
+  if (!output)
+    return -1;
+
+  if (str != NULL)
+    if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */
+      str[size - 1] = '\0';
+
+  if (output != str)
+    free (output);
+
+  return len;
+}
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ lib/vsnprintf.h     2005-01-09 20:44:25.000000000 -0600
@@ -0,0 +1,31 @@
+/* Formatted output to strings.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Written by Simon Josefsson and Yoann Vandoorselaere <address@hidden>.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef VSNPRINTF_H
+#define VSNPRINTF_H
+
+#include <stdarg.h>
+
+/* Get vsnprintf declaration, if available.  */
+#include <stdio.h>
+
+#if defined HAVE_DECL_VSNPRINTF && !HAVE_DECL_VSNPRINTF
+int vsnprintf (char *str, size_t size, const char *format, va_list args);
+#endif
+
+#endif /* VSNPRINTF_H */
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/vasnprintf.m4    2005-01-09 20:21:37.000000000 -0600
@@ -0,0 +1,60 @@
+# vasnprintf.m4 serial 5
+dnl Copyright (C) 2002-2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_VASNPRINTF],
+[
+  AC_REQUIRE([gl_EOVERFLOW])
+  AC_REPLACE_FUNCS(vasnprintf)
+  if test $ac_cv_func_vasnprintf = no; then
+    AC_LIBOBJ(printf-args)
+    AC_LIBOBJ(printf-parse)
+    AC_LIBOBJ(asnprintf)
+    gl_PREREQ_PRINTF_ARGS
+    gl_PREREQ_PRINTF_PARSE
+    gl_PREREQ_VASNPRINTF
+    gl_PREREQ_ASNPRINTF
+  fi
+])
+
+# Prequisites of lib/printf-args.h, lib/printf-args.c.
+AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
+[
+  AC_REQUIRE([bh_C_SIGNED])
+  AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
+  AC_REQUIRE([gt_TYPE_LONGDOUBLE])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  AC_REQUIRE([gt_TYPE_WINT_T])
+])
+
+# Prequisites of lib/printf-parse.h, lib/printf-parse.c.
+AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
+[
+  AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
+  AC_REQUIRE([gt_TYPE_LONGDOUBLE])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  AC_REQUIRE([AC_TYPE_SIZE_T])
+  AC_CHECK_TYPES(ptrdiff_t)
+  AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
+])
+
+# Prerequisites of lib/vasnprintf.c.
+AC_DEFUN([gl_PREREQ_VASNPRINTF],
+[
+  AC_REQUIRE([AC_FUNC_ALLOCA])
+  AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
+  AC_REQUIRE([gt_TYPE_LONGDOUBLE])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  AC_CHECK_FUNCS(snprintf wcslen)
+])
+
+# Prerequisites of lib/asnprintf.c.
+AC_DEFUN([gl_PREREQ_ASNPRINTF],
+[
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/eoverflow.m4     2005-01-09 20:22:58.000000000 -0600
@@ -0,0 +1,66 @@
+# eoverflow.m4 serial 1
+dnl Copyright (C) 2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+
+# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
+# POSIX.  But some systems (like AIX 3) don't define it, and some systems
+# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
+
+# Define EOVERFLOW as a C macro and as a substituted macro in such a way that
+# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
+# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
+#    value.
+
+AC_DEFUN([gl_EOVERFLOW],
+[
+  AC_REQUIRE([AC_PROG_CC])dnl
+
+  AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
+    AC_EGREP_CPP(yes,[
+#include <errno.h>
+#ifdef EOVERFLOW
+yes
+#endif
+      ], have_eoverflow=1)
+    if test -n "$have_eoverflow"; then
+      dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW 
ourselves.
+      ac_cv_decl_EOVERFLOW=yes
+    else
+      AC_EGREP_CPP(yes,[
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+#ifdef EOVERFLOW
+yes
+#endif
+        ], have_eoverflow=1)
+      if test -n "$have_eoverflow"; then
+        dnl EOVERFLOW exists but is hidden.
+        dnl Define it to the same value.
+        _AC_COMPUTE_INT([EOVERFLOW], ac_cv_decl_EOVERFLOW, [
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+/* The following two lines are a workaround against an autoconf-2.52 bug.  */
+#include <stdio.h>
+#include <stdlib.h>
+])
+      else
+        dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, 
but
+        dnl don't define it as EINVAL, because snprintf() callers want to
+        dnl distinguish EINVAL and EOVERFLOW.
+        ac_cv_decl_EOVERFLOW=E2BIG
+      fi
+    fi
+  ])
+  if test "$ac_cv_decl_EOVERFLOW" != yes; then
+    AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
+                       [Define as good substitute value for EOVERFLOW.])
+    EOVERFLOW="$ac_cv_decl_EOVERFLOW"
+    AC_SUBST(EOVERFLOW)
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/signed.m4        2005-01-09 20:23:26.000000000 -0600
@@ -0,0 +1,19 @@
+# signed.m4 serial 1 (gettext-0.10.40)
+dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([bh_C_SIGNED],
+[
+  AC_CACHE_CHECK([for signed], bh_cv_c_signed,
+   [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)])
+  if test $bh_cv_c_signed = no; then
+    AC_DEFINE(signed, ,
+              [Define to empty if the C compiler doesn't support this 
keyword.])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/longlong.m4      2005-01-09 20:23:50.000000000 -0600
@@ -0,0 +1,25 @@
+# longlong.m4 serial 5
+dnl Copyright (C) 1999-2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Paul Eggert.
+
+# Define HAVE_LONG_LONG if 'long long' works.
+
+AC_DEFUN([gl_AC_TYPE_LONG_LONG],
+[
+  AC_CACHE_CHECK([for long long], ac_cv_type_long_long,
+  [AC_TRY_LINK([long long ll = 1LL; int i = 63;],
+    [long long llmax = (long long) -1;
+     return ll << i | ll >> i | llmax / ll | llmax % ll;],
+    ac_cv_type_long_long=yes,
+    ac_cv_type_long_long=no)])
+  if test $ac_cv_type_long_long = yes; then
+    AC_DEFINE(HAVE_LONG_LONG, 1,
+      [Define if you have the 'long long' type.])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/longdouble.m4    2005-01-09 20:24:13.000000000 -0600
@@ -0,0 +1,30 @@
+# longdouble.m4 serial 1 (gettext-0.12)
+dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+dnl Test whether the compiler supports the 'long double' type.
+dnl Prerequisite: AC_PROG_CC
+
+AC_DEFUN([gt_TYPE_LONGDOUBLE],
+[
+  AC_CACHE_CHECK([for long double], gt_cv_c_long_double,
+    [if test "$GCC" = yes; then
+       gt_cv_c_long_double=yes
+     else
+       AC_TRY_COMPILE([
+         /* The Stardent Vistra knows sizeof(long double), but does not 
support it.  */
+         long double foo = 0.0;
+         /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
+         int array [2*(sizeof(long double) >= sizeof(double)) - 1];
+         ], ,
+         gt_cv_c_long_double=yes, gt_cv_c_long_double=no)
+     fi])
+  if test $gt_cv_c_long_double = yes; then
+    AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' 
type.])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/wchar_t.m4       2005-01-09 20:24:32.000000000 -0600
@@ -0,0 +1,22 @@
+# wchar_t.m4 serial 1 (gettext-0.12)
+dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+dnl Test whether <stddef.h> has the 'wchar_t' type.
+dnl Prerequisite: AC_PROG_CC
+
+AC_DEFUN([gt_TYPE_WCHAR_T],
+[
+  AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t,
+    [AC_TRY_COMPILE([#include <stddef.h>
+       wchar_t foo = (wchar_t)'\0';], ,
+       gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)])
+  if test $gt_cv_c_wchar_t = yes; then
+    AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/wint_t.m4        2005-01-09 20:24:46.000000000 -0600
@@ -0,0 +1,22 @@
+# wint_t.m4 serial 1 (gettext-0.12)
+dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+dnl Test whether <wchar.h> has the 'wint_t' type.
+dnl Prerequisite: AC_PROG_CC
+
+AC_DEFUN([gt_TYPE_WINT_T],
+[
+  AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
+    [AC_TRY_COMPILE([#include <wchar.h>
+       wint_t foo = (wchar_t)'\0';], ,
+       gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
+  if test $gt_cv_c_wint_t = yes; then
+    AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/intmax_t.m4      2005-01-09 20:25:04.000000000 -0600
@@ -0,0 +1,63 @@
+# intmax_t.m4 serial 4
+dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Paul Eggert.
+
+AC_PREREQ(2.13)
+
+# Define intmax_t to 'long' or 'long long'
+# if it is not already defined in <stdint.h> or <inttypes.h>.
+
+AC_DEFUN([gl_AC_TYPE_INTMAX_T],
+[
+  dnl For simplicity, we assume that a header file defines 'intmax_t' if and
+  dnl only if it defines 'uintmax_t'.
+  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+  if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; 
then
+    AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
+    test $ac_cv_type_long_long = yes \
+      && ac_type='long long' \
+      || ac_type='long'
+    AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
+     [Define to long or long long if <inttypes.h> and <stdint.h> don't 
define.])
+  else
+    AC_DEFINE(HAVE_INTMAX_T, 1,
+      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
+  fi
+])
+
+dnl An alternative would be to explicitly test for 'intmax_t'.
+
+AC_DEFUN([gt_AC_TYPE_INTMAX_T],
+[
+  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
+  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
+  AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t,
+    [AC_TRY_COMPILE([
+#include <stddef.h>
+#include <stdlib.h>
+#if HAVE_STDINT_H_WITH_UINTMAX
+#include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H_WITH_UINTMAX
+#include <inttypes.h>
+#endif
+], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
+  if test $gt_cv_c_intmax_t = yes; then
+    AC_DEFINE(HAVE_INTMAX_T, 1,
+      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
+  else
+    AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
+    test $ac_cv_type_long_long = yes \
+      && ac_type='long long' \
+      || ac_type='long'
+    AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
+     [Define to long or long long if <stdint.h> and <inttypes.h> don't 
define.])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/inttypes_h.m4    2005-01-09 20:25:29.000000000 -0600
@@ -0,0 +1,28 @@
+# inttypes_h.m4 serial 6
+dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Paul Eggert.
+
+# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+
+AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
+[
+  AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h,
+  [AC_TRY_COMPILE(
+    [#include <sys/types.h>
+#include <inttypes.h>],
+    [uintmax_t i = (uintmax_t) -1;],
+    gl_cv_header_inttypes_h=yes,
+    gl_cv_header_inttypes_h=no)])
+  if test $gl_cv_header_inttypes_h = yes; then
+    AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
+      [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
+       and declares uintmax_t. ])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/stdint_h.m4      2005-01-09 20:25:45.000000000 -0600
@@ -0,0 +1,28 @@
+# stdint_h.m4 serial 5
+dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Paul Eggert.
+
+# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+
+AC_DEFUN([gl_AC_HEADER_STDINT_H],
+[
+  AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h,
+  [AC_TRY_COMPILE(
+    [#include <sys/types.h>
+#include <stdint.h>],
+    [uintmax_t i = (uintmax_t) -1;],
+    gl_cv_header_stdint_h=yes,
+    gl_cv_header_stdint_h=no)])
+  if test $gl_cv_header_stdint_h = yes; then
+    AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
+      [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
+       and declares uintmax_t. ])
+  fi
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/vsnprintf.m4     2005-01-09 20:44:14.000000000 -0600
@@ -0,0 +1,17 @@
+# vsnprintf.m4 serial 1
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_VSNPRINTF],
+[
+  AC_REPLACE_FUNCS(vsnprintf)
+  AC_CHECK_DECLS_ONCE(vsnprintf)
+  gl_PREREQ_VSNPRINTF
+])
+
+# Prerequisites of lib/vsnprintf.c.
+AC_DEFUN([gl_PREREQ_VSNPRINTF], [:])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/xsize.m4 2005-01-09 21:53:10.000000000 -0600
@@ -0,0 +1,15 @@
+# xsize.m4 serial 3
+dnl Copyright (C) 2003-2004 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_XSIZE],
+[
+  dnl Prerequisites of lib/xsize.h.
+  AC_REQUIRE([gl_SIZE_MAX])
+  AC_REQUIRE([AC_C_INLINE])
+  AC_CHECK_HEADERS(stdint.h)
+])
--- /dev/null   2004-11-12 10:15:27.000000000 -0600
+++ m4/size_max.m4      2005-01-09 21:53:25.000000000 -0600
@@ -0,0 +1,61 @@
+# size_max.m4 serial 2
+dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_SIZE_MAX],
+[
+  AC_CHECK_HEADERS(stdint.h)
+  dnl First test whether the system already has SIZE_MAX.
+  AC_MSG_CHECKING([for SIZE_MAX])
+  result=
+  AC_EGREP_CPP([Found it], [
+#include <limits.h>
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef SIZE_MAX
+Found it
+#endif
+], result=yes)
+  if test -z "$result"; then
+    dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
+    dnl than the type 'unsigned long'.
+    dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr',
+    dnl which is guaranteed to work from LONG_MIN to LONG_MAX.
+    _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi,
+      [#include <stddef.h>], result=?)
+    _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo,
+      [#include <stddef.h>], result=?)
+    _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
+      [#include <stddef.h>], result=?)
+    if test "$fits_in_uint" = 1; then
+      dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
+      dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
+      AC_TRY_COMPILE([#include <stddef.h>
+        extern size_t foo;
+        extern unsigned long foo;
+        ], [], fits_in_uint=0)
+    fi
+    if test -z "$result"; then
+      if test "$fits_in_uint" = 1; then
+        result="$res_hi$res_lo"U
+      else
+        result="$res_hi$res_lo"UL
+      fi
+    else
+      dnl Shouldn't happen, but who knows...
+      result='~(size_t)0'
+    fi
+  fi
+  AC_MSG_RESULT([$result])
+  if test "$result" != yes; then
+    AC_DEFINE_UNQUOTED([SIZE_MAX], [$result],
+      [Define as the maximum value of type 'size_t', if the system doesn't 
define it.])
+  fi
+])
--- src/util.c.orig     2005-01-09 19:54:33.000000000 -0600
+++ src/util.c  2005-01-09 19:59:23.000000000 -0600
@@ -241,7 +241,7 @@
        {
          if (bytes_left < space_left)
            space_left = bytes_left;
-         bcopy (in_buf, out_buff, (unsigned) space_left);
+         memcpy (out_buff, in_buf, (unsigned) space_left);
          out_buff += space_left;
          output_size += space_left;
          in_buf += space_left;
@@ -268,7 +268,7 @@
        {
          if (bytes_left < space_left)
            space_left = bytes_left;
-         bcopy (in_buf, out_buff, (unsigned) space_left);
+         memcpy (out_buff, in_buf, (unsigned) space_left);
          out_buff += space_left;
          output_size += space_left;
          in_buf += space_left;
@@ -295,7 +295,7 @@
        space_left = bytes_left;
       else
        space_left = input_size;
-      bcopy (in_buff, in_buf, (unsigned) space_left);
+      memcpy (in_buf, in_buff, (unsigned) space_left);
       in_buff += space_left;
       in_buf += space_left;
       input_size -= space_left;
@@ -345,7 +345,7 @@
             first block to make room.  */
          int half;
          half = input_buffer_size / 2;
-         bcopy (input_buffer + half, input_buffer, half);
+         memcpy (input_buffer, input_buffer + half, half);
          in_buff = in_buff - half;
          append_buf = append_buf - half;
        }
@@ -369,7 +369,7 @@
     got_bytes = num_bytes;
   else
     got_bytes = input_size;
-  bcopy (in_buff, peek_buf, (unsigned) got_bytes);
+  memcpy (peek_buf, in_buff, (unsigned) got_bytes);
   return got_bytes;
 }
 
--- src/userspec.c.orig 2005-01-09 19:48:57.000000000 -0600
+++ src/userspec.c      2005-01-09 19:51:39.000000000 -0600
@@ -72,7 +72,7 @@
    otherwise return 0. */
 
 static int
-isnumber (const char *str)
+is_number (const char *str)
 {
   for (; *str; str++)
     if (!isdigit (*str))
@@ -111,9 +111,9 @@
   V_STRDUP (spec, spec_arg);
 
   /* Find the separator if there is one.  */
-  separator = index (spec, ':');
+  separator = strchr (spec, ':');
   if (separator == NULL)
-    separator = index (spec, '.');
+    separator = strchr (spec, '.');
 
   /* Replace separator with a NUL.  */
   if (separator != NULL)
@@ -136,7 +136,7 @@
       if (pwd == NULL)
        {
 
-         if (!isnumber (u))
+         if (!is_number (u))
            error_msg = _("invalid user");
          else
            {
@@ -182,7 +182,7 @@
       grp = getgrnam (g);
       if (grp == NULL)
        {
-         if (!isnumber (g))
+         if (!is_number (g))
            error_msg = _("invalid group");
          else
            *gid = atoi (g);
--- src/tar.c.orig      2005-01-09 20:00:44.000000000 -0600
+++ src/tar.c   2005-01-09 20:01:53.000000000 -0600
@@ -142,7 +142,7 @@
   union tar_record tar_rec;
   struct tar_header *tar_hdr = (struct tar_header *) &tar_rec;
 
-  bzero ((char *) &tar_rec, TARRECORDSIZE);
+  memset ((char *) &tar_rec, 0, TARRECORDSIZE);
 
   /* process_copy_out must ensure that file_hdr->c_name is short enough,
      or we will lose here.  */
--- src/main.c.orig     2005-01-09 20:01:59.000000000 -0600
+++ src/main.c  2005-01-09 20:02:05.000000000 -0600
@@ -727,7 +727,7 @@
   output_bytes = 0;
 
   /* Clear the block of zeros.  */
-  bzero (zeros_512, 512);
+  memset (zeros_512, 0, 512);
 }
 
 int
--- src/copypass.c.orig 2005-01-09 20:02:13.000000000 -0600
+++ src/copypass.c      2005-01-09 20:02:19.000000000 -0600
@@ -59,7 +59,7 @@
   output_name.ds_string[dirname_len] = '/';
   output_is_seekable = true;
   /* Initialize this in case it has members we don't know to set.  */
-  bzero (&times, sizeof (struct utimbuf));
+  memset (&times, 0, sizeof (struct utimbuf));
 
   /* Copy files with names read from stdin.  */
   while (ds_fgetstr (stdin, &input_name, name_end) != NULL)
--- src/copyout.c.orig  2005-01-09 20:02:27.000000000 -0600
+++ src/copyout.c       2005-01-09 20:02:38.000000000 -0600
@@ -213,7 +213,7 @@
   struct new_cpio_header file_hdr;
   struct utimbuf times;                /* For setting file times.  */
   /* Initialize this in case it has members we don't know to set.  */
-  bzero (&times, sizeof (struct utimbuf));
+  memset (&times, 0, sizeof (struct utimbuf));
 
   file_hdr = *header;
 
@@ -457,7 +457,7 @@
   /* Initialize the copy out.  */
   ds_init (&input_name, 128);
   /* Initialize this in case it has members we don't know to set.  */
-  bzero (&times, sizeof (struct utimbuf));
+  memset (&times, 0, sizeof (struct utimbuf));
   file_hdr.c_magic = 070707;
 
   /* Check whether the output file might be a tape.  */
--- src/copyin.c.orig   2005-01-09 20:02:54.000000000 -0600
+++ src/copyin.c        2005-01-09 20:03:40.000000000 -0600
@@ -357,7 +357,7 @@
   int  out_file_des;
   struct utimbuf times;                /* For setting file times.  */
   /* Initialize this in case it has members we don't know to set.  */
-  bzero (&times, sizeof (struct utimbuf));
+  memset (&times, 0, sizeof (struct utimbuf));
   
   for (d = deferments; d != NULL; d = d->next)
     {
@@ -583,7 +583,7 @@
     {
       struct utimbuf times;            /* For setting file times.  */
       /* Initialize this in case it has members we don't know to set.  */
-      bzero (&times, sizeof (struct utimbuf));
+      memset (&times, 0, sizeof (struct utimbuf));
 
       times.actime = times.modtime = file_hdr->c_mtime;
       if (utime (file_hdr->c_name, &times) < 0)
@@ -690,7 +690,7 @@
     {
       struct utimbuf times;            /* For setting file times.  */
       /* Initialize this in case it has members we don't know to set.  */
-      bzero (&times, sizeof (struct utimbuf));
+      memset (&times, 0, sizeof (struct utimbuf));
 
       times.actime = times.modtime = file_hdr->c_mtime;
       if (utime (file_hdr->c_name, &times) < 0)
@@ -768,7 +768,7 @@
     {
       struct utimbuf times;            /* For setting file times.  */
       /* Initialize this in case it has members we don't know to set.  */
-      bzero (&times, sizeof (struct utimbuf));
+      memset (&times, 0, sizeof (struct utimbuf));
 
       times.actime = times.modtime = file_hdr->c_mtime;
       if (utime (file_hdr->c_name, &times) < 0)
@@ -1134,7 +1134,7 @@
          break;
        }
       bytes_skipped++;
-      bcopy ((char *) file_hdr + 1, (char *) file_hdr, 5);
+      memcpy ((char *) file_hdr, (char *) file_hdr + 1, 5);
       tape_buffered_read ((char *) file_hdr + 5, in_des, 1L);
     }
 }
--- configure.ac.orig   2005-01-09 20:11:09.000000000 -0600
+++ configure.ac        2005-01-09 21:57:23.000000000 -0600
@@ -93,7 +93,9 @@
 fi
 
 AC_CHECK_FUNCS(lchown endpwent endgrent)
-AC_FUNC_VPRINTF
+gl_XSIZE
+gl_FUNC_VSNPRINTF
+gl_FUNC_VASNPRINTF
 AC_FUNC_ALLOCA
 AC_CHECK_LIB(nsl, gethostname, [LIBS="$LIBS -lnsl"])
 AC_CHECK_LIB(socket, setsockopt, [LIBS="$LIBS -lsocket"])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]