3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 09:05:32 +00:00

Fixed win32 troubles with f.readsome()

This commit is contained in:
Clifford Wolf 2014-10-11 11:36:22 +02:00
parent a32e067e5c
commit 8263f6a74a
6 changed files with 21 additions and 4 deletions

View file

@ -166,6 +166,22 @@ bool patmatch(const char *pattern, const char *string)
return false;
}
int readsome(std::istream &f, char *s, int n)
{
int rc = f.readsome(s, n);
// win32 sometimes returns 0 on a non-empty stream..
if (rc == 0) {
int c = f.get();
if (c != EOF) {
*s = c;
rc = 1;
}
}
return rc;
}
int GetSize(RTLIL::Wire *wire)
{
return wire->width;

View file

@ -86,6 +86,7 @@ std::string stringf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))
std::string vstringf(const char *fmt, va_list ap);
std::string next_token(std::string &text, const char *sep);
bool patmatch(const char *pattern, const char *string);
int readsome(std::istream &f, char *s, int n);
template<typename T> int GetSize(const T &obj) { return obj.size(); }
int GetSize(RTLIL::Wire *wire);