Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    r200fcb3 r58b6d1b  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 12 08:34:28 2018
    13 // Update Count     : 298
     12// Last Modified On : Tue Jun  5 17:02:56 2018
     13// Update Count     : 281
    1414//
    1515
     
    2020#include <stdarg.h>                                                                             // varargs
    2121#include <string.h>                                                                             // strlen
     22#include <stdbool.h>                                                                    // true/false
    2223#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
    2324#include <complex.h>                                                                    // creal, cimag
     
    2627#define IO_MSG "I/O error: "
    2728
    28 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool nonlManip, const char * separator, const char * tupleSeparator ) {
     29void ?{}( ofstream & os, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
    2930        os.file = file;
    3031        os.sepDefault = sepDefault;
    3132        os.sepOnOff = sepOnOff;
    32         os.nlOnOff = nlOnOff;
    33         os.nonlManip = nonlManip;
    3433        sepSet( os, separator );
    3534        sepSetCur( os, sepGet( os ) );
     
    3837
    3938// private
    40 bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }
     39_Bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }
    4140void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; }
    42 void sepReset( ofstream & os, bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }
     41void sepReset( ofstream & os, _Bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }
    4342const char * sepGetCur( ofstream & os ) { return os.sepCur; }
    4443void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; }
    45 bool getNL( ofstream & os ) { return os.sawNL; }
    46 void setNL( ofstream & os, bool state ) { os.sawNL = state; }
    47 bool getANL( ofstream & os ) { return os.nlOnOff; }
    48 bool getNonl( ofstream & os ) { return os.nonlManip; }
    49 void setNonl( ofstream & os, bool state ) { os.nonlManip = state; }
     44_Bool getNL( ofstream & os ) { return os.sawNL; }
     45void setNL( ofstream & os, _Bool state ) { os.sawNL = state; }
    5046
    5147// public
     
    6258void sepOff( ofstream & os ) { os.sepOnOff = false; }
    6359
    64 bool sepDisable( ofstream & os ) {
    65         bool temp = os.sepDefault;
     60_Bool sepDisable( ofstream & os ) {
     61        _Bool temp = os.sepDefault;
    6662        os.sepDefault = false;
    6763        sepReset( os );
     
    6965} // sepDisable
    7066
    71 bool sepEnable( ofstream & os ) {
    72         bool temp = os.sepDefault;
     67_Bool sepEnable( ofstream & os ) {
     68        _Bool temp = os.sepDefault;
    7369        os.sepDefault = true;
    7470        if ( os.sepOnOff ) sepReset( os );                                      // start of line ?
    7571        return temp;
    7672} // sepEnable
    77 
    78 void nlOn( ofstream & os ) { os.nlOnOff = true; }
    79 void nlOff( ofstream & os ) { os.nlOnOff = false; }
    8073
    8174const char * sepGet( ofstream & os ) { return os.separator; }
     
    10396void open( ofstream & os, const char * name, const char * mode ) {
    10497        FILE *file = fopen( name, mode );
    105         #ifdef __CFA_DEBUG__
    106         if ( file == 0 ) {
    107                 fprintf( stderr, IO_MSG "open output file \"%s\", ", name );
    108                 perror( 0 );
    109                 exit( EXIT_FAILURE );
    110         } // if
    111         #endif // __CFA_DEBUG__
    112         (os){ file, true, false, true, false, " ", ", " };
     98        // if ( file == 0 ) {                                                                   // do not change unless successful
     99        //      fprintf( stderr, IO_MSG "open output file \"%s\", ", name );
     100        //      perror( 0 );
     101        //      exit( EXIT_FAILURE );
     102        // } // if
     103        (os){ file, true, false, " ", ", " };
    113104} // open
    114105
     
    154145} // fmt
    155146
    156 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, true, false, " ", ", " };
     147static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
    157148ofstream & sout = soutFile;
    158 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, true, false, " ", ", " };
     149static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
    159150ofstream & serr = serrFile;
    160151
     
    187178void open( ifstream & is, const char * name, const char * mode ) {
    188179        FILE *file = fopen( name, mode );
    189         #ifdef __CFA_DEBUG__
    190         if ( file == 0 ) {
    191                 fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
    192                 perror( 0 );
    193                 exit( EXIT_FAILURE );
    194         } // if
    195         #endif // __CFA_DEBUG__
     180        // if ( file == 0 ) {                                                                   // do not change unless successful
     181        //      fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
     182        //      perror( 0 );
     183        //      exit( EXIT_FAILURE );
     184        // } // if
    196185        is.file = file;
    197186} // open
Note: See TracChangeset for help on using the changeset viewer.