aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/import.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go/gofrontend/import.cc')
-rw-r--r--gcc/go/gofrontend/import.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc
index c63ae24..081afef 100644
--- a/gcc/go/gofrontend/import.cc
+++ b/gcc/go/gofrontend/import.cc
@@ -1487,7 +1487,7 @@ Stream_from_file::~Stream_from_file()
bool
Stream_from_file::do_peek(size_t length, const char** bytes)
{
- if (this->data_.length() <= length)
+ if (this->data_.length() >= length)
{
*bytes = this->data_.data();
return true;
@@ -1504,7 +1504,7 @@ Stream_from_file::do_peek(size_t length, const char** bytes)
return false;
}
- if (lseek(this->fd_, - got, SEEK_CUR) != 0)
+ if (lseek(this->fd_, - got, SEEK_CUR) < 0)
{
if (!this->saw_error())
go_fatal_error(Linemap::unknown_location(), "lseek failed: %m");
@@ -1524,7 +1524,7 @@ Stream_from_file::do_peek(size_t length, const char** bytes)
void
Stream_from_file::do_advance(size_t skip)
{
- if (lseek(this->fd_, skip, SEEK_CUR) != 0)
+ if (lseek(this->fd_, skip, SEEK_CUR) < 0)
{
if (!this->saw_error())
go_fatal_error(Linemap::unknown_location(), "lseek failed: %m");
@@ -1532,7 +1532,7 @@ Stream_from_file::do_advance(size_t skip)
}
if (!this->data_.empty())
{
- if (this->data_.length() < skip)
+ if (this->data_.length() > skip)
this->data_.erase(0, skip);
else
this->data_.clear();