combine trees fix err not appearing

This commit is contained in:
vrd
2023-07-22 12:48:51 +03:00
parent 291168d507
commit 6a71d7e13c
6 changed files with 56 additions and 69 deletions
-8
View File
@@ -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);
} }
+8 -7
View File
@@ -9,8 +9,6 @@
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)
@@ -21,7 +19,7 @@ EventTime::EventTime(I16 Year, U8 Month, U16 Day, I8 Hour, I8 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);
@@ -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
View File
@@ -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;
+23 -7
View File
@@ -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;
} }
Tree tree( parseTftFile(argv[1]) );
/* bool negative = false; */
for(int i = 2; i < argc; ++i)
{
tree += parseTftFile(argv[i]);
/* if( !strcmp(argv[i], "-") ) */
/* { */
/* negative = true; */
/* } */
/* else */
/* { */
/* if(negative) */
/* tree -= parseTftFile(argv[i]); */
/* else */
/* tree += parseTftFile(argv[i]); */
/* } */
}
init(); init();
for(int i = 1; i < argc; ++i) tree.display();
{
parseTftFile(argv[i]).display();
}
return 0; return 0;
} }
-3
View File
@@ -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
{
}
} }
} }
-19
View File
@@ -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;