From: Kazuhiko <kaz...@fd...> - 2005-05-16 23:45:01
|
かずひこです。 At Mon, 16 May 2005 01:45:49 +0900, Kazuhiro NISHIYAMA wrote: > WindowsからLinuxへtdiaryの*.td?ファイルをそのままコピーして > 使うと、改行コードが"\r\n"になっていて、defaultio.rbの > gets( "\n.\n" )で何も読み込めなくてtd2ファイルが消えて > しまうようです。 たぶんこんな感じでよいかと思います。 Index: tdiary/defaultio.rb =================================================================== RCS file: /cvsroot/tdiary/core/tdiary/defaultio.rb,v retrieving revision 1.31 diff -u -r1.31 defaultio.rb --- tdiary/defaultio.rb 15 May 2005 10:53:52 -0000 1.31 +++ tdiary/defaultio.rb 16 May 2005 03:06:25 -0000 @@ -7,7 +7,7 @@ TDIARY_MAGIC = "#{TDIARY_MAGIC_MAJOR}.#{TDIARY_MAGIC_MINOR}" def TDiary::parse_tdiary( data ) - header, body = data.split( /\n\n/, 2 ) + header, body = data.split( /\r?\n\r?\n/, 2 ) if header and body body.gsub!( /^\./, '' ) headers = {} @@ -29,7 +29,7 @@ begin File::open( file, 'r' ) do |fh| fh.flock( File::LOCK_SH ) - while l = fh.gets( "\n.\n" ) + fh.read.split( /\r?\n\.\r?\n/ ).each do |l| headers, body = TDiary::parse_tdiary( l ) next unless body comment = Comment::new( @@ -74,7 +74,7 @@ begin File::open( file, 'r' ) do |fh| fh.flock( File::LOCK_SH ) - while l = fh.gets( "\n.\n" ) + fh.read.split( /\r?\n\.\r?\n/ ).each do |l| headers, body = TDiary::parse_tdiary( l ) next unless body body.each do |r| @@ -192,7 +192,7 @@ end # read and parse diary - while l = fh.gets( "\n.\n" ) + fh.read.split( /\r?\n\.\r?\n/ ).each do |l| headers, body = TDiary::parse_tdiary( l ) style_name = headers['Format'] || 'tDiary' diary = eval( "#{style( style_name )}::new( headers['Date'], headers['Title'], body, Time::at( headers['Last-Modified'].to_i ) )" ) # MacOS から... というケースではどうなんでしょ? -- かずひこ <http://wiki.fdiary.net/kazuhiko/> 「恋とハックはアジャイルが命!」 |