ruby-changes:3952
From: ko1@a...
Date: Tue, 12 Feb 2008 15:18:37 +0900 (JST)
Subject: [ruby-changes:3952] naruse - Ruby:r15442 (trunk): * ext/json/lib/json/pure/generator.rb,
naruse 2008-02-12 15:18:06 +0900 (Tue, 12 Feb 2008) New Revision: 15442 Modified files: trunk/ChangeLog trunk/ext/json/lib/json/pure/generator.rb trunk/ext/json/lib/json/pure/parser.rb trunk/ext/openssl/lib/openssl/x509.rb trunk/ext/win32ole/sample/olegen.rb trunk/lib/date/format.rb trunk/lib/irb/context.rb trunk/lib/irb/workspace.rb trunk/lib/net/http.rb trunk/lib/net/imap.rb trunk/lib/rdoc/generator.rb trunk/lib/rdoc/markup/to_html.rb trunk/lib/rdoc/markup/to_latex.rb trunk/lib/rdoc/parsers/parse_c.rb trunk/lib/rdoc/ri/formatter.rb trunk/lib/rexml/parsers/baseparser.rb trunk/lib/rexml/quickpath.rb trunk/lib/rexml/text.rb trunk/lib/rss/parser.rb trunk/lib/uri/common.rb trunk/lib/uri/generic.rb trunk/lib/webrick/httpresponse.rb trunk/lib/webrick/httpservlet/filehandler.rb trunk/lib/yaml/baseemitter.rb trunk/lib/yaml/encoding.rb Log: * ext/json/lib/json/pure/generator.rb, ext/json/lib/json/pure/parser.rb, ext/openssl/lib/openssl/x509.rb, ext/win32ole/sample/olegen.rb, lib/date/format.rb, lib/irb/context.rb, lib/irb/workspace.rb, lib/net/http.rb, lib/net/imap.rb, lib/rdoc/generator.rb, lib/rdoc/markup/to_html.rb, lib/rdoc/markup/to_latex.rb, lib/rdoc/parsers/parse_c.rb, lib/rdoc/ri/formatter.rb, lib/rexml/parsers/baseparser.rb, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rss/parser.rb, lib/uri/common.rb, lib/uri/generic.rb, lib/webrick/httpresponse.rb, lib/webrick/httpservlet/filehandler.rb, lib/yaml/baseemitter.rb, lib/yaml/encoding.rb: performance tuning arround String#gsub. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/date/format.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/openssl/lib/openssl/x509.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/json/lib/json/pure/parser.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rexml/text.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/ri/formatter.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/webrick/httpresponse.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/imap.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/yaml/baseemitter.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/uri/generic.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/uri/common.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/generator.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rexml/quickpath.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/markup/to_latex.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/webrick/httpservlet/filehandler.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rss/parser.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rexml/parsers/baseparser.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/markup/to_html.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/json/lib/json/pure/generator.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/yaml/encoding.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/irb/workspace.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/http.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/parsers/parse_c.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/irb/context.rb?r1=15442&r2=15441&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/win32ole/sample/olegen.rb?r1=15442&r2=15441&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15441) +++ ChangeLog (revision 15442) @@ -1,3 +1,17 @@ +Tue Feb 12 15:11:47 2008 NARUSE, Yui <naruse@r...> + + * ext/json/lib/json/pure/generator.rb, + ext/json/lib/json/pure/parser.rb, ext/openssl/lib/openssl/x509.rb, + ext/win32ole/sample/olegen.rb, lib/date/format.rb, lib/irb/context.rb, + lib/irb/workspace.rb, lib/net/http.rb, lib/net/imap.rb, + lib/rdoc/generator.rb, lib/rdoc/markup/to_html.rb, + lib/rdoc/markup/to_latex.rb, lib/rdoc/parsers/parse_c.rb, + lib/rdoc/ri/formatter.rb, lib/rexml/parsers/baseparser.rb, + lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rss/parser.rb, + lib/uri/common.rb, lib/uri/generic.rb, lib/webrick/httpresponse.rb, + lib/webrick/httpservlet/filehandler.rb, lib/yaml/baseemitter.rb, + lib/yaml/encoding.rb: performance tuning arround String#gsub. + Tue Feb 12 12:16:45 2008 Yukihiro Matsumoto <matz@r...> * string.c (rb_str_hash_cmp): lighter version of rb_str_cmp() for Index: lib/webrick/httpservlet/filehandler.rb =================================================================== --- lib/webrick/httpservlet/filehandler.rb (revision 15441) +++ lib/webrick/httpservlet/filehandler.rb (revision 15442) @@ -371,7 +371,7 @@ if name == ".." dname = "Parent Directory" elsif name.size > 25 - dname = name.sub(/^(.{23})(.*)/){ $1 + ".." } + dname = name.sub(/^(.{23})(?:.*)/, '\1..') else dname = name end Index: lib/webrick/httpresponse.rb =================================================================== --- lib/webrick/httpresponse.rb (revision 15441) +++ lib/webrick/httpresponse.rb (revision 15442) @@ -169,7 +169,7 @@ if @http_version.major > 0 data = status_line() @header.each{|key, value| - tmp = key.gsub(/\bwww|^te$|\b\w/){|s| s.upcase } + tmp = key.gsub(/\bwww|^te$|\b\w/){ $&.upcase } data << "#{tmp}: #{value}" << CRLF } @cookies.each{|cookie| Index: lib/rexml/parsers/baseparser.rb =================================================================== --- lib/rexml/parsers/baseparser.rb (revision 15441) +++ lib/rexml/parsers/baseparser.rb (revision 15442) @@ -482,7 +482,7 @@ rv.gsub!( /\r\n?/, "\n" ) matches = rv.scan( REFERENCE_RE ) return rv if matches.size == 0 - rv.gsub!( /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {|m| + rv.gsub!( /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) { m=$1 m = "0#{m}" if m[0] == ?x [Integer(m)].pack('U*') Index: lib/rexml/quickpath.rb =================================================================== --- lib/rexml/quickpath.rb (revision 15441) +++ lib/rexml/quickpath.rb (revision 15442) @@ -170,15 +170,12 @@ rest = path[ind+1..-1] # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c' - predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u ) { - "#$1 #$2 #$3 and #$3 #$4 #$5" - } + predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u, + '\1 \2 \3 and \3 \4 \5' ) # Let's do some Ruby trickery to avoid some work: predicate.gsub!( /&/u, "&&" ) predicate.gsub!( /=/u, "==" ) - predicate.gsub!( /@(\w[-\w.]*)/u ) { - "attribute(\"#$1\")" - } + predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' ) predicate.gsub!( /\bmod\b/u, "%" ) predicate.gsub!( /\b(\w[-\w.]*\()/u ) { fname = $1 Index: lib/rexml/text.rb =================================================================== --- lib/rexml/text.rb (revision 15441) +++ lib/rexml/text.rb (revision 15442) @@ -345,7 +345,7 @@ copy.gsub!( SETUTITSBUS[2], SLAICEPS[2] ) copy.gsub!( SETUTITSBUS[3], SLAICEPS[3] ) copy.gsub!( SETUTITSBUS[4], SLAICEPS[4] ) - copy.gsub!( /�*((?:\d+)|(?:x[a-f0-9]+));/ ) {|m| + copy.gsub!( /�*((?:\d+)|(?:x[a-f0-9]+));/ ) { m=$1 #m='0' if m=='' m = "0#{m}" if m[0] == ?x @@ -380,7 +380,8 @@ # Unescapes all possible entities def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil ) - string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) { |ref| + string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) { + ref = $& if ref[1] == ?# if ref[2] == ?x [ref[3...-1].to_i(16)].pack('U*') Index: lib/rss/parser.rb =================================================================== --- lib/rss/parser.rb (revision 15441) +++ lib/rss/parser.rb (revision 15442) @@ -199,9 +199,7 @@ name = (@@class_names[uri] || {})[tag_name] return name if name - tag_name = tag_name.gsub(/[_\-]([a-z]?)/) do - $1.upcase - end + tag_name.gsub!(/[_\-]([a-z]?)/){$1.upcase} tag_name[0, 1].upcase + tag_name[1..-1] end Index: lib/irb/context.rb =================================================================== --- lib/irb/context.rb (revision 15441) +++ lib/irb/context.rb (revision 15442) @@ -233,7 +233,7 @@ def inspect array = [] for ivar in instance_variables.sort{|e1, e2| e1 <=> e2} - name = ivar.sub(/^@(.*)$/){$1} + name = ivar.sub(/^@(.*)$/, '\1') val = instance_eval(ivar) case ivar when *NOPRINTING_IVARS Index: lib/irb/workspace.rb =================================================================== --- lib/irb/workspace.rb (revision 15441) +++ lib/irb/workspace.rb (revision 15442) @@ -95,7 +95,7 @@ return nil if bt =~ /irb\/.*\.rb/ when 3 return nil if bt =~ /irb\/.*\.rb/ - bt.sub!(/:\s*in `irb_binding'/){""} + bt.sub!(/:\s*in `irb_binding'/, '') end bt end Index: lib/rdoc/parsers/parse_c.rb =================================================================== --- lib/rdoc/parsers/parse_c.rb (revision 15441) +++ lib/rdoc/parsers/parse_c.rb (revision 15442) @@ -766,7 +766,7 @@ # Removes #ifdefs that would otherwise confuse us def handle_ifdefs_in(body) - body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m) { $1 } + body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m, '\1') end end Index: lib/rdoc/generator.rb =================================================================== --- lib/rdoc/generator.rb (revision 15441) +++ lib/rdoc/generator.rb (revision 15442) @@ -523,7 +523,7 @@ def http_url(full_name, prefix) path = full_name.dup - path.gsub!(/<<\s*(\w*)/) { "from-#$1" } if path['<<'] + path.gsub!(/<<\s*(\w*)/, 'from-\1') if path['<<'] ::File.join(prefix, path.split("::")) + ".html" end @@ -704,8 +704,8 @@ end def filename_to_label - @context.file_relative_name.gsub(/%|\/|\?|\#/) do |s| - '%%%x' % s[0].unpack('C') + @context.file_relative_name.gsub(/%|\/|\?|\#/) do + '%%%x' % $&[0].unpack('C') end end Index: lib/rdoc/markup/to_latex.rb =================================================================== --- lib/rdoc/markup/to_latex.rb (revision 15441) +++ lib/rdoc/markup/to_latex.rb (revision 15442) @@ -227,14 +227,14 @@ gsub(/\.\.\.\./, '.\ldots{}').gsub(/\.\.\./, '\ldots{}'). # convert single closing quote - gsub(%r{([^ \t\r\n\[\{\(])\'}) { "#$1'" }. - gsub(%r{\'(?=\W|s\b)}) { "'" }. + gsub(%r{([^ \t\r\n\[\{\(])\'}, '\1\''). + gsub(%r{\'(?=\W|s\b)}, "'" ). # convert single opening quote gsub(/'/, '`'). # convert double closing quote - gsub(%r{([^ \t\r\n\[\{\(])\"(?=\W)}) { "#$1''" }. + gsub(%r{([^ \t\r\n\[\{\(])\"(?=\W)}, "\\1''"). # convert double opening quote gsub(/"/, "``"). Index: lib/rdoc/markup/to_html.rb =================================================================== --- lib/rdoc/markup/to_html.rb (revision 15441) +++ lib/rdoc/markup/to_html.rb (revision 15442) @@ -200,14 +200,14 @@ gsub(/\.\.\.\./, '.…').gsub(/\.\.\./, '…'). # convert single closing quote - gsub(%r{([^ \t\r\n\[\{\(])\'}) { "#$1’" }. - gsub(%r{\'(?=\W|s\b)}) { "’" }. + gsub(%r{([^ \t\r\n\[\{\(])\'}, '\1’'). + gsub(%r{\'(?=\W|s\b)}, '’'). # convert single opening quote gsub(/'/, '‘'). # convert double closing quote - gsub(%r{([^ \t\r\n\[\{\(])\'(?=\W)}) { "#$1”" }. + gsub(%r{([^ \t\r\n\[\{\(])\'(?=\W)}, '\1”'). # convert double opening quote gsub(/'/, '“'). Index: lib/rdoc/ri/formatter.rb =================================================================== --- lib/rdoc/ri/formatter.rb (revision 15441) +++ lib/rdoc/ri/formatter.rb (revision 15442) @@ -87,22 +87,22 @@ # Convert HTML entities back to ASCII def conv_html(txt) - txt. - gsub(/>/, '>'). - gsub(/</, '<'). - gsub(/"/, '"'). - gsub(/&/, '&') + txt = txt.gsub(/>/, '>') + txt.gsub!(/</, '<') + txt.gsub!(/"/, '"') + txt.gsub!(/&/, '&') + txt end ## # Convert markup into display form def conv_markup(txt) - txt. - gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } . - gsub(%r{<code>(.*?)</code>}) { "+#$1+" } . - gsub(%r{<b>(.*?)</b>}) { "*#$1*" } . - gsub(%r{<em>(.*?)</em>}) { "_#$1_" } + txt = txt.gsub(%r{<tt>(.*?)</tt>}, '+\1+') + txt.gsub!(%r{<code>(.*?)</code>}, '+\1+') + txt.gsub!(%r{<b>(.*?)</b>}, '*\1*') + txt.gsub!(%r{<em>(.*?)</em>}, '_\1_') + txt end def display_list(list) @@ -548,11 +548,11 @@ end def escape(str) - str. - gsub(/&/n, '&'). - gsub(/\"/n, '"'). - gsub(/>/n, '>'). - gsub(/</n, '<') + str = str.gsub(/&/n, '&') + str.gsub!(/\"/n, '"') + str.gsub!(/>/n, '>') + str.gsub!(/</n, '<') + str end end Index: lib/uri/common.rb =================================================================== --- lib/uri/common.rb (revision 15441) +++ lib/uri/common.rb (revision 15442) @@ -285,7 +285,8 @@ # perhaps unsafe is String object unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false, 'N') end - str.gsub(unsafe) do |us| + str.gsub(unsafe) do + us = $& tmp = '' us.each_byte do |uc| tmp << sprintf('%%%02X', uc) Index: lib/uri/generic.rb =================================================================== --- lib/uri/generic.rb (revision 15441) +++ lib/uri/generic.rb (revision 15442) @@ -1105,7 +1105,7 @@ @@to_s = Kernel.instance_method(:to_s) def inspect - @@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"} + @@to_s.bind(self).call.sub!(/>\z/, " URL:#{self}>") end def coerce(oth) Index: lib/date/format.rb =================================================================== --- lib/date/format.rb (revision 15441) +++ lib/date/format.rb (revision 15442) @@ -215,9 +215,9 @@ :emit_a, :emit_ad, :emit_au def strftime(fmt='%F') - fmt.gsub(/%([-_0^#]+)?(\d+)?([EO]?(?::{1,3}z|.))/m) do |m| + fmt.gsub(/%([-_0^#]+)?(\d+)?([EO]?(?::{1,3}z|.))/m) do f = {} - a = $& + m = $& s, w, c = $1, $2, $3 if s s.scan(/./) do |k| @@ -327,7 +327,7 @@ when '%'; emit_a('%', 0, f) when '+'; emit_a(strftime('%a %b %e %H:%M:%S %Z %Y'), 0, f) else - a + m end end end Index: lib/net/http.rb =================================================================== --- lib/net/http.rb (revision 15441) +++ lib/net/http.rb (revision 15442) @@ -1521,7 +1521,7 @@ private :encode_kvpair def urlencode(str) - str.gsub(/[^a-zA-Z0-9_\.\-]/n) {|s| sprintf('%%%02x', s[0]) } + str.gsub(/[^a-zA-Z0-9_\.\-]/n) { sprintf('%%%02x', $&[0]) } end private :urlencode Index: lib/net/imap.rb =================================================================== --- lib/net/imap.rb (revision 15441) +++ lib/net/imap.rb (revision 15442) @@ -857,11 +857,11 @@ # Encode a string from UTF-8 format to modified UTF-7. def self.encode_utf7(s) - return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { |x| + return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { if $1 "&-" else - base64 = [x.unpack("U*").pack("n*")].pack("m") + base64 = [$&.unpack("U*").pack("n*")].pack("m") "&" + base64.delete("=\n").tr("/", ",") + "-" end }.force_encoding("ASCII-8BIT") Index: lib/yaml/encoding.rb =================================================================== --- lib/yaml/encoding.rb (revision 15441) +++ lib/yaml/encoding.rb (revision 15442) @@ -10,8 +10,8 @@ def YAML.escape( value, skip = "" ) value.gsub( /\\/, "\\\\\\" ). gsub( /"/, "\\\"" ). - gsub( /([\x00-\x1f])/ ) do |x| - skip[x] || ESCAPES[ x.unpack("C")[0] ] + gsub( /([\x00-\x1f])/ ) do + skip[$&] || ESCAPES[ $&.unpack("C")[0] ] end end @@ -19,7 +19,7 @@ # Unescape the condenses escapes # def YAML.unescape( value ) - value.gsub( /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ ) { |x| + value.gsub( /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ ) { if $3 ["#$3".hex ].pack('U*') elsif $2 Index: lib/yaml/baseemitter.rb =================================================================== --- lib/yaml/baseemitter.rb (revision 15441) +++ lib/yaml/baseemitter.rb (revision 15442) @@ -132,7 +132,7 @@ # Folding paragraphs within a column # def fold( value ) - value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]|\Z))|$)/ ) do |s| + value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]|\Z))|$)/ ) do $1 || $2 + ( $3 || "\n" ) end end Index: ext/win32ole/sample/olegen.rb =================================================================== --- ext/win32ole/sample/olegen.rb (revision 15441) +++ ext/win32ole/sample/olegen.rb (revision 15442) @@ -230,7 +230,7 @@ v.visible? && v.variable_kind == 'CONSTANT' }.each do |v| io.print " " - io.print v.name.sub(/^./){|c| c.upcase} + io.print v.name.sub(/^./){$&.upcase} io.print " = " io.puts v.value end Index: ext/json/lib/json/pure/generator.rb =================================================================== --- ext/json/lib/json/pure/generator.rb (revision 15441) +++ ext/json/lib/json/pure/generator.rb (revision 15442) @@ -40,7 +40,7 @@ # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with # UTF16 big endian characters as \u????, and return it. def utf8_to_json(string) # :nodoc: - string = string.gsub(/["\\\/\x0-\x1f]/) { |c| MAP[c] } + string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] } string.gsub!(/( (?: [\xc2-\xdf][\x80-\xbf] | Index: ext/json/lib/json/pure/parser.rb =================================================================== --- ext/json/lib/json/pure/parser.rb (revision 15441) +++ ext/json/lib/json/pure/parser.rb (revision 15442) @@ -122,7 +122,8 @@ def parse_string if scan(STRING) return '' if self[1].empty? - self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c| + self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do + c = $& if u = UNESCAPE_MAP[c[1]] u else # \uXXXX Index: ext/openssl/lib/openssl/x509.rb =================================================================== --- ext/openssl/lib/openssl/x509.rb (revision 15441) +++ ext/openssl/lib/openssl/x509.rb (revision 15442) @@ -82,7 +82,8 @@ def expand_pair(str) return nil unless str - return str.gsub(Pair){|pair| + return str.gsub(Pair){ + pair = $& case pair.size when 2 then pair[1,1] when 3 then Integer("0x#{pair[1,2]}").chr @@ -93,7 +94,7 @@ def expand_hexstring(str) return nil unless str - der = str.gsub(HexPair){|hex| Integer("0x#{hex}").chr } + der = str.gsub(HexPair){$&.to_i(16).chr } a1 = OpenSSL::ASN1.decode(der) return a1.value, a1.tag end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/