Last active
April 10, 2016 16:08
-
-
Save quartorz/bfba02795b8ed62fe3852b9ed2dc532b to your computer and use it in GitHub Desktop.
Visual C++ 2015でのkvのコンパイルエラーを修正するやつ
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
If($args.Length -lt 1){ | |
Add-Type -AssemblyName System.Windows.Forms; | |
$dialog = New-Object System.Windows.Forms.FolderBrowserDialog; | |
$dialog.Description = "Select kv header directory"; | |
$dialog.ShowNewFolderButton = $false; | |
$dialog.SelectedPath = Get-Location; | |
If($dialog.ShowDialog() -ne "OK"){ | |
Exit 1; | |
} | |
$kv = $dialog.SelectedPath; | |
}Else{ | |
$kv = (Get-Item $args[0]).FullName; | |
if((Get-Item $kv) -isnot [System.IO.DirectoryInfo]){ | |
Echo "$kv is not a directory"; | |
Exit 1; | |
} | |
} | |
Echo "Selected directory: $kv"; | |
if((Get-Item $kv).BaseName -ne "kv"){ | |
Echo "$kv is not kv header directory"; | |
Exit 1; | |
} | |
# size_tに対する単項-演算子がVisual C++ 2015プロジェクトの | |
# デフォルトの設定ではエラーになるのでintにキャストする。 | |
$regex = [regex]"-\s*(\w+\s*\.\s*size\s*\(\s*\))"; | |
Get-ChildItem $kv -Filter *.hpp | | |
ForEach-Object{ | |
$path = $_; | |
$content = Get-Content $path.FullName; | |
$matches = $regex.Matches($content); | |
If($matches.Count -ne 0){ | |
Echo "Rewrite $path"; | |
$newcontent = $content -replace $regex, '- static_cast<int>($1)'; | |
Set-Content $path.FullName $newcontent; | |
} | |
} | |
# &&の代わりにandが使われている箇所があるので修正する。 | |
# 修正する代わりにciso646をincludeしても良い。 | |
$regex = [regex]"-1 and mode"; | |
Get-ChildItem $kv -Filter *.hpp | | |
ForEach-Object{ | |
$path = $_; | |
$content = Get-Content $path.FullName; | |
$matches = $regex.Matches($content); | |
If($matches.Count -ne 0){ | |
Echo "Rewrite $path"; | |
$newcontent = $content -replace $regex, '-1 && mode'; | |
Set-Content $path.FullName $newcontent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment