Changes in / [50f6afb:8edbe40]
- Files:
-
- 4 deleted
- 5 edited
-
libcfa/src/Makefile.am (modified) (2 diffs)
-
libcfa/src/fstream.cfa (modified) (6 diffs)
-
libcfa/src/fstream.hfa (modified) (8 diffs)
-
libcfa/src/iostream.cfa (modified) (11 diffs)
-
libcfa/src/iostream.hfa (modified) (10 diffs)
-
libcfa/src/strstream.cfa (deleted)
-
libcfa/src/strstream.hfa (deleted)
-
tests/.expect/strstream.txt (deleted)
-
tests/strstream.cfa (deleted)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/Makefile.am
r50f6afb r8edbe40 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sat Apr 24 09:09:56 202114 ## Update Count : 25 413 ## Last Modified On : Wed Dec 9 22:46:14 2020 14 ## Update Count : 250 15 15 ############################################################################### 16 16 … … 69 69 common.hfa \ 70 70 fstream.hfa \ 71 strstream.hfa \72 71 heap.hfa \ 73 72 iostream.hfa \ -
libcfa/src/fstream.cfa
r50f6afb r8edbe40 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 24 09:05:16 202113 // Update Count : 42 612 // Last Modified On : Tue Apr 20 19:04:46 2021 13 // Update Count : 425 14 14 // 15 15 … … 19 19 #include <stdlib.h> // exit 20 20 #include <stdarg.h> // varargs 21 #include <string.h> // strncpy, strerror 21 #include <string.h> // strlen 22 #include <float.h> // DBL_DIG, LDBL_DIG 23 #include <complex.h> // creal, cimag 22 24 #include <assert.h> 23 25 #include <errno.h> // errno … … 91 93 void sepSet( ofstream & os, const char s[] ) { 92 94 assert( s ); 93 strncpy( os.separator$, s, ofstream_sepSize - 1 );94 os.separator$[ ofstream_sepSize - 1] = '\0';95 strncpy( os.separator$, s, sepSize - 1 ); 96 os.separator$[sepSize - 1] = '\0'; 95 97 } // sepSet 96 98 … … 98 100 void sepSetTuple( ofstream & os, const char s[] ) { 99 101 assert( s ); 100 strncpy( os.tupleSeparator$, s, ofstream_sepSize - 1 );101 os.tupleSeparator$[ ofstream_sepSize - 1] = '\0';102 strncpy( os.tupleSeparator$, s, sepSize - 1 ); 103 os.tupleSeparator$[sepSize - 1] = '\0'; 102 104 } // sepSet 103 105 … … 110 112 } // ends 111 113 112 boolfail( ofstream & os ) {114 int fail( ofstream & os ) { 113 115 return os.file$ == 0 || ferror( (FILE *)(os.file$) ); 114 116 } // fail … … 226 228 bool getANL( ifstream & os ) { return os.nlOnOff$; } 227 229 228 boolfail( ifstream & is ) {230 int fail( ifstream & is ) { 229 231 return is.file$ == 0p || ferror( (FILE *)(is.file$) ); 230 232 } // fail -
libcfa/src/fstream.hfa
r50f6afb r8edbe40 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 24 09:04:03202113 // Update Count : 21 912 // Last Modified On : Tue Apr 20 19:04:12 2021 13 // Update Count : 218 14 14 // 15 15 … … 24 24 25 25 26 enum { ofstream_sepSize = 16 };26 enum { sepSize = 16 }; 27 27 struct ofstream { 28 28 void * file$; … … 33 33 bool sawNL$; 34 34 const char * sepCur$; 35 char separator$[ ofstream_sepSize];36 char tupleSeparator$[ ofstream_sepSize];35 char separator$[sepSize]; 36 char tupleSeparator$[sepSize]; 37 37 multiple_acquisition_lock lock$; 38 38 bool acquired$; 39 39 }; // ofstream 40 41 // Satisfies ostream42 40 43 41 // private … … 66 64 void sepSetTuple( ofstream &, const char [] ); 67 65 68 void ends( ofstream & ); 69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 70 71 bool fail( ofstream & ); 66 void ends( ofstream & os ); 67 int fail( ofstream & ); 72 68 int flush( ofstream & ); 73 69 void open( ofstream &, const char name[], const char mode[] ); … … 75 71 void close( ofstream & ); 76 72 ofstream & write( ofstream &, const char data[], size_t size ); 77 78 void acquire( ofstream & );79 void release( ofstream & );73 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 74 void acquire( ofstream & os ); 75 void release( ofstream & os ); 80 76 81 77 struct osacquire { 82 78 ofstream & os; 83 79 }; 84 void ?{}( osacquire & acq, ofstream & );80 void ?{}( osacquire & acq, ofstream & os ); 85 81 void ^?{}( osacquire & acq ); 86 82 87 void ?{}( ofstream & );88 void ?{}( ofstream & , const char name[], const char mode[] );89 void ?{}( ofstream & , const char name[] );90 void ^?{}( ofstream & );83 void ?{}( ofstream & os ); 84 void ?{}( ofstream & os, const char name[], const char mode[] ); 85 void ?{}( ofstream & os, const char name[] ); 86 void ^?{}( ofstream & os ); 91 87 92 88 extern ofstream & sout, & stdout, & serr, & stderr; // aliases … … 104 100 }; // ifstream 105 101 106 // Satisfies istream107 108 102 // public 109 103 void nlOn( ifstream & ); … … 111 105 bool getANL( ifstream & ); 112 106 void ends( ifstream & ); 113 boolfail( ifstream & is );107 int fail( ifstream & is ); 114 108 int eof( ifstream & is ); 115 109 void open( ifstream & is, const char name[], const char mode[] ); … … 148 142 ); 149 143 150 void ?{}( Open_Failure & this, ofstream & );151 void ?{}( Open_Failure & this, ifstream & );144 void ?{}( Open_Failure & this, ofstream & ostream ); 145 void ?{}( Open_Failure & this, ifstream & istream ); 152 146 153 147 // Local Variables: // -
libcfa/src/iostream.cfa
r50f6afb r8edbe40 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 24 10:03:54202113 // Update Count : 132 912 // Last Modified On : Tue Apr 20 19:09:41 2021 13 // Update Count : 1325 14 14 // 15 15 … … 36 36 37 37 38 forall( ostype & | basic_ostream( ostype ) ) {38 forall( ostype & | ostream( ostype ) ) { 39 39 ostype & ?|?( ostype & os, bool b ) { 40 40 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); … … 294 294 295 295 // last character IS spacing or opening punctuation => turn off separator for next item 296 int len = strlen( s );296 size_t len = strlen( s ); 297 297 ch = s[len - 1]; // must make unsigned 298 fmt( os, "%s", s ); // fmt resets seperator, but reset it again299 298 if ( sepPrt$( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 300 299 sepOn( os ); … … 303 302 } // if 304 303 if ( ch == '\n' ) setNL$( os, true ); // check *AFTER* sepPrt$ call above as it resets NL flag 305 return os; 306 // return write( os, s, len ); 304 return write( os, s, len ); 307 305 } // ?|? 308 306 void ?|?( ostype & os, const char s[] ) { … … 399 397 return os; 400 398 } // nlOff 401 } // distribution 402 403 forall( ostype & | ostream( ostype ) ) { 399 404 400 ostype & acquire( ostype & os ) { 405 401 acquire( os ); // call void returning … … 449 445 // Default prefix for non-decimal prints is 0b, 0, 0x. 450 446 #define IntegralFMTImpl( T, IFMTNP, IFMTP ) \ 451 forall( ostype & | basic_ostream( ostype ) ) { \447 forall( ostype & | ostream( ostype ) ) { \ 452 448 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 453 449 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); \ … … 543 539 #if defined( __SIZEOF_INT128__ ) 544 540 // Default prefix for non-decimal prints is 0b, 0, 0x. 545 forall( ostype & | basic_ostream( ostype ) )541 forall( ostype & | ostream( ostype ) ) 546 542 static inline void base_128( ostype & os, unsigned int128 val, unsigned int128 power, _Ostream_Manip(uint64_t) & f, unsigned int maxdig, unsigned int bits, unsigned int cnt = 0 ) { 547 543 int wd = 1; // f.wd is never 0 because 0 implies left-pad … … 608 604 609 605 #define IntegralFMTImpl128( T ) \ 610 forall( ostype & | basic_ostream( ostype ) ) { \606 forall( ostype & | ostream( ostype ) ) { \ 611 607 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 612 608 _Ostream_Manip(uint64_t) fmt; \ … … 681 677 682 678 #define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \ 683 forall( ostype & | basic_ostream( ostype ) ) { \679 forall( ostype & | ostream( ostype ) ) { \ 684 680 static void eng( T &value, int & pc, int & exp10 ) { \ 685 681 exp10 = lrint( floor( log10( abs( value ) ) ) ); /* round to desired precision */ \ … … 727 723 // *********************************** character *********************************** 728 724 729 forall( ostype & | basic_ostream( ostype ) ) {725 forall( ostype & | ostream( ostype ) ) { 730 726 ostype & ?|?( ostype & os, _Ostream_Manip(char) f ) { 731 727 if ( f.base != 'c' ) { // bespoke binary/octal/hex format … … 760 756 // *********************************** C string *********************************** 761 757 762 forall( ostype & | basic_ostream( ostype ) ) {758 forall( ostype & | ostream( ostype ) ) { 763 759 ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ) { 764 760 if ( ! f.val ) return os; // null pointer ? -
libcfa/src/iostream.hfa
r50f6afb r8edbe40 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 24 09:28:56202113 // Update Count : 3 9312 // Last Modified On : Tue Apr 20 19:09:44 2021 13 // Update Count : 385 14 14 // 15 15 … … 22 22 23 23 24 trait basic_ostream( ostype & ) {24 trait ostream( ostype & ) { 25 25 // private 26 26 bool sepPrt$( ostype & ); // get separator state (on/off) … … 47 47 void sepSetTuple( ostype &, const char [] ); // set tuple separator to string (15 character maximum) 48 48 49 void ends( ostype & ); // end of output statement 49 void ends( ostype & os ); // end of output statement 50 int fail( ostype & ); 51 int flush( ostype & ); 52 void open( ostype & os, const char name[], const char mode[] ); 53 void close( ostype & os ); 54 ostype & write( ostype &, const char [], size_t ); 50 55 int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 51 int flush( ostype & ); 52 }; // basic_ostream 53 54 trait ostream( ostype & | basic_ostream( ostype ) ) { 55 bool fail( ostype & ); // operation failed? 56 void open( ostype &, const char name[], const char mode[] ); 57 void close( ostype & ); 58 ostype & write( ostype &, const char [], size_t ); 59 void acquire( ostype & ); // concurrent access 56 void acquire( ostype & ); 60 57 }; // ostream 61 58 … … 70 67 // implement writable for intrinsic types 71 68 72 forall( ostype & | basic_ostream( ostype ) ) {69 forall( ostype & | ostream( ostype ) ) { 73 70 ostype & ?|?( ostype &, bool ); 74 71 void ?|?( ostype &, bool ); … … 141 138 ostype & nlOn( ostype & ); 142 139 ostype & nlOff( ostype & ); 143 } // distribution144 145 forall( ostype & | ostream( ostype ) ) {146 140 ostype & acquire( ostype & ); 147 141 } // distribution … … 202 196 _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \ 203 197 } /* distribution */ \ 204 forall( ostype & | basic_ostream( ostype ) ) { \198 forall( ostype & | ostream( ostype ) ) { \ 205 199 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \ 206 200 void ?|?( ostype & os, _Ostream_Manip(T) f ); \ … … 247 241 _Ostream_Manip(T) & unit( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \ 248 242 } /* distribution */ \ 249 forall( ostype & | basic_ostream( ostype ) ) { \243 forall( ostype & | ostream( ostype ) ) { \ 250 244 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \ 251 245 void ?|?( ostype & os, _Ostream_Manip(T) f ); \ … … 267 261 _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 268 262 } // distribution 269 forall( ostype & | basic_ostream( ostype ) ) {263 forall( ostype & | ostream( ostype ) ) { 270 264 ostype & ?|?( ostype & os, _Ostream_Manip(char) f ); 271 265 void ?|?( ostype & os, _Ostream_Manip(char) f ); … … 285 279 _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 286 280 } // distribution 287 forall( ostype & | basic_ostream( ostype ) ) {281 forall( ostype & | ostream( ostype ) ) { 288 282 ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ); 289 283 void ?|?( ostype & os, _Ostream_Manip(const char *) f ); … … 300 294 301 295 void ends( istype & os ); // end of output statement 302 boolfail( istype & );296 int fail( istype & ); 303 297 int eof( istype & ); 304 298 void open( istype & is, const char name[] );
Note:
See TracChangeset
for help on using the changeset viewer.