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
+3 -1
View File
@@ -5,7 +5,9 @@
do { \
if (Globals::log_level == Log_Level::Debug) { \
printf("in"); \
for (int i = 0; i < 30-strlen(__FILE__);++i) \
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__); \
+5
View File
@@ -149,6 +149,8 @@ namespace Slime {
String* message;
};
const wchar_t* char_to_wchar(const char* c);
char* read_entire_file(char* filename);
void add_to_load_path(const char*);
bool lisp_object_equal(Lisp_Object*,Lisp_Object*);
Lisp_Object* built_in_load(String*);
@@ -182,6 +184,9 @@ namespace Slime {
void generate_docs(String* path);
namespace Memory {
extern Lisp_Object* nil;
extern Lisp_Object* t;
Environment* create_built_ins_environment();
Lisp_Object* create_lisp_object_cfunction(bool is_special);
Lisp_Object* get_or_create_lisp_object_keyword(const char* identifier);
+3 -1
View File
@@ -5,7 +5,9 @@
do { \
if (Globals::log_level == Log_Level::Debug) { \
printf("in"); \
for (int i = 0; i < 30-strlen(__FILE__);++i) \
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__); \
+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;