From: Dave Thomas Date: 2004-10-06T11:17:44+09:00 Subject: Re: rdoc and C files again On Oct 5, 2004, at 16:50, Charles Mills wrote: > Looks like rdoc doesn't replace tabs in .c files like expected (when > using the -w option). > I added a handle_tab_width() function to parse_c.rb and it seems to > work fine. > Here is the diff <1.9version> output: > > $ diff parse_c.rb > /Users/boson/local/lib/ruby/1.9/rdoc/parsers/parse_c.rb > 177c177 > < @body = handle_tab_width(handle_ifdefs_in(body)) > --- > > @body = handle_ifdefs_in(body) > 514,527d513 > < > < def handle_tab_width(body) > < if /\t/ =~ body > < tab_str = ' ' * > Options.instance.tab_width > < body.gsub(/\t/, tab_str) This doesn't work if you have abcdef That's why we have the somewhat uglier: > < #tab_width = Options.instance.tab_width > < #content = content.split(/\n/).map do > |line| > < #1 while line.gsub!(/\t+/) { ' ' * > (tab_width*$&.length - $`.length % tab_width)} && $~ #` > < # line > < #end .join("\n") > < else Cheers Dave