libc testsuite + fixes

git-svn-id: svn://kolibrios.org@6433 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
siemargl
2016-05-19 12:15:22 +00:00
parent cd8030cee3
commit ace23ebbe2
86 changed files with 3327 additions and 197 deletions

View File

@@ -2,8 +2,17 @@
int fputc(int c,FILE* file)
{
dword res;
if(!file)
{
errno = E_INVALIDPTR;
return EOF;
}
if ((file->mode & 3)==FILE_OPEN_READ) return EOF;
if ((file->mode & 3)==FILE_OPEN_READ)
{
errno = E_ACCESS;
return EOF;
}
file->buffer[0]=c;
if ((file->mode & 3)==FILE_OPEN_APPEND)
@@ -11,25 +20,37 @@ int fputc(int c,FILE* file)
file->filepos=file->filesize;
file->filesize++;
res=_ksys_appendtofile(file->filename,file->filepos,1,file->buffer);
if (res!=0) return(res);
if (res!=0)
{
errno = -res;
return EOF;
}
file->filepos++;
return(0);
return c;
}
if ((file->mode & 3)==FILE_OPEN_WRITE)
{
if (file->filepos==0)
{ //file not craeted
{ //file not created
res=_ksys_rewritefile(file->filename,1,file->buffer);
if (res!=0) return(res);
if (res!=0)
{
errno = -res;
return EOF;
}
file->filepos++;
return 0;
return c;
}
else
{ //file craeted and need append one byte
{ //file created and need append one byte
res=_ksys_appendtofile(file->filename,file->filepos,1,file->buffer);
if (res!=0) return(res);
if (res!=0)
{
errno = -res;
return EOF;
}
file->filepos++;
return 0;
return c;
}
}
}