From e6636fe890ab7cf8f8f1b86ca54a3e10f98d43e6 Mon Sep 17 00:00:00 2001 From: ser Date: Tue, 9 Dec 2003 02:41:33 +0000 Subject: * Added the lower-case Shift-JIS files to the manifest. The upper-case ones should be deprecated, but I need a Shift-JIS encoded XML file to test against, first. * Added support for maintaining external entity occurances in DTDs * Deprecated the use of Document::DECLARATION. The new default declaration can be gotten with XMLDecl::default() * Refactored the encoding support code. It should be more robust now, and fixes a few bugs. * The XPath string() function now deals with Element nodes properly. * Serialization with Output objects now works as would be expected. * Various code cleanups, some reducing the number of warnings that Ruby 1.8.x produces with REXML. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rexml/source.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/rexml/source.rb') diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index 8161750694..2110e6db66 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -28,7 +28,7 @@ module REXML # Constructor # @param arg must be a String, and should be a valid XML document - def initialize arg + def initialize(arg) @orig = @buffer = arg self.encoding = check_encoding( @buffer ) #@buffer = decode(@buffer) unless @encoding == UTF_8 @@ -64,10 +64,10 @@ module REXML # everything after it in the Source. # @return the pattern, if found, or nil if the Source is empty or the # pattern is not found. - def scan pattern, consume=false + def scan(pattern, cons=false) return nil if @buffer.nil? rv = @buffer.scan(pattern) - @buffer = $' if consume and rv.size>0 + @buffer = $' if cons and rv.size>0 rv end @@ -88,21 +88,21 @@ module REXML return md end - def match pattern, consume=false + def match(pattern, cons=false) md = pattern.match(@buffer) - @buffer = $' if consume and md + @buffer = $' if cons and md return md end # @return true if the Source is exhausted def empty? - @buffer.nil? or @buffer.strip.nil? + @buffer.nil? end # @return the current line in the source def current_line lines = @orig.split - res = lines.grep(@buffer[0..30]) + res = lines.grep @buffer[0..30] res = res[-1] if res.kind_of? Array lines.index( res ) if res end @@ -113,7 +113,7 @@ module REXML class IOSource < Source #attr_reader :block_size - def initialize arg, block_size=500 + def initialize(arg, block_size=500) @er_source = @source = arg @to_utf = false # READLINE OPT @@ -127,7 +127,7 @@ module REXML @line_break = encode( '>' ) end - def scan pattern, consume=false + def scan(pattern, cons=false) rv = super # You'll notice that this next section is very similar to the same # section in match(), but just a liiittle different. This is @@ -166,16 +166,16 @@ module REXML match( pattern, true ) end - def match pattern, consume=false + def match( pattern, cons=false ) rv = pattern.match(@buffer) - @buffer = $' if consume and rv + @buffer = $' if cons and rv while !rv and @source begin str = @source.readline('>') str = decode(str) if @to_utf and str @buffer << str rv = pattern.match(@buffer) - @buffer = $' if consume and rv + @buffer = $' if cons and rv rescue @source = nil end -- cgit v1.2.3