dsprintf.c File Reference

#include "nsd.h"
#include <float.h>

Defines

#define quad_t   ns_int64
#define u_quad_t   ns_uint64
#define MAXEXP   308
#define MAXFRACT   39
#define BUF   (MAXEXP+MAXFRACT+1)
#define to_digit(c)   ((c) - '0')
#define is_digit(c)   ((unsigned)to_digit(c) <= 9)
#define to_char(n)   ((char)((n) + '0'))
#define ALT   0x001
#define HEXPREFIX   0x002
#define LADJUST   0x004
#define LONGDBL   0x008
#define LONGINT   0x010
#define QUADINT   0x020
#define SHORTINT   0x040
#define ZEROPAD   0x080
#define PRINT(ptr, len)   Tcl_DStringAppend(dsPtr, (ptr), (len))
#define PAD(howmany, with)
#define SARG()
#define UARG()

Functions

char * Ns_DStringVPrintf (Tcl_DString *dsPtr, char *fmt0, va_list ap)

Define Documentation

#define ALT   0x001

Flags used during conversion.

#define BUF   (MAXEXP+MAXFRACT+1)

#define HEXPREFIX   0x002

#define is_digit (  )     ((unsigned)to_digit(c) <= 9)

#define LADJUST   0x004

#define LONGDBL   0x008

#define LONGINT   0x010

#define MAXEXP   308

11-bit exponent (VAX G floating point) is 308 decimal digits

#define MAXFRACT   39

128 bit fraction takes up 39 decimal digits; max reasonable precision

#define PAD ( howmany,
with   ) 

Value:

{ \
        if ((n = (howmany)) > 0) { \
            len = dsPtr->length; \
            Tcl_DStringSetLength(dsPtr, len + n); \
            for (bp = dsPtr->string + len; n > 0; --n) *bp++ = (with);\
        }\
}

#define PRINT ( ptr,
len   )     Tcl_DStringAppend(dsPtr, (ptr), (len))

#define quad_t   ns_int64

This code is derived from software contributed to Berkeley by Chris Torek.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#define QUADINT   0x020

 
#define SARG (  ) 

Value:

(flags&QUADINT ? va_arg(ap, quad_t) : \
            flags&LONGINT ? va_arg(ap, long) : \
            flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
            (long)va_arg(ap, int))

#define SHORTINT   0x040

#define to_char (  )     ((char)((n) + '0'))

#define to_digit (  )     ((c) - '0')

Macros for converting digits to letters and vice versa

#define u_quad_t   ns_uint64

 
#define UARG (  ) 

Value:

(flags&QUADINT ? va_arg(ap, u_quad_t) : \
            flags&LONGINT ? va_arg(ap, u_long) : \
            flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \
            (u_long)va_arg(ap, u_int))

#define ZEROPAD   0x080


Function Documentation

char* Ns_DStringVPrintf ( Tcl_DString *  dsPtr,
char *  fmt0,
va_list  ap 
)


Generated on Tue Sep 4 19:58:56 2007 by  doxygen 1.5.1