-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix s:TemporaryFilename in win11, & verilator in win32 #5057
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your neat and well-explained pull request, @congyong! One worry I see is that the replaced pattern is still used elsewhere within the ale sources. Running Fixing this instance is great. Fixing the others too would be even better. Not every occurrence of the pattern might be lucky enough to have access to a value from a freshly called Maybe something like this? (Not verified to work) function! ale#util#Pathseparator() abort
let l:separator = ''
if has('win32') && exists('+shellslash')
if &shellslash
let l:separator = '/'
else
let l:separator = '\\'
endif
elseif has('win32')
if &shellcmdflag =~ '^-' && &shell !~ 'powershell\|pwsh'
let l:separator = '/'
else
let l:separator = '\\'
endif
else
let l:separator = '/'
endif
return l:separator
endfunctionChecking whether the result of Would you agree addressing the pattern seems like a reasonable thing to do? Could you be up for doing it within the scope of this pull request? |
|
Hello, rymdbar and There are too many corners in the forward combing, so consider other ways to implement the code. " Detect the best path separator for the current environment.
function! ale#util#PathSeparator(...) abort
" 1. Get base dir from args OR a temporary file name (reflects the real system path style)
let l:tmpname = a:0 ? a:1 : ale#util#Tempname()
" 2. On Windows, if the path contains '\', use it.
if has('win32')
if l:tmpname =~# '\\'
return '\\'
endif
" Otherwise, fallback to '/' (e.g., WSL, Git Bash, MSYS2)
return '/'
endif
" 3. On Unix-like systems, always use '/'
return '/'
endfunction
~Yong |
|
Background of this function: I have reviewed the relevant code that uses Win32 for checking, and most of its calling scenarios contain directory information. Therefore, I added a judgment logic to the PathSep function. If the passed-in args include a directory, the format of this directory will be verified; if not, a temporary file (Tempfile) will be generated to parse the directory format. In addition, the code style under ale_linter is not consistent, and each file needs to be reviewed one by one. |
Summary
Operating System: Windows 11
Language: Verilog
Linter Tool: Verilator 4.216 2021-12-05 rev v4.216-22-g141c5da3 & 5.026
Tested Code: a.zip
Motivation and Context
While testing the Verilator integration on Windows 11, I observed that the temporary file path generated by
s:TemporaryFilenamewas inconsistent with the expected Windows path format.For example:
The existing implementation uses the following logic ( function! s:TemporaryFilename(buffer) in
verilator.vim) :This approach always appends a backslash (
\) on Windows systems.However, on Windows 11, temporary paths returned by
ale#util#Tempname()may contain either forward slashes (/) or backslashes (\), resulting in mixed and invalid paths.Description of Changes in ‘command.vim’
To ensure consistent and valid path construction across Windows versions while maintaining backward compatibility,
the separator is now determined dynamically based on the actual temporary path:
This change ensures correct handling of paths on Windows 11 and remains compatible with older Windows systems.
Changes in
verilator.vimWindows paths differ from Unix-style paths in that they include drive letters (e.g.,
D:) and additional colons.The parsing logic in
verilator.vimhas been updated to correctly handle such cases, preventing path-related errors when running Verilator on Windows.Testing
The changes were tested locally on Windows 11 with Verilator.
After applying the modifications, the Verilog linter executed successfully, and temporary files were created using valid path formats.
Additional Notes
These updates improve cross-platform consistency without affecting Unix-based environments.
No regressions were observed in local testing.