forked from KolibriOS/kolibrios
Mistakes in functions of work with files and with system calls KolibriOS are corrected.
New functions for work with system calls KolibriOS are added. Functions for format output are added: printf (), fprintf (), sprintf (), snprintf (), vsnprintf (). For material numbers it is meanwhile supported only format output the (%f), and exponential output a (%e) is not realized yet. Functions for format output correctly work only in GCC because TinyC incorrectly works with the functions containing variable number of arguments. git-svn-id: svn://kolibrios.org@647 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include "ctype.h"
|
||||
int __is[128] = {
|
||||
0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
|
||||
0x004, 0x104, 0x104, 0x104, 0x104, 0x104, 0x004, 0x004,
|
||||
0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
|
||||
0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
|
||||
0x140, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0,
|
||||
0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0,
|
||||
0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459,
|
||||
0x459, 0x459, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0,
|
||||
0x0D0, 0x653, 0x653, 0x653, 0x653, 0x653, 0x653, 0x253,
|
||||
0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
|
||||
0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
|
||||
0x253, 0x253, 0x253, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x0D0,
|
||||
0x0D0, 0x473, 0x473, 0x473, 0x473, 0x473, 0x473, 0x073,
|
||||
0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
|
||||
0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
|
||||
0x073, 0x073, 0x073, 0x0D0, 0x0D0, 0x0D0, 0x0D0, 0x004
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
void* memchr(const void* buf,int c,int count)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<count;i++)
|
||||
if (*(char*)buf==c)
|
||||
return (void*)buf;
|
||||
else
|
||||
buf++;
|
||||
return (void*)0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
typedef unsigned char uc;
|
||||
int memcmp(const void* buf1,const void* buf2,int count)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<count;i++)
|
||||
{
|
||||
if (*(uc*)buf1<*(uc*)buf2)
|
||||
return -1;
|
||||
if (*(uc*)buf1>*(uc*)buf2)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
format ELF
|
||||
|
||||
section '.text' executable
|
||||
include 'proc32.inc'
|
||||
|
||||
public memcpy
|
||||
public memmove
|
||||
|
||||
proc memcpy stdcall, to:dword,from:dword,count:dword
|
||||
|
||||
mov ecx,[count]
|
||||
test ecx,ecx
|
||||
jz no_copy_block
|
||||
|
||||
mov esi,[from]
|
||||
mov edi,[to]
|
||||
rep movsb
|
||||
no_copy_block:
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
proc memmove stdcall, to:dword,from:dword,count:dword
|
||||
|
||||
mov ecx,[count]
|
||||
test ecx,ecx
|
||||
jz no_copy_block_
|
||||
|
||||
mov esi,[from]
|
||||
mov edi,[to]
|
||||
rep movsb
|
||||
no_copy_block_:
|
||||
|
||||
ret
|
||||
endp
|
||||
@@ -0,0 +1,15 @@
|
||||
format ELF
|
||||
section '.text' executable
|
||||
public memset
|
||||
memset:
|
||||
push edi
|
||||
mov edi,[esp+8]
|
||||
mov eax,[esp+12]
|
||||
mov ecx,[esp+16]
|
||||
jecxz .no_set
|
||||
cld
|
||||
rep stosb
|
||||
.no_set:
|
||||
pop edi
|
||||
ret
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
char* strcat(char* strDest, const char* strSource)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while (*strDest++) ;
|
||||
while (*strDest++ = *strSource++) ;
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
char* strchr(const char* string, int c)
|
||||
{
|
||||
while (*string)
|
||||
{
|
||||
if (*string==c)
|
||||
return (char*)string;
|
||||
string++;
|
||||
}
|
||||
return (char*)0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
int strcmp(const char* string1, const char* string2)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (*string1<*string2)
|
||||
return -1;
|
||||
if (*string1>*string2)
|
||||
return 1;
|
||||
if (*string1=='\0')
|
||||
return 0;
|
||||
string1++;
|
||||
string2++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int strcoll(const char* string1,const char* string2)
|
||||
{
|
||||
return strcmp(string1,string2);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
char* strcpy(char* strDest,char* strSource)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while(*strDest++ == strSource++) ;
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
int strcspn(const char* string, const char* strCharSet)
|
||||
{
|
||||
const char* temp;
|
||||
int i;
|
||||
i=0;
|
||||
while(1)
|
||||
{
|
||||
temp=strCharSet;
|
||||
while (*temp!='\0')
|
||||
{
|
||||
if (*string==*temp)
|
||||
return i;
|
||||
temp++;
|
||||
}
|
||||
i++;string++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
char* strdup(char* str)
|
||||
{
|
||||
char* res;
|
||||
int len;
|
||||
len=strlen(str)+1;
|
||||
res=malloc(len);
|
||||
memcpy(res,str,len);
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
char* strerror(int err)
|
||||
{
|
||||
return (char*)0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
int strlen(const char* string)
|
||||
{
|
||||
int i;
|
||||
i=0;
|
||||
while (*string++) i++;
|
||||
return i;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
char* strpbrk(const char* string, const char* strCharSet)
|
||||
{
|
||||
char* temp;
|
||||
while (*string!='\0')
|
||||
{
|
||||
temp=strCharSet;
|
||||
while (*temp!='\0')
|
||||
{
|
||||
if (*string==*temp)
|
||||
return string;
|
||||
temp++;
|
||||
}
|
||||
string++;
|
||||
}
|
||||
return (char*)0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
char* strncat(char* strDest,const char* strSource,int count)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while (*strDest++) ;
|
||||
while(count-->0)
|
||||
{
|
||||
if(*strDest++ = *strSource++) continue;
|
||||
return(res);
|
||||
}
|
||||
*strDest = 0;
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
int strncmp(const char* string1, const char* string2, int count)
|
||||
{
|
||||
while(count>0 && *string1==*string2)
|
||||
{
|
||||
if (*string1) return 0;
|
||||
++string1;
|
||||
++string2;
|
||||
--count;
|
||||
}
|
||||
if(count) return (*string1 - *string2);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
char* strncpy(char* strDest,const char* strSource,int count)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while (count>0)
|
||||
{
|
||||
*strDest=*strSource;
|
||||
if (*strSource!='\0')
|
||||
strSource++;
|
||||
strDest++;
|
||||
count--;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
char* strrchr(const char* s,int c)
|
||||
{
|
||||
char* res;
|
||||
res=(char*)0;
|
||||
while (1)
|
||||
{
|
||||
if (*s==(char)c)
|
||||
res=(char*)s;
|
||||
if (*s=='\0')
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
int strspn(const char* string,const char* strCharSet)
|
||||
{
|
||||
int i;
|
||||
const char* temp;
|
||||
i=0;
|
||||
while (*string!='\0')
|
||||
{
|
||||
temp=strCharSet;
|
||||
while (temp!='\0')
|
||||
{
|
||||
if (*temp==*string)
|
||||
break;
|
||||
}
|
||||
if (temp=='\0')
|
||||
break;
|
||||
*string++;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
extern int strncmp(char* s1,char* s2,int len);
|
||||
char* strstr(const char* s, const char* find)
|
||||
{
|
||||
int len;
|
||||
len=strlen(find);
|
||||
while (1)
|
||||
{
|
||||
if (strncmp(s,find,len)==0) return s;
|
||||
if (*s=='\0')
|
||||
return (char*) 0;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "string.h"
|
||||
char* strtok(char* s,const char* delim)
|
||||
{
|
||||
char* res;
|
||||
if (*s=='\0')
|
||||
return (char*)0;
|
||||
s+=strspn(s,delim);
|
||||
if (*s=='\0')
|
||||
return (char*)0;
|
||||
res=s;
|
||||
s+=strcspn(s,delim);
|
||||
*s=='\0';
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int strxfrm(char* strDest, const char* strSource, int count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user