From: Akinori MUSHA Date: 2007-02-11T01:35:22+09:00 Subject: [ruby-dev:30313] Re: [ruby-cvs:18927] Ruby:r11679: * ext/thread: Make style fixes (mostly de-K&R'ism) to match the At Sat, 10 Feb 2007 21:03:08 +0900, I wrote: > At Sat, 10 Feb 2007 00:00:44 +0900, > Nobuyoshi Nakada wrote: > > なかだです。 > > > > At Fri, 9 Feb 2007 20:48:35 +0900 (JST), > > knu@ruby-lang.org wrote in [ruby-cvs:18927]: > > > * ext/thread: Make style fixes (mostly de-K&R'ism) to match the > > > rest of the source code. > > > > fastthreadは1.8のcoreに取り込む予定かと思っていたのですが、1.8 > > ではむしろ、(少なくともcoreでは)K&R styleなんですが。 > >  そうでしたか。新規のコードは ANSI/ISO が望ましいと思っていました。 > >  K&R コンパイラしかないレガシー環境のサポートよりも、64bit環境等 > での宣言漏れによるエンバグのリスクの排除を優先したいんですが、 > 戻した方がいいですか。(digest もすでに de-K&R してしまった)  core に入れることは考えていませんでしたが、入れるときはこんな 感じで変換します。 print ARGF.read.gsub(/^((?:[^ \n].+\n)+)(\w+)\(([^\n]*)\)\s*/) { type = $1 func = $2 plist = $3 if plist == 'void' sprintf <<-EOS, type, func %s%s() EOS else params = plist.split(/,\s*/) decls = params.map { |s| " #{s};" }.join("\n") stype = type.gsub(/\s+/, " ") ptypes = params.map { |s| /\s*\w+$/.match(s); $` }.join(", ") pnames = params.map { |s| /(\w+)$/.match(s); $1 }.join(", ") sprintf <<-EOS, stype, func, ptypes, type, func, pnames, decls %s%s _((%s)); %s%s(%s) %s EOS end }  gcc や Emacs の cc-mode にこういう機能はないんですかねえ。 特に逆方向の変換。 -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Different eyes see different things, Different hearts beat on different strings -- But there are times for you and me when all such things agree"