combine trees fix err not appearing
This commit is contained in:
@@ -101,7 +101,6 @@ namespace /* internal */
|
|||||||
{
|
{
|
||||||
endwin();
|
endwin();
|
||||||
cerr << "Unexpected end of file\n";
|
cerr << "Unexpected end of file\n";
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +108,6 @@ namespace /* internal */
|
|||||||
{
|
{
|
||||||
endwin();
|
endwin();
|
||||||
cerr << "Line " << line << ": Unexpected '" << c << "'\n";
|
cerr << "Line " << line << ": Unexpected '" << c << "'\n";
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +117,6 @@ namespace /* internal */
|
|||||||
cerr << "Line " << line << ": Expected " << what << " got ";
|
cerr << "Line " << line << ": Expected " << what << " got ";
|
||||||
cerr.write(instead.begin, instead.size());
|
cerr.write(instead.begin, instead.size());
|
||||||
cerr << " instead\n";
|
cerr << " instead\n";
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +127,6 @@ namespace /* internal */
|
|||||||
cerr << "Line " << line << ": Unexpected token '";
|
cerr << "Line " << line << ": Unexpected token '";
|
||||||
cerr.write(t.begin, t.size());
|
cerr.write(t.begin, t.size());
|
||||||
cerr << "'\n";
|
cerr << "'\n";
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +136,6 @@ namespace /* internal */
|
|||||||
cerr << "Line " << line << ": Illegal attribute '";
|
cerr << "Line " << line << ": Illegal attribute '";
|
||||||
cerr.write(attr.begin, attr.size());
|
cerr.write(attr.begin, attr.size());
|
||||||
cerr << "'\n";
|
cerr << "'\n";
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +144,6 @@ namespace /* internal */
|
|||||||
/* endwin(); */
|
/* endwin(); */
|
||||||
/* cerr << "Line " << line << ": two parents are already defined, " */
|
/* cerr << "Line " << line << ": two parents are already defined, " */
|
||||||
/* << extra_name << " is third\n"; */
|
/* << extra_name << " is third\n"; */
|
||||||
/* cerr.flush(); */
|
|
||||||
/* exit(1); */
|
/* exit(1); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
@@ -158,7 +152,6 @@ namespace /* internal */
|
|||||||
endwin();
|
endwin();
|
||||||
cerr << "Line " << line << ": '" << name << "' is undefined.\n"
|
cerr << "Line " << line << ": '" << name << "' is undefined.\n"
|
||||||
"Members need to be defined before they are used as relations\n";
|
"Members need to be defined before they are used as relations\n";
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +162,6 @@ namespace /* internal */
|
|||||||
<< "At most the index after a name can be the number of people with the "
|
<< "At most the index after a name can be the number of people with the "
|
||||||
"same name already defined - 1, since the count starts from 0.\n"
|
"same name already defined - 1, since the count starts from 0.\n"
|
||||||
"In this case the max is " << max << '\n';
|
"In this case the max is " << max << '\n';
|
||||||
cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-29
@@ -9,44 +9,42 @@
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
static WINDOW* info_tab;
|
|
||||||
|
|
||||||
EventTime::EventTime(I16 Year, U8 Month, U16 Day, I8 Hour, I8 Minute)
|
EventTime::EventTime(I16 Year, U8 Month, U16 Day, I8 Hour, I8 Minute)
|
||||||
: year(Year)
|
: year(Year)
|
||||||
, month(Month)
|
, month(Month)
|
||||||
, day(Day)
|
, day(Day)
|
||||||
, hour(Hour)
|
, hour(Hour)
|
||||||
, minute(Minute)
|
, minute(Minute)
|
||||||
{
|
{
|
||||||
assert(month <= 12 && day <= 31 && hour <= 23 && minute <= 59 && "Invalid EventTime data");
|
assert(month <= 12 && day <= 31 && hour <= 23 && minute <= 59 && "Invalid EventTime data");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTime::print() const
|
void EventTime::print(WINDOW* info_tab) const
|
||||||
{
|
{
|
||||||
if (day != UNKNOWN_DATE)
|
if (day != UNKNOWN_DATE)
|
||||||
wprintw(info_tab, "%d", day);
|
wprintw(info_tab, "%d", day);
|
||||||
else
|
else
|
||||||
waddstr(info_tab, "??");
|
waddstr(info_tab, "??");
|
||||||
waddch(info_tab, '.');
|
waddch(info_tab, '.');
|
||||||
|
|
||||||
if (month != UNKNOWN_DATE)
|
if (month != UNKNOWN_DATE)
|
||||||
wprintw(info_tab, "%d", month);
|
wprintw(info_tab, "%d", month);
|
||||||
else
|
else
|
||||||
waddstr(info_tab, "??");
|
waddstr(info_tab, "??");
|
||||||
waddch(info_tab, '.');
|
waddch(info_tab, '.');
|
||||||
|
|
||||||
if (year != UNKNOWN_DATE)
|
if (year != UNKNOWN_DATE)
|
||||||
wprintw(info_tab, "%d", year);
|
wprintw(info_tab, "%d", year);
|
||||||
else
|
else
|
||||||
waddstr(info_tab, "????");
|
waddstr(info_tab, "????");
|
||||||
waddch(info_tab, '\n');
|
waddch(info_tab, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Person::Person(const char* aName, EventTime aBirth, Sex aSex, EventTime aDeath)
|
Person::Person(const char* aName, EventTime aBirth, Sex aSex, EventTime aDeath)
|
||||||
: name(aName)
|
: name(aName)
|
||||||
, birth(aBirth)
|
, birth(aBirth)
|
||||||
, sex(aSex)
|
, sex(aSex)
|
||||||
, death(aDeath)
|
, death(aDeath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -54,21 +52,24 @@ Person::Person(const char* aName, EventTime aBirth, Sex aSex, EventTime aDeath)
|
|||||||
|
|
||||||
bool Person::operator==(const Person &other)const
|
bool Person::operator==(const Person &other)const
|
||||||
{
|
{
|
||||||
return name == other.name; //&& sex == other.sex; //TODO && day == other.day || !day || !other.day) && (month == other.month || !month || !other.month) && (year == other.year || !year || !other.year);
|
return sex == other.sex && name == other.name &&
|
||||||
|
(birth.day == other.birth.day || birth.day == EventTime::UNKNOWN_DATE || other.birth.day == EventTime::UNKNOWN_DATE) &&
|
||||||
|
(birth.month == other.birth.month || birth.month == EventTime::UNKNOWN_DATE || other.birth.month == EventTime::UNKNOWN_DATE) &&
|
||||||
|
(birth.year == other.birth.year || birth.year == EventTime::UNKNOWN_DATE || other.birth.year == EventTime::UNKNOWN_DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Person::displayInfo()const
|
void Person::displayInfo()const
|
||||||
{
|
{
|
||||||
info_tab = newwin(LINES, COLS, 0, 0);
|
WINDOW* info_tab = newwin(LINES, COLS, 0, 0);
|
||||||
|
|
||||||
waddstr(info_tab, name.data());
|
waddstr(info_tab, name.data());
|
||||||
waddch(info_tab,'\n');
|
waddch(info_tab,'\n');
|
||||||
|
|
||||||
waddstr(info_tab, "Birth: ");
|
waddstr(info_tab, "Birth: ");
|
||||||
birth.print();
|
birth.print(info_tab);
|
||||||
|
|
||||||
waddstr(info_tab, "Death: ");
|
waddstr(info_tab, "Death: ");
|
||||||
death.print();
|
death.print(info_tab);
|
||||||
|
|
||||||
mvwaddstr(info_tab, LINES-1, 0, "Press any key to return.");
|
mvwaddstr(info_tab, LINES-1, 0, "Press any key to return.");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ struct EventTime
|
|||||||
enum: I8 { UNKNOWN_TIME=-1 };
|
enum: I8 { UNKNOWN_TIME=-1 };
|
||||||
|
|
||||||
EventTime(I16 Year=UNKNOWN_DATE, U8 Month=UNKNOWN_DATE, U16 Day=UNKNOWN_DATE, I8 Hour=UNKNOWN_TIME, I8 Minute=UNKNOWN_TIME);
|
EventTime(I16 Year=UNKNOWN_DATE, U8 Month=UNKNOWN_DATE, U16 Day=UNKNOWN_DATE, I8 Hour=UNKNOWN_TIME, I8 Minute=UNKNOWN_TIME);
|
||||||
void print() const;
|
void print(WINDOW*) const;
|
||||||
|
|
||||||
I16 year; //The year in relation to Chritst's birth - 1 (AD) is the year He was born, -1 (BC) is the previous year. There is no year 0
|
I16 year; //The year in relation to Chritst's birth - 1 (AD) is the year He was born, -1 (BC) is the previous year. There is no year 0
|
||||||
U8 month;
|
U8 month;
|
||||||
|
|||||||
+22
-6
@@ -14,22 +14,38 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
{
|
{
|
||||||
cout << "Usage: tft FILE...\n";
|
cout << "Usage: tft FILES...\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!strcmp(argv[1], "--help"))
|
if(!strcmp(argv[1], "--help"))
|
||||||
{
|
{
|
||||||
cout << "Usage: tft FILE...\n"
|
cout << "Usage: tft FILES...\n"
|
||||||
<< "Display the family tree in each FILE\n";
|
<< "Display the combined family tree in the FILES\n";
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
Tree tree( parseTftFile(argv[1]) );
|
||||||
for(int i = 1; i < argc; ++i)
|
/* bool negative = false; */
|
||||||
|
|
||||||
|
for(int i = 2; i < argc; ++i)
|
||||||
{
|
{
|
||||||
parseTftFile(argv[i]).display();
|
tree += parseTftFile(argv[i]);
|
||||||
|
/* if( !strcmp(argv[i], "-") ) */
|
||||||
|
/* { */
|
||||||
|
/* negative = true; */
|
||||||
|
/* } */
|
||||||
|
/* else */
|
||||||
|
/* { */
|
||||||
|
/* if(negative) */
|
||||||
|
/* tree -= parseTftFile(argv[i]); */
|
||||||
|
/* else */
|
||||||
|
/* tree += parseTftFile(argv[i]); */
|
||||||
|
/* } */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
tree.display();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,9 +61,6 @@ Tree& Tree::operator+=(const Tree& other)
|
|||||||
{
|
{
|
||||||
if(newId[rel.id] >= initNum) /* not already in I */
|
if(newId[rel.id] >= initNum) /* not already in I */
|
||||||
relations[idIn1].push_back( {newId[rel.id], rel.type} );
|
relations[idIn1].push_back( {newId[rel.id], rel.type} );
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-22
@@ -6,24 +6,6 @@
|
|||||||
#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");
|
||||||
@@ -62,7 +44,6 @@ fd_t openOrDie(const char* path)
|
|||||||
{
|
{
|
||||||
endwin();
|
endwin();
|
||||||
std::cerr << "Can't open: " << path << '\n';
|
std::cerr << "Can't open: " << path << '\n';
|
||||||
std::cerr.flush();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
@@ -81,7 +62,7 @@ void drawpad(WINDOW* pad, I16 drawY, I16 drawX)
|
|||||||
const U16 pbegX = drawX>0 ? 0 : -drawX;
|
const U16 pbegX = drawX>0 ? 0 : -drawX;
|
||||||
|
|
||||||
pnoutrefresh(pad,
|
pnoutrefresh(pad,
|
||||||
pbegY, pbegX,
|
pbegY, pbegX,
|
||||||
drawY, drawX,
|
drawY, drawX,
|
||||||
LINES - 1, COLS - 1);
|
LINES - 1, COLS - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user