forked from KolibriOS/kolibrios
CMM: remove strncpy() function, replace it by strlcpy() as more stable
git-svn-id: svn://kolibrios.org@5803 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
e72b02a21c
commit
1ed8c3d59c
@ -292,7 +292,7 @@ void Scan(dword id__)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(#URL,"http://",7);
|
strlcpy(#URL,"http://",7);
|
||||||
strcat(#URL, #editURL);
|
strcat(#URL, #editURL);
|
||||||
}
|
}
|
||||||
OpenPage();
|
OpenPage();
|
||||||
@ -336,7 +336,7 @@ void Scan(dword id__)
|
|||||||
return;
|
return;
|
||||||
case DOWNLOAD_MANAGER:
|
case DOWNLOAD_MANAGER:
|
||||||
if (!downloader_opened) {
|
if (!downloader_opened) {
|
||||||
strncpy(#DL_URL, "http://",7);
|
strlcpy(#DL_URL, "http://",7);
|
||||||
CreateThread(#Downloader,#downloader_stak+4092);
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
}
|
}
|
||||||
return; /*
|
return; /*
|
||||||
|
@ -397,7 +397,7 @@ void main()
|
|||||||
Paste();
|
Paste();
|
||||||
break;
|
break;
|
||||||
case 032: //Ctrl+D - set as bg
|
case 032: //Ctrl+D - set as bg
|
||||||
strncpy(#temp, "\\S__",4);
|
strlcpy(#temp, "\\S__",4);
|
||||||
strcat(#temp, #file_path);
|
strcat(#temp, #file_path);
|
||||||
RunProgram("/sys/media/kiv", #temp);
|
RunProgram("/sys/media/kiv", #temp);
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +94,7 @@ void GetSystemDiscs()
|
|||||||
for (j1=0; j1<dev_disc_num; j1++;)
|
for (j1=0; j1<dev_disc_num; j1++;)
|
||||||
{
|
{
|
||||||
l=sprintf(#sys_discs,"%s%s/",#dev_name,j1*304+ buf+72);
|
l=sprintf(#sys_discs,"%s%s/",#dev_name,j1*304+ buf+72);
|
||||||
strncpy(#disk_list[disc_num].Item, #sys_discs,l);
|
strlcpy(#disk_list[disc_num].Item, #sys_discs,l);
|
||||||
disc_num++;
|
disc_num++;
|
||||||
}
|
}
|
||||||
if (!strncmp(#sys_discs, "/rd/1/",6))
|
if (!strncmp(#sys_discs, "/rd/1/",6))
|
||||||
@ -102,7 +102,7 @@ void GetSystemDiscs()
|
|||||||
GetDir(#tempbuf, #temp_file_count, "/kolibrios/", DIRS_ONLYREAL);
|
GetDir(#tempbuf, #temp_file_count, "/kolibrios/", DIRS_ONLYREAL);
|
||||||
if (temp_file_count)
|
if (temp_file_count)
|
||||||
{
|
{
|
||||||
strncpy(#disk_list[disc_num].Item, "/kolibrios/",11);
|
strlcpy(#disk_list[disc_num].Item, "/kolibrios/",11);
|
||||||
kolibrios_drive = true;
|
kolibrios_drive = true;
|
||||||
disc_num++;
|
disc_num++;
|
||||||
}
|
}
|
||||||
|
@ -281,10 +281,10 @@ enum
|
|||||||
:dword ConvertSize(dword bytes)
|
:dword ConvertSize(dword bytes)
|
||||||
{
|
{
|
||||||
byte size_nm[4];
|
byte size_nm[4];
|
||||||
if (bytes>=1073741824) strncpy(#size_nm, "Gb",2);
|
if (bytes>=1073741824) strlcpy(#size_nm, "Gb",2);
|
||||||
else if (bytes>=1048576) strncpy(#size_nm, "Mb",2);
|
else if (bytes>=1048576) strlcpy(#size_nm, "Mb",2);
|
||||||
else if (bytes>=1024) strncpy(#size_nm, "Kb",2);
|
else if (bytes>=1024) strlcpy(#size_nm, "Kb",2);
|
||||||
else strncpy(#size_nm, "b ",2);
|
else strlcpy(#size_nm, "b ",2);
|
||||||
while (bytes>1023) bytes/=1024;
|
while (bytes>1023) bytes/=1024;
|
||||||
sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
|
sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
|
||||||
return #ConvertSize_size_prefix;
|
return #ConvertSize_size_prefix;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// strlen( EDI)
|
// strlen( EDI)
|
||||||
// utf8_strlen( ESI)
|
// utf8_strlen( ESI)
|
||||||
// strcpy( EDI, ESI) --- 0 if ==
|
// strcpy( EDI, ESI) --- 0 if ==
|
||||||
// strncpy(dword text1,text2,signed length)
|
// strlcpy(dword text1,text2,signed length)
|
||||||
// strcat( EDI, ESI)
|
// strcat( EDI, ESI)
|
||||||
// strncat(dword text1,text2,signed length) --- pasting the text of a certain length
|
// strncat(dword text1,text2,signed length) --- pasting the text of a certain length
|
||||||
// strchr( ESI,BL) --- find first BL
|
// strchr( ESI,BL) --- find first BL
|
||||||
@ -216,34 +216,6 @@ L2:
|
|||||||
$jnz L2
|
$jnz L2
|
||||||
}
|
}
|
||||||
|
|
||||||
inline dword strncpy(dword text1, text2, signed len)
|
|
||||||
signed o1,o2;
|
|
||||||
{
|
|
||||||
if(!text1)||(!len) return text1;
|
|
||||||
if(len<4)
|
|
||||||
{
|
|
||||||
o2 = len;
|
|
||||||
goto RUN_BYTE;
|
|
||||||
}
|
|
||||||
o1 = len/4;
|
|
||||||
o2 = len-4*o1;
|
|
||||||
while(o1){
|
|
||||||
DSDWORD[text1] = DSDWORD[text2];
|
|
||||||
text1 += 4;
|
|
||||||
text2 += 4;
|
|
||||||
$dec o1
|
|
||||||
}
|
|
||||||
RUN_BYTE:
|
|
||||||
while(o2){
|
|
||||||
DSBYTE[text1] = DSBYTE[text2];
|
|
||||||
$inc text1
|
|
||||||
$inc text2
|
|
||||||
$dec o2
|
|
||||||
}
|
|
||||||
DSBYTE[text1] = 0;
|
|
||||||
return text1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fastcall int strlcpy(dword ESI, EDI, EBX)
|
inline fastcall int strlcpy(dword ESI, EDI, EBX)
|
||||||
{
|
{
|
||||||
if (EBX<0) return -1;
|
if (EBX<0) return -1;
|
||||||
@ -759,7 +731,7 @@ inline dword strdup(dword text)
|
|||||||
dword l = strlen(text);
|
dword l = strlen(text);
|
||||||
dword ret = malloc(l+1);
|
dword ret = malloc(l+1);
|
||||||
if(!ret) return NULL;
|
if(!ret) return NULL;
|
||||||
strncpy(ret,text,l);
|
strlcpy(ret,text,l);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,7 +743,7 @@ inline dword strndup(dword str, signed maxlen)
|
|||||||
copy = malloc(len + 1);
|
copy = malloc(len + 1);
|
||||||
if (copy != NULL)
|
if (copy != NULL)
|
||||||
{
|
{
|
||||||
strncpy(copy, str, len);
|
strlcpy(copy, str, len);
|
||||||
DSBYTE[len+copy] = '\0';
|
DSBYTE[len+copy] = '\0';
|
||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -149,8 +149,6 @@ void main()
|
|||||||
mouse.get();
|
mouse.get();
|
||||||
if (tmp_x!=mouse.x) || (tmp_y!=mouse.y)
|
if (tmp_x!=mouse.x) || (tmp_y!=mouse.y)
|
||||||
{
|
{
|
||||||
debugi(mouse.x);
|
|
||||||
debugi(tmp_x);
|
|
||||||
z1 = Form.left + mouse.x - tmp_x;
|
z1 = Form.left + mouse.x - tmp_x;
|
||||||
z2 = Form.top + mouse.y - tmp_y;
|
z2 = Form.top + mouse.y - tmp_y;
|
||||||
if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width;
|
if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form.width-10)z1=screen.width-Form.width;
|
||||||
|
Loading…
Reference in New Issue
Block a user