summaryrefslogtreecommitdiff
path: root/src/ToolBox/superpmi/mcs/verbstrip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ToolBox/superpmi/mcs/verbstrip.cpp')
-rw-r--r--src/ToolBox/superpmi/mcs/verbstrip.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/ToolBox/superpmi/mcs/verbstrip.cpp b/src/ToolBox/superpmi/mcs/verbstrip.cpp
index 8783b1a767..352ef04e93 100644
--- a/src/ToolBox/superpmi/mcs/verbstrip.cpp
+++ b/src/ToolBox/superpmi/mcs/verbstrip.cpp
@@ -13,37 +13,39 @@
// verbStrip::DoWork handles both "-copy" and "-strip". These both copy from input file to output file,
// but treat the passed-in indexes in opposite ways.
-int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes, bool strip, bool stripCR)
+int verbStrip::DoWork(
+ const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes, bool strip, bool stripCR)
{
if (strip)
return DoWorkTheOldWay(nameOfInput, nameOfOutput, indexCount, indexes, stripCR);
- SimpleTimer *st1 = new SimpleTimer();
+ SimpleTimer* st1 = new SimpleTimer();
LogVerbose("Reading from '%s' removing Mc Indexes and writing into '%s'", nameOfInput, nameOfOutput);
- int loadedCount = 0;
- MethodContext *mc = nullptr;
- int savedCount = 0;
- int index = 0;
+ int loadedCount = 0;
+ MethodContext* mc = nullptr;
+ int savedCount = 0;
+ int index = 0;
// The method context reader handles skipping any unrequested method contexts
// Used in conjunction with an MCI file, it does a lot less work...
- MethodContextReader *reader = new MethodContextReader(nameOfInput, indexes, indexCount);
+ MethodContextReader* reader = new MethodContextReader(nameOfInput, indexes, indexCount);
if (!reader->isValid())
{
return -1;
}
- HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, NULL);
- if(hFileOut == INVALID_HANDLE_VALUE)
+ HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ if (hFileOut == INVALID_HANDLE_VALUE)
{
LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError());
return -1;
}
- if(indexCount == -1)
- strip = true; //Copy command with no indexes listed should copy all the inputs...
- while(true)
+ if (indexCount == -1)
+ strip = true; // Copy command with no indexes listed should copy all the inputs...
+ while (true)
{
MethodContextBuffer mcb = reader->GetNextMethodContext();
if (mcb.Error())
@@ -56,17 +58,18 @@ int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int ind
}
loadedCount++;
- if((loadedCount%500==0)&&(loadedCount>0))
+ if ((loadedCount % 500 == 0) && (loadedCount > 0))
{
st1->Stop();
- LogVerbose("%2.1f%% - Loaded %d at %d per second", reader->PercentComplete(), loadedCount, (int)((double)500 / st1->GetSeconds()));
+ LogVerbose("%2.1f%% - Loaded %d at %d per second", reader->PercentComplete(), loadedCount,
+ (int)((double)500 / st1->GetSeconds()));
st1->Start();
}
if (!MethodContext::Initialize(loadedCount, mcb.buff, mcb.size, &mc))
return -1;
- if(stripCR)
+ if (stripCR)
{
delete mc->cr;
mc->cr = new CompileResult();
@@ -75,7 +78,7 @@ int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int ind
savedCount++;
delete mc;
}
- if(CloseHandle(hFileOut)==0)
+ if (CloseHandle(hFileOut) == 0)
{
LogError("2nd CloseHandle failed. GetLastError()=%u", GetLastError());
return -1;
@@ -85,9 +88,9 @@ int verbStrip::DoWork(const char *nameOfInput, const char *nameOfOutput, int ind
return 0;
}
-
// This is only used for "-strip".
-int verbStrip::DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput, int indexCount, const int *indexes, bool stripCR)
+int verbStrip::DoWorkTheOldWay(
+ const char* nameOfInput, const char* nameOfOutput, int indexCount, const int* indexes, bool stripCR)
{
LogVerbose("Reading from '%s' removing MC Indexes and writing into '%s'", nameOfInput, nameOfOutput);
@@ -95,11 +98,12 @@ int verbStrip::DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput
if (!mci.Initialize(nameOfInput))
return -1;
- int savedCount = 0;
+ int savedCount = 0;
bool write;
- int index = 0; // Can't use MethodContextIterator indexing, since we want the opposite of that.
+ int index = 0; // Can't use MethodContextIterator indexing, since we want the opposite of that.
- HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ HANDLE hFileOut = CreateFileA(nameOfOutput, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hFileOut == INVALID_HANDLE_VALUE)
{
LogError("Failed to open input 1 '%s'. GetLastError()=%u", nameOfOutput, GetLastError());
@@ -139,7 +143,8 @@ int verbStrip::DoWorkTheOldWay(const char *nameOfInput, const char *nameOfOutput
}
if (index < indexCount)
- LogWarning("Didn't use all of index count input %d < %d (i.e. didn't see MC #%d)", index, indexCount, indexes[index]);
+ LogWarning("Didn't use all of index count input %d < %d (i.e. didn't see MC #%d)", index, indexCount,
+ indexes[index]);
LogInfo("Loaded %d, Saved %d", mci.MethodContextNumber(), savedCount);