- Made some flags for the flag value from the FILE structure compatible with the...
authorHartmut Birr <osexpert@googlemail.com>
Wed, 21 Apr 2004 21:40:43 +0000 (21:40 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Wed, 21 Apr 2004 21:40:43 +0000 (21:40 +0000)
- Use _IO_LBF instead of _IOLBF, because _IOSTRG and _IOLBF has the same value.

svn path=/trunk/; revision=9194

reactos/include/msvcrt/stdio.h
reactos/lib/msvcrt/stdio/fflush.c
reactos/lib/msvcrt/stdio/filbuf.c
reactos/lib/msvcrt/stdio/flsbuf.c
reactos/lib/msvcrt/stdio/fwrite.c
reactos/lib/msvcrt/stdio/putchar.c
reactos/lib/msvcrt/stdio/setvbuf.c
reactos/lib/msvcrt/stdio/stdhnd.c

index 8ddce7d..ca291f0 100644 (file)
@@ -22,9 +22,9 @@
  *  DISCLAIMED. This includes but is not limited to warranties of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Revision: 1.7 $
- * $Author: sedwards $
- * $Date: 2003/08/25 01:37:47 $
+ * $Revision: 1.8 $
+ * $Author: hbirr $
+ * $Date: 2004/04/21 21:40:43 $
  *
  */
 /* Appropriated for Reactos Crtdll by Ariadne */
@@ -46,26 +46,22 @@ extern "C" {
 #include <msvcrt/stddef.h>
 
 
-/* Some flags for the iobuf structure provided by djgpp stdio.h */
-#define _IOREAD   0x000010
-#define _IOWRT    0x000020
-#define _IOMYBUF  0x000040
-#define _IOEOF    0x000100
-#define _IOERR    0x000200
-#define _IOSTRG   0x000400
+#define _IOREAD   0x0001
+#define _IOWRT    0x0002
+#define _IOMYBUF  0x0008  /* stdio malloc()'d buffer */
+#define _IOEOF    0x0010  /* EOF reached on read */
+#define _IOERR    0x0020  /* I/O error from system */
+#define _IOSTRG   0x0040  /* Strange or no file descriptor */
 
-#define _IOBINARY 0x000800
+#define _IOBINARY 0x040000
 #define _IOTEXT   0x000000
 
-#define _IOAPPEND 0x002000
-#define _IORMONCL 0x004000  /* remove on close, for temp files */
-/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
-#define _IOUNGETC 0x010000  /* there is an ungetc'ed character in the buffer */
-#define _IOCOMMIT 0x008000
+#define _IOCOMMIT 0x100000
+
+#define _IODIRTY  0x010000
+#define _IOAHEAD  0x020000
+
 
-#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...
  * maybe I'm testing it wrong?
  */
-#define _IOFBF  0   /* fully buffered */
-#define _IOLBF  1   /* line buffered */
-#define _IONBF  2   /* unbuffered */
+#define _IOFBF    0x0000     /* full buffered */
+#define _IOLBF    0x0040     /* line buffered */
+#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);
 
index 6ce5e09..e70e4cf 100644 (file)
@@ -81,7 +81,7 @@ int fflush(FILE *f)
     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 ???
 
index 306c8bd..64b2134 100644 (file)
@@ -34,7 +34,7 @@ int _filbuf(FILE* f)
     if ((f->_base = malloc(size+1)) == NULL) {
        // error ENOMEM
       f->_flag |= _IONBF;
-      f->_flag &= ~(_IOFBF|_IOLBF);
+      f->_flag &= ~(_IOFBF|_IO_LBF);
     } else {
       f->_flag |= _IOMYBUF;
       f->_bufsiz = size;
@@ -45,9 +45,9 @@ int _filbuf(FILE* f)
 
   // flush stdout before reading from stdin 
   if (f == stdin) {
-    if (stdout->_flag&_IOLBF)
+    if (stdout->_flag&_IO_LBF)
       fflush(stdout);
-    if (stderr->_flag&_IOLBF)
+    if (stderr->_flag&_IO_LBF)
       fflush(stderr);
   }
 
index 5d01507..e0b4154 100644 (file)
@@ -40,19 +40,19 @@ int _flsbuf(int c, FILE* f)
         size = 4096;
         if ((f->_base = base = malloc(size)) == NULL) {
             f->_flag |= _IONBF;
-            f->_flag &= ~(_IOFBF|_IOLBF);
+            f->_flag &= ~(_IOFBF|_IO_LBF);
         } else {
             f->_flag |= _IOMYBUF;
             f->_cnt = f->_bufsiz = size;
             f->_ptr = base;
             rn = 0;
             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 */
         *f->_ptr++ = c;
         rn = f->_ptr - base;
@@ -90,7 +90,7 @@ int _flsbuf(int c, FILE* f)
         rn -= n;
         base += n;
     }
-    if ((f->_flag & (_IOLBF|_IONBF)) == 0) {
+    if ((f->_flag & (_IO_LBF|_IONBF)) == 0) {
         f->_cnt--;
         *f->_ptr++ = c;
     }
index 7d6e23d..24d5739 100644 (file)
@@ -44,7 +44,7 @@ size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop)
         return 1;
   }
 
-  if (iop->_flag & _IOLBF)
+  if (iop->_flag & _IO_LBF)
   {
      while (to_write > 0)
      {
index 911e29e..7c3030c 100644 (file)
@@ -21,7 +21,7 @@
 int putchar(int c)
 {
   int r = putc(c, stdout);
-  if (stdout->_flag & _IOLBF)
+  if (stdout->_flag & _IO_LBF)
      fflush(stdout);
   return r;
 }
@@ -32,7 +32,7 @@ int putchar(int c)
 wint_t putwchar(wint_t c)
 {
   wint_t r = putwc(c, stdout);
-  if (stdout->_flag & _IOLBF)
+  if (stdout->_flag & _IO_LBF)
      fflush(stdout);
   return r;
 }
index 8447b35..d0dadf0 100644 (file)
@@ -20,10 +20,14 @@ int setvbuf(FILE *f, char *buf, int type, size_t len)
   }
   if ( f->_base != NULL )
        fflush(f);
+  /* Cannot use _IOLBF as flag value because _IOLBF is equal to _IOSTRG */
+  if (type == _IOLBF) 
+      type = _IO_LBF;
+    
   switch (type)
   {
   case _IOFBF:
-  case _IOLBF:
+  case _IO_LBF:
     if (len <= 0) {
        __set_errno (EINVAL);
        return EOF;
@@ -43,7 +47,7 @@ int setvbuf(FILE *f, char *buf, int type, size_t len)
       free(f->_base);
     f->_cnt = 0;
 
-    f->_flag &= ~(_IONBF|_IOFBF|_IOLBF|_IOUNGETC);
+    f->_flag &= ~(_IONBF|_IOFBF|_IO_LBF|_IOUNGETC);
     f->_flag |= type;
     if (type != _IONBF)
     {
index 3d59487..012cd48 100644 (file)
@@ -7,13 +7,13 @@ FILE _iob[5] =
        // stdin
 {
  NULL, 0, NULL,
-  _IOREAD | _IOLBF ,
+  _IOREAD | _IO_LBF ,
   0, 0,0, NULL
 },
        // stdout
 {
  NULL, 0, NULL,
-   _IOWRT | _IOLBF |_IOSTRG,
+   _IOWRT | _IO_LBF |_IOSTRG,
   1,0,0, NULL
 },
        // stderr