kkm000 / openfst

Port of the OpenFST library to Windows
http://www.openfst.org/
Other
69 stars 38 forks source link

Always use binary mode on std{in.out} #32

Closed kkm000 closed 4 years ago

kkm000 commented 4 years ago

@daanzu, PTAL. No other hacks required, as the library uses ios:binary whenever required. It's only the cin and cout that are affected.

jtrmal commented 4 years ago

LGTM

On Wed, Jul 22, 2020 at 9:55 AM kkm000 notifications@github.com wrote:

@daanzu https://github.com/daanzu, PTAL. No other hacks required, as the library uses ios:binary whenever required. It's only the cin and cout that are affected.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kkm000/openfst/pull/32#issuecomment-662303654, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUKYX5TDT6TZ4JA6RD7BXLR42LPFANCNFSM4PENZQBA .

daanzu commented 4 years ago

@kkm000 I haven't tested it, but it looks good. I figured there should be a better place to put the modifications than where I did, but I didn't know my way around openfst enough to find it. Thanks for making the change!

kkm000 commented 4 years ago

I did. I noticed that the extra 0x0A appears if you `fstcompile something

temp.fst, or pipe to xxd directly, but not when not using the redirect fstcompile something temp.fst, letting fstcompile open the file. You can grep the sourcegrep -w ::ios and then-w ::ios::binary`: all binary files are open with a correct flag. Only symbol files and remapping pairs of integers from text files are opened without the binary flag.

Thanks for the code that changes the I/O type of an open file, as freopen did not work: you cannot reassign stdin or stdout in Windows, those are special, and defined as macros each calling a function.

-kkm