]> pd.if.org Git - pdclib/blobdiff - functions/stdio/fopen.c
Added some functions.
[pdclib] / functions / stdio / fopen.c
index 1e9bd41358a60aa48484325bf9afe7333a4663e9..96fdcc19803bb709efa65f28f61107ccb65cf57b 100644 (file)
@@ -77,13 +77,14 @@ struct _PDCLIB_file_t * fopen( const char * _PDCLIB_restrict filename, const cha
     if ( ( rc->status = filemode( mode ) ) == 0 ) goto fail; /* invalid mode */
     rc->handle = _PDCLIB_open( filename, rc->status );
     if ( rc->handle == _PDCLIB_NOHANDLE ) goto fail; /* OS open() failed */
-
     /* Adding to list of open files */
     rc->next = _PDCLIB_filelist;
     _PDCLIB_filelist = rc;
-    /* Setting buffer, and mark as internal. TODO: Check for unbuffered? */
+    /* Setting buffer, and mark as internal. TODO: Check for unbuffered */
     if ( ( rc->buffer = malloc( BUFSIZ ) ) == NULL ) goto fail;
-    rc->status |= _PDCLIB_LIBBUFFER;
+    rc->bufsize = BUFSIZ;
+    rc->bufidx = 0;
+    rc->status |= ( _PDCLIB_LIBBUFFER | _PDCLIB_VIRGINSTR );
     /* TODO: Setting mbstate */
     return rc;
 fail: