From: Seth Kurtzberg Date: 2003-03-07T02:11:54+09:00 Subject: File that produces "unknown node type 0" error --Boundary-00=_SF4Z+OahbZc3/Co Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Attached is a file that produces the "unknown node type 0" error. Unfortunately the error doesn't happen when I reduce this to the minimum code necessary to invoke the same methods. The error is produced with a snapshot distribution that I downloaded last week. I've included (I hope) all the files pulled in by require. The program has two required arguments. Run as follows: compared --directory1 SomeName --directory2 SomeOtherName The arguments are two directory names (the program compares all files in two directories; well, actually, all files in directory1 are compared to files of the same name in directory2). The directory names shouldn't matter for showing the error as it won't get that far (but they should exist). -- Seth Kurtzberg M. I. S. Corp. 480-661-1849 seth@cql.com --Boundary-00=_SF4Z+OahbZc3/Co Content-Type: text/plain; charset="us-ascii"; name="compared.rb.unknown.node.type.0" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="compared.rb.unknown.node.type.0" #!/usr/local/bin/ruby require 'tk' require 'tcltklib' require 'mu' require 'argproc' def eventsUntilIdle(root) #oneEventCounter = 1 rc = nil while (rc = root.do_one_event(2)) != 0 #puts("did event, rc=#{rc}, counter=#{oneEventCounter}") #oneEventCounter += 1 end end def doDirectory(direc,parent1,parent2) if direc != nil d1 = parent1 + '/' + direc d2 = parent2 + '/' + direc else d1 = parent1 d2 = parent2 end $currentDirectory1.configure('text'=>"Current Directory 1: #{d1}") $currentDirectory2.configure('text'=>"Current Directory 2: #{d2}") eventsUntilIdle($root) Dir.foreach(d1) { |fname| eventsUntilIdle($root) if fname != '.' && fname != '..' if File.stat(d1+'/'+fname).directory? if doDirectory(fname,d1,d2) == false return false end else $fbytes = 0 $fileBytes.configure('text'=>"File Bytes: #{$fbytes}") $currentFile.configure('text'=>"Current File: #{d1+'/'+fname}") eventsUntilIdle($root) fi1 = File.open(d1+'/'+fname,'r') fi1.nonblock basename = File.basename(fname) fname2 = d2 + '/' + basename fi2 = File.open(fname2) fi2.nonblock while( (s=fi1.read($bsize)) != nil) s2 = fi2.read(s.length) if s2 == nil puts("error, s2==nil") return false elsif s.length != s2.length puts("error, s.length=#{s.length}, s2.length=#{s2.length}") return false end if s != s2 puts("compare error, file #{fname}") return false end $fbytes += s.length $tbytes += s.length $bytesDisplayed += s.length if $bytesDisplayed > 1000000 $bytesDisplayed = 0 $fileBytes.configure('text'=>"File Bytes: #{$fbytes}") $totalBytes.configure('text'=>"Total Bytes: #{$tbytes}") eventsUntilIdle($root) end end if fi2.eof? == false puts("EOF on first file, but not second.") return false end end end } end argp = ArgProc.new argp.addArg(Argument.new( { 'name'=>'directory1', 'hasValue'=>true, 'required'=>true } ) ) argp.addArg(Argument.new( { 'name'=>'directory2', 'hasValue'=>true, 'required'=>true } ) ) argp.addArg(Argument.new( { 'name'=>'blocksize', 'hasValue'=>true, 'valueType'=>'integer', 'default'=>32256, 'required'=>false } ) ) argp.processArgs(ARGV) $root = TkRoot.new { title "Compare Progress" } $currentDirectory1 = TkLabel.new($root) { text 'Current Directory 1:' pack {side 'left'} } $currentDirectory2 = TkLabel.new($root) { text 'Current Directory 2:' pack {side 'left'} } $currentFile = TkLabel.new($root) { text 'Current File:' pack {side 'left'} } $fileBytes = TkLabel.new($root) { text 'File Bytes:' pack {side 'left'} } $totalBytes = TkLabel.new($root) { text 'Total Bytes:' pack {side 'left'} } $root.pack('fill'=>'both','expand'=>'yes') eventsUntilIdle($root) $tbytes = 0 $fbytes = 0 $bytesDisplayed = 0 $bsize = argp.value('blocksize') directory1 = argp.value('directory1') directory2 = argp.value('directory2') if doDirectory(nil,directory1,directory2) == false puts("Error occurred, exiting...") else puts("Successful completion...") end --Boundary-00=_SF4Z+OahbZc3/Co Content-Type: text/x-c++src; charset="us-ascii"; name="argproc.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="argproc.rb" require 'MessagePrinter' class Argument attr_reader :name, :default, :hasValue, :valueType attr_accessor :required, :value def initialize(args) @name = args['name'] @hasValue = args['hasValue'] @valueType = args['valueType'] @default = args['default'] @required = args['required'] @value = nil @value = @default end def display String.new("@name=#{@name},") + "@hasValue=#{@hasValue}," + "@valueType=#{@valueType}," + "@default=#{@default}," + "@required=#{@required}," + "@value=#{@value}" end end class ArgumentException < Exception def exname return 'ArgumentException' end end class MissingRequiredArgException < Exception def exname return 'MissingRequiredArgException' end end class ArgProc def initialize @names = Hash.new @dashpat = /^-+/ #add generic arguments addArg(Argument.new( { 'name' => 'inputfile', 'hasValue' => true, 'valueType' => 'string', 'required' => false } ) ) end def addArg(arg) MessagePrinter.show(3,__FILE__,__LINE__,"adding arg=#{arg.display}") if arg.name == nil puts "arg=#{arg.display}" raise ArgumentException end @names[arg.name] = arg end def processArgs(arglist) while arglist.length > 0 argstr = arglist.shift if !(argstr =~ @dashpat) raise ArgumentException end argstr = argstr.gsub(@dashpat,'') arg = @names[argstr] if !arg raise ArgumentException end if arg.hasValue arg.value = arglist.shift else arg.value = true end end @names.each_value do |val| if val.required && val.value == nil raise MissingRequiredArgException end end end def value(aname) MessagePrinter.show(3,__FILE__,__LINE__,"aname=#{aname}") arg = @names[aname] case arg.valueType when 'integer' return arg.value.to_i else return arg.value end end def setRequired(aname) arg = @names[aname] if !arg raise ArgumentException end arg.required(true) end end --Boundary-00=_SF4Z+OahbZc3/Co Content-Type: text/x-c++src; charset="us-ascii"; name="MessagePrinter.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="MessagePrinter.rb" require 'singleton' require 'thread' class String def logdata(fhandle) if fhandle != nil fhandle.write(self) end end end class MessagePrinter include Singleton @dest = $stdout @destex = $stderr @tracelevel = 0 @mutex = Mutex.new @previousTime = 0 def MessagePrinter.settracelevel(ll) @tracelevel = ll puts( "tracelevel set to #{ll}" ) end def MessagePrinter.setexdest(fname) @destex = File.new(fname,"w") end def MessagePrinter.setdest(fname) @dest = File.new(fname, "w") end def MessagePrinter.show(tl, fi, li, str, checkLevel = true, destfd=nil) if destfd == nil destfd = @dest end @mutex.synchronize do if checkLevel == false || tl <= @tracelevel time = Time.now if @previousTime != 0 && ((time - @previousTime) > 2) destfd.puts( "##################################################" ) end @previousTime = time destfd.puts( "thread #{Thread.current}, #{time}, file #{fi}, line #{li}, message:#{str}" ) destfd.flush end end end def MessagePrinter.log(fhandle,li) if fhandle != nil fhandle.puts(li) end end def MessagePrinter.showerr(tl,fi,li,msg) MessagePrinter.show(tl,fi,li,msg,true,@destex) end def MessagePrinter.showex(fi,li,ex,msg) if msg == nil || msg.length == 0 msg = "Exception: " end show(0,fi,li,"#{msg}#{ex}",false,@destex) fs = ex.backtrace.first.split(/:/) eline = fs[1] @destex.puts( "Error occured in file #{fs[0]} on line #{eline}\nstack:" ) fs.each do |li| @destex.puts li end @destex.flush end end --Boundary-00=_SF4Z+OahbZc3/Co Content-Type: text/plain; charset="us-ascii"; name="mistk.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mistk.rb" require 'tk' require 'tcltklib' def eventsUntilIdle(root) #oneEventCounter = 1 rc = nil while (rc = root.do_one_event(2)) != 0 #puts("did event, rc=#{rc}, counter=#{oneEventCounter}") #oneEventCounter += 1 end end def messageBox(msg) buttonPressed = false root = TkRoot.new { title msg } TkLabel.new(root) { text msg pack } TkButton.new(root) { text "CONTINUE" command proc { buttonPressed=true } pack } while buttonPressed == false eventsUntilIdle(root) end end --Boundary-00=_SF4Z+OahbZc3/Co Content-Type: text/plain; charset="us-ascii"; name="mu.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mu.rb" require 'fcntl' module Mu def Mu.die(thread0,fi,li,ex,msg) puts("thread #{Thread.current}, file #{fi}, line #{li}, Exception:#{ex}, #{msg}" ) puts( "aborting..." ) thread0.exit end end class IO def nonblock opts = fcntl(Fcntl::F_GETFL) fcntl(Fcntl::F_SETFL,opts | Fcntl::O_NONBLOCK) end end --Boundary-00=_SF4Z+OahbZc3/Co--