mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-22 21:45:09 +02:00
committing un-revertable diff
This commit is contained in:
parent
8485fd9035
commit
8dd7423e13
@ -1,200 +1,200 @@
|
|||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$Win32Macro = 'WIN32_FIXME'
|
$Win32Macro = 'WIN32_FIXME'
|
||||||
$sourceRoot = 'C:\openssh\Win32-OpenSSH'
|
$sourceRoot = 'C:\openssh\Win32-OpenSSH'
|
||||||
|
|
||||||
[int]$g_code = 0
|
[int]$g_code = 0
|
||||||
[int]$g_win32 = 0
|
[int]$g_win32 = 0
|
||||||
[int]$g_unix = 0
|
[int]$g_unix = 0
|
||||||
|
|
||||||
function AnalyzeFile($file, [bool]$log)
|
function AnalyzeFile($file, [bool]$log)
|
||||||
{
|
{
|
||||||
$file = Join-Path $sourceRoot $file
|
$file = Join-Path $sourceRoot $file
|
||||||
if ($log) { Write-Host -ForegroundColor Gray $file }
|
if ($log) { Write-Host -ForegroundColor Gray $file }
|
||||||
$content = Get-Content $file
|
$content = Get-Content $file
|
||||||
[int]$commentlines = 0 #comments
|
[int]$commentlines = 0 #comments
|
||||||
[int]$emptylines = 0 #emptylines
|
[int]$emptylines = 0 #emptylines
|
||||||
[int]$code = 0 #all code lines
|
[int]$code = 0 #all code lines
|
||||||
[int]$win32 = 0 #win32 only lines
|
[int]$win32 = 0 #win32 only lines
|
||||||
[int]$win32substituted = 0#lines in win32 block that have a corresponding Unix block (#ifdef with #else)
|
[int]$win32substituted = 0#lines in win32 block that have a corresponding Unix block (#ifdef with #else)
|
||||||
[int]$unix = 0; #unix only lines
|
[int]$unix = 0; #unix only lines
|
||||||
[int]$unixsubstituted = 0 #lines in unix block that have a corresponding Win32 block (#ifdef with #else)
|
[int]$unixsubstituted = 0 #lines in unix block that have a corresponding Win32 block (#ifdef with #else)
|
||||||
[int]$total = 0
|
[int]$total = 0
|
||||||
[int]$nestedmacros = 0 #tracks nested macro blocks inside a win32 or a unix block
|
[int]$nestedmacros = 0 #tracks nested macro blocks inside a win32 or a unix block
|
||||||
[bool]$incommentblock = $false
|
[bool]$incommentblock = $false
|
||||||
[bool]$inWin32block = $false
|
[bool]$inWin32block = $false
|
||||||
[bool]$inUnixblock = $false
|
[bool]$inUnixblock = $false
|
||||||
[int]$currentblockcode = 0
|
[int]$currentblockcode = 0
|
||||||
[bool]$insubstitutedblock = $false
|
[bool]$insubstitutedblock = $false
|
||||||
|
|
||||||
|
|
||||||
foreach ($linestr in $content)
|
foreach ($linestr in $content)
|
||||||
{
|
{
|
||||||
$total++
|
$total++
|
||||||
$line = [String]$linestr
|
$line = [String]$linestr
|
||||||
$line = $line.Trim()
|
$line = $line.Trim()
|
||||||
#skip if line is empty
|
#skip if line is empty
|
||||||
if ($line.Length -gt 0)
|
if ($line.Length -gt 0)
|
||||||
{
|
{
|
||||||
if ($incommentblock)
|
if ($incommentblock)
|
||||||
{
|
{
|
||||||
$commentlines++
|
$commentlines++
|
||||||
if ($line.EndsWith('*/')) {$incommentblock = $false}
|
if ($line.EndsWith('*/')) {$incommentblock = $false}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($line.StartsWith('//')) {$commentlines++}
|
if ($line.StartsWith('//')) {$commentlines++}
|
||||||
elseif ($line.StartsWith('/*'))
|
elseif ($line.StartsWith('/*'))
|
||||||
{
|
{
|
||||||
if (!($line.EndsWith('*/'))) { $incommentblock = $true }
|
if (!($line.EndsWith('*/'))) { $incommentblock = $true }
|
||||||
$commentlines++
|
$commentlines++
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$code++
|
$code++
|
||||||
if ($inWin32block)
|
if ($inWin32block)
|
||||||
{
|
{
|
||||||
$win32++
|
$win32++
|
||||||
$currentblockcode++
|
$currentblockcode++
|
||||||
#keep skipping inner #ifdefs
|
#keep skipping inner #ifdefs
|
||||||
if ($line.StartsWith('#ifdef')) {$nestedmacros++}
|
if ($line.StartsWith('#ifdef')) {$nestedmacros++}
|
||||||
|
|
||||||
if ($line.EndsWith('#endif') -or $line.EndsWith('#else'))
|
if ($line.EndsWith('#endif') -or $line.EndsWith('#else'))
|
||||||
{
|
{
|
||||||
if ($nestedmacros -eq 0)
|
if ($nestedmacros -eq 0)
|
||||||
{
|
{
|
||||||
$inWin32block = $false
|
$inWin32block = $false
|
||||||
if ($line.EndsWith('#else'))
|
if ($line.EndsWith('#else'))
|
||||||
{
|
{
|
||||||
$inUnixblock = $true
|
$inUnixblock = $true
|
||||||
$insubstitutedblock = $true
|
$insubstitutedblock = $true
|
||||||
$win32substituted += $currentblockcode
|
$win32substituted += $currentblockcode
|
||||||
}
|
}
|
||||||
elseif ($insubstitutedblock)
|
elseif ($insubstitutedblock)
|
||||||
{
|
{
|
||||||
$win32substituted += $currentblockcode
|
$win32substituted += $currentblockcode
|
||||||
$insubstitutedblock = $false
|
$insubstitutedblock = $false
|
||||||
}
|
}
|
||||||
$currentblockcode = 0
|
$currentblockcode = 0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($line.EndsWith('#endif')) {$nestedmacros--}
|
if ($line.EndsWith('#endif')) {$nestedmacros--}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($inUnixblock)
|
elseif ($inUnixblock)
|
||||||
{
|
{
|
||||||
$unix++
|
$unix++
|
||||||
$currentblockcode++
|
$currentblockcode++
|
||||||
#keep skipping inner #ifdefs
|
#keep skipping inner #ifdefs
|
||||||
if ($line.StartsWith('#ifdef')) {$nestedmacros++}
|
if ($line.StartsWith('#ifdef')) {$nestedmacros++}
|
||||||
|
|
||||||
if ($line.EndsWith('#endif') -or $line.EndsWith('#else'))
|
if ($line.EndsWith('#endif') -or $line.EndsWith('#else'))
|
||||||
{
|
{
|
||||||
if ($nestedmacros -eq 0)
|
if ($nestedmacros -eq 0)
|
||||||
{
|
{
|
||||||
$inUnixblock = $false
|
$inUnixblock = $false
|
||||||
if ($line.EndsWith('#else'))
|
if ($line.EndsWith('#else'))
|
||||||
{
|
{
|
||||||
$inWin32block = $true
|
$inWin32block = $true
|
||||||
$insubstitutedblock = $true
|
$insubstitutedblock = $true
|
||||||
$unixsubstituted += $currentblockcode
|
$unixsubstituted += $currentblockcode
|
||||||
}
|
}
|
||||||
elseif ($insubstitutedblock)
|
elseif ($insubstitutedblock)
|
||||||
{
|
{
|
||||||
$unixsubstituted += $currentblockcode
|
$unixsubstituted += $currentblockcode
|
||||||
$insubstitutedblock = $false
|
$insubstitutedblock = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentblockcode = 0
|
$currentblockcode = 0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($line.EndsWith('#endif')) {$nestedmacros--}
|
if ($line.EndsWith('#endif')) {$nestedmacros--}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($line.StartsWith('#ifdef') -and $line.Contains($Win32Macro))
|
if ($line.StartsWith('#ifdef') -and $line.Contains($Win32Macro))
|
||||||
{
|
{
|
||||||
$inWin32block = $true
|
$inWin32block = $true
|
||||||
$currentblockcode = 0
|
$currentblockcode = 0
|
||||||
}
|
}
|
||||||
if ($line.StartsWith('#ifndef') -and $line.Contains($Win32Macro))
|
if ($line.StartsWith('#ifndef') -and $line.Contains($Win32Macro))
|
||||||
{
|
{
|
||||||
$inUnixblock = $true
|
$inUnixblock = $true
|
||||||
$currentblockcode = 0;
|
$currentblockcode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {$emptylines++}
|
else {$emptylines++}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($log)
|
if ($log)
|
||||||
{
|
{
|
||||||
Write-Host -ForegroundColor Yellow " Comments " $commentlines
|
Write-Host -ForegroundColor Yellow " Comments " $commentlines
|
||||||
Write-Host -ForegroundColor Green " Blank " $emptylines
|
Write-Host -ForegroundColor Green " Blank " $emptylines
|
||||||
Write-Host -ForegroundColor Cyan " Code " $code
|
Write-Host -ForegroundColor Cyan " Code " $code
|
||||||
Write-Host -ForegroundColor DarkMagenta " Total " $total " check("($commentlines+$emptylines+$code)")"
|
Write-Host -ForegroundColor DarkMagenta " Total " $total " check("($commentlines+$emptylines+$code)")"
|
||||||
Write-Host -ForegroundColor Cyan " Win32 " $win32
|
Write-Host -ForegroundColor Cyan " Win32 " $win32
|
||||||
Write-Host -ForegroundColor Cyan " Unix " $unix
|
Write-Host -ForegroundColor Cyan " Unix " $unix
|
||||||
Write-Host -ForegroundColor Cyan " Win32sub " $win32substituted
|
Write-Host -ForegroundColor Cyan " Win32sub " $win32substituted
|
||||||
Write-Host -ForegroundColor Cyan " Unixsub " $unixsubstituted
|
Write-Host -ForegroundColor Cyan " Unixsub " $unixsubstituted
|
||||||
}
|
}
|
||||||
|
|
||||||
$global:g_code += $code
|
$global:g_code += $code
|
||||||
$global:g_win32 += $win32
|
$global:g_win32 += $win32
|
||||||
$global:g_unix += $unix
|
$global:g_unix += $unix
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function AnalyzeProject($project, [bool]$log)
|
function AnalyzeProject($project, [bool]$log)
|
||||||
{
|
{
|
||||||
if ($log) { Write-Host "Project: " $project}
|
if ($log) { Write-Host "Project: " $project}
|
||||||
$projectName = $project
|
$projectName = $project
|
||||||
$projectroot = Join-Path $sourceRoot 'contrib\win32\openssh'
|
$projectroot = Join-Path $sourceRoot 'contrib\win32\openssh'
|
||||||
$project = Join-Path $projectroot $project
|
$project = Join-Path $projectroot $project
|
||||||
$project = $project + '.vcxproj'
|
$project = $project + '.vcxproj'
|
||||||
|
|
||||||
$global:g_code = 0
|
$global:g_code = 0
|
||||||
$global:g_win32 = 0
|
$global:g_win32 = 0
|
||||||
$global:g_unix = 0
|
$global:g_unix = 0
|
||||||
|
|
||||||
$c = Get-Content $project
|
$c = Get-Content $project
|
||||||
foreach ($ln in $c){
|
foreach ($ln in $c){
|
||||||
$l = [String]$ln
|
$l = [String]$ln
|
||||||
$l = $l.Trim()
|
$l = $l.Trim()
|
||||||
|
|
||||||
if ($l.StartsWith('<ClCompile Include="$(OpenSSH-Src-Path)'))
|
if ($l.StartsWith('<ClCompile Include="$(OpenSSH-Src-Path)'))
|
||||||
{
|
{
|
||||||
$l = $l.Replace('<ClCompile Include="$(OpenSSH-Src-Path)','')
|
$l = $l.Replace('<ClCompile Include="$(OpenSSH-Src-Path)','')
|
||||||
$l = $l.Substring(0, $l.IndexOf('"'))
|
$l = $l.Substring(0, $l.IndexOf('"'))
|
||||||
AnalyzeFile $l $log
|
AnalyzeFile $l $log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($log)
|
if ($log)
|
||||||
{
|
{
|
||||||
Write-Host " Total Code " $global:g_code
|
Write-Host " Total Code " $global:g_code
|
||||||
Write-Host " Win32 Code " $global:g_win32
|
Write-Host " Win32 Code " $global:g_win32
|
||||||
Write-Host " Unix Code " $global:g_unix
|
Write-Host " Unix Code " $global:g_unix
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host $projectName " " (100 - ($global:g_unix*100/($global:g_code - $global:g_win32))) "%"
|
Write-Host $projectName " " (100 - ($global:g_unix*100/($global:g_code - $global:g_win32))) "%"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AnalyzeProject libssh
|
AnalyzeProject libssh
|
||||||
AnalyzeProject scp
|
AnalyzeProject scp
|
||||||
AnalyzeProject sftp
|
AnalyzeProject sftp
|
||||||
AnalyzeProject sftp-server
|
AnalyzeProject sftp-server
|
||||||
AnalyzeProject ssh
|
AnalyzeProject ssh
|
||||||
AnalyzeProject ssh-add
|
AnalyzeProject ssh-add
|
||||||
AnalyzeProject ssh-agent
|
AnalyzeProject ssh-agent
|
||||||
AnalyzeProject sshd
|
AnalyzeProject sshd
|
Loading…
x
Reference in New Issue
Block a user