[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[1954] 2009-01-22 Christian Franke <address@hidden>
From: |
Christian Franke |
Subject: |
[1954] 2009-01-22 Christian Franke <address@hidden> |
Date: |
Thu, 22 Jan 2009 20:27:52 +0000 |
Revision: 1954
http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=1954
Author: chrfranke
Date: 2009-01-22 20:27:52 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
2009-01-22 Christian Franke <address@hidden>
* kern/misc.c (grub_vsprintf): Fix size and termination of `format2'
(precision) digit string. Allow `.format2' without `format1' (width).
Limit input chars for `%s' output to `format2' if specified. This is
compatible with standard printf ().
Modified Paths:
--------------
trunk/grub2/ChangeLog
trunk/grub2/kern/misc.c
Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog 2009-01-22 20:15:05 UTC (rev 1953)
+++ trunk/grub2/ChangeLog 2009-01-22 20:27:52 UTC (rev 1954)
@@ -1,5 +1,12 @@
2009-01-22 Christian Franke <address@hidden>
+ * kern/misc.c (grub_vsprintf): Fix size and termination of `format2'
+ (precision) digit string. Allow `.format2' without `format1' (width).
+ Limit input chars for `%s' output to `format2' if specified. This is
+ compatible with standard printf ().
+
+2009-01-22 Christian Franke <address@hidden>
+
* disk/ata.c (grub_ata_wait_status): Replace by ...
(grub_ata_wait_not_busy): ... this function. Checks only BSY bit,
other status bits may be invalid while BSY is asserted.
Modified: trunk/grub2/kern/misc.c
===================================================================
--- trunk/grub2/kern/misc.c 2009-01-22 20:15:05 UTC (rev 1953)
+++ trunk/grub2/kern/misc.c 2009-01-22 20:27:52 UTC (rev 1954)
@@ -700,7 +700,7 @@
char tmp[32];
char *p;
unsigned int format1 = 0;
- unsigned int format2 = 3;
+ unsigned int format2 = ~ 0U;
char zerofill = ' ';
int rightfill = 0;
int n;
@@ -727,20 +727,22 @@
zerofill = '0';
format1 = grub_strtoul (s, 0, 10);
fmt = p;
- if (*p && *p == '.')
+ }
+
+ if (*p && *p == '.')
+ {
+ p++;
+ fmt++;
+ while (*p && grub_isdigit (*p))
+ p++;
+
+ if (p > fmt)
{
- p++;
- fmt++;
- while (*p && grub_isdigit (*p))
- p++;
-
- if (p > fmt)
- {
- char fstr[p - fmt];
- grub_strncpy (fstr, fmt, p - fmt);
- format2 = grub_strtoul (fstr, 0, 10);
- fmt = p;
- }
+ char fstr[p - fmt + 1];
+ grub_strncpy (fstr, fmt, p - fmt);
+ fstr[p - fmt] = 0;
+ format2 = grub_strtoul (fstr, 0, 10);
+ fmt = p;
}
}
@@ -847,13 +849,19 @@
p = va_arg (args, char *);
if (p)
{
- if (!rightfill && grub_strlen (p) < format1)
- write_fill (zerofill, format1 - grub_strlen (p));
-
- write_str (p);
-
- if (rightfill && grub_strlen (p) < format1)
- write_fill (zerofill, format1 - grub_strlen (p));
+ grub_size_t len = 0;
+ while (len < format2 && p[len])
+ len++;
+
+ if (!rightfill && len < format1)
+ write_fill (zerofill, format1 - len);
+
+ grub_size_t i;
+ for (i = 0; i < len; i++)
+ write_char (*p++);
+
+ if (rightfill && len < format1)
+ write_fill (zerofill, format1 - len);
}
else
write_str ("(null)");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [1954] 2009-01-22 Christian Franke <address@hidden>,
Christian Franke <=