Download
Magazine
Develop
Account
Download
Magazine
Develop
Login
Forgot Account/Password
Create Account
Language
Help
Language
Help
×
Login
Login Name
Password
×
Forgot Account/Password
Category:
Software
People
PersonalForge
Magazine
Wiki
Search
OSDN
>
Find Software
>
Communications
>
Email
>
Filters
>
bsfilter
>
Forums
>
users
>
改行コード
bsfilter
Description
Project Summary
Developer Dashboard
Developers
Image Gallery
List of RSS Feeds
Activity
Statistics
History
Downloads
List of Releases
Stats
Source Code
Code Repository list
CVS
View Repository
Ticket
Ticket List
Milestone List
Type List
Component List
List of frequently used tickets/RSS
Submit New Ticket
Documents
FrontPage
Title index
Recent changes
Communication
List of Forums
users (627)
Forums:
users
(Thread #6063)
Return to Thread list
RSS
改行コード (2004-09-28 18:23 by
Anonymous
#11208)
Reply
Create ticket
Windows で --pipe --insert-flag をつけて使う場合、
元のファイルが改行 LF (UNIX) 形式であっても、
出力は改行 CRLF (DOS) 形式になってしまいます。
とりあえず以下のパッチを当てて、
ファイル入出力をすべてバイナリモードにするようにして
逃げていますが、何かいい方法はないでしょうか?
--- bsfilter.org Wed May 05 16:42:28 2004
+++ bsfilter Tue Jul 20 11:29:07 2004
@@ -263,6 +263,7 @@
def open_ro(file)
if (file == "-")
+ STDIN::binmode
fh = STDIN
yield fh
elsif (file.class == Array)
@@ -290,7 +291,7 @@
if (! FileTest::file?(file))
raise sprintf("%s is not file", file)
end
- fh = open(file)
+ fh = open(file, "rb")
yield fh
fh.close
end
@@ -298,9 +299,10 @@
def open_wo(file, &block)
if (file == "-")
+ STDOUT::binmode
fh = STDOUT
else
- fh = open(file, "w")
+ fh = open(file, "wb")
end
if (block)
yield fh
@@ -2110,6 +2112,7 @@
dbs.push(db)
if (Options["pipe"])
insert_headers!(buf, (Options["add-spam"] || Options["sub-clean"]), nil)
+ STDOUT::binmode
print buf
end
update_token_db_one(db)
@@ -3056,6 +3059,7 @@
DB[token_db.language].get_combined_probability(token_db)
insert_headers!(buf, token_db.spam_flag, token_db.probability)
if (Options["pipe"])
+ STDOUT::binmode
print buf
end
printf("%s\n", file) if (token_db.spam_flag && Options["list-spam"])
Reply to #11208
×
Subject
Body
Reply To Message #11208 > Windows で --pipe --insert-flag をつけて使う場合、 > 元のファイルが改行 LF (UNIX) 形式であっても、 > 出力は改行 CRLF (DOS) 形式になってしまいます。 > > とりあえず以下のパッチを当てて、 > ファイル入出力をすべてバイナリモードにするようにして > 逃げていますが、何かいい方法はないでしょうか? > > --- bsfilter.org Wed May 05 16:42:28 2004 > +++ bsfilter Tue Jul 20 11:29:07 2004 > @@ -263,6 +263,7 @@ > > def open_ro(file) > if (file == "-") > + STDIN::binmode > fh = STDIN > yield fh > elsif (file.class == Array) > @@ -290,7 +291,7 @@ > if (! FileTest::file?(file)) > raise sprintf("%s is not file", file) > end > - fh = open(file) > + fh = open(file, "rb") > yield fh > fh.close > end > @@ -298,9 +299,10 @@ > > def open_wo(file, &block) > if (file == "-") > + STDOUT::binmode > fh = STDOUT > else > - fh = open(file, "w") > + fh = open(file, "wb") > end > if (block) > yield fh > @@ -2110,6 +2112,7 @@ > dbs.push(db) > if (Options["pipe"]) > insert_headers!(buf, (Options["add-spam"] || Options["sub-clean"]), nil) > + STDOUT::binmode > print buf > end > update_token_db_one(db) > @@ -3056,6 +3059,7 @@ > DB[token_db.language].get_combined_probability(token_db) > insert_headers!(buf, token_db.spam_flag, token_db.probability) > if (Options["pipe"]) > + STDOUT::binmode > print buf > end > printf("%s\n", file) if (token_db.spam_flag && Options["list-spam"])
You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.)
Login
Nickname
Preview
Post
Cancel
RE: 改行コード (2004-09-28 20:13 by
a39
#11211)
Reply
Create ticket
メイルクライアントによって,改行コードがCR(MacOS)/CRLF(DOS/Windows)/LF(UNIX)と違うと思います.
オプショナルに選択できる実装の方が良いように思います.
Reply to
#11208
Reply to #11211
×
Subject
Body
Reply To Message #11211 > メイルクライアントによって,改行コードがCR(MacOS)/CRLF(DOS/Windows)/LF(UNIX)と違うと思います. > オプショナルに選択できる実装の方が良いように思います. >
You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.)
Login
Nickname
Preview
Post
Cancel
RE: 改行コード (2004-09-28 20:46 by
Anonymous
#11213)
Reply
Create ticket
先のパッチのように、
入出力ともにバイナリモードにしておけば、
元ファイルの改行コードが何であろうと、
そのまま維持されて出力されると思うのですが、
どうでしょうか?
Reply to
#11208
Reply to #11213
×
Subject
Body
Reply To Message #11213 > 先のパッチのように、 > 入出力ともにバイナリモードにしておけば、 > 元ファイルの改行コードが何であろうと、 > そのまま維持されて出力されると思うのですが、 > どうでしょうか?
You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.)
Login
Nickname
Preview
Post
Cancel
RE: 改行コード (2004-09-28 21:22 by
a39
#11215)
Reply
Create ticket
追加されるheader(X-Spam-Flag:, X-Spam-Probability:)の末尾の改行コードは大丈夫でしょうか.
Rubyではbinary modeだと自動的にCR/CRLF/LFを使い分けてくれるのですか?
Reply to
#11213
Reply to #11215
×
Subject
Body
Reply To Message #11215 > 追加されるheader(X-Spam-Flag:, X-Spam-Probability:)の末尾の改行コードは大丈夫でしょうか. > Rubyではbinary modeだと自動的にCR/CRLF/LFを使い分けてくれるのですか?
You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.)
Login
Nickname
Preview
Post
Cancel
RE: 改行コード (2004-09-29 22:53 by
nabeken
#11231)
Reply
Create ticket
Windows上ではcygwinのrubyを使っていたため、
この現象に気付いていませんでした。
近日中にデバッグします。
入力ファイルの改行コードで出力する、というのが仕様です。
Reply to
#11208
Reply to #11231
×
Subject
Body
Reply To Message #11231 > Windows上ではcygwinのrubyを使っていたため、 > この現象に気付いていませんでした。 > 近日中にデバッグします。 > 入力ファイルの改行コードで出力する、というのが仕様です。
You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.)
Login
Nickname
Preview
Post
Cancel