mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-28 23:17:57 +00:00
Re-introduced Yosys::readsome() helper function
(f.read() + f.gcount() made problems with lines > 16kB)
This commit is contained in:
parent
750c615e7f
commit
c5eb5e56b8
6 changed files with 25 additions and 21 deletions
|
@ -97,6 +97,22 @@ std::string vstringf(const char *fmt, va_list ap)
|
|||
return string;
|
||||
}
|
||||
|
||||
int readsome(std::istream &f, char *s, int n)
|
||||
{
|
||||
int rc = f.readsome(s, n);
|
||||
|
||||
// f.readsome() sometimes returns 0 on a non-empty stream..
|
||||
if (rc == 0) {
|
||||
int c = f.get();
|
||||
if (c != EOF) {
|
||||
*s = c;
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
std::string next_token(std::string &text, const char *sep)
|
||||
{
|
||||
size_t pos_begin = text.find_first_not_of(sep);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue