Open dra27 opened 6 years ago
https://github.com/ocaml/opam-file-format/pull/11/commits/3632a6ded471681347efd663a55faaf8c4969275 contains an unrelated, but important, change to the encoding of strings containing newlines.
Tests to follow - @AltGr, is AppVeyor enabled as well?
just before i rebase #13 -- is this mergeable now?
Thanks @dra27! I ported half of the PR in #21 for CI & #22 for doc. I'll ping @altgr for CLRF review
Dev meeting discussion: this is for opam 2.2 at the earlier
This PR makes the following changes:
OpamLexer
requires some additional state which allows it to track the line-endings of the file being parsed.OpamBaseParser
'sEOF
token is augmented with abool option
indicating whether the file had CRLF-encoded line endings, LF-encoded line endings or a mixture.OpamParser
then treats mixed endings as CRLF on Windows and LF elsewhere and returns anopamfile
record augmented with afile_crlf
field.OpamPrinter
uses this information to control how it convertsopamfile
and related values back to strings.Important notes:
Normalise
functions are unchanged - in particular, they use LF-endings on WindowsPreserved
functions now no longer LF-endings for changed entries and CRLF-endings for any unchanged values in a file which was CRLF-encodedopam format upgrade
should not magically convert all CRLF-encoded files to LF-encoded files.This is still partially a work-in-progress, but is ready for initial review - in particular, I plan to add CI to this repo and some tests of these various behaviours and also produce a parallel PR in opam itself, as some changes are required there for CRLF-preservation.
In addition, the API is now documented.