This repository has been archived by the owner on Jun 13, 2018. It is now read-only.
Problem: inconsistent path treatment leads to confusing behavior. #78
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 resolves the various path-related issues identified in #73.
In reviewing a large portion of GSL I discovered a widespread issue pertaining to normalization. Each category of platforms have their own idiosyncrasies with respect to paths. Windows is the most obvious of course, because of the "Gates File System" (as it's referred to in the source) slash reversal.
The problem is that there is an inconsistently-applied canonical form in the code. It appears to want to convert everything to a Linux form. For example, directories are terminated with "/" without consideration for platform. On the other hand, paths are not always normalized when they are read in from APIs or from XML or script. Some functions appear to denormalize accidentally.
There are really two questions of normal form, one for directory termination and the other for platform-specific representation. Different functions produce different forms for paths, although all that I reviewed also guarded against unexpected forms. This leads to a lot of redundant checking, and terminating/unterminating, but doesn't appear broken. The same holds for platform normalization. However in this case the guards and reconversions don't keep up.
There is way to much code for me to make a thorough review, so I made a small number of changes to improve matters while keeping regression risk low. These are things that were already being done, just less consistently. So this is the basic idea:
This means that GSL can accept any input, and internal operations should be simpler (could be more so). But it also means that output will be consistent. This should help prevent the need for platform-specific code in scripts. It is a bit odd to see
c:/foo/bar/
but certainly better than seeingc:\foo\bar/
. Also windows compilers have no problem with forward-slashed paths, and they are definitely preferred (for cross compile).There is also an aspect of the change that makes the directory input more friendly. These are now all valid directories:
Previously only the last was valid on Windows and the first was not valid at all (terminating slash was expected).