-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRLF preservation #11
Open
dra27
wants to merge
10
commits into
ocaml:master
Choose a base branch
from
dra27:crlf-preserving
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If a string contains newlines, it is printed using triple-quoting format, however this introduces a newline at the start of the string. If the string does not begin with a newline, then add an escaped one.
The file_crlf field records whether the opam file was read from a file where the line endings were CRLF-encoded. This changes the signatures for the lexer, as state must now be threaded through each call. The EOF token in OpamBaseParser has a bool option parameter added to it which indicates if the file line-endings were CRLF-encoded (Some true), LF-encoded (Some false), or mixed (None). If the file endings are mixed, then OpamParser will default to assuming CRLF-encoding on Windows and LF-encoding everywhere else, including Cygwin.
3632a6d 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? |
dra27
added a commit
to dra27/opam-file-format
that referenced
this pull request
May 13, 2020
These are part of the documentation for ocaml#11, which isn't yet merged.
dra27
added a commit
to dra27/opam-file-format
that referenced
this pull request
May 13, 2020
These are part of the documentation for ocaml#11, which isn't yet merged.
dra27
added a commit
to dra27/opam-file-format
that referenced
this pull request
May 14, 2020
These are part of the documentation for ocaml#11, which isn't yet merged.
Merged
dra27
added a commit
to dra27/opam-file-format
that referenced
this pull request
May 26, 2020
These are part of the documentation for ocaml#11, which isn't yet merged.
dra27
added a commit
to dra27/opam-file-format
that referenced
this pull request
May 26, 2020
These are part of the documentation for ocaml#11, which isn't yet merged.
Dev meeting discussion: this is for opam 2.2 at the earlier |
Merged
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.