зеркало из https://github.com/mozilla/gecko-dev.git
Bug 225994 DRefTool analysis for universalchardet files
r=smontagu sr=roc
This commit is contained in:
Родитель
e08f95f026
Коммит
504c031dee
|
@ -106,10 +106,10 @@ nsUniversalDetector::Reset()
|
||||||
#define SHORTCUT_THRESHOLD (float)0.95
|
#define SHORTCUT_THRESHOLD (float)0.95
|
||||||
#define MINIMUM_THRESHOLD (float)0.20
|
#define MINIMUM_THRESHOLD (float)0.20
|
||||||
|
|
||||||
void nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
nsresult nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
||||||
{
|
{
|
||||||
if(mDone)
|
if(mDone)
|
||||||
return;
|
return NS_OK;
|
||||||
|
|
||||||
if (aLen > 0)
|
if (aLen > 0)
|
||||||
mGotData = PR_TRUE;
|
mGotData = PR_TRUE;
|
||||||
|
@ -155,7 +155,7 @@ void nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
||||||
if (mDetectedCharset)
|
if (mDetectedCharset)
|
||||||
{
|
{
|
||||||
mDone = PR_TRUE;
|
mDone = PR_TRUE;
|
||||||
return;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,8 +203,11 @@ void nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
||||||
switch (mInputState)
|
switch (mInputState)
|
||||||
{
|
{
|
||||||
case eEscAscii:
|
case eEscAscii:
|
||||||
if (nsnull == mEscCharSetProber)
|
if (nsnull == mEscCharSetProber) {
|
||||||
mEscCharSetProber = new nsEscCharSetProber;
|
mEscCharSetProber = new nsEscCharSetProber;
|
||||||
|
if (nsnull == mEscCharSetProber)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
st = mEscCharSetProber->HandleData(aBuf, aLen);
|
st = mEscCharSetProber->HandleData(aBuf, aLen);
|
||||||
if (st == eFoundIt)
|
if (st == eFoundIt)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +223,7 @@ void nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
||||||
{
|
{
|
||||||
mDone = PR_TRUE;
|
mDone = PR_TRUE;
|
||||||
mDetectedCharset = mCharSetProbers[i]->GetCharSetName();
|
mDetectedCharset = mCharSetProbers[i]->GetCharSetName();
|
||||||
return;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -228,7 +231,7 @@ void nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
||||||
default: //pure ascii
|
default: //pure ascii
|
||||||
;//do nothing here
|
;//do nothing here
|
||||||
}
|
}
|
||||||
return ;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,19 +320,19 @@ NS_IMETHODIMP nsUniversalXPCOMDetector::DoIt(
|
||||||
NS_ASSERTION(mObserver != nsnull , "have not init yet");
|
NS_ASSERTION(mObserver != nsnull , "have not init yet");
|
||||||
|
|
||||||
if((nsnull == aBuf) || (nsnull == oDontFeedMe))
|
if((nsnull == aBuf) || (nsnull == oDontFeedMe))
|
||||||
return NS_ERROR_ILLEGAL_VALUE;
|
return NS_ERROR_ILLEGAL_VALUE;
|
||||||
|
|
||||||
|
nsresult rv = this->HandleData(aBuf, aLen);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
this->HandleData(aBuf, aLen);
|
|
||||||
|
|
||||||
if (mDone)
|
if (mDone)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mDetectedCharset)
|
if (mDetectedCharset)
|
||||||
{
|
{
|
||||||
Report(mDetectedCharset);
|
Report(mDetectedCharset);
|
||||||
}
|
}
|
||||||
|
*oDontFeedMe = PR_TRUE;
|
||||||
*oDontFeedMe = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
*oDontFeedMe = PR_FALSE;
|
*oDontFeedMe = PR_FALSE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -377,16 +380,18 @@ void nsUniversalXPCOMStringDetector::Report(const char *aCharset)
|
||||||
NS_IMETHODIMP nsUniversalXPCOMStringDetector::DoIt(const char* aBuf, PRUint32 aLen,
|
NS_IMETHODIMP nsUniversalXPCOMStringDetector::DoIt(const char* aBuf, PRUint32 aLen,
|
||||||
const char** oCharset, nsDetectionConfident &oConf)
|
const char** oCharset, nsDetectionConfident &oConf)
|
||||||
{
|
{
|
||||||
mResult = nsnull;
|
mResult = nsnull;
|
||||||
this->Reset();
|
this->Reset();
|
||||||
this->HandleData(aBuf, aLen);
|
nsresult rv = this->HandleData(aBuf, aLen);
|
||||||
this->DataEnd();
|
if (NS_FAILED(rv))
|
||||||
if (mResult)
|
return rv;
|
||||||
{
|
this->DataEnd();
|
||||||
*oCharset=mResult;
|
if (mResult)
|
||||||
oConf = eBestAnswer;
|
{
|
||||||
}
|
*oCharset=mResult;
|
||||||
return NS_OK;
|
oConf = eBestAnswer;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class nsUniversalDetector {
|
||||||
public:
|
public:
|
||||||
nsUniversalDetector();
|
nsUniversalDetector();
|
||||||
virtual ~nsUniversalDetector();
|
virtual ~nsUniversalDetector();
|
||||||
virtual void HandleData(const char* aBuf, PRUint32 aLen);
|
virtual nsresult HandleData(const char* aBuf, PRUint32 aLen);
|
||||||
virtual void DataEnd(void);
|
virtual void DataEnd(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче