summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-10-23 10:47:21 +0200
committerClifford Wolf <clifford@clifford.at>2014-10-23 10:58:36 +0200
commitc5eb5e56b8911bb520a987761739bbb9d9328380 (patch)
tree6a578b95c4bc007bb87928df299f90391abfcc07 /frontends
parent750c615e7f01d44db4a7d504024b3681a56d8a78 (diff)
Re-introduced Yosys::readsome() helper function
(f.read() + f.gcount() made problems with lines > 16kB)
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ilang/ilang_lexer.l6
-rw-r--r--frontends/verilog/preproc.cc8
-rw-r--r--frontends/verilog/verilog_lexer.l6
3 files changed, 5 insertions, 15 deletions
diff --git a/frontends/ilang/ilang_lexer.l b/frontends/ilang/ilang_lexer.l
index dcbc6b6d..ace992fb 100644
--- a/frontends/ilang/ilang_lexer.l
+++ b/frontends/ilang/ilang_lexer.l
@@ -35,11 +35,7 @@
USING_YOSYS_NAMESPACE
#define YY_INPUT(buf,result,max_size) \
- do { \
- ILANG_FRONTEND::lexin->read(buf, max_size-1); \
- result = ILANG_FRONTEND::lexin->gcount(); \
- if (result >= 0) buf[result] = '\0'; \
- } while (0)
+ result = readsome(*ILANG_FRONTEND::lexin, buf, max_size)
%}
diff --git a/frontends/verilog/preproc.cc b/frontends/verilog/preproc.cc
index da658410..b4e77c31 100644
--- a/frontends/verilog/preproc.cc
+++ b/frontends/verilog/preproc.cc
@@ -196,16 +196,14 @@ static std::string next_token(bool pass_newline = false)
static void input_file(std::istream &f, std::string filename)
{
char buffer[513];
+ int rc;
insert_input("");
auto it = input_buffer.begin();
input_buffer.insert(it, "`file_push " + filename + "\n");
- while (1) {
- f.read(buffer, sizeof(buffer)-1);
- if (f.gcount() <= 0)
- break;
- buffer[f.gcount()] = 0;
+ while ((rc = readsome(f, buffer, sizeof(buffer)-1)) > 0) {
+ buffer[rc] = 0;
input_buffer.insert(it, buffer);
}
input_buffer.insert(it, "\n`file_pop\n");
diff --git a/frontends/verilog/verilog_lexer.l b/frontends/verilog/verilog_lexer.l
index 0d28e2e7..ae16ebf7 100644
--- a/frontends/verilog/verilog_lexer.l
+++ b/frontends/verilog/verilog_lexer.l
@@ -64,11 +64,7 @@ YOSYS_NAMESPACE_END
return TOK_ID;
#define YY_INPUT(buf,result,max_size) \
- do { \
- lexin->read(buf, max_size-1); \
- result = lexin->gcount(); \
- if (result >= 0) buf[result] = '\0'; \
- } while (0)
+ result = readsome(*VERILOG_FRONTEND::lexin, buf, max_size)
%}