-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let Location::str() handle
\r
correctly (#127)
The observed problem was that, on Windows, error messages had a strange `\r` in reported source locations that was inconsistent with both other platforms, and other parts of the same output string (you would see `\n` once then `\r\n` further along the same string). The trouble was traced back to `source.h`, which was separating lines based on only the `\n` character, and assuming that line breaks were only 1 char wide. This PR rewrites the 3 line/columns handling functions that did this, so that they will accept `\r\n`, `\n`, and `\r` as line delimiters while reporting correct line lengths (and so forth) on all platforms. The main change of substance is that the lines field of `SourceDef` changes from a vector of `size_t` to a vector of `pair<size_t, size_t>`, because it is no longer possible to derive where a line ends from where another line begins (we might have to add/subtract either 1 or 2 chars). Rather than try to detect some file-wide line break width (and possibly have problems due to corrupted files mixing line ending types), this rewrite just looks at which line ending variant each line had and records span information to match. Additionally, this commit adds exhaustive generative testing of this changed feature. The test code is commented to explain logically how it builds all possible permutations of line endings and line contents up to a certain length (albeit using just a as contents since this code is not sensitive to string contents). As configured in the `CMakeLists.txt`, it runs 729 test cases up to length 6 (6 chars, 6 line endings, and everything in between).
- Loading branch information
Showing
5 changed files
with
534 additions
and
16 deletions.
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.