flush err
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
bin
|
|
||||||
.codelite
|
|
||||||
*.workspace
|
|
||||||
GPATH
|
|
||||||
GRTAGS
|
|
||||||
GTAGS
|
|
||||||
|
|
||||||
*.tft
|
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
# This is a comment
|
||||||
|
# The dating in this tree is according to the Byzantine calendar but relative to Christ's birth
|
||||||
|
|
||||||
|
Adam, M # Adam is a male
|
||||||
|
b: -5509.9.06 # Birthday in format yyyy.mm.dd
|
||||||
|
|
||||||
|
Eve, F
|
||||||
|
b: -5509.9.06
|
||||||
|
s: Adam # Eve's spouse is Adam
|
||||||
|
|
||||||
|
Cain, M # Cain's birthday is unknown
|
||||||
|
p: Adam, Eve,steve # Cain's parents are Adam and Eve
|
||||||
|
|
||||||
|
Abel, M
|
||||||
|
p: - # Abel's parents are the same as the last person's (Cain)
|
||||||
|
|
||||||
|
Seth, M
|
||||||
|
b: -5279
|
||||||
|
p: -
|
||||||
+21
-12
@@ -4,17 +4,23 @@
|
|||||||
#include "tree.hpp"
|
#include "tree.hpp"
|
||||||
#include "utils.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::cerr;
|
||||||
/* using std::string_view; */
|
/* using std::string_view; */
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
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 */
|
namespace /* internal */
|
||||||
{
|
{
|
||||||
@@ -45,11 +51,11 @@ namespace /* internal */
|
|||||||
/* result */
|
/* result */
|
||||||
Tree* cur_tree;
|
Tree* cur_tree;
|
||||||
|
|
||||||
void err_three_parents(const string& extra_name)
|
void err_third_parent(const string& extra_name)
|
||||||
{
|
{
|
||||||
endwin();
|
endwin();
|
||||||
cerr << "Line " << line << " two parents are already defined, "
|
cerr << "Line " << line << ": two parents are already defined, "
|
||||||
<< extra_name << " is third" << endl;
|
<< extra_name << " is third\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +183,7 @@ namespace /* internal */
|
|||||||
else if(res.second == Nobody)
|
else if(res.second == Nobody)
|
||||||
res.second = cur_tree->findId(name)[same_name_index];
|
res.second = cur_tree->findId(name)[same_name_index];
|
||||||
else
|
else
|
||||||
err_three_parents(name);
|
err_third_parent(name);
|
||||||
|
|
||||||
same_name_index = 0;
|
same_name_index = 0;
|
||||||
name.clear();
|
name.clear();
|
||||||
@@ -190,9 +196,12 @@ namespace /* internal */
|
|||||||
case '\n':
|
case '\n':
|
||||||
++line;
|
++line;
|
||||||
if(res.first == Nobody)
|
if(res.first == Nobody)
|
||||||
res.first = cur_tree->findId(name)[same_name_index];
|
res.first = cur_tree->findId(name)[same_name_index]; /* todo validate index */
|
||||||
else
|
else if(res.second == Nobody)
|
||||||
res.second = cur_tree->findId(name)[same_name_index];
|
res.second = cur_tree->findId(name)[same_name_index];
|
||||||
|
else
|
||||||
|
err_third_parent(name);
|
||||||
|
|
||||||
return prev_parents = res;
|
return prev_parents = res;
|
||||||
case '_':
|
case '_':
|
||||||
name.push_back(' ');
|
name.push_back(' ');
|
||||||
|
|||||||
@@ -6,6 +6,24 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <iostream>
|
#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()
|
void init()
|
||||||
{
|
{
|
||||||
setlocale(LC_ALL, "en_US.UTF-8");
|
setlocale(LC_ALL, "en_US.UTF-8");
|
||||||
|
|||||||
Reference in New Issue
Block a user