Small improvement
This commit is contained in:
parent
ff629d543a
commit
4431f1ff69
|
@ -9,9 +9,6 @@
|
|||
|
||||
using namespace antlr4;
|
||||
|
||||
ANTLRFileStream::ANTLRFileStream(): ANTLRInputStream() {
|
||||
}
|
||||
|
||||
void ANTLRFileStream::loadFromFile(const std::string &fileName) {
|
||||
_fileName = fileName;
|
||||
if (_fileName.empty()) {
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace antlr4 {
|
|||
// TODO: this class needs testing.
|
||||
class ANTLR4CPP_PUBLIC ANTLRFileStream : public ANTLRInputStream {
|
||||
public:
|
||||
ANTLRFileStream();
|
||||
ANTLRFileStream() = default;
|
||||
ANTLRFileStream(const std::string &) = delete;
|
||||
ANTLRFileStream(const char *data, size_t length) = delete;
|
||||
ANTLRFileStream(std::istream &stream) = delete;
|
||||
|
|
|
@ -48,7 +48,7 @@ void ANTLRInputStream::load(const std::string &input) {
|
|||
void ANTLRInputStream::load(const char *data, size_t length) {
|
||||
// Remove the UTF-8 BOM if present.
|
||||
const char *bom = "\xef\xbb\xbf";
|
||||
if (length > 3 && strncmp(data, bom, 3) == 0)
|
||||
if (length >= 3 && strncmp(data, bom, 3) == 0)
|
||||
_data = antlrcpp::utf8_to_utf32(data + 3, data + length);
|
||||
else
|
||||
_data = antlrcpp::utf8_to_utf32(data, data + length);
|
||||
|
|
Loading…
Reference in New Issue