forked from sroyuela/rose
/
postProcessGlobalAndStaticDataFile.C
85 lines (67 loc) · 1.9 KB
/
postProcessGlobalAndStaticDataFile.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <fstream>
#include <stdio.h>
#include<string>
#include<list>
#include<assert.h>
using namespace std;
int
main(int argc, char *argv[])
{
int i;
printf ("argc = %d \n",argc);
for (i = 0; i < argc; i++)
{
cout << "argv[" << i << "] = " << argv[i] << endl;
}
if (argc != 3)
{
printf ("Error: Usage: uniqueStrings <input file> <output file> \n");
assert(false);
}
ifstream inputFile ( argv[1] , ios::in );
if ( inputFile.good() == false )
{
printf ("inputFile failed to open \n");
assert(false);
}
// ofstream outputFile ( argv[2] , ios::out | ios::app );
ofstream outputFile ( argv[2] , ios::out | ios::trunc );
if ( outputFile.good() == false )
{
printf ("outputFile failed to open \n");
assert(false);
}
char buffer[1000];
list<string> stringList;
int count = 0;
while (!inputFile.eof())
{
inputFile.getline (buffer,1000);
string s = buffer;
if (inputFile.eof() == false)
{
printf ("count = %4d s = %s \n",count,s.c_str());
#if 0
// Remove the path to where we store the ROSE headers
string targetString ="/usr/casc/overture/dquinlan/";
if (s.find(targetString) != string::npos)
{
s.replace(s.find(targetString),targetString.size(),"");
}
#endif
stringList.push_front(s);
count++;
}
}
inputFile.close();
stringList.sort();
stringList.unique();
for (list<string>::iterator i = stringList.begin(); i != stringList.end(); i++)
{
printf ("%s \n",(*i).c_str());
outputFile << (*i) << endl;
}
outputFile.close();
return 0;
}