84 continue; |
84 continue; |
85 } |
85 } |
86 removedbegin = iRemoved.find(basefilename); |
86 removedbegin = iRemoved.find(basefilename); |
87 if (removedbegin != iRemoved.end()) |
87 if (removedbegin != iRemoved.end()) |
88 { |
88 { |
89 map<string, list<pair<pair<string, string>,string> > >::iterator cur = current.find(curfilename); |
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); |
90 if (cur == current.end()) // We need to check if there is a list with given filename |
91 if (cur == current.end()) // We need to check if there is a list with given filename |
91 // because they aren't created in situation where there isn't any macros |
92 // because they aren't created in situation where there isn't any macros |
92 { // specific to that file or the include guard for the file is duplicated. |
93 { // specific to that file or the include guard for the file is duplicated. |
93 list<pair<pair<string, string>,string> > tempvar; |
94 list<pair<pair<string, string>,string> > tempvar; |
94 pair<string, list<pair<pair<string, string>,string> > > tempvar2(curfilename, tempvar); |
95 pair<string, list<pair<pair<string, string>,string> > > tempvar2(curfilename, tempvar); |
106 |
107 |
107 //maintain a cache list of files with macros |
108 //maintain a cache list of files with macros |
108 if(base->second.size() > 0) |
109 if(base->second.size() > 0) |
109 aMacroFiles.push_back(toLowerCaseWin(base->first)); |
110 aMacroFiles.push_back(toLowerCaseWin(base->first)); |
110 if(cur->second.size() > 0) |
111 if(cur->second.size() > 0) |
111 aMacroFiles.push_back(toLowerCaseWin(cur->first)); |
112 aMacroFiles.push_back(toLowerCaseWin(curfilename)); |
112 |
113 |
113 // After next loop we will have in list only those which has been either removed or changed |
114 // After next loop we will have in list only those which has been either removed or changed |
114 list<pair<pair<string, string>,string> >::iterator begin = cur->second.begin(); |
115 list<pair<pair<string, string>,string> >::iterator begin = cur->second.begin(); |
115 list<pair<pair<string, string>,string> >::iterator end = cur->second.end(); |
116 list<pair<pair<string, string>,string> >::iterator end = cur->second.end(); |
116 for(;begin != end; begin++) |
117 for(;begin != end; begin++) |
234 |
235 |
235 // ---------------------------------------------------------------------------- |
236 // ---------------------------------------------------------------------------- |
236 // MacroAnalyser::parseMacros |
237 // MacroAnalyser::parseMacros |
237 // ---------------------------------------------------------------------------- |
238 // ---------------------------------------------------------------------------- |
238 // |
239 // |
239 map<string, list<pair<pair<string, string>,string> > > MacroAnalyser::parseMacros(ifstream& aFile, vector<string>& bundlefiles, map<string, TChange<list<pair<string,string> > > >* aRemoved, bool aAddToRemoved) |
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) |
240 { |
241 { |
241 // ret, is the file and related set of macros returned by the function |
242 // ret, is the file and related set of macros returned by the function |
242 map<string, list<pair<pair<string, string>,string> > > ret; |
243 map<string, list<pair<pair<string, string>,string> > > ret; |
243 vector<pair<string, string> > files; |
244 vector<pair<string, string> > files; |
244 vector<string>::iterator bundlefile = bundlefiles.begin(); |
245 vector<string>::iterator bundlefile = bundlefiles.begin(); |
249 files.push_back(bothcase); |
250 files.push_back(bothcase); |
250 } |
251 } |
251 // Read macrofiles as lines |
252 // Read macrofiles as lines |
252 string cline; |
253 string cline; |
253 string levelname = ""; |
254 string levelname = ""; |
254 bool isbundle = false; |
255 bool isFileMatched = false; |
255 while((cline = getLine(aFile)) != KEmpty) |
256 while((cline = getLine(aFile)) != KEmpty) |
256 { |
257 { |
257 string line = cline; |
258 string line = cline; |
258 char tempNo[6]; |
259 char tempNo[6]; |
259 string lineNo; |
260 string lineNo; |
303 pos = levelname.find_first_of("\\/", start); |
304 pos = levelname.find_first_of("\\/", start); |
304 } |
305 } |
305 // found the levelname; filename |
306 // found the levelname; filename |
306 correctedname += levelname.substr(start); |
307 correctedname += levelname.substr(start); |
307 levelname = toLowerCaseWin(correctedname); |
308 levelname = toLowerCaseWin(correctedname); |
308 |
309 isFileMatched = false; |
309 vector<pair<string, string> >::iterator begin = files.begin(); |
310 |
310 vector<pair<string, string> >::iterator end = files.end(); |
311 // For baseline, need to list only those macros,which are belonging to bundle files. |
311 |
312 if (isbaseline == true) |
312 isbundle = false; |
313 { |
313 for(; begin != end; begin++) |
314 vector<pair<string, string> >::iterator begin = files.begin(); |
314 { |
315 vector<pair<string, string> >::iterator end = files.end(); |
315 if (begin->first == levelname) |
316 for(; begin != end; begin++) |
316 { |
317 { |
317 isbundle = true; |
318 if (begin->first == levelname) |
318 levelname = begin->second; |
319 { |
319 break; |
320 isFileMatched = true; |
320 } |
321 levelname = begin->second; |
321 } |
322 break; |
322 } |
323 } |
323 } |
324 } |
324 else if (isbundle == true && length > 8 && line.substr(0, 8) == "#define ") |
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 } |
|
331 } |
|
332 } |
|
333 else if (isFileMatched == true && length > 8 && line.substr(0, 8) == "#define ") |
325 { // we found preprocessor directive #define |
334 { // we found preprocessor directive #define |
326 pair<string,string> macro = FindMacro(line); |
335 pair<string,string> macro = FindMacro(line); |
327 // 'ret' contains the set of files and associated macros to be returned from function |
336 // 'ret' contains the set of files and associated macros to be returned from function |
328 map<string, list<pair<pair<string, string>,string> > >::iterator found = ret.find(levelname); |
337 map<string, list<pair<pair<string, string>,string> > >::iterator found = ret.find(levelname); |
329 bool exist = false; |
338 bool exist = false; |
357 pair<string, list<pair<pair<string, string>,string> > > newfile(levelname, values); |
366 pair<string, list<pair<pair<string, string>,string> > > newfile(levelname, values); |
358 ret.insert(newfile); |
367 ret.insert(newfile); |
359 } |
368 } |
360 // perform the same test as above on aRemoved data structure |
369 // perform the same test as above on aRemoved data structure |
361 // this will be used for finding any duplicate macro definitions |
370 // this will be used for finding any duplicate macro definitions |
362 if (aAddToRemoved == true) |
371 if (isbaseline == true) |
363 { |
372 { |
364 pair<string,string> temp(macro.first,tempNo); |
373 pair<string,string> temp(macro.first,tempNo); |
365 map<string, TChange<list<pair<string,string> > > >::iterator found2 = aRemoved->find(levelname); |
374 map<string, TChange<list<pair<string,string> > > >::iterator found2 = aRemoved->find(levelname); |
366 if (found2 != aRemoved->end()) |
375 if (found2 != aRemoved->end()) |
367 { |
376 { |