----Next_Part(Sat_Mar_20_02:10:50_1999_893)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit ³±¤Ç¤¹¡£¤Í¤Ü¤±¤Æ¤Þ¤¹¡£ > > ruby-dev ¤ÎÊý¤Ç°ì»þ´üÏÃÂê¤Ë¤Ê¤Ã¤Æ¤¤¤¿ eRuby ¤ò¼ÂÁõ¤·¤Æ¤ß¤Þ¤·¤¿¡£ > > ...(ά)... > > HTML¤Îʸ äÄ귿ʸ¤ÎºîÀ®¤Ê¤É¤ËÊØÍø¤ ¤Ç¤¹¡£ > > ¤ªÌܱø¤·¤Ë¤É¤¦¤¾¡£ > ¤í¤¤¤í»È¤¨¤Ç¤¹¤è¤Í¡£LaTeX ¤Îʸ ˥ơ¼¥Ö¥ë¥³¥Þ¥ó¥É¤òÀ¸À®¤¹¤¨Â Òõâù ¥¹¥¯¥ê¥×¥È¤òËä¤á¹þ¤ó¤À¤ê¤È¤«¡£ ¤Ç¤¹¤è¤Í¡£¤¤¤í¤¤¤í±þÍѤ¬¤¢¤ê¤Ç¤¹¡£ ePerl ¤ÎÊý¤Ï¤É¤¦¤¤¤¦±þÍѤ¬¤¢¤ë¤ó¤À¤í¤¦¡£ ÅÚ´ô¤µ¤ó¡¢¥Ñ¥Ã¥Á¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤·¤¿¡£ ¤Û¤Ü¤Þ¤Þ¤¢¤Æ¤Þ¤·¤¿¡£ ¤Ä¤¤¤Ç¤Ë¼«Ê¬¤Ç¸«¤Ä¤±¤¿¥Ð¥°(result¤¬Æ°¤«¤Ê¤¤)¤Î µ¤¨Â ¤«¤Í¤Æ $SAFE ¤ò»ØÄꤷ¤Æ¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤Ç¤¤ë¤è¤¦¤Ë¤·¤Þ¤·¤¿¡£ ERb.new(ʸ»úÎó, [À°¿ô]) ¤ÇERb¤òÀ¸À®¤¹¤ë¤ÈÂèÆó°ú¿ô¤ò $SAFE ¤ËÀßÄꤷ¤Æ¼Â¹Ô¤·¤Þ¤¹¡£ CGI¤Ê¤É¤Ç»È¤¦»þ¤Ë°Â¿´¤Ç¤¤Þ¤¹¡£ ERb¤¬ $SAFE ¤ËÂбþ¤Ç¤¤¿¤Î¤Ç¡¢shttpsrv-1.04 ¤ò²þ¤¤·¤Æ eRuby ¥Õ¥¡¥¤¥ëÂбþ¤Ë¤·¤Æ¤ß¤Þ¤·¤¿¡£ ¶á¤¤¤¦¤Á¤Ë¥Ñ¥Ã¥Á¤ò ·¤Þ¤¹¡¨Â åÒõâ¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¤Ï¤Ê¤ó¤È¤¹¤ì¤ÐÎɤ¤¤Î¤Ç¤·¤ç¤¦? .rhtml?? > * `<% ÃÍ] %>' ¥¿¥°¤Ï `print [ÃÍ]' ¤ËÃÖ´¹¤µ¤ì¤Þ¤¹¤¬¡¢¤³¤ì¤À¤È snip > Ãͤò³ç¸Ì¤Ç¤Ç³ç¤Ã¤Æ `<% ÃÍ] %>' ¤¬ `print ([ÃÍ])' ¤ËÃÖ´¹¤µ¤ì > ¤ë¤è¤¦¤ËÊѹ¹¤·¤Þ¤·¤¿¡£ ¤¹¤ß¤Þ¤»¤ó¡£ ¥Ð¥°¤Ç¤·¤¿¡£ > * ³Þ¸¶ ´ðÇ·¤µ¤ó¤Î getoptlong ¥é¥¤¥Ö¥é¥ê > (http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/) > ¤ò»È¤Ã¤Æ¤¤¤¯¤Ä¤«¥ª¥×¥·¥ç¥ó¤òÄɲ䷤Ƥߤޤ·¤¿¡£ > -d, --debug ¥Ç¥Ð¥Ã¥°¥â¡¼¥É > -r ¥é¥¤¥Ö¥é¥ê¤Î¥í¡¼¥É > -v, --version ¥Ð¡¼¥¸¥ç¥ó¤Î > -w ¾éĹ¥â¡¼¥É > ¤³¤ì¤é¤Ï¤ï¤¿¤·¤¬¤¢¤Ã¤¿¤é¤¤¤¤¤Ê¤È»×¤Ã¤¿¥ª¥×¥·¥ç¥ó¤Ç¤¹¡£ getoptlong¤Ã¤ÆÉ¸ Ç¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤ë¤ó¤¸¤ã¤Ê¤«¤Ã¤¿¤ó¤Ç¤¹¤Í¡¨Â °ì ¨Â çåôïðô¤Ë ľ¤¹¤«Çº¤ó¤À¤Î¤Ç¤¹¤¬¤ ¤Þ¤Þ¤Ë¤·¤Þ¤·¤¿¡£ -S À°¿ô $SAFE ¤Î»ØÄê ¤òÄɲä·¤Þ¤·¤¿¡£ -- ³± ----Next_Part(Sat_Mar_20_02:10:50_1999_893)-- Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=erb.rb #!/usr/local/bin/ruby # $Id: erb.rb,v 1.19 1999/03/19 16:45:48 mas Exp $ # $Author: mas $ # Copyright (c) 1999 Masatoshi SEKI require 'enumre.rb' # http://www2a.biglobe.ne.jp/%7Eseki/ruby/enumre.rb class ERb Revision $Date: 1999/03/19 16:45:48 $' def version "erb.rb [#{ERb::Revision.split[1]}]" end module_function :version class StringIO def initialize(str ) @str tr.to_s end attr :str def print (*arg) if $, sep , else sep ' end write(arg.join(sep)) end def write(str) @str.concat(str) end def as_stdout(&proc) begin writer elf.new save > $> riter proc.call writer.str ensure $> ave if save end end module_function :as_stdout def as_stdout_safe(safe, &proc) begin writer elf.new save > $> riter th hread.start { $SAFE afe proc.call writer.str } Thread.join th th.value ensure $> ave if save end end module_function :as_stdout_safe end def pre_compile(s) list ] s.each_line do |line| line.gsub!(/(<%#)|(<% (<% )|( %>)/) do |m| "\n#{m}\n" end list + ine.split("\n") list.push("\n") end # list ¤«¤é¥³¥á¥ó¥È¤ò¼è¤ê ¨Â ìéóô ãïííåîô®çóõâ¨ìéóô© îé ðòéî¤ËÃÖ´¹ list print.gsub(list) { v print.matching_data[1].join ['<% ', "print (#{v})", ' %>'] } end module_function :pre_compile private :pre_compile def compile(s) cmdlist ] str_table ] list re_compile(s) # ÀèÆ¬¤«¤éstag¤Þ¤Ç¤òÃÖ´¹ list head.sub(list) { match head.matching_data match[1].join.each do |line| cmdlist.push("print #{line.dump}") end nil } list compile.gsub(list) { match compile.matching_data cmdlist.push(match[1].join) match[3].join.each do |line| cmdlist.push("print #{line.dump}") end nil } list.join.each do |line| cmdlist.push("print #{line.dump}") end cmdlist.join("\n") end module_function :compile private :compile def setup_compiler first RegexpFirst.new stag RegexpEq.new('<% ') etag RegexpEq.new(' %>') commenttag RegexpEq.new('<%#') printtag RegexpEq.new('<% any RegexpAny.new.repeat(0, nil).greedy(false) notstag RegexpEq.new('<% ').negate.repeat(0, nil).greedy(true) @head Regexp.new([first, notstag]); @comment Regexp.new([commenttag, any, etag]) @print Regexp.new([printtag, any, etag]) @compile Regexp.new([stag, any, etag, notstag]) end module_function :setup_compiler private :setup_compiler def initialize(str, safe_level l) @src Rb.compile(str) @safe_level afe_level end attr :src setup_compiler # ¼Â¹Ô¤·¡¢·ë²Ì¤ò°õ»ú¤¹¤ë def run(b PLEVEL_BINDING) if @safe_level print self.result(b) else eval(@src, b) end end # ¼Â¹Ô¤·¡¢·ë²Ì¤òʸ»úÎó¤ÇÊÖ¤¹ def result(b PLEVEL_BINDING) if @safe_level StringIO.as_stdout_safe(@safe_level) { eval(@src, b) } else StringIO.as_stdout { eval(@src, b) } end end end if __FILE__ $0 require "getoptlong" opt_parser etoptLong.new([ "-x", GetoptLong::NO_ARGUMENT ], [ "-n", GetoptLong::NO_ARGUMENT ], [ "-d", "--debug", GetoptLong::NO_ARGUMENT ], [ "-S", GetoptLong::REQUIRED_ARGUMENT ], [ "-r", GetoptLong::REQUIRED_ARGUMENT ], [ "-v", "--version", GetoptLong::NO_ARGUMENT ], [ "-w", GetoptLong::NO_ARGUMENT ]) opt_parser.each_option do |name, arg| case name when "-x" # ruby source $output rue when "-n" # line number $number rue when "-w" # verbose $VERBOSE rue when "-v" # version STDERR.puts ERb.version exit when "-d" # debug $DEBUG rue when "-r" # require require arg when "-S" # safe level $safe_level rg.to_i end end src <.read exit 1 unless src erb Rb.new(src, $safe_level) if $output if $number l for line in erb.src puts "%3d %s"%[l, line] l + end else puts erb.src end else erb.run end end ----Next_Part(Sat_Mar_20_02:10:50_1999_893)----