flush err
This commit is contained in:
+21
-12
@@ -4,17 +4,23 @@
|
||||
#include "tree.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
/* macros rather then function to avoid warnings */
|
||||
#define ERR_UNEXPECTED_END() { endwin(); cerr << "Unexpected end of file" << endl; exit(1); }
|
||||
#define ERR_UNEXPECTED_CHAR(c) { endwin(); cerr << "Line " << line << ": Unexpected '" << c << endl; exit(1); }
|
||||
|
||||
|
||||
using std::cerr;
|
||||
/* using std::string_view; */
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::endl;
|
||||
/* using std::endl; */
|
||||
|
||||
/* macros rather then function to avoid warnings */
|
||||
#define ERR_UNEXPECTED_END() { endwin(); \
|
||||
cerr << "Unexpected end of file\n"; \
|
||||
cerr.flush(); \
|
||||
exit(1); }
|
||||
|
||||
#define ERR_UNEXPECTED_CHAR(c) { endwin(); \
|
||||
cerr << "Line " << line << ": Unexpected '" << c << "'\n"; \
|
||||
cerr.flush(); \
|
||||
exit(1); }
|
||||
|
||||
namespace /* internal */
|
||||
{
|
||||
@@ -45,11 +51,11 @@ namespace /* internal */
|
||||
/* result */
|
||||
Tree* cur_tree;
|
||||
|
||||
void err_three_parents(const string& extra_name)
|
||||
void err_third_parent(const string& extra_name)
|
||||
{
|
||||
endwin();
|
||||
cerr << "Line " << line << " two parents are already defined, "
|
||||
<< extra_name << " is third" << endl;
|
||||
cerr << "Line " << line << ": two parents are already defined, "
|
||||
<< extra_name << " is third\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -177,7 +183,7 @@ namespace /* internal */
|
||||
else if(res.second == Nobody)
|
||||
res.second = cur_tree->findId(name)[same_name_index];
|
||||
else
|
||||
err_three_parents(name);
|
||||
err_third_parent(name);
|
||||
|
||||
same_name_index = 0;
|
||||
name.clear();
|
||||
@@ -190,9 +196,12 @@ namespace /* internal */
|
||||
case '\n':
|
||||
++line;
|
||||
if(res.first == Nobody)
|
||||
res.first = cur_tree->findId(name)[same_name_index];
|
||||
else
|
||||
res.first = cur_tree->findId(name)[same_name_index]; /* todo validate index */
|
||||
else if(res.second == Nobody)
|
||||
res.second = cur_tree->findId(name)[same_name_index];
|
||||
else
|
||||
err_third_parent(name);
|
||||
|
||||
return prev_parents = res;
|
||||
case '_':
|
||||
name.push_back(' ');
|
||||
|
||||
@@ -6,6 +6,24 @@
|
||||
#include <sys/mman.h>
|
||||
#include <iostream>
|
||||
|
||||
static void end()
|
||||
{
|
||||
/* printf("before end\n"); */
|
||||
/* fflush(stdout); */
|
||||
/* for(int i=0;i < 100;i) */
|
||||
/* { */
|
||||
/* printf("before end\n"); */
|
||||
/* fflush(stdout); */
|
||||
/* } */
|
||||
endwin();
|
||||
/* printf("done\n"); */
|
||||
/* fflush(stdout); */
|
||||
|
||||
/* std::cout <<"done\n"<<std::endl; */
|
||||
/* std::cout.flush(); */
|
||||
/* std::cerr.flush(); */
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
setlocale(LC_ALL, "en_US.UTF-8");
|
||||
|
||||
Reference in New Issue
Block a user