-
Notifications
You must be signed in to change notification settings - Fork 64
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
System.Filepath: Add to_slash() and from_slash() #586
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dbf19fd
System.Filepath: Add to_slash() and from_slash()
ujihisa 8714c87
System.Filepath: Fix wrong assertions from my brain
ujihisa a1f1886
System.Filepath: Performance improvement
ujihisa d005552
System.Filepath: Performance improvement
ujihisa 7e54598
System.Filepath: Refactor to use existing s:is_windows
ujihisa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,26 @@ | |
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
if has('win32') || has('win64') | ||
function! s:to_slash(path) abort | ||
return tr(a:path, '\', '/') | ||
endfunction | ||
else | ||
function! s:to_slash(path) abort | ||
return a:path | ||
endfunction | ||
endif | ||
|
||
if has('win32') || has('win64') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 下で |
||
function! s:from_slash(path) abort | ||
return tr(a:path, '/', '\') | ||
endfunction | ||
else | ||
function! s:from_slash(path) abort | ||
return a:path | ||
endfunction | ||
endif | ||
|
||
let s:path_sep_pattern = (exists('+shellslash') ? '[\\/]' : '/') . '\+' | ||
let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95') | ||
let s:is_cygwin = has('win32unix') | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下で
s:is_windows
定義してるのでそれ使うと良さそう?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(windowsに詳しくないのでwindowsに詳しい人の意見欲しい) それだとwin16とwin95も入っちゃうけど大丈夫かな?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそも @h-east さんによると
has('win32') || has('win64')
はhas('win32')
だけでいいそうです (help にもそう書いてある)。つまり
win32
はwin95
とwin64
を含む Windows の判定として使えます (今調べて気付いた)。そして
win16
に至ってはそもそも feature-list に残ってすらいない (help は 7.4.1382, 実装は 7.4.1375, 7.4.1368, 7.4.1364 で削除済み) ので、総括すると以下の判定でいいという事になります。修正前:
let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95')
修正後:
let s:is_windows = has('win32')
feature-list の判定の実装
そもそも
has('win32')
がどういう場合に non-zero になるか気になったので調べたら、以下のようになっていました。win32
:WIN32
マクロが定義されている場合に non-zerowin64
:WIN64
あるいは_WIN64
マクロが定義されている場合に non-zerowin95
: feature-list にはあるみたいですが、実装は見つけられませんでした。もしかして既にサポート切られてドキュメントが古い?@k-takata さんが言ってたんですが、64bitであっても
WIN32
,_WIN32
は定義されるため、help の言う通り 64bit でもwin32
だけで non-zero を返します。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8.0.0029 で WinXP より前のサポートは打ち切られました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど。win95 が無いのはそのせいでしたか。
win95 が help に残ってる件について Bram に尋ねてみたら、「過去あった物なので残してる (今は常に false を返す点については追記しておく)」との事だったので、「win16 も過去あったよ」とだけ伝えました (なので復元するべき、まで伝えるべきでした…)。
https://groups.google.com/d/msg/vim_dev/owxmPRf_Pog/plmWQZLSBQAJ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dos16, dos32, os2 も復活させるべき。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
おおーなるほど、こうなってたんですね!
とりあえず派生pullreq作ってみました。主目的は上記議論のdocument化です #589
ひとまずそこではwin16, dos{16,32}, os2はスルーしてます。