Changeset a0cfa44 for src/tests


Ignore:
Timestamp:
May 15, 2018, 12:27:10 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, with_gc
Children:
a61fa0bb
Parents:
2b22e050
Message:

simplify

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine/fmtLines.c

    r2b22e050 ra0cfa44  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // fmtLines.cc --
     7// fmtLines.cc -- format characters into blocks of 4 and groups of 5 blocks per line
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  5 21:56:35 2017
    13 // Update Count     : 38
     12// Last Modified On : Tue May 15 12:25:33 2018
     13// Update Count     : 42
    1414//
    1515
     
    2121        int g, b;                                                                                       // global because used in destructor
    2222};
    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 }
    3123
    3224void main( Format & fmt ) with( fmt ) {
     
    4638} // main
    4739
    48 void prt( Format & fmt, char ch ) {
    49         fmt.ch = ch;
     40void ?{}( Format & fmt ) {
     41        resume( fmt );                                                                          // prime (start) coroutine
     42}
     43
     44void ^?{}( Format & fmt ) with( fmt ) {
     45        if ( g != 0 || b != 0 ) sout | endl;
     46}
     47
     48void format( Format & fmt ) {
    5049        resume( fmt );
    5150} // prt
    5251
    5352int main() {
    54         Format fmt;                                                                                     // format characters into blocks of 4 and groups of 5 blocks per line
    55         char ch;
     53        Format fmt;
    5654
    57         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
     55        eof: for ( ;; ) {                                                                       // read until end of file
     56                sin | fmt.ch;                                                                   // read one character
     57          if ( eof( sin ) ) break eof;                                          // eof ?
     58                format( fmt );                                                                  // push character for formatting
    6159        } // for
    6260} // main
Note: See TracChangeset for help on using the changeset viewer.