Ignore:
Timestamp:
Jul 12, 2019, 1:46:10 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
302d84c2
Parents:
1d760934
Message:

first attempt to add streams exit and abort, rename private iostream nl function to ends

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    r1d760934 r65240bb  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 16 08:33:28 2019
    13 // Update Count     : 328
     12// Last Modified On : Fri Jul 12 12:03:53 2019
     13// Update Count     : 344
    1414//
    1515
     
    2424#include <assert.h>
    2525#include <errno.h>                                                                              // errno
     26
     27
     28//*********************************** ofstream ***********************************
     29
    2630
    2731#define IO_MSG "I/O error: "
     
    3741        sepSetCur( os, sepGet( os ) );
    3842        sepSetTuple( os, ", " );
    39 }
     43} // ?{}
    4044
    4145// private
     
    5660void ?{}( ofstream & os, const char * name, const char * mode ) {
    5761        open( os, name, mode );
    58 }
     62} // ?{}
     63
    5964void ?{}( ofstream & os, const char * name ) {
    6065        open( os, name, "w" );
    61 }
     66} // ?{}
    6267
    6368void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
     
    9499        os.tupleSeparator[sepSize - 1] = '\0';
    95100} // sepSet
     101
     102void ends( ofstream & os ) {
     103        if ( getANL( os ) ) nl( os );
     104        else setPrt( os, false );                                                       // turn off
     105        if ( &os == &exit ) exit( EXIT_FAILURE );
     106        if ( &os == &abort ) abort();
     107} // ends
    96108
    97109int fail( ofstream & os ) {
     
    157169ofstream & serr = serrFile;
    158170
    159 // static ofstream sexitFile = { (FILE *)(&_IO_2_1_stdout_) };
    160 // ofstream & sexit = sexitFile;
    161 // static ofstream sabortFile = { (FILE *)(&_IO_2_1_stderr_) };
    162 // ofstream & sabort = sabortFile;
    163 
    164 void nl( ofstream & os ) {
    165         if ( getANL( os ) ) (ofstream &)(nl( os ));                     // implementation only
    166         else setPrt( os, false );                                                       // turn off
    167 }
    168 
    169 //---------------------------------------
     171static ofstream exitFile = { (FILE *)(&_IO_2_1_stdout_) };
     172ofstream & exit = exitFile;
     173static ofstream abortFile = { (FILE *)(&_IO_2_1_stderr_) };
     174ofstream & abort = abortFile;
     175
     176
     177//*********************************** ifstream ***********************************
     178
    170179
    171180// private
     
    173182        is.file = file;
    174183        is.nlOnOff = false;
    175 }
     184} // ?{}
    176185
    177186// public
     
    180189void ?{}( ifstream & is, const char * name, const char * mode ) {
    181190        open( is, name, mode );
    182 }
     191} // ?{}
     192
    183193void ?{}( ifstream & is, const char * name ) {
    184194        open( is, name, "r" );
    185 }
     195} // ?{}
    186196
    187197void nlOn( ifstream & os ) { os.nlOnOff = true; }
Note: See TracChangeset for help on using the changeset viewer.