tiny icon indicating copy to clipboard operation
tiny copied to clipboard

No CRLF support

Open pixelshaded opened this issue 12 years ago • 4 comments
trafficstars

When I commit on my windows machine, git replaces LF with CRLF in my tiny file. After that Tiny is no longer able to get my data out of the database,

pixelshaded avatar Jun 19 '13 20:06 pixelshaded

You can not blame tiny for not working properly if some other program such as Git changes its data. The proper way to handle this is with a .gitattributes file, specifying the path to your tiny database should always have LF line endings. See the man page for .gitattributes: http://git-scm.com/docs/gitattributes

If you really think this is a problem which should be fixed in tiny, then I suggest you look into this loop: https://github.com/chjj/node-tiny/blob/master/lib/tiny.js#L179-L210 It should probably be possible to get it to ignore 0x0D characters (CR).

Tenzer avatar Jun 19 '13 20:06 Tenzer

I understand your perspective. The data Tiny expects is indeed being manipulated from the outside, so I can see how this would seem like it should be of no concern to the library. The tiny file is however simply a text file. IDEs and operating systems tend to enjoy messing with the line endings of this type of file. If the parsing logic depends on platform specific line endings, then it would seem reasonable to assert that perhaps cross platform compatibility is not a concern.

pixelshaded avatar Jun 19 '13 20:06 pixelshaded

I gave a shot at adding support for CRLF line endings, just for the fun of it. You can try it out with my branch here, and please let me know how it works for you: https://github.com/Tenzer/node-tiny/tree/crlf-support

Tenzer avatar Jun 19 '13 21:06 Tenzer

oh jeez! Thanks for your efforts, but we had already made your suggested git fix before you posted it.

pixelshaded avatar Jun 19 '13 21:06 pixelshaded