URL:
<http://savannah.gnu.org/bugs/?33144>
Summary: [PATCH] Support * as field width or precision in
printf
Project: GNU GRUB
Submitted by: joshtriplett
Submitted on: Fri 22 Apr 2011 12:52:51 AM PDT
Category: None
Severity: Major
Priority: 5 - Normal
Item Group: Feature Request
Status: None
Privacy: Public
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release:
Release: Bazaar - trunk
Reproducibility: None
Planned Release: None
_______________________________________________________
Details:
The attached patch implements support for * as the field width or precision in
printf, which obtains that field width or precision from the next va_arg.
This proves particularly useful for modifying %s: %.*s allows printing a
non-NUL-terminated string with a known length.
Tested with the following test cases, all of which worked:
grub_printf("|%*s|\n", -50, "left-aligned in 50");
grub_printf("|%*s|\n", 50, "right-aligned in 50");
grub_printf("|%.*s|\n", 5, "truncated");
grub_printf("|%.*s|\n", -5, "truncated");
grub_printf("|%*.*s|\n", 20, 5, "truncated");
grub_printf("|%*.*s|\n", -20, 5, "truncated");
grub_printf("|%50s|\n", "hardcoded 50");
grub_printf("|%-50s|\n", "hardcoded -50");
grub_printf("|%.5s|\n", "truncated");
ChangeLog entry:
2011-04-21 Josh Triplett <[email protected]>
2011-04-21 Burt Triplett <[email protected]>
* grub-core/kern/misc.c (grub_vsnprintf_real): Add support for '*'
as field width or precision.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Fri 22 Apr 2011 12:52:51 AM PDT Name: grub-printf-star.patch Size: 2kB
By: joshtriplett
<http://savannah.gnu.org/bugs/download.php?file_id=23288>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?33144>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Bug-grub mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-grub