Conversation
msolve always writes its output file with "\n" line endings, since the output file is opened in binary mode. Users working with "\r\n" input files then have to convert the output themselves (e.g. with unix2dos). The line ending of the input file is now detected from its first line before the computation. If it is "\r\n", the output file is rewritten afterwards with "\r\n" line endings. Inputs with "\n" line endings are unaffected and incur no overhead. A new test checks that, for each pair of inputs differing only by their line endings, the output for the DOS input is the output for the Unix input with "\r\n" line endings. Fixes algebraic-solving#299. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wegank
marked this pull request as ready for review
October 1, 2026 22:38
ederc
approved these changes
Oct 2, 2026
This file contains hidden or 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
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.
Fixes #299.
msolve writes its output file in binary mode, so the output always uses
\nline endings, whatever the platform or the input. Users working with\r\ninput files then have to rununix2doson the output themselves.As suggested in #299, this PR detects the line ending of the input file before
core_msolveinsrc/msolve/main.c. If the input uses\r\n, the output file (-o) is rewritten afterwards with\r\nline endings. This adds no overhead for inputs with\nline endings.\nnot already preceded by\rbecomes\r\n. The file is copied to atmpfile()and rewritten in place, so its permissions and any symlink are kept. If the conversion fails, msolve prints a warning and the output keeps\nline endings.-o) is not converted.Tests
The new test
test/diff/diff_line-endings.shruns msolve on the pairs of inputs ininput_files/line_endings/, which differ only by their line endings, with default options,-g 2and-P 1. It checks that:\r, and\r\nline endings.The existing
line_endings_supporttest still checks that the parser reads both inputs identically.make checkpasses locally on macOS (69/69). This has not been tested on Windows.AI disclosure
This PR was written with the assistance of generative AI (Claude Code), and reviewed by me.
🤖 Generated with Claude Code