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