bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #33144] [PATCH] Support * as field width or precision in printf


From: Josh Triplett
Subject: [bug #33144] [PATCH] Support * as field width or precision in printf
Date: Fri, 22 Apr 2011 07:52:52 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20110323 Firefox/4.0 Iceweasel/4.0

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  <address@hidden>
2011-04-21  Burt Triplett  <address@hidden>

        * 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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]