[MacRuby-devel] [MacRuby] #608: rb_str_format() does not handle the "field width" flag for strings

MacRuby ruby-noreply at macosforge.org
Mon Feb 8 08:34:59 PST 2010


#608: rb_str_format() does not handle the "field width" flag for strings
----------------------------------------+-----------------------------------
 Reporter:  martinlagardette@…          |       Owner:  lsansonetti@…        
     Type:  defect                      |      Status:  new                  
 Priority:  minor                       |   Milestone:                       
Component:  MacRuby                     |    Keywords:                       
----------------------------------------+-----------------------------------
 Ruby:
 {{{
 ruby -e 'puts "%-10s%s" % ["a", "b"]'
 a         b
 }}}

 MacRuby SVN r3441:
 {{{
 macruby -e 'puts "%-10s%s" % ["a", "b"]'
 ab
 }}}

 This happens because `sprintf.cpp:rb_str_format:467` transforms `%s` into
 `%@`, and asks for formating to `CFStringCreateWithFormat()`, which does
 not handle the "field width" flag for Cocoa objects (`%@`).

 A possible fix might be to explicitly call `-[NSObject description]` and
 then get the UTF8/16 C string (which means `%s` would not be transformed
 into `%@`), but I'm not sure this is a pretty fix :D

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/608>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list