forked from KolibriOS/kolibrios
libc testsuite + fixes
git-svn-id: svn://kolibrios.org@6433 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user