fixed a bug where too long filenames would not be printed in errors

and the porgam would jsut essentially print spaced forever
This commit is contained in:
FelixBrendel
2019-10-24 00:11:57 +02:00
parent 6260359a83
commit 814cceaf3d
5 changed files with 51 additions and 33 deletions
+11 -9
View File
@@ -1,15 +1,17 @@
#define concat_( a, b) a##b
#define label(prefix, lnum) concat_(prefix,lnum)
#define log_location() \
do { \
if (Globals::log_level == Log_Level::Debug) { \
printf("in"); \
for (int i = 0; i < 30-strlen(__FILE__);++i) \
printf(" "); \
printf("%s (%d) ", __FILE__, __LINE__); \
printf("-> %s\n",__FUNCTION__); \
} \
#define log_location() \
do { \
if (Globals::log_level == Log_Level::Debug) { \
printf("in"); \
int spacing = 30-(int)strlen(__FILE__); \
if (spacing < 1) spacing = 1; \
for (int i = 0; i < spacing;++i) \
printf(" "); \
printf("%s (%d) ", __FILE__, __LINE__); \
printf("-> %s\n",__FUNCTION__); \
} \
} while(0)
#define if_error_log_location_and_return() \
+3 -1
View File
@@ -16,7 +16,9 @@ proc create_error(const char* c_func_name,const char* c_file_name, int c_file_li
printf("-");
printf("\nin");
for (int i = 0; i < 30-(strlen(c_file_name) - (int)log10(c_file_line)); ++i)
int spacing = 30-((int)strlen(c_file_name) - (int)log10(c_file_line));
if (spacing < 1) spacing = 1;
for (int i = 0; i < spacing; ++i)
printf(" ");
printf("%s (%d) ", c_file_name, c_file_line);
printf("-> %s\n", c_func_name);
+9 -2
View File
@@ -301,6 +301,13 @@ char* wchar_to_char(const wchar_t* pwchar) {
return filePathC;
}
const wchar_t* char_to_wchar(const char* c) {
const size_t cSize = strlen(c)+1;
wchar_t* wc = new wchar_t[cSize];
mbstowcs (wc, c, cSize);
return wc;
}
proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void {
switch (Memory::get_type(node)) {
case (Lisp_Object_Type::Nil): fputs("()", file); break;
@@ -339,10 +346,10 @@ proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void {
case (Lisp_Object_Type::Vector): {
fputs("[", file);
if (node->value.vector.length > 0)
print(node->value.vector.data);
print(node->value.vector.data, print_repr, file);
for (int i = 1; i < node->value.vector.length; ++i) {
fputs(" ", file);
print(node->value.vector.data+i);
print(node->value.vector.data+i, print_repr, file);
}
fputs("]", file);
} break;