Changeset d1a9ff5 for libcfa/src
- Timestamp:
- Feb 8, 2020, 7:41:33 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3e274ab
- Parents:
- 095ac99
- Location:
- libcfa/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r095ac99 rd1a9ff5 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 11:55:29202013 // Update Count : 3 5612 // Last Modified On : Fri Feb 7 19:01:01 2020 13 // Update Count : 363 14 14 // 15 15 … … 32 32 33 33 void ?{}( ofstream & os, void * file ) { 34 os.file = file; 35 os.sepDefault = true; 36 os.sepOnOff = false; 37 os.nlOnOff = true; 38 os.prt = false; 39 os.sawNL = false; 34 os.$file = file; 35 os.$sepDefault = true; 36 os.$sepOnOff = false; 37 os.$nlOnOff = true; 38 os.$prt = false; 39 os.$sawNL = false; 40 $sepSetCur( os, sepGet( os ) ); 40 41 sepSet( os, " " ); 41 sepSetCur( os, sepGet( os ) );42 42 sepSetTuple( os, ", " ); 43 43 } // ?{} 44 44 45 45 // private 46 bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }47 void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; }48 void sepReset( ofstream & os, bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }49 const char * sepGetCur( ofstream & os ) { return os.sepCur; }50 void sepSetCur( ofstream & os, const char sepCur[] ) { os.sepCur = sepCur; }51 bool getNL( ofstream & os ) { return os.sawNL; }52 void setNL( ofstream & os, bool state ) { os.sawNL = state; }53 bool getANL( ofstream & os ) { return os.nlOnOff; }54 bool getPrt( ofstream & os ) { return os.prt; }55 void setPrt( ofstream & os, bool state ) { os.prt = state; }46 bool $sepPrt( ofstream & os ) { $setNL( os, false ); return os.$sepOnOff; } 47 void $sepReset( ofstream & os ) { os.$sepOnOff = os.$sepDefault; } 48 void $sepReset( ofstream & os, bool reset ) { os.$sepDefault = reset; os.$sepOnOff = os.$sepDefault; } 49 const char * $sepGetCur( ofstream & os ) { return os.$sepCur; } 50 void $sepSetCur( ofstream & os, const char sepCur[] ) { os.$sepCur = sepCur; } 51 bool $getNL( ofstream & os ) { return os.$sawNL; } 52 void $setNL( ofstream & os, bool state ) { os.$sawNL = state; } 53 bool $getANL( ofstream & os ) { return os.$nlOnOff; } 54 bool $getPrt( ofstream & os ) { return os.$prt; } 55 void $setPrt( ofstream & os, bool state ) { os.$prt = state; } 56 56 57 57 // public 58 void ?{}( ofstream & os ) { os. file = 0; }58 void ?{}( ofstream & os ) { os.$file = 0p; } 59 59 60 60 void ?{}( ofstream & os, const char name[], const char mode[] ) { … … 70 70 } // ^?{} 71 71 72 void sepOn( ofstream & os ) { os. sepOnOff = !getNL( os ); }73 void sepOff( ofstream & os ) { os. sepOnOff = false; }72 void sepOn( ofstream & os ) { os.$sepOnOff = ! $getNL( os ); } 73 void sepOff( ofstream & os ) { os.$sepOnOff = false; } 74 74 75 75 bool sepDisable( ofstream & os ) { 76 bool temp = os. sepDefault;77 os. sepDefault = false;78 sepReset( os );76 bool temp = os.$sepDefault; 77 os.$sepDefault = false; 78 $sepReset( os ); 79 79 return temp; 80 80 } // sepDisable 81 81 82 82 bool sepEnable( ofstream & os ) { 83 bool temp = os. sepDefault;84 os. sepDefault = true;85 if ( os. sepOnOff ) sepReset( os );// start of line ?83 bool temp = os.$sepDefault; 84 os.$sepDefault = true; 85 if ( os.$sepOnOff ) $sepReset( os ); // start of line ? 86 86 return temp; 87 87 } // sepEnable 88 88 89 void nlOn( ofstream & os ) { os. nlOnOff = true; }90 void nlOff( ofstream & os ) { os. nlOnOff = false; }91 92 const char * sepGet( ofstream & os ) { return os. separator; }89 void nlOn( ofstream & os ) { os.$nlOnOff = true; } 90 void nlOff( ofstream & os ) { os.$nlOnOff = false; } 91 92 const char * sepGet( ofstream & os ) { return os.$separator; } 93 93 void sepSet( ofstream & os, const char s[] ) { 94 94 assert( s ); 95 strncpy( os. separator, s, sepSize - 1 );96 os. separator[sepSize - 1] = '\0';95 strncpy( os.$separator, s, sepSize - 1 ); 96 os.$separator[sepSize - 1] = '\0'; 97 97 } // sepSet 98 98 99 const char * sepGetTuple( ofstream & os ) { return os. tupleSeparator; }99 const char * sepGetTuple( ofstream & os ) { return os.$tupleSeparator; } 100 100 void sepSetTuple( ofstream & os, const char s[] ) { 101 101 assert( s ); 102 strncpy( os. tupleSeparator, s, sepSize - 1 );103 os. tupleSeparator[sepSize - 1] = '\0';102 strncpy( os.$tupleSeparator, s, sepSize - 1 ); 103 os.$tupleSeparator[sepSize - 1] = '\0'; 104 104 } // sepSet 105 105 106 106 void ends( ofstream & os ) { 107 if ( getANL( os ) ) nl( os );108 else setPrt( os, false ); // turn off107 if ( $getANL( os ) ) nl( os ); 108 else $setPrt( os, false ); // turn off 109 109 if ( &os == &exit ) exit( EXIT_FAILURE ); 110 110 if ( &os == &abort ) abort(); … … 112 112 113 113 int fail( ofstream & os ) { 114 return os. file == 0 || ferror( (FILE *)(os.file) );114 return os.$file == 0 || ferror( (FILE *)(os.$file) ); 115 115 } // fail 116 116 117 117 int flush( ofstream & os ) { 118 return fflush( (FILE *)(os. file) );118 return fflush( (FILE *)(os.$file) ); 119 119 } // flush 120 120 … … 122 122 FILE * file = fopen( name, mode ); 123 123 #ifdef __CFA_DEBUG__ 124 if ( file == 0 ) {124 if ( file == 0p ) { 125 125 abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 126 126 } // if … … 134 134 135 135 void close( ofstream & os ) { 136 if ( (FILE *)(os. file) == stdout || (FILE *)(os.file) == stderr ) return;137 138 if ( fclose( (FILE *)(os. file) ) == EOF ) {136 if ( (FILE *)(os.$file) == stdout || (FILE *)(os.$file) == stderr ) return; 137 138 if ( fclose( (FILE *)(os.$file) ) == EOF ) { 139 139 abort | IO_MSG "close output" | nl | strerror( errno ); 140 140 } // if … … 146 146 } // if 147 147 148 if ( fwrite( data, 1, size, (FILE *)(os. file) ) != size ) {148 if ( fwrite( data, 1, size, (FILE *)(os.$file) ) != size ) { 149 149 abort | IO_MSG "write" | nl | strerror( errno ); 150 150 } // if … … 155 155 va_list args; 156 156 va_start( args, format ); 157 int len = vfprintf( (FILE *)(os. file), format, args );157 int len = vfprintf( (FILE *)(os.$file), format, args ); 158 158 if ( len == EOF ) { 159 if ( ferror( (FILE *)(os. file) ) ) {159 if ( ferror( (FILE *)(os.$file) ) ) { 160 160 abort | IO_MSG "invalid write"; 161 161 } // if … … 163 163 va_end( args ); 164 164 165 setPrt( os, true );// called in output cascade166 sepReset( os );// reset separator165 $setPrt( os, true ); // called in output cascade 166 $sepReset( os ); // reset separator 167 167 return len; 168 168 } // fmt … … 184 184 // private 185 185 void ?{}( ifstream & is, void * file ) { 186 is. file = file;187 is. nlOnOff = false;186 is.$file = file; 187 is.$nlOnOff = false; 188 188 } // ?{} 189 189 190 190 // public 191 void ?{}( ifstream & is ) { is.file = 0; }191 void ?{}( ifstream & is ) { is.$file = 0p; } 192 192 193 193 void ?{}( ifstream & is, const char name[], const char mode[] ) { … … 203 203 } // ^?{} 204 204 205 void nlOn( ifstream & os ) { os. nlOnOff = true; }206 void nlOff( ifstream & os ) { os. nlOnOff = false; }207 bool getANL( ifstream & os ) { return os. nlOnOff; }205 void nlOn( ifstream & os ) { os.$nlOnOff = true; } 206 void nlOff( ifstream & os ) { os.$nlOnOff = false; } 207 bool getANL( ifstream & os ) { return os.$nlOnOff; } 208 208 209 209 int fail( ifstream & is ) { 210 return is. file == 0 || ferror( (FILE *)(is.file) );210 return is.$file == 0p || ferror( (FILE *)(is.$file) ); 211 211 } // fail 212 212 213 213 int eof( ifstream & is ) { 214 return feof( (FILE *)(is. file) );214 return feof( (FILE *)(is.$file) ); 215 215 } // eof 216 216 … … 218 218 FILE * file = fopen( name, mode ); 219 219 #ifdef __CFA_DEBUG__ 220 if ( file == 0 ) {220 if ( file == 0p ) { 221 221 abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 222 222 } // if 223 223 #endif // __CFA_DEBUG__ 224 is. file = file;224 is.$file = file; 225 225 } // open 226 226 … … 230 230 231 231 void close( ifstream & is ) { 232 if ( (FILE *)(is. file) == stdin ) return;233 234 if ( fclose( (FILE *)(is. file) ) == EOF ) {232 if ( (FILE *)(is.$file) == stdin ) return; 233 234 if ( fclose( (FILE *)(is.$file) ) == EOF ) { 235 235 abort | IO_MSG "close input" | nl | strerror( errno ); 236 236 } // if … … 242 242 } // if 243 243 244 if ( fread( data, size, 1, (FILE *)(is. file) ) == 0 ) {244 if ( fread( data, size, 1, (FILE *)(is.$file) ) == 0 ) { 245 245 abort | IO_MSG "read" | nl | strerror( errno ); 246 246 } // if … … 253 253 } // if 254 254 255 if ( ungetc( c, (FILE *)(is. file) ) == EOF ) {255 if ( ungetc( c, (FILE *)(is.$file) ) == EOF ) { 256 256 abort | IO_MSG "ungetc" | nl | strerror( errno ); 257 257 } // if … … 263 263 264 264 va_start( args, format ); 265 int len = vfscanf( (FILE *)(is. file), format, args );265 int len = vfscanf( (FILE *)(is.$file), format, args ); 266 266 if ( len == EOF ) { 267 if ( ferror( (FILE *)(is. file) ) ) {267 if ( ferror( (FILE *)(is.$file) ) ) { 268 268 abort | IO_MSG "invalid read"; 269 269 } // if -
libcfa/src/fstream.hfa
r095ac99 rd1a9ff5 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:17202013 // Update Count : 17 212 // Last Modified On : Fri Feb 7 19:00:51 2020 13 // Update Count : 174 14 14 // 15 15 … … 24 24 enum { sepSize = 16 }; 25 25 struct ofstream { 26 void * file;27 bool sepDefault;28 bool sepOnOff;29 bool nlOnOff;30 bool prt; // print text31 bool sawNL;32 const char * sepCur;33 char separator[sepSize];34 char tupleSeparator[sepSize];26 void * $file; 27 bool $sepDefault; 28 bool $sepOnOff; 29 bool $nlOnOff; 30 bool $prt; // print text 31 bool $sawNL; 32 const char * $sepCur; 33 char $separator[sepSize]; 34 char $tupleSeparator[sepSize]; 35 35 }; // ofstream 36 36 37 37 // private 38 bool sepPrt( ofstream & );39 void sepReset( ofstream & );40 void sepReset( ofstream &, bool );41 const char * sepGetCur( ofstream & );42 void sepSetCur( ofstream &, const char [] );43 bool getNL( ofstream & );44 void setNL( ofstream &, bool );45 bool getANL( ofstream & );46 bool getPrt( ofstream & );47 void setPrt( ofstream &, bool );38 bool $sepPrt( ofstream & ); 39 void $sepReset( ofstream & ); 40 void $sepReset( ofstream &, bool ); 41 const char * $sepGetCur( ofstream & ); 42 void $sepSetCur( ofstream &, const char [] ); 43 bool $getNL( ofstream & ); 44 void $setNL( ofstream &, bool ); 45 bool $getANL( ofstream & ); 46 bool $getPrt( ofstream & ); 47 void $setPrt( ofstream &, bool ); 48 48 49 49 // public … … 82 82 83 83 struct ifstream { 84 void * file;85 bool nlOnOff;84 void * $file; 85 bool $nlOnOff; 86 86 }; // ifstream 87 87 -
libcfa/src/gmp.hfa
r095ac99 rd1a9ff5 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 11:55:07202013 // Update Count : 2 812 // Last Modified On : Fri Feb 7 22:10:30 2020 13 // Update Count : 29 14 14 // 15 15 … … 265 265 forall( dtype ostype | ostream( ostype ) ) { 266 266 ostype & ?|?( ostype & os, Int mp ) { 267 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );267 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 268 268 gmp_printf( "%Zd", mp.mpz ); 269 269 sepOn( os ); -
libcfa/src/iostream.cfa
r095ac99 rd1a9ff5 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 10:07:17202013 // Update Count : 82 212 // Last Modified On : Fri Feb 7 18:48:38 2020 13 // Update Count : 825 14 14 // 15 15 … … 35 35 forall( dtype ostype | ostream( ostype ) ) { 36 36 ostype & ?|?( ostype & os, zero_t ) { 37 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );37 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 38 38 fmt( os, "%d", 0n ); 39 39 return os; … … 44 44 45 45 ostype & ?|?( ostype & os, one_t ) { 46 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );46 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 47 47 fmt( os, "%d", 1n ); 48 48 return os; … … 53 53 54 54 ostype & ?|?( ostype & os, bool b ) { 55 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );55 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 56 56 fmt( os, "%s", b ? "true" : "false" ); 57 57 return os; … … 63 63 ostype & ?|?( ostype & os, char c ) { 64 64 fmt( os, "%c", c ); 65 if ( c == '\n' ) setNL( os, true );65 if ( c == '\n' ) $setNL( os, true ); 66 66 return sepOff( os ); 67 67 } // ?|? … … 71 71 72 72 ostype & ?|?( ostype & os, signed char sc ) { 73 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );73 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 74 74 fmt( os, "%hhd", sc ); 75 75 return os; … … 80 80 81 81 ostype & ?|?( ostype & os, unsigned char usc ) { 82 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );82 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 83 83 fmt( os, "%hhu", usc ); 84 84 return os; … … 89 89 90 90 ostype & ?|?( ostype & os, short int si ) { 91 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );91 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 92 92 fmt( os, "%hd", si ); 93 93 return os; … … 98 98 99 99 ostype & ?|?( ostype & os, unsigned short int usi ) { 100 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );100 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 101 101 fmt( os, "%hu", usi ); 102 102 return os; … … 107 107 108 108 ostype & ?|?( ostype & os, int i ) { 109 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );109 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 110 110 fmt( os, "%d", i ); 111 111 return os; … … 116 116 117 117 ostype & ?|?( ostype & os, unsigned int ui ) { 118 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );118 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 119 119 fmt( os, "%u", ui ); 120 120 return os; … … 125 125 126 126 ostype & ?|?( ostype & os, long int li ) { 127 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );127 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 128 128 fmt( os, "%ld", li ); 129 129 return os; … … 134 134 135 135 ostype & ?|?( ostype & os, unsigned long int uli ) { 136 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );136 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 137 137 fmt( os, "%lu", uli ); 138 138 return os; … … 143 143 144 144 ostype & ?|?( ostype & os, long long int lli ) { 145 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );145 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 146 146 fmt( os, "%lld", lli ); 147 147 return os; … … 152 152 153 153 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 154 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );154 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 155 155 fmt( os, "%llu", ulli ); 156 156 return os; … … 175 175 176 176 ostype & ?|?( ostype & os, float f ) { 177 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );177 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 178 178 PrintWithDP( os, "%g", f ); 179 179 return os; … … 184 184 185 185 ostype & ?|?( ostype & os, double d ) { 186 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );186 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 187 187 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 188 188 return os; … … 193 193 194 194 ostype & ?|?( ostype & os, long double ld ) { 195 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );195 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 196 196 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 197 197 return os; … … 202 202 203 203 ostype & ?|?( ostype & os, float _Complex fc ) { 204 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );204 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 205 205 // os | crealf( fc ) | nonl; 206 206 PrintWithDP( os, "%g", crealf( fc ) ); … … 214 214 215 215 ostype & ?|?( ostype & os, double _Complex dc ) { 216 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );216 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 217 217 // os | creal( dc ) | nonl; 218 218 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 226 226 227 227 ostype & ?|?( ostype & os, long double _Complex ldc ) { 228 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );228 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 229 229 // os | creall( ldc ) || nonl; 230 230 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 257 257 // first character IS NOT spacing or closing punctuation => add left separator 258 258 unsigned char ch = str[0]; // must make unsigned 259 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {260 fmt( os, "%s", sepGetCur( os ) );259 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 260 fmt( os, "%s", $sepGetCur( os ) ); 261 261 } // if 262 262 263 263 // if string starts line, must reset to determine open state because separator is off 264 sepReset( os );// reset separator264 $sepReset( os ); // reset separator 265 265 266 266 // last character IS spacing or opening punctuation => turn off separator for next item 267 267 size_t len = strlen( str ); 268 268 ch = str[len - 1]; // must make unsigned 269 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {269 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 270 270 sepOn( os ); 271 271 } else { 272 272 sepOff( os ); 273 273 } // if 274 if ( ch == '\n' ) setNL( os, true ); // check *AFTER*sepPrt call above as it resets NL flag274 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag 275 275 return write( os, str, len ); 276 276 } // ?|? … … 281 281 282 282 // ostype & ?|?( ostype & os, const char16_t * str ) { 283 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );283 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 284 284 // fmt( os, "%ls", str ); 285 285 // return os; … … 288 288 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 289 289 // ostype & ?|?( ostype & os, const char32_t * str ) { 290 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );290 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 291 291 // fmt( os, "%ls", str ); 292 292 // return os; … … 295 295 296 296 // ostype & ?|?( ostype & os, const wchar_t * str ) { 297 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );297 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 298 298 // fmt( os, "%ls", str ); 299 299 // return os; … … 301 301 302 302 ostype & ?|?( ostype & os, const void * p ) { 303 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );303 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 304 304 fmt( os, "%p", p ); 305 305 return os; … … 316 316 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 317 317 (ostype &)(manip( os )); 318 if ( getPrt( os ) ) ends( os );// something printed ?319 setPrt( os, false ); // turn off318 if ( $getPrt( os ) ) ends( os ); // something printed ? 319 $setPrt( os, false ); // turn off 320 320 } // ?|? 321 321 … … 330 330 ostype & nl( ostype & os ) { 331 331 (ostype &)(os | '\n'); 332 setPrt( os, false ); // turn off333 setNL( os, true );332 $setPrt( os, false ); // turn off 333 $setNL( os, true ); 334 334 flush( os ); 335 335 return sepOff( os ); // prepare for next line … … 337 337 338 338 ostype & nonl( ostype & os ) { 339 setPrt( os, false ); // turn off339 $setPrt( os, false ); // turn off 340 340 return os; 341 341 } // nonl … … 376 376 ostype & ?|?( ostype & os, T arg, Params rest ) { 377 377 (ostype &)(os | arg); // print first argument 378 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator378 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 379 379 (ostype &)(os | rest); // print remaining arguments 380 sepSetCur( os, sepGet( os ) ); // switch to regular separator380 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 381 381 return os; 382 382 } // ?|? … … 384 384 // (ostype &)(?|?( os, arg, rest )); ends( os ); 385 385 (ostype &)(os | arg); // print first argument 386 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator386 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 387 387 (ostype &)(os | rest); // print remaining arguments 388 sepSetCur( os, sepGet( os ) ); // switch to regular separator388 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 389 389 ends( os ); 390 390 } // ?|? … … 415 415 forall( dtype ostype | ostream( ostype ) ) { \ 416 416 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 417 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \417 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 418 418 \ 419 419 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 514 514 forall( dtype ostype | ostream( ostype ) ) { \ 515 515 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 516 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \516 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 517 517 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 518 518 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 557 557 } // if 558 558 559 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );559 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 560 560 561 561 #define CFMTNP "% * " … … 595 595 } // if 596 596 597 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );597 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 598 598 599 599 #define SFMTNP "% * " -
libcfa/src/iostream.hfa
r095ac99 rd1a9ff5 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 11:55:28202013 // Update Count : 33 512 // Last Modified On : Fri Feb 7 17:53:52 2020 13 // Update Count : 336 14 14 // 15 15 … … 24 24 trait ostream( dtype ostype ) { 25 25 // private 26 bool sepPrt( ostype & ); // get separator state (on/off)27 void sepReset( ostype & ); // set separator state to default state28 void sepReset( ostype &, bool ); // set separator and default state29 const char * sepGetCur( ostype & );// get current separator string30 void sepSetCur( ostype &, const char [] ); // set current separator string31 bool getNL( ostype & );// check newline32 void setNL( ostype &, bool ); // saw newline33 bool getANL( ostype & ); // get auto newline (on/off)34 bool getPrt( ostype & ); // get fmt called in output cascade35 void setPrt( ostype &, bool ); // set fmt called in output cascade26 bool $sepPrt( ostype & ); // get separator state (on/off) 27 void $sepReset( ostype & ); // set separator state to default state 28 void $sepReset( ostype &, bool ); // set separator and default state 29 const char * $sepGetCur( ostype & ); // get current separator string 30 void $sepSetCur( ostype &, const char [] ); // set current separator string 31 bool $getNL( ostype & ); // check newline 32 void $setNL( ostype &, bool ); // saw newline 33 bool $getANL( ostype & ); // get auto newline (on/off) 34 bool $getPrt( ostype & ); // get fmt called in output cascade 35 void $setPrt( ostype &, bool ); // set fmt called in output cascade 36 36 // public 37 37 void sepOn( ostype & ); // turn separator state on
Note: See TracChangeset
for help on using the changeset viewer.