Changes in / [37f9860:c4187df]
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream
r37f9860 rc4187df 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 21 15:57:24201713 // Update Count : 10212 // Last Modified On : Tue Mar 7 14:48:08 2017 13 // Update Count : 91 14 14 // 15 15 … … 21 21 enum { separateSize = 16 }; 22 22 struct ofstream { 23 void * 23 void *file; 24 24 _Bool sepDefault; 25 25 _Bool sepOnOff; 26 const char * sepCur;27 26 char separator[separateSize]; 28 char tupleSeparator[separateSize];29 27 }; // ofstream 30 28 … … 34 32 void sepReset( ofstream * ); 35 33 void sepReset( ofstream *, _Bool ); 36 const char * sepGetCur( ofstream * );37 void sepSetCur( ofstream *, const char * );38 34 const char * sepGet( ofstream * ); 39 35 void sepSet( ofstream *, const char * ); 40 const char * sepGetTuple( ofstream * );41 void sepSetTuple( ofstream *, const char * );42 36 _Bool sepDisable( ofstream * ); 43 37 _Bool sepEnable( ofstream * ); … … 48 42 void close( ofstream * ); 49 43 ofstream * write( ofstream *, const char * data, unsigned long int size ); 50 int fmt( ofstream *, const char fmt[], ... ); 51 52 void ?{}( ofstream * ); 44 int prtfmt( ofstream *, const char fmt[], ... ); 53 45 54 46 extern ofstream * sout, * serr; … … 56 48 // implement context istream 57 49 struct ifstream { 58 void * 50 void *file; 59 51 }; // ifstream 60 52 … … 65 57 ifstream * read( ifstream * is, char * data, unsigned long int size ); 66 58 ifstream * ungetc( ifstream * is, char c ); 67 int fmt( ifstream *, const char fmt[], ... );59 int scanfmt( ifstream *, const char fmt[], ... ); 68 60 69 extern ifstream * 61 extern ifstream *sin; 70 62 71 63 #endif // __FSTREAM_H__ -
src/libcfa/fstream.c
r37f9860 rc4187df 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 22 16:17:21201713 // Update Count : 22112 // Last Modified On : Tue Mar 7 14:48:09 2017 13 // Update Count : 192 14 14 // 15 15 … … 25 25 #include <complex.h> // creal, cimag 26 26 } 27 #include "assert"28 27 29 28 #define IO_MSG "I/O error: " … … 34 33 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; } 35 34 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; } 36 37 const char * sepGetCur( ofstream * os ) { return os->sepCur; } 38 void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; } 39 40 const char * sepGet( ofstream * os ) { return os->separator; } 35 const char * sepGet( ofstream * os ) { return &(os->separator[0]); } 41 36 42 37 void sepSet( ofstream * os, const char * s ) { 43 assert( s ); 44 strncpy( os->separator, s, separateSize - 1 ); 38 strncpy( &(os->separator[0]), s, separateSize - 1 ); 45 39 os->separator[separateSize - 1] = '\0'; 46 } // sepSet47 48 const char * sepGetTuple( ofstream * os ) { return os->tupleSeparator; }49 50 void sepSetTuple( ofstream * os, const char * s ) {51 assert( s );52 strncpy( os->tupleSeparator, s, separateSize - 1 );53 os->tupleSeparator[separateSize - 1] = '\0';54 40 } // sepSet 55 41 … … 109 95 } // write 110 96 111 int fmt( ofstream * os, const char format[], ... ) {97 int prtfmt( ofstream * os, const char fmt[], ... ) { 112 98 va_list args; 113 va_start( args, f ormat );114 int len = vfprintf( (FILE *)(os->file), f ormat, args );99 va_start( args, fmt ); 100 int len = vfprintf( (FILE *)(os->file), fmt, args ); 115 101 if ( len == EOF ) { 116 102 if ( ferror( (FILE *)(os->file) ) ) { … … 123 109 sepReset( os ); // reset separator 124 110 return len; 125 } // fmt111 } // prtfmt 126 112 127 void ?{}( ofstream * this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {128 this->file = file;129 this->sepDefault = sepDefault;130 this->sepOnOff = sepOnOff;131 sepSet( this, separator );132 sepSetCur( this, sepGet( this ) );133 sepSetTuple( this, tupleSeparator );134 }135 113 136 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", "};114 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, { ' ', '\0' } }; 137 115 ofstream *sout = &soutFile; 138 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", "};116 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, { ' ', '\0' } }; 139 117 ofstream *serr = &serrFile; 140 118 … … 195 173 } // ungetc 196 174 197 int fmt( ifstream * is, const char format[], ... ) {175 int scanfmt( ifstream * is, const char fmt[], ... ) { 198 176 va_list args; 199 177 200 va_start( args, f ormat );201 int len = vfscanf( (FILE *)(is->file), f ormat, args );178 va_start( args, fmt ); 179 int len = vfscanf( (FILE *)(is->file), fmt, args ); 202 180 if ( len == EOF ) { 203 181 if ( ferror( (FILE *)(is->file) ) ) { … … 208 186 va_end( args ); 209 187 return len; 210 } // fmt188 } // prtfmt 211 189 212 190 -
src/libcfa/iostream
r37f9860 rc4187df 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 21 15:57:29201713 // Update Count : 10412 // Last Modified On : Mon Mar 6 20:51:35 2017 13 // Update Count : 98 14 14 // 15 15 … … 25 25 void sepReset( ostype * ); // set separator state to default state 26 26 void sepReset( ostype *, _Bool ); // set separator and default state 27 const char * sepGetCur( ostype * ); // get current separator string 28 void sepSetCur( ostype *, const char * ); // set current separator string 27 void sepSet( ostype *, const char * ); // set separator to string (15 character maximum) 29 28 const char * sepGet( ostype * ); // get separator string 30 void sepSet( ostype *, const char * ); // set separator to string (15 character maximum)31 const char * sepGetTuple( ostype * ); // get tuple separator string32 void sepSetTuple( ostype *, const char * ); // set tuple separator to string (15 character maximum)33 29 _Bool sepDisable( ostype * ); // set default state to off, and return previous state 34 30 _Bool sepEnable( ostype * ); // set default state to on, and return previous state … … 39 35 void close( ostype * os ); 40 36 ostype * write( ostype *, const char *, unsigned long int ); 41 int fmt( ostype *, const char fmt[], ... );37 int prtfmt( ostype *, const char fmt[], ... ); 42 38 }; 43 39 … … 99 95 istype * read( istype *, char *, unsigned long int ); 100 96 istype * ungetc( istype *, char ); 101 int fmt( istype *, const char fmt[], ... );97 int scanfmt( istype *, const char fmt[], ... ); 102 98 }; 103 99 -
src/libcfa/iostream.c
r37f9860 rc4187df 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 22 17:21:23201713 // Update Count : 3 5812 // Last Modified On : Mon Mar 6 20:52:02 2017 13 // Update Count : 313 14 14 // 15 15 … … 24 24 25 25 forall( dtype ostype | ostream( ostype ) ) 26 ostype * ?|?( ostype * 27 fmt( os, "%c", c );28 sepOff( os ); 29 return os; 30 } // ?|? 31 32 forall( dtype ostype | ostream( ostype ) ) 33 ostype * ?|?( ostype * 34 fmt( os, "%hhd", c );35 sepOff( os ); 36 return os; 37 } // ?|? 38 39 forall( dtype ostype | ostream( ostype ) ) 40 ostype * ?|?( ostype * 41 fmt( os, "%hhu", c );42 sepOff( os ); 43 return os; 44 } // ?|? 45 46 forall( dtype ostype | ostream( ostype ) ) 47 ostype * ?|?( ostype * 48 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );49 fmt( os, "%hd", si );50 return os; 51 } // ?|? 52 53 forall( dtype ostype | ostream( ostype ) ) 54 ostype * ?|?( ostype * 55 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );56 fmt( os, "%hu", usi );57 return os; 58 } // ?|? 59 60 forall( dtype ostype | ostream( ostype ) ) 61 ostype * ?|?( ostype * 62 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );63 fmt( os, "%d", i );64 return os; 65 } // ?|? 66 67 forall( dtype ostype | ostream( ostype ) ) 68 ostype * ?|?( ostype * 69 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );70 fmt( os, "%u", ui );71 return os; 72 } // ?|? 73 74 forall( dtype ostype | ostream( ostype ) ) 75 ostype * ?|?( ostype * 76 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );77 fmt( os, "%ld", li );78 return os; 79 } // ?|? 80 81 forall( dtype ostype | ostream( ostype ) ) 82 ostype * ?|?( ostype * 83 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );84 fmt( os, "%lu", uli );85 return os; 86 } // ?|? 87 88 forall( dtype ostype | ostream( ostype ) ) 89 ostype * ?|?( ostype * 90 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );91 fmt( os, "%lld", lli );92 return os; 93 } // ?|? 94 95 forall( dtype ostype | ostream( ostype ) ) 96 ostype * ?|?( ostype * 97 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );98 fmt( os, "%llu", ulli );99 return os; 100 } // ?|? 101 102 forall( dtype ostype | ostream( ostype ) ) 103 ostype * ?|?( ostype * 104 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );105 fmt( os, "%g", f );106 return os; 107 } // ?|? 108 109 forall( dtype ostype | ostream( ostype ) ) 110 ostype * ?|?( ostype * 111 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );112 fmt( os, "%.*lg", DBL_DIG, d );113 return os; 114 } // ?|? 115 116 forall( dtype ostype | ostream( ostype ) ) 117 ostype * ?|?( ostype * 118 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );119 fmt( os, "%.*Lg", LDBL_DIG, ld );120 return os; 121 } // ?|? 122 123 forall( dtype ostype | ostream( ostype ) ) 124 ostype * ?|?( ostype * 26 ostype * ?|?( ostype *os, char c ) { 27 prtfmt( os, "%c", c ); 28 sepOff( os ); 29 return os; 30 } // ?|? 31 32 forall( dtype ostype | ostream( ostype ) ) 33 ostype * ?|?( ostype *os, signed char c ) { 34 prtfmt( os, "%hhd", c ); 35 sepOff( os ); 36 return os; 37 } // ?|? 38 39 forall( dtype ostype | ostream( ostype ) ) 40 ostype * ?|?( ostype *os, unsigned char c ) { 41 prtfmt( os, "%hhu", c ); 42 sepOff( os ); 43 return os; 44 } // ?|? 45 46 forall( dtype ostype | ostream( ostype ) ) 47 ostype * ?|?( ostype *os, short int si ) { 48 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 49 prtfmt( os, "%hd", si ); 50 return os; 51 } // ?|? 52 53 forall( dtype ostype | ostream( ostype ) ) 54 ostype * ?|?( ostype *os, unsigned short int usi ) { 55 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 56 prtfmt( os, "%hu", usi ); 57 return os; 58 } // ?|? 59 60 forall( dtype ostype | ostream( ostype ) ) 61 ostype * ?|?( ostype *os, int i ) { 62 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 63 prtfmt( os, "%d", i ); 64 return os; 65 } // ?|? 66 67 forall( dtype ostype | ostream( ostype ) ) 68 ostype * ?|?( ostype *os, unsigned int ui ) { 69 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 70 prtfmt( os, "%u", ui ); 71 return os; 72 } // ?|? 73 74 forall( dtype ostype | ostream( ostype ) ) 75 ostype * ?|?( ostype *os, long int li ) { 76 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 77 prtfmt( os, "%ld", li ); 78 return os; 79 } // ?|? 80 81 forall( dtype ostype | ostream( ostype ) ) 82 ostype * ?|?( ostype *os, unsigned long int uli ) { 83 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 84 prtfmt( os, "%lu", uli ); 85 return os; 86 } // ?|? 87 88 forall( dtype ostype | ostream( ostype ) ) 89 ostype * ?|?( ostype *os, long long int lli ) { 90 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 91 prtfmt( os, "%lld", lli ); 92 return os; 93 } // ?|? 94 95 forall( dtype ostype | ostream( ostype ) ) 96 ostype * ?|?( ostype *os, unsigned long long int ulli ) { 97 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 98 prtfmt( os, "%llu", ulli ); 99 return os; 100 } // ?|? 101 102 forall( dtype ostype | ostream( ostype ) ) 103 ostype * ?|?( ostype *os, float f ) { 104 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 105 prtfmt( os, "%g", f ); 106 return os; 107 } // ?|? 108 109 forall( dtype ostype | ostream( ostype ) ) 110 ostype * ?|?( ostype *os, double d ) { 111 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 112 prtfmt( os, "%.*lg", DBL_DIG, d ); 113 return os; 114 } // ?|? 115 116 forall( dtype ostype | ostream( ostype ) ) 117 ostype * ?|?( ostype *os, long double ld ) { 118 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 119 prtfmt( os, "%.*Lg", LDBL_DIG, ld ); 120 return os; 121 } // ?|? 122 123 forall( dtype ostype | ostream( ostype ) ) 124 ostype * ?|?( ostype *os, float _Complex fc ) { 125 125 os | crealf( fc ); 126 126 _Bool temp = sepDisable( os ); // disable separators within complex value … … 132 132 133 133 forall( dtype ostype | ostream( ostype ) ) 134 ostype * ?|?( ostype * 134 ostype * ?|?( ostype *os, double _Complex dc ) { 135 135 os | creal( dc ); 136 136 _Bool temp = sepDisable( os ); // disable separators within complex value … … 142 142 143 143 forall( dtype ostype | ostream( ostype ) ) 144 ostype * ?|?( ostype * 144 ostype * ?|?( ostype *os, long double _Complex ldc ) { 145 145 os | creall( ldc ); 146 146 _Bool temp = sepDisable( os ); // disable separators within complex value … … 152 152 153 153 forall( dtype ostype | ostream( ostype ) ) 154 ostype * ?|?( ostype * os, const char *cp ) {154 ostype * ?|?( ostype *os, const char *cp ) { 155 155 enum { Open = 1, Close, OpenClose }; 156 156 static const unsigned char mask[256] = { 157 157 // opening delimiters, no space after 158 158 ['('] : Open, ['['] : Open, ['{'] : Open, 159 [' ='] : Open, ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,159 ['$'] : Open, ['='] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, 160 160 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 161 161 // closing delimiters, no space before 162 162 [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close, 163 [')'] : Close, [']'] : Close, ['}'] : Close, 163 164 ['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close, 164 [')'] : Close, [']'] : Close, ['}'] : Close,165 165 // opening-closing delimiters, no space before or after 166 166 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, … … 173 173 unsigned char ch = cp[0]; // must make unsigned 174 174 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 175 fmt( os, "%s", sepGetCur( os ) );175 prtfmt( os, "%s", sepGet( os ) ); 176 176 } // if 177 177 … … 191 191 192 192 forall( dtype ostype | ostream( ostype ) ) 193 ostype * ?|?( ostype * os, const void *p ) {194 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );195 fmt( os, "%p", p );193 ostype * ?|?( ostype *os, const void *p ) { 194 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 195 prtfmt( os, "%p", p ); 196 196 return os; 197 197 } // ?|? … … 201 201 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) 202 202 ostype * ?|?( ostype * os, T arg, Params rest ) { 203 forall( ttype Params ) ostype * prtTuple( ostype * os, T arg, Params rest ) { 204 os | arg; // print first argument 205 os | rest; // print remaining arguments 206 return os; 207 } // prtTuple 208 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 209 prtTuple( os, arg, rest ); // recursively print tuple 210 sepSetCur( os, sepGet( os ) ); // switch to regular separator 203 os | arg | ", "; 204 os | rest; 211 205 return os; 212 206 } // ?|? … … 254 248 255 249 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) ) 256 void write( iteratortype begin, iteratortype end, ostype * 250 void write( iteratortype begin, iteratortype end, ostype *os ) { 257 251 void print( elttype i ) { os | i; } 258 252 for_each( begin, end, print ); … … 260 254 261 255 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) ) 262 void write_reverse( iteratortype begin, iteratortype end, ostype * 256 void write_reverse( iteratortype begin, iteratortype end, ostype *os ) { 263 257 void print( elttype i ) { os | i; } 264 258 for_each_reverse( begin, end, print ); … … 269 263 forall( dtype istype | istream( istype ) ) 270 264 istype * ?|?( istype * is, char * c ) { 271 fmt( is, "%c", c );265 scanfmt( is, "%c", c ); 272 266 return is; 273 267 } // ?|? … … 275 269 forall( dtype istype | istream( istype ) ) 276 270 istype * ?|?( istype * is, short int * si ) { 277 fmt( is, "%hd", si );271 scanfmt( is, "%hd", si ); 278 272 return is; 279 273 } // ?|? … … 281 275 forall( dtype istype | istream( istype ) ) 282 276 istype * ?|?( istype * is, unsigned short int * usi ) { 283 fmt( is, "%hu", usi );277 scanfmt( is, "%hu", usi ); 284 278 return is; 285 279 } // ?|? … … 287 281 forall( dtype istype | istream( istype ) ) 288 282 istype * ?|?( istype * is, int * i ) { 289 fmt( is, "%d", i );283 scanfmt( is, "%d", i ); 290 284 return is; 291 285 } // ?|? … … 293 287 forall( dtype istype | istream( istype ) ) 294 288 istype * ?|?( istype * is, unsigned int * ui ) { 295 fmt( is, "%u", ui );289 scanfmt( is, "%u", ui ); 296 290 return is; 297 291 } // ?|? … … 299 293 forall( dtype istype | istream( istype ) ) 300 294 istype * ?|?( istype * is, long int * li ) { 301 fmt( is, "%ld", li );295 scanfmt( is, "%ld", li ); 302 296 return is; 303 297 } // ?|? … … 305 299 forall( dtype istype | istream( istype ) ) 306 300 istype * ?|?( istype * is, unsigned long int * ulli ) { 307 fmt( is, "%lu", ulli );301 scanfmt( is, "%lu", ulli ); 308 302 return is; 309 303 } // ?|? … … 311 305 forall( dtype istype | istream( istype ) ) 312 306 istype * ?|?( istype * is, long long int * lli ) { 313 fmt( is, "%lld", lli );307 scanfmt( is, "%lld", lli ); 314 308 return is; 315 309 } // ?|? … … 317 311 forall( dtype istype | istream( istype ) ) 318 312 istype * ?|?( istype * is, unsigned long long int * ulli ) { 319 fmt( is, "%llu", ulli );313 scanfmt( is, "%llu", ulli ); 320 314 return is; 321 315 } // ?|? … … 324 318 forall( dtype istype | istream( istype ) ) 325 319 istype * ?|?( istype * is, float * f ) { 326 fmt( is, "%f", f );320 scanfmt( is, "%f", f ); 327 321 return is; 328 322 } // ?|? … … 330 324 forall( dtype istype | istream( istype ) ) 331 325 istype * ?|?( istype * is, double * d ) { 332 fmt( is, "%lf", d );326 scanfmt( is, "%lf", d ); 333 327 return is; 334 328 } // ?|? … … 336 330 forall( dtype istype | istream( istype ) ) 337 331 istype * ?|?( istype * is, long double * ld ) { 338 fmt( is, "%Lf", ld );332 scanfmt( is, "%Lf", ld ); 339 333 return is; 340 334 } // ?|? … … 344 338 istype * ?|?( istype * is, float _Complex * fc ) { 345 339 float re, im; 346 fmt( is, "%g%gi", &re, &im );340 scanfmt( is, "%g%gi", &re, &im ); 347 341 *fc = re + im * _Complex_I; 348 342 return is; … … 352 346 istype * ?|?( istype * is, double _Complex * dc ) { 353 347 double re, im; 354 fmt( is, "%lf%lfi", &re, &im );348 scanfmt( is, "%lf%lfi", &re, &im ); 355 349 *dc = re + im * _Complex_I; 356 350 return is; … … 360 354 istype * ?|?( istype * is, long double _Complex * ldc ) { 361 355 long double re, im; 362 fmt( is, "%Lf%Lfi", &re, &im );356 scanfmt( is, "%Lf%Lfi", &re, &im ); 363 357 *ldc = re + im * _Complex_I; 364 358 return is; … … 368 362 forall( dtype istype | istream( istype ) ) 369 363 istype * ?|?( istype * is, _Istream_cstrUC cstr ) { 370 fmt( is, "%s", cstr.s );364 scanfmt( is, "%s", cstr.s ); 371 365 return is; 372 366 } // cstr … … 377 371 char buf[16]; 378 372 sprintf( buf, "%%%ds", cstr.size ); 379 fmt( is, buf, cstr.s );373 scanfmt( is, buf, cstr.s ); 380 374 return is; 381 375 } // cstr -
src/tests/.expect/io.txt
r37f9860 rc4187df 18 18 abc, $xyz 19 19 20 v(27 v[27 v{27 $27 =27£27 ¥27 ¡27 ¿27 «2721 25, 25. 25: 25; 25! 25? 25 % 25¢ 25» 25) 25] 25}20 v(27 v[27 v{27 $27 £27 ¥27 ¡27 ¿27 «27 21 25, 25. 25: 25; 25! 25? 25) 25] 25} 25% 25¢ 25» 22 22 25'27 25`27 25"27 25 27 25 23 23 27 25 … … 25 25 27 25 27 25 26 26 27 27 3, 4, a, 7.228 3, 4, a, 7.229 3 4 a 7.230 3 4 a 7.234a7.2 3 4 a 7.231 3-4-a-7.2^3^4-3-4-a-7.2 -
src/tests/io.c
r37f9860 rc4187df 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 21 22:36:06 201713 // Update Count : 4812 // Last Modified On : Tue Jul 5 18:29:23 2016 13 // Update Count : 31 14 14 // 15 15 … … 62 62 63 63 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 64 sout | f | d | ld | endl 65 | fc | dc | ldc | endl 64 sout | f | d | ld | endl // floating point without separator 65 | fc | dc | ldc | endl // complex without separator 66 66 | s1 | s2 | endl; 67 67 sout | endl; … … 74 74 | "v{" | 27 75 75 | "$" | 27 76 | "=" | 2777 76 | "£" | 27 78 77 | "¥" | 27 … … 88 87 | 25 | "!" 89 88 | 25 | "?" 89 | 25 | ")" 90 | 25 | "]" 91 | 25 | "}" 90 92 | 25 | "%" 91 93 | 25 | "¢" 92 94 | 25 | "»" 93 | 25 | ")"94 | 25 | "]"95 | 25 | "}"96 95 | endl 97 96 // opening-closing delimiters … … 106 105 | 25 | "\v" | 27 107 106 | endl; 108 109 [int, int, const char *, double] t = { 3, 4, "a", 7.2 };110 sout | [ 3, 4, "a", 7.2 ] | endl;111 sout | t | endl;112 sepSetTuple( sout, " " );113 sout | t | endl;114 sout | sepOn | t | sepDisable | t | sepEnable | t | endl;115 sepSet( sout, "^" );116 sepSetTuple( sout, "-" );117 sout | t | 3 | 4 | t | endl;118 107 } 119 108
Note: See TracChangeset
for help on using the changeset viewer.