Subversion Repositories Kolibri OS

Rev

Rev 6433 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6433 Rev 7184
Line 1... Line 1...
1
#include 
1
#include 
2
// non standard realization - no support for virtually change char
2
// non standard realization - support for virtually change ONLY ONE char
-
 
3
 
-
 
4
 
-
 
5
 
3
int ungetc(int c,FILE* file)
6
int ungetc(int c,FILE* file)
4
{
7
{
5
	dword res;
8
	dword res;
Line 6... Line 9...
6
 
9
 
7
    if(!file)
10
    if(!file)
8
    {
11
    {
9
        errno = E_INVALIDPTR;
12
        errno = E_INVALIDPTR;
10
        return EOF;
13
        return EOF;
Line 11... Line 14...
11
    }
14
    }
12
 
15
 
13
	if ((file->mode & 3!=FILE_OPEN_READ) && (file->mode & FILE_OPEN_PLUS==0))
16
	if ((file->mode & 3) != FILE_OPEN_READ && (file->mode & FILE_OPEN_PLUS) == 0)
14
    {
17
    {
15
        errno = E_ACCESS;
18
        errno = E_ACCESS;
Line 16... Line 19...
16
        return EOF;
19
        return EOF;
17
    }
20
    }
18
 
21
 
19
	if (file->filepos>file->filesize || file->filepos==0)
22
	if (file->filepos > file->filesize || file->filepos == 0 || c == EOF || file->ungetc_buf != EOF)
20
	{
23
	{
-
 
24
	    errno = E_EOF;
-
 
25
		return EOF;
21
	    errno = E_EOF;
26
	}
Line 22... Line 27...
22
		return EOF;
27
	
23
	}
28
	file->ungetc_buf = c;