r2007 - in glibc-package/branches/glibc-2.5/debian: . patches patches/any
Author: aurel32
Date: 2007-02-21 12:10:38 +0100 (Wed, 21 Feb 2007)
New Revision: 2007
Added:
glibc-package/branches/glibc-2.5/debian/patches/any/cvs-printf_fp-c.diff
Modified:
glibc-package/branches/glibc-2.5/debian/changelog
glibc-package/branches/glibc-2.5/debian/patches/series
Log:
* any/cvs-printf_fp-c.diff: new patch (fix printf %#.0g) from CVS.
Closes: #209136.
Modified: glibc-package/branches/glibc-2.5/debian/changelog
===================================================================
--- glibc-package/branches/glibc-2.5/debian/changelog 2007-02-21 11:01:41 UTC (rev 2006)
+++ glibc-package/branches/glibc-2.5/debian/changelog 2007-02-21 11:10:38 UTC (rev 2007)
@@ -70,7 +70,7 @@
with linuxthreads) from the libc-alpha mailing list.
* debian/powerpc/cvs-tls-debug.diff: new patch (fix for debugging
thread-local variables on powerpc) from CVS.
- * Build depends on binutils (>= 2.17.50) to enable --hash-style=both
+ * Build depends on binutils (>= 2.17.50) to enable --hash-style=both
linking. Depends on a binutils version that supports DT_GNU_HASH.
Closes: #405738.
* Build depends on gcc-4.2 on hppa to enable TLS on hppa. Closes: #397813.
@@ -109,7 +109,7 @@
* Change any/local-__thread.diff into any/local-notls.diff.
* Update any/local-notls.diff (make glibc buildable without TLS support)
from Petr Salinger and Aurelien Jarno.
- * hurd-i386/submitted-trivia.diff: new patch from Thomas Schwinge (make glibc
+ * hurd-i386/submitted-trivia.diff: new patch from Thomas Schwinge (make glibc
partly buildable on Hurd).
* hurd-i386/submitted-stat.diff: new patch from Thomas Schwinge (update
struct stat on Hurd).
@@ -129,8 +129,10 @@
versioned conflict. Closes: #407540.
* any/local-mktemp.diff: new patch (also propose mkdtemp as an alternative
to mktemp). Closes: #377310.
- * any/cvs-ftw-c.diff: new patch (fix nftw() with FTW_CHDIR in /) from CVS.
+ * any/cvs-ftw-c.diff: new patch (fix nftw() with FTW_CHDIR in /) from CVS.
Closes: #367522.
+ * any/cvs-printf_fp-c.diff: new patch (fix printf %#.0g) from CVS.
+ Closes: #209136.
[ Denis Barbier ]
* Remove localedata/locale-en_NZ.diff (merged upstream).
@@ -162,7 +164,7 @@
an unknown timezone in $TZ, submitted upstream as #4028.
Closes: #55648, #119540, #269238.
- -- Aurelien Jarno <aurel32@debian.org> Wed, 7 Feb 2007 13:56:40 +0100
+ -- Aurelien Jarno <aurel32@debian.org> Wed, 21 Feb 2007 12:09:32 +0100
glibc (2.4-1) UNRELEASED; urgency=low
Added: glibc-package/branches/glibc-2.5/debian/patches/any/cvs-printf_fp-c.diff
===================================================================
--- glibc-package/branches/glibc-2.5/debian/patches/any/cvs-printf_fp-c.diff 2007-02-21 11:01:41 UTC (rev 2006)
+++ glibc-package/branches/glibc-2.5/debian/patches/any/cvs-printf_fp-c.diff 2007-02-21 11:10:38 UTC (rev 2007)
@@ -0,0 +1,190 @@
+2007-02-21 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #4070]
+ * stdio-common/printf_fp.c (___printf_fp): Handle a few more
+ special cases.
+
+===================================================================
+RCS file: /cvs/glibc/libc/stdio-common/printf_fp.c,v
+retrieving revision 1.58
+retrieving revision 1.61
+diff -u -r1.58 -r1.61
+--- libc/stdio-common/printf_fp.c 2006/04/25 18:38:30 1.58
++++ libc/stdio-common/printf_fp.c 2007/02/21 08:56:40 1.61
+@@ -811,12 +811,14 @@
+ int chars_needed;
+ int expscale;
+ int intdig_max, intdig_no = 0;
+- int fracdig_min, fracdig_max, fracdig_no = 0;
++ int fracdig_min;
++ int fracdig_max;
+ int dig_max;
+ int significant;
+ int ngroups = 0;
++ char spec = _tolower (info->spec);
+
+- if (_tolower (info->spec) == 'e')
++ if (spec == 'e')
+ {
+ type = info->spec;
+ intdig_max = 1;
+@@ -826,7 +828,7 @@
+ dig_max = INT_MAX; /* Unlimited. */
+ significant = 1; /* Does not matter here. */
+ }
+- else if (_tolower (info->spec) == 'f')
++ else if (spec == 'f')
+ {
+ type = 'f';
+ fracdig_min = fracdig_max = info->prec < 0 ? 6 : info->prec;
+@@ -887,7 +889,7 @@
+ other output. If the amount of memory we have to allocate is too
+ large use `malloc' instead of `alloca'. */
+ buffer_malloced = ! __libc_use_alloca (chars_needed * 2 * sizeof (wchar_t));
+- if (buffer_malloced)
++ if (__builtin_expect (buffer_malloced, 0))
+ {
+ wbuffer = (wchar_t *) malloc ((2 + chars_needed) * sizeof (wchar_t));
+ if (wbuffer == NULL)
+@@ -923,7 +925,9 @@
+ }
+
+ /* Generate the needed number of fractional digits. */
+- while (fracdig_no < fracdig_min
++ int fracdig_no = 0;
++ int added_zeros = 0;
++ while (fracdig_no < fracdig_min + added_zeros
+ || (fracdig_no < fracdig_max && (fracsize > 1 || frac[0] != 0)))
+ {
+ ++fracdig_no;
+@@ -934,7 +938,7 @@
+ {
+ ++fracdig_max;
+ if (fracdig_min > 0)
+- ++fracdig_min;
++ ++added_zeros;
+ }
+ }
+
+@@ -971,11 +975,23 @@
+ {
+ /* Process fractional digits. Terminate if not rounded or
+ radix character is reached. */
++ int removed = 0;
+ while (*--wtp != decimalwc && *wtp == L'9')
+- *wtp = '0';
++ {
++ *wtp = L'0';
++ ++removed;
++ }
++ if (removed == fracdig_min && added_zeros > 0)
++ --added_zeros;
+ if (*wtp != decimalwc)
+ /* Round up. */
+ (*wtp)++;
++ else if (__builtin_expect (spec == 'g' && type == 'f' && info->alt,
++ 0))
++ /* This is a special case: the rounded number is 1.0,
++ the format is 'g' or 'G', and the alternative format
++ is selected. This means the result mist be "1.". */
++ --added_zeros;
+ }
+
+ if (fracdig_no == 0 || *wtp == decimalwc)
+@@ -1042,7 +1058,7 @@
+
+ do_expo:
+ /* Now remove unnecessary '0' at the end of the string. */
+- while (fracdig_no > fracdig_min && *(wcp - 1) == L'0')
++ while (fracdig_no > fracdig_min + added_zeros && *(wcp - 1) == L'0')
+ {
+ --wcp;
+ --fracdig_no;
+@@ -1060,26 +1076,41 @@
+ /* Write the exponent if it is needed. */
+ if (type != 'f')
+ {
+- *wcp++ = (wchar_t) type;
+- *wcp++ = expsign ? L'-' : L'+';
+-
+- /* Find the magnitude of the exponent. */
+- expscale = 10;
+- while (expscale <= exponent)
+- expscale *= 10;
+-
+- if (exponent < 10)
+- /* Exponent always has at least two digits. */
+- *wcp++ = L'0';
++ if (__builtin_expect (expsign != 0 && exponent == 4 && spec == 'g', 0))
++ {
++ /* This is another special case. The exponent of the number is
++ really smaller than -4, which requires the 'e'/'E' format.
++ But after rounding the number has an exponent of -4. */
++ assert (wcp >= wstartp + 2);
++ assert (wstartp[0] == L'1');
++ __wmemcpy (wstartp, L"0.0001", 6);
++ wstartp[1] = decimalwc;
++ wmemset (wstartp + 6, L'0', wcp - (wstartp + 2));
++ wcp += 4;
++ }
+ else
+- do
+- {
+- expscale /= 10;
+- *wcp++ = L'0' + (exponent / expscale);
+- exponent %= expscale;
+- }
+- while (expscale > 10);
+- *wcp++ = L'0' + exponent;
++ {
++ *wcp++ = (wchar_t) type;
++ *wcp++ = expsign ? L'-' : L'+';
++
++ /* Find the magnitude of the exponent. */
++ expscale = 10;
++ while (expscale <= exponent)
++ expscale *= 10;
++
++ if (exponent < 10)
++ /* Exponent always has at least two digits. */
++ *wcp++ = L'0';
++ else
++ do
++ {
++ expscale /= 10;
++ *wcp++ = L'0' + (exponent / expscale);
++ exponent %= expscale;
++ }
++ while (expscale > 10);
++ *wcp++ = L'0' + exponent;
++ }
+ }
+
+ /* Compute number of characters which must be filled with the padding
+@@ -1120,15 +1151,14 @@
+ else
+ thousands_sep_len = strlen (thousands_sep);
+
+- if (buffer_malloced)
++ if (__builtin_expect (buffer_malloced, 0))
+ {
+ buffer = (char *) malloc (2 + chars_needed + decimal_len
+ + ngroups * thousands_sep_len);
+ if (buffer == NULL)
+ {
+ /* Signal an error to the caller. */
+- if (buffer_malloced)
+- free (wbuffer);
++ free (wbuffer);
+ return -1;
+ }
+ }
+@@ -1162,7 +1192,7 @@
+ PRINT (tmpptr, wstartp, wide ? wcp - wstartp : cp - tmpptr);
+
+ /* Free the memory if necessary. */
+- if (buffer_malloced)
++ if (__builtin_expect (buffer_malloced, 0))
+ {
+ free (buffer);
+ free (wbuffer);
Modified: glibc-package/branches/glibc-2.5/debian/patches/series
===================================================================
--- glibc-package/branches/glibc-2.5/debian/patches/series 2007-02-21 11:01:41 UTC (rev 2006)
+++ glibc-package/branches/glibc-2.5/debian/patches/series 2007-02-21 11:10:38 UTC (rev 2007)
@@ -95,6 +95,7 @@
all/submitted-new-brf-encoding.diff -p0
any/cvs-2.5-branch-update.diff -p1
+any/cvs-printf_fp-c.diff -p1
any/cvs-ftw-c.diff -p0
any/cvs-itoa-c.diff -p1
any/cvs-lt-update.diff -p0
Reply to: