Skip to content

Commit

Permalink
Stop naively replacing \ with / in file paths for error msgs
Browse files Browse the repository at this point in the history
As demonstrated in
kaitai-io/kaitai_struct#507 (comment),
this could in fact change the path incorrectly: on a Unix system, a file
name can contain `\` as a special character, for example
`hello\world.ksy`, but the old code would still "normalize" a Unix path
like `./hello\world.ksy` to `./hello/world.ksy`, which is wrong.

But I don't see why forced path normalization should be done on Windows
either, except for purity reasons (which are unimportant if you ask me).
I don't mind any mix of `\` and `/` slashes in the path coming out on
Windows (which can indeed happen from now on, especially for paths to
imported specs), as long as the resulting path points to the correct
file (which it kind of has to, because it is the same path that the
compiler used to access the file).

This commit reverts 2aef0de.
  • Loading branch information
generalmimon committed Aug 18, 2023
1 parent 4c5096b commit 2b84e0a
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ case class ProblemCoords(
}

object ProblemCoords {
def formatFileName(file: Option[String]): String = file match {
case Some(x) => x.replace('\\', '/')
case None => "(main)"
}
def formatFileName(file: Option[String]): String = file.getOrElse("(main)")
}

0 comments on commit 2b84e0a

Please sign in to comment.