diff --git a/ChangeLog b/ChangeLog index 86ab4a4222..26b24037ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Tue Apr 6 05:59:12 2010 NARUSE, Yui + + * 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. + Mon Apr 5 19:54:58 2010 NARUSE, Yui * re.c (make_regexp): use onig_new_with_source to keep 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})*"