mirror of
https://gitlab.freedesktop.org/uchardet/uchardet.git
synced 2025-12-07 17:26:41 +08:00
do not use std::string which breaks c++ abi
Some stl types can break abi. If the program is built with g++ 5, and libstdc++ on the target platform is g++ 4.x, then it can not run
This commit is contained in:
parent
84e292d1b9
commit
3a518c0536
@ -35,41 +35,47 @@
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
#include "uchardet.h"
|
#include "uchardet.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "nscore.h"
|
#include "nscore.h"
|
||||||
#include "nsUniversalDetector.h"
|
#include "nsUniversalDetector.h"
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
class HandleUniversalDetector : public nsUniversalDetector
|
class HandleUniversalDetector : public nsUniversalDetector
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
string m_charset;
|
char *m_charset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HandleUniversalDetector()
|
HandleUniversalDetector()
|
||||||
: nsUniversalDetector(NS_FILTER_ALL)
|
: nsUniversalDetector(NS_FILTER_ALL)
|
||||||
|
, m_charset(0)
|
||||||
{
|
{
|
||||||
m_charset = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~HandleUniversalDetector()
|
virtual ~HandleUniversalDetector()
|
||||||
{}
|
{
|
||||||
|
if (m_charset)
|
||||||
|
free(m_charset);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void Report(const char* charset)
|
virtual void Report(const char* charset)
|
||||||
{
|
{
|
||||||
m_charset = charset;
|
if (m_charset)
|
||||||
|
free(m_charset);
|
||||||
|
m_charset = strdup(charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Reset()
|
virtual void Reset()
|
||||||
{
|
{
|
||||||
nsUniversalDetector::Reset();
|
nsUniversalDetector::Reset();
|
||||||
m_charset = "";
|
if (m_charset)
|
||||||
|
free(m_charset);
|
||||||
|
m_charset = strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetCharset() const
|
const char* GetCharset() const
|
||||||
{
|
{
|
||||||
return m_charset.c_str();
|
return m_charset;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user