Ignore:
Timestamp:
Jun 29, 2023, 12:07:50 PM (16 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
7d25f44
Parents:
70e47fec
Message:

harmonize separator manipulators names with newline names: change from sep, sepTuple, sepEnable, sepDisable, sepOn, sepOff to sepVal, sepTupleVal, sepOn, sepOff, sep, nosep; fix bug printing null string with WD so no separator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r70e47fec rf5d9c37  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  9 09:27:58 2023
    13 // Update Count     : 1361
     12// Last Modified On : Thu Jun 29 10:12:39 2023
     13// Update Count     : 1380
    1414//
    1515
     
    5050                fmt( os, "%c", c );
    5151                if ( c == '\n' ) setNL$( os, true );
    52                 return sepOff( os );
     52                return nosep( os );
    5353        } // ?|?
    5454        void ?|?( ostype & os, char c ) {
     
    284284
    285285          if ( s == 0p ) { fmt( os, "%s", "0p" ); return os; } // null pointer
    286           if ( s[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator
     286          if ( s[0] == '\0' ) { nosep( os ); return os; }       // null string => no leading/trailing separator
    287287
    288288                // first character IS NOT spacing or closing punctuation => add left separator
     
    300300                fmt( os, "%s", s );                                                             // fmt resets seperator, but reset it again
    301301                if ( sepPrt$( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    302                         sepOn( os );
     302                        sep( os );
    303303                } else {
    304                         sepOff( os );
     304                        nosep( os );
    305305                } // if
    306306                if ( ch == '\n' ) setNL$( os, true );                   // check *AFTER* sepPrt$ call above as it resets NL flag
     
    351351        } // ?|?
    352352
    353         ostype & sep( ostype & os ) {
    354                 return (ostype &)(os | sepGet( os ));
    355         } // sep
    356 
    357         ostype & sepTuple( ostype & os ) {
    358                 return os | sepGetTuple( os );
    359         } // sepTuple
    360 
    361353        ostype & nl( ostype & os ) {
    362354                (ostype &)(os | '\n');
    363355                setPrt$( os, false );                                                   // turn off
    364356                setNL$( os, true );
    365                 return sepOff( os );                                                    // prepare for next line
     357                return nosep( os );                                                             // prepare for next line
    366358        } // nl
    367359
     
    371363        } // nonl
    372364
     365        ostype & nlOn( ostype & os ) {
     366                nlOn( os );                                                                             // call void returning
     367                return os;
     368        } // nlOn
     369
     370        ostype & nlOff( ostype & os ) {
     371                nlOff( os );                                                                    // call void returning
     372                return os;
     373        } // nlOff
     374
     375        ostype & sepVal( ostype & os ) {
     376                return (ostype &)(os | sepGet( os ));
     377        } // sepVal
     378
     379        ostype & sepTupleVal( ostype & os ) {
     380                return os | sepGetTuple( os );
     381        } // sepTupleVal
     382
     383        ostype & sep( ostype & os ) {
     384                sep( os );                                                                              // call void returning
     385                return os;
     386        } // sep
     387
     388        ostype & nosep( ostype & os ) {
     389                nosep( os );                                                                    // call void returning
     390                return os;
     391        } // nosep
     392
    373393        ostype & sepOn( ostype & os ) {
    374394                sepOn( os );                                                                    // call void returning
     
    380400                return os;
    381401        } // sepOff
    382 
    383         ostype & sepEnable( ostype & os ) {
    384                 sepEnable( os );                                                                // call void returning
    385                 return os;
    386         } // sepEnable
    387 
    388         ostype & sepDisable( ostype & os ) {
    389                 sepDisable( os );                                                               // call void returning
    390                 return os;
    391         } // sepDisable
    392 
    393         ostype & nlOn( ostype & os ) {
    394                 nlOn( os );                                                                             // call void returning
    395                 return os;
    396         } // nlOn
    397 
    398         ostype & nlOff( ostype & os ) {
    399                 nlOff( os );                                                                    // call void returning
    400                 return os;
    401         } // nlOff
    402402} // distribution
    403403
     
    550550                if ( cnt == 1 ) {
    551551                        if ( f.flags.left ) { wd -= maxdig; f.wd = wd < 0 ? 1 : wd; } // update and restore f.wd for printing end chunk
    552                         sepOff( os );                                                           // no seperator between chunks
     552                        nosep( os );                                                            // no seperator between chunks
    553553                } // if
    554554        } else {                                                                                        // print start chunk
     
    595595                else { f.pc = maxdig; f.flags.pc = true; }              // left pad with precision
    596596
    597                 if ( cnt != 0 ) sepOff( os );                                   // no seperator between chunks
     597                if ( cnt != 0 ) nosep( os );                                    // no seperator between chunks
    598598                f.wd = wd;                                                                              // reset f.wd for next chunk
    599599                f.flags.sign = false;                                                   // no leading +/- sign
     
    773773                } // if
    774774
    775                 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
     775                if ( f.val[0] != '\0' &&                                                // null string => no leading separator
     776                         sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    776777
    777778                #define SFMTNP "% * "
     
    795796                        fmt( os, &fmtstr[star], f.wd, f.pc, f.val );
    796797                } // if
     798                if ( f.val[0] == '\0' ) { nosep( os ); }                // null string => no trailing separator
    797799                return os;
    798800        } // ?|?
Note: See TracChangeset for help on using the changeset viewer.