Changeset 6de9f4a for src/libcfa
- Timestamp:
- Sep 11, 2017, 5:15:47 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- cd218e8
- Parents:
- 7b1d5ec
- Location:
- src/libcfa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/iostream
r7b1d5ec r6de9f4a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 24 08:14:29201713 // Update Count : 13 312 // Last Modified On : Mon Sep 11 09:17:07 2017 13 // Update Count : 137 14 14 // 15 15 16 16 #pragma once 17 17 18 #include <uchar.h> 19 #include <wchar.h> 18 20 #include "iterator" 19 21 … … 78 80 79 81 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * ); 82 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char16_t * ); 83 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char32_t * ); 84 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const wchar_t * ); 80 85 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * ); 81 86 … … 118 123 119 124 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, char & ); 125 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, signed char & ); 126 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned char & ); 120 127 121 128 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, short int & ); -
src/libcfa/iostream.c
r7b1d5ec r6de9f4a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 24 08:41:53201713 // Update Count : 4 0512 // Last Modified On : Mon Sep 11 09:21:24 2017 13 // Update Count : 420 14 14 // 15 15 … … 145 145 146 146 forall( dtype ostype | ostream( ostype ) ) 147 ostype * ?|?( ostype * os, const char * cp) {147 ostype * ?|?( ostype * os, const char * str ) { 148 148 enum { Open = 1, Close, OpenClose }; 149 149 static const unsigned char mask[256] @= { … … 161 161 }; // mask 162 162 163 if ( cp[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator163 if ( str[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator 164 164 165 165 // first character IS NOT spacing or closing punctuation => add left separator 166 unsigned char ch = cp[0]; // must make unsigned166 unsigned char ch = str[0]; // must make unsigned 167 167 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 168 168 fmt( os, "%s", sepGetCur( os ) ); … … 173 173 174 174 // last character IS spacing or opening punctuation => turn off separator for next item 175 size_t len = strlen( cp);176 ch = cp[len - 1]; // must make unsigned175 size_t len = strlen( str ); 176 ch = str[len - 1]; // must make unsigned 177 177 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 178 178 sepOn( os ); … … 181 181 } // if 182 182 if ( ch == '\n' ) setNL( os, true ); // check *AFTER* sepPrt call above as it resets NL flag 183 return write( os, cp, len ); 183 return write( os, str, len ); 184 } // ?|? 185 186 forall( dtype ostype | ostream( ostype ) ) 187 ostype * ?|?( ostype * os, const char16_t * str ) { 188 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 189 fmt( os, "%ls", str ); 190 return os; 191 } // ?|? 192 193 forall( dtype ostype | ostream( ostype ) ) 194 ostype * ?|?( ostype * os, const char32_t * str ) { 195 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 196 fmt( os, "%ls", str ); 197 return os; 198 } // ?|? 199 200 forall( dtype ostype | ostream( ostype ) ) 201 ostype * ?|?( ostype * os, const wchar_t * str ) { 202 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 203 fmt( os, "%ls", str ); 204 return os; 184 205 } // ?|? 185 206 … … 277 298 278 299 forall( dtype istype | istream( istype ) ) 300 istype * ?|?( istype * is, signed char & sc ) { 301 fmt( is, "%hhd", &sc ); 302 return is; 303 } // ?|? 304 305 forall( dtype istype | istream( istype ) ) 306 istype * ?|?( istype * is, unsigned char & usc ) { 307 fmt( is, "%hhu", &usc ); 308 return is; 309 } // ?|? 310 311 forall( dtype istype | istream( istype ) ) 279 312 istype * ?|?( istype * is, short int & si ) { 280 313 fmt( is, "%hd", &si );
Note: See TracChangeset
for help on using the changeset viewer.