[前][次][番号順一覧][スレッド一覧]

ruby-changes:9683

From: akr <ko1@a...>
Date: Thu, 1 Jan 2009 15:08:53 +0900 (JST)
Subject: [ruby-changes:9683] Ruby:r21224 (trunk): * ext/socket/mkconstants.rb: add -o option.

akr	2009-01-01 15:08:41 +0900 (Thu, 01 Jan 2009)

  New Revision: 21224

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21224

  Log:
    * ext/socket/mkconstants.rb: add -o option.
    * ext/socket/depend: use mkconstants.rb with -o option.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/depend
    trunk/ext/socket/mkconstants.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21223)
+++ ChangeLog	(revision 21224)
@@ -1,3 +1,9 @@
+Thu Jan  1 15:07:56 2009  Tanaka Akira  <akr@f...>
+
+	* ext/socket/mkconstants.rb: add -o option.
+
+	* ext/socket/depend: use mkconstants.rb with -o option.
+
 Thu Jan  1 07:42:36 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* lib/singleton.rb: fix indentation of RDoc text.  [ruby-core:21029]
Index: ext/socket/depend
===================================================================
--- ext/socket/depend	(revision 21223)
+++ ext/socket/depend	(revision 21224)
@@ -6,4 +6,4 @@
 
 constants.h: $(srcdir)/mkconstants.rb
 	@echo "generating constants.h"
-	@$(RUBY) $(srcdir)/mkconstants.rb > $@
+	@$(RUBY) $(srcdir)/mkconstants.rb -o $@
Index: ext/socket/mkconstants.rb
===================================================================
--- ext/socket/mkconstants.rb	(revision 21223)
+++ ext/socket/mkconstants.rb	(revision 21224)
@@ -1,5 +1,25 @@
-$out ||= $stdout
+require 'optparse'
 
+opt = OptionParser.new
+
+opt.def_option('-h', 'help') {
+  puts opt
+  exit 0
+}
+
+opt_o = nil
+opt.def_option('-o FILE', 'specify output file') {|filename|
+  opt_o = filename
+}
+
+$out = ''
+def $out.puts(str="")
+  str += "\n" if /\n\z/ !~ str
+  self << str
+end
+
+opt.parse!
+
 # workaround for NetBSD, OpenBSD and etc.
 $out.puts("#define pseudo_AF_FTIP pseudo_AF_RTIP")
 
@@ -23,6 +43,14 @@
   end
 end
 
+if opt_o
+  File.open(opt_o, 'w') {|f|
+    f << $out
+  }
+else
+  $stdout << $out
+end
+
 __END__
 
 SOCK_STREAM

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]