mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 13:59:25 +00:00
better statistics
svn path=/trunk/; revision=9013
This commit is contained in:
parent
87a878a82e
commit
f38bef7c32
1 changed files with 41 additions and 16 deletions
|
@ -16,6 +16,8 @@ typedef struct _EXTENSION_INFO
|
||||||
struct _EXTENSION_INFO * Next;
|
struct _EXTENSION_INFO * Next;
|
||||||
struct _FILE_INFO * StatInfoList;
|
struct _FILE_INFO * StatInfoList;
|
||||||
TCHAR ExtName[16];
|
TCHAR ExtName[16];
|
||||||
|
TCHAR ExpandedExtName[128];
|
||||||
|
DWORD nExtensions;
|
||||||
TCHAR Description[256];
|
TCHAR Description[256];
|
||||||
DWORD FileCount;
|
DWORD FileCount;
|
||||||
DWORD LineCount;
|
DWORD LineCount;
|
||||||
|
@ -80,14 +82,28 @@ AddExtension(LPTSTR ExtName,
|
||||||
{
|
{
|
||||||
PEXTENSION_INFO ExtInfo;
|
PEXTENSION_INFO ExtInfo;
|
||||||
PEXTENSION_INFO Info;
|
PEXTENSION_INFO Info;
|
||||||
|
TCHAR *t;
|
||||||
|
DWORD ln;
|
||||||
|
|
||||||
ExtInfo = (PEXTENSION_INFO) HeapAlloc (GetProcessHeap(), 0, sizeof (EXTENSION_INFO));
|
ExtInfo = (PEXTENSION_INFO) HeapAlloc (GetProcessHeap(), 0, sizeof (EXTENSION_INFO));
|
||||||
if (!ExtInfo)
|
if (!ExtInfo)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
for(t = ExtName; *t != _T('\0'); t += _tcslen(t) + 1);
|
||||||
|
ln = (DWORD)t - (DWORD)ExtName;
|
||||||
|
|
||||||
ZeroMemory (ExtInfo, sizeof (EXTENSION_INFO));
|
ZeroMemory (ExtInfo, sizeof (EXTENSION_INFO));
|
||||||
_tcscpy (ExtInfo->ExtName, ExtName);
|
memcpy (ExtInfo->ExtName, ExtName, ln);
|
||||||
_tcscpy (ExtInfo->Description, Description);
|
_tcscpy (ExtInfo->Description, Description);
|
||||||
|
|
||||||
|
for(t = ExtInfo->ExtName; *t != _T('\0'); t += _tcslen(t) + 1)
|
||||||
|
{
|
||||||
|
if(ExtInfo->nExtensions++ != 0)
|
||||||
|
_tcscat (ExtInfo->ExpandedExtName, _T(";"));
|
||||||
|
_tcscat (ExtInfo->ExpandedExtName, _T("*."));
|
||||||
|
_tcscat (ExtInfo->ExpandedExtName, t);
|
||||||
|
}
|
||||||
|
|
||||||
if (ExtInfoList)
|
if (ExtInfoList)
|
||||||
{
|
{
|
||||||
Info = ExtInfoList;
|
Info = ExtInfoList;
|
||||||
|
@ -273,14 +289,22 @@ PrintStatistics()
|
||||||
TotalFileCount = 0;
|
TotalFileCount = 0;
|
||||||
TotalLineCount = 0;
|
TotalLineCount = 0;
|
||||||
Info = ExtInfoList;
|
Info = ExtInfoList;
|
||||||
|
|
||||||
while (Info != NULL)
|
for (Info = ExtInfoList; Info != NULL; Info = Info->Next)
|
||||||
|
{
|
||||||
|
TotalFileCount += Info->FileCount;
|
||||||
|
TotalLineCount += Info->LineCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
TotalAvgLF = (TotalFileCount ? TotalLineCount / TotalFileCount : 0);
|
||||||
|
|
||||||
|
for (Info = ExtInfoList; Info != NULL; Info = Info->Next)
|
||||||
{
|
{
|
||||||
DWORD AvgLF;
|
DWORD AvgLF;
|
||||||
|
|
||||||
if (Info->FileCount != 0)
|
if (Info->FileCount != 0)
|
||||||
{
|
{
|
||||||
AvgLF = Info->LineCount / Info->FileCount;
|
AvgLF = (Info->FileCount ? Info->LineCount / Info->FileCount : 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -288,20 +312,14 @@ PrintStatistics()
|
||||||
}
|
}
|
||||||
|
|
||||||
_tprintf (_T("\n"));
|
_tprintf (_T("\n"));
|
||||||
_tprintf (_T("File extension : %s\n"), Info->ExtName);
|
_tprintf (_T("File extension%c : %s\n"), ((Info->nExtensions > 1) ? _T('s') : _T(' ')), Info->ExpandedExtName);
|
||||||
_tprintf (_T("File ext. description : %s\n"), Info->Description);
|
_tprintf (_T("File ext. description : %s\n"), Info->Description);
|
||||||
_tprintf (_T("Number of files : %lu\n"), Info->FileCount);
|
_tprintf (_T("Number of files : %lu\n"), Info->FileCount);
|
||||||
_tprintf (_T("Number of lines : %lu\n"), Info->LineCount);
|
_tprintf (_T("Number of lines : %lu\n"), Info->LineCount);
|
||||||
|
_tprintf (_T("Proportion of lines : %.2f %%\n"), (float)(TotalLineCount ? (((float)Info->LineCount * 100) / (float)TotalLineCount) : 0));
|
||||||
_tprintf (_T("Average no. lines/file : %lu\n"), AvgLF);
|
_tprintf (_T("Average no. lines/file : %lu\n"), AvgLF);
|
||||||
|
|
||||||
TotalFileCount += Info->FileCount;
|
|
||||||
TotalLineCount += Info->LineCount;
|
|
||||||
|
|
||||||
Info = Info->Next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalAvgLF = TotalLineCount / TotalFileCount;
|
|
||||||
|
|
||||||
_tprintf (_T("\n"));
|
_tprintf (_T("\n"));
|
||||||
_tprintf (_T("Total number of files : %lu\n"), TotalFileCount);
|
_tprintf (_T("Total number of files : %lu\n"), TotalFileCount);
|
||||||
_tprintf (_T("Total number of lines : %lu\n"), TotalLineCount);
|
_tprintf (_T("Total number of lines : %lu\n"), TotalLineCount);
|
||||||
|
@ -316,16 +334,20 @@ ProcessFiles(LPTSTR Path)
|
||||||
PEXTENSION_INFO Info;
|
PEXTENSION_INFO Info;
|
||||||
TCHAR SearchPath[256];
|
TCHAR SearchPath[256];
|
||||||
TCHAR FileName[256];
|
TCHAR FileName[256];
|
||||||
|
TCHAR *Ext;
|
||||||
HANDLE SearchHandle;
|
HANDLE SearchHandle;
|
||||||
BOOL More;
|
BOOL More;
|
||||||
|
|
||||||
Info = ExtInfoList;
|
Info = ExtInfoList;
|
||||||
while (Info != NULL)
|
while (Info != NULL)
|
||||||
{
|
{
|
||||||
|
Ext = Info->ExtName;
|
||||||
|
do
|
||||||
|
{
|
||||||
ZeroMemory (&FindFile, sizeof (FindFile));
|
ZeroMemory (&FindFile, sizeof (FindFile));
|
||||||
_tcscpy (SearchPath, Path);
|
_tcscpy (SearchPath, Path);
|
||||||
_tcscat (SearchPath, _T("\\*."));
|
_tcscat (SearchPath, _T("\\*."));
|
||||||
_tcscat (SearchPath, Info->ExtName);
|
_tcscat (SearchPath, Ext);
|
||||||
_tcscpy (FindFile.cFileName, SearchPath);
|
_tcscpy (FindFile.cFileName, SearchPath);
|
||||||
SearchHandle = FindFirstFile (SearchPath, &FindFile);
|
SearchHandle = FindFirstFile (SearchPath, &FindFile);
|
||||||
if (SearchHandle != INVALID_HANDLE_VALUE)
|
if (SearchHandle != INVALID_HANDLE_VALUE)
|
||||||
|
@ -362,6 +384,8 @@ ProcessFiles(LPTSTR Path)
|
||||||
}
|
}
|
||||||
FindClose (SearchHandle);
|
FindClose (SearchHandle);
|
||||||
}
|
}
|
||||||
|
Ext += _tcslen(Ext) + 1;
|
||||||
|
} while(*Ext != _T('\0'));
|
||||||
Info = Info->Next;
|
Info = Info->Next;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -450,8 +474,9 @@ main (int argc, char * argv [])
|
||||||
}
|
}
|
||||||
|
|
||||||
Initialize();
|
Initialize();
|
||||||
AddExtension (_T("c"), _T("Source files"));
|
AddExtension (_T("c\0\0"), _T("Ansi C Source files"));
|
||||||
AddExtension (_T("h"), _T("Header files"));
|
AddExtension (_T("cpp\0cxx\0\0"), _T("C++ Source files"));
|
||||||
|
AddExtension (_T("h\0\0"), _T("Header files"));
|
||||||
Execute (argv[1]);
|
Execute (argv[1]);
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue