--- l2_ut_format.c 2002/09/22 07:35:40 1.7
+++ l2_ut_format.c 2003/01/06 11:41:52 1.8
@@ -1,9 +1,10 @@
/*
-** OSSP l2 - Logging Library
-** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/)
-** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/)
+** OSSP l2 - Flexible Logging
+** Copyright (c) 2001-2003 Cable & Wireless Deutschland GmbH
+** Copyright (c) 2001-2003 The OSSP Project (http://www.ossp.org/)
+** Copyright (c) 2001-2003 Ralf S. Engelschall <rse@engelschall.com>
**
-** This file is part of OSSP L2, a flexible logging library which
+** This file is part of OSSP l2, a flexible logging library which
** can be found at http://www.ossp.org/pkg/lib/l2/.
**
** Permission to use, copy, modify, and distribute this software for
@@ -39,7 +40,7 @@
* Especially any Apache and network specific kludges were removed again
* and instead the formatting engine now can be extended by the caller
* on-the-fly. It was then finally adjusted to be stand-alone for use
- * inside OSSP L2.
+ * inside OSSP l2.
*/
/*
@@ -128,7 +129,7 @@
#define FLOAT_DIGITS 6
#define EXPONENT_LENGTH 10
-/* NUM_BUF_SIZE is the size of the buffer used for arithmetic
+/* NUM_BUF_SIZE is the size of the buffer used for arithmetic
conversions. This is a magic number; do NOT decrease it! */
#define NUM_BUF_SIZE 512
#define NDIG 80
@@ -148,7 +149,7 @@
#define l2_util_islower(c) (islower(((unsigned char)(c))))
#define l2_util_tolower(c) (tolower((unsigned char)(c)))
-/*
+/*
* Convert decimal number to its string representation. The number of
* digits is specified by ndigit decpt is set to the position of the
* decimal point sign is set to 0 for positive, 1 for negative. buf must
@@ -163,10 +164,10 @@
static char *
l2_util_cvt(
- double arg,
- int ndigits,
- int *decpt,
- int *sign,
+ double arg,
+ int ndigits,
+ int *decpt,
+ int *sign,
int eflag,
char *buf)
{
@@ -242,9 +243,9 @@
static char *
l2_util_gcvt(
- double number,
- int ndigit,
- char *buf,
+ double number,
+ int ndigit,
+ char *buf,
int altform)
{
int sign;
@@ -326,7 +327,7 @@
}
/*
- * Convert a string to decimal value
+ * Convert a string to decimal value
*/
#define NUM(c) ((c) - '0')
#define STR_TO_DEC(str, num) { \
@@ -336,7 +337,7 @@
num += NUM(*str++) ; \
} \
}
-
+
/*
* This macro does zero padding so that the precision requirement is
* satisfied. The padding is done by adding '0's to the left of the
@@ -351,7 +352,7 @@
}
/*
- * This macro does padding.
+ * This macro does padding.
* The padding is done by printing the character ch.
*/
#define PAD(width, len, ch) \
@@ -385,9 +386,9 @@
*/
static char *
conv_10(
- register long_int num,
+ register long_int num,
register int is_unsigned,
- register int *is_negative,
+ register int *is_negative,
char *buf_end,
register size_t *len)
{
@@ -400,7 +401,7 @@
}
else {
*is_negative = (num < 0);
- /* On a 2's complement machine, negating the most negative integer
+ /* On a 2's complement machine, negating the most negative integer
results in a number that cannot be represented as a signed integer.
Here is what we do to obtain the number's magnitude:
a. add 1 to the number
@@ -427,9 +428,9 @@
static char *
conv_10_quad(
- quad_int num,
+ quad_int num,
register int is_unsigned,
- register int *is_negative,
+ register int *is_negative,
char *buf_end,
register size_t *len)
{
@@ -442,7 +443,7 @@
}
else {
*is_negative = (num < 0);
- /* On a 2's complement machine, negating the most negative integer
+ /* On a 2's complement machine, negating the most negative integer
result in a number that cannot be represented as a signed integer.
Here is what we do to obtain the number's magnitude:
a. add 1 to the number
@@ -474,12 +475,12 @@
*/
static char *
conv_fp(
- register char format,
+ register char format,
register double num,
- int add_dp,
- int precision,
+ int add_dp,
+ int precision,
int *is_negative,
- char *buf,
+ char *buf,
size_t *len)
{
register char *s = buf;
@@ -535,7 +536,7 @@
*s++ = format; /* either e or E */
decimal_point--;
if (decimal_point != 0) {
- p = conv_10((long_int) decimal_point, FALSE, &exponent_is_negative,
+ p = conv_10((long_int) decimal_point, FALSE, &exponent_is_negative,
&temp[EXPONENT_LENGTH], &t_len);
*s++ = exponent_is_negative ? '-' : '+';
/* Make sure the exponent has at least 2 digits */
@@ -572,10 +573,10 @@
static char *
conv_p2(
- register u_long_int num,
+ register u_long_int num,
register int nbits,
- char format,
- char *buf_end,
+ char format,
+ char *buf_end,
register size_t *len)
{
register int mask = (1 << nbits) - 1;
@@ -592,10 +593,10 @@
static char *
conv_p2_quad(
- u_quad_int num,
+ u_quad_int num,
register int nbits,
- char format,
- char *buf_end,
+ char format,
+ char *buf_end,
register size_t *len)
{
register int mask = (1 << nbits) - 1;
@@ -610,14 +611,14 @@
return p;
}
-/*
+/*
* l2_util_format(), the generic printf-style formatting routine
* and heart of this piece of source.
*/
-int
+int
l2_util_format(
- l2_util_format_t *vbuff,
- const char *fmt,
+ l2_util_format_t *vbuff,
+ const char *fmt,
va_list ap)
{
register char *sp;
@@ -911,7 +912,7 @@
else {
/* use &num_buf[1], so that we have room for the sign */
s = conv_fp(*fmt, fp_num, alternate_form,
- (adjust_precision == FALSE) ? FLOAT_DIGITS : precision,
+ (adjust_precision == FALSE) ? FLOAT_DIGITS : precision,
&is_negative, &num_buf[1], &s_len);
if (is_negative)
prefix_char = '-';
@@ -986,7 +987,7 @@
break;
/*
- * Pointer argument type.
+ * Pointer argument type.
*/
case 'p':
#if defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == SIZEOF_VOID_P)
@@ -1020,7 +1021,7 @@
s = NULL;
if (vbuff->format != NULL) {
vbuff->format(vbuff,
- &prefix_char, &pad_char, &s, &s_len,
+ &prefix_char, &pad_char, &s, &s_len,
num_buf, NUM_BUF_SIZE, extinfo, *fmt, &ap);
if (s == NULL)
return -1;
@@ -1051,7 +1052,7 @@
}
/*
- * Print the string s.
+ * Print the string s.
*/
for (i = s_len; i != 0; i--) {
INS_CHAR(*s, sp, bep, cc);
|