Changes in src/libcfa/iostream.c [e945826:53ba273]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/iostream.c
re945826 r53ba273 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 30 14:00:53201613 // Update Count : 30212 // Last Modified On : Wed Apr 6 16:13:29 2016 13 // Update Count : 278 14 14 // 15 15 … … 34 34 ostype * ?|?( ostype *os, short int si ) { 35 35 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 36 sepReset( os ); 36 37 prtfmt( os, "%hd", si ); 37 38 return os; … … 41 42 ostype * ?|?( ostype *os, unsigned short int usi ) { 42 43 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 44 sepReset( os ); 43 45 prtfmt( os, "%hu", usi ); 44 46 return os; … … 48 50 ostype * ?|?( ostype *os, int i ) { 49 51 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 52 sepReset( os ); 50 53 prtfmt( os, "%d", i ); 51 54 return os; … … 55 58 ostype * ?|?( ostype *os, unsigned int ui ) { 56 59 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 60 sepReset( os ); 57 61 prtfmt( os, "%u", ui ); 58 62 return os; … … 62 66 ostype * ?|?( ostype *os, long int li ) { 63 67 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 68 sepReset( os ); 64 69 prtfmt( os, "%ld", li ); 65 70 return os; … … 69 74 ostype * ?|?( ostype *os, unsigned long int uli ) { 70 75 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 76 sepReset( os ); 71 77 prtfmt( os, "%lu", uli ); 72 78 return os; … … 76 82 ostype * ?|?( ostype *os, long long int lli ) { 77 83 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 84 sepReset( os ); 78 85 prtfmt( os, "%lld", lli ); 79 86 return os; … … 83 90 ostype * ?|?( ostype *os, unsigned long long int ulli ) { 84 91 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 92 sepReset( os ); 85 93 prtfmt( os, "%llu", ulli ); 86 94 return os; … … 90 98 ostype * ?|?( ostype *os, float f ) { 91 99 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 100 sepReset( os ); 92 101 prtfmt( os, "%g", f ); 93 102 return os; … … 97 106 ostype * ?|?( ostype *os, double d ) { 98 107 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 108 sepReset( os ); 99 109 prtfmt( os, "%.*lg", DBL_DIG, d ); 100 110 return os; … … 104 114 ostype * ?|?( ostype *os, long double ld ) { 105 115 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 116 sepReset( os ); 106 117 prtfmt( os, "%.*Lg", LDBL_DIG, ld ); 107 118 return os; … … 144 155 // opening delimiters 145 156 ['('] : Open, ['['] : Open, ['{'] : Open, 146 ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, 147 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 157 ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 148 158 // closing delimiters 149 159 [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close, … … 152 162 // opening-closing delimiters 153 163 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, 154 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace164 ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace 155 165 }; // mask 156 166 157 if ( cp[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator 158 167 int len = strlen( cp ); 168 // null string => no separator 169 if ( len == 0 ) { sepOff( os ); return os; } 159 170 // first character IS NOT spacing or closing punctuation => add left separator 160 171 unsigned char ch = cp[0]; // must make unsigned … … 162 173 prtfmt( os, "%s", sepGet( os ) ); 163 174 } // if 164 165 // if string starts line, must reset to determine open state because separator is off166 sepReset( os ); // reset separator167 168 175 // last character IS spacing or opening punctuation => turn off separator for next item 169 unsigned int len = strlen( cp ),posn = len - 1;176 unsigned int posn = len - 1; 170 177 ch = cp[posn]; // must make unsigned 171 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 178 if ( mask[ ch ] == Open || mask[ ch ] == OpenClose ) { 179 sepOff( os ); 180 } else { 172 181 sepOn( os ); 173 } else {174 sepOff( os );175 182 } // if 176 183 return write( os, cp, len ); … … 180 187 ostype * ?|?( ostype *os, const void *p ) { 181 188 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 189 sepReset( os ); 182 190 prtfmt( os, "%p", p ); 183 191 return os; 184 192 } // ?|? 193 185 194 186 195 forall( dtype ostype | ostream( ostype ) )
Note:
See TracChangeset
for help on using the changeset viewer.