about summary refs log tree commit diff
path: root/stdio-common/_itoa.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-05-05 17:08:26 +0000
committerUlrich Drepper <drepper@redhat.com>1999-05-05 17:08:26 +0000
commit4f8dbcb126883c92d33d49c86365a1fb1e54696a (patch)
tree0bdac0d2659e6b57ce50ad5994301c12ace483e8 /stdio-common/_itoa.c
parentbc9ffe71f95d21d8aa4107838d7c7f912863c3b7 (diff)
downloadglibc-4f8dbcb126883c92d33d49c86365a1fb1e54696a.tar.gz
glibc-4f8dbcb126883c92d33d49c86365a1fb1e54696a.tar.xz
glibc-4f8dbcb126883c92d33d49c86365a1fb1e54696a.zip
Update.
	* stdio-common/_itoa.c (_itoa): Fix special 32bit platform case
	with specific bases and only few bits set in second word.
Diffstat (limited to 'stdio-common/_itoa.c')
-rw-r--r--stdio-common/_itoa.c83
1 files changed, 43 insertions, 40 deletions
diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c
index af4836036f..3a7cd78003 100644
--- a/stdio-common/_itoa.c
+++ b/stdio-common/_itoa.c
@@ -175,46 +175,49 @@ _itoa (value, buflim, base, upper_case)
 
   switch (base)
     {
-#define RUN_2N(BITS)							  \
-      do								  \
-        {								  \
-	  /* `unsigned long long int' always has 64 bits.  */		  \
-	  mp_limb_t work_hi = value >> (64 - BITS_PER_MP_LIMB);		  \
-									  \
-	  if (BITS_PER_MP_LIMB == 32)					  \
-	    {								  \
-	      if (work_hi != 0)						  \
-		{							  \
-		  mp_limb_t work_lo;					  \
-		  int cnt;						  \
-									  \
-		  work_lo = value & 0xfffffffful;			  \
-		  for (cnt = BITS_PER_MP_LIMB / BITS; cnt > 0; --cnt)	  \
-		    {							  \
-		      *--bp = digits[work_lo & ((1ul << BITS) - 1)];	  \
-		      work_lo >>= BITS;					  \
-		    }							  \
-		  if (BITS_PER_MP_LIMB % BITS != 0)			  \
-		    {							  \
-		      work_lo						  \
-			|= ((work_hi					  \
-			     & ((1 << (BITS - BITS_PER_MP_LIMB%BITS))	  \
-				- 1))					  \
-			    << BITS_PER_MP_LIMB % BITS);		  \
-		      *--bp = digits[work_lo];				  \
-		      work_hi >>= BITS - BITS_PER_MP_LIMB % BITS;	  \
-		    }							  \
-		}							  \
-	      else							  \
-		work_hi = value & 0xfffffffful;				  \
-	    }								  \
-	  do								  \
-	    {								  \
-	      *--bp = digits[work_hi & ((1 << BITS) - 1)];		  \
-	      work_hi >>= BITS;						  \
-	    }								  \
-	  while (work_hi != 0);						  \
-	}								  \
+#define RUN_2N(BITS) \
+      do								      \
+        {								      \
+	  /* `unsigned long long int' always has 64 bits.  */		      \
+	  mp_limb_t work_hi = value >> (64 - BITS_PER_MP_LIMB);		      \
+									      \
+	  if (BITS_PER_MP_LIMB == 32)					      \
+	    {								      \
+	      if (work_hi != 0)						      \
+		{							      \
+		  mp_limb_t work_lo;					      \
+		  int cnt;						      \
+									      \
+		  work_lo = value & 0xfffffffful;			      \
+		  for (cnt = BITS_PER_MP_LIMB / BITS; cnt > 0; --cnt)	      \
+		    {							      \
+		      *--bp = digits[work_lo & ((1ul << BITS) - 1)];	      \
+		      work_lo >>= BITS;					      \
+		    }							      \
+		  if (BITS_PER_MP_LIMB % BITS != 0)			      \
+		    {							      \
+		      work_lo						      \
+			|= ((work_hi					      \
+			     & ((1 << (BITS - BITS_PER_MP_LIMB%BITS))	      \
+				- 1))					      \
+			    << BITS_PER_MP_LIMB % BITS);		      \
+		      work_hi >>= BITS - BITS_PER_MP_LIMB % BITS;	      \
+		      if (work_hi == 0)					      \
+			work_hi = work_lo;				      \
+		      else						      \
+			*--bp = digits[work_lo];			      \
+		    }							      \
+		}							      \
+	      else							      \
+		work_hi = value & 0xfffffffful;				      \
+	    }								      \
+	  do								      \
+	    {								      \
+	      *--bp = digits[work_hi & ((1 << BITS) - 1)];		      \
+	      work_hi >>= BITS;						      \
+	    }								      \
+	  while (work_hi != 0);						      \
+	}								      \
       while (0)
     case 8:
       RUN_2N (3);