Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream.c

    r53a6c2a r86f384b  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 18:14:17 2017
    13 // Update Count     : 396
     12// Last Modified On : Sun Jul  2 08:54:02 2017
     13// Update Count     : 375
    1414//
    1515
     
    1818extern "C" {
    1919#include <stdio.h>
    20 #include <stdbool.h>                                                                    // true/false
    2120#include <string.h>                                                                             // strlen
    2221#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
     
    2524
    2625forall( dtype ostype | ostream( ostype ) )
    27 ostype * ?|?( ostype * os, char ch ) {
    28         fmt( os, "%c", ch );
    29         if ( ch == '\n' ) setNL( os, true );
     26ostype * ?|?( ostype * os, char c ) {
     27        fmt( os, "%c", c );
    3028        sepOff( os );
    3129        return os;
     
    182180
    183181        // last character IS spacing or opening punctuation => turn off separator for next item
    184         size_t len = strlen( cp );
    185         ch = cp[len - 1];                                                                       // must make unsigned
     182        unsigned int len = strlen( cp ), posn = len - 1;
     183        ch = cp[posn];                                                                          // must make unsigned
    186184        if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    187185                sepOn( os );
     
    189187                sepOff( os );
    190188        } // if
    191         if ( ch == '\n' ) setNL( os, true );                            // check *AFTER* sepPrt call above as it resets NL flag
    192189        return write( os, cp, len );
    193190} // ?|?
     
    219216
    220217forall( dtype ostype | ostream( ostype ) )
    221 ostype * sep( ostype * os ) {
    222         os | sepGet( os );
    223         return os;
    224 } // sep
    225 
    226 forall( dtype ostype | ostream( ostype ) )
    227 ostype * sepTuple( ostype * os ) {
    228         os | sepGetTuple( os );
    229         return os;
    230 } // sepTuple
    231 
    232 forall( dtype ostype | ostream( ostype ) )
    233218ostype * endl( ostype * os ) {
     219        if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) );
    234220        os | '\n';
    235         setNL( os, true );
    236221        flush( os );
    237222        sepOff( os );                                                                           // prepare for next line
Note: See TracChangeset for help on using the changeset viewer.