*polished code.
This commit is contained in:
parent
85d71edc68
commit
d3ecd6ced1
31
shell/main.c
31
shell/main.c
@ -403,7 +403,9 @@ static _code_line_t* _code(void) {
|
||||
}
|
||||
|
||||
static _code_line_t* _create_code(void) {
|
||||
_code_line_t* result = (_code_line_t*)malloc(sizeof(_code_line_t));
|
||||
_code_line_t* result = 0;
|
||||
|
||||
result = (_code_line_t*)malloc(sizeof(_code_line_t));
|
||||
result->count = 0;
|
||||
result->size = _LINE_INC_STEP;
|
||||
result->lines = (char**)malloc(sizeof(char*) * result->size);
|
||||
@ -560,9 +562,14 @@ static void _destroy_importing_directories(void) {
|
||||
}
|
||||
|
||||
static _importing_dirs_t* _set_importing_directories(char* dirs) {
|
||||
if(dirs) {
|
||||
char* end = dirs + strlen(dirs);
|
||||
_importing_dirs_t* result = (_importing_dirs_t*)malloc(sizeof(_importing_dirs_t));
|
||||
_importing_dirs_t* result = 0;
|
||||
char* end = 0;
|
||||
|
||||
if(!dirs)
|
||||
return result;
|
||||
|
||||
end = dirs + strlen(dirs);
|
||||
result = (_importing_dirs_t*)malloc(sizeof(_importing_dirs_t));
|
||||
result->count = 0;
|
||||
result->size = _LINE_INC_STEP;
|
||||
result->dirs = (char**)malloc(sizeof(char*) * result->size);
|
||||
@ -600,9 +607,6 @@ static _importing_dirs_t* _set_importing_directories(char* dirs) {
|
||||
importing_dirs = result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool_t _try_import(struct mb_interpreter_t* s, const char* p) {
|
||||
@ -785,7 +789,11 @@ static void _alter_program(const char* no) {
|
||||
}
|
||||
|
||||
static void _load_program(const char* path) {
|
||||
char* txt = _load_file(path);
|
||||
char* txt = 0;
|
||||
|
||||
mb_assert(path);
|
||||
|
||||
txt = _load_file(path);
|
||||
if(txt) {
|
||||
_new_program();
|
||||
_set_code(txt);
|
||||
@ -801,7 +809,11 @@ static void _load_program(const char* path) {
|
||||
}
|
||||
|
||||
static void _save_program(const char* path) {
|
||||
char* txt = _get_code();
|
||||
char* txt = 0;
|
||||
|
||||
mb_assert(path);
|
||||
|
||||
txt = _get_code();
|
||||
if(!_save_file(path, txt)) {
|
||||
_printf("Cannot save file \"%s\".\n", path);
|
||||
} else {
|
||||
@ -824,6 +836,7 @@ static void _kill_program(const char* path) {
|
||||
|
||||
static void _list_directory(const char* path) {
|
||||
char line[_MAX_LINE_LENGTH];
|
||||
|
||||
#ifdef MB_OS_WIN
|
||||
if(path && *path) sprintf(line, "dir %s", path);
|
||||
else sprintf(line, "dir");
|
||||
|
Loading…
x
Reference in New Issue
Block a user