From 40bc864003879046de3439fd08af43567a0c574c Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 5 Apr 2010 21:08:12 +0000 Subject: * lib/rexml/parsers/baseparser.rb (LETTER, DIGIT): always use POSIX charclass. * lib/rexml/parsers/baseparser.rb (NAMECHAR): remove duplicated range. * lib/rexml/xmltokens.rb (NCNAME_STR, NAMECHAR): ditto. * lib/rexml/parsers/xpathparser.rb (PathExpr): ditto. * lib/rexml/text.rb (REXML::Text#initialize): initialize @parent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rexml/parsers/baseparser.rb | 13 +++---------- lib/rexml/parsers/xpathparser.rb | 2 +- lib/rexml/text.rb | 3 +-- lib/rexml/xmltokens.rb | 4 ++-- 4 files changed, 7 insertions(+), 15 deletions(-) (limited to 'lib/rexml') diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index 3c80231c35..09312abdde 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -25,15 +25,8 @@ module REXML # # Nat Price gave me some good ideas for the API. class BaseParser - if String.method_defined? :encode - # Oniguruma / POSIX [understands unicode] - LETTER = '[[:alpha:]]' - DIGIT = '[[:digit:]]' - else - # Ruby < 1.9 [doesn't understand unicode] - LETTER = 'a-zA-Z' - DIGIT = '\d' - end + LETTER = '[:alpha:]' + DIGIT = '[:digit:]' COMBININGCHAR = '' # TODO EXTENDER = '' # TODO @@ -42,7 +35,7 @@ module REXML NAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})" UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}" - NAMECHAR = '[\-\w\d\.:]' + NAMECHAR = '[\-\w:]' NAME = "([\\w:]#{NAMECHAR}*)" NMTOKEN = "(?:#{NAMECHAR})+" NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*" diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb index aafa72ab9e..2db37a2578 100644 --- a/lib/rexml/parsers/xpathparser.rb +++ b/lib/rexml/parsers/xpathparser.rb @@ -551,7 +551,7 @@ module REXML end end #puts "BEFORE WITH '#{rest}'" - rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w_*]/ + rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w*]/ parsed.concat(n) return rest end diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb index 0f15f00c31..2e42a5d423 100644 --- a/lib/rexml/text.rb +++ b/lib/rexml/text.rb @@ -93,12 +93,11 @@ module REXML entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK ) @raw = false + @parent = nil if parent super( parent ) @raw = parent.raw - else - @parent = nil end @raw = raw unless raw.nil? diff --git a/lib/rexml/xmltokens.rb b/lib/rexml/xmltokens.rb index 83efeb0e44..7dc4e8b2ba 100644 --- a/lib/rexml/xmltokens.rb +++ b/lib/rexml/xmltokens.rb @@ -2,10 +2,10 @@ module REXML # Defines a number of tokens used for parsing XML. Not for general # consumption. module XMLTokens - NCNAME_STR= '[\w:][\-\w\d.]*' + NCNAME_STR= '[\w:][\-\w.]*' NAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}" - NAMECHAR = '[\-\w\d\.:]' + NAMECHAR = '[\-\w\.:]' NAME = "([\\w:]#{NAMECHAR}*)" NMTOKEN = "(?:#{NAMECHAR})+" NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*" -- cgit v1.2.3