|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
#include "CmdGlobals.h"
|
|
|
20 |
#ifdef __WIN__
|
|
|
21 |
#pragma warning(disable:4786)
|
|
|
22 |
#endif
|
|
|
23 |
|
|
|
24 |
#include <iostream>
|
|
|
25 |
#include <fstream>
|
|
|
26 |
#include <string>
|
|
|
27 |
#include <map>
|
|
|
28 |
#include <list>
|
|
|
29 |
#include "Utils.h"
|
|
|
30 |
#include "TChange.h"
|
|
|
31 |
#include "HAException.h"
|
|
|
32 |
|
|
|
33 |
using namespace std;
|
|
|
34 |
|
|
|
35 |
#include "MacroAnalyser.h"
|
|
|
36 |
|
|
|
37 |
// ----------------------------------------------------------------------------
|
|
|
38 |
// MacroAnalyser::MacroAnalyser
|
|
|
39 |
// ----------------------------------------------------------------------------
|
|
|
40 |
//
|
|
|
41 |
MacroAnalyser::MacroAnalyser(string filebase, string filecurrent, vector<string> basebundle, vector<string> currentbundle)
|
|
|
42 |
:iBaseFile(filebase), iCurrentFile(filecurrent), iBaseBundle(basebundle), iCurrentBundle(currentbundle)
|
|
|
43 |
{
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
// ----------------------------------------------------------------------------
|
|
|
47 |
// MacroAnalyser::~MacroAnalyser
|
|
|
48 |
// ----------------------------------------------------------------------------
|
|
|
49 |
//
|
|
|
50 |
MacroAnalyser::~MacroAnalyser(void)
|
|
|
51 |
{
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
// ----------------------------------------------------------------------------
|
|
|
55 |
// MacroAnalyser::Analyse
|
|
|
56 |
// ----------------------------------------------------------------------------
|
|
|
57 |
//
|
|
|
58 |
void MacroAnalyser::Analyse(list<string>& aMacroFiles)
|
|
|
59 |
{
|
|
|
60 |
ifstream basefile(iBaseFile.c_str(), ios::in);
|
|
|
61 |
ifstream currentfile(iCurrentFile.c_str(), ios::in);
|
|
|
62 |
|
|
|
63 |
map<string, list<pair<pair<string, string>,string> > > baseline;
|
|
|
64 |
map<string, list<pair<pair<string, string>,string> > > current;
|
|
|
65 |
|
|
|
66 |
baseline = parseMacros(basefile, iBaseBundle, &iRemoved, true);
|
|
|
67 |
current = parseMacros(currentfile, iCurrentBundle);
|
|
|
68 |
|
|
|
69 |
vector<string>::iterator curbegin = iCurrentBundle.begin();
|
|
|
70 |
vector<string>::iterator curend = iCurrentBundle.end();
|
|
|
71 |
vector<string>::iterator basebegin = iBaseBundle.begin();
|
|
|
72 |
vector<string>::iterator baseend = iBaseBundle.end();
|
|
|
73 |
map<string, TChange<list<pair<string,string> > > >::iterator removedbegin;
|
|
|
74 |
for(;curbegin != curend; curbegin++)
|
|
|
75 |
{
|
|
|
76 |
string curfilename = *curbegin;
|
|
|
77 |
string basefilename;
|
|
|
78 |
if( basebegin != iBaseBundle.end() )
|
|
|
79 |
{
|
|
|
80 |
basefilename = *basebegin;
|
|
|
81 |
}
|
|
|
82 |
else
|
|
|
83 |
{
|
|
|
84 |
continue;
|
|
|
85 |
}
|
|
|
86 |
removedbegin = iRemoved.find(basefilename);
|
|
|
87 |
if (removedbegin != iRemoved.end())
|
|
|
88 |
{
|
|
12
|
89 |
// serach the macro value elemnts with key value "key_val_CURRENT",defined for Current file
|
|
|
90 |
map<string, list<pair<pair<string, string>,string> > >::iterator cur = current.find(KEY_VAL_CURRENT);
|
|
0
|
91 |
if (cur == current.end()) // We need to check if there is a list with given filename
|
|
|
92 |
// because they aren't created in situation where there isn't any macros
|
|
|
93 |
{ // specific to that file or the include guard for the file is duplicated.
|
|
|
94 |
list<pair<pair<string, string>,string> > tempvar;
|
|
|
95 |
pair<string, list<pair<pair<string, string>,string> > > tempvar2(curfilename, tempvar);
|
|
|
96 |
pair<map<string, list<pair<pair<string, string>,string> > >::iterator, bool > pos = current.insert(tempvar2);
|
|
|
97 |
if (pos.second == true)
|
|
|
98 |
{
|
|
|
99 |
cur = pos.first;
|
|
|
100 |
} else
|
|
|
101 |
{ // this shouldn't be happening
|
|
|
102 |
throw HAException("Problems ahead.");
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
map<string, list<pair<pair<string, string>,string> > >::iterator base = baseline.find(basefilename);
|
|
|
106 |
findDuplicates(basefilename,curfilename,base->second, cur->second, removedbegin->second, iBaseDuplicates, iCurrentDuplicates);
|
|
|
107 |
|
|
|
108 |
//maintain a cache list of files with macros
|
|
|
109 |
if(base->second.size() > 0)
|
|
|
110 |
aMacroFiles.push_back(toLowerCaseWin(base->first));
|
|
|
111 |
if(cur->second.size() > 0)
|
|
12
|
112 |
aMacroFiles.push_back(toLowerCaseWin(curfilename));
|
|
0
|
113 |
|
|
|
114 |
// After next loop we will have in list only those which has been either removed or changed
|
|
|
115 |
list<pair<pair<string, string>,string> >::iterator begin = cur->second.begin();
|
|
|
116 |
list<pair<pair<string, string>,string> >::iterator end = cur->second.end();
|
|
|
117 |
for(;begin != end; begin++)
|
|
|
118 |
{
|
|
|
119 |
list<pair<string,string> >::iterator place = FindFromList(begin->first.first, removedbegin->second.GetValue());
|
|
|
120 |
if (place != removedbegin->second.GetValue().end())
|
|
|
121 |
{
|
|
|
122 |
removedbegin->second.GetValue().erase(place); // we found macro with same name so we can remove it
|
|
|
123 |
list<pair<pair<string, string>,string> > baselist = base->second;
|
|
|
124 |
list<pair<pair<string, string>,string> >::iterator found = FindFromList(begin->first.first, baselist, ELeftValue);
|
|
|
125 |
if (found != baselist.end())
|
|
|
126 |
{
|
|
|
127 |
if (found->first.second != begin->first.second)
|
|
|
128 |
{ // Contents of macro are different so we need to add the macro to changed list
|
|
|
129 |
pair<pair<string,string>,string> changes;
|
|
|
130 |
changes.first.first = found->first.second;
|
|
|
131 |
changes.first.second = begin->first.second;
|
|
|
132 |
changes.second = begin->second;
|
|
|
133 |
pair<string, pair<pair<string, string>,string> > param(begin->first.first,changes);
|
|
|
134 |
map<string, TChange<map<string, pair<pair<string, string>,string> > > >::iterator file = iChanged.find(basefilename);
|
|
|
135 |
if (file != iChanged.end())
|
|
|
136 |
{
|
|
|
137 |
file->second.GetValue().insert(param);
|
|
|
138 |
} else
|
|
|
139 |
{
|
|
|
140 |
map<string, pair<pair<string, string>,string> > tempvar;
|
|
|
141 |
tempvar.insert(param);
|
|
|
142 |
TChange<map<string, pair<pair<string, string>,string> > > tempvar2(basefilename, curfilename, tempvar);
|
|
|
143 |
pair<string, TChange<map<string, pair<pair<string, string>,string> > > > tempvar3(basefilename, tempvar2);
|
|
|
144 |
iChanged.insert(tempvar3);
|
|
|
145 |
}
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
removedbegin->second.SetCurrent(curfilename);
|
|
|
151 |
}
|
|
|
152 |
basebegin++;
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
// ----------------------------------------------------------------------------
|
|
|
157 |
// MacroAnalyser::FindMacro
|
|
|
158 |
// ----------------------------------------------------------------------------
|
|
|
159 |
//
|
|
|
160 |
pair<string, string> MacroAnalyser::FindMacro(string aLine)
|
|
|
161 |
{
|
|
|
162 |
pair<string, string> ret;
|
|
|
163 |
string::size_type pos = aLine.find_first_of(" \t");
|
|
|
164 |
while(pos != string::npos && (aLine.at(pos) == ' ' || aLine.at(pos) == '\t') )
|
|
|
165 |
pos++;
|
|
|
166 |
string::size_type param_pos = pos ;
|
|
|
167 |
pos = aLine.find_first_of(" \t(",param_pos);
|
|
|
168 |
string value;
|
|
|
169 |
if (pos != string::npos && aLine.at(pos) == '(')
|
|
|
170 |
{
|
|
|
171 |
pos = aLine.find(')',pos);
|
|
|
172 |
if(pos !=string::npos )
|
|
|
173 |
pos++;
|
|
|
174 |
}
|
|
|
175 |
if (pos != string::npos && pos < aLine.size())
|
|
|
176 |
{ // only if there is stuff after name of macro we put it to value
|
|
|
177 |
size_t value_pos = (unsigned int)pos + 1;
|
|
|
178 |
value = aLine.substr(value_pos);
|
|
|
179 |
value = trimWhiteSpace(value);
|
|
|
180 |
if (value.size() != 0)
|
|
|
181 |
{
|
|
|
182 |
value_pos = value.find_first_not_of(" \t");
|
|
|
183 |
if (value_pos != string::npos && value_pos != 0)
|
|
|
184 |
{
|
|
|
185 |
value = value.substr(value_pos);
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
} else
|
|
|
189 |
{ // otherwise we put empty value
|
|
|
190 |
value = "";
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
string param = aLine.substr(param_pos, pos - param_pos);
|
|
|
194 |
ret = pair<string,string>(param,value);
|
|
|
195 |
return ret;
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
// ----------------------------------------------------------------------------
|
|
|
199 |
// MacroAnalyser::getRemoved
|
|
|
200 |
// ----------------------------------------------------------------------------
|
|
|
201 |
//
|
|
|
202 |
map<string, TChange<list<pair<string,string> > > >& MacroAnalyser::getRemoved()
|
|
|
203 |
{
|
|
|
204 |
return iRemoved;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
// ----------------------------------------------------------------------------
|
|
|
208 |
// MacroAnalyser::FindMacro
|
|
|
209 |
// readParameters should be called so that first is called baseline command
|
|
|
210 |
// and after that current command, otherwise it doesn't work
|
|
|
211 |
// ----------------------------------------------------------------------------
|
|
|
212 |
//
|
|
|
213 |
map<string, TChange<map<string, pair<pair<string, string>,string> > > >& MacroAnalyser::getChanged()
|
|
|
214 |
{
|
|
|
215 |
return iChanged;
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
// ----------------------------------------------------------------------------
|
|
|
219 |
// MacroAnalyser::getBaseDuplicates
|
|
|
220 |
// ----------------------------------------------------------------------------
|
|
|
221 |
//
|
|
|
222 |
map<string, vector<pair<string,string> > >& MacroAnalyser::getBaseDuplicates()
|
|
|
223 |
{
|
|
|
224 |
return iBaseDuplicates;
|
|
|
225 |
}
|
|
|
226 |
|
|
|
227 |
// ----------------------------------------------------------------------------
|
|
|
228 |
// MacroAnalyser::getCurrentDuplicates
|
|
|
229 |
// ----------------------------------------------------------------------------
|
|
|
230 |
//
|
|
|
231 |
map<string, vector<pair<string,string> > >& MacroAnalyser::getCurrentDuplicates()
|
|
|
232 |
{
|
|
|
233 |
return iCurrentDuplicates;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
// ----------------------------------------------------------------------------
|
|
|
237 |
// MacroAnalyser::parseMacros
|
|
|
238 |
// ----------------------------------------------------------------------------
|
|
|
239 |
//
|
|
12
|
240 |
map<string, list<pair<pair<string, string>,string> > > MacroAnalyser::parseMacros(ifstream& aFile, vector<string>& bundlefiles, map<string, TChange<list<pair<string,string> > > >* aRemoved, bool isbaseline)
|
|
0
|
241 |
{
|
|
|
242 |
// ret, is the file and related set of macros returned by the function
|
|
|
243 |
map<string, list<pair<pair<string, string>,string> > > ret;
|
|
|
244 |
vector<pair<string, string> > files;
|
|
|
245 |
vector<string>::iterator bundlefile = bundlefiles.begin();
|
|
|
246 |
vector<string>::iterator bundleend = bundlefiles.end();
|
|
|
247 |
for(; bundlefile != bundleend; bundlefile++)
|
|
|
248 |
{
|
|
|
249 |
pair<string, string> bothcase(toLowerCaseWin(*bundlefile), *bundlefile);
|
|
|
250 |
files.push_back(bothcase);
|
|
|
251 |
}
|
|
|
252 |
// Read macrofiles as lines
|
|
|
253 |
string cline;
|
|
|
254 |
string levelname = "";
|
|
12
|
255 |
bool isFileMatched = false;
|
|
0
|
256 |
while((cline = getLine(aFile)) != KEmpty)
|
|
|
257 |
{
|
|
|
258 |
string line = cline;
|
|
|
259 |
char tempNo[6];
|
|
|
260 |
string lineNo;
|
|
|
261 |
unsigned int length = (unsigned int)line.length();
|
|
|
262 |
if (length > 6 && line.at(0) == '#' && line.at(1) == ' ')
|
|
|
263 |
{ // we may have found a file descriptor: '# xx "path/to/file.h"' or
|
|
|
264 |
// '# xx "path/to/file.h" 1' or '# xx "path/to/file.h" 2'
|
|
|
265 |
unsigned int index;
|
|
|
266 |
int count = 0;
|
|
|
267 |
for(index = 2; index < length; index++)
|
|
|
268 |
{
|
|
|
269 |
char ch = line.at(index);
|
|
|
270 |
if (ch < '0' || ch > '9')
|
|
|
271 |
break;
|
|
|
272 |
else
|
|
|
273 |
{
|
|
|
274 |
tempNo[count] = ch;
|
|
|
275 |
count++;
|
|
|
276 |
}
|
|
|
277 |
}
|
|
|
278 |
tempNo[count] = '\0';
|
|
|
279 |
lineNo.copy(tempNo,strlen(tempNo));
|
|
|
280 |
index++;
|
|
|
281 |
if (index < length)
|
|
|
282 |
{
|
|
|
283 |
unsigned int index2 = index + 1;
|
|
|
284 |
for(; index2 < length; index2++)
|
|
|
285 |
{
|
|
|
286 |
char ch = line.at(index2);
|
|
|
287 |
if (ch == '"') break;
|
|
|
288 |
}
|
|
|
289 |
if (length > index2 + 1)
|
|
|
290 |
{
|
|
|
291 |
levelname = line.substr(index + 1, index2 - index - 1);
|
|
|
292 |
} else
|
|
|
293 |
{
|
|
|
294 |
levelname = line.substr(index + 1, length - index - 2);
|
|
|
295 |
}
|
|
|
296 |
string correctedname = "";
|
|
|
297 |
string::size_type start = 0;
|
|
|
298 |
string::size_type pos = levelname.find_first_of("\\/");
|
|
|
299 |
while(pos != string::npos)
|
|
|
300 |
{
|
|
|
301 |
correctedname += levelname.substr(start, pos - start);
|
|
|
302 |
correctedname += DIR_SEPARATOR;
|
|
|
303 |
start = pos + 1;
|
|
|
304 |
pos = levelname.find_first_of("\\/", start);
|
|
|
305 |
}
|
|
|
306 |
// found the levelname; filename
|
|
|
307 |
correctedname += levelname.substr(start);
|
|
|
308 |
levelname = toLowerCaseWin(correctedname);
|
|
12
|
309 |
isFileMatched = false;
|
|
0
|
310 |
|
|
12
|
311 |
// For baseline, need to list only those macros,which are belonging to bundle files.
|
|
|
312 |
if (isbaseline == true)
|
|
|
313 |
{
|
|
|
314 |
vector<pair<string, string> >::iterator begin = files.begin();
|
|
|
315 |
vector<pair<string, string> >::iterator end = files.end();
|
|
|
316 |
for(; begin != end; begin++)
|
|
|
317 |
{
|
|
|
318 |
if (begin->first == levelname)
|
|
|
319 |
{
|
|
|
320 |
isFileMatched = true;
|
|
|
321 |
levelname = begin->second;
|
|
|
322 |
break;
|
|
|
323 |
}
|
|
|
324 |
}
|
|
|
325 |
}
|
|
|
326 |
else // current macro file, so search macros in the entire file
|
|
|
327 |
{
|
|
|
328 |
isFileMatched = true;
|
|
|
329 |
levelname = KEY_VAL_CURRENT; // set a generic key_val for all current macros
|
|
|
330 |
}
|
|
0
|
331 |
}
|
|
|
332 |
}
|
|
12
|
333 |
else if (isFileMatched == true && length > 8 && line.substr(0, 8) == "#define ")
|
|
0
|
334 |
{ // we found preprocessor directive #define
|
|
|
335 |
pair<string,string> macro = FindMacro(line);
|
|
|
336 |
// 'ret' contains the set of files and associated macros to be returned from function
|
|
|
337 |
map<string, list<pair<pair<string, string>,string> > >::iterator found = ret.find(levelname);
|
|
|
338 |
bool exist = false;
|
|
|
339 |
if( found != ret.end())
|
|
|
340 |
{
|
|
|
341 |
list< pair<pair<string, string>,string> >::iterator start = found->second.begin();
|
|
|
342 |
list< pair<pair<string, string>,string> >::iterator end = found->second.end();
|
|
|
343 |
|
|
|
344 |
// check if this macro is already defined, within this file(levelname)
|
|
|
345 |
while(start != end)
|
|
|
346 |
{
|
|
|
347 |
if( macro.first == start->first.first )
|
|
|
348 |
exist = true;
|
|
|
349 |
start++;
|
|
|
350 |
}
|
|
|
351 |
}
|
|
|
352 |
// if macro not found, add it to the list of macros associated with the current file
|
|
|
353 |
if( !exist )
|
|
|
354 |
{
|
|
|
355 |
pair<pair<string,string>,string> tempVal(macro,tempNo);
|
|
|
356 |
// if file already defined, only add the macro
|
|
|
357 |
if (found != ret.end())
|
|
|
358 |
{
|
|
|
359 |
found->second.push_back(tempVal);
|
|
|
360 |
}
|
|
|
361 |
// else add both filename and asssociated macro
|
|
|
362 |
else
|
|
|
363 |
{
|
|
|
364 |
list<pair<pair<string, string>,string> > values;
|
|
|
365 |
values.push_back(tempVal);
|
|
|
366 |
pair<string, list<pair<pair<string, string>,string> > > newfile(levelname, values);
|
|
|
367 |
ret.insert(newfile);
|
|
|
368 |
}
|
|
|
369 |
// perform the same test as above on aRemoved data structure
|
|
|
370 |
// this will be used for finding any duplicate macro definitions
|
|
12
|
371 |
if (isbaseline == true)
|
|
0
|
372 |
{
|
|
|
373 |
pair<string,string> temp(macro.first,tempNo);
|
|
|
374 |
map<string, TChange<list<pair<string,string> > > >::iterator found2 = aRemoved->find(levelname);
|
|
|
375 |
if (found2 != aRemoved->end())
|
|
|
376 |
{
|
|
|
377 |
found2->second.GetValue().push_back(temp);
|
|
|
378 |
} else
|
|
|
379 |
{
|
|
|
380 |
list<pair<string,string> > values;
|
|
|
381 |
values.push_back(temp);
|
|
|
382 |
TChange<list<pair<string,string> > > tempvar(levelname, values);
|
|
|
383 |
pair<string, TChange<list<pair<string,string> > > > newfile(levelname, tempvar);
|
|
|
384 |
aRemoved->insert(newfile);
|
|
|
385 |
}
|
|
|
386 |
}
|
|
|
387 |
} //if(!exist)
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
return ret;
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
// ----------------------------------------------------------------------------
|
|
|
394 |
// MacroAnalyser::findDuplicates
|
|
|
395 |
// ----------------------------------------------------------------------------
|
|
|
396 |
//
|
|
|
397 |
bool MacroAnalyser::findDuplicates(const string& basefilename, const string& currentfilename, list<pair<pair<string, string>,string> >& aBaseline, list<pair<pair<string, string>,string> >& aCurrent, TChange<list<pair<string,string> > >& aRemovedList, map<string, vector<pair<string,string> > >& baselinedup, map<string, vector<pair<string,string> > >& currentdup)
|
|
|
398 |
{
|
|
|
399 |
bool ret = false;
|
|
|
400 |
map<pair<string,string>, int> dups;
|
|
|
401 |
list<pair<pair<string, string>,string> >::iterator begin = aBaseline.begin();
|
|
|
402 |
list<pair<pair<string, string>,string> >::iterator end = aBaseline.end();
|
|
|
403 |
bool found = false;
|
|
|
404 |
while(begin != end)
|
|
|
405 |
{
|
|
|
406 |
found = false;
|
|
|
407 |
list<pair<pair<string, string>,string> >::iterator duplicates = begin;
|
|
|
408 |
duplicates++;
|
|
|
409 |
string original = begin->first.first;
|
|
|
410 |
pair<string,string> original1(original,begin->second);
|
|
|
411 |
while(duplicates != end)
|
|
|
412 |
{
|
|
|
413 |
if (original == duplicates->first.first)
|
|
|
414 |
{
|
|
|
415 |
found = true;
|
|
|
416 |
pair<pair<string,string>, int> tempvar(original1, 1);
|
|
|
417 |
dups.insert(tempvar);
|
|
|
418 |
duplicates = aBaseline.erase(duplicates);
|
|
|
419 |
} else
|
|
|
420 |
{
|
|
|
421 |
duplicates++;
|
|
|
422 |
}
|
|
|
423 |
}
|
|
|
424 |
if(found)
|
|
|
425 |
{
|
|
|
426 |
ret = true;
|
|
|
427 |
aRemovedList.GetValue().remove(original1);
|
|
|
428 |
begin = aBaseline.erase(begin);
|
|
|
429 |
}
|
|
|
430 |
begin++;
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
if (dups.size() != 0)
|
|
|
434 |
{
|
|
|
435 |
vector<pair<string,string> > values;
|
|
|
436 |
values.reserve(dups.size());
|
|
|
437 |
map<pair<string,string>, int>::iterator dupsbegin = dups.begin();
|
|
|
438 |
map<pair<string,string>, int>::iterator dupsend = dups.end();
|
|
|
439 |
for(; dupsbegin != dupsend; dupsbegin++)
|
|
|
440 |
{
|
|
|
441 |
values.push_back(dupsbegin->first);
|
|
|
442 |
}
|
|
|
443 |
pair<string, vector<pair<string,string> > > tempvar(basefilename, values);
|
|
|
444 |
baselinedup.insert(tempvar);
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
dups.clear();
|
|
|
448 |
begin = aCurrent.begin();
|
|
|
449 |
end = aCurrent.end();
|
|
|
450 |
while(begin != end)
|
|
|
451 |
{
|
|
|
452 |
found = false;
|
|
|
453 |
list<pair<pair<string, string>,string> >::iterator duplicates = begin;
|
|
|
454 |
duplicates++;
|
|
|
455 |
string original = begin->first.first;
|
|
|
456 |
pair<string,string> original1(original,begin->second);
|
|
|
457 |
while(duplicates != end)
|
|
|
458 |
{
|
|
|
459 |
if (original == duplicates->first.first)
|
|
|
460 |
{
|
|
|
461 |
found = true;
|
|
|
462 |
pair<pair<string,string>, int> tempvar(original1, 1);
|
|
|
463 |
dups.insert(tempvar);
|
|
|
464 |
duplicates = aCurrent.erase(duplicates);
|
|
|
465 |
} else
|
|
|
466 |
{
|
|
|
467 |
duplicates++;
|
|
|
468 |
}
|
|
|
469 |
}
|
|
|
470 |
if (found == true)
|
|
|
471 |
{
|
|
|
472 |
ret = true;
|
|
|
473 |
begin = aCurrent.erase(begin);
|
|
|
474 |
} else
|
|
|
475 |
{
|
|
|
476 |
begin++;
|
|
|
477 |
}
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
if (dups.size() != 0)
|
|
|
481 |
{
|
|
|
482 |
vector<pair<string,string> > values;
|
|
|
483 |
values.reserve(dups.size());
|
|
|
484 |
map<pair<string,string>, int>::iterator dupsbegin = dups.begin();
|
|
|
485 |
map<pair<string,string>, int>::iterator dupsend = dups.end();
|
|
|
486 |
for(; dupsbegin != dupsend; dupsbegin++)
|
|
|
487 |
{
|
|
|
488 |
string macroname = dupsbegin->first.first;
|
|
|
489 |
pair<string,string> tempVal (macroname,dupsbegin->first.second);
|
|
|
490 |
begin = aBaseline.begin();
|
|
|
491 |
end = aBaseline.end();
|
|
|
492 |
for(; begin != end; begin++)
|
|
|
493 |
{ // we have to remove all macros, which have duplicates in current, from baseline
|
|
|
494 |
// so that there won't be unnecessary warnings of removed macros
|
|
|
495 |
if (begin->first.first == macroname)
|
|
|
496 |
{
|
|
|
497 |
aBaseline.erase(begin);
|
|
|
498 |
break;
|
|
|
499 |
}
|
|
|
500 |
}
|
|
|
501 |
values.push_back(tempVal);
|
|
|
502 |
}
|
|
|
503 |
pair<string, vector<pair<string,string> > > tempvar(currentfilename, values);
|
|
|
504 |
currentdup.insert(tempvar);
|
|
|
505 |
}
|
|
|
506 |
return ret;
|
|
|
507 |
}
|