From 64a38edddf98ab6e3f5ba7296302103c3419f7ca Mon Sep 17 00:00:00 2001 From: ygrek Date: Sun, 19 Oct 2008 21:49:33 +0300 Subject: [PATCH] fix segv and iostream problems --- lib-src/automata/iolexerbuf.cc | 9 ++++++++- prop-src/codegen.cc | 2 +- prop-src/lexer.cc | 1 + prop-src/simple.pcc | 12 +++++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib-src/automata/iolexerbuf.cc b/lib-src/automata/iolexerbuf.cc index c685189..630de1b 100644 --- a/lib-src/automata/iolexerbuf.cc +++ b/lib-src/automata/iolexerbuf.cc @@ -50,8 +50,15 @@ void IOLexerBuffer::allocate_buffer(size_t n) size_t IOLexerBuffer::read_buffer(char * buf, size_t n) { // Input one line at a time for interactive use. size_t len = input->get(buf, n - 1).gcount(); - if (input->peek() == '\n') { buf[len++] = input->get(); } + if (0 == len) + { + input->clear(); + } +// std::cout << len << std::endl; +// std::cout << (int)input->peek() << " " << input->eof() << std::endl; + if (input->peek() == '\n') { /*std::cout << "peeked \\n" << std::endl; */ buf[len++] = input->get(); } buf[len] = '\0'; +// std::cout << "returning " << len << std::endl; return len; } diff --git a/prop-src/codegen.cc b/prop-src/codegen.cc index 332463f..dcc93b3 100644 --- a/prop-src/codegen.cc +++ b/prop-src/codegen.cc @@ -283,7 +283,7 @@ list_1_(integer_ty,list_1_(mkptrty(QUALty(QUALconst,ty)))) (*output) << MatchCompiler::untag(exp,ty); } break; case '*': { Cons cons = va_arg(arg,Cons); - Bool normalized = va_arg(arg,Bool); + Bool normalized = va_arg(arg,int); (*output) << MatchCompiler::tag_name_of(cons, normalized); } break; diff --git a/prop-src/lexer.cc b/prop-src/lexer.cc index 1acd72b..b910ea1 100644 --- a/prop-src/lexer.cc +++ b/prop-src/lexer.cc @@ -43,6 +43,7 @@ /////////////////////////////////////////////////////////////////////////////// int PropParser::get_token() { + //std::cout << "get_token " << lexbuf.text() << std::endl; for (;;) { diff --git a/prop-src/simple.pcc b/prop-src/simple.pcc index ccf05a0..4200612 100644 --- a/prop-src/simple.pcc +++ b/prop-src/simple.pcc @@ -1,6 +1,8 @@ -datatype Exp = INT int => _ - | ADD (Exp, Exp) => _ "+" _ - | SUB (Exp, Exp) => _ "-" _ - | MUL (Exp, Exp) => _ "*" _ - | DIV (Exp, Exp) => _ "/" _ +datatype Exp = INT int + | ADD (Exp, Exp) + | SUB (Exp, Exp) + | MUL (Exp, Exp) + | DIV (Exp, Exp) ; + +datatype Q = Some int | None ; -- 2.11.4.GIT