]> pd.if.org Git - pdclib/blobdiff - functions/stdio/fopen.c
Intermediate stdio work.
[pdclib] / functions / stdio / fopen.c
index 14ce3a8f57b2fe8911baba2c941f0529c76050a0..d181cc1f876ded1362cc297e8c2fad923e67ae64 100644 (file)
@@ -38,7 +38,11 @@ struct _PDCLIB_file_t * fopen( const char * _PDCLIB_restrict filename, const cha
     if ( ( rc->buffer = malloc( BUFSIZ ) ) == NULL ) goto fail;
     rc->bufsize = BUFSIZ;
     rc->bufidx = 0;
-    rc->status |= ( _PDCLIB_LIBBUFFER | _PDCLIB_VIRGINSTR );
+    /* Setting buffer to _IOLBF because "when opened, a stream is fully
+       buffered if and only if it can be determined not to refer to an
+       interactive device."
+    */
+    rc->status |= ( _PDCLIB_LIBBUFFER | _PDCLIB_VIRGINSTR /* | _IOLBF */ ); /* FIXME: Uncommenting the _IOLBF here breaks output. */
     /* TODO: Setting mbstate */
     return rc;
 fail:
@@ -53,13 +57,23 @@ fail:
 
 int main( void )
 {
+    /* Some of the tests are not executed for regression tests, as the libc on
+       my system is at once less forgiving (segfaults on mode NULL) and more
+       forgiving (accepts undefined modes).
+    */
+#ifndef REGTEST
     TESTCASE( fopen( NULL, NULL ) == NULL );
+#endif
     TESTCASE( fopen( NULL, "w" ) == NULL );
+#ifndef REGTEST
     TESTCASE( fopen( "", NULL ) == NULL );
+#endif
     TESTCASE( fopen( "", "w" ) == NULL );
     TESTCASE( fopen( "foo", "" ) == NULL );
-    TESTCASE( fopen( "testfile", "wq" ) == NULL ); /* Illegal mode */
-    TESTCASE( fopen( "testfile", "wr" ) == NULL ); /* Illegal mode */
+#ifndef REGTEST
+    TESTCASE( fopen( "testfile", "wq" ) == NULL ); /* Undefined mode */
+    TESTCASE( fopen( "testfile", "wr" ) == NULL ); /* Undefined mode */
+#endif
     TESTCASE( fopen( "testfile", "w" ) != NULL );
     system( "rm testfile" );
     return TEST_RESULTS;