ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | Last change
 on this file since 6f15121 was             466fa01, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago | 
        
          | 
add diagrams and example programs
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            876 bytes | 
      
      
| Line |  | 
|---|
| 1 | #include <stdio.h> | 
|---|
| 2 |  | 
|---|
| 3 | typedef struct { | 
|---|
| 4 | void * next; | 
|---|
| 5 | char ch; | 
|---|
| 6 | int g, b; | 
|---|
| 7 | } Fmt; | 
|---|
| 8 |  | 
|---|
| 9 | void comain( Fmt * f ) { | 
|---|
| 10 | if ( __builtin_expect(f->next != 0, 1) ) goto *f->next; | 
|---|
| 11 | f->next = &&s1; | 
|---|
| 12 | for ( ;; ) { | 
|---|
| 13 | for ( f->g = 0; f->g < 5; f->g += 1 ) {                 // groups | 
|---|
| 14 | for ( f->b = 0; f->b < 4; f->b += 1 ) {         // blocks | 
|---|
| 15 | return; | 
|---|
| 16 | s1:;  while ( f->ch == '\n' ) return;         // ignore | 
|---|
| 17 | printf( "%c", f->ch );                                  // print character | 
|---|
| 18 | } | 
|---|
| 19 | printf( " " );                                                          // block separator | 
|---|
| 20 | } | 
|---|
| 21 | printf( "\n" );                                                                 // group separator | 
|---|
| 22 | } | 
|---|
| 23 | } | 
|---|
| 24 |  | 
|---|
| 25 | int main() { | 
|---|
| 26 | Fmt fmt = { NULL }; | 
|---|
| 27 | comain( &fmt );                                                                         // prime | 
|---|
| 28 | for ( ;; ) { | 
|---|
| 29 | scanf( "%c", &fmt.ch );                                                 // direct read into communication variable | 
|---|
| 30 | if ( feof( stdin ) ) break; | 
|---|
| 31 | comain( &fmt ); | 
|---|
| 32 | } | 
|---|
| 33 | if ( fmt.g != 0 || fmt.b != 0 ) printf( "\n" ); | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | // Local Variables: // | 
|---|
| 37 | // tab-width: 4 // | 
|---|
| 38 | // compile-command: "gcc-8 Format.c" // | 
|---|
| 39 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.