mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Made some flags for the flag value from the FILE structure compatible with the mingw headers.
- Use _IO_LBF instead of _IOLBF, because _IOSTRG and _IOLBF has the same value. svn path=/trunk/; revision=9194
This commit is contained in:
parent
8a39d95805
commit
22adb5da88
8 changed files with 41 additions and 37 deletions
|
@ -22,9 +22,9 @@
|
||||||
* DISCLAIMED. This includes but is not limited to warranties of
|
* DISCLAIMED. This includes but is not limited to warranties of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.8 $
|
||||||
* $Author: sedwards $
|
* $Author: hbirr $
|
||||||
* $Date: 2003/08/25 01:37:47 $
|
* $Date: 2004/04/21 21:40:43 $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/* Appropriated for Reactos Crtdll by Ariadne */
|
/* Appropriated for Reactos Crtdll by Ariadne */
|
||||||
|
@ -46,26 +46,22 @@ extern "C" {
|
||||||
#include <msvcrt/stddef.h>
|
#include <msvcrt/stddef.h>
|
||||||
|
|
||||||
|
|
||||||
/* Some flags for the iobuf structure provided by djgpp stdio.h */
|
#define _IOREAD 0x0001
|
||||||
#define _IOREAD 0x000010
|
#define _IOWRT 0x0002
|
||||||
#define _IOWRT 0x000020
|
#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */
|
||||||
#define _IOMYBUF 0x000040
|
#define _IOEOF 0x0010 /* EOF reached on read */
|
||||||
#define _IOEOF 0x000100
|
#define _IOERR 0x0020 /* I/O error from system */
|
||||||
#define _IOERR 0x000200
|
#define _IOSTRG 0x0040 /* Strange or no file descriptor */
|
||||||
#define _IOSTRG 0x000400
|
|
||||||
|
|
||||||
#define _IOBINARY 0x000800
|
#define _IOBINARY 0x040000
|
||||||
#define _IOTEXT 0x000000
|
#define _IOTEXT 0x000000
|
||||||
|
|
||||||
#define _IOAPPEND 0x002000
|
#define _IOCOMMIT 0x100000
|
||||||
#define _IORMONCL 0x004000 /* remove on close, for temp files */
|
|
||||||
/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
|
#define _IODIRTY 0x010000
|
||||||
#define _IOUNGETC 0x010000 /* there is an ungetc'ed character in the buffer */
|
#define _IOAHEAD 0x020000
|
||||||
#define _IOCOMMIT 0x008000
|
|
||||||
|
|
||||||
#define _IODIRTY 0x000080
|
|
||||||
#define _IOAHEAD 0x000008
|
|
||||||
#define _IORW (_IOREAD | _IOWRITE )
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -180,9 +176,13 @@ wchar_t *_wtempnam(const wchar_t *dir,const wchar_t *prefix);
|
||||||
* NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
|
* NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
|
||||||
* maybe I'm testing it wrong?
|
* maybe I'm testing it wrong?
|
||||||
*/
|
*/
|
||||||
#define _IOFBF 0 /* fully buffered */
|
#define _IOFBF 0x0000 /* full buffered */
|
||||||
#define _IOLBF 1 /* line buffered */
|
#define _IOLBF 0x0040 /* line buffered */
|
||||||
#define _IONBF 2 /* unbuffered */
|
#define _IONBF 0x0004 /* not buffered */
|
||||||
|
|
||||||
|
#define _IO_LBF 0x80000 /* this value is used insteat of _IOLBF within the
|
||||||
|
structure FILE as value for _flags,
|
||||||
|
because _IOLBF has the same value as _IOSTRG */
|
||||||
|
|
||||||
int setvbuf(FILE* fileSetBuffer, char* caBuffer, int nMode, size_t sizeBuffer);
|
int setvbuf(FILE* fileSetBuffer, char* caBuffer, int nMode, size_t sizeBuffer);
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ int fflush(FILE *f)
|
||||||
f->_flag &= ~_IOAHEAD;
|
f->_flag &= ~_IOAHEAD;
|
||||||
|
|
||||||
|
|
||||||
f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz;
|
f->_cnt = (f->_flag&(_IO_LBF|_IONBF)) ? 0 : f->_bufsiz;
|
||||||
|
|
||||||
// how can write return less than rn without being on error ???
|
// how can write return less than rn without being on error ???
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ int _filbuf(FILE* f)
|
||||||
if ((f->_base = malloc(size+1)) == NULL) {
|
if ((f->_base = malloc(size+1)) == NULL) {
|
||||||
// error ENOMEM
|
// error ENOMEM
|
||||||
f->_flag |= _IONBF;
|
f->_flag |= _IONBF;
|
||||||
f->_flag &= ~(_IOFBF|_IOLBF);
|
f->_flag &= ~(_IOFBF|_IO_LBF);
|
||||||
} else {
|
} else {
|
||||||
f->_flag |= _IOMYBUF;
|
f->_flag |= _IOMYBUF;
|
||||||
f->_bufsiz = size;
|
f->_bufsiz = size;
|
||||||
|
@ -45,9 +45,9 @@ int _filbuf(FILE* f)
|
||||||
|
|
||||||
// flush stdout before reading from stdin
|
// flush stdout before reading from stdin
|
||||||
if (f == stdin) {
|
if (f == stdin) {
|
||||||
if (stdout->_flag&_IOLBF)
|
if (stdout->_flag&_IO_LBF)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (stderr->_flag&_IOLBF)
|
if (stderr->_flag&_IO_LBF)
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,19 +40,19 @@ int _flsbuf(int c, FILE* f)
|
||||||
size = 4096;
|
size = 4096;
|
||||||
if ((f->_base = base = malloc(size)) == NULL) {
|
if ((f->_base = base = malloc(size)) == NULL) {
|
||||||
f->_flag |= _IONBF;
|
f->_flag |= _IONBF;
|
||||||
f->_flag &= ~(_IOFBF|_IOLBF);
|
f->_flag &= ~(_IOFBF|_IO_LBF);
|
||||||
} else {
|
} else {
|
||||||
f->_flag |= _IOMYBUF;
|
f->_flag |= _IOMYBUF;
|
||||||
f->_cnt = f->_bufsiz = size;
|
f->_cnt = f->_bufsiz = size;
|
||||||
f->_ptr = base;
|
f->_ptr = base;
|
||||||
rn = 0;
|
rn = 0;
|
||||||
if (f == stdout && isatty(fileno(stdout))) {
|
if (f == stdout && isatty(fileno(stdout))) {
|
||||||
f->_flag |= _IOLBF;
|
f->_flag |= _IO_LBF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->_flag & _IOLBF) {
|
if (f->_flag & _IO_LBF) {
|
||||||
/* in line-buffering mode we get here on each character */
|
/* in line-buffering mode we get here on each character */
|
||||||
*f->_ptr++ = c;
|
*f->_ptr++ = c;
|
||||||
rn = f->_ptr - base;
|
rn = f->_ptr - base;
|
||||||
|
@ -90,7 +90,7 @@ int _flsbuf(int c, FILE* f)
|
||||||
rn -= n;
|
rn -= n;
|
||||||
base += n;
|
base += n;
|
||||||
}
|
}
|
||||||
if ((f->_flag & (_IOLBF|_IONBF)) == 0) {
|
if ((f->_flag & (_IO_LBF|_IONBF)) == 0) {
|
||||||
f->_cnt--;
|
f->_cnt--;
|
||||||
*f->_ptr++ = c;
|
*f->_ptr++ = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iop->_flag & _IOLBF)
|
if (iop->_flag & _IO_LBF)
|
||||||
{
|
{
|
||||||
while (to_write > 0)
|
while (to_write > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
int putchar(int c)
|
int putchar(int c)
|
||||||
{
|
{
|
||||||
int r = putc(c, stdout);
|
int r = putc(c, stdout);
|
||||||
if (stdout->_flag & _IOLBF)
|
if (stdout->_flag & _IO_LBF)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ int putchar(int c)
|
||||||
wint_t putwchar(wint_t c)
|
wint_t putwchar(wint_t c)
|
||||||
{
|
{
|
||||||
wint_t r = putwc(c, stdout);
|
wint_t r = putwc(c, stdout);
|
||||||
if (stdout->_flag & _IOLBF)
|
if (stdout->_flag & _IO_LBF)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,14 @@ int setvbuf(FILE *f, char *buf, int type, size_t len)
|
||||||
}
|
}
|
||||||
if ( f->_base != NULL )
|
if ( f->_base != NULL )
|
||||||
fflush(f);
|
fflush(f);
|
||||||
|
/* Cannot use _IOLBF as flag value because _IOLBF is equal to _IOSTRG */
|
||||||
|
if (type == _IOLBF)
|
||||||
|
type = _IO_LBF;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case _IOFBF:
|
case _IOFBF:
|
||||||
case _IOLBF:
|
case _IO_LBF:
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
return EOF;
|
return EOF;
|
||||||
|
@ -43,7 +47,7 @@ int setvbuf(FILE *f, char *buf, int type, size_t len)
|
||||||
free(f->_base);
|
free(f->_base);
|
||||||
f->_cnt = 0;
|
f->_cnt = 0;
|
||||||
|
|
||||||
f->_flag &= ~(_IONBF|_IOFBF|_IOLBF|_IOUNGETC);
|
f->_flag &= ~(_IONBF|_IOFBF|_IO_LBF|_IOUNGETC);
|
||||||
f->_flag |= type;
|
f->_flag |= type;
|
||||||
if (type != _IONBF)
|
if (type != _IONBF)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,13 +7,13 @@ FILE _iob[5] =
|
||||||
// stdin
|
// stdin
|
||||||
{
|
{
|
||||||
NULL, 0, NULL,
|
NULL, 0, NULL,
|
||||||
_IOREAD | _IOLBF ,
|
_IOREAD | _IO_LBF ,
|
||||||
0, 0,0, NULL
|
0, 0,0, NULL
|
||||||
},
|
},
|
||||||
// stdout
|
// stdout
|
||||||
{
|
{
|
||||||
NULL, 0, NULL,
|
NULL, 0, NULL,
|
||||||
_IOWRT | _IOLBF |_IOSTRG,
|
_IOWRT | _IO_LBF |_IOSTRG,
|
||||||
1,0,0, NULL
|
1,0,0, NULL
|
||||||
},
|
},
|
||||||
// stderr
|
// stderr
|
||||||
|
|
Loading…
Reference in a new issue