Skip to content
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

fix: fix the inconsistency in filename drive letters #1283

Merged
merged 7 commits into from
May 8, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions kclvm/parser/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,32 @@ impl<'a> Parser<'a> {
let hi = self.sess.lookup_char_pos(hi);

let filename: String = format!("{}", lo.file.name.prefer_remapped());
(
filename,
lo.line as u64,
lo.col.0 as u64,
hi.line as u64,
hi.col.0 as u64,
)

He1pa marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(target_os = "windows")]
{
use kclvm_utils::path::PathPrefix;
// The canonicalize() function will change the drive letter to uppercase in Windows.
// e.g.: c:\\xx -> C:\\xx
let file = std::path::Path::new(&filename).canonicalize().unwrap();
let case_insensitive_filename = file.adjust_canonicalization();
(
case_insensitive_filename,
lo.line as u64,
lo.col.0 as u64,
hi.line as u64,
hi.col.0 as u64,
)
}
#[cfg(not(target_os = "windows"))]
{
(
filename,
lo.line as u64,
lo.col.0 as u64,
hi.line as u64,
hi.col.0 as u64,
)
}
}

pub(crate) fn bump(&mut self) {
Expand Down
Loading