cmm: reduce C-- app sizes by removing sprintf() from some apps and libs

git-svn-id: svn://kolibrios.org@7768 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-05 19:29:24 +00:00
parent b62308a5e1
commit 37a69c4efa
7 changed files with 41 additions and 16 deletions

View File

@ -132,7 +132,7 @@ void UpdateEditBoxes(dword f1, f2)
void EventGo() void EventGo()
{ {
char run_param[4096]; char run_param[4096];
sprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path); wsprintf(#run_param, "\"%s\" \"%s\"", #src_path, #dst_path);
RunProgram(I_Path, #run_param); RunProgram(I_Path, #run_param);
} }
#endif #endif

View File

@ -80,7 +80,9 @@ void DrawPreviewPhrase()
for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
{ {
if (colored.checked) c = pal[i-10]; else c=0; if (colored.checked) c = pal[i-10]; else c=0;
sprintf(#line,"<EFBFBD>妞丞 魰其<E9ADB0>/size font %d 祠花市巧.",i); strcpy(#line, "<EFBFBD>妞丞 魰其<E9ADB0>/forn size is ");
strcat(#line, itoa(i));
strcat(#line, " 祠花市巧/px.");
kfont.WriteIntoBuffer(14,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, c, i, #line); kfont.WriteIntoBuffer(14,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, c, i, #line);
} }
if (kfont.smooth) kfont.ApplySmooth(); if (kfont.smooth) kfont.ApplySmooth();

View File

@ -7,20 +7,22 @@
#endif #endif
#ifdef LANG_RUS #ifdef LANG_RUS
#define _TEXT_ERROR_ADD "'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨" #define _TEXT_ERROR_ADD "'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨\n"
#elif LANG_EST #elif LANG_EST
#define _TEXT_ERROR_ADD "'Viga teegi laadimisel" #define _TEXT_ERROR_ADD "'Viga teegi laadimisel\n"
#else #else
#define _TEXT_ERROR_ADD "'Error while loading library" #define _TEXT_ERROR_ADD "'Error while loading library\n"
#endif #endif
char a_libdir[43] = "/sys/lib/\0"; char a_libdir[43] = "/sys/lib/\0";
:inline void error_init(dword text) :inline void error_init(dword lirary_path)
{ {
dword TEXT_ERROR[1024]; char error_text[1024];
sprintf(TEXT_ERROR, "%s `%s`' -E",_TEXT_ERROR_ADD,text); strcpy(#error_text, _TEXT_ERROR_ADD);
notify(TEXT_ERROR); strcat(#error_text, lirary_path);
strcat(#error_text, "' -E");
notify(#error_text);
} }
// stdcall with 1 parameter // stdcall with 1 parameter

View File

@ -232,7 +232,9 @@
{ {
return PATH; return PATH;
} }
sprintf(#__PATH_NEW,"%s/%s",self.dir,PATH); strcpy(#__PATH_NEW, self.dir);
chrcat(#__PATH_NEW, '/');
strcpy(#__PATH_NEW, PATH);
return #__PATH_NEW; return #__PATH_NEW;
} }

View File

@ -867,6 +867,7 @@ inline cdecl int sprintf(dword buf, format,...)
strlcpy(buf,"0x00000000",10); strlcpy(buf,"0x00000000",10);
buf+=10; buf+=10;
l=buf; l=buf;
debugval("tmp", tmp);
while(tmp) while(tmp)
{ {
$dec buf $dec buf

View File

@ -1,4 +1,4 @@
#define MEMSIZE 4096*10 #define MEMSIZE 1024*40
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/clipboard.h" #include "../lib/clipboard.h"
@ -89,13 +89,29 @@ void draw_window()
EventUpdateWindowContent(); EventUpdateWindowContent();
} }
//copy of sprintf() => %A
void str2col(dword buf, number)
{
byte s;
strlcpy(buf,"0x00000000",10);
buf+=10;
while(number)
{
$dec buf
s=number&0xF;
if(s>9)DSBYTE[buf]='A'+s-10;
else DSBYTE[buf]='0'+s;
number>>=4;
}
}
void EventUpdateWindowContent() void EventUpdateWindowContent()
{ {
sprintf(#picked_color_string, "%A", picked_color); //sprintf(#picked_color_string, "%A", picked_color);
str2col(#picked_color_string, picked_color);
rgb.DwordToRgb(picked_color); rgb.DwordToRgb(picked_color);
EDI = 0xFFFfff; WriteTextWithBg(12,12, 0xD0, 0x000111, #picked_color_string+4, 0xFFFfff);
WriteText(12,12, 0xD0, 0x000111, #picked_color_string+4);
WriteNumber(12,33, 0xD0, 0xff0000, 3, rgb.r); WriteNumber(12,33, 0xD0, 0xff0000, 3, rgb.r);
WriteNumber(43,33, 0xD0, 0x008000, 3, rgb.g); WriteNumber(43,33, 0xD0, 0x008000, 3, rgb.g);

View File

@ -270,7 +270,8 @@ void EventShowFileProperties()
{ {
char ss_param[4096]; char ss_param[4096];
if (!param) return; if (!param) return;
sprintf(#ss_param, "-p %s", #param); strcpy(#ss_param, "-p ");
strcpy(#ss_param+3, #param);
RunProgram("/sys/File managers/Eolite", #ss_param); RunProgram("/sys/File managers/Eolite", #ss_param);
} }
@ -365,7 +366,8 @@ void EventMenuClick()
EventOpenFileInAnotherProgram("/sys/develop/heed"); EventOpenFileInAnotherProgram("/sys/develop/heed");
break; break;
case 25: case 25:
sprintf(#open_param,"~%s",#param); open_param[0]='~';
strcpy(#open_param+1,#param);
RunProgram("/sys/@open", #open_param); RunProgram("/sys/@open", #open_param);
break; break;
//ColorSchemes //ColorSchemes