flush err

This commit is contained in:
vrd
2023-03-08 20:52:59 +02:00
parent 7b05b7c5c1
commit f4ca4211b2
4 changed files with 58 additions and 20 deletions
-8
View File
@@ -1,8 +0,0 @@
bin
.codelite
*.workspace
GPATH
GRTAGS
GTAGS
*.tft
+19
View File
@@ -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
View File
@@ -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(' ');
+18
View File
@@ -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");