Small improvement

This commit is contained in:
Mike Lischke 2021-03-10 13:21:54 +01:00
parent ff629d543a
commit 4431f1ff69
3 changed files with 2 additions and 5 deletions

View File

@ -9,9 +9,6 @@
using namespace antlr4;
ANTLRFileStream::ANTLRFileStream(): ANTLRInputStream() {
}
void ANTLRFileStream::loadFromFile(const std::string &fileName) {
_fileName = fileName;
if (_fileName.empty()) {

View File

@ -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;

View File

@ -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);