bug-gnulib
[Top][All Lists]
Advanced

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

Reconciliation of libsnprintfv vs. autogen


From: Bruce Korb
Subject: Reconciliation of libsnprintfv vs. autogen
Date: Sun, 25 Feb 2007 12:46:05 -0800
User-agent: Thunderbird 1.5.0.8 (X11/20060911)

Hi Daniel,

I found a number of misuses of casts in the subversion sources.
Attached are two difference files:   one vs. the libsnv source
on subversion, the other against my variation in autogen.
The primary difference (after application of the first patch)
is that snprintfv.m4 and compat.h are wildly different.
Since they are not particularly relevant to the gnulib port,
I see little reason to reconcile them.

Below are my comments about what I've done to the subversion
repository.

Cheers - Bruce

e.g.:
@@ -193,7 +197,7 @@ call_argtype_function (struct printf_inf

   else
     {
-      pinfo->spec = *(unsigned char *) pinfo->format;
+      pinfo->spec = (unsigned)*(pinfo->format);
       pinfo->extra = spec->user;
       pinfo->type = spec->type;

Do not dereference a cast.  GCC doesn't like it.
First, fetch the referenced value, *then* recast it.

The other largish changes were:

#1 whitespace - I eliminated the EOL whitespace, as it is not in my source
#2 single letter variables should not have scope (let alone usage) beyond
   a couple of lines.  It's too hard to follow.  Again, copied from my source.
#3 This code *IS* broken and must be fixed.  I left the comment in:
> @@ -224,7 +228,7 @@ call_argtype_function (struct printf_inf
>      }
>  
>  /* FIXME!!! && or || ???? */
> -  if (!pinfo->dollar && !IS_MODIFIER (spec))
> +  if (!pinfo->dollar || !IS_MODIFIER (spec))
>      pinfo->argindex += n;
>  
>    return n;

This is a really obtuse and nasty bug.  Without it you wind
up with the wrong index and seg faulting in an incomprehensible
way.  The fix is required.

=======================

*NOT* fixed, but needs to be, all of these:
             case PA_WSTRING:
-              args[idx].pa_wstring = *(const snv_wchar_t **)(ap + idx);
+              args[idx].pa_wstring = (const snv_wchar_t *)ap[idx];
               break;

I am also puzzled by this diff in gendoc (since I don't touch that
thing, I don't know where the diff came from):

@@ -479,7 +480,7 @@ funcdecl>0 {
            # We have just seen two consecutive keywords or "void", both of
            # which mark an ANSI declaration, and need to reset for the next
            # header
-           funcdecl = 0;
+           funcdecl = 3;

            # Is this a printf attributable prototype?  Look for
            # ``format,'' in the penultimate argument:
! /usr/bin/cvs diff ...
Index: gendoc.awk
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/gendoc.awk,v
retrieving revision 1.2
diff -b -B -u -p -u -p -r1.2 gendoc.awk
--- gendoc.awk  21 Feb 2007 15:41:26 -0000      1.2
+++ gendoc.awk  25 Feb 2007 20:11:53 -0000
@@ -299,7 +299,8 @@ funcdecl>0 {
            # Extract return type
            type[fname] = $0;
            sub(/^[ \t]*typedef[ \t]+/, "", type[fname]); # strip "typedef"
-           sub(/[ \t]+[A-Z_]*P[A-Z]* *\(\(/, " (", type[fname]); # and 
__P/PARAMS macro
+           # and __P/PARAMS macro
+           sub(/[ \t]+[A-Z_]*P[A-Z]* *\(\(/, " (", type[fname]);
            sub(/[ \t]*[(].*$/, "", type[fname]); # strip arguments
            sub(/[ \t]*[_A-Za-z][_A-Za-z0-9]*[ \t]*$/, "", type[fname]);
 
@@ -479,7 +480,7 @@ funcdecl>0 {
            # We have just seen two consecutive keywords or "void", both of
            # which mark an ANSI declaration, and need to reset for the next
            # header
-           funcdecl = 0;
+           funcdecl = 3;
 
            # Is this a printf attributable prototype?  Look for
            # ``format,'' in the penultimate argument:
Index: genproto
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/genproto,v
retrieving revision 1.2
diff -b -B -u -p -u -p -r1.2 genproto
--- genproto    21 Feb 2007 15:41:26 -0000      1.2
+++ genproto    25 Feb 2007 20:11:53 -0000
@@ -36,7 +36,7 @@
 # USAGE: genproto [debug] <filter> source.h-in > source.h
 #
 # This program scans a C source file for special comments preceding
-# K&R function declarations, and generates commented function
+# function definitions, and generates commented function
 # declarations suitable for use in a header file.
 #
 # See the accompanying README for details of how to format function headers
@@ -69,7 +69,8 @@ format=${FORMAT-GNUC_PRINTF}
 global=${GLOBAL-GLOBAL_DATA}
 scope=${SCOPE-SCOPE}
 
-filter="${AWK-awk} $debug -v mode=$mode -v format=$format -v global=$global -v 
scope=$scope -f $1"
+filter_args="-v mode=$mode -v format=$format -v global=$global -v scope=$scope"
+filter="${AWK-awk} $debug ${filter_args} -f $1"
 
 # Read in the source file expanding @protos foo.c lines using the
 # gendoc.awk script
@@ -93,4 +94,4 @@ NR == 1 {
 
 exit 0
 
-# genproto.sh ends here
+# genproto ends here
Index: snprintfv/compat.h
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/compat.h,v
retrieving revision 1.2
diff -b -B -u -p -u -p -r1.2 compat.h
--- snprintfv/compat.h  25 Feb 2007 14:45:02 -0000      1.2
+++ snprintfv/compat.h  25 Feb 2007 20:11:53 -0000
@@ -1,4 +1,6 @@
-/* compat.h.in --- verbose but portable cpp defines for snprintfv
+/*  -*- Mode: C -*-
+ * --------------------------------------------------------------------
+ * compat.h.in --- verbose but portable cpp defines for snprintfv
  * Copyright (C) 1999 Gary V. Vaughan
  * Originally by Gary V. Vaughan, 1999
  * This file is part of Snprintfv
@@ -21,16 +23,17 @@
  * distribute this file as part of a program that also links with and
  * uses the libopts library from AutoGen, you may include it under
  * the same distribution terms used by the libopts library.
- */
+ *
+ * Code:  */
 
 #ifndef SNPRINTFV_COMPAT_H
 #define SNPRINTFV_COMPAT_H 1
 
 #ifdef __cplusplus
 extern "C" {
-#if 0
-/* This brace is so that emacs can still indent properly: */ }
-#endif
+#define SNV_END_EXTERN_C }
+#else
+#define SNV_END_EXTERN_C
 #endif /* __cplusplus */
 
 #include <stdio.h>
@@ -208,12 +211,6 @@ typedef enum { SNV_FALSE = 0, SNV_TRUE =
 #define ABS(a)         ((a) < 0 ? -(a) : (a))
 #endif
 
-
-#ifdef __cplusplus
-#if 0
-/* This brace is so that emacs can still indent properly: */ {
-#endif
-}
-#endif /* __cplusplus */
-
-#endif /* COMPAT_H */
+SNV_END_EXTERN_C
+#endif /* SNPRINTFV_COMPAT_H */
+/* end of snprintfv/compat.h */
Index: snprintfv/custom.c
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/custom.c,v
retrieving revision 1.2
diff -b -B -u -p -u -p -r1.2 custom.c
--- snprintfv/custom.c  21 Feb 2007 15:41:26 -0000      1.2
+++ snprintfv/custom.c  25 Feb 2007 20:11:53 -0000
@@ -37,6 +37,10 @@
 
 #include <stddef.h>
 
+#if HAVE_RUNETYPE_H
+# include <runetype.h>
+#endif
+
 #ifdef HAVE_WCHAR_H
 #  include <wchar.h>
 #endif
@@ -168,4 +172,4 @@ printf_generic (STREAM *stream, struct p
   /* Return the number of characters emitted. */
   return count_or_errorcode;
 }
-
+/* end of snprintfv/custom.c */
Index: snprintfv/filament.in
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/filament.in,v
retrieving revision 1.6
diff -b -B -u -p -u -p -r1.6 filament.in
--- snprintfv/filament.in       21 Feb 2007 15:41:26 -0000      1.6
+++ snprintfv/filament.in       25 Feb 2007 20:11:53 -0000
@@ -40,7 +40,7 @@ extern "C"
 #endif
 #endif                         /* __cplusplus */
 
-#define FILAMENT_BUFSIZ       512
+#define FILAMENT_BUFSIZ       (512 - sizeof(char *) - (2 * sizeof(size_t)))
 
 /**
  * Filament:
Index: snprintfv/format.c
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/format.c,v
retrieving revision 1.6
diff -b -B -u -p -u -p -r1.6 format.c
--- snprintfv/format.c  21 Feb 2007 15:41:26 -0000      1.6
+++ snprintfv/format.c  25 Feb 2007 20:11:53 -0000
@@ -39,6 +39,10 @@
 #include <math.h>
 #include <stddef.h>
 
+#if HAVE_RUNETYPE_H
+# include <runetype.h>
+#endif
+
 #ifdef HAVE_WCHAR_H
 #  include <wchar.h>
 #endif
@@ -1141,7 +1145,7 @@ copysignl (long double x, long double y)
 #  endif /* !HAVE_COPYSIGN */
 }
 # endif /* !HAVE_COPYSIGNL */
-#endif /* !NO_FLOAT_PRINTING && HAVE_LONG_DOUBLE)
+#endif /* !NO_FLOAT_PRINTING && HAVE_LONG_DOUBLE) */
 
 
 
Index: snprintfv/mem.c
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/mem.c,v
retrieving revision 1.4
diff -b -B -u -p -u -p -r1.4 mem.c
--- snprintfv/mem.c     21 Feb 2007 15:41:26 -0000      1.4
+++ snprintfv/mem.c     25 Feb 2007 20:11:53 -0000
@@ -50,7 +50,8 @@ realloc_proc_t* snv_realloc = (realloc_p
 free_proc_t*    snv_free    = (free_proc_t*)free;
 
 /* Unportable memory management functions are reimplemented tout court.  */
-snv_pointer snv_xrealloc (snv_pointer old, size_t count)
+snv_pointer
+snv_xrealloc (snv_pointer old, size_t count)
 {
   if (count < 1)
     {
@@ -63,7 +64,8 @@ snv_pointer snv_xrealloc (snv_pointer ol
     return snv_realloc (old, count);
 }
 
-char *snv_strdup (const char *str)
+char *
+snv_strdup (const char *str)
 {
   size_t len = strlen (str);
   char *result = snv_malloc (len + 1);
Index: snprintfv/mem.h
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/mem.h,v
retrieving revision 1.6
diff -b -B -u -p -u -p -r1.6 mem.h
--- snprintfv/mem.h     24 Feb 2007 04:34:52 -0000      1.6
+++ snprintfv/mem.h     25 Feb 2007 20:11:53 -0000
@@ -37,6 +36,18 @@
 #  include <dmalloc.h>
 #endif
 
+#ifdef _WIN32
+#  ifdef DLL_EXPORT
+#    define SNV_SCOPE  extern __declspec(dllexport)
+#  else
+#    ifdef LIBSNPRINTFV_DLL_IMPORT
+#      define SNV_SCOPE        extern __declspec(dllimport)
+#    endif
+#  endif
+#else
+#  define SNV_SCOPE    extern
+#endif
+
 /* This is the API we use throughout libsnprintfv. */
 #define snv_new(type, count)           \
                ((type*)snv_malloc((size_t)sizeof(type) * (count)))
@@ -65,7 +76,7 @@ typedef void* (free_proc_t   )(snv_point
  * Return value:
  * The pointer to the newly-allocated memory area.
  */
-malloc_proc_t *snv_malloc;
+SNV_SCOPE malloc_proc_t *snv_malloc;
 
 /**
  * snv_realloc:
@@ -79,7 +90,7 @@ malloc_proc_t *snv_malloc;
  * The pointer to the newly-allocated memory area, possibly
  * the same as @old.
  */
-realloc_proc_t *snv_realloc;
+SNV_SCOPE realloc_proc_t *snv_realloc;
 
 /**
  * snv_free:
@@ -87,7 +98,7 @@ realloc_proc_t *snv_realloc;
  *
  * Frees a block of memory pointed to by @old.
  */
-free_proc_t *snv_free;
+SNV_SCOPE free_proc_t *snv_free;
 
 /* And these are reimplemented tout court because they are
    not fully portable.  */
Index: snprintfv/printf.c
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/printf.c,v
retrieving revision 1.2
diff -b -B -u -p -u -p -r1.2 printf.c
--- snprintfv/printf.c  21 Feb 2007 15:41:26 -0000      1.2
+++ snprintfv/printf.c  25 Feb 2007 20:11:53 -0000
@@ -85,13 +85,13 @@ spec_init (void)
   if (!is_init)
     {
       extern spec_entry snv_default_spec_table[];
-      int i;
+      unsigned ix;
 
       memset (spec_table, 0, sizeof (spec_table));
-      for (i = 0; snv_default_spec_table[i].spec_key != EOS; i++)
+      for (ix = 0; snv_default_spec_table[ix].spec_key != EOS; ix++)
        {
-         unsigned hash = spec_hash (snv_default_spec_table[i].spec_key);
-         spec_table[hash] = &snv_default_spec_table[i];
+         unsigned hash = spec_hash (snv_default_spec_table[ix].spec_key);
+         spec_table[hash] = snv_default_spec_table + ix;
        }
 
       is_init = SNV_TRUE;
@@ -120,7 +120,8 @@ spec_lookup (unsigned spec)
  * register_printf_function: printf.h
  * @spec: the character which will trigger @func, cast to an unsigned int.
  * @fmt: the handler function to actually print the arguments to the specifier
- * @arg: the handler function to tell %printf about the types of the arguments 
to the specifier
+ * @arg: the handler function to tell %printf about the types of the arguments
+ *       to the specifier
  * 
  * Register the pair made of @fmt and @arg, so that it is called
  * when @spec is encountered in a format string.
@@ -152,7 +153,10 @@ register_printf_function (unsigned spec,
 }
 
 static int
-call_argtype_function (struct printf_info *const pinfo, int **argtypes, 
spec_entry *spec)
+call_argtype_function (
+    struct printf_info *const pinfo,
+    int **argtypes,
+    spec_entry *spec)
 {
   int n;
   int argindex = (pinfo->dollar && !IS_MODIFIER (spec))
@@ -193,7 +197,7 @@ call_argtype_function (struct printf_inf
 
   else
     {
-      pinfo->spec = *(unsigned char *) pinfo->format;
+      pinfo->spec = (unsigned)*(pinfo->format);
       pinfo->extra = spec->user;
       pinfo->type = spec->type;
 
@@ -201,7 +205,7 @@ call_argtype_function (struct printf_inf
         n = spec->arg(pinfo, (size_t) (pinfo->argc - argindex),
                      *argtypes + argindex);
       else
-        n = spec->arg(pinfo, (size_t) 0, NULL);
+        n = spec->arg(pinfo, (size_t)0, NULL);
 
       if (n < 0)
        return n;
@@ -216,7 +220,7 @@ call_argtype_function (struct printf_inf
          pinfo->argindex = save_argindex;
          pinfo->format = save_format;
          pinfo->state = save_state;
-          pinfo->spec = *(unsigned char *) pinfo->format;
+          pinfo->spec     = (unsigned)*(pinfo->format);
           pinfo->extra = spec->user;
           pinfo->type = spec->type;
           n = spec->arg(pinfo, (size_t)n, *argtypes + argindex);
@@ -224,7 +228,7 @@ call_argtype_function (struct printf_inf
     }
 
 /* FIXME!!! && or || ???? */
-  if (!pinfo->dollar && !IS_MODIFIER (spec))
+  if (!pinfo->dollar || !IS_MODIFIER (spec))
     pinfo->argindex += n;
 
   return n;
@@ -250,7 +254,10 @@ printf_strerror (void)
 
 /* (re)initialise the memory used by PPARSER. */
 static inline void
-parser_init (struct printf_info *pinfo, const char *format, const union 
printf_arg *args)
+parser_init (
+    struct printf_info *pinfo,
+    const char *format,
+    const union printf_arg *args)
 {
   memset (pinfo, 0, sizeof (struct printf_info));
   pinfo->format = format;
@@ -352,7 +359,7 @@ parse_printf_format (const char *format,
 
   while (*info.format != EOS)
     {
-      int ch = *(unsigned char *) info.format++;
+      int ch = (int) *info.format++;
 
       switch (ch)
        {
@@ -373,7 +380,7 @@ parse_printf_format (const char *format,
 
                  /* ...lookup the handler associated with the char
                     we are looking at in the format string... */
-                 spec = spec_lookup (*(unsigned char *) info.format);
+                 spec = spec_lookup ((unsigned)*(info.format));
                  if (spec == NULL)
                    {
                      PRINTF_ERROR (&info, "unregistered specifier");
@@ -393,7 +400,7 @@ parse_printf_format (const char *format,
                  /* ...and call the relevant handler.  */
                  if (spec->arg)
                    {
-                     info.spec = *(unsigned char *) info.format;
+                      info.spec = (unsigned)*(info.format);
                      info.extra = spec->user;
                      info.type = spec->type;
                      status = (*spec->arg) (&info, (size_t) (n - argindex),
@@ -411,7 +418,7 @@ parse_printf_format (const char *format,
 
                  info.argc = MAX (info.argc, argindex + status);
 /* FIXME!!! && or || ????? */
-                 if (!info.dollar && !IS_MODIFIER (spec))
+                  if (!info.dollar || !IS_MODIFIER (spec))
                    info.argindex += status;
 
                  info.format++;
@@ -470,7 +477,8 @@ do_printfv (STREAM *stream, const char *
            {
              /* We found the start of a format specifier! */
              spec_entry *spec;
-             int status, argindex;
+             int status;
+             int argindex;
 
              parser_reset (&info);
              do
@@ -481,7 +489,7 @@ do_printfv (STREAM *stream, const char *
 
                  /* ...lookup the handler associated with the char
                     we are looking at in the format string... */
-                 spec = spec_lookup (*(unsigned char *) info.format);
+                 spec = spec_lookup ((unsigned)*(info.format));
                  if (spec == NULL)
                    {
                      PRINTF_ERROR (&info, "unregistered specifier");
@@ -496,7 +504,7 @@ do_printfv (STREAM *stream, const char *
                    }
 
                  /* ...and call the relevant handler. */
-                 info.spec = *(unsigned char *)info.format;
+                 info.spec = (unsigned)*(info.format);
                  info.extra = spec->user;
                  info.type = spec->type;
 
@@ -529,7 +537,7 @@ do_printfv (STREAM *stream, const char *
 
          /*FALLTHROUGH*/
 
-        default:       /* Just a character: ignore it. */
+        default:
           /* Just a character: copy it. */
          SNV_EMIT (ch, stream, info.count);
          continue;
@@ -577,6 +585,8 @@ stream_printfv (STREAM *stream, const ch
   return_val_if_fail (format != NULL, SNV_ERROR);
 
   parser_init (&info, format, NULL);
+
+  /* Keep going until the format string runs out! */
   while (*info.format != EOS)
     {
       int ch = (int) *info.format++;
@@ -595,9 +605,10 @@ stream_printfv (STREAM *stream, const ch
                  /* Until we fill the stream (or get some other
                     exception) or one of the handlers tells us
                     we have reached the end of the specifier... */
+
                  /* ...lookup the handler associated with the char
                     we are looking at in the format string... */
-                 spec = spec_lookup (*(unsigned char *) info.format);
+                  spec = spec_lookup ((unsigned)*(info.format));
                  if (spec == NULL)
                    {
                      PRINTF_ERROR (&info, "unregistered specifier");
@@ -635,85 +647,95 @@ stream_printfv (STREAM *stream, const ch
       break;
     }
 
-  if (info.argc > 0)
+  if (info.argc == 0)
     {
-      int i;
+      args = NULL;
+    }
+  else
+    {
+      int idx;
 
       args = snv_new (union printf_arg, info.argc);
 
       /* We scanned the format string to find the type of the arguments,
          so we can now cast it and store it correctly.  */
-      for (i = 0; i < info.argc; i++)
+      for (idx = 0; idx < info.argc; idx++)
         {
-          int tp = argtypes[i];
+          int tp = argtypes[idx];
           if ((tp & PA_TYPE_MASK) == PA_TYPE_MASK)
             {
-              if (i + 1 == info.argc)
+              if (idx + 1 == info.argc)
+                {
                 info.argc--;
-              continue;
+                  break;
+                }
+              continue; /* Ignore it.  We allow skipping args, but the
+                         * user is responsible for ensuring a void* sized
+                         * spacer in the argument list.
+                         */
             }
 
           switch (tp & ~PA_FLAG_UNSIGNED)
             {
             case PA_CHAR:
-              args[i].pa_char = (char) *(const long int *)(ap + i);
+              args[idx].pa_char = (char) *(const long int *)(ap + idx);
               break;
 
             case PA_WCHAR:
-              args[i].pa_wchar =
-                (snv_wchar_t) *(const long int *)(ap + i);
+              args[idx].pa_wchar =
+                (snv_wchar_t) *(const long int *)(ap + idx);
               break;
 
             case PA_INT|PA_FLAG_SHORT:
-              args[i].pa_short_int =
-                (short int) *(const long int *)(ap + i);
+              args[idx].pa_short_int =
+                (short int) *(const long int *)(ap + idx);
               break;
 
             case PA_INT:
-              args[i].pa_int = (int) *(const long int *)(ap + i);
+              args[idx].pa_int = (int) *(const long int *)(ap + idx);
               break;
 
             case PA_INT|PA_FLAG_LONG:
-              args[i].pa_long_int = *(const long int *)(ap + i);
+              args[idx].pa_long_int = *(const long int *)(ap + idx);
               break;
 
             case PA_INT|PA_FLAG_LONG_LONG:
-              args[i].pa_long_long_int = **(const intmax_t **)(ap + i);
+              args[idx].pa_long_long_int = **(const intmax_t **)(ap + idx);
               break;
 
             case PA_FLOAT:
-              args[i].pa_float = **(const float **)(ap + i);
+              args[idx].pa_float = **(const float **)(ap + idx);
               break;
 
             case PA_DOUBLE|PA_FLAG_LONG_DOUBLE:
 #ifdef HAVE_LONG_DOUBLE
-              args[i].pa_long_double = **(const long double **)(ap + i);
+              args[idx].pa_long_double = **(const long double **)(ap + idx);
               break;
 #endif
               /* else fall through */
 
             case PA_DOUBLE:
-              args[i].pa_double = **(const double **)(ap + i);
+              args[idx].pa_double = **(const double **)(ap + idx);
               break;
 
             /* Note that pointer types are dereferenced just once! */
             case PA_STRING:
-              args[i].pa_string = *(const char **)(ap + i);
+              args[idx].pa_string = *(const char **)(ap + idx);
               break;
 
             case PA_WSTRING:
-              args[i].pa_wstring = *(const snv_wchar_t **)(ap + i);
+              args[idx].pa_wstring = *(const snv_wchar_t **)(ap + idx);
               break;
 
             case PA_POINTER:
-              args[i].pa_pointer = *(snv_constpointer *)(ap + i);
+              args[idx].pa_pointer = *(snv_constpointer *)(ap + idx);
               break;
 
             default:
-              if (argtypes[i] & PA_FLAG_PTR)
-                args[i].pa_pointer = *(snv_constpointer *)(ap + i);
+              if (argtypes[idx] & PA_FLAG_PTR)
+                args[idx].pa_pointer = *(snv_constpointer *)(ap + idx);
               else
-                args[i].pa_long_double = 0.0;
+                args[idx].pa_long_double = 0.0;
               break;
             }
         }
@@ -766,7 +788,7 @@ stream_vprintf (STREAM *stream, const ch
   /* Keep going until the format string runs out! */
   while (*info.format != EOS)
     {
-      int ch = *(unsigned char *)info.format++;
+      int ch = (int) *info.format++;
 
       switch (ch)
        {
@@ -784,7 +806,7 @@ stream_vprintf (STREAM *stream, const ch
                     we have reached the end of the specifier... */
                  /* ...lookup the handler associated with the char
                     we are looking at in the format string... */
-                 spec = spec_lookup (*(unsigned char *) info.format);
+                 spec = spec_lookup ((unsigned)*(info.format));
                  if (spec == NULL)
                    {
                      PRINTF_ERROR (&info, "unregistered specifier");
@@ -824,7 +846,7 @@ stream_vprintf (STREAM *stream, const ch
 
   if (info.argc > 0)
     {
-      int i;
+      int idx;
 
       args = snv_new (union printf_arg, info.argc);
 
@@ -839,62 +861,62 @@ stream_vprintf (STREAM *stream, const ch
 
          Thanks to Robert Lipe <address@hidden> for explaining all
          this to me. */
-      for (i = 0; i < info.argc; i++)
-       switch (argtypes[i] & ~PA_FLAG_UNSIGNED)
+      for (idx = 0; idx < info.argc; idx++)
+       switch (argtypes[idx] & ~PA_FLAG_UNSIGNED)
          {
           case PA_CHAR:
-           args[i].pa_char = va_arg (ap, int); /* Promoted.  */
+           args[idx].pa_char = va_arg (ap, int); /* Promoted.  */
             break;
 
           case PA_WCHAR:
-           args[i].pa_wchar = va_arg (ap, snv_wint_t); /* Promoted.  */
+           args[idx].pa_wchar = va_arg (ap, snv_wint_t); /* Promoted.  */
             break;
 
           case PA_INT|PA_FLAG_SHORT:
-           args[i].pa_short_int = va_arg (ap, int); /* Promoted.  */
+           args[idx].pa_short_int = va_arg (ap, int); /* Promoted.  */
             break;
 
           case PA_INT:
-           args[i].pa_int = va_arg (ap, int);
+           args[idx].pa_int = va_arg (ap, int);
             break;
   
           case PA_INT|PA_FLAG_LONG:
-           args[i].pa_long_int = va_arg (ap, long int);
+           args[idx].pa_long_int = va_arg (ap, long int);
             break;
 
           case PA_INT|PA_FLAG_LONG_LONG:
-           args[i].pa_long_long_int = va_arg (ap, intmax_t);
+           args[idx].pa_long_long_int = va_arg (ap, intmax_t);
             break;
 
           case PA_FLOAT:
-           args[i].pa_float = va_arg (ap, double); /* Promoted.  */
+           args[idx].pa_float = va_arg (ap, double); /* Promoted.  */
             break;
 
           case PA_DOUBLE|PA_FLAG_LONG_DOUBLE:
-           args[i].pa_long_double = va_arg (ap, long double);
+           args[idx].pa_long_double = va_arg (ap, long double);
             break;
 
           case PA_DOUBLE:
-           args[i].pa_double = va_arg (ap, double);
+           args[idx].pa_double = va_arg (ap, double);
             break;
 
           case PA_STRING:
-           args[i].pa_string = va_arg (ap, const char *);
+           args[idx].pa_string = va_arg (ap, const char *);
             break;
 
           case PA_WSTRING:
-           args[i].pa_wstring = va_arg (ap, const snv_wchar_t *);
+           args[idx].pa_wstring = va_arg (ap, const snv_wchar_t *);
             break;
 
           case PA_POINTER:
-           args[i].pa_pointer = va_arg (ap, void *);
+           args[idx].pa_pointer = va_arg (ap, void *);
             break;
 
          default:
-            if (argtypes[i] & PA_FLAG_PTR)
-              args[i].pa_pointer = va_arg (ap, void *);
+            if (argtypes[idx] & PA_FLAG_PTR)
+              args[idx].pa_pointer = va_arg (ap, void *);
             else
-              args[i].pa_long_double = 0.0;
+              args[idx].pa_long_double = 0.0;
             break;
          }
     }
@@ -961,8 +983,8 @@ snv_fdputc (int ch, STREAM *stream)
 {
   static char buf[1] = { 0 };
   buf[0] = (char) ch;
-  return write ((int) SNV_POINTER_TO_LONG (stream_details (stream)), buf,
-               (size_t) 1)
+  return
+    write ((int) SNV_POINTER_TO_LONG (stream_details (stream)), buf, (size_t) 
1)
         ? ch : -1;
 }
 
@@ -1527,4 +1549,4 @@ snv_asprintfv (char **result, const char
   return count_or_errorcode;
 }
 
-/* snprintfv.c ends here */
+/* printfv.c ends here */
Index: snprintfv/printf.in
===================================================================
RCS file: /sources/libsnprintfv/libsnprintfv/snprintfv/printf.in,v
retrieving revision 1.3
diff -b -B -u -p -u -p -r1.3 printf.in
--- snprintfv/printf.in 21 Feb 2007 15:41:26 -0000      1.3
+++ snprintfv/printf.in 25 Feb 2007 20:11:53 -0000
@@ -154,9 +154,11 @@ typedef union printf_arg
 #define PRINTF_ERROR(pi, str)                                         \
         printf_error(pi, __FILE__, __LINE__, SNV_ASSERT_FMT, str);
 
-typedef int printf_function (STREAM *stream, struct printf_info *pparser, 
union printf_arg const * args);
+typedef int printf_function (STREAM *stream, struct printf_info *pparser,
+                             union printf_arg const * args);
 
-typedef int printf_arginfo_function (struct printf_info *pparser, size_t n, 
int *argtypes);
+typedef int printf_arginfo_function (struct printf_info *pparser, size_t n,
+                                     int *argtypes);
 
 /**
  * spec_entry:
--- ./snprintfv/compat.h        2007-02-25 11:59:54.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/compat.h    2007-02-25 12:09:49.000000000 
-0800
@@ -36,70 +36,112 @@ extern "C" {
 #define SNV_END_EXTERN_C
 #endif /* __cplusplus */
 
+#define NO_FLOAT_PRINTING
+
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+
 #include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdint.h>
 
-#define SNV_INLINE static inline
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#endif
 
-#ifdef HAVE_WCHAR_T
-#ifdef HAVE_RUNETYPE_H
-#include <runetype.h>
+#ifdef HAVE_ERRNO_H
+#  include <errno.h>
+#  ifndef errno
+     /* Some sytems #define this! */
+     extern int errno;
+#  endif
 #endif
-#include <wchar.h>
-typedef wchar_t snv_wchar_t;
-#else
-typedef unsigned int snv_wchar_t;
+
+#if defined( HAVE_LIMITS_H )
+#  include <limits.h>
+
+#elif defined( HAVE_SYS_LIMITS_H )
+#  include <sys/limits.h>
+
+#elif defined( HAVE_VALUES_H )
+#  ifndef MAXINT
+#    include <values.h>
+#  endif /* MAXINT */
 #endif
 
-#ifdef HAVE_WINT_T
-typedef wint_t snv_wint_t;
-#else
-typedef unsigned int snv_wint_t;
+#if defined( HAVE_STRING_H )
+#  include <string.h>
+
+#elif defined( HAVE_STRINGS_H )
+#  include <strings.h>
 #endif
 
-#ifdef HAVE_LONG_DOUBLE
-typedef long double snv_long_double;
-#else
-typedef double snv_long_double;
+#if defined( HAVE_MEMORY_H )
+#  include <memory.h>
 #endif
 
-#if defined(HAVE_FPUTC_UNLOCKED) && defined(HAVE_FLOCKFILE)
-#define SNV_FPUTC_UNLOCKED fputc_unlocked
-#define SNV_PUTC_UNLOCKED putc_unlocked
-#define SNV_WITH_LOCKED_FP(fp, tmp_var) \
-  for (flockfile (fp), tmp_var = 1; \
-       tmp_var--; funlockfile (fp))
+#if defined( HAVE_INTTYPES_H )
+#  include <inttypes.h>
+
+#elif defined( HAVE_STDINT_H )
+#  include <stdint.h>
+#endif
+
+#ifndef HAVE_UINTMAX_T
+#  if defined( HAVE_LONG_LONG )
+     typedef long long intmax_t;
+     typedef unsigned long long uintmax_t;
+#  else
+     typedef long intmax_t;
+     typedef unsigned long uintmax_t;
+#  endif
+#endif
+
+#if defined( HAVE_STDARG_H )
+#  include <stdarg.h>
+#  ifndef   VA_START
+#    define VA_START(a, f)  va_start(a, f)
+#    define VA_END(a)      va_end(a)
+#  endif /* VA_START */
+#  define SNV_USING_STDARG_H
+#elif defined( HAVE_VARARGS_H )
+#  include <varargs.h>
+#  ifndef   VA_START
+#    define VA_START(a, f) va_start(a)
+#    define VA_END(a)   va_end(a)
+#  endif /* VA_START */
+#  undef  SNV_USING_STDARG_H
 #else
-#define SNV_FPUTC_UNLOCKED fputc
-#define SNV_PUTC_UNLOCKED putc
-#define SNV_WITH_LOCKED_FP(fp, tmp_var) \
-  for (tmp_var = 1; tmp_var--; )
+#  include "must-have-stdarg-or-varargs"
 #endif
 
-/* Define macros for storing integers inside pointers.
- * Be aware that it is only safe to use these macros to store `int'
- * values in `char*' (or `void*') words, and then extract them later.
- * Although it will work the other way round on many common
- * architectures, it is not portable to assume a `char*' can be
- * stored in an `int' and extracted later without loss of the msb's
- */
+#if HAVE_RUNETYPE_H
+# include <runetype.h>
+#endif
 
-#define SNV_POINTER_TO_LONG(p) ((long)(p))
-#define SNV_POINTER_TO_ULONG(p)        ((unsigned long)(p))
-#define SNV_LONG_TO_POINTER(i) ((snv_pointer)(long)(i))
-#define SNV_ULONG_TO_POINTER(u)        ((snv_pointer)(unsigned long)(u))
+#ifdef HAVE_WCHAR_H
+# include <wchar.h>
+#endif
+
+#ifdef HAVE_WCHAR_T
+typedef wchar_t snv_wchar_t;
+#else
+typedef int snv_wchar_t;
+#endif
+
+#ifdef HAVE_WINT_T
+typedef wint_t snv_wint_t;
+#else
+typedef int snv_wint_t;
+#endif
 
 /* inline and const keywords are (mostly) handled by config.h */
 #ifdef __GNUC__
 #  ifndef const
 #    define const      __const
 #  endif
+#  ifndef inline
+#    define inline     __inline
+#  endif
 #  ifndef signed
 #    define signed     __signed
 #  endif
@@ -111,36 +153,46 @@ typedef double snv_long_double;
 #endif
 
 #ifdef __STDC__
-#  ifndef SNV_STR
-#    define SNV_STR(x)         #x
-#  endif
-typedef void *snv_pointer;
-typedef const void *snv_constpointer;
+#  define _SNV_STR(x)          #x
+   typedef void *snv_pointer;
+   typedef const void *snv_constpointer;
 #else
-#  ifndef SNV_STR
-#    define SNV_STR(x)         "x"
-#  endif
-typedef char *snv_pointer;
-typedef char *snv_constpointer;
+#  define _SNV_STR(x)          "x"
+   typedef char *snv_pointer;
+   typedef char *snv_constpointer;
 #endif
 
-/* Do not use `enum boolean': this tag is used in SVR4 <sys/types.h>.  */
-typedef enum { SNV_FALSE = 0, SNV_TRUE = 1 } snv_bool_t;
+/* Define macros for storing integers inside pointers.
+ * Be aware that it is only safe to use these macros to store `int'
+ * values in `char*' (or `void*') words, and then extract them later.
+ * Although it will work the other way round on many common
+ * architectures, it is not portable to assume a `char*' can be
+ * stored in an `int' and extracted later without loss of the msb's
+ */
 
-#if defined __CYGWIN32__
+#define SNV_POINTER_TO_INT(p)  ((long)(p))
+#define SNV_POINTER_TO_UINT(p) ((unsigned long)(p))
+#define SNV_INT_TO_POINTER(i)  ((snv_pointer)(long)(i))
+#define SNV_UINT_TO_POINTER(u) ((snv_pointer)(unsigned long)(u))
+
+typedef enum {
+    SNV_FALSE = 0,
+    SNV_TRUE  = 1
+} snv_bool_t;
+
+#ifdef __CYGWIN32__
 #  ifndef __CYGWIN__
-#     define __CYGWIN__
+#    define __CYGWIN__
 #  endif
 #endif
-#if defined __CYGWIN__ || defined __MSVCRT__ || defined WIN32 || defined 
__WIN32__
+#ifdef __CYGWIN__
 #  ifndef _WIN32
 #    define _WIN32
 #  endif
 #endif
 
-#ifndef EXIT_SUCCESS
-#  define EXIT_SUCCESS  0
-#  define EXIT_FAILURE  1
+#ifndef PARAMS
+#  define PARAMS(args)      args
 #endif
 
 #undef SNV_STMT_START
@@ -148,15 +200,28 @@ typedef enum { SNV_FALSE = 0, SNV_TRUE =
 #if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
 #  define SNV_STMT_START       (void)(
 #  define SNV_STMT_END         )
+
+#elif (defined (sun) || defined (__sun__))
+#  define SNV_STMT_START       if (1)
+#  define SNV_STMT_END         else (void)0
+
 #else
-#  if (defined (sun) || defined (__sun__))
-#    define SNV_STMT_START     if (1)
-#    define SNV_STMT_END       else (void)0
+#  define SNV_STMT_START       do
+#  define SNV_STMT_END         while (0)
+#endif
+
+#ifdef _WIN32
+#  ifdef DLL_EXPORT
+#    define SNV_SCOPE  extern __declspec(dllexport)
 #  else
-#    define SNV_STMT_START     do
-#    define SNV_STMT_END       while (0)
+#    ifdef LIBSNPRINTFV_DLL_IMPORT
+#      define SNV_SCOPE        extern __declspec(dllimport)
+#    endif
 #  endif
 #endif
+#ifndef SNV_SCOPE
+#  define SNV_SCOPE    extern
+#endif
 
 #undef SNV_GNUC_PRINTF
 #undef SNV_GNUC_NORETURN
@@ -165,39 +230,38 @@ typedef enum { SNV_FALSE = 0, SNV_TRUE =
        args __attribute__((format (printf, format_idx, arg_idx)))
 #  define SNV_GNUC_NORETURN                                            \
        __attribute__((noreturn))
-#  define SNV_ASSERT_FMT        " (", __PRETTY_FUNCTION__, ")"
+#  define SNV_ASSERT_FCN        " (", __PRETTY_FUNCTION__, ")"
 #else /* !__GNUC__ */
 #  define SNV_GNUC_PRINTF( args, format_idx, arg_idx ) args
 #  define SNV_GNUC_NORETURN
-#  define SNV_ASSERT_FMT               "", "", ""
+#  define SNV_ASSERT_FCN               "", "", ""
 #endif /* !__GNUC__ */
 
-#define snv_assert(expr)                       snv_fassert(stderr, expr)
-#define snv_fassert(stream, expr)      SNV_STMT_START{                 \
-    if (!(expr))                               \
-    {                                                     \
-       fprintf (stream, "file %s: line %d%s%s%s: assertion \"%s\" failed.\n", \
-       __FILE__, __LINE__, SNV_ASSERT_FMT, SNV_STR(expr));             \
-       exit(EXIT_FAILURE);                                             \
-    };                                 }SNV_STMT_END
+#define SNV_ASSERT_FMT  "file %s: line %d%s%s%s: assertion \"%s\" failed.\n"
+
+#define snv_assert(expr)               snv_fassert(stderr, expr)
+#define snv_fassert(stream, expr)   SNV_STMT_START {        \
+    if (!(expr))   {                                        \
+    fprintf (stream, SNV_ASSERT_FMT, __FILE__, __LINE__,    \
+             SNV_ASSERT_FCN, _SNV_STR(expr));               \
+    exit(EXIT_FAILURE);                                     \
+    }; } SNV_STMT_END
 
 #define return_if_fail(expr)           freturn_if_fail(stderr, expr)
-#define freturn_if_fail(expr)          SNV_STMT_START{                 \
-    if (!(expr))                                                       \
-    {                                                                  \
-       fprintf (stream, "file %s: line %d%s%s%s: assertion \"%s\" failed.\n", \
-       __FILE__, __LINE__, SNV_ASSERT_FMT, SNV_STR(expr));             \
-       return;                                                         \
-    };                                 }SNV_STMT_END
+#define freturn_if_fail(expr)       SNV_STMT_START {        \
+    if (!(expr))   {                                        \
+    fprintf (stream, SNV_ASSERT_FMT, __FILE__, __LINE__,    \
+             SNV_ASSERT_FCN, _SNV_STR(expr));               \
+    return;                                                 \
+    }; } SNV_STMT_END
 
 #define return_val_if_fail(expr, val)  freturn_val_if_fail(stderr, expr, val)
-#define freturn_val_if_fail(stream, expr, val) SNV_STMT_START{         \
-    if (!(expr))                                                       \
-    {                                                                  \
-       fprintf (stream, "file %s: line %d%s%s%s: assertion \"%s\" failed.\n", \
-       __FILE__, __LINE__, SNV_ASSERT_FMT, SNV_STR(expr));             \
-       return val;                                                     \
-    };                                 }SNV_STMT_END
+#define freturn_val_if_fail(stream, expr, val)  SNV_STMT_START {    \
+    if (!(expr))  {                                                 \
+    fprintf (stream, SNV_ASSERT_FMT, __FILE__, __LINE__,            \
+             SNV_ASSERT_FCN, _SNV_STR(expr));                       \
+    return val;                                                     \
+    }; } SNV_STMT_END
 
 #ifndef MAX
 #define MAX(a,b)       ((a) > (b) ? (a) : (b))
@@ -211,6 +275,20 @@ typedef enum { SNV_FALSE = 0, SNV_TRUE =
 #define ABS(a)         ((a) < 0 ? -(a) : (a))
 #endif
 
+typedef SNV_LONG_DOUBLE snv_long_double;
+
+#ifndef HAVE_STRTOUL
+extern unsigned long
+strtoul( const char *nptrm, char **endptr, register int base );
+#endif
+
 SNV_END_EXTERN_C
 #endif /* SNPRINTFV_COMPAT_H */
-/* end of snprintfv/compat.h */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/compat.h */
--- ./snprintfv/custom.c        2007-02-25 12:01:01.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/custom.c    2007-02-25 12:09:49.000000000 
-0800
@@ -172,4 +172,11 @@ printf_generic (STREAM *stream, struct p
   /* Return the number of characters emitted. */
   return count_or_errorcode;
 }
-/* end of snprintfv/custom.c */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/custom.c */
--- ./snprintfv/filament.c      2007-02-21 07:41:26.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/filament.c  2007-02-25 12:09:49.000000000 
-0800
@@ -223,4 +223,10 @@ _fil_extend (Filament *fil, size_t len, 
     fil->value = snv_renew (char, fil->value, fil->size);
 }
 
-/* Filament.c ends here */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/filament.c */
--- ./snprintfv/mem.c   2007-02-25 11:14:32.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/mem.c       2007-02-25 12:09:49.000000000 
-0800
@@ -72,3 +72,11 @@ snv_strdup (const char *str)
   memcpy (result, str, len + 1);
   return result;
 }
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/mem.c */
--- ./snprintfv/mem.h   2007-02-25 11:18:48.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/mem.h       2007-02-25 12:09:49.000000000 
-0800
@@ -111,4 +111,10 @@ extern char* snv_strdup (const char *str
 
 #endif /* SNPRINTFV_MEM_H */
 
-/* mem.h ends here */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/mem.h */
--- ./snprintfv/printf.c        2007-02-25 12:06:53.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/printf.c    2007-02-25 12:06:54.000000000 
-0800
@@ -43,7 +43,15 @@
 #include "filament.h"
 #include "stream.h"
 #include "mem.h"
-#include "dl.h"
+
+#ifdef SNV_LIBRARY_BUILD
+#  include "dl.h"
+#else
+
+#  ifndef HAVE_STRTOUL
+#    include "strtoul.c"
+#  endif
+#endif /* SNV_LIBRARY_BUILD */
 
 #define EOS                    '\0'
 #define SNV_CHAR_SPEC          '%'
@@ -227,7 +235,6 @@ call_argtype_function (
         }
     }
 
-/* FIXME!!! && or || ???? */
   if (!pinfo->dollar || !IS_MODIFIER (spec))
     pinfo->argindex += n;
 
@@ -417,7 +424,6 @@ parse_printf_format (const char *format,
                     goto error;
 
                   info.argc = MAX (info.argc, argindex + status);
-/* FIXME!!! && or || ????? */
                   if (!info.dollar || !IS_MODIFIER (spec))
                     info.argindex += status;
 
@@ -1549,4 +1555,10 @@ snv_asprintfv (char **result, const char
   return count_or_errorcode;
 }
 
-/* printfv.c ends here */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/printfv.c */
--- ./snprintfv.m4      2007-02-25 06:31:12.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/snprintfv.m4        2006-12-10 
11:45:56.000000000 -0800
@@ -1,8 +1,9 @@
+
 dnl AC_SNPRINTFV_CONVENIENCE[(dir)] - sets LIBSNPRINTFV to the link flags for
 dnl the snprintfv convenience library and INCSNPRINTFV to the include flags for
 dnl the snprintfv header and adds --enable-snprintfv-convenience to the
 dnl configure arguments.  Note that AC_CONFIG_SUBDIRS is not called.  If DIR
-dnl is not provided, it is assumed to be `snprintfv'.  LIBSNPRINTFV will be 
+dnl is not provided, it is assumed to be `snprintfv'.  LIBSNPRINTFV will be
 dnl prefixed with '${top_builddir}/' and INCSNPRINTFV will be prefixed with
 dnl '${top_srcdir}/' (note the single quotes!).  If your package is not
 dnl flat and you're not using automake, define top_builddir and
@@ -19,62 +20,23 @@ AC_DEFUN([AC_SNPRINTFV_CONVENIENCE],
   AC_SUBST(INCSNPRINTFV)
 ])
 
-dnl AC_SNPRINTFV_INSTALLABLE[(dir)] - sets LIBSNPRINTFV to the link flags for
-dnl the snprintfv installable library and INCSNPRINTFV to the include flags for
-dnl the snprintfv header and adds --enable-snprintfv-install to the
-dnl configure arguments.  Note that AC_CONFIG_SUBDIRS is not called.  If DIR
-dnl is not provided and an installed libsnprintfv is not found, it is assumed
-dnl to be `snprintfv'.  LIBSNPRINTFV will be prefixed with '${top_builddir}/'
-dnl and INCSNPRINTFV will be prefixed with # '${top_srcdir}/' (note the single
-dnl quotes!).  If your package is not flat and you're not using automake,
-dnl define top_builddir and top_srcdir appropriately in the Makefiles.
-dnl In the future, this macro may have to be called after AC_PROG_LIBTOOL.
-AC_DEFUN([AC_SNPRINTFV_INSTALLABLE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-  AC_CHECK_LIB(snprintfv, snv_printf,
-  [test x"$enable_snprintfv_install" != xyes && enable_snprintfv_install=no],
-  [if test x"$enable_snprintfv_install" = xno; then
-     AC_MSG_WARN([snprintfv not installed, but installation disabled])
-   else
-     enable_snprintfv_install=yes
-
-     # ----------------------------------------------------------------------
-     # Win32 objects need to tell the header whether they will be linking
-     # with a dll or static archive in order that everything is imported
-     # to the object in the same way that it was exported from the
-     # archive (``extern'' for static, ``__declspec(dllimport)'' for dlls).
-     # ----------------------------------------------------------------------
-     case "$host" in
-     *-*-cygwin* | *-*-mingw* | *-*-os2)
-       AC_DEFINE([LIBSNPRINTFV_DLL_IMPORT], ,
-        [Defined to 1 to work around Windows' broken implementation of
-         exported data symbols])
-         echo '#define LIBSNPRINTFV_DLL_IMPORT 1' >> $tmpfile
-       fi
-       ;;
-     esac
-   fi
-  ])
-
-
-  if test x"$enable_snprintfv_install" = x"yes"; then
-    ac_configure_args="$ac_configure_args --enable-snprintfv-install"
-    
LIBSNPRINTFV='${top_builddir}/'ifelse($#,1,[$1],['snprintfv'])/snprintfv/libsnprintfv.la
-    INCSNPRINTFV='-I${top_srcdir}/'ifelse($#,1,[$1],['snprintfv'])
-    INCSNPRINTFV='-I${top_builddir}/'ifelse($#,1,[$1],['snprintfv'])' 
-I${top_srcdir}/'ifelse($#,1,[$1],['snprintfv'])
-  else
-    ac_configure_args="$ac_configure_args --enable-snprintfv-install=no"
-    LIBSNPRINTFV="-lsnprintfv"
-    INCSNPRINTFV=
-  fi
-])
-
 AC_DEFUN([INVOKE_SNPRINTFV_MACROS],[
-  AC_REQUIRE([AM_WITH_DMALLOC])
-  AC_REQUIRE([AC_PROG_AWK])
+  AC_SNPRINTFV_CONVENIENCE
+  # ----------------------------------------------------------------------
+  # Set up and process configure options
+  # ----------------------------------------------------------------------
+  AC_ARG_ENABLE(snprintfv-install,
+  [  --enable-snprintfv-install  install libsnprintfv [yes]])
+  AM_CONDITIONAL(INSTALL_SNPRINTFV,
+  test x"${enable_snprintfv_install-no}" != xno)
+  AM_CONDITIONAL(CONVENIENCE_SNPRINTFV,
+  test x"${enable_snprintfv_convenience-no}" != xno)
+  AM_CONDITIONAL(SUBDIR_SNPRINTFV,
+  test x"${enable_subdir-no}" != xno)
+
+  AM_WITH_DMALLOC
+  AC_PROG_AWK
 
-  dnl FIXME: gnulib's wchar_.h ought to do this.
   # ----------------------------------------------------------------------
   # check for various programs used during the build.
   # On OS/X, "wchar.h" needs "runetype.h" to work properly.
@@ -85,27 +47,58 @@ AC_DEFUN([INVOKE_SNPRINTFV_MACROS],[
     # include <runetype.h>
     #endif
     ])
+  dnl am_cv_prog_cc_stdc is set by AC_PROG_CC_STDC
+  case x$am_cv_prog_cc_stdc in
+  xno)
+    # Non ansi C => won't work with stdarg.h
+    AC_CHECK_HEADER(varargs.h)
+    ;;
+  *)
+    case x$ac_cv_header_varargs_h in
+    xyes)
+      # Parent package is using varargs.h which is incompatible with
+      # stdarg.h, so we do the same.
+      AC_CHECK_HEADER(varargs.h)
+      ;;
+    *)
+      # If stdarg.h is present define HAVE_STDARG_H, otherwise if varargs.h
+      # is present define HAVE_VARARGS_H.
+      AC_CHECK_HEADERS(stdarg.h varargs.h, break)
+      ;;
+    esac
+    ;;
+  esac
 
-  AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR(Could not find stdarg.h.)])
+  case x$ac_cv_header_stdarg_h$ac_cv_header_varargs_h in
+  x*yes*) ;;
+  *) AC_MSG_ERROR(Could not find either stdarg.h or varargs.h.) ;;
+  esac
 
   # ----------------------------------------------------------------------
   # Checks for typedefs
   # ----------------------------------------------------------------------
-  AC_REQUIRE([gt_TYPE_WCHAR_T])
-  AC_REQUIRE([gt_TYPE_WINT_T])
-  AC_REQUIRE([AC_TYPE_SIZE_T])
-  AC_TYPE_LONG_DOUBLE
+  AC_CHECK_TYPE(wchar_t, [], [
+    AC_DEFINE_UNQUOTED([wchar_t], [unsigned int],
+        [Define to `unsigned int' if not found])])
+  AC_CHECK_TYPE(wint_t, [], [
+    AC_DEFINE_UNQUOTED([wint_t], [unsigned int],
+        [Define to `unsigned int' if not found])], [
+    AC_INCLUDES_DEFAULT
+    #if HAVE_RUNETYPE_H
+    # include <runetype.h>
+    #endif
+    #if HAVE_WCHAR_H
+    # include <wchar.h>
+    #endif
+    ])
+  AC_CHECK_TYPE(long double)
+  AC_CHECK_TYPE(intmax_t)
+  AC_TYPE_SIZE_T
 
   # ----------------------------------------------------------------------
   # Checks for library calls
   # ----------------------------------------------------------------------
-  dnl GNU Smalltalk local, delete dnl on the next line
-  dnl AC_REPLACE_FUNCS(strtoul ldexpl frexpl)
+  AC_REPLACE_FUNCS(strtoul ldexpl frexpl)
   AC_CHECK_LIB(m, log)
-  AC_CHECK_FUNCS(copysign copysignl isinf isinfl isnan isnanl modfl)
-
-  dnl Persuade glibc and Solaris <stdio.h> to declare
-  dnl fgets_unlocked(), fputs_unlocked() etc.
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS(flockfile fputc_unlocked)
+  AC_CHECK_FUNCS(copysign copysignl)
 ])
--- ./snprintfv/stream.c        2007-02-25 11:47:44.000000000 -0800
+++ /home/bkorb/ag/gnu-ag/snprintfv/stream.c    2007-02-25 12:09:49.000000000 
-0800
@@ -214,4 +214,10 @@ stream_get (STREAM *stream)
   return (*stream->get_func) (stream);
 }
 
-/* stream.c ends here */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of snprintfv/stream.c */

reply via email to

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