BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000624 [BusyBox] New Features feature always 01-05-06 06:11 01-06-06 12:28
Reporter Colin Watson View Status public  
Assigned To BusyBox
Priority normal Resolution fixed  
Status closed   Product Version svn
Summary 0000624: printf: please support POSIX quoted-argument-character syntax
Description POSIX documents (http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html) [^] the following syntax for printf arguments:

  The argument operands shall be treated as strings if the corresponding
  conversion specifier is b, c, or s ; otherwise, it shall be evaluated
  as a C constant, as described by the ISO C standard, with the
  following extensions:

    [...]
    * If the leading character is a single-quote or double-quote, the
      value shall be the numeric value in the underlying codeset of the
      character following the single-quote or double-quote.

I found myself wanting this recently in order to convert non-devfs disk device names into indices for display in a partitioning tool (e.g. /dev/hde => "IDE2 master (hde)"). Lacking any other way to map from a-z to 0-25 in shell that I can think of, it was going to have to be a messy sequence of sed commands until somebody pointed out this syntax to me. With this patch, I can just do:

  printf '%d\n' "'$character"

... to map from a-z to 0-25, which is much nicer. The small attached patch implements this feature; I've checked it against the printf implementation in GNU coreutils.
Additional Information
Attached Files  printf-quote-codepoint.patch [^] (998 bytes) 01-05-06 06:11

- Relationships

- Notes
(0000867)
landley
01-06-06 12:28

svn 13134
 

- Issue History
Date Modified Username Field Change
01-05-06 06:11 Colin Watson New Issue
01-05-06 06:11 Colin Watson Status new => assigned
01-05-06 06:11 Colin Watson Assigned To  => BusyBox
01-05-06 06:11 Colin Watson File Added: printf-quote-codepoint.patch
01-06-06 12:28 landley Status assigned => closed
01-06-06 12:28 landley Note Added: 0000867
01-06-06 12:28 landley Resolution open => fixed
01-06-06 12:28 landley Fixed in Version  => svn


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker