Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Dreftool.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Rick Gessner <rick@gessner.com>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Kenneth Herron <kjh-5727@comcast.net>
|
|
|
|
* Bernd Mielke <bmlk@gmx.de>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
1999-08-04 19:44:15 +00:00
|
|
|
#include "nsString.h"
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
#include "prio.h"
|
|
|
|
#include "plstr.h"
|
1999-08-04 19:44:15 +00:00
|
|
|
#include "CScanner.h"
|
|
|
|
#include "CCPPTokenizer.h"
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
#include "nsReadableUtils.h"
|
1999-08-04 19:44:15 +00:00
|
|
|
#include "tokens.h"
|
|
|
|
#include "CToken.h"
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
#include "stdlib.h"
|
2003-11-18 20:52:01 +00:00
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsILocalFile.h"
|
|
|
|
#include "nsISimpleEnumerator.h"
|
2003-11-20 17:23:40 +00:00
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsILineInputStream.h"
|
|
|
|
#include "nsHashSets.h"
|
|
|
|
#include "nsNetUtil.h"
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
//*******************************************************************************
|
|
|
|
// Global variables...
|
|
|
|
//*******************************************************************************
|
|
|
|
bool gVerbose=false;
|
|
|
|
bool gShowIncludeErrors=false;
|
|
|
|
bool gEmitHTML=false;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
bool gSloppy=false;
|
|
|
|
const char *gRootDir;
|
2003-11-20 17:23:40 +00:00
|
|
|
const char *gWatchFile;
|
1999-08-04 19:44:15 +00:00
|
|
|
|
2003-11-20 17:23:40 +00:00
|
|
|
struct WatchLists {
|
|
|
|
nsCStringHashSet mTableC, mTableCPP;
|
|
|
|
};
|
|
|
|
|
|
|
|
WatchLists *gWatchLists;
|
|
|
|
nsCStringHashSet *gWatchList;
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
class IPattern {
|
|
|
|
public:
|
2003-11-18 20:52:01 +00:00
|
|
|
virtual CToken* scan(CCPPTokenizer& aTokenizer,int anIndex)=0;
|
1999-08-04 19:44:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CPattern {
|
|
|
|
public:
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
CPattern(const nsAFlatCString& aFilename)
|
|
|
|
: mNames(0),
|
|
|
|
mSafeNames(0),
|
|
|
|
mIndex(0),
|
|
|
|
mLineNumber(1),
|
|
|
|
mErrCount(0),
|
|
|
|
mFilename(aFilename)
|
|
|
|
{
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
|
2003-11-20 17:23:40 +00:00
|
|
|
CToken* matchID(nsDeque& aDeque,const nsAFlatCString& aName){
|
1999-08-04 19:44:15 +00:00
|
|
|
int theMax=aDeque.GetSize();
|
|
|
|
for(int theIndex=0;theIndex<theMax;theIndex++){
|
|
|
|
CToken* theToken=(CToken*)aDeque.ObjectAt(theIndex);
|
|
|
|
if(theToken){
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theName=theToken->getStringValue();
|
1999-08-04 19:44:15 +00:00
|
|
|
if(theName==aName) {
|
|
|
|
return theToken;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
This gets called when we know we've seen an if statement (at anIndex).
|
|
|
|
Look into the parm list (...) for an ID. If you find one, then you know
|
|
|
|
it's a conditioned identifier which can be safely ignored during other
|
|
|
|
error tests.
|
|
|
|
***************************************************************************/
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
CToken* findSafeIDInIfStatement(CCPPTokenizer& aTokenizer) {
|
1999-08-04 19:44:15 +00:00
|
|
|
CToken* result=0;
|
|
|
|
|
|
|
|
enum eState {eSkipLparen,eFindID};
|
|
|
|
eState theState=eSkipLparen;
|
|
|
|
CToken* theToken=0;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
while((theToken=aTokenizer.getTokenAt(++mIndex))) {
|
1999-08-04 19:44:15 +00:00
|
|
|
int theType=theToken->getTokenType();
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
switch(theState) {
|
|
|
|
case eSkipLparen:
|
|
|
|
//first scan for the lparen...
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
mLineNumber+=theString.CountChar('\n');
|
|
|
|
break;
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
case eToken_operator:
|
|
|
|
switch(theChar) {
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
case '(':
|
|
|
|
theState=eFindID;
|
|
|
|
break;
|
|
|
|
case ')':
|
|
|
|
return 0;
|
1999-08-04 19:44:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
|
|
|
|
//now scan for the identifier...
|
|
|
|
case eFindID:
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
|
|
|
mLineNumber+=theString.CountChar('\n'); break;
|
|
|
|
|
|
|
|
case eToken_identifier:
|
|
|
|
if(matchID(mNames,theString)) {
|
|
|
|
return theToken;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eToken_operator:
|
|
|
|
switch(theChar) {
|
|
|
|
case ')':
|
|
|
|
case ';':
|
|
|
|
case '{':
|
|
|
|
case '(':
|
|
|
|
return result;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
|
|
|
mLineNumber+=theString.CountChar('\n');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
This gets called when we know we've seen an NS_ENSURE_TRUE statement (at anIndex).
|
|
|
|
Look into the parm list (...) for an ID. If you find one, then you know
|
|
|
|
it's a conditioned identifier which can be safely ignored during other
|
|
|
|
error tests.
|
|
|
|
***************************************************************************/
|
|
|
|
CToken* findSafeIDInEnsureTrue(CCPPTokenizer& aTokenizer) {
|
|
|
|
|
|
|
|
CToken* result=0;
|
|
|
|
enum eState {eSkipLparen,eFindID};
|
|
|
|
eState theState=eSkipLparen;
|
|
|
|
CToken* theToken=0;
|
|
|
|
while((theToken=aTokenizer.getTokenAt(++mIndex))) {
|
|
|
|
int theType=theToken->getTokenType();
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
|
|
|
|
|
|
|
switch(theState) {
|
|
|
|
case eSkipLparen:
|
|
|
|
//first scan for the lparen...
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
|
|
|
mLineNumber+=theString.CountChar('\n');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eToken_operator:
|
|
|
|
switch(theChar) {
|
|
|
|
case '(':
|
|
|
|
theState=eFindID;
|
|
|
|
break;
|
|
|
|
case ')':
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
|
|
|
|
//now scan for the identifier...
|
|
|
|
case eFindID:
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
|
|
|
mLineNumber+=theString.CountChar('\n'); break;
|
|
|
|
|
|
|
|
case eToken_identifier:
|
|
|
|
if(matchID(mNames,theString)) {
|
|
|
|
return theToken;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eToken_operator:
|
|
|
|
switch(theChar) {
|
|
|
|
case ')':
|
|
|
|
case ';':
|
|
|
|
case '{':
|
|
|
|
case '(':
|
|
|
|
return result;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_newline:
|
|
|
|
mLineNumber+=theString.CountChar('\n');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
/***************************************************************************
|
|
|
|
We're looking for the variable that is new created by a new
|
|
|
|
***************************************************************************/
|
|
|
|
CToken* findNewVariable(CCPPTokenizer& aTokenizer, int anIndex){
|
|
|
|
CToken* theToken=0;
|
|
|
|
while((theToken=aTokenizer.getTokenAt(--anIndex))){
|
|
|
|
if(theToken) {
|
|
|
|
int theType=theToken->getTokenType();
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
switch(theType){
|
|
|
|
case eToken_semicolon:
|
|
|
|
return 0;
|
|
|
|
case eToken_operator:
|
|
|
|
if (!StringBeginsWith(theString,NS_LITERAL_CSTRING("="))){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eToken_identifier:
|
|
|
|
if (StringBeginsWith(theString,NS_LITERAL_CSTRING("return"))){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return theToken;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} //if
|
|
|
|
} //while
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
void check_unsafe_ID(CToken* theToken){
|
|
|
|
}
|
|
|
|
void check_save_ID(CToken* theToken){
|
|
|
|
}
|
1999-08-04 19:44:15 +00:00
|
|
|
/***************************************************************************
|
|
|
|
We're looking for the pattern foo-> without the preceeding (conditional) if():
|
|
|
|
Assume that the given id (aName) exists in the tokenizer at anIndex.
|
|
|
|
|
|
|
|
if(foo)
|
|
|
|
foo->
|
|
|
|
***************************************************************************/
|
|
|
|
CToken* findPtrDecl(CCPPTokenizer& aTokenizer,int anIndex,PRUnichar& anOpChar,bool allocRequired) {
|
|
|
|
|
|
|
|
enum eState {eFindNew,eFindType,eFindPunct,eFindStar};
|
|
|
|
CToken* theToken=0;
|
|
|
|
CToken* theID=0;
|
|
|
|
eState theState=eFindStar;
|
|
|
|
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
while((theToken=aTokenizer.getTokenAt(++anIndex))){
|
1999-08-04 19:44:15 +00:00
|
|
|
if(theToken) {
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
1999-08-04 19:44:15 +00:00
|
|
|
int theType=theToken->getTokenType();
|
|
|
|
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
anOpChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
switch(theType){
|
|
|
|
|
|
|
|
case eToken_semicolon:
|
|
|
|
case eToken_operator:
|
|
|
|
switch(theState) {
|
|
|
|
case eFindStar:
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if('*'!=anOpChar)
|
|
|
|
return 0;
|
|
|
|
theState=eFindType;
|
1999-08-04 19:44:15 +00:00
|
|
|
break;
|
|
|
|
case eFindPunct:
|
|
|
|
switch(anOpChar) {
|
|
|
|
case '=':
|
|
|
|
if(!allocRequired)
|
|
|
|
return theID;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
theState=eFindNew;
|
1999-08-04 19:44:15 +00:00
|
|
|
break;
|
|
|
|
case ';':
|
|
|
|
return (allocRequired) ? 0 : theID;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eToken_identifier:
|
|
|
|
switch(theState){
|
|
|
|
case eFindType:
|
|
|
|
theID=theToken;
|
|
|
|
theState=eFindPunct;
|
|
|
|
break;
|
|
|
|
case eFindNew:
|
2003-11-20 17:23:40 +00:00
|
|
|
if (gWatchList->Contains(theString))
|
1999-08-04 19:44:15 +00:00
|
|
|
return theID;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
return 0;
|
1999-08-04 19:44:15 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}//if
|
|
|
|
}//while
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
We're looking for the pattern *foo.
|
|
|
|
***************************************************************************/
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
bool hasSimpleDeref(CCPPTokenizer& aTokenizer,int anIndex) {
|
1999-08-04 19:44:15 +00:00
|
|
|
bool result=false;
|
|
|
|
|
|
|
|
int theMin=anIndex-3;
|
|
|
|
for(int theIndex=anIndex-1;theIndex>theMin;theIndex--){
|
|
|
|
CToken* theToken=aTokenizer.getTokenAt(theIndex);
|
|
|
|
if(theToken) {
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
1999-08-04 19:44:15 +00:00
|
|
|
int theType=theToken->getTokenType();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
if(eToken_operator==theType) {
|
|
|
|
if('*'==theChar){
|
|
|
|
result=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(result) {
|
|
|
|
int theMax=anIndex+3;
|
|
|
|
for(int theIndex=anIndex;theIndex<theMax;theIndex++){
|
|
|
|
CToken* theToken=aTokenizer.getTokenAt(theIndex);
|
|
|
|
if(theToken) {
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
1999-08-04 19:44:15 +00:00
|
|
|
int theType=theToken->getTokenType();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
if(eToken_operator==theType) {
|
|
|
|
if((','==theChar) || (')'==theChar)){
|
|
|
|
result=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
We're looking for the pattern foo-> without the preceeding (conditional) if():
|
|
|
|
Assume that the given id (aName) exists in the tokenizer at anIndex.
|
|
|
|
|
|
|
|
if(foo)
|
|
|
|
foo->
|
|
|
|
***************************************************************************/
|
2003-11-20 17:23:40 +00:00
|
|
|
bool hasUnconditionedDeref(const nsAFlatCString& aName,CCPPTokenizer& aTokenizer,int anIndex) {
|
1999-08-04 19:44:15 +00:00
|
|
|
bool result=false;
|
|
|
|
|
|
|
|
enum eState {eFailure,eFindIf,eFindDeref};
|
|
|
|
eState theState=eFindDeref;
|
|
|
|
int theIndex=anIndex+1;
|
|
|
|
|
|
|
|
while(eFailure!=theState){
|
|
|
|
CToken* theToken=aTokenizer.getTokenAt(theIndex);
|
|
|
|
if(theToken) {
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
1999-08-04 19:44:15 +00:00
|
|
|
int theType=theToken->getTokenType();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
switch(theState){
|
|
|
|
case eFindDeref:
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_newline:
|
|
|
|
theIndex++;
|
|
|
|
break;
|
|
|
|
default:
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (StringBeginsWith(theString, NS_LITERAL_CSTRING("->"))) {
|
1999-08-04 19:44:15 +00:00
|
|
|
theIndex=anIndex-1; //now start looking backwards...
|
|
|
|
theState=eFindIf;
|
|
|
|
}
|
|
|
|
else theState=eFailure;
|
|
|
|
}//switch
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFindIf:
|
|
|
|
switch(theType) {
|
|
|
|
case eToken_whitespace:
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_newline:
|
|
|
|
theIndex--;
|
|
|
|
break;
|
|
|
|
case eToken_semicolon:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eToken_operator:
|
|
|
|
switch(theChar){
|
|
|
|
case '{':
|
|
|
|
case '+':
|
|
|
|
case '-':
|
|
|
|
case '=':
|
|
|
|
case '*':
|
|
|
|
case '%':
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
theIndex-=1;
|
|
|
|
break;
|
|
|
|
case eToken_identifier:
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (StringBeginsWith(theString, NS_LITERAL_CSTRING("if"))) {
|
1999-08-04 19:44:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (theString.Equals(aName)) {
|
1999-08-04 19:44:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (StringBeginsWith(theString, NS_LITERAL_CSTRING("while"))) {
|
1999-08-04 19:44:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
theIndex--;
|
|
|
|
} //switch
|
|
|
|
break;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
case eFailure:
|
|
|
|
break;
|
1999-08-04 19:44:15 +00:00
|
|
|
}//switch
|
|
|
|
}//if
|
|
|
|
else theState=eFailure;
|
|
|
|
}//while
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void skipSemi(CCPPTokenizer& aTokenizer) {
|
|
|
|
CToken* theToken=0;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
while((theToken=aTokenizer.getTokenAt(++mIndex))){
|
1999-08-04 19:44:15 +00:00
|
|
|
int theType=theToken->getTokenType();
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
switch(theType){
|
|
|
|
case eToken_semicolon:
|
|
|
|
return;
|
|
|
|
case eToken_operator:
|
|
|
|
if(('}'==theChar) || (';'==theChar))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case eToken_newline:
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_whitespace:
|
|
|
|
mLineNumber+=theString.CountChar('\n');
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
}//while
|
|
|
|
}
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
void OutputMozillaFilename() {
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
mFilename.ReplaceChar('\\','/');
|
|
|
|
PRInt32 pos=mFilename.RFind("/") + 1;
|
|
|
|
nsCAutoString entries,repository;
|
|
|
|
{
|
|
|
|
nsCAutoString cvsbase(
|
|
|
|
Substring(mFilename, 0, pos) +
|
|
|
|
NS_LITERAL_CSTRING("CVS/")
|
|
|
|
);
|
|
|
|
entries=cvsbase+NS_LITERAL_CSTRING("Entries");
|
|
|
|
repository=cvsbase+NS_LITERAL_CSTRING("Repository");
|
|
|
|
}
|
|
|
|
nsCAutoString filename(
|
|
|
|
Substring(mFilename, pos)
|
|
|
|
);
|
|
|
|
char cvspath[1024], cvsfilename[256], version[10], prefix;
|
|
|
|
bool found = false;
|
|
|
|
{
|
|
|
|
fstream cvsrecord (entries.get(),ios::in);
|
2003-11-18 20:52:01 +00:00
|
|
|
if (cvsrecord.is_open()) {
|
|
|
|
while (!cvsrecord.eof()) {
|
|
|
|
cvsrecord.get(prefix);
|
|
|
|
if (prefix=='/') {
|
|
|
|
cvsrecord.getline(cvsfilename,sizeof cvsfilename, '/');
|
|
|
|
if (found = !strcmp(filename.get(), cvsfilename))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cvsrecord.ignore(256,'\n');
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
}
|
2003-11-18 20:52:01 +00:00
|
|
|
if (found)
|
|
|
|
cvsrecord.getline(version,sizeof version, '/');
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
fstream cvsrecord (repository.get(),ios::in);
|
2003-11-18 20:52:01 +00:00
|
|
|
if (cvsrecord.is_open())
|
|
|
|
cvsrecord.getline(cvspath,sizeof cvspath);
|
|
|
|
else
|
|
|
|
cvspath[0]=0;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (cvspath[0])
|
|
|
|
filename =
|
|
|
|
NS_LITERAL_CSTRING("/") +
|
|
|
|
nsDependentCString(cvspath) +
|
|
|
|
NS_LITERAL_CSTRING("/") +
|
|
|
|
filename;
|
|
|
|
else
|
|
|
|
filename = mFilename;
|
|
|
|
}
|
2003-11-13 03:49:37 +00:00
|
|
|
pos=filename.Find("mozilla/");
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
const char* buf=filename.get();
|
|
|
|
|
1999-08-04 19:44:15 +00:00
|
|
|
if(-1<pos) {
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
buf+=pos+(found?0:8);
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
if(gEmitHTML)
|
|
|
|
fprintf(stdout, "<br><a href=\"");
|
|
|
|
if (found)
|
|
|
|
fprintf(stdout,
|
|
|
|
"http://bonsai.mozilla.org/cvsblame.cgi?file=%s"
|
|
|
|
"&rev=%s"
|
|
|
|
"&mark=%d"
|
|
|
|
"#%d",
|
|
|
|
buf,
|
|
|
|
version,
|
|
|
|
mLineNumber,
|
|
|
|
mLineNumber - 5);
|
|
|
|
else if (gEmitHTML)
|
|
|
|
fprintf(stdout,
|
|
|
|
"http://lxr.mozilla.org/mozilla/source/%s#%d",
|
|
|
|
buf,
|
|
|
|
mLineNumber);
|
|
|
|
else
|
|
|
|
fprintf(stdout,
|
|
|
|
"%s:%d",
|
|
|
|
buf,
|
|
|
|
mLineNumber);
|
|
|
|
if (gEmitHTML)
|
|
|
|
fprintf(stdout,
|
|
|
|
"\">%s:%d</a>",
|
|
|
|
buf,
|
|
|
|
mLineNumber);
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stdout, "%s", buf);
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
This method iterates the tokens (in tokenizer) looking for statements.
|
|
|
|
The statements are then decoded to find pointer variables. If they get a
|
|
|
|
new call, then they're recorded in mNames. If they're in an IF(), then
|
|
|
|
they're recording in mSafeNames. We also look for simple dereferences.
|
|
|
|
When we find one, we look it up in mSafeNames. If it's not there, we have
|
|
|
|
a potential deref error.
|
|
|
|
***************************************************************************/
|
2003-11-18 20:52:01 +00:00
|
|
|
void scan(CCPPTokenizer& aTokenizer){
|
1999-08-04 19:44:15 +00:00
|
|
|
int theMax=aTokenizer.getCount();
|
|
|
|
int theIDCount=mNames.GetSize();
|
|
|
|
int theSafeIDCount=mSafeNames.GetSize();
|
|
|
|
|
|
|
|
while(mIndex<theMax){
|
|
|
|
CToken* theToken=aTokenizer.getTokenAt(mIndex);
|
|
|
|
int theType=theToken->getTokenType();
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& theString=theToken->getStringValue();
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (!theString.IsEmpty())
|
1999-08-04 19:44:15 +00:00
|
|
|
switch(theType){
|
|
|
|
case eToken_operator:
|
|
|
|
{
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
char theChar=theString.First();
|
1999-08-04 19:44:15 +00:00
|
|
|
switch(theChar){
|
|
|
|
case '{':
|
|
|
|
mIndex++;
|
2003-11-18 20:52:01 +00:00
|
|
|
scan(aTokenizer);
|
1999-08-04 19:44:15 +00:00
|
|
|
break;
|
|
|
|
case '}':
|
|
|
|
//before returning, let's remove the new identifiers...
|
|
|
|
while(mNames.GetSize()>theIDCount){
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
mNames.Pop();
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
while(mSafeNames.GetSize()>theSafeIDCount){
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
mSafeNames.Pop();
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eToken_comment:
|
|
|
|
case eToken_newline:
|
|
|
|
case eToken_whitespace:
|
|
|
|
mLineNumber+=theString.CountChar('\n');
|
|
|
|
break;
|
|
|
|
|
|
|
|
//If it's an ID, then we're looking for 3 patterns:
|
|
|
|
// 1. ID* ID...;
|
|
|
|
// 2. *ID=ID;
|
|
|
|
// 3. ID->XXX;
|
|
|
|
case eToken_identifier:
|
|
|
|
{
|
|
|
|
PRUnichar theOpChar=0;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if((theToken=findPtrDecl(aTokenizer,mIndex,theOpChar,true))) {
|
1999-08-04 19:44:15 +00:00
|
|
|
//we found ID* ID; (or) ID* ID=...;
|
|
|
|
mNames.Push(theToken);
|
|
|
|
mIndex+=2;
|
|
|
|
skipSemi(aTokenizer);
|
|
|
|
}
|
|
|
|
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
else if (StringBeginsWith(theString, NS_LITERAL_CSTRING("if"))) {
|
|
|
|
CToken* theSafeID=findSafeIDInIfStatement(aTokenizer);
|
1999-08-04 19:44:15 +00:00
|
|
|
if(theSafeID) {
|
|
|
|
mSafeNames.Push(theSafeID);
|
|
|
|
theSafeIDCount++;
|
|
|
|
}
|
|
|
|
}
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
else if (StringBeginsWith(theString, NS_LITERAL_CSTRING("NS_ENSURE"))) {
|
|
|
|
CToken* theSafeID=findSafeIDInEnsureTrue(aTokenizer);
|
|
|
|
if (theSafeID) {
|
|
|
|
mSafeNames.Push(theSafeID);
|
|
|
|
theSafeIDCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!gSloppy &&
|
|
|
|
(theString.Equals(NS_LITERAL_CSTRING("new")))) {
|
|
|
|
CToken* theToken=findNewVariable(aTokenizer,mIndex);
|
|
|
|
if(theToken) {
|
|
|
|
mNames.Push(theToken);
|
|
|
|
theIDCount++;
|
|
|
|
CToken* lastSafe=(CToken*)mSafeNames.PeekFront();
|
|
|
|
if(lastSafe){
|
|
|
|
if(theToken==lastSafe){
|
|
|
|
mSafeNames.Pop();
|
|
|
|
theSafeIDCount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-08-04 19:44:15 +00:00
|
|
|
else {
|
|
|
|
CToken* theMatch=matchID(mNames,theString);
|
|
|
|
if(theMatch){
|
|
|
|
if((hasUnconditionedDeref(theString,aTokenizer,mIndex)) ||
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
(hasSimpleDeref(aTokenizer,mIndex))){
|
1999-08-04 19:44:15 +00:00
|
|
|
CToken* theSafeID=matchID(mSafeNames,theString);
|
|
|
|
if(theSafeID) {
|
2003-11-20 17:23:40 +00:00
|
|
|
const nsAFlatCString& s1=theSafeID->getStringValue();
|
1999-08-04 19:44:15 +00:00
|
|
|
if(s1.Equals(theString))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//dump the name out in LXR format
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
OutputMozillaFilename();
|
1999-08-04 19:44:15 +00:00
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stdout,
|
|
|
|
" Deref-error: \"%s\"\n",
|
|
|
|
theString.get());
|
1999-08-04 19:44:15 +00:00
|
|
|
mErrCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDeque mNames;
|
|
|
|
nsDeque mSafeNames;
|
|
|
|
int mIndex;
|
|
|
|
int mLineNumber;
|
|
|
|
int mErrCount;
|
|
|
|
nsCString mFilename;
|
|
|
|
};
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
void ScanFile(nsIFile *aFilename,int& aLineCount,int& anErrCount) {
|
|
|
|
nsCAutoString theCStr;
|
|
|
|
if (NS_FAILED(aFilename->GetNativePath(theCStr)) || theCStr.IsEmpty())
|
|
|
|
return;
|
|
|
|
fstream input(theCStr.get(),ios::in);
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
CScanner theScanner(input);
|
|
|
|
CCPPTokenizer theTokenizer;
|
1999-08-04 19:44:15 +00:00
|
|
|
theTokenizer.tokenize(theScanner);
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
CPattern thePattern(theCStr);
|
|
|
|
thePattern.scan(theTokenizer);
|
1999-08-04 19:44:15 +00:00
|
|
|
aLineCount+=thePattern.mLineNumber;
|
|
|
|
anErrCount+=thePattern.mErrCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
void IteratePath(nsIFile *aPath,
|
|
|
|
int& aFilecount,int& aLinecount,int& anErrcount)
|
|
|
|
{
|
|
|
|
PRBool is = PR_FALSE;
|
|
|
|
nsXPIDLCString name;
|
|
|
|
if (NS_FAILED(aPath->GetNativeLeafName(name)) ||
|
|
|
|
name.IsEmpty())
|
|
|
|
return;
|
|
|
|
if (NS_FAILED(aPath->IsSymlink(&is)) || is ||
|
|
|
|
NS_FAILED(aPath->IsSpecial(&is)) || is) {
|
|
|
|
fprintf(stderr, "Skipping: %s\n", name.get());
|
|
|
|
} else if (NS_SUCCEEDED(aPath->IsDirectory(&is)) && is &&
|
|
|
|
!name.Equals(NS_LITERAL_CSTRING("CVS"))) {
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> dirList;
|
|
|
|
if (NS_SUCCEEDED(aPath->GetDirectoryEntries(getter_AddRefs(dirList)))) {
|
|
|
|
while (NS_SUCCEEDED(dirList->HasMoreElements(&is)) && is) {
|
|
|
|
nsCOMPtr<nsISupports> thing;
|
|
|
|
nsCOMPtr<nsIFile> path;
|
|
|
|
if (NS_SUCCEEDED(dirList->GetNext(getter_AddRefs(thing))) &&
|
|
|
|
(path = do_QueryInterface(thing))) {
|
|
|
|
IteratePath(path, aFilecount, aLinecount, anErrcount);
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-20 17:23:40 +00:00
|
|
|
}
|
|
|
|
} else if (NS_SUCCEEDED(aPath->IsFile(&is)) && is) {
|
|
|
|
if (StringEndsWith(name, NS_LITERAL_CSTRING(".cpp"))) {
|
|
|
|
aFilecount++;
|
|
|
|
gWatchList=&gWatchLists->mTableCPP;
|
|
|
|
ScanFile(aPath,aLinecount,anErrcount);
|
|
|
|
} else if (StringEndsWith(name, NS_LITERAL_CSTRING(".c"))) {
|
|
|
|
aFilecount++;
|
|
|
|
gWatchList=&gWatchLists->mTableC;
|
|
|
|
ScanFile(aPath,aLinecount,anErrcount);
|
|
|
|
}
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
}
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
void ConsumeArguments(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
for(int index=1;index<argc;index++){
|
|
|
|
switch(argv[index][0]) {
|
|
|
|
case '-':
|
|
|
|
case '/':
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
switch(argv[index][1]){
|
|
|
|
case 'd':
|
|
|
|
case 'D': // Starting directory
|
2003-11-20 17:23:40 +00:00
|
|
|
gRootDir = argv[++index];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
case 'F': // list of functions to complain about
|
|
|
|
gWatchFile = argv[++index];
|
1999-08-04 19:44:15 +00:00
|
|
|
break;
|
|
|
|
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
case 'h':
|
|
|
|
case 'H': // Output HTML with lxr.mozilla.org links
|
1999-08-04 19:44:15 +00:00
|
|
|
gEmitHTML=true;
|
|
|
|
break;
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
case 's':
|
|
|
|
case 'S':
|
|
|
|
gSloppy=true; // Dont look for member variables
|
|
|
|
break;
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
default:
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stderr,
|
2003-11-20 17:23:40 +00:00
|
|
|
"Usage: dreftool [-h] [-s] [-f wordlist] [-d sourcepath]\n"
|
2003-11-18 20:52:01 +00:00
|
|
|
"-d path to root of source tree\n"
|
2003-11-20 17:23:40 +00:00
|
|
|
"-f file containing a list of functions which can return null\n"
|
|
|
|
"-h emit as HTML\n"
|
|
|
|
"-s sloppy mode: no warnings if member variables are used unsafe\n"
|
|
|
|
);
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
exit(1);
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]){
|
|
|
|
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
gRootDir = ".";
|
2003-11-20 17:23:40 +00:00
|
|
|
gWatchFile = "nullfunc.lst";
|
1999-08-04 19:44:15 +00:00
|
|
|
ConsumeArguments(argc,argv);
|
|
|
|
|
2003-11-20 17:23:40 +00:00
|
|
|
int fileCount=0, lineCount=0, errCount=0;
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
if(gEmitHTML) {
|
2003-11-20 17:23:40 +00:00
|
|
|
fprintf(stdout, "<html><title>DRefTool analysis");
|
|
|
|
if (gRootDir[0]!='.' || gRootDir[1])
|
|
|
|
fprintf(stdout, " for %s", gRootDir);
|
|
|
|
fprintf(stdout,"</title><body>\n");
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
{
|
2003-11-20 17:23:40 +00:00
|
|
|
WatchLists myWatchList;
|
|
|
|
if (NS_FAILED(myWatchList.mTableC.Init(16)) ||
|
|
|
|
NS_FAILED(myWatchList.mTableCPP.Init(16)))
|
|
|
|
return -1;
|
|
|
|
if (!gWatchFile) {
|
|
|
|
const char* wordList[] = {
|
|
|
|
"malloc",
|
|
|
|
"calloc",
|
|
|
|
"PR_Malloc",
|
|
|
|
"PR_Calloc",
|
|
|
|
"ToNewCString",
|
|
|
|
"ToNewUTF8String",
|
|
|
|
"ToNewUnicode",
|
|
|
|
"UTF8ToNewUnicode",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
int i=0;
|
|
|
|
while (const char* word=wordList[i++]) {
|
|
|
|
if (NS_FAILED(myWatchList.mTableC.Put(nsDependentCString(word))) ||
|
|
|
|
NS_FAILED(myWatchList.mTableCPP.Put(nsDependentCString(word))))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsILocalFile> file;
|
|
|
|
if (NS_FAILED(NS_NewNativeLocalFile(nsDependentCString(gWatchFile), PR_TRUE, getter_AddRefs(file))))
|
|
|
|
return -2;
|
|
|
|
nsCOMPtr<nsIInputStream> fileInputStream;
|
|
|
|
if (NS_FAILED(NS_NewLocalFileInputStream(getter_AddRefs(fileInputStream), file)))
|
|
|
|
return -3;
|
|
|
|
nsCOMPtr<nsILineInputStream> lineInputStream = do_QueryInterface(fileInputStream);
|
|
|
|
if (!lineInputStream)
|
|
|
|
return -4;
|
|
|
|
|
|
|
|
nsAutoString bufferUnicode;
|
|
|
|
nsCAutoString buffer;
|
|
|
|
PRBool isMore = PR_TRUE;
|
|
|
|
fprintf(stdout, "Function calls that will be checked for errors:\n");
|
|
|
|
if (gEmitHTML)
|
|
|
|
fprintf(stdout, "<ul>\n");
|
|
|
|
while (isMore && NS_SUCCEEDED(lineInputStream->ReadLine(bufferUnicode, &isMore))) {
|
|
|
|
LossyCopyUTF16toASCII(bufferUnicode, buffer);
|
|
|
|
if (NS_FAILED(myWatchList.mTableC.Put(buffer)) ||
|
|
|
|
NS_FAILED(myWatchList.mTableCPP.Put(buffer)))
|
|
|
|
return -1;
|
|
|
|
if (gEmitHTML)
|
|
|
|
fprintf(stdout, "<li>");
|
|
|
|
fprintf(stdout, "%s\n", buffer.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_FAILED(myWatchList.mTableCPP.Put(NS_LITERAL_CSTRING("new"))))
|
|
|
|
return -1;
|
|
|
|
if (gEmitHTML)
|
|
|
|
fprintf(stdout, "</ul>\n");
|
|
|
|
fprintf(stdout, "C++ only:\n");
|
|
|
|
if (gEmitHTML)
|
|
|
|
fprintf(stdout, "<ul>\n<li>");
|
|
|
|
fprintf(stdout, "new\n");
|
|
|
|
if (gEmitHTML)
|
|
|
|
fprintf(stdout, "</ul>\n");
|
|
|
|
fprintf(stdout, "\n");
|
|
|
|
gWatchLists = &myWatchList;
|
2003-11-18 20:52:01 +00:00
|
|
|
nsCOMPtr<nsIFile> root;
|
|
|
|
nsCOMPtr<nsILocalFile> localroot;
|
|
|
|
if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(gRootDir), PR_TRUE, getter_AddRefs(localroot))) &&
|
|
|
|
(root = do_QueryInterface(localroot)) &&
|
|
|
|
NS_SUCCEEDED(root->Normalize()))
|
|
|
|
IteratePath(root,fileCount,lineCount,errCount);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "Could not find path: %s\n", gRootDir);
|
|
|
|
}
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
if(gEmitHTML) {
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stdout, "<PRE>\n");
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stdout, "\nSummary");
|
Bug 8227 dreftool - rickg's phase 1 preventative crash maintenance
r=bernd
This is dreftool, resurrected with the help of kherron, bernd, and myself.
Licensing has been switched per http://bugzilla.mozilla.org/show_bug.cgi?id=8227#c45
to MPL/GPL/LGPL.
Old copies of xpcom classes have been removed, dreftool now uses the normal ones.
New:
* Builds on Linux and uses NSPR, so it should be possible to use it on most
systems.
* Member variables are screened.
* Tries to recognize NS_ENSURE early outs.
* Can parse a single file.
* The summary can indicate what it was told to parse.
* Links to LXR can be generated. Using this feature is not recommended as pieces of
mozilla tend to be on branches and the links will be bad. If for non branched content,
the links will drift as the files are changed.
* Links to Bonsai against the file revision will be generated if CVS records are
detected. This is good, unless you have local modifications in your tree.
Known issues:
* Aliasing isn't detected, so
|a = new something; *foo = a; if (!*foo) return NS_ERROR_FAILURE;| is flagged.
e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.33&mark=920-921,922,923,925#920
* Assigning to dereferenced objects
|*foo = new something| is not quite correctly handled (perhaps it's misinterpreted as
|foo = new something|. e.x.
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/extensions/transformiix/source/xslt/txStandaloneXSLTProcessor.cpp&rev=1.11&mark=88,92,96,99,84#91
* Various other allocators aren't caught: strdup and co., nsCRT::, nsMemory::, ...
* There's no way to provide a user defined list of allocators.
People should of course not file bugs simply based on dreftool, they should file bugs
after verifying that the complaints from dreftool are valid.
2003-11-12 22:38:24 +00:00
|
|
|
if (gRootDir[0]!='.' || gRootDir[1])
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stdout, " for %s", gRootDir);
|
|
|
|
fprintf(stdout,
|
|
|
|
": \n"
|
|
|
|
"===============================\n"
|
|
|
|
"Files: %d\n"
|
|
|
|
"Lines: %d\n"
|
|
|
|
"Errors: %d\n",
|
|
|
|
fileCount,
|
|
|
|
lineCount,
|
|
|
|
errCount);
|
1999-08-04 19:44:15 +00:00
|
|
|
|
|
|
|
if(gEmitHTML) {
|
2003-11-18 20:52:01 +00:00
|
|
|
fprintf(stdout, "</PRE>\n</body></html>\n");
|
1999-08-04 19:44:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|