[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r8806 - in /libdfp/trunk: include/printf_dfp.h printf_dfp.c
- To: commits@xxxxxxxxxx
- Subject: [commits] r8806 - in /libdfp/trunk: include/printf_dfp.h printf_dfp.c
- From: ryanarn@xxxxxxxxxx
- Date: Wed, 12 Aug 2009 18:50:13 -0000
Author: ryanarn
Date: Wed Aug 12 11:50:13 2009
New Revision: 8806
Log:
Fixes to correct erroneous registration of decimal printf specifiers. This
method allows all three sized types to be printed. This also fixes a bug
where the print routines were printing infinite numbers of spaces.
2009-08-11 Andreas Krebbel <krebbel@xxxxxxxxxxxxxxxxxx>
* include/printf_dfp.h (__d32_ais, __d64_ais, __d128_ais): Removed
prototypes and replaced with unified __dfp_ais().
* printf_dfp.c (__printf_dfp): Changed width from unsigned into to
int in order to prevent negative default.
(__register_printf_dfp): Replaced individual decimal sized
specifier registrations with a unified registrations.
(__d32_ais, __d64_ais, __d128_ais): Removed and replaced with unified
__dfp_ais().
Modified:
libdfp/trunk/include/printf_dfp.h
libdfp/trunk/printf_dfp.c
Modified: libdfp/trunk/include/printf_dfp.h
==============================================================================
--- libdfp/trunk/include/printf_dfp.h (original)
+++ libdfp/trunk/include/printf_dfp.h Wed Aug 12 11:50:13 2009
@@ -47,12 +47,8 @@
extern void __d32_va (void *mem, va_list *ap);
hidden_proto (__d32_va)
-extern int __d128_ais (const struct printf_info *info, size_t n, int *argtype, int *size);
-hidden_proto (__d128_ais)
-extern int __d64_ais (const struct printf_info *info, size_t n, int *argtype, int *size);
-hidden_proto (__d64_ais)
-extern int __d32_ais (const struct printf_info *info, size_t n, int *argtype, int *size);
-hidden_proto (__d32_ais)
+extern int __dfp_ais (const struct printf_info *info, size_t n, int *argtype, int *size);
+hidden_proto (__dfp_ais)
extern int __register_printf_dfp (void);
hidden_proto(__register_printf_dfp)
Modified: libdfp/trunk/printf_dfp.c
==============================================================================
--- libdfp/trunk/printf_dfp.c (original)
+++ libdfp/trunk/printf_dfp.c Wed Aug 12 11:50:13 2009
@@ -142,68 +142,62 @@
static int pa_d64;
static int pa_d32;
-void
-__d128_va (void *mem, va_list *ap)
-{
- _Decimal128 d = va_arg (*ap, _Decimal128);
- memcpy (mem, &d, sizeof (d));
-}
-strong_alias(__d128_va, d128_va)
-hidden_def(__d128_va)
-
-void
-__d64_va (void *mem, va_list *ap)
-{
- _Decimal64 d = va_arg (*ap, _Decimal64);
- memcpy (mem, &d, sizeof (d));
-}
-strong_alias(__d64_va, d64_va)
-hidden_def(__d64_va)
-
-void
-__d32_va (void *mem, va_list *ap)
-{
- _Decimal32 d = va_arg (*ap, _Decimal32);
- memcpy (mem, &d, sizeof (d));
-}
-strong_alias(__d32_va, d32_va)
-hidden_def(__d32_va)
-
-int
-__d128_ais (const struct printf_info *info __attribute__ ((unused)), size_t n __attribute__ ((unused)), int *argtype, int *size)
-{
- argtype[0] = pa_d128;
- size[0] = sizeof (_Decimal128);
- /* Isn't this going to say it always handles this type? */
- return 1;
-}
-strong_alias(__d128_ais, d128_ais)
-hidden_def(__d128_ais)
-
-int
-__d64_ais (const struct printf_info *info __attribute__ ((unused)), size_t n __attribute__ ((unused)), int *argtype, int *size)
-{
- argtype[0] = pa_d64;
- size[0] = sizeof (_Decimal64);
- return 1;
-}
-strong_alias(__d64_ais, d64_ais)
-hidden_def(__d64_ais)
-
-int
-__d32_ais (const struct printf_info *info __attribute__ ((unused)), size_t n __attribute__ ((unused)), int *argtype, int *size)
-{
- argtype[0] = pa_d32;
- size[0] = sizeof (_Decimal32);
- return 1;
-}
-strong_alias(__d32_ais, d32_ais)
-hidden_def(__d32_ais)
-
static int mod_H;
static int mod_D;
static int mod_DD;
+void
+__d128_va (void *mem, va_list *ap)
+{
+ _Decimal128 d = va_arg (*ap, _Decimal128);
+ memcpy (mem, &d, sizeof (d));
+}
+strong_alias(__d128_va, d128_va)
+hidden_def(__d128_va)
+
+void
+__d64_va (void *mem, va_list *ap)
+{
+ _Decimal64 d = va_arg (*ap, _Decimal64);
+ memcpy (mem, &d, sizeof (d));
+}
+strong_alias(__d64_va, d64_va)
+hidden_def(__d64_va)
+
+void
+__d32_va (void *mem, va_list *ap)
+{
+ _Decimal32 d = va_arg (*ap, _Decimal32);
+ memcpy (mem, &d, sizeof (d));
+}
+strong_alias(__d32_va, d32_va)
+hidden_def(__d32_va)
+
+int
+__dfp_ais (const struct printf_info *info, size_t n __attribute__ ((unused)), int *argtype, int *size)
+{
+ if ((info->user & mod_H) == mod_H)
+ {
+ argtype[0] = pa_d32;
+ size[0] = sizeof (_Decimal32);
+ return 1;
+ }
+ else if ((info->user & mod_D) == mod_D)
+ {
+ argtype[0] = pa_d64;
+ size[0] = sizeof (_Decimal64);
+ return 1;
+ }
+ else if ((info->user & mod_DD) == mod_DD)
+ {
+ argtype[0] = pa_d128;
+ size[0] = sizeof (_Decimal128);
+ return 1;
+ }
+ return 0;
+}
+strong_alias(__dfp_ais, dfp_ais)
+hidden_def(__dfp_ais)
#define DECIMAL_PRINTF_BUF_SIZE 65 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */
@@ -357,7 +351,7 @@
n; /* current digit offset into digits[] */
//width, /* width of the field */
- unsigned int width; /* width of the field */
+ int width; /* width of the field */
digits[0] = '0'; /* need an extra digit for rounding up */
// __get_dpd_digits (
@@ -644,34 +638,14 @@
mod_H = register_printf_modifier (L"H");
mod_D = register_printf_modifier (L"D");
- register_printf_specifier ('f', printf_dfp, d128_ais);
- register_printf_specifier ('F', printf_dfp, d128_ais);
- register_printf_specifier ('e', printf_dfp, d128_ais);
- register_printf_specifier ('E', printf_dfp, d128_ais);
- register_printf_specifier ('g', printf_dfp, d128_ais);
- register_printf_specifier ('G', printf_dfp, d128_ais);
- register_printf_specifier ('a', printf_dfp, d128_ais);
- register_printf_specifier ('A', printf_dfp, d128_ais);
-
- register_printf_specifier ('f', printf_dfp, d32_ais);
- register_printf_specifier ('F', printf_dfp, d32_ais);
- register_printf_specifier ('e', printf_dfp, d32_ais);
- register_printf_specifier ('E', printf_dfp, d32_ais);
- register_printf_specifier ('g', printf_dfp, d32_ais);
- register_printf_specifier ('G', printf_dfp, d32_ais);
- register_printf_specifier ('a', printf_dfp, d32_ais);
- register_printf_specifier ('A', printf_dfp, d32_ais);
-
- /* Currently GLIBC's printf hooks only support one override so we make it
- * _Decimal64 by registering last. */
- register_printf_specifier ('f', printf_dfp, d64_ais);
- register_printf_specifier ('F', printf_dfp, d64_ais);
- register_printf_specifier ('e', printf_dfp, d64_ais);
- register_printf_specifier ('E', printf_dfp, d64_ais);
- register_printf_specifier ('g', printf_dfp, d64_ais);
- register_printf_specifier ('G', printf_dfp, d64_ais);
- register_printf_specifier ('a', printf_dfp, d64_ais);
- register_printf_specifier ('A', printf_dfp, d64_ais);
+ register_printf_specifier ('f', printf_dfp, dfp_ais);
+ register_printf_specifier ('F', printf_dfp, dfp_ais);
+ register_printf_specifier ('e', printf_dfp, dfp_ais);
+ register_printf_specifier ('E', printf_dfp, dfp_ais);
+ register_printf_specifier ('g', printf_dfp, dfp_ais);
+ register_printf_specifier ('G', printf_dfp, dfp_ais);
+ register_printf_specifier ('a', printf_dfp, dfp_ais);
+ register_printf_specifier ('A', printf_dfp, dfp_ais);
return 0;
}