#define fmtfp(b, c, m, f, min, max, fl) currlen
#endif
-#define outch(c) {if (currlen < maxlen) { buffer[currlen++] = (c);}}
-
+/*
+ * NOTE!!!! do not use this #define with a construct such
+ * as outch(--place);. It just will NOT work, because the
+ * decrement of place is done ONLY if there is room in the
+ * output buffer.
+ */
+#define outch(c) {int len=currlen; if (currlen < maxlen) \
+ { buffer[len] = (c); currlen++; }}
/* format read states */
#define DP_S_DEFAULT 0
/* Conversion Flags */
#define DP_C_INT16 1
-#define DP_C_INT32 2
+#define DP_C_INT32 2
#define DP_C_LDOUBLE 3
#define DP_C_INT64 4
currlen = fmtfp(buffer, currlen, maxlen, fvalue, min, max, flags);
break;
case 'c':
- outch(va_arg(args, int));
+ ch = va_arg(args, int);
+ outch(ch);
break;
case 's':
strvalue = va_arg(args, char *);
{
int padlen, strln; /* amount to pad */
int cnt = 0;
+ char ch;
if (flags & DP_F_DOT && max < 0) { /* Max not specified */
--padlen;
}
while (*value && (cnt < max)) {
- outch(*value++);
+ ch = *value++;
+ outch(ch);
++cnt;
}
while (padlen < 0) {
}
}
- /* Digits */
+ /* Output digits backward giving correct order */
while (place > 0) {
- outch(convert[--place]);
+ place--;
+ outch(convert[place]);
}
/* Left Justified spaces */
int signvalue = 0;
LDOUBLE ufvalue;
#ifndef HAVE_FCVT
- char iconvert[20];
- char fconvert[20];
+ char iconvert[25];
+ char fconvert[25];
#else
char iconvert[311];
char fconvert[311];
iconvert[iplace++] =
(caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
- } while (intpart && (iplace < 20));
- if (iplace == 20)
+ } while (intpart && (iplace < (int)sizeof(iplace)));
+ if (iplace == (int)sizeof(iplace)) {
iplace--;
+ }
iconvert[iplace] = 0;
/* Convert fractional part */
fconvert[fplace++] =
(caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
- } while (fracpart && (fplace < 20));
- if (fplace == 20)
+ } while (fracpart && (fplace < (int)sizeof(fplace)));
+ if (fplace == (int)sizeof(fplace)) {
fplace--;
+ }
fconvert[fplace] = 0;
#else /* use fcvt() */
- if (max > 310)
+ if (max > 310) {
max = 310;
+ }
# ifdef HAVE_FCVTL
result = fcvtl(ufvalue, max, &dec_pt, &sig);
# else
}
while (iplace > 0) {
- outch(iconvert[--iplace]);
+ iplace--;
+ outch(iconvert[iplace]);
}
if (max > 0) {
outch('.');
while (fplace > 0) {
- outch(fconvert[--fplace]);
+ fplace--;
+ outch(fconvert[fplace]);
}
}
Technical notes on version 2.2
General:
-23Dec07
-kes Attempt to eliminate seg fault Frank Sweetser is seeing in
- running the regression tests on his Fedora systems. It seems
- to be related to bsnprintf and long path names.
+24Dec07
+kes Fix seg fault Frank Sweetser reports in regression testing
+ on his systems. The problem was that the original author of
+ bsnprintf.c did not take into account the side effects of
+ using ++x in the argument to a #define.
14Dec07
kes Apply patch from Michael Stapelberg <michael@stapelberg.de>
that implements double quoting include names in conf files,