Jump to content

  •  

Bug Tracker Migration

June 3rd
Good news everyone! The staff has decided that it is time to slowly kill off this Bug Tracker. We will begin the process of slowly migrating from this Bug Tracker over to our Github Issues which can be found here: https://github.com/HerculesWS/Hercules/issues

Over the next couple of days, I will be closing off any opportunity to create new reports. However, I still will keep the opportunity to reply to existing Bug Reports. Doing this will allow us to slowly fix any bug reports we have listed here so that we can easily migrate over to our Issue Tracker.

Update - June 7th 2015: Creating new bug posts has been disabled. Please use our https://github.com/HerculesWS/Hercules/issues tracker to post bugs. Users are still able to reply to existing bug posts.

- Administration

Issue Information

  • #000045

  • 5 - Critical

  • Fixed

Issue Confirmations

  • Yes (0)No (0)
Photo

Bad Savefile Line Terminators (windows)

Posted by Hercules Bot on 12 September 2007 - 08:06 PM

Originally posted by theultramage
http://www.eathena.w...cker&showbug=45

(Originally reported in this topic)

The '\n' char is a standardized C token meaning "newline". That is, they came up with the idea that people shouldn't need to change their code when porting to a different OS. It goes like this: you write \n in your program. The compiler writes \n (1 byte with value 10) in the output binary. Only the OS layer does the mapping from symbolic to physical newline.

now see this thing:
CODE
#if defined(WIN32) || defined(CYGWIN)
#define RETCODE   "\r\n"   // CR/LF : Windows systems
#elif defined(__APPLE__)
#define RETCODE "\r" // CR : Macintosh systems
#else
#define RETCODE "\n" // LF : Unix systems
#endif


This is the reason why windows' savefiles are terminated with CRCRLF - because RETCODE is "\r\n" and windows expands it to #13#13#10.
Actually, RETCODE should never have existed since it goes completely against C's definition.
(Truthfully, I also didn't know what the cause was until I accidentally found this topic while random-browsing. This thing is a non-trivial catch).

More details:
This thing was there since revision 1 and still is in jAthena. Key difference is that before r9435, it only (erroneously) applied to CYGWIN. After that change that 'corrected' the bad define, this is how it ended up.
One more mention of cygwin... according to info, cygwin lets you pick whether you want to go Unix-style or DOS-style during installation, therefore it supports both modes and can't be covered by a simple declaration like the above. It actually breaks cygwin's reading the same way it breaks windows'.