Changes in src/tests/coroutine/fmtLines.c [a0cfa44:971d9f2]
- File:
-
- 1 edited
-
src/tests/coroutine/fmtLines.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/coroutine/fmtLines.c
ra0cfa44 r971d9f2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fmtLines.cc -- format characters into blocks of 4 and groups of 5 blocks per line7 // fmtLines.cc -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 15 12:25:33 201813 // Update Count : 4212 // Last Modified On : Tue Dec 5 21:56:35 2017 13 // Update Count : 38 14 14 // 15 15 … … 21 21 int g, b; // global because used in destructor 22 22 }; 23 24 void ?{}( Format & fmt ) { 25 resume( fmt ); // prime (start) coroutine 26 } 27 28 void ^?{}( Format & fmt ) with( fmt ) { 29 if ( g != 0 || b != 0 ) sout | endl; 30 } 23 31 24 32 void main( Format & fmt ) with( fmt ) { … … 38 46 } // main 39 47 40 void ?{}( Format & fmt ) { 41 resume( fmt ); // prime (start) coroutine 42 } 43 44 void ^?{}( Format & fmt ) with( fmt ) { 45 if ( g != 0 || b != 0 ) sout | endl; 46 } 47 48 void format( Format & fmt ) { 48 void prt( Format & fmt, char ch ) { 49 fmt.ch = ch; 49 50 resume( fmt ); 50 51 } // prt 51 52 52 53 int main() { 53 Format fmt; 54 Format fmt; // format characters into blocks of 4 and groups of 5 blocks per line 55 char ch; 54 56 55 eof: for ( ;; ) { // read until end of file56 sin | fmt.ch;// read one character57 if ( eof( sin ) ) break eof; // eof ?58 format( fmt); // push character for formatting57 Eof: for ( ;; ) { // read until end of file 58 sin | ch; // read one character 59 if ( eof( sin ) ) break Eof; // eof ? 60 prt( fmt, ch ); // push character for formatting 59 61 } // for 60 62 } // main
Note:
See TracChangeset
for help on using the changeset viewer.