Ignore:
Timestamp:
Jun 1, 2015, 12:55:33 PM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
6db50d5
Parents:
46cbfe1 (diff), db82596 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into labels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/iostream.c

    r46cbfe1 r76934fb  
    1 // "cfa -c -o iostream.o iostream.c"
    2 // "cfa -v -E iostream.c > iostream_out.c"
    3 // "cfa -CFA iostream.c > iostream_out.c"
    4 // "cfa iostream_out.c"
    5 // "gcc32 iostream_out.c LibCfa/libcfa.a"
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// iostream.c --
     8//
     9// Author           : Richard C. Bilson
     10// Created On       : Wed May 27 17:56:53 2015
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed May 27 18:18:13 2015
     13// Update Count     : 2
     14//
    615
    716#include "iostream.h"
     
    1019//#include <string.h>
    1120//#include <ctype.h>
    12 typedef long unsigned int size_t;
    13 size_t strlen(const char *s);
     21        typedef long unsigned int size_t;
     22        size_t strlen(const char *s);
    1423}
    1524
    1625forall( dtype ostype | ostream( ostype ) )
    1726ostype * ?<<?( ostype *os, char c ) {
    18     return write( os, &c, 1 );
     27        return write( os, &c, 1 );
    1928}
    2029
    2130forall( dtype ostype | ostream( ostype ) )
    2231ostype * ?<<?( ostype *os, int i ) {
    23     char buffer[20];      // larger than the largest integer
    24     sprintf( buffer, "%d", i );
    25     return write( os, buffer, strlen( buffer ) );
     32        char buffer[20];      // larger than the largest integer
     33        sprintf( buffer, "%d", i );
     34        return write( os, buffer, strlen( buffer ) );
    2635}
    2736
    2837forall( dtype ostype | ostream( ostype ) )
    2938ostype * ?<<?( ostype *os, double d ) {
    30     char buffer[32];      // larger than the largest double
    31     sprintf( buffer, "%g", d );
    32     return write( os, buffer, strlen( buffer ) );
     39        char buffer[32];      // larger than the largest double
     40        sprintf( buffer, "%g", d );
     41        return write( os, buffer, strlen( buffer ) );
    3342}
    3443
    3544forall( dtype ostype | ostream( ostype ) )
    3645ostype * ?<<?( ostype *os, const char *cp ) {
    37     return write( os, cp, strlen( cp ) );
     46        return write( os, cp, strlen( cp ) );
    3847}
    3948
    4049forall( dtype istype | istream( istype ) )
    4150istype * ?>>?( istype *is, char *cp ) {
    42     return read( is, cp, 1 );
     51        return read( is, cp, 1 );
    4352}
    4453
    4554forall( dtype istype | istream( istype ) )
    4655istype * ?>>?( istype *is, int *ip ) {
    47     char cur;
     56        char cur;
    4857 
    49     // skip some whitespace
    50     do {
    51         is >> &cur;
    52         if ( fail( is ) || eof( is ) ) return is;
    53     } while ( !( cur >= '0' && cur <= '9' ) );
     58        // skip some whitespace
     59        do {
     60                is >> &cur;
     61                if ( fail( is ) || eof( is ) ) return is;
     62        } while ( !( cur >= '0' && cur <= '9' ) );
    5463 
    55     // accumulate digits
    56     *ip = 0;
    57     while ( cur >= '0' && cur <= '9' ) {
    58         *ip = *ip * 10 + ( cur - '0' );
    59         is >> &cur;
    60         if ( fail( is ) || eof( is ) ) return is;
    61     }
     64        // accumulate digits
     65        *ip = 0;
     66        while ( cur >= '0' && cur <= '9' ) {
     67                *ip = *ip * 10 + ( cur - '0' );
     68                is >> &cur;
     69                if ( fail( is ) || eof( is ) ) return is;
     70        }
    6271 
    63     unread( is, cur );
    64     return is;
     72        unread( is, cur );
     73        return is;
    6574}
     75
     76// Local Variables: //
     77// tab-width: 4 //
     78// compile-command: "cfa iostream.c" //
     79// End: //
Note: See TracChangeset for help on using the changeset viewer.