Преглед на файлове

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

and the porgam would jsut essentially print spaced forever
master
FelixBrendel преди 6 години
родител
ревизия
814cceaf3d
променени са 5 файла, в които са добавени 51 реда и са изтрити 33 реда
  1. +23
    -21
      include/define_macros.hpp
  2. +5
    -0
      include/libslime.h
  3. +11
    -9
      src/define_macros.hpp
  4. +3
    -1
      src/error.cpp
  5. +9
    -2
      src/io.cpp

+ 23
- 21
include/define_macros.hpp Целия файл

@@ -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() \
@@ -21,18 +23,18 @@
} while(0)


#define try_or_else_return(val) \
if (1) \
goto label(body,__LINE__); \
else \
while (1) \
if (1) { \
if (Globals::error) { \
log_location(); \
return val; \
} \
break; \
} \
#define try_or_else_return(val) \
if (1) \
goto label(body,__LINE__); \
else \
while (1) \
if (1) { \
if (Globals::error) { \
log_location(); \
return val; \
} \
break; \
} \
else label(body,__LINE__):
;



+ 5
- 0
include/libslime.h Целия файл

@@ -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);


+ 11
- 9
src/define_macros.hpp Целия файл

@@ -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
src/error.cpp Целия файл

@@ -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
src/io.cpp Целия файл

@@ -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;


Зареждане…
Отказ
Запис