From 7805691d0886d37900fbfc555f27abf203b7cd0c Mon Sep 17 00:00:00 2001 From: Coldy Date: Sun, 8 May 2022 08:22:31 +0000 Subject: [PATCH] shell: - fixed definitions - stack locals changed to heap variables (reduced app size) git-svn-id: svn://kolibrios.org@9808 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/shell/all.h | 4 ++-- programs/system/shell/cmd/cmd_ls.c | 3 ++- programs/system/shell/cmd/cmd_more.c | 3 ++- programs/system/shell/cmd/cmd_rm.c | 4 +++- programs/system/shell/cmd/cmd_rmdir.c | 4 +++- programs/system/shell/cmd/cmd_touch.c | 4 +++- programs/system/shell/system/kolibri.h | 1 + 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/programs/system/shell/all.h b/programs/system/shell/all.h index 6c6f5d8d44..191836967a 100644 --- a/programs/system/shell/all.h +++ b/programs/system/shell/all.h @@ -6,6 +6,8 @@ #include "lang.h" #endif +#include // Added by Coldy (this should be right here) + #include "system/boolean.h" #include "system/kolibri.h" //#include "system/stdlib.h" @@ -37,8 +39,6 @@ while (1) } //-------- -extern int _FUNC(sprintf)(char* buffer, const char* format, ...); - #include "globals.h" #include "prototypes.h" diff --git a/programs/system/shell/cmd/cmd_ls.c b/programs/system/shell/cmd/cmd_ls.c index 9a398d570f..f9efab442d 100644 --- a/programs/system/shell/cmd/cmd_ls.c +++ b/programs/system/shell/cmd/cmd_ls.c @@ -7,7 +7,7 @@ int cmd_ls(char dir[]) { unsigned *t; unsigned type_of_file; // check is this a file or a folder int i, result; - char tmp[FILENAME_MAX]; + char* tmp = (char*) malloc(FILENAME_MAX); bool single_column_mode = FALSE; @@ -121,6 +121,7 @@ int cmd_ls(char dir[]) { } free((void*)k70.p16); + free(tmp); return TRUE; } diff --git a/programs/system/shell/cmd/cmd_more.c b/programs/system/shell/cmd/cmd_more.c index cf6d72cc12..bd60284675 100644 --- a/programs/system/shell/cmd/cmd_more.c +++ b/programs/system/shell/cmd/cmd_more.c @@ -6,7 +6,7 @@ int cmd_more(char file[]) { unsigned result, i; unsigned long long filesize, pos; char buf[81]; //���� - char temp[FILENAME_MAX]; + char* temp = (char*) malloc(FILENAME_MAX); unsigned flags; if (strlen(file)<1) { @@ -87,6 +87,7 @@ int cmd_more(char file[]) { } con_set_flags(flags); printf ("\n\r"); + free(temp); return TRUE; } diff --git a/programs/system/shell/cmd/cmd_rm.c b/programs/system/shell/cmd/cmd_rm.c index 35adf3512e..2345173b44 100644 --- a/programs/system/shell/cmd/cmd_rm.c +++ b/programs/system/shell/cmd/cmd_rm.c @@ -2,7 +2,7 @@ int cmd_rm(char file[]) { kol_struct70 k70; - char temp[FILENAME_MAX]; + char* temp = (char*) malloc(FILENAME_MAX); unsigned result; if (NULL == file || strlen(file) == 0) { @@ -41,6 +41,8 @@ int cmd_rm(char file[]) { k70.p21 = temp; result = kol_file_70(&k70); + + free(temp); if (0 == result) return TRUE; diff --git a/programs/system/shell/cmd/cmd_rmdir.c b/programs/system/shell/cmd/cmd_rmdir.c index 75bef3c6d2..0f0135fb52 100644 --- a/programs/system/shell/cmd/cmd_rmdir.c +++ b/programs/system/shell/cmd/cmd_rmdir.c @@ -1,6 +1,6 @@ int cmd_rmdir(char dir[]) { - char temp[FILENAME_MAX]; + char* temp = (char*) malloc(FILENAME_MAX); kol_struct70 k70; unsigned result; @@ -35,6 +35,8 @@ int cmd_rmdir(char dir[]) { result = kol_file_70(&k70); + free(temp); + if (0 == result) return TRUE; else diff --git a/programs/system/shell/cmd/cmd_touch.c b/programs/system/shell/cmd/cmd_touch.c index be726bc977..e54c7a3ef8 100644 --- a/programs/system/shell/cmd/cmd_touch.c +++ b/programs/system/shell/cmd/cmd_touch.c @@ -2,7 +2,7 @@ int cmd_touch(char file[]) { kol_struct70 k70; - char temp[FILENAME_MAX]; + char* temp = (char*) malloc(FILENAME_MAX); unsigned result; if (NULL == file || strlen(file) == 0) { @@ -43,6 +43,8 @@ int cmd_touch(char file[]) result = kol_file_70(&k70); + free(temp); + if (0 == result) return TRUE; else diff --git a/programs/system/shell/system/kolibri.h b/programs/system/shell/system/kolibri.h index 2aabaa41ae..eb133e586c 100644 --- a/programs/system/shell/system/kolibri.h +++ b/programs/system/shell/system/kolibri.h @@ -12,6 +12,7 @@ #define E_NOMEM 30 #define E_PARAM 33 +#undef FILENAME_MAX // Added by Coldy (elimination of conflict with stdio.h) #define FILENAME_MAX 1024 #pragma pack(push,1)