ruby-changes:15356
From: naruse <ko1@a...>
Date: Wed, 7 Apr 2010 12:00:01 +0900 (JST)
Subject: [ruby-changes:15356] Ruby:r27246 (trunk): * lib/rexml/quickpath.rb (REXML::QuickPath::predicate): fix regexp.
naruse 2010-04-07 11:59:33 +0900 (Wed, 07 Apr 2010) New Revision: 27246 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27246 Log: * lib/rexml/quickpath.rb (REXML::QuickPath::predicate): fix regexp. Modified files: trunk/ChangeLog trunk/lib/rexml/quickpath.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 27245) +++ ChangeLog (revision 27246) @@ -1,3 +1,8 @@ +Wed Apr 7 11:49:34 2010 NARUSE, Yui <naruse@r...> + + * lib/rexml/quickpath.rb (REXML::QuickPath::predicate): + fix regexp. + Wed Apr 7 09:44:48 2010 Nobuyoshi Nakada <nobu@r...> * configure.in (Makefile): quote init-commands. Index: lib/rexml/quickpath.rb =================================================================== --- lib/rexml/quickpath.rb (revision 27245) +++ lib/rexml/quickpath.rb (revision 27246) @@ -141,6 +141,7 @@ return matches.uniq end + OPERAND_ = '((?=(?:(?!and|or).)*[^\s<>=])[^\s<>=]+)' # A predicate filters a node-set with respect to an axis to produce a # new node-set. For each node in the node-set to be filtered, the # PredicateExpr is evaluated with that node as the context node, with @@ -170,7 +171,9 @@ 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, + # + predicate.gsub!( + /#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u, '\1 \2 \3 and \3 \4 \5' ) # Let's do some Ruby trickery to avoid some work: predicate.gsub!( /&/u, "&&" ) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/