[Prime-cvs] CVS update: prime/lib

Back to archive index

Hiroyuki Komatsu komat****@users*****
2005年 1月 16日 (日) 04:47:16 JST


Index: prime/lib/session.rb
diff -u prime/lib/session.rb:1.4.4.16 prime/lib/session.rb:1.4.4.17
--- prime/lib/session.rb:1.4.4.16	Thu Dec 23 06:53:28 2004
+++ prime/lib/session.rb	Sun Jan 16 04:47:15 2005
@@ -1,5 +1,5 @@
 # session.rb
-# $Id: session.rb,v 1.4.4.16 2004/12/22 21:53:28 komatsu Exp $
+# $Id: session.rb,v 1.4.4.17 2005/01/15 19:47:15 komatsu Exp $
 #
 # Copyright (C) 2001 Satoru Takabayashi <sator****@namaz*****>
 # Copyright (C) 2002, 2003, 2004 Hiroyuki Komatsu <komat****@taiya*****>
@@ -525,7 +525,7 @@
     loop {
       char = io_in.getc()
       if char.nil? then
-        return
+        return nil
       end
       if char.chr == " " or char.chr == "\n" then
         return line
Index: prime/lib/server.rb
diff -u prime/lib/server.rb:1.2.4.2 prime/lib/server.rb:1.2.4.3
--- prime/lib/server.rb:1.2.4.2	Fri Dec 31 05:15:25 2004
+++ prime/lib/server.rb	Sun Jan 16 04:47:15 2005
@@ -1,5 +1,5 @@
 # server.rb
-# $Id: server.rb,v 1.2.4.2 2004/12/30 20:15:25 komatsu Exp $
+# $Id: server.rb,v 1.2.4.3 2005/01/15 19:47:15 komatsu Exp $
 #
 # Copyright (C) 2001 Satoru Takabayashi <sator****@namaz*****>
 # Copyright (C) 2004 Hiroyuki Komatsu <komat****@taiya*****>
@@ -24,6 +24,9 @@
   def session_loop (io_in, io_out)
     loop {
       line = receive(io_in)
+      if line.nil? then
+        return  # The connection has been closed.
+      end
       logging(line)
       Mutex.new.synchronize {
         result =****@sessi*****(line)
@@ -37,8 +40,14 @@
     }
   end
 
+  ## This receives a string line from the PRIME session and returns it.
+  ## If the session has been closed, this returns nil.
   def receive (io_in)
     line =****@sessi*****_line(io_in)
+    if line.nil? then
+      return nil
+    end
+
     if @iconv_in then
       return @iconv_in.iconv(line)
     else
@@ -68,6 +77,8 @@
     @debug_io.chmod(0600) if @debug_io::stat.owned?
   end
 
+  ## This method writes Line to @debug_io, if the debug mode is on.
+  ## This doesn't return any value.
   def logging (line)
     if @debug then
       line.chomp()
Index: prime/lib/prime2.rb
diff -u prime/lib/prime2.rb:1.1.2.9 prime/lib/prime2.rb:1.1.2.10
--- prime/lib/prime2.rb:1.1.2.9	Thu Dec 23 06:53:28 2004
+++ prime/lib/prime2.rb	Sun Jan 16 04:47:15 2005
@@ -1,5 +1,5 @@
 # prime2.rb: Module for PRIME2 protocol.
-# $Id: prime2.rb,v 1.1.2.9 2004/12/22 21:53:28 komatsu Exp $
+# $Id: prime2.rb,v 1.1.2.10 2005/01/15 19:47:15 komatsu Exp $
 #
 # Copyright (C) 2004 Hiroyuki Komatsu <komat****@taiya*****>
 #     All rights reserved.
@@ -812,20 +812,20 @@
     segment      = @segments[@position]
     reading_list = segment.reading.chars()
 
+    if reading_list.length == 1 then
+      return false
+    end
+
+    ## Checking if @postion is the end of segments.
     if @position ==****@segme***** - 1 then
-      next_segment = PrimeSegment.new("")  # The first value is a reading.
+      next_segment = PrimeSegment.new("")  # The first value "" is a reading.
       @segments.push(next_segment)
     else
       next_segment = @segments[@position + 1]
     end
 
     next_segment.set_reading( reading_list.last() + next_segment.reading )
-
-    if reading_list.length == 1 then
-      @segments[0,1] = nil
-    else
-      segment.set_reading( reading_list[0..-2].join() )
-    end
+    segment.set_reading( reading_list[0..-2].join() )
     return true
   end
 


Prime-cvs メーリングリストの案内
Back to archive index