Newline handling on Windows was a long-time hair-puller for me.
As we all know, the Windows standard for newline is CRLF (and IMHO that is the correct one). Some Windows applications do not work at all well with bare-LF line terminator text files.
15 years ago, I was forced to make the Windows code be able to access traditional UNIX files on a UNIX server via Samba (my pleas to "use IMAP" being disregarded for many years until it finally sunk in). That requirement, thankfully, has long been abandoned but there are still echoes of it in the Windows code.
Then came what do you do when someone FTP's it in binary mode (rather than ASCII).
Then came what do you do when the file is all mixed with LF-only and CRLF newlines (much of which came about by the Samba requirement).
The current UNIX code aggressively strips all CRs from the file, and the Windows code equally aggressively inserts CRs in front of all LFs. Both have to deal with the possibility of bare CRs (and both strip these).
What this all means is that "I'm not touching it". You're welcome to hack your copy and pull your hair instead. I want to keep the hair I still have! ;-)
If I were you, and determined to do this project in spite of my warnings, I would not start with the current Windows driver (.../src/osdep/nt/unixnt.c). I would start with the current UNIX code (.../src/osdep/unix/unix.c) and port that to Windows.
To port the UNIX code to Windows, you have to fix some several library calls, and especially the way that the locking routines are called. It won't compile until you do that.
You can use the Windows code as a guideline, but only minimally since there are traps if you do that (e.g., subtle differences in size calculations). You may be able to do some diff comparisons, but the Windows code forked off so long ago it won't be as helpful as you think.
Good luck! You'll need it... On Sun, 4 May 2008, Vadim Zeitlin wrote:
I had a request of one of the users of my c-client-based MUA to create MBOX files using LF line terminations instead of CR LF ones under Windows (if you're curious, he wants to use the same mailboxes from different systems) and I wonder if there is already a possibility to do it or if I could easily modify the code to add it.
-- Mark -- http://panda.com/mrc Democracy is two wolves and a sheep deciding what to eat for lunch. Liberty is a well-armed sheep contesting the vote. _______________________________________________ Imap-uw mailing list [email protected] https://mailman1.u.washington.edu/mailman/listinfo/imap-uw
