Blame SOURCES/xsane-0.999-snprintf-update.patch

8ceb32
diff -up xsane-0.999/lib/snprintf.c.OLD xsane-0.999/lib/snprintf.c
8ceb32
--- xsane-0.999/lib/snprintf.c.OLD	2014-05-29 10:42:26.795419830 -0400
8ceb32
+++ xsane-0.999/lib/snprintf.c	2014-05-29 10:48:58.544431002 -0400
8ceb32
@@ -2,180 +2,616 @@
8ceb32
 
8ceb32
 #ifndef HAVE_SNPRINTF
8ceb32
 
8ceb32
-/***************************************************************************
8ceb32
- * LPRng - An Extended Print Spooler System
8ceb32
- *
8ceb32
- * Copyright 1988-1997, Patrick Powell, San Diego, CA
8ceb32
- *     papowell@sdsu.edu
8ceb32
- * See below for conditions of use.
8ceb32
- *
8ceb32
- ***************************************************************************
8ceb32
- * MODULE: snprintf.c
8ceb32
- * PURPOSE: LPRng version of printf - absolutely bombproof (hopefully!)
8ceb32
+/**************************************************************************
8ceb32
+ * Copyright 1994-2003 Patrick Powell, San Diego, CA <papowell@lprng.com>
8ceb32
  **************************************************************************/
8ceb32
-#if 0
8ceb32
-
8ceb32
-			 The "Artistic License"
8ceb32
-
8ceb32
-				Preamble
8ceb32
-
8ceb32
-The intent of this document is to state the conditions under which a
8ceb32
-Package may be copied, such that the Copyright Holder maintains some
8ceb32
-semblance of artistic control over the development of the package,
8ceb32
-while giving the users of the package the right to use and distribute
8ceb32
-the Package in a more-or-less customary fashion, plus the right to make
8ceb32
-reasonable modifications.
8ceb32
-
8ceb32
-Definitions:
8ceb32
-
8ceb32
-	"Package" refers to the collection of files distributed by the
8ceb32
-	Copyright Holder, and derivatives of that collection of files
8ceb32
-	created through textual modification.
8ceb32
-
8ceb32
-	"Standard Version" refers to such a Package if it has not been
8ceb32
-	modified, or has been modified in accordance with the wishes
8ceb32
-	of the Copyright Holder as specified below.
8ceb32
-
8ceb32
-	"Copyright Holder" is whoever is named in the copyright or
8ceb32
-	copyrights for the package.
8ceb32
-
8ceb32
-	"You" is you, if you are thinking about copying or distributing
8ceb32
-	this Package.
8ceb32
-
8ceb32
-	"Reasonable copying fee" is whatever you can justify on the
8ceb32
-	basis of media cost, duplication charges, time of people involved,
8ceb32
-	and so on.  (You will not be required to justify it to the
8ceb32
-	Copyright Holder, but only to the computing community at large
8ceb32
-	as a market that must bear the fee.)
8ceb32
 
8ceb32
-	"Freely Available" means that no fee is charged for the item
8ceb32
-	itself, though there may be fees involved in handling the item.
8ceb32
-	It also means that recipients of the item may redistribute it
8ceb32
-	under the same conditions they received it.
8ceb32
-
8ceb32
-1. You may make and give away verbatim copies of the source form of the
8ceb32
-Standard Version of this Package without restriction, provided that you
8ceb32
-duplicate all of the original copyright notices and associated disclaimers.
8ceb32
-
8ceb32
-2. You may apply bug fixes, portability fixes and other modifications
8ceb32
-derived from the Public Domain or from the Copyright Holder.  A Package
8ceb32
-modified in such a way shall still be considered the Standard Version.
8ceb32
-
8ceb32
-3. You may otherwise modify your copy of this Package in any way, provided
8ceb32
-that you insert a prominent notice in each changed file stating how and
8ceb32
-when you changed that file, and provided that you do at least ONE of the
8ceb32
-following:
8ceb32
-
8ceb32
-    a) place your modifications in the Public Domain or otherwise make them
8ceb32
-    Freely Available, such as by posting said modifications to Usenet or
8ceb32
-    an equivalent medium, or placing the modifications on a major archive
8ceb32
-    site such as uunet.uu.net, or by allowing the Copyright Holder to include
8ceb32
-    your modifications in the Standard Version of the Package.
8ceb32
-
8ceb32
-    b) use the modified Package only within your corporation or organization.
8ceb32
-
8ceb32
-    c) rename any non-standard executables so the names do not conflict
8ceb32
-    with standard executables, which must also be provided, and provide
8ceb32
-    a separate manual page for each non-standard executable that clearly
8ceb32
-    documents how it differs from the Standard Version.
8ceb32
-
8ceb32
-    d) make other distribution arrangements with the Copyright Holder.
8ceb32
-
8ceb32
-4. You may distribute the programs of this Package in object code or
8ceb32
-executable form, provided that you do at least ONE of the following:
8ceb32
+/*
8ceb32
+   Overview:
8ceb32
 
8ceb32
-    a) distribute a Standard Version of the executables and library files,
8ceb32
-    together with instructions (in the manual page or equivalent) on where
8ceb32
-    to get the Standard Version.
8ceb32
+   snprintf( char *buffer, int len, const char *format,...)
8ceb32
+   plp_unsafe_snprintf( char *buffer, int len, const char *format,...)
8ceb32
+     its horribly unsafe companion that does NOT protect you from
8ceb32
+     the printing of evil control characters,  but may be necessary
8ceb32
+     See the man page documentation below
8ceb32
+   
8ceb32
+   This version of snprintf was developed originally for printing
8ceb32
+   on a motley collection of specialized hardware that had NO IO
8ceb32
+   library.  Due to contractual restrictions,  a clean room implementation
8ceb32
+   of the printf() code had to be developed.
8ceb32
+   
8ceb32
+   The method chosen for printf was to be as paranoid as possible,
8ceb32
+   as these platforms had NO memory protection,  and very small
8ceb32
+   address spaces.  This made it possible to try to print
8ceb32
+   very long strings, i.e. - all of memory, very easily.  To guard
8ceb32
+   against this,  all printing was done via a buffer, generous enough
8ceb32
+   to hold strings,  but small enough to protect against overruns,
8ceb32
+   etc.
8ceb32
+   
8ceb32
+   Strangely enough,  this proved to be of immense importance when
8ceb32
+   SPRINTFing to a buffer on a stack...  The rest,  of course,  is
8ceb32
+   well known,  as buffer overruns in the stack are a common way to
8ceb32
+   do horrible things to operating systems, security, etc etc.
8ceb32
+   
8ceb32
+   This version of snprintf is VERY limited by modern standards.
8ceb32
+
8ceb32
+   Revision History:
8ceb32
+   First Released Version - 1994.  This version had NO comments.
8ceb32
+   First Released Version - 1994.  This version had NO comments.
8ceb32
+   Second Major Released Version - Tue May 23 10:43:44 PDT 2000
8ceb32
+    Configuration and other items changed.  Read this doc.
8ceb32
+    Treat this as a new version.
8ceb32
+   Minor Revision - Mon Apr  1 09:41:28 PST 2002
8ceb32
+     - fixed up some constants and casts 
8ceb32
+   
8ceb32
+   COPYRIGHT AND TERMS OF USE:
8ceb32
+   
8ceb32
+   You may use, copy, distribute, or otherwise incorporate this software
8ceb32
+   and documentation into any product or other item,  provided that
8ceb32
+   the copyright in the documentation and source code as well as the
8ceb32
+   source code generated constant strings in the object, executable
8ceb32
+   or other code remain in place and are present in executable modules
8ceb32
+   or objects.
8ceb32
+   
8ceb32
+   You may modify this code as appropriate to your usage; however the
8ceb32
+   modified version must be identified by changing the various source
8ceb32
+   and object code identification strings as is appropriately noted
8ceb32
+   in the source code.
8ceb32
+   
8ceb32
+   You can use this with the GNU CONFIGURE utility.
8ceb32
+   This should define the following macros appropriately:
8ceb32
+   
8ceb32
+   HAVE_STDARG_H - if the <stdargs.h> include file is available
8ceb32
+   HAVE_VARARG_H - if the <varargs.h> include file is available
8ceb32
+   
8ceb32
+   HAVE_STRERROR - if the strerror() routine is available.
8ceb32
+     If it is not available, then examine the lines containing
8ceb32
+     the tests below.
8ceb32
+
8ceb32
+   HAVE_SYS_ERRLIST  - have sys_errlist available
8ceb32
+   HAVE_DECL_SYS_ERRLIST - sys_errlist declaration in include files
8ceb32
+   HAVE_SYS_NERR - have sys_nerr available
8ceb32
+   HAVE_DECL_SYS_NERR -  sys_nerr declaration in include files
8ceb32
+   
8ceb32
+   HAVE_QUAD_T      - if the quad_t type is defined
8ceb32
+   HAVE_LONG_LONG   - if the long long type is defined
8ceb32
+   HAVE_LONG_DOUBLE - if the long double type is defined
8ceb32
+   
8ceb32
+     If you are using the GNU configure (autoconf) facility, add the
8ceb32
+     following line to the configure.in file, to force checking for the
8ceb32
+     quad_t and long long  data types:
8ceb32
+
8ceb32
+
8ceb32
+    AC_CHECK_HEADERS(stdlib.h,stdio.h,unistd.h,errno.h)
8ceb32
+	AC_CHECK_FUNCS(strerror)
8ceb32
+	AC_CACHE_CHECK(for errno,
8ceb32
+	ac_cv_errno,
8ceb32
+	[
8ceb32
+	AC_TRY_LINK(,[extern int errno; return (errno);],
8ceb32
+		ac_cv_errno=yes, ac_cv_errno=no)
8ceb32
+	])
8ceb32
+	if test "$ac_cv_errno" = yes; then
8ceb32
+		AC_DEFINE(HAVE_ERRNO)
8ceb32
+		AC_CACHE_CHECK(for errno declaration,
8ceb32
+		ac_cv_decl_errno,
8ceb32
+		[
8ceb32
+		AC_TRY_COMPILE([
8ceb32
+		#include <stdio.h>
8ceb32
+		#ifdef HAVE_STDLIB_H
8ceb32
+		#include <stdlib.h>
8ceb32
+		#endif
8ceb32
+		#ifdef HAVE_UNISTD_H
8ceb32
+		#include <unistd.h>
8ceb32
+		#endif
8ceb32
+		#ifdef HAVE_ERRNO_H
8ceb32
+		#include <errno.h>
8ceb32
+		],[return(sys_nerr);],
8ceb32
+			ac_cv_decl_errno=yes, ac_cv_decl_errno=no)
8ceb32
+		])
8ceb32
+		if test "$ac_cv_decl_errno" = yes; then
8ceb32
+			AC_DEFINE(HAVE_DECL_ERRNO)
8ceb32
+		fi;
8ceb32
+	fi
8ceb32
+
8ceb32
+	AC_CACHE_CHECK(for sys_nerr,
8ceb32
+	ac_cv_sys_nerr,
8ceb32
+	[
8ceb32
+	AC_TRY_LINK(,[extern int sys_nerr; return (sys_nerr);],
8ceb32
+		ac_cv_sys_nerr=yes, ac_cv_sys_nerr=no)
8ceb32
+	])
8ceb32
+	if test "$ac_cv_sys_nerr" = yes; then
8ceb32
+		AC_DEFINE(HAVE_SYS_NERR)
8ceb32
+		AC_CACHE_CHECK(for sys_nerr declaration,
8ceb32
+		ac_cv_decl_sys_nerr,
8ceb32
+		[
8ceb32
+		AC_TRY_COMPILE([
8ceb32
+		#include <stdio.h>
8ceb32
+		#ifdef HAVE_STDLIB_H
8ceb32
+		#include <stdlib.h>
8ceb32
+		#endif
8ceb32
+		#ifdef HAVE_UNISTD_H
8ceb32
+		#include <unistd.h>
8ceb32
+		#endif],[return(sys_nerr);],
8ceb32
+		ac_cv_decl_sys_nerr_def=yes, ac_cv_decl_sys_nerr_def=no)
8ceb32
+		])
8ceb32
+		if test "$ac_cv_decl_sys_nerr" = yes; then
8ceb32
+			AC_DEFINE(HAVE_DECL_SYS_NERR)
8ceb32
+		fi
8ceb32
+	fi
8ceb32
+
8ceb32
+
8ceb32
+	AC_CACHE_CHECK(for sys_errlist array,
8ceb32
+	ac_cv_sys_errlist,
8ceb32
+	[AC_TRY_LINK(,[extern char *sys_errlist[];
8ceb32
+		sys_errlist[0];],
8ceb32
+		ac_cv_sys_errlist=yes, ac_cv_sys_errlist=no)
8ceb32
+	])
8ceb32
+	if test "$ac_cv_sys_errlist" = yes; then
8ceb32
+		AC_DEFINE(HAVE_SYS_ERRLIST)
8ceb32
+		AC_CACHE_CHECK(for sys_errlist declaration,
8ceb32
+		ac_cv_sys_errlist_def,
8ceb32
+		[AC_TRY_COMPILE([
8ceb32
+		#include <stdio.h>
8ceb32
+		#include <errno.h>
8ceb32
+		#ifdef HAVE_STDLIB_H
8ceb32
+		#include <stdlib.h>
8ceb32
+		#endif
8ceb32
+		#ifdef HAVE_UNISTD_H
8ceb32
+		#include <unistd.h>
8ceb32
+		#endif],[char *s = sys_errlist[0]; return(*s);],
8ceb32
+		ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)
8ceb32
+		])
8ceb32
+		if test "$ac_cv_decl_sys_errlist" = yes; then
8ceb32
+			AC_DEFINE(HAVE_DECL_SYS_ERRLIST)
8ceb32
+		fi
8ceb32
+	fi
8ceb32
+
8ceb32
+
8ceb32
+
8ceb32
+	AC_CACHE_CHECK(checking for long long,
8ceb32
+	ac_cv_long_long,
8ceb32
+	[
8ceb32
+	AC_TRY_COMPILE([
8ceb32
+	#include <stdio.h>
8ceb32
+	#include <sys/types.h>
8ceb32
+	], [printf("%d",sizeof(long long));],
8ceb32
+	ac_cv_long_long=yes, ac_cv_long_long=no)
8ceb32
+	])
8ceb32
+	if test $ac_cv_long_long = yes; then
8ceb32
+	  AC_DEFINE(HAVE_LONG_LONG)
8ceb32
+	fi
8ceb32
+
8ceb32
+	AC_CACHE_CHECK(checking for long double,
8ceb32
+	ac_cv_long_double,
8ceb32
+	[
8ceb32
+	AC_TRY_COMPILE([
8ceb32
+	#include <stdio.h>
8ceb32
+	#include <sys/types.h>
8ceb32
+	], [printf("%d",sizeof(long double));],
8ceb32
+	ac_cv_long_double=yes, ac_cv_long_double=no)
8ceb32
+	])
8ceb32
+	if test $ac_cv_long_double = yes; then
8ceb32
+	  AC_DEFINE(HAVE_LONG_DOUBLE)
8ceb32
+	fi
8ceb32
+
8ceb32
+	AC_CACHE_CHECK(checking for quad_t,
8ceb32
+	ac_cv_quad_t,
8ceb32
+	[
8ceb32
+	AC_TRY_COMPILE([
8ceb32
+	#include <stdio.h>
8ceb32
+	#include <sys/types.h>
8ceb32
+	], [printf("%d",sizeof(quad_t));],
8ceb32
+	ac_cv_quad_t=yes, ac_cv_quad_t=no)
8ceb32
+	])
8ceb32
+	if test $ac_cv_quad_t = yes; then
8ceb32
+	  AC_DEFINE(HAVE_QUAD_T)
8ceb32
+	fi
8ceb32
+
8ceb32
+
8ceb32
+
8ceb32
+ NAME
8ceb32
+     snprintf, plp_vsnprintf - formatted output conversion
8ceb32
+
8ceb32
+ SYNOPSIS
8ceb32
+     #include <stdio.h>
8ceb32
+     #include <stdarg.h>
8ceb32
+
8ceb32
+     int
8ceb32
+     snprintf(const char *format, size_t size, va_list ap);
8ceb32
+     int
8ceb32
+     plp_unsafe_snprintf(const char *format, size_t size, va_list ap);
8ceb32
+
8ceb32
+     AKA snprintf and unsafe_snprintf in the documentation below
8ceb32
+
8ceb32
+     int
8ceb32
+     vsnprintf(char *str, size_t size, const char *format, va_list ap);
8ceb32
+     int
8ceb32
+     unsafe_vsnprintf(char *str, size_t size, const char *format, va_list ap);
8ceb32
+
8ceb32
+     AKA vsnprintf and unsafe_vsnprintf in the documentation below
8ceb32
+
8ceb32
+     (Multithreaded Safe)
8ceb32
+
8ceb32
+ DESCRIPTION
8ceb32
+     The printf() family of functions produces output according to
8ceb32
+     a format as described below.  Snprintf(), and vsnprintf()
8ceb32
+     write to the character string str. These functions write the
8ceb32
+     output under the control of a format string that specifies
8ceb32
+     how subsequent arguments (or arguments accessed via the
8ceb32
+     variable-length argument facilities of stdarg(3))  are converted
8ceb32
+     for output.  These functions return the number of characters
8ceb32
+     printed (not including the trailing `\0' used to end output
8ceb32
+     to strings).  Snprintf() and vsnprintf() will write at most
8ceb32
+     size-1 of the characters printed into the output string (the
8ceb32
+     size'th character then gets the terminating `\0'); if the
8ceb32
+     return value is greater than or equal to the size argument,
8ceb32
+     the string was too short and some of the printed characters
8ceb32
+     were discarded.  The size or str may be given as zero to find
8ceb32
+     out how many characters are needed; in this case, the str
8ceb32
+     argument is ignored.
8ceb32
+
8ceb32
+     By default, the snprintf function will not format control
8ceb32
+     characters (except new line and tab) in strings.  This is a
8ceb32
+     safety feature that has proven to be extremely critical when
8ceb32
+     using snprintf for secure applications and when debugging.
8ceb32
+     If you MUST have control characters formatted or printed,
8ceb32
+     then use the unsafe_snprintf() and unsafe_vsnprintf() and on
8ceb32
+     your own head be the consequences.  You have been warned.
8ceb32
+
8ceb32
+     There is one exception to the comments above, and that is
8ceb32
+     the "%c" (character) format.  It brutally assumes that the
8ceb32
+     user will have performed the necessary 'isprint()' or other
8ceb32
+     checks and uses the integer value as a character.
8ceb32
+
8ceb32
+     The format string is composed of zero or more directives:
8ceb32
+     ordinary characters (not %), which are copied unchanged to
8ceb32
+     the output stream; and conversion specifications, each
8ceb32
+     of which results in fetching zero or more subsequent arguments.
8ceb32
+     Each conversion specification is introduced by the character
8ceb32
+     %. The arguments must correspond properly (after type promotion)
8ceb32
+     with the conversion specifier.  After the %, the following
8ceb32
+     appear in sequence:
8ceb32
+
8ceb32
+     o   Zero or more of the following flags:
8ceb32
+
8ceb32
+	   -   A zero `0' character specifying zero padding.  For
8ceb32
+	     all conversions except n, the converted value is padded
8ceb32
+	     on the left with zeros rather than blanks.  If a
8ceb32
+	     precision is given with a numeric conversion (d, i,
8ceb32
+	     o, u, i, x, and X), the `0' flag is ignored.
8ceb32
+
8ceb32
+       -   A negative field width flag `-' indicates the converted
8ceb32
+	     value is to be left adjusted on the field boundary.  Except
8ceb32
+	     for n conversions, the converted value is padded on
8ceb32
+	     the right with blanks, rather than on the left with
8ceb32
+	     blanks or zeros.  A `-' overrides a `0' if both are
8ceb32
+	     given.
8ceb32
+
8ceb32
+	   -   A space, specifying that a blank should be left before
8ceb32
+	     a positive number produced by a signed conversion (d, e, E, f,
8ceb32
+	     g, G, or i).
8ceb32
+
8ceb32
+	   -   A `+' character specifying that a sign always be placed
8ceb32
+	     before a number produced by a signed conversion.  A `+' overrides
8ceb32
+	     a space if both are used.
8ceb32
+
8ceb32
+     o   An optional decimal digit string specifying a minimum
8ceb32
+		 field width.  If the converted value has fewer
8ceb32
+		 characters than the field width, it will be padded
8ceb32
+		 with spaces on the left (or right, if the
8ceb32
+		 left-adjustment flag has been given) to fill out
8ceb32
+		 the field width.
8ceb32
+
8ceb32
+     o   An optional precision, in the form of a period `.' followed
8ceb32
+		 by an optional digit string.  If the digit string
8ceb32
+		 is omitted, the precision is taken as zero.  This
8ceb32
+		 gives the minimum number of digits to appear for
8ceb32
+		 d, i, o, u, x, and X conversions, the number of
8ceb32
+		 digits to appear after the decimal-point for e,
8ceb32
+		 E, and f conversions, the maximum number of
8ceb32
+		 significant digits for g and G conversions, or
8ceb32
+		 the maximum number of characters to be printed
8ceb32
+		 from a string for s conversions.
8ceb32
+
8ceb32
+     o   The optional character h, specifying that a following d,
8ceb32
+		 i, o, u, x, or X conversion corresponds to a short
8ceb32
+		 int or unsigned short int argument, or that a
8ceb32
+		 following n conversion corresponds to a pointer
8ceb32
+		 to a short int argument.
8ceb32
+
8ceb32
+     o   The optional character l (ell) specifying that a following
8ceb32
+		 d, i, o, u, x, or X conversion applies to a pointer
8ceb32
+		 to a long int or unsigned long int argument, or
8ceb32
+		 that a following n conversion corresponds to a
8ceb32
+		 pointer to a long int argument.
8ceb32
+
8ceb32
+     o   The optional character q, specifying that a following d,
8ceb32
+		 i, o, u, x, or X conversion corresponds to a quad_t
8ceb32
+		 or u_quad_t argument, or that a following n
8ceb32
+		 conversion corresponds to a quad_t argument.
8ceb32
+         This value is always printed in HEX notation.  Tough.
8ceb32
+         quad_t's are an OS system implementation, and should
8ceb32
+         not be allowed.
8ceb32
+
8ceb32
+     o   The character L specifying that a following e, E, f, g,
8ceb32
+		 or G conversion corresponds to a long double
8ceb32
+		 argument.
8ceb32
+
8ceb32
+     o   A character that specifies the type of conversion to be applied.
8ceb32
+
8ceb32
+
8ceb32
+     A field width or precision, or both, may be indicated by an asterisk `*'
8ceb32
+     instead of a digit string.  In this case, an int argument supplies the
8ceb32
+     field width or precision.  A negative field width is treated as a left
8ceb32
+     adjustment flag followed by a positive field width; a negative precision
8ceb32
+     is treated as though it were missing.
8ceb32
+
8ceb32
+     The conversion specifiers and their meanings are:
8ceb32
+
8ceb32
+     diouxX  The int (or appropriate variant) argument is converted to signed
8ceb32
+			 decimal (d and i), unsigned octal (o), unsigned decimal
8ceb32
+			 (u), or unsigned hexadecimal (x and X) notation.  The
8ceb32
+			 letters abcdef are used for x conversions; the letters
8ceb32
+			 ABCDEF are used for X conversions.  The precision, if
8ceb32
+			 any, gives the minimum number of digits that must
8ceb32
+			 appear; if the converted value requires fewer digits,
8ceb32
+			 it is padded on the left with zeros.
8ceb32
+
8ceb32
+     eE      The double argument is rounded and converted in the style
8ceb32
+             [-]d.ddde+-dd where there is one digit before the decimal-point
8ceb32
+			 character and the number of digits after it is equal
8ceb32
+			 to the precision; if the precision is missing, it is
8ceb32
+			 taken as 6; if the precision is zero, no decimal-point
8ceb32
+			 character appears.  An E conversion uses the letter
8ceb32
+			 E (rather than e) to introduce the exponent.
8ceb32
+			 The exponent always contains at least two digits; if
8ceb32
+			 the value is zero, the exponent is 00.
8ceb32
+
8ceb32
+     f       The double argument is rounded and converted to decimal notation
8ceb32
+             in the style [-]ddd.ddd, where the number of digits after the
8ceb32
+             decimal-point character is equal to the precision specification.
8ceb32
+             If the precision is missing, it is taken as 6; if the precision
8ceb32
+             is explicitly zero, no decimal-point character appears.  If a
8ceb32
+             decimal point appears, at least one digit appears before it.
8ceb32
+
8ceb32
+     g       The double argument is converted in style f or e (or
8ceb32
+			 E for G conversions).  The precision specifies the
8ceb32
+			 number of significant digits.  If the precision is
8ceb32
+			 missing, 6 digits are given; if the precision is zero,
8ceb32
+			 it is treated as 1.  Style e is used if the exponent
8ceb32
+			 from its conversion is less than -4 or greater than
8ceb32
+			 or equal to the precision.  Trailing zeros are removed
8ceb32
+			 from the fractional part of the result; a decimal
8ceb32
+			 point appears only if it is followed by at least one
8ceb32
+			 digit.
8ceb32
+
8ceb32
+     c       The int argument is converted to an unsigned char,
8ceb32
+             and the resulting character is written.
8ceb32
+
8ceb32
+     s       The ``char *'' argument is expected to be a pointer to an array
8ceb32
+			 of character type (pointer to a string).  Characters
8ceb32
+			 from the array are written up to (but not including)
8ceb32
+			 a terminating NUL character; if a precision is
8ceb32
+			 specified, no more than the number specified are
8ceb32
+			 written.  If a precision is given, no null character
8ceb32
+			 need be present; if the precision is not specified,
8ceb32
+			 or is greater than the size of the array, the array
8ceb32
+			 must contain a terminating NUL character.
8ceb32
+
8ceb32
+     %       A `%' is written. No argument is converted. The complete
8ceb32
+             conversion specification is `%%'.
8ceb32
+
8ceb32
+     In no case does a non-existent or small field width cause truncation of a
8ceb32
+     field; if the result of a conversion is wider than the field width, the
8ceb32
+     field is expanded to contain the conversion result.
8ceb32
+
8ceb32
+ EXAMPLES
8ceb32
+     To print a date and time in the form `Sunday, July 3, 10:02', where
8ceb32
+     weekday and month are pointers to strings:
8ceb32
+
8ceb32
+           #include <stdio.h>
8ceb32
+           fprintf(stdout, "%s, %s %d, %.2d:%.2d\n",
8ceb32
+                   weekday, month, day, hour, min);
8ceb32
+
8ceb32
+     To print pi to five decimal places:
8ceb32
+
8ceb32
+           #include <math.h>
8ceb32
+           #include <stdio.h>
8ceb32
+           fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0));
8ceb32
+
8ceb32
+     To allocate a 128 byte string and print into it:
8ceb32
+
8ceb32
+           #include <stdio.h>
8ceb32
+           #include <stdlib.h>
8ceb32
+           #include <stdarg.h>
8ceb32
+           char *newfmt(const char *fmt, ...)
8ceb32
+           {
8ceb32
+               char *p;
8ceb32
+               va_list ap;
8ceb32
+               if ((p = malloc(128)) == NULL)
8ceb32
+                       return (NULL);
8ceb32
+               va_start(ap, fmt);
8ceb32
+               (void) vsnprintf(p, 128, fmt, ap);
8ceb32
+               va_end(ap);
8ceb32
+               return (p);
8ceb32
+           }
8ceb32
+
8ceb32
+ SEE ALSO
8ceb32
+     printf(1),  scanf(3)
8ceb32
+
8ceb32
+ STANDARDS
8ceb32
+     Turkey C Standardization and wimpy POSIX folks did not define
8ceb32
+     snprintf or vsnprintf().
8ceb32
+
8ceb32
+ BUGS
8ceb32
+     The conversion formats %D, %O, and %U are not standard and are provided
8ceb32
+     only for backward compatibility.  The effect of padding the %p format
8ceb32
+     with zeros (either by the `0' flag or by specifying a precision), and the
8ceb32
+     benign effect (i.e., none) of the `#' flag on %n and %p conversions, as
8ceb32
+     well as other nonsensical combinations such as %Ld, are not standard;
8ceb32
+     such combinations should be avoided.
8ceb32
 
8ceb32
-    b) accompany the distribution with the machine-readable source of
8ceb32
-    the Package with your modifications.
8ceb32
+     The typedef names quad_t and u_quad_t are infelicitous.
8ceb32
 
8ceb32
-    c) give non-standard executables non-standard names, and clearly
8ceb32
-    document the differences in manual pages (or equivalent), together
8ceb32
-    with instructions on where to get the Standard Version.
8ceb32
+*/
8ceb32
 
8ceb32
-    d) make other distribution arrangements with the Copyright Holder.
8ceb32
 
8ceb32
-5. You may charge a reasonable copying fee for any distribution of this
8ceb32
-Package.  You may charge any fee you choose for support of this
8ceb32
-Package.  You may not charge a fee for this Package itself.  However,
8ceb32
-you may distribute this Package in aggregate with other (possibly
8ceb32
-commercial) programs as part of a larger (possibly commercial) software
8ceb32
-distribution provided that you do not advertise this Package as a
8ceb32
-product of your own. 
8ceb32
+#include <sys/types.h>
8ceb32
+#include <ctype.h>
8ceb32
+#include <stdlib.h>
8ceb32
+#include <stdio.h>
8ceb32
+#if defined(HAVE_STRING_H)
8ceb32
+# include <string.h>
8ceb32
+#endif
8ceb32
+#if defined(HAVE_STRINGS_H)
8ceb32
+# include <strings.h>
8ceb32
+#endif
8ceb32
+#if defined(HAVE_ERRNO_H)
8ceb32
+#include <errno.h>
8ceb32
+#endif
8ceb32
 
8ceb32
-6. The name of the Copyright Holder may not be used to endorse or promote
8ceb32
-products derived from this software without specific prior written permission.
8ceb32
+/*
8ceb32
+ * For testing, define these values
8ceb32
+ */
8ceb32
+#if 0
8ceb32
+#define HAVE_STDARG_H 1
8ceb32
+#define TEST 1
8ceb32
+#define HAVE_QUAD_T 1
8ceb32
+#endif
8ceb32
 
8ceb32
-7. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
8ceb32
-IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
8ceb32
-WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
8ceb32
+/**** ENDINCLUDE ****/
8ceb32
 
8ceb32
-				The End
8ceb32
-#include "lp.h"
8ceb32
+/*************************************************
8ceb32
+ * KEEP THIS STRING - MODIFY AT THE END WITH YOUR REVISIONS
8ceb32
+ * i.e. - the LOCAL REVISIONS part is for your use
8ceb32
+ *************************************************/
8ceb32
+ 
8ceb32
+ 
8ceb32
+ static char *const _id = "plp_snprintf V2000.08.18 Copyright Patrick Powell 1988-2000 "
8ceb32
+ "$Id: plp_snprintf.c,v 1.4 2005/04/14 20:05:19 papowell Exp $"
8ceb32
+ " LOCAL REVISIONS: renamed plp_snprintf to snprintf, conditionalized everything on HAVE_SNPRINTF";
8ceb32
+
8ceb32
+/* varargs declarations: */
8ceb32
+
8ceb32
+# undef HAVE_STDARGS    /* let's hope that works everywhere (mj) */
8ceb32
+# undef VA_LOCAL_DECL
8ceb32
+# undef VA_START
8ceb32
+# undef VA_SHIFT
8ceb32
+# undef VA_END
8ceb32
+
8ceb32
+#if defined(HAVE_STDARG_H)
8ceb32
+# include <stdarg.h>
8ceb32
+# define HAVE_STDARGS    /* let's hope that works everywhere (mj) */
8ceb32
+# define VA_LOCAL_DECL   va_list ap;
8ceb32
+# define VA_START(f)     va_start(ap, f)
8ceb32
+# define VA_SHIFT(v,t)	;	/* no-op for ANSI */
8ceb32
+# define VA_END          va_end(ap)
8ceb32
+#else
8ceb32
+# if defined(HAVE_VARARGS_H)
8ceb32
+#  include <varargs.h>
8ceb32
+#  undef HAVE_STDARGS
8ceb32
+#  define VA_LOCAL_DECL   va_list ap;
8ceb32
+#  define VA_START(f)     va_start(ap)		/* f is ignored! */
8ceb32
+#  define VA_SHIFT(v,t)	v = va_arg(ap,t)
8ceb32
+#  define VA_END		va_end(ap)
8ceb32
+# else
8ceb32
+ XX ** NO VARARGS ** XX
8ceb32
+# endif
8ceb32
 #endif
8ceb32
 
8ceb32
-#include <stdarg.h>
8ceb32
-#include <errno.h>
8ceb32
-#include <sys/types.h>
8ceb32
-#define HAVE_STDARGS /* let's hope that works everywhere (mj) */
8ceb32
-#define VA_LOCAL_DECL va_list ap;
8ceb32
-#define VA_START(f) va_start(ap, f)
8ceb32
-#define VA_SHIFT(v,t) ; /* no-op for ANSI */
8ceb32
-#define VA_END va_end(ap)
8ceb32
-
8ceb32
-/**** ENDINCLUDE ****/
8ceb32
+ union value {
8ceb32
+#if defined(HAVE_QUAD_T)
8ceb32
+	quad_t qvalue;
8ceb32
+#endif
8ceb32
+#if defined(HAVE_LONG_LONG)
8ceb32
+	long long value;
8ceb32
+#else
8ceb32
+	long value;
8ceb32
+#endif
8ceb32
+	double dvalue;
8ceb32
+};
8ceb32
 
8ceb32
-static char *const _id = "$Id: snprintf.c,v 3.2 1997/01/19 14:34:56 papowell Exp $";
8ceb32
+#undef CVAL 
8ceb32
+#define CVAL(s) (*((unsigned char *)s))
8ceb32
+#define safestrlen(s) ((s)?strlen(s):0)
8ceb32
 
8ceb32
-/*
8ceb32
- * dopr(): poor man's version of doprintf
8ceb32
- */
8ceb32
 
8ceb32
-static char * plp_Errormsg ( int err );
8ceb32
-static void dopr( char *buffer, const char *format, va_list args );
8ceb32
-static void fmtstr(  char *value, int ljust, int len, int zpad, int precision );
8ceb32
-static void fmtnum(  long value, int base, int dosign,
8ceb32
+ static char * plp_Errormsg ( int err, char *buffer );
8ceb32
+ static void dopr( int visible_control, char **buffer, int *left,
8ceb32
+	const char *format, va_list args );
8ceb32
+ static void fmtstr( int visible_control, char **buffer, int *left,
8ceb32
+	char *value, int ljust, int len, int zpad, int precision );
8ceb32
+ static void fmtnum(  char **buffer, int *left,
8ceb32
+	union value *value, int base, int dosign,
8ceb32
+	int ljust, int len, int zpad, int precision );
8ceb32
+#if defined(HAVE_QUAD_T)
8ceb32
+ static void fmtquad(  char **buffer, int *left,
8ceb32
+	union value *value, int base, int dosign,
8ceb32
 	int ljust, int len, int zpad, int precision );
8ceb32
-static void fmtdouble( int fmt, double value,
8ceb32
+#endif
8ceb32
+ static void fmtdouble( char **bufer, int *left,
8ceb32
+	int fmt, double value,
8ceb32
 	int ljust, int len, int zpad, int precision );
8ceb32
-static void dostr( char * );
8ceb32
-static char *output;
8ceb32
-static void dopr_outch( int c );
8ceb32
-static char *end;
8ceb32
-int visible_control = 1;
8ceb32
-
8ceb32
-/**************************************************************
8ceb32
- * Original:
8ceb32
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
8ceb32
- * A bombproof version of doprnt (dopr) included.
8ceb32
- * Sigh.  This sort of thing is always nasty do deal with.  Note that
8ceb32
- * the version here does not include floating point...
8ceb32
- *
8ceb32
- * plp_snprintf() is used instead of sprintf() as it does limit checks
8ceb32
- * for string length.  This covers a nasty loophole.
8ceb32
- *
8ceb32
- * The other functions are there to prevent NULL pointers from
8ceb32
- * causing nast effects.
8ceb32
- **************************************************************/
8ceb32
-
8ceb32
-int vsnprintf(char *str, size_t count, const char *fmt, va_list args)
8ceb32
-{
8ceb32
-	str[0] = 0;
8ceb32
-	end = str+count-1;
8ceb32
-	dopr( str, fmt, args );
8ceb32
-	if( count>0 ){
8ceb32
-		end[0] = 0;
8ceb32
+ static void dostr(  char **buffer, int *left, char *str );
8ceb32
+ static void dopr_outch(  char **buffer, int *left, int c );
8ceb32
+/* VARARGS3 */
8ceb32
+#ifdef HAVE_STDARGS
8ceb32
+ int plp_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
8ceb32
+#else
8ceb32
+ int plp_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
8ceb32
+#endif
8ceb32
+
8ceb32
+{
8ceb32
+	int left;
8ceb32
+	char *buffer;
8ceb32
+	if( (int)count < 0 ) count = 0;
8ceb32
+	left = count;
8ceb32
+	if( count == 0 ) str = 0;
8ceb32
+	buffer = str;
8ceb32
+	dopr( 1, &buffer, &left, fmt, args );
8ceb32
+	/* fprintf(stderr,"str 0x%x, buffer 0x%x, count %d, left %d\n",
8ceb32
+		(int)str, (int)buffer, count, left ); */
8ceb32
+	if( str && count > 0 ){
8ceb32
+		if( left > 0 ){
8ceb32
+			str[count-left] = 0;
8ceb32
+		} else {
8ceb32
+			str[count-1] = 0;
8ceb32
+		}
8ceb32
+	}
8ceb32
+	return(count - left);
8ceb32
+}
8ceb32
+
8ceb32
+/* VARARGS3 */
8ceb32
+#ifdef HAVE_STDARGS
8ceb32
+ int plp_unsafe_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
8ceb32
+#else
8ceb32
+ int plp_unsafe_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
8ceb32
+#endif
8ceb32
+{
8ceb32
+	int left;
8ceb32
+	char *buffer;
8ceb32
+	if( (int)count < 0 ) count = 0;
8ceb32
+	left = count;
8ceb32
+	if( count == 0 ) str = 0;
8ceb32
+	buffer = str;
8ceb32
+	dopr( 0, &buffer, &left, fmt, args );
8ceb32
+	/* fprintf(stderr,"str 0x%x, buffer 0x%x, count %d, left %d\n",
8ceb32
+		(int)str, (int)buffer, count, left ); */
8ceb32
+	if( str && count > 0 ){
8ceb32
+		if( left > 0 ){
8ceb32
+			str[count-left] = 0;
8ceb32
+		} else {
8ceb32
+			str[count-1] = 0;
8ceb32
+		}
8ceb32
 	}
8ceb32
-	return(strlen(str));
8ceb32
+	return(count - left);
8ceb32
 }
8ceb32
 
8ceb32
 /* VARARGS3 */
8ceb32
 #ifdef HAVE_STDARGS
8ceb32
-int snprintf (char *str,size_t count,const char *fmt,...)
8ceb32
+ int snprintf (char *str,size_t count,const char *fmt,...)
8ceb32
 #else
8ceb32
-int snprintf (va_alist) va_dcl
8ceb32
+ int snprintf (va_alist) va_dcl
8ceb32
 #endif
8ceb32
 {
8ceb32
 #ifndef HAVE_STDARGS
8ceb32
@@ -183,22 +619,48 @@ int snprintf (va_alist) va_dcl
8ceb32
 	size_t count;
8ceb32
     char *fmt;
8ceb32
 #endif
8ceb32
+	int n = 0;
8ceb32
     VA_LOCAL_DECL
8ceb32
 
8ceb32
     VA_START (fmt);
8ceb32
     VA_SHIFT (str, char *);
8ceb32
     VA_SHIFT (count, size_t );
8ceb32
     VA_SHIFT (fmt, char *);
8ceb32
-    (void) vsnprintf ( str, count, fmt, ap);
8ceb32
+    n = plp_vsnprintf ( str, count, fmt, ap);
8ceb32
     VA_END;
8ceb32
-	return( strlen( str ) );
8ceb32
+	return( n );
8ceb32
 }
8ceb32
 
8ceb32
-static void dopr( char *buffer, const char *format, va_list args )
8ceb32
+
8ceb32
+/* VARARGS3 */
8ceb32
+#ifdef HAVE_STDARGS
8ceb32
+ int plp_unsafe_snprintf (char *str,size_t count,const char *fmt,...)
8ceb32
+#else
8ceb32
+ int plp_unsafe_snprintf (va_alist) va_dcl
8ceb32
+#endif
8ceb32
+{
8ceb32
+#ifndef HAVE_STDARGS
8ceb32
+    char *str;
8ceb32
+	size_t count;
8ceb32
+    char *fmt;
8ceb32
+#endif
8ceb32
+	int n = 0;
8ceb32
+    VA_LOCAL_DECL
8ceb32
+
8ceb32
+    VA_START (fmt);
8ceb32
+    VA_SHIFT (str, char *);
8ceb32
+    VA_SHIFT (count, size_t );
8ceb32
+    VA_SHIFT (fmt, char *);
8ceb32
+    n = plp_unsafe_vsnprintf ( str, count, fmt, ap);
8ceb32
+    VA_END;
8ceb32
+	return( n );
8ceb32
+}
8ceb32
+ static void dopr( int visible_control, char **buffer, int *left, const char *format, va_list args )
8ceb32
 {
8ceb32
 	int ch;
8ceb32
-	long value;
8ceb32
+	union value value;
8ceb32
 	int longflag = 0;
8ceb32
+	int quadflag = 0;
8ceb32
 	char *strvalue;
8ceb32
 	int ljust;
8ceb32
 	int len;
8ceb32
@@ -207,22 +669,30 @@ static void dopr( char *buffer, const ch
8ceb32
 	int set_precision;
8ceb32
 	double dval;
8ceb32
 	int err = errno;
8ceb32
+	int base = 0;
8ceb32
+	int signed_val = 0;
8ceb32
 
8ceb32
-	output = buffer;
8ceb32
 	while( (ch = *format++) ){
8ceb32
 		switch( ch ){
8ceb32
 		case '%':
8ceb32
-			ljust = len = zpad = 0;
8ceb32
+			longflag = quadflag =
8ceb32
+			ljust = len = zpad = base = signed_val = 0;
8ceb32
 			precision = -1; set_precision = 0;
8ceb32
 		nextch: 
8ceb32
 			ch = *format++;
8ceb32
 			switch( ch ){
8ceb32
 			case 0:
8ceb32
-				dostr( "**end of format**" );
8ceb32
+				dostr( buffer, left, "**end of format**" );
8ceb32
 				return;
8ceb32
 			case '-': ljust = 1; goto nextch;
8ceb32
 			case '.': set_precision = 1; precision = 0; goto nextch;
8ceb32
-			case '*': len = va_arg( args, int ); goto nextch;
8ceb32
+			case '*':
8ceb32
+				if( set_precision ){
8ceb32
+					precision = va_arg( args, int );
8ceb32
+				} else {
8ceb32
+					len = va_arg( args, int );
8ceb32
+				}
8ceb32
+				goto nextch;
8ceb32
 			case '0': /* set zero padding if len not set */
8ceb32
 				if(len==0 && set_precision == 0 ) zpad = '0';
8ceb32
 			case '1': case '2': case '3':
8ceb32
@@ -234,76 +704,91 @@ static void dopr( char *buffer, const ch
8ceb32
 					len = len*10 + ch - '0';
8ceb32
 				}
8ceb32
 				goto nextch;
8ceb32
-			case 'l': longflag = 1; goto nextch;
8ceb32
+			case 'l': ++longflag; goto nextch;
8ceb32
+			case 'q':
8ceb32
+#if !defined( HAVE_QUAD_T )
8ceb32
+					dostr( buffer, left, "*no quad_t support *");
8ceb32
+					return;
8ceb32
+#endif
8ceb32
+					quadflag = 1;
8ceb32
+					goto nextch;
8ceb32
 			case 'u': case 'U':
8ceb32
-				/*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
8ceb32
-				if( longflag ){
8ceb32
-					value = va_arg( args, long );
8ceb32
-				} else {
8ceb32
-					value = va_arg( args, int );
8ceb32
-				}
8ceb32
-				fmtnum( value, 10,0, ljust, len, zpad, precision ); break;
8ceb32
+				if( base == 0 ){ base = 10; signed_val = 0; }
8ceb32
 			case 'o': case 'O':
8ceb32
-				/*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
8ceb32
-				if( longflag ){
8ceb32
-					value = va_arg( args, long );
8ceb32
-				} else {
8ceb32
-					value = va_arg( args, int );
8ceb32
-				}
8ceb32
-				fmtnum( value, 8,0, ljust, len, zpad, precision ); break;
8ceb32
+				if( base == 0 ){ base = 8; signed_val = 0; }
8ceb32
 			case 'd': case 'D':
8ceb32
-				if( longflag ){
8ceb32
-					value = va_arg( args, long );
8ceb32
-				} else {
8ceb32
-					value = va_arg( args, int );
8ceb32
-				}
8ceb32
-				fmtnum( value, 10,1, ljust, len, zpad, precision ); break;
8ceb32
+				if( base == 0 ){ base = 10; signed_val = 1; }
8ceb32
 			case 'x':
8ceb32
-				if( longflag ){
8ceb32
-					value = va_arg( args, long );
8ceb32
-				} else {
8ceb32
-					value = va_arg( args, int );
8ceb32
-				}
8ceb32
-				fmtnum( value, 16,0, ljust, len, zpad, precision ); break;
8ceb32
+				if( base == 0 ){ base = 16; signed_val = 0; }
8ceb32
 			case 'X':
8ceb32
-				if( longflag ){
8ceb32
-					value = va_arg( args, long );
8ceb32
+				if( base == 0 ){ base = -16; signed_val = 0; }
8ceb32
+#if defined( HAVE_QUAD_T )
8ceb32
+				if( quadflag ){
8ceb32
+					value.qvalue = va_arg( args, quad_t );
8ceb32
+					fmtquad( buffer, left,  &value,base,signed_val, ljust, len, zpad, precision );
8ceb32
+					break;
8ceb32
+				} else
8ceb32
+#endif
8ceb32
+				if( longflag > 1 ){
8ceb32
+#if defined(HAVE_LONG_LONG)
8ceb32
+					if( signed_val ){
8ceb32
+					value.value = va_arg( args, long long );
8ceb32
+					} else {
8ceb32
+					value.value = va_arg( args, unsigned long long );
8ceb32
+					}
8ceb32
+#else
8ceb32
+					if( signed_val ){
8ceb32
+					value.value = va_arg( args, long );
8ceb32
+					} else {
8ceb32
+					value.value = va_arg( args, unsigned long );
8ceb32
+					}
8ceb32
+#endif
8ceb32
+				} else if( longflag ){
8ceb32
+					if( signed_val ){
8ceb32
+						value.value = va_arg( args, long );
8ceb32
+					} else {
8ceb32
+						value.value = va_arg( args, unsigned long );
8ceb32
+					}
8ceb32
 				} else {
8ceb32
-					value = va_arg( args, int );
8ceb32
+					if( signed_val ){
8ceb32
+						value.value = va_arg( args, int );
8ceb32
+					} else {
8ceb32
+						value.value = va_arg( args, unsigned int );
8ceb32
+					}
8ceb32
 				}
8ceb32
-				fmtnum( value,-16,0, ljust, len, zpad, precision ); break;
8ceb32
+				fmtnum( buffer, left,  &value,base,signed_val, ljust, len, zpad, precision ); break;
8ceb32
 			case 's':
8ceb32
 				strvalue = va_arg( args, char *);
8ceb32
-				fmtstr( strvalue,ljust,len, zpad, precision );
8ceb32
+				fmtstr( visible_control, buffer, left, strvalue,ljust,len, zpad, precision );
8ceb32
 				break;
8ceb32
 			case 'c':
8ceb32
 				ch = va_arg( args, int );
8ceb32
 				{ char b[2];
8ceb32
-					int vsb = visible_control;
8ceb32
 					b[0] = ch;
8ceb32
 					b[1] = 0;
8ceb32
-					visible_control = 0;
8ceb32
-					fmtstr( b,ljust,len, zpad, precision );
8ceb32
-					visible_control = vsb;
8ceb32
+					fmtstr( 0, buffer, left, b,ljust,len, zpad, precision );
8ceb32
 				}
8ceb32
 				break;
8ceb32
-			case 'f': case 'g':
8ceb32
+			case 'f': case 'g': case 'e':
8ceb32
 				dval = va_arg( args, double );
8ceb32
-				fmtdouble( ch, dval,ljust,len, zpad, precision ); break;
8ceb32
+				fmtdouble( buffer, left, ch, dval,ljust,len, zpad, precision ); break;
8ceb32
 			case 'm':
8ceb32
-				fmtstr( plp_Errormsg(err),ljust,len, zpad, precision ); break;
8ceb32
-			case '%': dopr_outch( ch ); continue;
8ceb32
+				{ char shortbuffer[32];
8ceb32
+				fmtstr( visible_control, buffer, left,
8ceb32
+					plp_Errormsg(err, shortbuffer),ljust,len, zpad, precision );
8ceb32
+				}
8ceb32
+				break;
8ceb32
+			case '%': dopr_outch( buffer, left, ch ); continue;
8ceb32
 			default:
8ceb32
-				dostr(  "???????" );
8ceb32
+				dostr(  buffer, left, "???????" );
8ceb32
 			}
8ceb32
 			longflag = 0;
8ceb32
 			break;
8ceb32
 		default:
8ceb32
-			dopr_outch( ch );
8ceb32
+			dopr_outch( buffer, left, ch );
8ceb32
 			break;
8ceb32
 		}
8ceb32
 	}
8ceb32
-	*output = 0;
8ceb32
 }
8ceb32
 
8ceb32
 /*
8ceb32
@@ -312,63 +797,69 @@ static void dopr( char *buffer, const ch
8ceb32
  * len = minimum length
8ceb32
  * precision = numbers of chars in string to use
8ceb32
  */
8ceb32
-static void
8ceb32
-fmtstr(  char *value, int ljust, int len, int zpad, int precision )
8ceb32
+ static void
8ceb32
+ fmtstr( int visible_control, char **buffer, int *left,
8ceb32
+	 char *value, int ljust, int len, int zpad, int precision )
8ceb32
 {
8ceb32
-	int padlen, strlen, i, c;	/* amount to pad */
8ceb32
+	int padlen, strlenv, i, c;	/* amount to pad */
8ceb32
 
8ceb32
 	if( value == 0 ){
8ceb32
 		value = "<NULL>";
8ceb32
 	}
8ceb32
-	if( precision > 0 ){
8ceb32
-		strlen = precision;
8ceb32
-	} else {
8ceb32
-		/* cheap strlen so you do not have library call */
8ceb32
-		for( strlen = 0; (c=value[strlen]); ++ strlen ){
8ceb32
-			if( visible_control && iscntrl( c ) && !isspace( c ) ){
8ceb32
-				++strlen;
8ceb32
-			}
8ceb32
+	/* cheap strlen so you do not have library call */
8ceb32
+	for( strlenv = i = 0; (c=CVAL(value+i)); ++i ){
8ceb32
+		if( visible_control && iscntrl( c ) && c != '\t' && c != '\n' ){
8ceb32
+			++strlenv;
8ceb32
 		}
8ceb32
+		++strlenv;
8ceb32
 	}
8ceb32
-	padlen = len - strlen;
8ceb32
+	if( precision > 0 && strlenv > precision ){
8ceb32
+		strlenv = precision;
8ceb32
+	}
8ceb32
+	padlen = len - strlenv;
8ceb32
 	if( padlen < 0 ) padlen = 0;
8ceb32
 	if( ljust ) padlen = -padlen;
8ceb32
 	while( padlen > 0 ) {
8ceb32
-		dopr_outch( ' ' );
8ceb32
+		dopr_outch( buffer, left, ' ' );
8ceb32
 		--padlen;
8ceb32
 	}
8ceb32
 	/* output characters */
8ceb32
-	for( i = 0; (c = value[i]); ++i ){
8ceb32
-		if( visible_control && iscntrl( c ) && !isspace( c ) ){
8ceb32
-			dopr_outch('^');
8ceb32
+	for( i = 0; i < strlenv && (c = CVAL(value+i)); ++i ){
8ceb32
+		if( visible_control && iscntrl( c ) && c != '\t' && c != '\n' ){
8ceb32
+			dopr_outch(buffer, left, '^');
8ceb32
 			c = ('@' | (c & 0x1F));
8ceb32
 		}
8ceb32
-		dopr_outch(c);
8ceb32
+		dopr_outch(buffer, left, c);
8ceb32
 	}
8ceb32
 	while( padlen < 0 ) {
8ceb32
-		dopr_outch( ' ' );
8ceb32
+		dopr_outch( buffer, left, ' ' );
8ceb32
 		++padlen;
8ceb32
 	}
8ceb32
 }
8ceb32
 
8ceb32
-static void
8ceb32
-fmtnum(  long value, int base, int dosign, int ljust,
8ceb32
+ static void
8ceb32
+ fmtnum( char **buffer, int *left,
8ceb32
+	union value *value, int base, int dosign, int ljust,
8ceb32
 	int len, int zpad, int precision )
8ceb32
 {
8ceb32
 	int signvalue = 0;
8ceb32
+#if defined(HAVE_LONG_LONG)
8ceb32
+	unsigned long long uvalue;
8ceb32
+#else
8ceb32
 	unsigned long uvalue;
8ceb32
-	char convert[20];
8ceb32
+#endif
8ceb32
+	char convert[sizeof( union value) * 8 + 16];
8ceb32
 	int place = 0;
8ceb32
 	int padlen = 0;	/* amount to pad */
8ceb32
 	int caps = 0;
8ceb32
 
8ceb32
-	/* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
8ceb32
-		value, base, dosign, ljust, len, zpad )); */
8ceb32
-	uvalue = value;
8ceb32
+	/* fprintf(stderr,"value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
8ceb32
+		value, base, dosign, ljust, len, zpad );/ **/
8ceb32
+	uvalue = value->value;
8ceb32
 	if( dosign ){
8ceb32
-		if( value < 0 ) {
8ceb32
+		if( value->value < 0 ) {
8ceb32
 			signvalue = '-';
8ceb32
-			uvalue = -value; 
8ceb32
+			uvalue = -value->value; 
8ceb32
 		}
8ceb32
 	}
8ceb32
 	if( base < 0 ){
8ceb32
@@ -385,71 +876,148 @@ fmtnum(  long value, int base, int dosig
8ceb32
 	padlen = len - place;
8ceb32
 	if( padlen < 0 ) padlen = 0;
8ceb32
 	if( ljust ) padlen = -padlen;
8ceb32
-	/* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n",
8ceb32
-		convert,place,signvalue,padlen)); */
8ceb32
+	/* fprintf( stderr, "str '%s', place %d, sign %c, padlen %d\n",
8ceb32
+		convert,place,signvalue,padlen); / **/
8ceb32
 	if( zpad && padlen > 0 ){
8ceb32
 		if( signvalue ){
8ceb32
-			dopr_outch( signvalue );
8ceb32
+			dopr_outch( buffer, left, signvalue );
8ceb32
 			--padlen;
8ceb32
 			signvalue = 0;
8ceb32
 		}
8ceb32
 		while( padlen > 0 ){
8ceb32
-			dopr_outch( zpad );
8ceb32
+			dopr_outch( buffer, left, zpad );
8ceb32
 			--padlen;
8ceb32
 		}
8ceb32
 	}
8ceb32
 	while( padlen > 0 ) {
8ceb32
-		dopr_outch( ' ' );
8ceb32
+		dopr_outch( buffer, left, ' ' );
8ceb32
 		--padlen;
8ceb32
 	}
8ceb32
-	if( signvalue ) dopr_outch( signvalue );
8ceb32
-	while( place > 0 ) dopr_outch( convert[--place] );
8ceb32
+	if( signvalue ) dopr_outch( buffer, left, signvalue );
8ceb32
+	while( place > 0 ) dopr_outch( buffer, left, convert[--place] );
8ceb32
 	while( padlen < 0 ){
8ceb32
-		dopr_outch( ' ' );
8ceb32
+		dopr_outch( buffer, left, ' ' );
8ceb32
 		++padlen;
8ceb32
 	}
8ceb32
 }
8ceb32
 
8ceb32
-static void
8ceb32
-fmtdouble( int fmt, double value, int ljust, int len, int zpad, int precision )
8ceb32
+#if defined(HAVE_QUAD_T)
8ceb32
+
8ceb32
+ static void
8ceb32
+ fmtquad( char **buffer, int *left,
8ceb32
+	union value *value, int base, int dosign, int ljust,
8ceb32
+	int len, int zpad, int precision )
8ceb32
 {
8ceb32
-	char convert[128];
8ceb32
-	char fmtstr[128];
8ceb32
-	int l;
8ceb32
+	int signvalue = 0;
8ceb32
+	int place = 0;
8ceb32
+	int padlen = 0;	/* amount to pad */
8ceb32
+	int caps = 0;
8ceb32
+	int i, c;
8ceb32
+	union {
8ceb32
+		quad_t qvalue;
8ceb32
+		unsigned char qconvert[sizeof(quad_t)];
8ceb32
+	} vvalue;
8ceb32
+	char convert[2*sizeof(quad_t)+1];
8ceb32
+
8ceb32
+	/* fprintf(stderr,"value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
8ceb32
+		value, base, dosign, ljust, len, zpad );/ **/
8ceb32
+	vvalue.qvalue = value->qvalue;
8ceb32
 
8ceb32
-	if( len == 0 ) len = 10;
8ceb32
-	if( len > sizeof(convert) - 10 ){
8ceb32
-		len = sizeof(convert) - 10;
8ceb32
+	if( base < 0 ){
8ceb32
+		caps = 1;
8ceb32
 	}
8ceb32
-	if( precision > sizeof(convert) - 10 ){
8ceb32
-		precision = sizeof(convert) - 10;
8ceb32
+
8ceb32
+	for( i = 0; i < (int)sizeof(quad_t); ++i ){
8ceb32
+		c = vvalue.qconvert[i];
8ceb32
+		convert[2*i] = 
8ceb32
+			(caps? "0123456789ABCDEF":"0123456789abcdef")[ (c >> 4) & 0xF];
8ceb32
+		convert[2*i+1] = 
8ceb32
+			(caps? "0123456789ABCDEF":"0123456789abcdef")[ c  & 0xF];
8ceb32
 	}
8ceb32
-	if( precision > len ) precision = len;
8ceb32
-	strcpy( fmtstr, "%" );
8ceb32
-	if( ljust ) strcat(fmtstr, "-" );
8ceb32
-	if( len ){
8ceb32
-		sprintf( fmtstr+strlen(fmtstr), "%d", len );
8ceb32
+	convert[2*i] = 0;
8ceb32
+
8ceb32
+	place = strlen(convert);
8ceb32
+	padlen = len - place;
8ceb32
+	if( padlen < 0 ) padlen = 0;
8ceb32
+	if( ljust ) padlen = -padlen;
8ceb32
+	/* fprintf( stderr, "str '%s', place %d, sign %c, padlen %d\n",
8ceb32
+		convert,place,signvalue,padlen); / **/
8ceb32
+	if( zpad && padlen > 0 ){
8ceb32
+		if( signvalue ){
8ceb32
+			dopr_outch( buffer, left, signvalue );
8ceb32
+			--padlen;
8ceb32
+			signvalue = 0;
8ceb32
+		}
8ceb32
+		while( padlen > 0 ){
8ceb32
+			dopr_outch( buffer, left, zpad );
8ceb32
+			--padlen;
8ceb32
+		}
8ceb32
+	}
8ceb32
+	while( padlen > 0 ) {
8ceb32
+		dopr_outch( buffer, left, ' ' );
8ceb32
+		--padlen;
8ceb32
+	}
8ceb32
+	if( signvalue ) dopr_outch( buffer, left, signvalue );
8ceb32
+	while( place > 0 ) dopr_outch( buffer, left, convert[--place] );
8ceb32
+	while( padlen < 0 ){
8ceb32
+		dopr_outch( buffer, left, ' ' );
8ceb32
+		++padlen;
8ceb32
+	}
8ceb32
+}
8ceb32
+
8ceb32
+#endif
8ceb32
+
8ceb32
+ static void mystrcat(char *dest, char *src )
8ceb32
+{
8ceb32
+	if( dest && src ){
8ceb32
+		dest += safestrlen(dest);
8ceb32
+		strcpy(dest,src);
8ceb32
+	}
8ceb32
+}
8ceb32
+
8ceb32
+ static void
8ceb32
+ fmtdouble( char **buffer, int *left,
8ceb32
+	int fmt, double value, int ljust, int len, int zpad, int precision )
8ceb32
+{
8ceb32
+	char convert[sizeof( union value) * 8 + 512];
8ceb32
+	char formatstr[128];
8ceb32
+
8ceb32
+	/* fprintf(stderr,"len %d, precision %d\n", len, precision ); */
8ceb32
+	if( len > 255 ){
8ceb32
+		len = 255;
8ceb32
+	}
8ceb32
+	if( precision > 255 ){
8ceb32
+		precision = 255;
8ceb32
+	}
8ceb32
+	if( precision >= 0 && len > 0 && precision > len ) precision = len;
8ceb32
+	strcpy( formatstr, "%" );		/* 1 */
8ceb32
+	if( ljust ) mystrcat(formatstr, "-" ); /* 1 */
8ceb32
+	if( zpad ) mystrcat(formatstr, "0" );	/* 1 */
8ceb32
+	if( len >= 0 ){
8ceb32
+		sprintf( formatstr+strlen(formatstr), "%d", len ); /* 3 */
8ceb32
 	}
8ceb32
-	if( precision > 0 ){
8ceb32
-		sprintf( fmtstr+strlen(fmtstr), ".%d", precision );
8ceb32
+	if( precision >= 0 ){
8ceb32
+		sprintf( formatstr+strlen(formatstr), ".%d", precision ); /* 3 */
8ceb32
 	}
8ceb32
-	l = strlen( fmtstr );
8ceb32
-	fmtstr[l] = fmt;
8ceb32
-	fmtstr[l+1] = 0;
8ceb32
-	sprintf( convert, fmtstr, value );
8ceb32
-	dostr( convert );
8ceb32
+	/* format string will be at most 10 chars long ... */
8ceb32
+	sprintf( formatstr+strlen(formatstr), "%c", fmt );
8ceb32
+	/* this is easier than trying to do the portable dtostr */
8ceb32
+	/* fprintf(stderr,"format string '%s'\n", formatstr); */
8ceb32
+	sprintf( convert, formatstr, value );
8ceb32
+	dostr( buffer, left, convert );
8ceb32
 }
8ceb32
 
8ceb32
-static void dostr( char *str )
8ceb32
+ static void dostr( char **buffer, int *left, char *str  )
8ceb32
 {
8ceb32
-	while(*str) dopr_outch(*str++);
8ceb32
+	if(str)while(*str) dopr_outch( buffer, left, *str++ );
8ceb32
 }
8ceb32
 
8ceb32
-static void dopr_outch( int c )
8ceb32
+ static void dopr_outch( char **buffer, int *left, int c )
8ceb32
 {
8ceb32
-	if( end == 0 || output < end ){
8ceb32
-		*output++ = c;
8ceb32
+	if( *left > 0 ){
8ceb32
+		*(*buffer)++ = c;
8ceb32
 	}
8ceb32
+	*left -= 1;
8ceb32
 }
8ceb32
 
8ceb32
 
8ceb32
@@ -461,29 +1029,26 @@ static void dopr_outch( int c )
8ceb32
  *  Patrick Powell Tue Apr 11 08:05:05 PDT 1995
8ceb32
  ****************************************************************************/
8ceb32
 /****************************************************************************/
8ceb32
-#if !defined(HAVE_STRERROR)
8ceb32
-
8ceb32
-# if defined(HAVE_SYS_NERR)
8ceb32
-#  if !defined(HAVE_SYS_NERR_DEF)
8ceb32
-     extern int sys_nerr;
8ceb32
-#  endif
8ceb32
-#  define num_errors    (sys_nerr)
8ceb32
-# else
8ceb32
-#  define num_errors    (-1)            /* always use "errno=%d" */
8ceb32
-# endif
8ceb32
 
8ceb32
+#if !defined(HAVE_STRERROR)
8ceb32
+# undef  num_errors
8ceb32
 # if defined(HAVE_SYS_ERRLIST)
8ceb32
-#  if !defined(HAVE_SYS_ERRLIST_DEF)
8ceb32
+#  if !defined(HAVE_DECL_SYS_ERRLIST)
8ceb32
      extern const char *const sys_errlist[];
8ceb32
 #  endif
8ceb32
-# else
8ceb32
-#  undef  num_errors
8ceb32
-#  define num_errors   (-1)            /* always use "errno=%d" */
8ceb32
+#  if defined(HAVE_SYS_NERR)
8ceb32
+#   if !defined(HAVE_DECL_SYS_NERR)
8ceb32
+      extern int sys_nerr;
8ceb32
+#   endif
8ceb32
+#   define num_errors    (sys_nerr)
8ceb32
+#  endif
8ceb32
+# endif
8ceb32
+# if !defined(num_errors)
8ceb32
+#   define num_errors   (-1)            /* always use "errno=%d" */
8ceb32
 # endif
8ceb32
-
8ceb32
 #endif
8ceb32
 
8ceb32
-static char * plp_Errormsg ( int err )
8ceb32
+ static char * plp_Errormsg ( int err, char *buffer /* int maxlen = 32 */)
8ceb32
 {
8ceb32
     char *cp;
8ceb32
 
8ceb32
@@ -496,10 +1061,8 @@ static char * plp_Errormsg ( int err )
8ceb32
     } else
8ceb32
 # endif
8ceb32
 	{
8ceb32
-		static char msgbuf[32];     /* holds "errno=%d". */
8ceb32
-		/* SAFE use of sprintf */
8ceb32
-		(void) sprintf (msgbuf, "errno=%d", err);
8ceb32
-		cp = msgbuf;
8ceb32
+		(void) sprintf (buffer, "errno=%d", err);
8ceb32
+		cp = buffer;
8ceb32
     }
8ceb32
 #endif
8ceb32
     return (cp);
8ceb32
@@ -507,23 +1070,47 @@ static char * plp_Errormsg ( int err )
8ceb32
 
8ceb32
 #if defined(TEST)
8ceb32
 #include <stdio.h>
8ceb32
-int main( void )
8ceb32
+ int main( void )
8ceb32
 {
8ceb32
 	char buffer[128];
8ceb32
 	char *t;
8ceb32
 	char *test1 = "01234";
8ceb32
+	int n;
8ceb32
 	errno = 1;
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t="errno '%m'")); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%s"), test1 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%12s"), test1 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%-12s"), test1 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%12.2s"), test1 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%-12.2s"), test1 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%g"), 1.25 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%g"), 1.2345 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%12g"), 1.25 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%12.2g"), 1.25 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
-	plp_snprintf( buffer, sizeof(buffer), (t = "%0*d"), 6, 1 ); printf( "%s = '%s'\n", t, buffer );
8ceb32
+	buffer[0] = 0;
8ceb32
+	n = snprintf( buffer, 0, (t="test")); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t="errno '%m'")); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%-12s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12.2s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%-12.2s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%g"), 1.2345 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12.1g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12.2g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12.3g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%0*d"), 6, 1 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+#if defined(HAVE_LONG_LONG)
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%llx"), 1, 2, 3, 4 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%llx"), (long long)1, (long long)2 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%qx"), 1, 2, 3, 4 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%qx"), (quad_t)1, (quad_t)2 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+#endif
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), (char *)(0x01234567), (char *)0, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), (char *)(0x01234567), (char *)0x89ABCDEF, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), t, 0, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.2345 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%12.2f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%0.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%1.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%1.5f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
+	n = snprintf( buffer, sizeof(buffer), (t = "%5.5f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer );
8ceb32
 	return(0);
8ceb32
 }
8ceb32
 #endif