mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-05 21:53:24 +00:00
liberty: Fix handling of non-ascii characters
Use an `unsigned char` buffer to ensure characters cast to an `int` are in the range 0 <= c <= 255.
This commit is contained in:
parent
ecf9c9f0cf
commit
5101b9fcba
2 changed files with 3 additions and 3 deletions
|
@ -75,7 +75,7 @@ bool LibertyInputStream::extend_buffer_once()
|
||||||
buffer.resize(buf_end + chunk_size);
|
buffer.resize(buf_end + chunk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t read_size = f.rdbuf()->sgetn(buffer.data() + buf_end, chunk_size);
|
size_t read_size = f.rdbuf()->sgetn((char *)buffer.data() + buf_end, chunk_size);
|
||||||
buf_end += read_size;
|
buf_end += read_size;
|
||||||
if (read_size < chunk_size)
|
if (read_size < chunk_size)
|
||||||
eof = true;
|
eof = true;
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace Yosys
|
||||||
|
|
||||||
class LibertyInputStream {
|
class LibertyInputStream {
|
||||||
std::istream &f;
|
std::istream &f;
|
||||||
std::vector<char> buffer;
|
std::vector<unsigned char> buffer;
|
||||||
size_t buf_pos = 0;
|
size_t buf_pos = 0;
|
||||||
size_t buf_end = 0;
|
size_t buf_end = 0;
|
||||||
bool eof = false;
|
bool eof = false;
|
||||||
|
@ -107,7 +107,7 @@ namespace Yosys
|
||||||
LibertyInputStream(std::istream &f) : f(f) {}
|
LibertyInputStream(std::istream &f) : f(f) {}
|
||||||
|
|
||||||
size_t buffered_size() { return buf_end - buf_pos; }
|
size_t buffered_size() { return buf_end - buf_pos; }
|
||||||
const char *buffered_data() { return buffer.data() + buf_pos; }
|
const unsigned char *buffered_data() { return buffer.data() + buf_pos; }
|
||||||
|
|
||||||
int get() {
|
int get() {
|
||||||
if (buf_pos == buf_end)
|
if (buf_pos == buf_end)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue