fix warnings add error info

This commit is contained in:
vrd
2023-03-11 18:38:16 +02:00
parent 84e4938683
commit 6fb3dbcaee
4 changed files with 33 additions and 25 deletions
+2 -1
View File
@@ -10,7 +10,8 @@ language='
warnings=' warnings='
-Wall -Wall
-Wextra' -Wextra
-Wno-implicit-fallthrough'
cd src cd src
g++ -o ../tft_debug $language -g -O0 -march=native $warnings -pipe *.cpp -lncursesw g++ -o ../tft_debug $language -g -O0 -march=native $warnings -pipe *.cpp -lncursesw
+2 -1
View File
@@ -19,7 +19,8 @@ optimizations='
warnings=' warnings='
-Wall -Wall
-Wextra' -Wextra
-Wno-implicit-fallthrough'
# -Wpedantic' #-fanalyzer # -Wpedantic' #-fanalyzer
+25 -19
View File
@@ -94,10 +94,12 @@ namespace /* internal */
exit(1); exit(1);
} }
[[noreturn]]void err_expected(const char* what) [[noreturn]]void err_expected(const char* what, token instead)
{ {
endwin(); endwin();
cerr << "Line " << line << ": Expected " << what << "\n"; cerr << "Line " << line << ": Expected " << what << "got";
cerr.write(instead.begin, instead.size());
cerr << "instead\n";
cerr.flush(); cerr.flush();
exit(1); exit(1);
} }
@@ -106,7 +108,9 @@ namespace /* internal */
[[noreturn]]void err_unexpected_token(token t) [[noreturn]]void err_unexpected_token(token t)
{ {
endwin(); endwin();
/* cerr << "Line " << line << ": Unexpected token '" << c << "'\n"; */ cerr << "Line " << line << ": Unexpected token '";
cerr.write(t.begin, t.size());
cerr << "'\n";
cerr.flush(); cerr.flush();
exit(1); exit(1);
} }
@@ -114,19 +118,21 @@ namespace /* internal */
[[noreturn]]void err_illegal_attribute(token attr) [[noreturn]]void err_illegal_attribute(token attr)
{ {
endwin(); endwin();
/* cerr << "Line " << line << ": Unexpected '" << c << "'\n"; */ cerr << "Line " << line << ": Illegal attribute '";
cerr.write(attr.begin, attr.size());
cerr << "'\n";
cerr.flush(); cerr.flush();
exit(1); exit(1);
} }
[[noreturn]]void err_thirdParent(const string& extra_name) /* [[noreturn]]void err_thirdParent(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\n"; /* << extra_name << " is third\n"; */
cerr.flush(); /* cerr.flush(); */
exit(1); /* exit(1); */
} /* } */
[[noreturn]]void err_personUndefined(const string& name) [[noreturn]]void err_personUndefined(const string& name)
{ {
@@ -232,7 +238,7 @@ namespace /* internal */
string parseName(TokenIt& it, TokenIt end) string parseName(TokenIt& it, TokenIt end)
{ {
if(it->type != STRING) if(it->type != STRING)
err_expected("name"); err_expected("name", *it);
string name; string name;
for(; it < end && it->type == STRING; ++it) for(; it < end && it->type == STRING; ++it)
@@ -287,11 +293,11 @@ namespace /* internal */
else if(it->begin[0] == 'F') else if(it->begin[0] == 'F')
res = F; res = F;
else else
err_expected("sex"); err_expected("sex", *it);
++it; ++it;
} }
else else
err_expected("sex"); err_expected("sex", *it);
} }
else else
@@ -331,7 +337,7 @@ namespace /* internal */
return sign * val; return sign * val;
} }
EventTime state_date(TokenIt& it, TokenIt end) /* todo validate */ EventTime state_date(TokenIt& it) /* todo validate */
{ {
++it; /* skip attribute */ ++it; /* skip attribute */
if(it->type == STRING || it->type == NUMBER) if(it->type == STRING || it->type == NUMBER)
@@ -357,7 +363,7 @@ namespace /* internal */
return date; return date;
} }
else else
err_expected("date"); err_expected("date", *it);
} }
@@ -470,10 +476,10 @@ namespace /* internal */
switch(it->begin[0]) switch(it->begin[0])
{ {
case 'b': case 'b':
birth = state_date(it, end); /* todo check for redefinition */ birth = state_date(it); /* todo check for redefinition */
break; break;
case 'd': case 'd':
death = state_date(it, end); death = state_date(it);
break; break;
case 'p': case 'p':
parents = processParents(it, end); parents = processParents(it, end);
+4 -4
View File
@@ -6,8 +6,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <iostream> #include <iostream>
static void end() /* static void end() */
{ /* { */
/* printf("before end\n"); */ /* printf("before end\n"); */
/* fflush(stdout); */ /* fflush(stdout); */
/* for(int i=0;i < 100;i) */ /* for(int i=0;i < 100;i) */
@@ -15,14 +15,14 @@ static void end()
/* printf("before end\n"); */ /* printf("before end\n"); */
/* fflush(stdout); */ /* fflush(stdout); */
/* } */ /* } */
endwin(); /* endwin(); */
/* printf("done\n"); */ /* printf("done\n"); */
/* fflush(stdout); */ /* fflush(stdout); */
/* std::cout <<"done\n"<<std::endl; */ /* std::cout <<"done\n"<<std::endl; */
/* std::cout.flush(); */ /* std::cout.flush(); */
/* std::cerr.flush(); */ /* std::cerr.flush(); */
} /* } */
void init() void init()
{ {