This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.14-338-g187da0a


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  187da0aedcd9d0a2fb34477bef41549681ba1273 (commit)
      from  9277c064373074aebbf1b6617c006f5985ec7938 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=187da0aedcd9d0a2fb34477bef41549681ba1273

commit 187da0aedcd9d0a2fb34477bef41549681ba1273
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat Oct 8 08:22:44 2011 -0400

    isinf returns the sign of the number, use it in printf*

diff --git a/ChangeLog b/ChangeLog
index 6f6082e..db3a61b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-10-08  Ulrich Drepper  <drepper@gmail.com>
 
+	* stdio-common/printf_fp.c: Use the fact that isinf returns the sign
+	of the number.
+	* stdio-common/printf_fphex.c: Likewise.
+	* stdio-common/printf_size.c: Likewise.
+
 	* math/e_exp10.c: Include math_private.h using <...> not "...".
 	* math/e_exp10f.c: Likewise.
 	* math/e_exp10l.c: Likewise.
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 0a61147..0853bc2 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -334,6 +334,7 @@ ___printf_fp (FILE *fp,
       fpnum.ldbl = *(const long double *) args[0];
 
       /* Check for special values: not a number or infinity.  */
+      int res;
       if (__isnanl (fpnum.ldbl))
 	{
 	  union ieee854_long_double u = { .d = fpnum.ldbl };
@@ -349,9 +350,9 @@ ___printf_fp (FILE *fp,
 		wspecial = L"nan";
 	      }
 	}
-      else if (__isinfl (fpnum.ldbl))
+      else if ((res = __isinfl (fpnum.ldbl)))
 	{
-	  is_neg = fpnum.ldbl < 0;
+	  is_neg = res < 0;
 	  if (isupper (info->spec))
 	    {
 	      special = "INF";
@@ -379,6 +380,7 @@ ___printf_fp (FILE *fp,
       fpnum.dbl = *(const double *) args[0];
 
       /* Check for special values: not a number or infinity.  */
+      int res;
       if (__isnan (fpnum.dbl))
 	{
 	  union ieee754_double u = { .d = fpnum.dbl };
@@ -394,9 +396,9 @@ ___printf_fp (FILE *fp,
 	      wspecial = L"nan";
 	    }
 	}
-      else if (__isinf (fpnum.dbl))
+      else if ((res = __isinf (fpnum.dbl)))
 	{
-	  is_neg = fpnum.dbl < 0;
+	  is_neg = res < 0;
 	  if (isupper (info->spec))
 	    {
 	      special = "INF";
diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c
index 284cc6e..6cb7141 100644
--- a/stdio-common/printf_fphex.c
+++ b/stdio-common/printf_fphex.c
@@ -180,7 +180,8 @@ __printf_fphex (FILE *fp,
 	}
       else
 	{
-	  if (__isinfl (fpnum.ldbl.d))
+	  int res = __isinfl (fpnum.ldbl.d);
+	  if (res)
 	    {
 	      if (isupper (info->spec))
 		{
@@ -192,9 +193,10 @@ __printf_fphex (FILE *fp,
 		  special = "inf";
 		  wspecial = L"inf";
 		}
+	      negative = res < 0;
 	    }
-
-	  negative = signbit (fpnum.ldbl.d);
+	  else
+	    negative = signbit (fpnum.ldbl.d);
 	}
     }
   else
@@ -219,7 +221,8 @@ __printf_fphex (FILE *fp,
 	}
       else
 	{
-	  if (__isinf (fpnum.dbl.d))
+	  int res = __isinf (fpnum.dbl.d);
+	  if (res)
 	    {
 	      if (isupper (info->spec))
 		{
@@ -231,9 +234,10 @@ __printf_fphex (FILE *fp,
 		  special = "inf";
 		  wspecial = L"inf";
 		}
+	      negative = res < 0;
 	    }
-
-	  negative = signbit (fpnum.dbl.d);
+	  else
+	    negative = signbit (fpnum.dbl.d);
 	}
     }
 
diff --git a/stdio-common/printf_size.c b/stdio-common/printf_size.c
index 957de2f..651b3db 100644
--- a/stdio-common/printf_size.c
+++ b/stdio-common/printf_size.c
@@ -1,5 +1,5 @@
 /* Print size value using units for orders of magnitude.
-   Copyright (C) 1997-2002, 2004, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997-2002, 2004, 2006, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
    Based on a proposal by Larry McVoy <lm@sgi.com>.
@@ -109,7 +109,7 @@ __printf_size (FILE *fp, const struct printf_info *info,
   fpnum;
   const void *ptr = &fpnum;
 
-  int negative = 0;
+  int fpnum_sign = 0;
 
   /* "NaN" or "Inf" for the special cases.  */
   const char *special = NULL;
@@ -118,7 +118,7 @@ __printf_size (FILE *fp, const struct printf_info *info,
   struct printf_info fp_info;
   int done = 0;
   int wide = info->wide;
-
+  int res;
 
   /* Fetch the argument value.	*/
 #ifndef __NO_LONG_DOUBLE_MATH
@@ -131,14 +131,13 @@ __printf_size (FILE *fp, const struct printf_info *info,
 	{
 	  special = "nan";
 	  wspecial = L"nan";
-	  negative = 0;
+	  // fpnum_sign = 0;	Already zero
 	}
-      else if (__isinfl (fpnum.ldbl.d))
+      else if ((res = __isinfl (fpnum.ldbl.d)))
 	{
+	  fpnum_sign = res;
 	  special = "inf";
 	  wspecial = L"inf";
-
-	  negative = fpnum.ldbl.d < 0;
 	}
       else
 	while (fpnum.ldbl.d >= divisor && tag[1] != '\0')
@@ -157,14 +156,13 @@ __printf_size (FILE *fp, const struct printf_info *info,
 	{
 	  special = "nan";
 	  wspecial = L"nan";
-	  negative = 0;
+	  // fpnum_sign = 0;	Already zero
 	}
-      else if (__isinf (fpnum.dbl.d))
+      else if ((res = __isinf (fpnum.dbl.d)))
 	{
+	  fpnum_sign = res;
 	  special = "inf";
 	  wspecial = L"inf";
-
-	  negative = fpnum.dbl.d < 0;
 	}
       else
 	while (fpnum.dbl.d >= divisor && tag[1] != '\0')
@@ -178,14 +176,14 @@ __printf_size (FILE *fp, const struct printf_info *info,
     {
       int width = info->prec > info->width ? info->prec : info->width;
 
-      if (negative || info->showsign || info->space)
+      if (fpnum_sign < 0 || info->showsign || info->space)
 	--width;
       width -= 3;
 
       if (!info->left && width > 0)
 	PADN (' ', width);
 
-      if (negative)
+      if (fpnum_sign < 0)
 	outchar ('-');
       else if (info->showsign)
 	outchar ('+');

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                   |    5 +++++
 stdio-common/printf_fp.c    |   10 ++++++----
 stdio-common/printf_fphex.c |   16 ++++++++++------
 stdio-common/printf_size.c  |   24 +++++++++++-------------
 4 files changed, 32 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]