From: Charles Mills Date: 2004-10-06T07:31:47+09:00 Subject: Re: rdoc and C files again I also added support for rb_define_attr(). New diff is below... On Oct 5, 2004, at 2:50 PM, 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: 177c177 < @body = handle_tab_width(handle_ifdefs_in(body)) --- > @body = handle_ifdefs_in(body) 328,344d327 < @body.scan(%r{rb_define_attr\( < \s*([\w\.]+), < \s*"([^"]+)", < \s*(\d+), < \s*(\d+)\s*\) < (?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))? < }xm) do #" < |var_name, meth_name, attr_reader, attr_writer, source_file| < < #var_name = "rb_cObject" if var_name == "rb_mKernel" < < handle_method("method", var_name, meth_name, < nil, 0, source_file) unless attr_reader.to_i == 0 < handle_method("method", var_name, meth_name + '=', < nil, 1, source_file) unless attr_writer.to_i == 0 < end < 417c400 < find_body(meth_body, meth_obj, body) if meth_body --- > find_body(meth_body, meth_obj, body) 531,544d513 < < def handle_tab_width(body) < if /\t/ =~ body < tab_str = ' ' * Options.instance.tab_width < body.gsub(/\t/, tab_str) < #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 < body < end < end -Charlie