7 Bug-Reported-by: Stuart Shelton <stuart@openobjects.com>
8 Bug-Reference-ID: <453F7CC8.6030907@openobjects.com>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-10/msg00127.html
13 A missing extern declaration for `asprintf' caused `double' arguments to be
14 passed as `0', leading to incorrect results. Additionally, a bug in the
15 replacement asprintf/snprintf function caused an infinite loop when passed
16 0 arguments to the floating point conversions under some circumstances.
20 *** ../bash-3.2/builtins/printf.def Mon Sep 18 08:48:42 2006
21 --- builtins/printf.def Tue Oct 31 08:19:44 2006
25 # define INT_MIN (-2147483647-1)
28 + #if defined (PREFER_STDARG)
29 + # include <stdarg.h>
31 + # include <varargs.h>
35 #include <chartypes.h>
40 #define SKIP1 "#'-+ 0"
41 #define LENMODS "hjlLtz"
43 + #ifndef HAVE_ASPRINTF
44 + extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
47 static void printf_erange __P((char *));
48 static int printstr __P((char *, char *, int, int, int));
49 static int tescape __P((char *, char *, int *));
52 *** ../bash-3.2/lib/sh/snprintf.c Thu Apr 6 09:48:40 2006
53 --- lib/sh/snprintf.c Sat Oct 28 00:00:13 2006
61 + * NOTE: do not call this with r == 0 -- an infinite loop results.
68 integral_part[0] = '0';
69 integral_part[1] = '\0';
70 ! fraction_part[0] = '0';
71 ! fraction_part[1] = '\0';
73 *fract = fraction_part;
77 integral_part[0] = '0';
78 integral_part[1] = '\0';
79 ! /* The fractional part has to take the precision into account */
80 ! for (ch = 0; ch < precision-1; ch++)
81 ! fraction_part[ch] = '0';
82 ! fraction_part[ch] = '0';
83 ! fraction_part[ch+1] = '\0';
85 *fract = fraction_part;
99 if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
102 /* calculate the padding. 1 for the dot */
103 p->width = p->width -
104 ((d > 0. && p->justify == RIGHT) ? 1:0) -
105 ((p->flags & PF_SPACE) ? 1:0) -
106 ! strlen(tmp) - p->precision - 1;
111 if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
114 + if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
116 + /* smash the trailing zeros unless altform */
117 + for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
119 + if (tmp2[0] == '\0')
123 /* calculate the padding. 1 for the dot */
124 p->width = p->width -
125 ((d > 0. && p->justify == RIGHT) ? 1:0) -
126 ((p->flags & PF_SPACE) ? 1:0) -
127 ! strlen(tmp) - p->precision -
128 ! ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0); /* radix char */
134 if (p->precision != 0 || (p->flags & PF_ALTFORM))
135 PUT_CHAR(decpoint, p); /* put the '.' */
137 - if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
138 - /* smash the trailing zeros unless altform */
139 - for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
142 for (; *tmp2; tmp2++)
143 PUT_CHAR(*tmp2, p); /* the fraction */
151 ! if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))
152 return; /* already printed nan or inf */
154 GETLOCALEDATA(decpoint, thoussep, grouping);
157 ! d = d / pow_10(j); /* get the Mantissa */
159 tmp = dtoa(d, p->precision, &tmp2);
161 /* 1 for unit, 1 for the '.', 1 for 'e|E',
166 ! if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)))
167 return; /* already printed nan or inf */
169 GETLOCALEDATA(decpoint, thoussep, grouping);
176 ! d = d / pow_10(j); /* get the Mantissa */
179 tmp = dtoa(d, p->precision, &tmp2);
181 /* 1 for unit, 1 for the '.', 1 for 'e|E',
199 * for '%g|%G' ANSI: use f if exponent
200 * is in the range or [-4,p] exclusively
205 ! i = (d != 0.) ? log_10(d) : -1;
207 * for '%g|%G' ANSI: use f if exponent
208 * is in the range or [-4,p] exclusively
209 *** ../bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
210 --- patchlevel.h Mon Oct 16 14:22:54 2006
213 looks for to find the patch level (for the sccs version string). */
215 ! #define PATCHLEVEL 4
217 #endif /* _PATCHLEVEL_H_ */
219 looks for to find the patch level (for the sccs version string). */
221 ! #define PATCHLEVEL 5
223 #endif /* _PATCHLEVEL_H_ */