Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r61c7239 re63326b  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jun  9 16:27:17 2019
    13 // Update Count     : 803
     12// Last Modified On : Tue May 21 13:01:26 2019
     13// Update Count     : 674
    1414//
    1515
     
    2020#include <stdbool.h>                                                                    // true/false
    2121//#include <string.h>                                                                   // strlen, strcmp
     22extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
    2223extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
    23 extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
    24 extern char *strcpy (char *__restrict __dest, const char *__restrict __src) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
    25 extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
    2624#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
    2725#include <math.h>                                                                               // isfinite
    2826#include <complex.h>                                                                    // creal, cimag
    29 } // extern "C"
    30 
    31 
    32 //*********************************** Ostream ***********************************
    33 
     27}
    3428
    3529forall( dtype ostype | ostream( ostype ) ) {
     
    204198                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    205199//              os | crealf( fc ) | nonl;
    206                 PrintWithDP( os, "%g", crealf( fc ) );
    207                 PrintWithDP( os, "%+g", cimagf( fc ) );
     200                float f = crealf( fc );
     201                PrintWithDP( os, "%g", f );
     202                f = cimagf( fc );
     203                PrintWithDP( os, "%+g", f );
    208204                fmt( os, "i" );
    209205                return os;
     
    216212                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    217213//              os | creal( dc ) | nonl;
    218                 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG );
    219                 PrintWithDP( os, "%+.*lg", cimag( dc ), DBL_DIG );
     214                double d = creal( dc );
     215                PrintWithDP( os, "%.*lg", d, DBL_DIG );
     216                d = cimag( dc );
     217                PrintWithDP( os, "%+.*lg", d, DBL_DIG );
    220218                fmt( os, "i" );
    221219                return os;
     
    228226                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    229227//              os | creall( ldc ) || nonl;
    230                 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG );
    231                 PrintWithDP( os, "%+.*Lg", cimagl( ldc ), LDBL_DIG );
     228                long double ld = creall( ldc );
     229                PrintWithDP( os, "%.*Lg", ld, LDBL_DIG );
     230                ld = cimagl( ldc );
     231                PrintWithDP( os, "%+.*Lg", ld, LDBL_DIG );
    232232                fmt( os, "i" );
    233233                return os;
     
    395395} // distribution
    396396
     397//---------------------------------------
     398
    397399// writes the range [begin, end) to the given stream
    398400forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) {
     
    408410} // distribution
    409411
    410 //*********************************** Manipulators ***********************************
    411 
    412 //*********************************** Integral ***********************************
    413 
    414 static const char * shortbin[] = { "0", "1", "10", "11", "100", "101", "110", "111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" };
    415 static const char * longbin[]  = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" };
    416 
    417 // Default prefix for non-decimal prints is 0b, 0, 0x.
    418 #define IntegralFMTImpl( T, CODE, IFMTNP, IFMTP ) \
    419 forall( dtype ostype | ostream( ostype ) ) { \
    420         ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    421                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
    422 \
    423                 if ( f.base == 'b' || f.base == 'B' ) {                 /* bespoke binary format */ \
    424                         int bits;                                                                                                       \
    425                         if ( f.val == (T){0} ) bits = 1;                        /* force at least one bit to print */ \
    426                         else bits = sizeof(long long int) * 8 - __builtin_clzll( f.val ); /* position of most significant bit */ \
    427                         bits = bits > sizeof(f.val) * 8 ? sizeof(f.val) * 8 : bits; \
    428                         int spaces = f.wd - bits;                                       /* can be negative */ \
    429                         if ( ! f.flags.nobsdp ) { spaces -= 2; }        /* base prefix takes space */ \
    430                         /* printf( "%d %d\n", bits, spaces ); */ \
    431                         if ( ! f.flags.left ) {                                         /* right justified ? */ \
    432                                 /* Note, base prefix then zero padding or spacing then prefix. */ \
    433                                 if ( f.flags.pad0 || f.flags.pc ) { \
    434                                         if ( ! f.flags.nobsdp ) { fmt( os, "0%c", f.base ); } \
    435                                         if ( f.flags.pc ) spaces = f.pc - bits; \
    436                                         if ( spaces > 0 ) fmt( os, "%0*d", spaces, 0 ); /* zero pad */ \
    437                                 } else { \
    438                                         if ( spaces > 0 ) fmt( os, "%*s", spaces, " " ); /* space pad */ \
    439                                         if ( ! f.flags.nobsdp ) { fmt( os, "0%c", f.base ); } \
    440                                 } /* if */ \
    441                         } else if ( ! f.flags.nobsdp ) { \
    442                                 fmt( os, "0%c", f.base ); \
    443                         } /* if */ \
    444                         int shift = (bits - 1) / 4 * 4; /* floor( bits - 1, 4 ) */ \
    445                         typeof( f.val ) temp = f.val; \
    446                         fmt( os, "%s", shortbin[(temp >> shift) & 0xf] ); \
    447                         for () { \
    448                                 shift -= 4; \
    449                           if ( shift < 0 ) break; \
    450                                 temp = f.val; \
    451                                 fmt( os, "%s", longbin[(temp >> shift) & 0xf] ); \
    452                         } /* for */ \
    453                         if ( f.flags.left && spaces > 0 ) fmt( os, "%*s", spaces, " " ); \
    454                         return os; \
    455                 } /* if  */ \
    456 \
    457                 char fmtstr[sizeof(IFMTP)];                                             /* sizeof includes '\0' */ \
    458                 if ( ! f.flags.pc ) memcpy( &fmtstr, IFMTNP, sizeof(IFMTNP) ); \
    459                 else memcpy( &fmtstr, IFMTP, sizeof(IFMTP) ); \
    460                 int star = 4;                                                                   /* position before first '*' */ \
    461 \
    462                 /* Insert flags into spaces before '*', from right to left. */ \
    463                 if ( ! f.flags.nobsdp ) { fmtstr[star] = '#'; star -= 1; } \
    464                 if ( f.flags.left ) { fmtstr[star] = '-'; star -= 1; } \
    465                 if ( f.flags.sign && f.base == CODE ) { fmtstr[star] = '+'; star -= 1; } \
    466                 if ( f.flags.pad0 && ! f.flags.pc ) { fmtstr[star] = '0'; star -= 1; } \
    467                 fmtstr[star] = '%'; \
    468 \
    469                 if ( ! f.flags.pc ) {                                                   /* no precision */ \
    470                         /* printf( "%s\n", &fmtstr[star] ); */ \
    471                         fmtstr[sizeof(IFMTNP)-2] = f.base;                      /* sizeof includes '\0' */ \
    472                         fmt( os, &fmtstr[star], f.wd, f.val ); \
    473                 } else {                                                                                /* precision */ \
    474                         fmtstr[sizeof(IFMTP)-2] = f.base;                       /* sizeof includes '\0' */ \
    475                         /* printf( "%s\n", &fmtstr[star] ); */ \
    476                         fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \
    477                 } /* if */ \
    478                 return os; \
    479         } /* ?|? */ \
    480         void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); nl( os ); } \
    481 } // distribution
    482 
    483 IntegralFMTImpl( signed char, 'd', "%    *hh ", "%    *.*hh " )
    484 IntegralFMTImpl( unsigned char, 'u', "%    *hh ", "%    *.*hh " )
    485 IntegralFMTImpl( signed short int, 'd', "%    *h ", "%    *.*h " )
    486 IntegralFMTImpl( unsigned short int, 'u', "%    *h ", "%    *.*h " )
    487 IntegralFMTImpl( signed int, 'd', "%    * ", "%    *.* " )
    488 IntegralFMTImpl( unsigned int, 'u', "%    * ", "%    *.* " )
    489 IntegralFMTImpl( signed long int, 'd', "%    *l ", "%    *.*l " )
    490 IntegralFMTImpl( unsigned long int, 'u', "%    *l ", "%    *.*l " )
    491 IntegralFMTImpl( signed long long int, 'd', "%    *ll ", "%    *.*ll " )
    492 IntegralFMTImpl( unsigned long long int, 'u', "%    *ll ", "%    *.*ll " )
    493 
    494 //*********************************** Floating Point ***********************************
    495 
    496 #define PrintWithDP2( os, format, val, ... ) \
    497         { \
    498                 enum { size = 48 }; \
    499                 char buf[size]; \
    500                 int bufbeg = 0, i, len = snprintf( buf, size, format, ##__VA_ARGS__, val ); \
    501                 if ( isfinite( val ) && (f.base != 'g' || f.pc != 0) ) { /* if number, print decimal point */ \
    502                         for ( i = 0; i < len && buf[i] != '.' && buf[i] != 'e' && buf[i] != 'E'; i += 1 ); /* decimal point or scientific ? */ \
    503                         if ( i == len && ! f.flags.nobsdp ) { \
    504                                 if ( ! f.flags.left ) { \
    505                                         buf[i] = '.'; buf[i + 1] = '\0'; \
    506                                         if ( buf[0] == ' ' ) bufbeg = 1; /* decimal point within width */ \
    507                                 } else { \
    508                                         for ( i = 0; i < len && buf[i] != ' '; i += 1 ); /* trailing blank ? */ \
    509                                         buf[i] = '.'; \
    510                                         if ( i == len ) buf[i + 1] = '\0'; \
    511                                 } /* if */ \
    512                         } /* if */ \
    513                 } /* if */ \
    514                 fmt( os, "%s", &buf[bufbeg] ); \
    515         }
    516 
    517 #define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \
    518 forall( dtype ostype | ostream( ostype ) ) { \
    519         ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    520                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
    521                 char fmtstr[sizeof(DFMTP)];                                             /* sizeof includes '\0' */ \
    522                 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \
    523                 else memcpy( &fmtstr, DFMTP, sizeof(DFMTP) ); \
    524                 int star = 4;                                                                   /* position before first '*' */ \
    525 \
    526                 /* Insert flags into spaces before '*', from right to left. */ \
    527                 if ( f.flags.left ) { fmtstr[star] = '-'; star -= 1; } \
    528                 if ( f.flags.sign ) { fmtstr[star] = '+'; star -= 1; } \
    529                 if ( f.flags.pad0 ) { fmtstr[star] = '0'; star -= 1; } \
    530                 fmtstr[star] = '%'; \
    531 \
    532                 if ( ! f.flags.pc ) {                                                   /* no precision */ \
    533                         fmtstr[sizeof(DFMTNP)-2] = f.base;                      /* sizeof includes '\0' */ \
    534                         /* printf( "%g %d %s\n", f.val, f.wd, &fmtstr[star]); */ \
    535                         PrintWithDP2( os, &fmtstr[star], f.val, f.wd ) \
    536                 } else {                                                                                /* precision */ \
    537                         fmtstr[sizeof(DFMTP)-2] = f.base;                       /* sizeof includes '\0' */ \
    538                         /* printf( "%g %d %d %s\n", f.val, f.wd, f.pc, &fmtstr[star] ); */ \
    539                         PrintWithDP2( os, &fmtstr[star], f.val, f.wd, f.pc ) \
    540                 } /* if */ \
    541                 return os; \
    542         } /* ?|? */ \
    543         void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); nl( os ); } \
    544 } // distribution
    545 
    546 FloatingPointFMTImpl( double, "%    * ", "%    *.* " )
    547 FloatingPointFMTImpl( long double, "%    *L ", "%    *.*L " )
    548 
    549 //*********************************** Character ***********************************
    550 
    551 forall( dtype ostype | ostream( ostype ) ) {
    552         ostype & ?|?( ostype & os, _Ostream_Manip(char) f ) {
    553                 if ( f.base != 'c' ) {                                                          // bespoke binary/octal/hex format
    554                         _Ostream_Manip(unsigned char) fmtuc @= { f.val, f.wd, f.pc, f.base, {'\0'} };
    555                         fmtuc.flags.pc = f.flags.pc;
    556                         fmtuc.flags.nobsdp = f.flags.nobsdp;
    557 //                      os | fmtuc | nonl;
    558                         (ostype &)(os | fmtuc);
    559                         return os;
    560                 } // if
    561 
    562                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    563 
    564                 #define CFMTNP "% * "
    565                 char fmtstr[sizeof(CFMTNP)];                                            // sizeof includes '\0'
    566                 memcpy( &fmtstr, CFMTNP, sizeof(CFMTNP) );
    567                 int star = 1;                                                                           // position before first '*'
    568 
    569                 // Insert flags into spaces before '*', from right to left.
    570                 if ( f.flags.left ) { fmtstr[star] = '-'; star -= 1; }
    571                 fmtstr[star] = '%';
    572 
    573                 fmtstr[sizeof(CFMTNP)-2] = f.base;                                      // sizeof includes '\0'
    574                 // printf( "%d %s\n", f.wd, &fmtstr[star] );
    575                 fmt( os, &fmtstr[star], f.wd, f.val );
    576                 return os;
    577         } // ?|?
    578         void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); nl( os ); }
    579 } // distribution
    580 
    581 //*********************************** C String ***********************************
    582 
    583 forall( dtype ostype | ostream( ostype ) ) {
    584         ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ) {
    585                 if ( ! f.val ) return os;                                               // null pointer ?
    586 
    587                 if ( f.base != 's' ) {                                                  // bespoke binary/octal/hex format
    588                         _Ostream_Manip(unsigned char) fmtuc @= { 0, f.wd, f.pc, f.base, {'\0'} };
    589                         fmtuc.flags.pc = f.flags.pc;
    590                         fmtuc.flags.nobsdp = f.flags.nobsdp;
    591                         for ( unsigned int i = 0; f.val[i] != '\0'; i += 1 ) {
    592                                 fmtuc.val = f.val[i];
    593 //                              os | fmtuc | nonl;
    594                                 (ostype &)(os | fmtuc);
    595                         } // for
    596                         return os;
    597                 } // if
    598 
    599                 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    600 
    601                 #define SFMTNP "% * "
    602                 #define SFMTP "% *.* "
    603                 char fmtstr[sizeof(SFMTP)];                                             // sizeof includes '\0'
    604                 if ( ! f.flags.pc ) memcpy( &fmtstr, SFMTNP, sizeof(SFMTNP) );
    605                 else memcpy( &fmtstr, SFMTP, sizeof(SFMTP) );
    606                 int star = 1;                                                                   // position before first '*'
    607 
    608                 // Insert flags into spaces before '*', from right to left.
    609                 if ( f.flags.left ) { fmtstr[star] = '-'; star -= 1; }
    610                 fmtstr[star] = '%';
    611 
    612                 if ( ! f.flags.pc ) {                                                   // no precision
    613                         // printf( "%d %s\n", f.wd, &fmtstr[star] );
    614                         fmtstr[sizeof(SFMTNP)-2] = f.base;                      // sizeof includes '\0'
    615                         fmt( os, &fmtstr[star], f.wd, f.val );
    616                 } else {                                                                                // precision
    617                         fmtstr[sizeof(SFMTP)-2] = f.base;                       // sizeof includes '\0'
    618                         // printf( "%d %d %s\n", f.wd, f.pc, &fmtstr[star] );
    619                         fmt( os, &fmtstr[star], f.wd, f.pc, f.val );
    620                 } // if
    621                 return os;
    622         } // ?|?
    623         void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); nl( os ); }
    624 } // distribution
    625 
    626 
    627 //*********************************** Istream ***********************************
    628 
     412//---------------------------------------
    629413
    630414forall( dtype istype | istream( istype ) ) {
     
    653437
    654438        istype & ?|?( istype & is, signed char & sc ) {
    655                 fmt( is, "%hhi", &sc );
     439                fmt( is, "%hhd", &sc );
    656440                return is;
    657441        } // ?|?
    658442
    659443        istype & ?|?( istype & is, unsigned char & usc ) {
    660                 fmt( is, "%hhi", &usc );
     444                fmt( is, "%hhu", &usc );
    661445                return is;
    662446        } // ?|?
    663447
    664448        istype & ?|?( istype & is, short int & si ) {
    665                 fmt( is, "%hi", &si );
     449                fmt( is, "%hd", &si );
    666450                return is;
    667451        } // ?|?
    668452
    669453        istype & ?|?( istype & is, unsigned short int & usi ) {
    670                 fmt( is, "%hi", &usi );
     454                fmt( is, "%hu", &usi );
    671455                return is;
    672456        } // ?|?
    673457
    674458        istype & ?|?( istype & is, int & i ) {
    675                 fmt( is, "%i", &i );
     459                fmt( is, "%d", &i );
    676460                return is;
    677461        } // ?|?
    678462
    679463        istype & ?|?( istype & is, unsigned int & ui ) {
    680                 fmt( is, "%i", &ui );
     464                fmt( is, "%u", &ui );
    681465                return is;
    682466        } // ?|?
    683467
    684468        istype & ?|?( istype & is, long int & li ) {
    685                 fmt( is, "%li", &li );
     469                fmt( is, "%ld", &li );
    686470                return is;
    687471        } // ?|?
    688472
    689473        istype & ?|?( istype & is, unsigned long int & ulli ) {
    690                 fmt( is, "%li", &ulli );
     474                fmt( is, "%lu", &ulli );
    691475                return is;
    692476        } // ?|?
    693477
    694478        istype & ?|?( istype & is, long long int & lli ) {
    695                 fmt( is, "%lli", &lli );
     479                fmt( is, "%lld", &lli );
    696480                return is;
    697481        } // ?|?
    698482
    699483        istype & ?|?( istype & is, unsigned long long int & ulli ) {
    700                 fmt( is, "%lli", &ulli );
     484                fmt( is, "%llu", &ulli );
    701485                return is;
    702486        } // ?|?
     
    721505        istype & ?|?( istype & is, float _Complex & fc ) {
    722506                float re, im;
    723                 fmt( is, "%f%fi", &re, &im );
     507                fmt( is, "%g%gi", &re, &im );
    724508                fc = re + im * _Complex_I;
    725509                return is;
     
    761545} // distribution
    762546
    763 //*********************************** Manipulators ***********************************
    764 
     547_Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; }
    765548forall( dtype istype | istream( istype ) )
    766 istype & ?|?( istype & is, _Istream_Cstr f ) {
    767         // skip xxx
    768         if ( ! f.s ) {
    769                 // printf( "skip %s\n", f.scanset );
    770                 fmt( is, f.scanset, "" );                                               // no input arguments
    771                 return is;
    772         } // if
    773         size_t len = 0;
    774         if ( f.scanset ) len = strlen( f.scanset );
    775         char fmtstr[len + 16];
    776         int start = 1;
    777         fmtstr[0] = '%';
    778         if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; }
    779         if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); }
    780         // cstr %s, %*s, %ws, %*ws
    781         if ( ! f.scanset ) {
    782                 fmtstr[start] = 's'; fmtstr[start + 1] = '\0';
    783                 // printf( "cstr %s\n", fmtstr );
    784                 fmt( is, fmtstr, f.s );
    785                 return is;
    786         } // if
    787         // incl %[xxx],  %*[xxx],  %w[xxx],  %*w[xxx]
    788         // excl %[^xxx], %*[^xxx], %w[^xxx], %*w[^xxx]
    789         fmtstr[start] = '['; start += 1;
    790         if ( f.flags.inex ) { fmtstr[start] = '^'; start += 1; }
    791         strcpy( &fmtstr[start], f.scanset );                            // copy includes '\0'
    792         len += start;
    793         fmtstr[len] = ']'; fmtstr[len + 1] = '\0';
    794         // printf( "incl/excl %s\n", fmtstr );
    795         fmt( is, fmtstr, f.s );
     549istype & ?|?( istype & is, _Istream_cstrUC cstr ) {
     550        fmt( is, "%s", cstr.s );
    796551        return is;
    797 } // ?|?
    798 
    799 #define InputFMTImpl( T, CODE ) \
    800 forall( dtype istype | istream( istype ) ) \
    801 istype & ?|?( istype & is, _Istream_Manip(T) f ) { \
    802         enum { size = 16 }; \
    803         char fmtstr[size]; \
    804         if ( f.wd == -1 || strcmp( CODE, "c" ) == 0 ) { /* ignore width with "c" */     \
    805                 snprintf( fmtstr, size, "%%%s%s", f.ignore ? "*" : "", CODE ); \
    806         } else { \
    807                 snprintf( fmtstr, size, "%%%s%d%s", f.ignore ? "*" : "", f.wd, CODE ); \
    808         } /* if */ \
    809         /* printf( "%d %s %p\n", f.wd, fmtstr, &f.val ); */ \
    810         fmt( is, fmtstr, &f.val ); \
    811         return is; \
    812 } // ?|?
    813 
    814 InputFMTImpl( char, "c" )
    815 InputFMTImpl( signed char, "hhi" )
    816 InputFMTImpl( unsigned char, "hhi" )
    817 InputFMTImpl( signed short int, "hi" )
    818 InputFMTImpl( unsigned short int, "hi" )
    819 InputFMTImpl( signed int, "i" )
    820 InputFMTImpl( unsigned int, "i" )
    821 InputFMTImpl( signed long int, "li" )
    822 InputFMTImpl( unsigned long int, "li" )
    823 InputFMTImpl( signed long long int, "lli" )
    824 InputFMTImpl( unsigned long long int, "lli" )
    825 
    826 InputFMTImpl( float, "f" )
    827 InputFMTImpl( double, "lf" )
    828 InputFMTImpl( long double, "Lf" )
    829 
     552} // cstr
     553
     554_Istream_cstrC cstr( char * str, int size ) { return (_Istream_cstrC){ str, size }; }
    830555forall( dtype istype | istream( istype ) )
    831 istype & ?|?( istype & is, _Istream_Manip(float _Complex) fc ) {
    832         float re, im;
    833         _Istream_Manip(float) fmtuc @= { re, fc.wd, fc.ignore };
    834         is | fmtuc;
    835         &fmtuc.val = &im;
    836         is | fmtuc;
    837         if ( ! fc.ignore ) fc.val = re + im * _Complex_I;       // re/im are uninitialized for ignore
     556istype & ?|?( istype & is, _Istream_cstrC cstr ) {
     557        char buf[16];
     558        sprintf( buf, "%%%ds", cstr.size );
     559        fmt( is, buf, cstr.s );
    838560        return is;
    839 } // ?|?
    840 
    841 forall( dtype istype | istream( istype ) )
    842 istype & ?|?( istype & is, _Istream_Manip(double _Complex) dc ) {
    843         double re, im;
    844         _Istream_Manip(double) fmtuc @= { re, dc.wd, dc.ignore };
    845         is | fmtuc;
    846         &fmtuc.val = &im;
    847         is | fmtuc;
    848         if ( ! dc.ignore ) dc.val = re + im * _Complex_I;       // re/im are uninitialized for ignore
    849         return is;
    850 } // ?|?
    851 
    852 forall( dtype istype | istream( istype ) )
    853 istype & ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) {
    854         long double re, im;
    855         _Istream_Manip(long double) fmtuc @= { re, ldc.wd, ldc.ignore };
    856         is | fmtuc;
    857         &fmtuc.val = &im;
    858         is | fmtuc;
    859         if ( ! ldc.ignore ) ldc.val = re + im * _Complex_I;     // re/im are uninitialized for ignore
    860         return is;
    861 } // ?|?
     561} // cstr
    862562
    863563// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.