[2116] 2009-04-15 Vladimir Serbinenko <[email protected]>

Vladimir Serbinenko <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2116
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2116
Author:   phcoder
Date:     2009-04-15 12:33:46 +0000 (Wed, 15 Apr 2009)
Log Message:
-----------
2009-04-15  Vladimir Serbinenko	 <[email protected]>

	use grub_lltoa instead of grub_itoa and grub_ltoa for all purposes
	
	* kern/misc.c (grub_itoa): Removed function
	(grub_ltoa): likewise
	(grub_vsprintf): use grub_lltoa

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/kern/misc.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-04-15 12:32:08 UTC (rev 2115)
+++ trunk/grub2/ChangeLog	2009-04-15 12:33:46 UTC (rev 2116)
@@ -1,5 +1,13 @@
 2009-04-15  Vladimir Serbinenko	 <[email protected]>
 
+	use grub_lltoa instead of grub_itoa and grub_ltoa for all purposes
+	
+	* kern/misc.c (grub_itoa): Removed function
+	(grub_ltoa): likewise
+	(grub_vsprintf): use grub_lltoa
+
+2009-04-15  Vladimir Serbinenko	 <[email protected]>
+
 	Restore grub-emu
 
 	* conf/i386-pc.rmk (grub_emu_SOURCES): add normal/handler.c

Modified: trunk/grub2/kern/misc.c
===================================================================
--- trunk/grub2/kern/misc.c	2009-04-15 12:32:08 UTC (rev 2115)
+++ trunk/grub2/kern/misc.c	2009-04-15 12:33:46 UTC (rev 2116)
@@ -565,56 +565,6 @@
     }
 }
 
-static char *
-grub_itoa (char *str, int c, unsigned n)
-{
-  unsigned base = (c == 'x') ? 16 : 10;
-  char *p;
-  
-  if ((int) n < 0 && c == 'd')
-    {
-      n = (unsigned) (-((int) n));
-      *str++ = '-';
-    }
-
-  p = str;
-  do
-    {
-      unsigned d = n % base;
-      *p++ = (d > 9) ? d + 'a' - 10 : d + '0';
-    }
-  while (n /= base);
-  *p = 0;
-
-  grub_reverse (str);
-  return p;
-}
-
-static char *
-grub_ltoa (char *str, int c, unsigned long n)
-{
-  unsigned long base = (c == 'x') ? 16 : 10;
-  char *p;
-
-  if ((long) n < 0 && c == 'd')
-    {
-      n = (unsigned long) (-((long) n));
-      *str++ = '-';
-    }
-
-  p = str;
-  do
-    {
-      unsigned long d = n % base;
-      *p++ = (d > 9) ? d + 'a' - 10 : d + '0';
-    }
-  while (n /= base);
-  *p = 0;
-
-  grub_reverse (str);
-  return p;
-}
-
 /* Divide N by D, return the quotient, and store the remainder in *R.  */
 grub_uint64_t
 grub_divmod64 (grub_uint64_t n, grub_uint32_t d, grub_uint32_t *r)
@@ -746,6 +696,7 @@
 	  int n;
 	  int longfmt = 0;
 	  int longlongfmt = 0;
+	  int unsig = 0;
 
 	  if (*fmt && *fmt =='-')
 	    {
@@ -804,9 +755,11 @@
 	      write_str ("0x");
 	      c = 'x';
 	      longlongfmt |= (sizeof (void *) == sizeof (long long));
-	      /* fall through */
+	      /* Fall through. */
 	    case 'x':
 	    case 'u':
+	      unsig = 1;
+	      /* Fall through. */
 	    case 'd':
 	      if (longlongfmt)
 		{
@@ -815,15 +768,25 @@
 		  ll = va_arg (args, long long);
 		  grub_lltoa (tmp, c, ll);
 		}
+	      else if (longfmt && unsig)
+		{
+		  unsigned long l = va_arg (args, unsigned long);
+		  grub_lltoa (tmp, c, l);
+		}
 	      else if (longfmt)
 		{
 		  long l = va_arg (args, long);
-		  grub_ltoa (tmp, c, l);
+		  grub_lltoa (tmp, c, l);
 		}
+	      else if (unsig)
+		{
+		  unsigned u = va_arg (args, unsigned);
+		  grub_lltoa (tmp, c, u);
+		}
 	      else
 		{
 		  n = va_arg (args, int);
-		  grub_itoa (tmp, c, n);
+		  grub_lltoa (tmp, c, n);
 		}
 	      if (! rightfill && grub_strlen (tmp) < format1)
 		write_fill (zerofill, format1 - grub_strlen (tmp));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.