Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream.c

    re945826 r53ba273  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 30 14:00:53 2016
    13 // Update Count     : 302
     12// Last Modified On : Wed Apr  6 16:13:29 2016
     13// Update Count     : 278
    1414//
    1515
     
    3434ostype * ?|?( ostype *os, short int si ) {
    3535        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     36        sepReset( os );
    3637        prtfmt( os, "%hd", si );
    3738        return os;
     
    4142ostype * ?|?( ostype *os, unsigned short int usi ) {
    4243        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     44        sepReset( os );
    4345        prtfmt( os, "%hu", usi );
    4446        return os;
     
    4850ostype * ?|?( ostype *os, int i ) {
    4951        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     52        sepReset( os );
    5053        prtfmt( os, "%d", i );
    5154        return os;
     
    5558ostype * ?|?( ostype *os, unsigned int ui ) {
    5659        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     60        sepReset( os );
    5761        prtfmt( os, "%u", ui );
    5862        return os;
     
    6266ostype * ?|?( ostype *os, long int li ) {
    6367        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     68        sepReset( os );
    6469        prtfmt( os, "%ld", li );
    6570        return os;
     
    6974ostype * ?|?( ostype *os, unsigned long int uli ) {
    7075        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     76        sepReset( os );
    7177        prtfmt( os, "%lu", uli );
    7278        return os;
     
    7682ostype * ?|?( ostype *os, long long int lli ) {
    7783        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     84        sepReset( os );
    7885        prtfmt( os, "%lld", lli );
    7986        return os;
     
    8390ostype * ?|?( ostype *os, unsigned long long int ulli ) {
    8491        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     92        sepReset( os );
    8593        prtfmt( os, "%llu", ulli );
    8694        return os;
     
    9098ostype * ?|?( ostype *os, float f ) {
    9199        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     100        sepReset( os );
    92101        prtfmt( os, "%g", f );
    93102        return os;
     
    97106ostype * ?|?( ostype *os, double d ) {
    98107        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     108        sepReset( os );
    99109        prtfmt( os, "%.*lg", DBL_DIG, d );
    100110        return os;
     
    104114ostype * ?|?( ostype *os, long double ld ) {
    105115        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     116        sepReset( os );
    106117        prtfmt( os, "%.*Lg", LDBL_DIG, ld );
    107118        return os;
     
    144155                // opening delimiters
    145156                ['('] : Open, ['['] : Open, ['{'] : Open,
    146                 ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,
    147                 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,
     157                ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,
    148158                // closing delimiters
    149159                [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
     
    152162                // opening-closing delimiters
    153163                ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose,
    154                 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace
     164                ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace
    155165        }; // mask
    156166
    157   if ( cp[0] == '\0' ) { sepOff( os ); return os; }             // null string => no separator
    158 
     167        int len = strlen( cp );
     168        // null string => no separator
     169  if ( len == 0 ) { sepOff( os ); return os; }
    159170        // first character IS NOT spacing or closing punctuation => add left separator
    160171        unsigned char ch = cp[0];                                                       // must make unsigned
     
    162173                prtfmt( os, "%s", sepGet( os ) );
    163174        } // if
    164 
    165         // if string starts line, must reset to determine open state because separator is off
    166         sepReset( os );                                                                         // reset separator
    167 
    168175        // last character IS spacing or opening punctuation => turn off separator for next item
    169         unsigned int len = strlen( cp ), posn = len - 1;
     176        unsigned int posn = len - 1;
    170177        ch = cp[posn];                                                                          // must make unsigned
    171         if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
     178        if ( mask[ ch ] == Open || mask[ ch ] == OpenClose ) {
     179                sepOff( os );
     180        } else {
    172181                sepOn( os );
    173         } else {
    174                 sepOff( os );
    175182        } // if
    176183        return write( os, cp, len );
     
    180187ostype * ?|?( ostype *os, const void *p ) {
    181188        if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) );
     189        sepReset( os );
    182190        prtfmt( os, "%p", p );
    183191        return os;
    184192} // ?|?
     193
    185194
    186195forall( dtype ostype | ostream( ostype ) )
Note: See TracChangeset for help on using the changeset viewer.